From 0961a4ebfeacaed4787c59e017691775a339616f Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 10 四月 2025 14:51:28 +0800
Subject: [PATCH] 1、中空任务界面改造,新增第三条线任务判

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java |  148 ++++++++++++++++++++++++++++--------------------
 1 files changed, 86 insertions(+), 62 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 fa45fe7..7e06a03 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
@@ -181,7 +181,7 @@
             }
         }
         //瓒呭ぇ灏哄
-        if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() > slotMaxthickness) {
+        if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() >= slotMaxthickness) {
             int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                     .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT)
                     .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL));
@@ -207,17 +207,51 @@
         //璁$畻鐩爣鏍煎瓙
         List<HollowBigStorageCageHistoryTask> historyTasks = new ArrayList<>();
         try {
-            for (BigStorageCageTask task : inTaskList) {
-                GlassInfo info = glassListMap.get(task.getGlassId()).get(0);
-                HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(),
-                        info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer());
+            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(),
+                            info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer());
 //            涓存椂鏇存柊鏍煎瓙鐨勫墿浣欏昂瀵革細闃叉鐩搁偦鐜荤拑杩涘悓涓�鏍煎瓙閫犳垚鍓╀綑灏哄涓嶈冻锛岀幓鐠冭秺鐣岀殑鎯呭喌锛屼换鍔″畬鎴愬悗鍐嶆鏇存柊澶х悊鐗囩琛ㄥ墿浣欏搴︼紙鎸夌収绗煎唴鐜荤拑鏁伴噺鏇存柊澶х悊鐗囩鍓╀綑灏哄锛�
-                hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>()
-                        .set(HollowBigStorageCage::getRemainWidth, bigStorageDTO.getRemainWidth() - Math.max(info.getWidth(), info.getHeight()) - glassGap)
-                        .eq(HollowBigStorageCage::getSlot, bigStorageDTO.getSlot()));
-                task.setTargetSlot(bigStorageDTO.getSlot());
-                task.setGlassId(info.getGlassId());
-                bigStorageCageTaskService.updateTaskMessage(BIG_STORAGE_CAGE_IN_TWO_TASK, task);
+                    hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>()
+                            .set(HollowBigStorageCage::getRemainWidth, bigStorageDTO.getRemainWidth() - Math.max(info.getWidth(), info.getHeight()) - glassGap)
+                            .eq(HollowBigStorageCage::getSlot, bigStorageDTO.getSlot()));
+                    task.setTargetSlot(bigStorageDTO.getSlot());
+                    task.setGlassId(info.getGlassId());
+                    bigStorageCageTaskService.updateTaskMessage(BIG_STORAGE_CAGE_IN_TWO_TASK, task);
+                    //瀛樻斁鍘嗗彶浠诲姟
+                    HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask();
+                    BeanUtils.copyProperties(task, historyTask);
+                    historyTask.setTaskType(Const.BIG_STORAGE_AFTER_IN);
+                    historyTask.setGlassCount(glassInfoList.size());
+                    historyTask.setTaskState(Const.ENGINEERING_NEW);
+                    historyTasks.add(historyTask);
+                    //瀛樻斁璇︽儏鏁版嵁
+                    HollowBigStorageCageDetails cageDetails = new HollowBigStorageCageDetails();
+                    BeanUtils.copyProperties(bigStorageDTO, cageDetails);
+                    BeanUtils.copyProperties(info, cageDetails);
+                    cageDetails.setState(Const.GLASS_STATE_NEW);
+                    cageDetails.setSequence(bigStorageDTO.getSlotSequence());
+                    cageDetails.setGap(glassGap);
+                    cageDetails.setId(null);
+                    hollowBigStorageCageDetailsService.save(cageDetails);
+                    hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>()
+                            .set(HollowGlassRelationInfo::getGlassId, cageDetails.getGlassId())
+                            .set(HollowGlassRelationInfo::getTemperingLayoutId, cageDetails.getTemperingLayoutId())
+                            .set(HollowGlassRelationInfo::getTemperingFeedSequence, cageDetails.getTemperingFeedSequence())
+                            .set(HollowGlassRelationInfo::getEngineerId, cageDetails.getEngineerId())
+                            .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY)
+                            .eq(HollowGlassRelationInfo::getFlowCardId, bigStorageDTO.getFlowCardId())
+                            .eq(HollowGlassRelationInfo::getLayer, bigStorageDTO.getLayer())
+                            .eq(HollowGlassRelationInfo::getVirtualSlot, bigStorageDTO.getVirtualSlot())
+                            .eq(HollowGlassRelationInfo::getSlotSequence, bigStorageDTO.getSlotSequence())
+                            .eq(HollowGlassRelationInfo::getHollowSequence, bigStorageDTO.getHollowSequence())
+                    );
+                }
+            } else {
+                BigStorageCageTask task = inTaskList.get(0);
+                task.setTargetSlot(THROUGH_SLOT);
+                bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_two_task", task);
                 //瀛樻斁鍘嗗彶浠诲姟
                 HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask();
                 BeanUtils.copyProperties(task, historyTask);
@@ -225,27 +259,18 @@
                 historyTask.setGlassCount(glassInfoList.size());
                 historyTask.setTaskState(Const.ENGINEERING_NEW);
                 historyTasks.add(historyTask);
-                //瀛樻斁璇︽儏鏁版嵁
+                GlassInfo info = glassInfoList.get(0);
                 HollowBigStorageCageDetails cageDetails = new HollowBigStorageCageDetails();
-                BeanUtils.copyProperties(bigStorageDTO, cageDetails);
                 BeanUtils.copyProperties(info, cageDetails);
+                cageDetails.setSlot(THROUGH_SLOT);
                 cageDetails.setState(Const.GLASS_STATE_NEW);
-                cageDetails.setSequence(bigStorageDTO.getSlotSequence());
+                cageDetails.setDeviceId(0);
+                cageDetails.setSequence(0);
+                cageDetails.setHollowSequence(0);
                 cageDetails.setGap(glassGap);
+                cageDetails.setFilmsId(info.getFilmsid());
                 cageDetails.setId(null);
                 hollowBigStorageCageDetailsService.save(cageDetails);
-                hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>()
-                        .set(HollowGlassRelationInfo::getGlassId, cageDetails.getGlassId())
-                        .set(HollowGlassRelationInfo::getTemperingLayoutId, cageDetails.getTemperingLayoutId())
-                        .set(HollowGlassRelationInfo::getTemperingFeedSequence, cageDetails.getTemperingFeedSequence())
-                        .set(HollowGlassRelationInfo::getEngineerId, cageDetails.getEngineerId())
-                        .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY)
-                        .eq(HollowGlassRelationInfo::getFlowCardId, bigStorageDTO.getFlowCardId())
-                        .eq(HollowGlassRelationInfo::getLayer, bigStorageDTO.getLayer())
-                        .eq(HollowGlassRelationInfo::getVirtualSlot, bigStorageDTO.getVirtualSlot())
-                        .eq(HollowGlassRelationInfo::getSlotSequence, bigStorageDTO.getSlotSequence())
-                        .eq(HollowGlassRelationInfo::getHollowSequence, bigStorageDTO.getHollowSequence())
-                );
             }
         } catch (Exception exception) {
             log.info("杩涚墖浠诲姟鎵ц涓彂鐢熷紓甯革細{}", exception);
@@ -290,44 +315,41 @@
         }
 
         //鑾峰彇绌洪棽涓旈鍙栦换鍔$殑鏁版嵁淇℃伅锛屾病鏈変换鍔$洿鎺ヨ蛋鐜荤拑璋冨害
