Browse Source

AGV入库回库轮询分配到每辆车

k 1 year ago
parent
commit
6309dcb87d

+ 1 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisKey.java

@@ -6,4 +6,5 @@ public class RedisKey {
 
     public static final String AGV01_TASK_NUM = "AGV01_TASK_NUM";
     public static final String AGV02_TASK_NUM = "AGV02_TASK_NUM";
+    public static final String AGV_TASK_CAR_NO = "AGV_TASK_CAR_NO";
 }

+ 32 - 18
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -473,25 +473,30 @@ public class BusinessServiceImpl implements IBusinessService {
      * @return
      */
     private int recommendedWarehousingCarNumber() {
-        if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) == null
-                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) == null) {
-            return  0;
-        } else if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) == null
-                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != null
-                && (int) redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != 0) {
-            return  1;
-        } else if (redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) == null
-                && redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != null
-                && (int) redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != 0) {
-            return  2;
-        } else if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != null
-                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != null) {
-            int agv01 = redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM);
-            int agv02 = redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM);
-            return agv01 > agv02 ? 2 : 1;
+        if (redisCache.getCacheObject(RedisKey.AGV_TASK_CAR_NO) != null) {
+            int carNo = redisCache.getCacheObject(RedisKey.AGV_TASK_CAR_NO);
+            return carNo == 1 ? 2 : 1;
+        }
+
+//        if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) == null
+//                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) == null) {
+//            return  0;
+//        } else if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) == null
+//                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != null
+//                && (int) redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != 0) {
+//            return  1;
+//        } else if (redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) == null
+//                && redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != null
+//                && (int) redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != 0) {
+//            return  2;
+//        } else if (redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM) != null
+//                && redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM) != null) {
+//            int agv01 = redisCache.getCacheObject(RedisKey.AGV01_TASK_NUM);
+//            int agv02 = redisCache.getCacheObject(RedisKey.AGV02_TASK_NUM);
+//            return agv01 > agv02 ? 2 : 1;
+//        }
+            return 0;
         }
-        return 0;
-    }
 
     public Boolean checkLocCanPut(BaseLocationInfo locationFrom, BaseLocationInfo locationTo) {
         boolean con = false;
@@ -573,6 +578,15 @@ public class BusinessServiceImpl implements IBusinessService {
             wcsTask.setExtParam(agvCallDTO.getExtParam());
             wcsTaskList.add(wcsTask);
             businessService.addTask(wcsTask);
+            // 入库任务,记录当前是哪辆车接了任务
+            if (locationTo.getZoneId().equals(Constant.ZONE_TYPE.ZONE_INV.getValue())) {
+                if (locationTo.getFoldedTag().equals("1")) {
+                    redisCache.setCacheObject(RedisKey.AGV_TASK_CAR_NO, 1);
+                } else if (locationTo.getFoldedTag().equals("2")) {
+                    redisCache.setCacheObject(RedisKey.AGV_TASK_CAR_NO, 2);
+                }
+            }
+
             // 入库任务,统计两辆车分别发了多少任务
             if (locationTo.getZoneId().equals(Constant.ZONE_TYPE.ZONE_INV.getValue())) {
                 if (locationTo.getFoldedTag().equals("1")) {