From a4a795a986b009779f09e9a825c0099aa0bacbb8 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 18 八月 2025 16:41:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java |  102 +++++++++++++++++++++-----------------------------
 1 files changed, 43 insertions(+), 59 deletions(-)

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..5486592 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
@@ -104,8 +104,6 @@
     private static final String BIG_STORAGE_CAGE_IN_TWO_TASK = "big_storage_cage_in_two_task";
     private static final String BIG_STORAGE_CAGE_OUT_TWO_TASK = "big_storage_cage_out_two_task";
 
-    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);
     /**
      * 鐩撮�氭牸瀛�
      */
@@ -116,27 +114,27 @@
     private RedisUtil redisUtil;
 
     @Scheduled(fixedDelay = 1000)
-    public void inBigStorageTask() throws Exception {
+    public void inBigStorageTask() {
         S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class);
         log.info("杩涚墖浠诲姟璇诲彇s7DataZKDLPOne:{}", s7DataZKDLPOne);
         Boolean inkageEntity = s7DataZKDLPOne.getMesControl();
-        if (true != inkageEntity) {
+        if (!inkageEntity) {
             log.info("褰撳墠涓洪潪鑱旀満鐘舵�侊紝缁撴潫杩涚墖浠诲姟");
             return;
         }
-        String requestEntity = s7DataZKDLPOne.getRequestMes().toString();
-        if (!"1".equals(requestEntity)) {
+        Integer requestEntity = s7DataZKDLPOne.getRequestMes();
+        if (1 != requestEntity) {
             log.info("褰撳墠鏈敹鍒拌繘鐗囪姹傦紝缁撴潫杩涚墖浠诲姟");
             return;
         }
-        String mesReplyEntity = s7DataZKDLPOne.getMesReply().toString();
-        if ("1".equals(mesReplyEntity)) {
+        Integer mesReplyEntity = s7DataZKDLPOne.getMesReply();
+        if (1 != mesReplyEntity) {
             log.info("鏈夋鍦ㄦ墽琛岀殑浠诲姟锛岀粨鏉熻繘鐗囦换鍔�");
             return;
         }
 
         List<BigStorageCageTask> inTaskList = new ArrayList();
-        String fromOpcUa = s7DataZKDLPOne.getFrom1().toString();
+        Integer from = s7DataZKDLPOne.getFrom1();
         List<String> glassIdList = new ArrayList<>();
         List<String> requestWords = s7DataZKDLPOne.getIds();
         for (int i = 1; i <= 6; i++) {
@@ -144,7 +142,7 @@
             if (null != requestWord && !requestWord.isEmpty()) {
                 BigStorageCageTask task = new BigStorageCageTask();
                 task.setGlassId(requestWord);
-                task.setStartSlot(Integer.parseInt(fromOpcUa));
+                task.setStartSlot(from);
                 inTaskList.add(task);
                 glassIdList.add(requestWord);
                 continue;
@@ -244,7 +242,7 @@
             if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) {
                 for (BigStorageCageTask task : inTaskList) {
                     GlassInfo info = glassListMap.get(task.getGlassId()).get(0);
-                    HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(),
+                    HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(),info.getGlassType()
                             info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer());
 //            涓存椂鏇存柊鏍煎瓙鐨勫墿浣欏昂瀵革細闃叉鐩搁偦鐜荤拑杩涘悓涓�鏍煎瓙閫犳垚鍓╀綑灏哄涓嶈冻锛岀幓鐠冭秺鐣岀殑鎯呭喌锛屼换鍔″畬鎴愬悗鍐嶆鏇存柊澶х悊鐗囩琛ㄥ墿浣欏搴︼紙鎸夌収绗煎唴鐜荤拑鏁伴噺鏇存柊澶х悊鐗囩鍓╀綑灏哄锛�
                     hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>()
@@ -306,6 +304,9 @@
             }
         } catch (Exception exception) {
             log.info("杩涚墖浠诲姟鎵ц涓彂鐢熷紓甯革細{}", exception);
+            hollowBigStorageCageDetailsService.update(new LambdaUpdateWrapper<HollowBigStorageCageDetails>()
+                    .set(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_TAKE)
+                    .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_NEW));
             hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>()
                     .set(HollowGlassRelationInfo::getGlassId, null)
                     .set(HollowGlassRelationInfo::getTemperingLayoutId, null)
@@ -314,6 +315,7 @@
                     .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
                     .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY)
             );
+            return;
         }
         //鍘嗗彶鏁版嵁鍏ュ簱
         hollowBigStorageCageHistoryTaskService.saveBatch(historyTasks);
@@ -354,33 +356,31 @@
         S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class);
         log.info("鍑虹墖浠诲姟璇诲彇s7DataZKDLPTwo:{}", s7DataZKDLPTwo);
         Boolean inkageEntity = s7DataZKDLPTwo.getMesControl();