+        HashMap<Integer, ReadWriteEntity> map = new HashMap<>();
         ReadWriteEntity oneEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree");
+        ReadWriteEntity twoEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree");
+        ReadWriteEntity threeEntity = miloService.readFromOpcUa("ZKQ3.ZKQ3.isFree");
+        map.put(930, oneEntity);
+        map.put(931, twoEntity);
+        map.put(932, threeEntity);
         HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
         int cell = -1;
-        //鏉庤禌鍏嬬嚎闇�瑕佽幏鍙栭煩姹焢lc鐨勭嚎璺┖闂茬姸鎬侊細10000000绗�8浣嶄负 1琛ㄧず蹇欑 0琛ㄧず绌洪棽
-        if (null != oneEntity.getValue() && "1".equals(oneEntity.getValue() + "")) {
-            cell = 930;
-            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                            .eq(HollowGlassOutRelationInfo::getCell, cell)
-                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                    );
+        for (int i = 930; i < 931; i++) {
+            if (null == hollowGlassOutRelationInfo) {
+                ReadWriteEntity entity = map.get(i);
+                cell = i;
+                if (null != entity.getValue() && ("1".equals(entity.getValue() + "") || Boolean.parseBoolean(twoEntity.getValue() + ""))) {
+                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
+                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
+                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                            );
+                }
+            } else {
+                break;
+            }
         }
-
-        ReadWriteEntity twoEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree");
-        if (null == hollowGlassOutRelationInfo && null != twoEntity.getValue() && Boolean.parseBoolean(twoEntity.getValue() + "")) {
-            cell = 931;
-            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                            .eq(HollowGlassOutRelationInfo::getCell, cell)
-                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                    );
-        }
-        if (null == hollowGlassOutRelationInfo) {
-            cell = 930;
-            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                            .eq(HollowGlassOutRelationInfo::getCell, cell)
-                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                    );
-        }
-
-        if (null == hollowGlassOutRelationInfo) {
-            cell = 931;
-            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                            .eq(HollowGlassOutRelationInfo::getCell, cell)
-                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                    );
+        for (int i = 930; i <= 932; i++) {
+            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;
+            }
         }
 
         if (null != hollowGlassOutRelationInfo) {
@@ -742,7 +764,8 @@
     }
 
 
-    private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, int targetSlot, int isPair, int totalLayer, int isForce) throws Exception {
+    private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list,
+                                                                                    int targetSlot, int isPair, int totalLayer, int isForce) throws Exception {
         List<T> resultList = new ArrayList<>();
         List<T> tempList = new ArrayList<>();
         int taskType = Const.BIG_STORAGE_AFTER_OUT;
@@ -795,7 +818,8 @@
      * @param totalLayer
      * @return
      */
-    private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, int targetSlot, int state, int taskType, int totalLayer, int isForce) {
+    private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName,
+                                                                                 int targetSlot, int state, int taskType, int totalLayer, int isForce) {
         //浠诲姟鏁版嵁:鑾峰彇杞﹀瓙瀛樻斁鐜荤拑鏈�澶ф暟閲�,鐜荤拑闂撮殧
         List<T> templist = new ArrayList<>();
         //鎵撹溅鍓╀綑灏哄

--
Gitblit v1.8.0