From 09402133807b1e774e658a13ad365b2e6efca25b Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期一, 21 四月 2025 16:06:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java |  122 ++++++++++++++++++++++------------------
 1 files changed, 68 insertions(+), 54 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 7d25456..733c1e3 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
@@ -12,6 +12,7 @@
 import com.mes.bigstoragecagetask.entity.BigStorageCageTask;
 import com.mes.bigstoragecagetask.service.BigStorageCageTaskService;
 import com.mes.common.config.Const;
+import com.mes.common.config.ConstSysConfig;
 import com.mes.damage.entity.Damage;
 import com.mes.damage.service.DamageService;
 import com.mes.glassinfo.entity.GlassInfo;
@@ -32,6 +33,7 @@
 import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
 import com.mes.hollowtask.entity.HollowBigStorageCageHistoryTask;
 import com.mes.hollowtask.service.HollowBigStorageCageHistoryTaskService;
+import com.mes.sysconfig.service.SysConfigService;
 import com.mes.temperingglass.entity.TemperingGlassInfo;
 import com.mes.temperingglass.service.TemperingGlassInfoService;
 import com.mes.utils.RedisUtil;
@@ -39,7 +41,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -75,6 +76,8 @@
     private HollowGlassQueueInfoService hollowGlassQueueInfoService;
     @Resource
     private HollowGlassOutRelationInfoService hollowGlassOutRelationInfoService;
+    @Resource
+    private SysConfigService sysConfigService;
 
     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";
@@ -87,22 +90,22 @@
     @Resource
     private RedisUtil redisUtil;
 
-    @Value("${mes.slotWidth}")
-    private Integer slotWidth;
-
-    @Value("${mes.glassGap}")
-    private Integer glassGap;
-
-    @Value("${mes.carWidth}")
-    private Integer carWidth;
-
-    @Value("${mes.outCarMaxSize}")
-    private Integer outCarMaxSize;
-
-    @Value("${mes.slotMaxHeight}")
-    private Integer slotMaxHeight;
-    @Value("${mes.slotMaxthickness}")
-    private Integer slotMaxthickness;
+//    @Value("${mes.slotWidth}")
+//    private Integer slotWidth;
+//
+//    @Value("${mes.glassGap}")
+//    private Integer glassGap;
+//
+//    @Value("${mes.carWidth}")
+//    private Integer carWidth;
+//
+//    @Value("${mes.outCarMaxSize}")
+//    private Integer outCarMaxSize;
+//
+//    @Value("${mes.slotMaxHeight}")
+//    private Integer slotMaxHeight;
+//    @Value("${mes.slotMaxthickness}")
+//    private Integer slotMaxthickness;
 
     @Scheduled(fixedDelay = 1000)
     public void inBigStorageTask() throws Exception {
@@ -166,6 +169,8 @@
             miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 8));
             return;
         }
+
+        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
         //鎸夌収鐜荤拑鍘氬害鍒嗙粍锛屽垽鏂墿浣欐牸瀛愭槸鍚﹀彲浠ュ瓨鏀�
         Map<Double, Long> thickCountMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getThickness, Collectors.counting()));
         for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) {
@@ -181,6 +186,8 @@
             }
         }
         //瓒呭ぇ灏哄
+        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)
@@ -206,6 +213,8 @@
 
         //璁$畻鐩爣鏍煎瓙
         List<HollowBigStorageCageHistoryTask> historyTasks = new ArrayList<>();
+
+        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP);
         try {
             if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) {
                 for (BigStorageCageTask task : inTaskList) {
@@ -315,44 +324,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("ZKQ2.ZKQ2.isFree03");
+        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 <= 932; i++) {
+            if (null == hollowGlassOutRelationInfo) {
+                ReadWriteEntity entity = map.get(i);
+                cell = i;
+                if (null != entity.getValue() && ("1".equals(entity.getValue() + "") || Boolean.parseBoolean(entity.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) {
@@ -767,7 +773,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;
@@ -779,6 +786,8 @@
                 break;
             }
         }
+
+        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
         if (isPair == 0 && isForce != 1) {
             taskType = Const.BIG_STORAGE_AFTER_DISPATCH;
             taskState = Const.GLASS_STATE_SCHEDULE_ING;
@@ -820,11 +829,14 @@
      * @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<>();
         //鎵撹溅鍓╀綑灏哄
-        Integer remainWidth = carWidth;
+        Integer remainWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
+        Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_OUT_CAR_SIZE);
+        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP);
         for (T e : list) {
             if (templist.size() >= outCarMaxSize || Math.max((int) e.getWidth(), (int) e.getHeight()) > remainWidth) {
                 break;
@@ -902,6 +914,8 @@
                 .in(HollowBigStorageCageDetails::getSlot, slotList).in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL));
         Map<Integer, Double> slotRemainMap = new HashMap<>();
         //鏄惁瀛樺湪鏈夋牸瀛愰潪绌虹殑鐜荤拑
+        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP);
+        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
         if (CollectionUtils.isNotEmpty(inSlotGlassList)) {
             //瀛樺湪  灏嗘牸瀛愬唴鐨勭幓鐠冨垎鍒繘琛屾洿鏂�
 //            List<HollowBigStorageCage> hollowBigStorageCageList = hollowBigStorageCageService.list(new LambdaQueryWrapper<HollowBigStorageCage>()

--
Gitblit v1.8.0