From a545c7b3ced83760ef633dcb04ae60a12aed66ac Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期三, 13 八月 2025 14:33:57 +0800
Subject: [PATCH] 1、中空任务出片逻辑调整 三条线均计算在内(第三条状态不影响优先级):定义线路顺序优先级(lisec优先/韩江优先), 定义全局变量记录上一次的任务线路 1、当一/二线都忙碌/空闲时,获取上一次任务线路,判断条线优先级并执行 2、当部分忙碌/空闲时,按照顺序一线二线依次往下走,直到空闲且有任务为止

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/controller/HollowGlassOutRelationInfoController.java    |    6 ---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java |    6 ---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java                           |   61 +++++++++++++++---------------
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassOutRelationInfoService.java          |    2 -
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java                                    |    9 ----
 5 files changed, 30 insertions(+), 54 deletions(-)

diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/controller/HollowGlassOutRelationInfoController.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/controller/HollowGlassOutRelationInfoController.java
index 7585d13..47cec31 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/controller/HollowGlassOutRelationInfoController.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/controller/HollowGlassOutRelationInfoController.java
@@ -97,12 +97,6 @@
         return Result.build(200, "淇敼鎴愬姛", hollowGlassOutRelationInfoService.dispatchHollowSwitch(flag));
     }
 
-    @ApiOperation("涓┖浼樺厛绾у紑鍏�")
-    @PostMapping("/priorityHollowSwitch")
-    public Result<Boolean> priorityHollowSwitch(Boolean flag) {
-        return Result.build(200, "淇敼鎴愬姛", hollowGlassOutRelationInfoService.priorityHollowSwitch(flag));
-    }
-
     @ApiOperation("鎵嬪姩鐢熸垚鏉庤禌鍏嬫枃浠�")
     @PostMapping("/generateHollowLisecFile")
     public Result<String> generateHollowLisecFile(String flowCardId, int cell, int isForce) throws IOException {
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassOutRelationInfoService.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassOutRelationInfoService.java
index 5760c51..398d723 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassOutRelationInfoService.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassOutRelationInfoService.java
@@ -25,8 +25,6 @@
 
     Boolean dispatchHollowSwitch(Boolean flag);
 
-    Boolean priorityHollowSwitch(Boolean flag);
-
     List<String> hollowTaskList(int cell);
 
     List<HollowGlassQueueInfo> appointHollowTaskDetails(String flowCardId, int cell);
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
index 49bb670..2de2d63 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
@@ -97,12 +97,6 @@
     }
 
     @Override