-        if (true != inkageEntity) {
+        if (!inkageEntity) {
             log.info("褰撳墠涓洪潪鑱旀満鐘舵�侊紝缁撴潫杩涚墖浠诲姟");
             return;
         }
-        String requestEntity = s7DataZKDLPTwo.getRequestMes().toString();
-        if (!"1".equals(requestEntity)) {
+        Integer requestEntity = s7DataZKDLPTwo.getRequestMes();
+        if (1 != requestEntity) {
             log.info("褰撳墠鏈敹鍒板嚭鐗囪姹傦紝缁撴潫鍑虹墖浠诲姟");
             return;
         }
         //鑾峰彇鍑虹墖浠诲姟琛�
         List<BigStorageCageTask> outTaskList = getOutTaskList(s7DataZKDLPTwo);
-
         if (CollectionUtil.isNotEmpty(outTaskList)) {
             log.info("鏈夋鍦ㄦ墽琛岀殑鍑虹墖浠诲姟锛岀粨鏉熸湰娆″嚭鐗囦换鍔�");
             return;
         }
-
+        //鑾峰彇鎵�鏈夌┖闂茬殑绾胯矾淇℃伅
+        List<Integer> freeLineList = new ArrayList<>();
         //鑾峰彇绌洪棽涓旈鍙栦换鍔$殑鏁版嵁淇℃伅锛屾病鏈変换鍔$洿鎺ヨ蛋鐜荤拑璋冨害
-        HashMap<Integer, Boolean> map = new HashMap<>();
         try {
             if (CMJ1ModbusTcp.checkConnected()) {
-                Boolean oneEntity = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
-                map.put(930, oneEntity);
-            } else {
-                map.put(930, Boolean.FALSE);
+                Boolean oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
+                if (oneState) {
+                    freeLineList.add(930);
+                }
             }
-
         } catch (Exception e) {
             //nothing
             log.info("涓�绾跨┖闂茬姸鎬佽幏鍙栧紓甯�");
@@ -388,46 +388,30 @@
         try {
             S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class);
             log.info("涓┖棰濆璇诲彇{}", s7DataZKExtra);
-            map.put(931, s7DataZKExtra.getIsFree());
-            map.put(932, s7DataZKExtra.getIsFree03());
+            Boolean twoState = s7DataZKExtra.getIsFree();
+            Boolean threeState = s7DataZKExtra.getIsFree03();
+            if (twoState) {
+                freeLineList.add(931);
+            }
+            if (threeState) {
+                freeLineList.add(932);
+            }
         } 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) {
-                    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;
-            }
+        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
+                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                        .in(HollowGlassOutRelationInfo::getCell, freeLineList)
+                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                        .orderByAsc(HollowGlassOutRelationInfo::getUpdateTime).last("limit 1")
+                );
+        if (hollowGlassOutRelationInfo == null) {
+            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
+                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                            .orderByAsc(HollowGlassOutRelationInfo::getUpdateTime).last("limit 1")
+                    );
         }
 
         if (null != hollowGlassOutRelationInfo) {
@@ -436,7 +420,7 @@
 //            鑾峰彇褰撳墠涓┖浠诲姟鏈畬鎴愬嚭鐗囩殑鐜荤拑淇℃伅
             List<HollowGlassQueueInfo> unFinishHollowQueueList = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
                     .eq(HollowGlassQueueInfo::getFlowCardId, hollowGlassOutRelationInfo.getFlowCardId())
-                    .eq(HollowGlassQueueInfo::getCell, cell)
+                    .eq(HollowGlassQueueInfo::getCell, hollowGlassOutRelationInfo.getCell())
                     .eq(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW)
                     .orderByAsc(HollowGlassQueueInfo::getHollowSequence));
             if (CollectionUtil.isNotEmpty(unFinishHollowQueueList)) {

--
Gitblit v1.8.0