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 |  173 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 104 insertions(+), 69 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 b467f80..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
@@ -145,7 +145,8 @@
         for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) {
             if (entry.getValue() > 1) {
                 log.info("杩涚墖鐜荤拑{}瀛樺湪鐩稿悓锛岀粨鏉熸湰娆′换鍔�", entry.getKey());
-                //todo:鍚憄lc鍙戦�佹姤璀�
+                //鍚憄lc鍙戦�佹姤璀�:鍚屼竴杞﹁繘鐗囩幓鐠冨瓨鍦ㄧ浉鍚�
+                miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 2));
                 return;
             }
         }
@@ -153,14 +154,16 @@
                 .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO));
         if (CollectionUtil.isNotEmpty(detailsList)) {
             log.info("鐞嗙墖绗煎瓨鍦ㄧ浉鍚岀殑杩涚墖鐜荤拑{}锛岀粨鏉熸湰娆′换鍔�", detailsList);
-            //todo:鍚憄lc鍙戦�佹姤璀�
+            //鍚憄lc鍙戦�佹姤璀�:鐞嗙墖绗煎瓨鍦ㄧ浉鍚岀殑杩涚墖鐜荤拑
+            miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 4));
             return;
         }
         List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList));
 
         if (glassInfoList.size() != inTaskList.size()) {
             log.info("杩涚墖浠诲姟鏁伴噺{}涓庣幓鐠冩暟閲弡}涓嶅尮閰嶏紝缁撴潫鏈杩涚墖", inTaskList.size(), glassInfoList.size());
-            //todo:鍚憄lc鍙戦�佹姤璀�
+            //鍚憄lc鍙戦�佹姤璀�:杩涚墖浠诲姟鏁伴噺涓庣郴缁熸煡璇㈠埌鐨勭幓鐠冩暟閲忎笉鍖归厤
+            miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 8));
             return;
         }
         //鎸夌収鐜荤拑鍘氬害鍒嗙粍锛屽垽鏂墿浣欐牸瀛愭槸鍚﹀彲浠ュ瓨鏀�
@@ -172,18 +175,20 @@
                     .ge(HollowBigStorageCage::getMaxThickness, entry.getKey()));
             if (count < entry.getValue()) {
                 log.info("绗煎唴鏍煎瓙鍓╀綑鏁伴噺涓嶈冻锛岀粨鏉熸湰娆¤繘鐗�");
-                //todo:鍚憄lc鍙戦�佹姤璀�
+                //鍚憄lc鍙戦�佹姤璀�:绗煎唴鏍煎瓙鍓╀綑鏁伴噺涓嶈冻
+                miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 16));
                 return;
             }
         }
-        //todo:瓒呭ぇ灏哄
-        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));
             if (count > 0) {
                 log.info("鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝缁撴潫鏈杩涚墖");
-                //todo:鍚憄lc鍙戦�佹姤璀�
+                //鍚憄lc鍙戦�佹姤璀�:鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝鏃犳硶缁х画鐩撮��
+                miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 64));
                 return;
             }
         }
@@ -202,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);
@@ -220,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);
@@ -285,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) {
@@ -737,7 +764,8 @@
     }
 
 
-    private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, int targetSlot, int isPair, int totalLayer, int isForce) {
+    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;
@@ -762,7 +790,13 @@
                         .ge(HollowBigStorageCage::getMaxThickness, list.get(0).getThickness())
                         .eq(HollowBigStorageCage::getRemainWidth, slotWidth)
                         .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1"));
-                Assert.isFalse(storageCage == null, "浠诲姟璋冨害娌℃湁澶氫綑鏍煎瓙锛岀粨鏉熻皟搴︿换鍔�");
+
+                if (null == storageCage) {
+                    //鍚憄lc鍙戦�佹姤璀�:鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝鏃犳硶缁х画鐩撮��
+                    miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16));
+                    Assert.isFalse(storageCage == null, "浠诲姟璋冨害娌℃湁澶氫綑鏍煎瓙锛岀粨鏉熻皟搴︿换鍔�");
+                }
+
                 targetSlot = storageCage.getSlot();
                 hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>()
                         .set(HollowBigStorageCage::getRemainWidth, 0).eq(HollowBigStorageCage::getSlot, targetSlot));
@@ -784,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