-    public Boolean priorityHollowSwitch(Boolean flag) {
-        redisUtil.setCacheObject("priorityHollowSwitch", flag);
-        return redisUtil.getCacheObject("priorityHollowSwitch");
-    }
-
-    @Override
     public List<String> hollowTaskList(int cell) {
         //鏌ヨ浠诲姟琛ㄤ腑鏈潯绾挎墍鏈夋湭瀹屾垚鐨勪换鍔′俊鎭�
         List<HollowGlassOutRelationInfo> list = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
index 97cf082..500012b 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -106,6 +106,7 @@
 
     private static final List<Integer> ONE_LINE_FIRST = Arrays.asList(930, 931, 932);
     private static final List<Integer> TWO_LINE_FIRST = Arrays.asList(931, 930, 932);
+    private Integer lastTimeLine = -1;
     /**
      * 鐩撮�氭牸瀛�
      */
@@ -373,14 +374,14 @@
 
         //鑾峰彇绌洪棽涓旈鍙栦换鍔$殑鏁版嵁淇℃伅锛屾病鏈変换鍔$洿鎺ヨ蛋鐜荤拑璋冨害
         HashMap<Integer, Boolean> map = new HashMap<>();
+        Boolean oneState = Boolean.FALSE;
+        Boolean twoState = Boolean.FALSE;
+        Boolean threeState = Boolean.FALSE;
         try {
             if (CMJ1ModbusTcp.checkConnected()) {
-                Boolean oneEntity = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
-                map.put(930, oneEntity);
-            } else {
-                map.put(930, Boolean.FALSE);
+                oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
+                map.put(930, oneState);
             }
-
         } catch (Exception e) {
             //nothing
             log.info("涓�绾跨┖闂茬姸鎬佽幏鍙栧紓甯�");
@@ -388,45 +389,42 @@
         try {
             S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class);
             log.info("涓┖棰濆璇诲彇{}", s7DataZKExtra);
-            map.put(931, s7DataZKExtra.getIsFree());
-            map.put(932, s7DataZKExtra.getIsFree03());
+            twoState = s7DataZKExtra.getIsFree();
+            threeState = s7DataZKExtra.getIsFree03();
+            map.put(931, twoState);
+            map.put(932, threeState);
         } catch (Exception e) {
             //nothing
             log.info("浜�/涓夌嚎绾跨┖闂茬姸鎬佽幏鍙栧紓甯�");
         }
-        List<Integer> resultList = new ArrayList<>();
-        if (redisUtil.getCacheObject("priorityHollowSwitch")) {
-            resultList = TWO_LINE_FIRST;
-        } else {
-            resultList = ONE_LINE_FIRST;
-        }
         HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
         int cell = -1;
-        for (Integer i : resultList) {
-            if (null == hollowGlassOutRelationInfo) {
-                Boolean entity = map.get(i);
-                cell = i;
-                if (null != entity && entity) {
+        if (oneState && twoState || !(oneState || twoState)) {
+            //鑾峰彇涓婁竴娆$殑浠诲姟淇℃伅绾胯矾
+            List<Integer> resultList = lastTimeLine == 930 ? TWO_LINE_FIRST : ONE_LINE_FIRST;
+            for (int i : resultList) {
+                if (null == hollowGlassOutRelationInfo) {
+                    cell = i;
                     hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                             .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                     .eq(HollowGlassOutRelationInfo::getCell, cell)
                                     .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                             );
                 }
-            } else {
-                break;
             }
-        }
-        for (Integer i : resultList) {
-            if (null == hollowGlassOutRelationInfo) {
-                cell = i;
-                hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                        .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                                .eq(HollowGlassOutRelationInfo::getCell, cell)
-                                .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                        );
-            } else {
-                break;
+        } else {
+            for (int i : ONE_LINE_FIRST) {
+                if (null == hollowGlassOutRelationInfo) {
+                    Boolean freeFlag = map.get(i);
+                    cell = i;
+                    if (freeFlag) {
+                        hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
+                                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
+                                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                                );
+                    }
+                }
             }
         }
 
@@ -1064,6 +1062,7 @@
             s7DataZKDLPTwo = new S7DataZKDLPTwo();
             s7DataZKDLPTwo.setMesReply(1);
             s7SerializerZKDLPTwo.write(s7DataZKDLPTwo);
+            lastTimeLine = targetSlot;
         } catch (Exception e) {
             e.printStackTrace();
         }
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java
index 6dee99b..3182e9a 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java
@@ -331,15 +331,6 @@
             dispatchHollowSwitch = redisUtil.getCacheObject("dispatchHollowSwitch");
         }
         jsonObject.append("dispatchHollowSwitch", dispatchHollowSwitch);
-        //璋冨害寮�鍏�
-        boolean priorityHollowSwitch = false;
-        if (redisUtil.getCacheObject("priorityHollowSwitch") == null) {
-            redisUtil.setCacheObject("priorityHollowSwitch", false);
-        } else {
-            dispatchHollowSwitch = redisUtil.getCacheObject("priorityHollowSwitch");
-        }
-        jsonObject.append("dispatchHollowSwitch", dispatchHollowSwitch);
-
         //鐞嗙墖绗间娇鐢ㄦ儏鍐�
         List<Map<String, Object>> bigStorageCageUsage = hollowBigStorageCageService.selectBigStorageCageUsage();
         jsonObject.append("bigStorageCageUsage", bigStorageCageUsage);

--
Gitblit v1.8.0