From c55387f287690dd3335e56d7749195d361803628 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期五, 19 十二月 2025 13:59:54 +0800
Subject: [PATCH] 1、 查询是否除膜优化:由单选改为复选框选择

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java |  152 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 100 insertions(+), 52 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 4ec3629..0a7de37 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
@@ -117,6 +117,8 @@
     private static final String ALARM_TYPE = "涓┖澶х悊鐗�";
     private static final String ALARM_CODE_SIZE = "sizeSame";
     private static final String ALARM_CODE_ID = "idSame";
+    private static final String ALARM_CODE_SLOT = "slotLess";
+    private static final String ALARM_CODE_OVER = "overSize";
 
     /**
      * 鐩撮�氭牸瀛�
@@ -245,6 +247,13 @@
                     .ge(HollowBigStorageCage::getMaxThickness, entry.getKey()));
             if (count < entry.getValue()) {
                 log.info("绗煎唴鏍煎瓙鍓╀綑鏁伴噺涓嶈冻锛岀粨鏉熸湰娆¤繘鐗�");
+                ProductAlarmInfo alarmInfo = new ProductAlarmInfo();
+                alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW);
+                alarmInfo.setAlarmModule(ALARM_MODULE);
+                alarmInfo.setAlarmType(ALARM_TYPE);
+                alarmInfo.setAlarmCode(ALARM_CODE_SLOT);
+                alarmInfo.setAlarmMessage(count + "");
+                productAlarmInfoService.save(alarmInfo);
                 //鍚憄lc鍙戦�佹姤璀�:绗煎唴鏍煎瓙鍓╀綑鏁伴噺涓嶈冻
                 s7DataZKDLPOne = new S7DataZKDLPOne();
                 s7DataZKDLPOne.setAlramSignal(16);
@@ -253,23 +262,6 @@
             }
         }
 //        }
-        //瓒呭ぇ灏哄
-//        Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT);
-//        Integer slotMaxthickness = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_THICKNESS);
-//        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("鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝缁撴潫鏈杩涚墖");
-//                //鍚憄lc鍙戦�佹姤璀�:鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝鏃犳硶缁х画鐩撮��
-//                s7DataZKDLPOne = new S7DataZKDLPOne();
-//                s7DataZKDLPOne.setAlramSignal(64);
-//                s7SerializerZKDLPOne.write(s7DataZKDLPOne);
-//                return;
-//            }
-//        }
-
         log.info("灏嗛挗鍖栧皬鐗囪〃鍐呯殑鐘舵�佹敼涓洪挗鍖栫粨鏉燂紝鐜荤拑id鏈夛細{}", glassIdList);
         //淇敼閽㈠寲浠诲姟琛ㄤ腑鐨勭姸鎬�
         temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>()
@@ -277,7 +269,9 @@
         //鎶ュ伐
         log.info("灏嗘帴鏀跺埌鐨勭幓鐠冭繘琛岄挗鍖栬嚜鍔ㄦ姤宸ワ紝鐜荤拑id鏈夛細{}", glassIdList);
         for (String glass : glassIdList) {
-            damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "閽㈠寲", "杩涗腑绌虹悊鐗囩", 1);
+            if (from.equals(910)) {
+                damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "閽㈠寲", "杩涗腑绌虹悊鐗囩", 1);
+            }
         }
         Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId));
 
@@ -468,6 +462,20 @@
         }
 
         HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
+
+        //鐩撮�氬彴鏈夌幓鐠冩椂灏嗕腑绌哄嚭鐗囬槦鍒椾腑瀵瑰簲鐜荤拑id鐨勬牸瀛愬彿鏇挎崲鏈洿閫氬彴
+        HollowBigStorageCageDetails details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
+                .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT)
+                .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).last("limit 1"));
+        if (details != null) {
+            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService.getOne(
+                    new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                            .eq(HollowGlassOutRelationInfo::getFlowCardId, details.getFlowCardId())
+                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                            .orderByAsc(HollowGlassOutRelationInfo::getId)
+                            .last("limit 1")
+            );
+        }
         int cell = -1;
         for (Integer i : resultList) {
             if (null == hollowGlassOutRelationInfo) {
@@ -486,20 +494,20 @@
                 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)
-                                .orderByAsc(HollowGlassOutRelationInfo::getId)
-                                .last("limit 1")
-                        );
-            } 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)
+//                                .orderByAsc(HollowGlassOutRelationInfo::getId)
+//                                .last("limit 1")
+//                        );
+//            } else {
+//                break;
+//            }
+//        }
 
         if (null != hollowGlassOutRelationInfo) {
             //鏄惁鍏佽涓┖
@@ -509,14 +517,14 @@
                     .eq(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW)
                     .eq(HollowGlassQueueInfo::getRelationId, hollowGlassOutRelationInfo.getId())
                     .orderByAsc(HollowGlassQueueInfo::getHollowSequence));
-            if (CollectionUtil.isNotEmpty(unFinishHollowQueueList)) {
+            //鎸夌収浠诲姟淇℃伅杩囨护绛涢�夐渶瑕佸嚭鐗囧強璋冨害鐨勭幓鐠冮槦鍒�
+            List<HollowGlassQueueInfo> resultQueue = computeOutHollowQueue(unFinishHollowQueueList, hollowGlassOutRelationInfo);
+            log.info("涓┖鍑虹墖浠诲姟璁$畻鍚庣殑鍑虹墖闃熷垪涓猴細{}", resultQueue);
+            if (CollectionUtil.isNotEmpty(resultQueue)) {
                 //鐩撮�氬彴鏈夌幓鐠冩椂灏嗕腑绌哄嚭鐗囬槦鍒椾腑瀵瑰簲鐜荤拑id鐨勬牸瀛愬彿鏇挎崲鏈洿閫氬彴
-                HollowBigStorageCageDetails details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
-                        .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT)
-                        .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).last("limit 1"));
                 log.info("涓┖澶х悊鐗囩洿閫氬彴鐜荤拑淇℃伅{}", details);
                 if (details != null) {
-                    unFinishHollowQueueList.stream().forEach(e -> {
+                    resultQueue.stream().forEach(e -> {
                         if (e.getGlassId().equals(details.getGlassId())) {
                             e.setSlot(THROUGH_SLOT);
                             e.setDeviceId(0);
@@ -524,11 +532,9 @@
                         }
                     });
                 }
-
-                List<HollowGlassQueueInfo> infoList = unFinishHollowQueueList.stream().filter(e -> !(e.getSlot() > 500 && e.getSlot() < 900 && e.getIsPair() != 1)).collect(Collectors.toList());
-                log.info("鏈夋鍦ㄥ嚭鐗囩殑涓┖浠诲姟");
-                Integer isPair = infoList.get(0).getIsPair();
-                hollowOutGlassByIsPair(infoList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce());
+                log.info("鏈夋鍦ㄥ嚭鐗囩殑涓┖浠诲姟:{}", hollowGlassOutRelationInfo);
+                Integer isPair = resultQueue.get(0).getIsPair();
+                hollowOutGlassByIsPair(resultQueue, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce());
                 Date endDate = new Date();
                 log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
                 return;
@@ -578,6 +584,7 @@
         log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
         return;
     }
+
 
     @Scheduled(fixedDelay = 1000)
     public void finishInBigStorageTask() throws Exception {
@@ -908,7 +915,11 @@
             log.info("褰撳墠鏈敹鍒拌繘鐗囪姹傦紝缁撴潫杩涚墖浠诲姟");
             return;
         }
-        if (StringUtils.isNotBlank(s7DataZKDLPOne.getId1())){
+        if (StringUtils.isNotBlank(s7DataZKDLPOne.getId1())) {
+            log.info("褰撳墠瀛樺湪杩涚墖浠诲姟锛岀粨鏉�");
+            return;
+        }
+        if (StringUtils.isNotBlank(s7DataZKDLPOne.getId1())) {
             log.info("褰撳墠瀛樺湪杩涚墖浠诲姟璇锋眰锛岀粨鏉熸湰娆″ぇ绗煎瓙璋冨害");
             return;
         }
@@ -924,15 +935,19 @@
         if (count > 0) {
             return;
         }
-        List<HollowBigStorageCageDetails> list = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
-                .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN)
-//                .in(HollowBigStorageCageDetails::getDeviceId, 6)
-                .in(HollowBigStorageCageDetails::getGlassId, glassIdList));
-        log.info("鑾峰彇璋冨害浠诲姟鍒楄〃锛歿}", list);
-        if (CollectionUtil.isEmpty(list)) {
+        HollowBigStorageCageDetails details = null;
+        for (String glassId : glassIdList) {
+            details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
+                    .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN)
+                    .eq(HollowBigStorageCageDetails::getGlassId, glassId).last("limit 1"));
+            log.info("鑾峰彇璋冨害浠诲姟锛歿}", details);
+            if (details != null) {
+                break;
+            }
+        }
+        if (details == null) {
             return;
         }
-        HollowBigStorageCageDetails details = list.get(0);
         log.info("鑾峰彇闇�瑕佽皟搴︾殑鍗曟潯浠诲姟锛歿}", details);
         //鐢熸垚杩涜繘鐗囧ぇ杞︿换鍔�
         hollowBigStorageCageDetailsService.update(new LambdaUpdateWrapper<HollowBigStorageCageDetails>()
@@ -963,7 +978,7 @@
             damage.setWorkingProcedure("纾ㄨ竟");
             damage.setRemark("杩涚鍓嶅崸杞珛");
             damage.setStatus(1);
-            damage.setType(item.getTaskState());
+            damage.setType(Const.GLASS_STATE_DAMAGE);
             damageService.insertDamage(damage);
             slotList.add(item.getTargetSlot());
         }
@@ -988,7 +1003,7 @@
             damage.setWorkingProcedure("涓┖鍓�");
             damage.setRemark("杩涚鍚庡崸杞珛");
             damage.setStatus(1);
-            damage.setType(item.getTaskState());
+            damage.setType(Const.GLASS_STATE_DAMAGE);
             damageService.insertDamage(damage);
             slotList.add(item.getTargetSlot());
             slotList.add(item.getStartSlot());
@@ -1048,6 +1063,32 @@
         log.info("鍑虹墖浠诲姟-鏃犲姩浣滄墽琛屽畬鎴�");
     }
 
+    private List<HollowGlassQueueInfo> computeOutHollowQueue(List<HollowGlassQueueInfo> queueInfoList, HollowGlassOutRelationInfo hollowGlassOutRelationInfo) {
+        if (CollectionUtil.isEmpty(queueInfoList)) {
+            return new ArrayList<>();
+        }
+        //浠诲姟涓哄己鍒讹紝鍙洿鎺ヨ繑鍥炲師鏈夌殑闃熷垪
+        if (hollowGlassOutRelationInfo.getIsForce() == 1) {
+            return queueInfoList;
+        }
+        log.info("棰嗗彇浠诲姟锛歿}鐨勯槦鍒楋細{}", hollowGlassOutRelationInfo, queueInfoList);
+        // 鎸夋牸瀛愬彿鍒嗙粍
+        Map<Integer, List<HollowGlassQueueInfo>> gridGroups = queueInfoList.stream()
+                .collect(Collectors.groupingBy(HollowGlassQueueInfo::getSlot));
+        List<HollowGlassQueueInfo> resultQueue = new ArrayList<>();
+
+        for (List<HollowGlassQueueInfo> items : gridGroups.values()) {
+            // 鎯呭喌2锛氭牸瀛愬唴鍏ㄩ儴涓烘湭閰嶅鐨勬暟鎹� - 杩囨护鎺�
+            boolean allUnpaired = items.stream().noneMatch(e -> e.getIsPair() == 1);
+            if (allUnpaired) {
+                continue;
+            }
+            // 鍚﹀垯淇濈暀杩欎釜鏍煎瓙鍐呯殑鎵�鏈夋暟鎹�
+            resultQueue.addAll(items);
+        }
+        Collections.sort(resultQueue, Comparator.comparing(HollowGlassQueueInfo::getId));
+        return resultQueue;
+    }
 
     private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list,
                                                                                     int targetSlot, int isPair, int totalLayer, int isForce) throws Exception {
@@ -1084,6 +1125,13 @@
                     S7DataZKDLPOne s7DataZKDLPOne = new S7DataZKDLPOne();
                     s7DataZKDLPOne.setAlramSignal(16);
                     s7SerializerZKDLPOne.write(s7DataZKDLPOne);
+                    ProductAlarmInfo alarmInfo = new ProductAlarmInfo();
+                    alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW);
+                    alarmInfo.setAlarmModule(ALARM_MODULE);
+                    alarmInfo.setAlarmType(ALARM_TYPE);
+                    alarmInfo.setAlarmCode(ALARM_CODE_SLOT);
+                    alarmInfo.setAlarmMessage("");
+                    productAlarmInfoService.save(alarmInfo);
                     Assert.isFalse(storageCage == null, "浠诲姟璋冨害娌℃湁澶氫綑鏍煎瓙锛岀粨鏉熻皟搴︿换鍔�");
                 }
 

--
Gitblit v1.8.0