diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java index 7ece41e..35ed432 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java @@ -42,7 +42,7 @@ public class CacheController caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); - caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位号占用状态")); + caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位")); } @PreAuthorize("@ss.hasPermi('monitor:cache:list')") 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 0e6e451..553f8cf 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 @@ -38,13 +38,15 @@ public class storageLocationController extends BaseController @Autowired private ISysConfigService configService; + /*===========================================库位设置==========================================================*/ /** - * 获取库位信息 + * 获取库位占用信息 */ @GetMapping("/list") public AjaxResult list(StorageLocation storageLocation) { AjaxResult ajaxResult = new AjaxResult(); + String user_name = getLoginUser().getUsername();//当前登陆者 List listA = storageLocationService.selectStorageLocationAList(storageLocation); List listB = storageLocationService.selectStorageLocationBList(storageLocation); List listC = storageLocationService.selectStorageLocationCList(storageLocation); @@ -52,6 +54,38 @@ public class storageLocationController extends BaseController ajaxResult.put("materialDetailA",listA); ajaxResult.put("materialDetailB",listB); ajaxResult.put("materialDetailC",listC); + + //根据库位状态 同步更新库位占用缓存-刷新页面时用 + for(StorageLocation sl:listA){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + 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)); + } + } + } + for(StorageLocation sl:listB){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + 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)); + } + } + } + for(StorageLocation sl:listC){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + 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)); + } + } + } return ajaxResult; } @@ -65,13 +99,13 @@ public class storageLocationController extends BaseController String user_name = getLoginUser().getUsername();//当前登陆者 String materialBh = storageLocation.getMaterialBh(); - String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if(StringUtils.isNull(kw_user_name)){ return error("已超过有效录入信息时间,请关闭重新录入!"); }else if(!user_name.equals(kw_user_name)){ return error("已超过有效录入信息时间,当前库位有人正在操作!"); }else{ - redisCache.setCacheObject(getCacheKey(materialBh),user_name); + redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name); return toAjax(storageLocationService.addStorageLocation(storageLocation)); } @@ -89,11 +123,11 @@ public class storageLocationController extends BaseController String user_name = getLoginUser().getUsername();//当前登陆者 String materialBh = storageLocation.getMaterialBh(); - String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ return error("当前库位有人正在操作,请勿操作!"); }else{ - redisCache.setCacheObject(getCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); + redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); return success(); } } @@ -108,22 +142,153 @@ public class storageLocationController extends BaseController String user_name = getLoginUser().getUsername();//当前登陆者 String materialBh = storageLocation.getMaterialBh(); - String kw_user_name = redisCache.getCacheObject(getCacheKey(materialBh)); + String kw_user_name = redisCache.getCacheObject(getLocationZyCacheKey(materialBh)); if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ - redisCache.deleteObject(getCacheKey(materialBh)); + redisCache.deleteObject(getLocationZyCacheKey(materialBh)); + } + return success(); + } + /*===========================================库位设置==========================================================*/ + + /*===========================================库位领用==========================================================*/ + /** + * 获取库位领用信息 + */ + @GetMapping("/lyList") + public AjaxResult lyList(StorageLocation storageLocation) + { + AjaxResult ajaxResult = new AjaxResult(); + String user_name = getLoginUser().getUsername();//当前登陆者 + List listA = storageLocationService.selectStorageLocationAList(storageLocation); + List listB = storageLocationService.selectStorageLocationBList(storageLocation); + List listC = storageLocationService.selectStorageLocationCList(storageLocation); + + ajaxResult.put("materialDetailA",listA); + ajaxResult.put("materialDetailB",listB); + ajaxResult.put("materialDetailC",listC); + + //根据库位状态 同步更新库位占用缓存-刷新页面时用 + for(StorageLocation sl:listA){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if("1".equals(materialState)){ + if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ + redisCache.deleteObject(getLocationLyCacheKey(materialBh)); + } + } + } + for(StorageLocation sl:listB){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if("1".equals(materialState)){ + if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ + redisCache.deleteObject(getLocationLyCacheKey(materialBh)); + } + } + } + for(StorageLocation sl:listC){ + String materialBh = sl.getMaterialBh(); + String materialState = sl.getMaterialState(); + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if("1".equals(materialState)){ + if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ + redisCache.deleteObject(getLocationLyCacheKey(materialBh)); + } + } + } + return ajaxResult; + } + + + + /** + * 校验库位是否被领用 + */ + @Log(title = "校验库位是否被领用", businessType = BusinessType.OTHER) + @PostMapping("/checklyStorageLocation") + public AjaxResult checklyStorageLocation(@RequestBody StorageLocation storageLocation) + { + String storageExpire = configService.selectConfigByKey("storage.expire.ly"); + + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ + return error("当前库位有人正在操作,请勿操作!"); + }else{ + redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name); + return success(); + } + } + + /** + * 清除库位领用缓存 + */ + @Log(title = "清除库位领用缓存", businessType = BusinessType.OTHER) + @PostMapping("/clearLocationLyCacheKey") + public AjaxResult clearLocationLyCacheKey(@RequestBody StorageLocation storageLocation) + { + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){ + redisCache.deleteObject(getLocationLyCacheKey(materialBh)); } return success(); } /** - * 库位缓存键名 + * 确认完成认领 + */ + @Log(title = "确认完成认领", businessType = BusinessType.OTHER) + @PostMapping("/confirmStorageLocation") + public AjaxResult confirmStorageLocation(@RequestBody String [] materialBhArr) + { + + System.out.println(materialBhArr); + /* String storageExpire = configService.selectConfigByKey("storage.expire.ly"); + + String user_name = getLoginUser().getUsername();//当前登陆者 + String materialBh = storageLocation.getMaterialBh(); + + String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); + if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ + return error("当前库位有人正在操作,请勿操作!"); + }else{ + redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name); + return success(); + }*/ + storageLocationService.confirmStorageLocation(materialBhArr); + return success(); + } + + /*===========================================库位领用==========================================================*/ + + + /** + * 库位占用缓存键名 * * @param materialBh 库位号 * @return 缓存键key */ - private String getCacheKey(String materialBh) + private String getLocationZyCacheKey(String materialBh) { - return CacheConstants.STORAGE_LOCATION + materialBh; + return CacheConstants.STORAGE_LOCATION + materialBh + "-ZY"; + } + + /** + * 库位领用缓存键名 + * + * @param materialBh 库位号 + * @return 缓存键key + */ + private String getLocationLyCacheKey(String materialBh) + { + return CacheConstants.STORAGE_LOCATION + materialBh + "-LY"; } } 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 85b3ae5..00d21e5 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 @@ -28,4 +28,10 @@ public interface StorageLocationMapper * @return */ int addStorageLocation(StorageLocation storageLocation); + + /** + * 确认完成认领 + * @param materialBhArr + */ + void confirmStorageLocation(String[] materialBhArr); } 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 4757a27..8496e16 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 @@ -29,4 +29,10 @@ public interface StorageLocationService * @return */ int addStorageLocation(StorageLocation storageLocation); + + /** + * 确认完成认领 + * @param materialBhArr + */ + void confirmStorageLocation(String[] materialBhArr); } 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 96a274a..a78f160 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 @@ -47,4 +47,13 @@ public class StorageLocationServiceImpl implements StorageLocationService public int addStorageLocation(StorageLocation storageLocation) { return storageLocationMapper.addStorageLocation(storageLocation); } + + /** + * 确认完成认领 + * @param materialBhArr + */ + @Override + public void confirmStorageLocation(String[] materialBhArr) { + storageLocationMapper.confirmStorageLocation(materialBhArr); + } } diff --git a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml index ead1c72..dd5fe0d 100644 --- a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml @@ -40,4 +40,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where materialBh = #{materialBh} + + update storageLocation set materialState = '0' + + materialBh + + #{materialBh} + + + + + diff --git a/ruoyi-ui/src/api/storageLocation/storageConsuming.js b/ruoyi-ui/src/api/storageLocation/storageConsuming.js index 61fd134..adb18d8 100644 --- a/ruoyi-ui/src/api/storageLocation/storageConsuming.js +++ b/ruoyi-ui/src/api/storageLocation/storageConsuming.js @@ -3,34 +3,34 @@ import request from '@/utils/request' // 获取库位信息 export function listStorageLocation(query) { return request({ - url: '/storageLocation/storageLocation/list', + url: '/storageLocation/storageLocation/lyList', method: 'get', params: query }) } -// 录入库位信息 -export function addStorageLocation(data) { - return request({ - url: '/storageLocation/storageLocation', - method: 'post', - data: data - }) -} - -// 校验库位是否已占用 +// 校验库位是否被领用 export function checkStorageLocation(data) { return request({ - url: '/storageLocation/storageLocation/checkStorageLocation', + url: '/storageLocation/storageLocation/checklyStorageLocation', method: 'post', data: data }) } -// 弹窗取消按钮 清除库位缓存 -export function cancelStorageLocation(data) { +// 清除库位领用缓存 +export function clearLocationLyCacheKey(data) { return request({ - url: '/storageLocation/storageLocation/cancelStorageLocation', + url: '/storageLocation/storageLocation/clearLocationLyCacheKey', + method: 'post', + data: data + }) +} + +// 确认完成认领 +export function confirmStorageLocation(data) { + return request({ + url: '/storageLocation/storageLocation/confirmStorageLocation', method: 'post', data: data }) diff --git a/ruoyi-ui/src/api/storageLocation/storageLocation.js b/ruoyi-ui/src/api/storageLocation/storageLocation.js index 61fd134..e7dde4a 100644 --- a/ruoyi-ui/src/api/storageLocation/storageLocation.js +++ b/ruoyi-ui/src/api/storageLocation/storageLocation.js @@ -27,7 +27,7 @@ export function checkStorageLocation(data) { }) } -// 弹窗取消按钮 清除库位缓存 +// 弹窗取消按钮 清除库位占用缓存 export function cancelStorageLocation(data) { return request({ url: '/storageLocation/storageLocation/cancelStorageLocation', diff --git a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue index 3209e24..ae16c8d 100644 --- a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue +++ b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue @@ -81,11 +81,11 @@ 状态 - 空闲 - + 空闲 + - 占用 - + 占用 + - 空闲 - + 空闲 + - 占用 - + 占用 +