From f3d00a2c50c3481ef0283919c23b1d44dee715bb Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Tue, 19 Mar 2024 10:05:33 +0800 Subject: [PATCH] '123' --- .../storageLocationController.java | 85 ++++++++++++++++++- .../mapper/StorageLocationMapper.java | 7 ++ .../service/StorageLocationService.java | 6 ++ .../impl/StorageLocationServiceImpl.java | 9 ++ .../storageLocation/StorageLocationMapper.xml | 15 +++- .../api/storageLocation/storageLocation.js | 18 ++++ .../storageLocation/locationConsuming.vue | 12 +-- .../src/views/storageLocation/locationSet.vue | 65 +++++++++----- .../src/views/storageLocation/operlog.vue | 2 +- 9 files changed, 189 insertions(+), 30 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java index 3f6ef58..d05ed79 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/storageLocation/storageLocationController.java @@ -65,31 +65,40 @@ public class storageLocationController extends BaseController for(StorageLocation sl:listA){ String materialBh = sl.getMaterialBh(); String materialState = sl.getMaterialState(); + String userName = sl.getUserName(); String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if("0".equals(materialState)){ if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ redisCache.deleteObject(getLocationZyCacheKey(materialBh)); } + }else if ("1".equals(materialState)){ + redisCache.setCacheObject(getLocationZyCacheKey(materialBh),userName); } } for(StorageLocation sl:listB){ String materialBh = sl.getMaterialBh(); String materialState = sl.getMaterialState(); + String userName = sl.getUserName(); String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if("0".equals(materialState)){ if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ redisCache.deleteObject(getLocationZyCacheKey(materialBh)); } + }else if ("1".equals(materialState)){ + redisCache.setCacheObject(getLocationZyCacheKey(materialBh),userName); } } for(StorageLocation sl:listC){ String materialBh = sl.getMaterialBh(); String materialState = sl.getMaterialState(); + String userName = sl.getUserName(); String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if("0".equals(materialState)){ if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ redisCache.deleteObject(getLocationZyCacheKey(materialBh)); } + }else if ("1".equals(materialState)){ + redisCache.setCacheObject(getLocationZyCacheKey(materialBh),userName); } } return ajaxResult; @@ -126,13 +135,56 @@ public class storageLocationController extends BaseController operlog.setOperlog_guig(storageLocation.getMaterialGuig()); operlog.setOperlog_diany(storageLocation.getMaterialDiany()); operlog.setOperlog_ms(storageLocation.getMaterialMs()); - storageLocationService.addOperlog(operlog); + + storageLocation.setUserName(user_name); return toAjax(storageLocationService.addStorageLocation(storageLocation)); } } + /** + * 修噶库位信息 + */ + @Log(title = "修改库位信息", businessType = BusinessType.UPDATE) + @PostMapping("/addUpdStorageLocation") + public AjaxResult addUpdStorageLocation(@RequestBody StorageLocation storageLocation) + { + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); + if (StringUtils.isNotNull(kw_user_name)) { + + String kw_user2_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + //查询已录入库位信息 + StorageSelected storageSelected = storageLocationService.hasStorageLocation(materialBh); + if (StringUtils.isNotNull(kw_user2_name)&&storageSelected!=null) {//已选择领用,有选择领用记录 + return error("当前库位已被其他人选择领用中,领用人账号:" + kw_user2_name + ",请先删除领用记录,再继续操作!"); + } else { + //插入操作记录表 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Operlog operlog = new Operlog(); + operlog.setOperlog_user_name(user_name); + operlog.setOperlog_date(format.format(new Date())); + operlog.setOperlog_event("修改库位信息"); + operlog.setOperlog_kw(storageLocation.getMaterialBh()); + operlog.setOperlog_zlh(storageLocation.getMaterialZlh()); + operlog.setOperlog_xingh(storageLocation.getMaterialXingh()); + operlog.setOperlog_guig(storageLocation.getMaterialGuig()); + operlog.setOperlog_diany(storageLocation.getMaterialDiany()); + operlog.setOperlog_ms(storageLocation.getMaterialMs()); + storageLocationService.addOperlog(operlog); + + storageLocation.setUserName(user_name); + return toAjax(storageLocationService.addStorageLocation(storageLocation)); + } + }else{ + return error("当前库位或被其他人领用,请刷新重试!"); + } + + } + /** * 校验库位是否已占用 */ @@ -155,6 +207,37 @@ public class storageLocationController extends BaseController } } + /** + * 校验库位是否被领用或者是否是自己录入的 + */ + @Log(title = "校验库位是否被领用或者是否是自己录入的", businessType = BusinessType.OTHER) + @PostMapping("/checkUpdStorageLocation") + public AjaxResult checkUpdStorageLocation(@RequestBody StorageLocation storageLocation) { + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); + if (StringUtils.isNotNull(kw_user_name)) { + + if (!user_name.equals(kw_user_name)) { + return error("当前库位信息非本人录入,不允许修改!"); + } else { + String kw_user2_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + //查询已录入库位信息 + StorageSelected storageSelected = storageLocationService.hasStorageLocation(materialBh); + if (StringUtils.isNotNull(kw_user2_name)&&storageSelected!=null) {//已选择领用,有选择领用记录 + return error("当前库位已被其他人选择领用中,领用人账号:" + kw_user2_name + ",请先删除领用记录,再继续操作!"); + } else { + //查询已录入库位信息 + StorageLocation sl = storageLocationService.selectYlrStorageLocation(materialBh); + return success(sl); + } + } + }else{ + return error("当前库位或被其他人领用,请刷新重试!"); + } + } + /** * 弹窗取消按钮 清除库位缓存 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java index 025f439..5928da4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/mapper/StorageLocationMapper.java @@ -106,4 +106,11 @@ public interface StorageLocationMapper * @return */ List selectOperlogs(Operlog operlog); + + /** + * 查询已录入库位信息 + * @param materialBh + * @return + */ + StorageLocation selectYlrStorageLocation(String materialBh); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java index fa55d7b..c7675bc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/StorageLocationService.java @@ -105,4 +105,10 @@ public interface StorageLocationService * @return */ List selectOperlogs(Operlog operlog); + + /** + * 查询已录入库位信息 + * @param materialBh + */ + StorageLocation selectYlrStorageLocation(String materialBh); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java index 20960c6..4f67840 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/storageLocation/service/impl/StorageLocationServiceImpl.java @@ -163,4 +163,13 @@ public class StorageLocationServiceImpl implements StorageLocationService public List selectOperlogs(Operlog operlog) { return storageLocationMapper.selectOperlogs(operlog); } + + /** + * 查询已录入库位信息 + * @param materialBh + */ + @Override + public StorageLocation selectYlrStorageLocation(String materialBh) { + return storageLocationMapper.selectYlrStorageLocation(materialBh); + } } diff --git a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml index 46f8900..8155b1d 100644 --- a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml @@ -16,15 +16,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" materialGuig = #{materialGuig}, materialDiany = #{materialDiany}, materialMs = #{materialMs}, + userName = #{userName}, materialState = '1' where materialBh = #{materialBh} @@ -144,4 +145,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from operlog where operlog_kw = #{operlog_kw} order by operlog_date desc + + + diff --git a/ruoyi-ui/src/api/storageLocation/storageLocation.js b/ruoyi-ui/src/api/storageLocation/storageLocation.js index e7dde4a..2683172 100644 --- a/ruoyi-ui/src/api/storageLocation/storageLocation.js +++ b/ruoyi-ui/src/api/storageLocation/storageLocation.js @@ -18,6 +18,15 @@ export function addStorageLocation(data) { }) } +// 修改库位信息 +export function addUpdStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation/addUpdStorageLocation', + method: 'post', + data: data + }) +} + // 校验库位是否已占用 export function checkStorageLocation(data) { return request({ @@ -27,6 +36,15 @@ export function checkStorageLocation(data) { }) } +// 校验库位是否被领用或者是否是自己录入的 +export function checkUpdStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation/checkUpdStorageLocation', + method: 'post', + data: data + }) +} + // 弹窗取消按钮 清除库位占用缓存 export function cancelStorageLocation(data) { return request({ diff --git a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue index 236d8ef..0bd6e9e 100644 --- a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue +++ b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue @@ -54,7 +54,7 @@ {{item.materialDiany}} @@ -107,7 +107,7 @@ {{item.materialDiany}} @@ -160,7 +160,7 @@ {{item.materialDiany}} @@ -531,7 +531,6 @@ refresh(){ this.getStorageLocation(); }, - /*获取库位信息*/ getStorageLocation(){ listStorageLocation(this.queryParams).then(response => { @@ -600,6 +599,7 @@ /*===============================================领用操作==========================================*/ // Tag标签页点击事件 handleClick(tab, event) { + this.getStorageLocation(); console.log(tab, event); }, @@ -636,7 +636,7 @@ //校验库位是否被领用 checkStorageLocation(this.form).then(response => { - if(materialBh.indexOf('A-')==0){ + /*if(materialBh.indexOf('A-')==0){ this.selMaterialDetailA.push(item) } if(materialBh.indexOf('B-')==0){ @@ -644,7 +644,7 @@ } if(materialBh.indexOf('C-')==0){ this.selMaterialDetailC.push(item) - } + }*/ this.$message({ message: '已成功选择库位 '+ materialBh, type: 'success' diff --git a/ruoyi-ui/src/views/storageLocation/locationSet.vue b/ruoyi-ui/src/views/storageLocation/locationSet.vue index c8280e0..bd7a025 100644 --- a/ruoyi-ui/src/views/storageLocation/locationSet.vue +++ b/ruoyi-ui/src/views/storageLocation/locationSet.vue @@ -30,7 +30,7 @@ 空闲 - 已用 + 已用 @@ -53,7 +53,7 @@ {{item.materialDiany}} @@ -106,7 +106,7 @@ {{item.materialDiany}} @@ -159,7 +159,7 @@ {{item.materialDiany}} @@ -181,6 +181,7 @@ + @@ -215,8 +216,8 @@ @@ -271,7 +272,7 @@ }