From be7bea1ca5254ab9eef2554b3c2f80f36873fbc7 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Mon, 18 Mar 2024 12:40:22 +0800 Subject: [PATCH] '123' --- .../storageLocationController.java | 28 ++++++++++++------- .../src/main/resources/application-druid.yml | 4 +-- .../mapper/StorageLocationMapper.java | 9 +++++- .../service/StorageLocationService.java | 9 +++++- .../impl/StorageLocationServiceImpl.java | 12 +++++++- .../storageLocation/StorageLocationMapper.xml | 14 ++++++++-- .../storageLocation/locationConsuming.vue | 18 ++++++++---- .../src/views/storageLocation/locationSet.vue | 12 ++++++-- 8 files changed, 79 insertions(+), 27 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 29bedf0..b02e9c1 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 @@ -6,9 +6,11 @@ import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.storageLocation.domain.StorageLocation; import com.ruoyi.storageLocation.domain.StorageSelected; import com.ruoyi.storageLocation.service.StorageLocationService; @@ -30,6 +32,9 @@ public class storageLocationController extends BaseController @Autowired private RedisCache redisCache; + @Autowired + private RedisLock redisLock; + @Autowired private StorageLocationService storageLocationService; @@ -126,7 +131,8 @@ public class storageLocationController extends BaseController if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ return error("当前库位有人正在操作,请勿操作!"); }else{ - redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); + redisLock.getLock(getLocationZyCacheKey(materialBh), Integer.valueOf(storageExpire), user_name); + //redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name,Integer.valueOf(storageExpire), TimeUnit.SECONDS); return success(); } } @@ -199,7 +205,7 @@ public class storageLocationController extends BaseController String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh)); if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){ - return error("该库位当前有人正在操作,请勿操作!"); + return error("该库位当前有人正在领用操作,请勿操作!"); }else{ // 判断已选库位表是否存在库位信息 StorageSelected storageSelected = storageLocationService.hasStorageLocation(materialBh); @@ -211,8 +217,10 @@ public class storageLocationController extends BaseController } }else{ // 保存至已选库位表并缓存 - redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name); - storageLocationService.saveStorageLocation(user_name,materialBh); + Boolean lock = redisLock.getLock(getLocationLyCacheKey(materialBh), -1, user_name); + if(lock){ + storageLocationService.saveStorageLocation(user_name,materialBh); + } } return success(); } @@ -244,15 +252,15 @@ public class storageLocationController extends BaseController public AjaxResult confirmStorageLocation(@RequestBody String [] materialBhArr) { - storageLocationService.confirmStorageLocation(materialBhArr); + List materialBhList = Arrays.asList(materialBhArr); + storageLocationService.confirmStorageLocation(materialBhList); + + String user_name = getLoginUser().getUsername();//当前登陆者 + storageLocationService.deleteBatchStorageLocation(user_name,materialBhList); - List list = new ArrayList(); for(String materialBh:materialBhArr){ - list.add(getLocationZyCacheKey(materialBh)); + redisCache.deleteObject(getLocationZyCacheKey(materialBh));// 清空占用缓存keys } - Collection> collection = new ArrayList<>(); - collection.add(list); - redisCache.deleteObject(collection);// 清空占用缓存keys return success(); } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index dd7b311..3f1ebba 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,7 +6,7 @@ spring: # 主库数据源 master: driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver - url: jdbc:sqlserver://192.168.9.66:1433;DatabaseName=ry-vue + url: jdbc:sqlserver://192.168.9.130:1433;DatabaseName=ry-vue username: sa password: Itcenter110- # 红本数据库数据源 @@ -23,7 +23,7 @@ spring: enabled: true driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver # 测试数据库 - # url: jdbc:sqlserver://192.168.9.66:1433;DatabaseName=jn_quot + # url: jdbc:sqlserver://192.168.9.130:1433;DatabaseName=jn_quot # 正式数据库 url: jdbc:sqlserver://192.168.9.99:1433;DatabaseName=jn_quot username: sa 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 57c57e8..1bf7d33 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 @@ -35,7 +35,7 @@ public interface StorageLocationMapper * 确认完成认领 * @param materialBhArr */ - void confirmStorageLocation(String[] materialBhArr); + void confirmStorageLocation(List materialBhArr); /** * 判断已选库位表是否存在库位信息 @@ -71,4 +71,11 @@ public interface StorageLocationMapper * @return */ List selectStorageSelectedLocationList(); + + /** + * 批量删除已选库位表记录 + * @param userName + * @param materialBhList + */ + void deleteBatchStorageLocation(@Param("userName") String userName, @Param("list") List materialBhList); } 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 bc19956..926d44e 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 @@ -35,7 +35,7 @@ public interface StorageLocationService * 确认完成认领 * @param materialBhArr */ - void confirmStorageLocation(String[] materialBhArr); + void confirmStorageLocation(List materialBhArr); /** * 判断已选库位表是否存在库位信息 @@ -71,4 +71,11 @@ public interface StorageLocationService * @return */ List selectStorageSelectedLocationList(); + + /** + * 批量删除已选库位表记录 + * @param user_name + * @param materialBhList + */ + void deleteBatchStorageLocation(String user_name, List materialBhList); } 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 8476d87..c79ec62 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 @@ -54,7 +54,7 @@ public class StorageLocationServiceImpl implements StorageLocationService * @param materialBhArr */ @Override - public void confirmStorageLocation(String[] materialBhArr) { + public void confirmStorageLocation(List materialBhArr) { storageLocationMapper.confirmStorageLocation(materialBhArr); } @@ -113,4 +113,14 @@ public class StorageLocationServiceImpl implements StorageLocationService public List selectStorageSelectedLocationList() { return storageLocationMapper.selectStorageSelectedLocationList(); } + + /** + * 批量删除已选库位表记录 + * @param userName + * @param materialBhList + */ + @Override + public void deleteBatchStorageLocation(String userName, List materialBhList) { + storageLocationMapper.deleteBatchStorageLocation(userName,materialBhList); + } } diff --git a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml index e1a0014..487920a 100644 --- a/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/storageLocation/StorageLocationMapper.xml @@ -41,12 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where materialBh = #{materialBh} - + update storageLocation set materialState = '0' materialBh - - #{materialBh} + + #{item} @@ -96,4 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select user_name,material_bh from storageSelected + + + delete from storageSelected where user_name = #{userName} + and material_bh + + #{item} + + diff --git a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue index 5aedb51..1d683f1 100644 --- a/ruoyi-ui/src/views/storageLocation/locationConsuming.vue +++ b/ruoyi-ui/src/views/storageLocation/locationConsuming.vue @@ -4,13 +4,13 @@ -
黄色线芯A区(余{{countA}})
+
黄色线芯A区(可用{{countA}})
-
绿色线芯B区(余{{countB}})
+
绿色线芯B区(可用{{countB}})
-
红色线芯C区(余{{countC}})
+
红色线芯C区(可用{{countC}})
@@ -416,6 +416,7 @@ display: flex; /* 设置为 Flexbox */ justify-content: center; /* 水平居中 */ align-items: center; /* 垂直居中 */ + cursor: pointer; /* 将鼠标形状改为指针形状 */ } .bg-purpleA { background: #e6a700; @@ -501,18 +502,23 @@ computed:{ countA(){ // 使用 find 方法找到第一个符合条件的对象 - return this.materialDetailA.filter(task => task.materialState === '0').length; + return this.materialDetailA.filter(task => task.materialState === '1').length; }, countB(){ // 使用 find 方法找到第一个符合条件的对象 - return this.materialDetailB.filter(task => task.materialState === '0').length; + return this.materialDetailB.filter(task => task.materialState === '1').length; }, countC(){ // 使用 find 方法找到第一个符合条件的对象 - return this.materialDetailC.filter(task => task.materialState === '0').length; + return this.materialDetailC.filter(task => task.materialState === '1').length; } }, methods: { + /*刷新库位信息*/ + refresh(){ + this.getStorageLocation(); + }, + /*获取库位信息*/ getStorageLocation(){ listStorageLocation(this.queryParams).then(response => { diff --git a/ruoyi-ui/src/views/storageLocation/locationSet.vue b/ruoyi-ui/src/views/storageLocation/locationSet.vue index 24732e1..f54f5c5 100644 --- a/ruoyi-ui/src/views/storageLocation/locationSet.vue +++ b/ruoyi-ui/src/views/storageLocation/locationSet.vue @@ -3,13 +3,13 @@
-
黄色线芯A区(余{{countA}})
+
黄色线芯A区(余{{countA}})
-
绿色线芯B区(余{{countB}})
+
绿色线芯B区(余{{countB}})
-
红色线芯C区(余{{countC}})
+
红色线芯C区(余{{countC}})
@@ -248,6 +248,7 @@ display: flex; /* 设置为 Flexbox */ justify-content: center; /* 水平居中 */ align-items: center; /* 垂直居中 */ + cursor: pointer; /* 将鼠标形状改为指针形状 */ } .bg-purpleA { background: #e6a700; @@ -338,6 +339,11 @@ } }, methods: { + /*刷新库位信息*/ + refresh(){ + this.getStorageLocation(); + }, + /*获取库位信息*/ getStorageLocation(){ listStorageLocation(this.queryParams).then(response => {