From 21be0725d75e2df39445d03c7f7f0b34527bb757 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 18 八月 2025 16:40:06 +0800
Subject: [PATCH] 1、fixbug:进片任务异常后仍会向plc发任务 2、中空大理片玻璃配对按照流程卡+订单序号配对,弃用之前由玻璃尺寸匹配的情况 3、中空大理片出片规则调整适用性:获取多条中空线的仅空闲的状态,去任务表按更新时间倒序获取第一条任务(最近最不活跃的线路)。获取任务为空,则按照所有线路获取更新时间倒序第一条任务(最近最不活跃的线路)。

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java                        |  112 ++++++++++++++-----------------------
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java          |    4 
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java |   10 +--
 3 files changed, 49 insertions(+), 77 deletions(-)

diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java
index c1f2395..dd29b34 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java
@@ -1,7 +1,6 @@
 package com.mes.hollow.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.mes.common.config.ConstSysConfig;
 import com.mes.hollow.entity.HollowGlassRelationInfo;
 import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
 import com.mes.hollow.entity.dto.HollowBigStorageDTO;
@@ -24,7 +23,7 @@
      *
      * @return
      */
-    HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, double width, double height, int totalLayer, int layer);
+    HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, Integer glassType, double width, double height, int totalLayer, int layer);
 
     /**
      * 鐢熸垚涓┖鐜荤拑淇℃伅
@@ -43,6 +42,7 @@
 
     /**
      * 鎸夌収鍘氬害鑾峰彇鐜荤拑闂撮殭
+     *
      * @param thickness
      * @return
      */
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
index 9c78f1c..8cb44d1 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -68,12 +68,11 @@
 //    private Integer outCarMaxSize;
 
     @Override
-    public HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, double width, double height, int totalLayer, int layer) {
+    public HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, Integer glassType, double width, double height, int totalLayer, int layer) {
         //鎸夌収鐜荤拑淇℃伅鑾峰彇鍏崇郴琛ㄤ腑瀵瑰簲鐨勫ぇ鐞嗙墖绗兼牸瀛愬彿
         HollowGlassRelationInfo relationInfoOne = hollowGlassRelationInfoService.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>()
                 .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
-                .eq(HollowGlassRelationInfo::getWidth, width)
-                .eq(HollowGlassRelationInfo::getHeight, height)
+                .eq(HollowGlassRelationInfo::getOrderSort, glassType)
                 .eq(HollowGlassRelationInfo::getTotalLayer, totalLayer)
                 .eq(HollowGlassRelationInfo::getLayer, layer)
                 .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
@@ -95,8 +94,7 @@
             //铏氭嫙浣嶇疆琛ㄦ病鏈夋湰宸ョ▼涓嬬殑鎵�鏈夌幓鐠冭櫄鎷熶俊鎭紝鎸夌収鐜荤拑id鐢熸垚鏈伐绋嬩笅鎵�鏈夌幓鐠冪殑铏氭嫙淇℃伅
             relationInfoOne = this.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>()
                     .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
-                    .eq(HollowGlassRelationInfo::getWidth, width)
-                    .eq(HollowGlassRelationInfo::getHeight, height)
+                    .eq(HollowGlassRelationInfo::getOrderSort, glassType)
                     .eq(HollowGlassRelationInfo::getTotalLayer, totalLayer)
                     .eq(HollowGlassRelationInfo::getLayer, layer)
                     .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
@@ -330,7 +328,7 @@
                 }
                 List<FlowCardGlassInfoDTO> flowCardInfoList = hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE);
                 log.info("鑾峰彇鍒扮殑娴佺▼鍗′俊鎭负:{}", flowCardInfoList);
-                if(CollectionUtil.isNotEmpty(flowCardInfoList)){
+                if (CollectionUtil.isNotEmpty(flowCardInfoList)) {
                     hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(flowCardInfoList);
                     pairTotalCount.addAndGet(flowCardInfoList.get(0).getPairCount());
                 }
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 d80c2e9..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,9 +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);
-    private Integer lastTimeLine = -1;
     /**
      * 鐩撮�氭牸瀛�
      */
@@ -117,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++) {
@@ -145,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;
@@ -245,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>()
@@ -307,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)
@@ -315,6 +315,7 @@
                     .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
                     .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY)
             );
+            return;
         }
         //鍘嗗彶鏁版嵁鍏ュ簱
         hollowBigStorageCageHistoryTaskService.saveBatch(historyTasks);
@@ -355,32 +356,30 @@
         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<>();
-        Boolean oneState = Boolean.FALSE;
-        Boolean twoState = Boolean.FALSE;
-        Boolean threeState = Boolean.FALSE;
         try {
             if (CMJ1ModbusTcp.checkConnected()) {
-                oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
-                map.put(930, oneState);
+                Boolean oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
+                if (oneState) {
+                    freeLineList.add(930);
+                }
             }
         } catch (Exception e) {
             //nothing
@@ -389,54 +388,30 @@
         try {
             S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class);
             log.info("涓┖棰濆璇诲彇{}", s7DataZKExtra);
-            twoState = s7DataZKExtra.getIsFree();
-            threeState = s7DataZKExtra.getIsFree03();
-            map.put(931, twoState);
-            map.put(932, threeState);
+            Boolean twoState = s7DataZKExtra.getIsFree();
+            Boolean threeState = s7DataZKExtra.getIsFree03();
+            if (twoState) {
+                freeLineList.add(931);
+            }
+            if (threeState) {
+                freeLineList.add(932);
+            }
         } catch (Exception e) {
             //nothing
             log.info("浜�/涓夌嚎绾跨┖闂茬姸鎬佽幏鍙栧紓甯�");
         }
-        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
-        int cell = -1;
-        if (oneState && twoState || !(oneState || twoState)) {
-            //鑾峰彇涓婁竴娆$殑浠诲姟淇℃伅绾胯矾
-            List<Integer> resultList = lastTimeLine == 930 ? TWO_LINE_FIRST : ONE_LINE_FIRST;
-            for (int 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 {
-            for (int i : ONE_LINE_FIRST) {
-                if (null == hollowGlassOutRelationInfo) {
-                    Boolean freeFlag = map.get(i);
-                    cell = i;
-                    if (freeFlag) {
-                        hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
-                                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                                );
-                    }
-                }
-            }
-            for (int i : ONE_LINE_FIRST) {
-                if (null == hollowGlassOutRelationInfo) {
-                    cell = i;
-                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
-                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
-                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                            );
-
-                }
-            }
+        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) {
@@ -445,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)) {
@@ -1073,7 +1048,6 @@
             s7DataZKDLPTwo = new S7DataZKDLPTwo();
             s7DataZKDLPTwo.setMesReply(1);
             s7SerializerZKDLPTwo.write(s7DataZKDLPTwo);
-            lastTimeLine = targetSlot;
         } catch (Exception e) {
             e.printStackTrace();
         }

--
Gitblit v1.8.0