From 112ff5924fd5f6114c1562af60ca16e6eba6f7fb Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期一, 27 十月 2025 08:34:50 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/YiWuProject

---
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/entity/dto/BigStorageSlotDTO.java                  |   22 +++++
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml                           |   25 ++++++
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/BigStorageCageDetailsService.java          |    8 ++
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java |   14 +++
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java                             |  135 ++++++++++++++++++++++++---------
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/mapper/BigStorageCageDetailsMapper.java            |    5 +
 6 files changed, 172 insertions(+), 37 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/entity/dto/BigStorageSlotDTO.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/entity/dto/BigStorageSlotDTO.java
new file mode 100644
index 0000000..847f32b
--- /dev/null
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/entity/dto/BigStorageSlotDTO.java
@@ -0,0 +1,22 @@
+package com.mes.bigstorage.entity.dto;
+
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/11/25 18:53
+ * @Description:
+ */
+@Data
+public class BigStorageSlotDTO {
+
+    /**
+     * 璧峰鏍煎瓙
+     */
+    private Integer startSlot;
+    /**
+     * 鐩爣鏍煎瓙
+     */
+    private Integer targetSlot;
+
+}
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/mapper/BigStorageCageDetailsMapper.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/mapper/BigStorageCageDetailsMapper.java
index b7a9ef3..0e91ac2 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/mapper/BigStorageCageDetailsMapper.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/mapper/BigStorageCageDetailsMapper.java
@@ -67,5 +67,10 @@
 
     List<BigStorageVO> querybigStorageCageDetail();
 
+    List<BigStorageCageDetails> queryNeedDispatch();
+
+
+    BigStorageSlotDTO queryNeedDispatchSlotBySequence();
+
     List<TemperingGlassCountDTO> queryTemperingGlassCountSummary(int isTempering);
 }
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/BigStorageCageDetailsService.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/BigStorageCageDetailsService.java
index 9f75829..2392ac2 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/BigStorageCageDetailsService.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/BigStorageCageDetailsService.java
@@ -142,6 +142,14 @@
      * @return
      */
     List<BigStorageCageDetails> queryEngineer();
+
+    /**
+     * 鏌ヨ4鍙风鍙線5-6鍙风涓嶆弧鏍煎嵈婊¤冻涓埆鐨勮皟搴�
+     * @return
+     */
+    List<BigStorageCageDetails> queryNeedDispatch();
+
+    BigStorageSlotDTO queryNeedDispatchSlotBySequence();
     /**
      * 鏌ヨ閽㈠寲鎺掍骇椤哄簭
      * @return OptimizeProject 閽㈠寲鎺掍骇椤哄簭
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
index b233b36..2d2b9d6 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
@@ -44,6 +44,10 @@
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -580,6 +584,16 @@
     }
 
     @Override
+    public List<BigStorageCageDetails> queryNeedDispatch() {
+        return baseMapper.queryNeedDispatch();
+    }
+
+    @Override
+    public BigStorageSlotDTO queryNeedDispatchSlotBySequence() {
+        return baseMapper.queryNeedDispatchSlotBySequence();
+    }
+
+    @Override
     public List<OptimizeProject> queryTemperingOrder() {
         String temperingengineerId = redisUtil.getCacheObject("temperingEngineerId");
         List<TemperingGlassCountDTO> temperingGlassCountDTOS = baseMapper.queryTemperingGlassCountSummary(1);
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java
index d4fa6fa..5cbe4f6 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java
@@ -14,10 +14,7 @@
 import com.mes.base.entity.BigStorageCageBaseInfo;
 import com.mes.bigstorage.entity.BigStorageCage;
 import com.mes.bigstorage.entity.BigStorageCageDetails;
-import com.mes.bigstorage.entity.dto.BigStorageDTO;
-import com.mes.bigstorage.entity.dto.BigStorageRelationDTO;
-import com.mes.bigstorage.entity.dto.BigStorageSequenceDTO;
-import com.mes.bigstorage.entity.dto.TemperingLayoutDTO;
+import com.mes.bigstorage.entity.dto.*;
 import com.mes.bigstorage.service.BigStorageCageDetailsService;
 import com.mes.bigstorage.service.BigStorageCageService;
 import com.mes.bigstorage.service.BigStorageGlassInfoService;
@@ -143,16 +140,17 @@
         String fromOpcUa = s7DataDLPOne.getFrom1().toString();
 
         List<String> ids = s7DataDLPOne.getIds();
+        log.info("鑾峰彇鍒拌繘鐗囦换鍔� 鐜荤拑id锛歿}", ids);
         List<String> glassIdList = new ArrayList<>();
         for (int i = 0; i < 6; i++) {
             String requestWord = ids.get(i);
-            if (null != requestWord && !requestWord.isEmpty()) {
+            if (StringUtils.isNotBlank(requestWord)) {
+                log.info("鐜荤拑id{}鍔犲叆杩涚墖浠诲姟", requestWord);
                 BigStorageCageTask task = new BigStorageCageTask();
                 task.setGlassId(requestWord);
                 task.setStartSlot(Integer.parseInt(fromOpcUa));
                 inTaskList.add(task);
                 glassIdList.add(requestWord);
-                break;
             }
         }
         if (CollectionUtil.isEmpty(inTaskList)) {
@@ -160,9 +158,9 @@
             return;
         }
         log.info("鑾峰彇浠诲姟鐨勭幓鐠僫d锛歿}", glassIdList);
-        String countEntity = s7DataDLPOne.getGlassCount().toString();
-        if (null == countEntity || Integer.parseInt(countEntity) != glassIdList.size()) {
-            log.info("褰撳墠澶ц溅杩涚墖鐜荤拑鏁伴噺{}涓巑es璇诲彇鍒扮殑鏁伴噺{}涓嶅尮閰嶏紝缁撴潫杩涚墖浠诲姟", countEntity, glassIdList.size());
+        Integer glassCount = s7DataDLPOne.getGlassCount();
+        if (glassCount != glassIdList.size()) {
+            log.info("褰撳墠澶ц溅杩涚墖鐜荤拑鏁伴噺{}涓巑es璇诲彇鍒扮殑鏁伴噺{}涓嶅尮閰嶏紝缁撴潫杩涚墖浠诲姟", glassCount, glassIdList.size());
             //鍚憄lc鍙戦�佹姤璀�:褰撳墠澶ц溅杩涚墖鐜荤拑鏁伴噺涓巑es璇诲彇鍒扮殑鏁伴噺涓嶅尮閰�
             s7DataDLPOne = new S7DataDLPOne();
             s7DataDLPOne.setAlarmSignal(1);
@@ -228,7 +226,7 @@
             for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) {
                 int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>()
                         .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth)
-                        .ge(BigStorageCage::getDeviceId, 4)
+                        .le(BigStorageCage::getDeviceId, 4)
                         .le(BigStorageCage::getMinThickness, entry.getKey())
                         .ge(BigStorageCage::getMaxThickness, entry.getKey()));
                 if (count < entry.getValue()) {
@@ -381,17 +379,16 @@
             log.info("鏈夋鍦ㄦ墽琛岀殑鍑虹墖浠诲姟锛岀粨鏉熸湰娆″嚭鐗囦换鍔�");
             return;
         }
-
+        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP);
+        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH);
+        Integer slotMaxThickness = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_THICKNESS);
+        Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_HEIGHT);
         List<BigStorageCageDetails> detailsList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
                 .eq(BigStorageCageDetails::getSlot, THROUGH_SLOT)
                 .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).orderByAsc(BigStorageCageDetails::getId));
         if (CollectionUtil.isNotEmpty(detailsList)) {
             List<BigStorageCageHistoryTask> historyTasks = new ArrayList<>();
             List<BigStorageCageTask> taskList = new ArrayList<>();
-            Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP);
-            Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH);
-            Integer slotMaxThickness = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_THICKNESS);
-            Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_HEIGHT);
             for (BigStorageCageDetails info : detailsList) {
                 BigStorageCageTask task = new BigStorageCageTask();
                 task.setGlassId(info.getGlassId());
@@ -399,11 +396,12 @@
                 task.setTaskState(Const.ENGINEERING_NEW);
 
                 LambdaQueryWrapper<BigStorageCage> queryWrapper = new LambdaQueryWrapper<BigStorageCage>()
-                        .eq(BigStorageCage::getRemainWidth, slotWidth).orderByAsc(BigStorageCage::getSlot)
+                        .eq(BigStorageCage::getRemainWidth, slotWidth)
                         .eq(BigStorageCage::getEnableState, Const.SLOT_ON)
+                        .orderByAsc(BigStorageCage::getDeviceId).orderByAsc(BigStorageCage::getSlot)
                         .last("limit 1");
 
-                if (slotMaxHeight > Math.min(info.getWidth(), info.getHeight()) && info.getThickness() < slotMaxThickness) {
+                if (slotMaxHeight > Math.min(info.getWidth(), info.getHeight())) {
                     queryWrapper.in(BigStorageCage::getDeviceId, Arrays.asList(5, 6));
                 } else {
                     queryWrapper.eq(BigStorageCage::getDeviceId, 6);
@@ -430,15 +428,20 @@
                 cageDetails.setState(Const.GLASS_STATE_NEW);
                 cageDetails.setDeviceId(bigStorageCage.getDeviceId());
                 cageDetails.setSequence(0);
-                cageDetails.setAngle((int) info.getAngle());
+                cageDetails.setAngle(info.getAngle());
                 cageDetails.setGap(glassGap);
                 cageDetails.setFilmsId(info.getFilmsId());
                 cageDetails.setId(null);
                 bigStorageCageDetailsService.save(cageDetails);
+                info.setState(Const.GLASS_STATE_OUT);
+                bigStorageCageDetailsService.updateById(info);
             }
             //鍘嗗彶鏁版嵁鍏ュ簱
             bigStorageCageHistoryTaskService.saveBatch(historyTasks);
             extracted(taskList);
+            S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo();
+            s7DataDLPTwo.setMesReply(1);
+            s7SerializerDLPTwo.write(s7DataDLPTwo);
             return;
         }
 
@@ -501,7 +504,8 @@
         Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_OUT_CAR_SIZE);
         List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
                 .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
-                .orderByAsc(BigStorageCageDetails::getSlot)
+                .orderByAsc(BigStorageCageDetails::getDeviceId)
+                .orderByAsc(BigStorageCageDetails::getId)
                 .orderByAsc(BigStorageCageDetails::getId).last("limit " + outCarMaxSize));
         if (CollectionUtil.isNotEmpty(artificialList)) {
             computeOutGlassInfoByVirtualSlot(artificialList, "big_storage_cage_out_one_task", artificialOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
@@ -523,14 +527,75 @@
                 log.info("鏈夋鍦ㄦ墽琛岀殑杩涚墖浠诲姟锛岀粨鏉熻皟搴︿换鍔�");
                 return;
             }
-//todo:4鍙疯幏鍙栫鍐呭崟鏍煎凡缁忓埌榻愮殑鐜荤拑鏍煎瓙淇℃伅
+//4鍙疯幏鍙栫鍐呭崟鏍煎凡缁忓埌榻愮殑鐜荤拑鏍煎瓙淇℃伅
+            List<BigStorageCageDetails> list = new ArrayList<>();
             List<BigStorageRelationDTO> virtualList = bigStorageCageDetailsService.queryIsAllNeedDispatchVirtualSlot(Arrays.asList(4));
+            for (BigStorageRelationDTO dto : virtualList) {
+                List<BigStorageSequenceDTO> sequenceDTOList = bigStorageCageDetailsService.dispatchBigStorageGlassInfo(dto);
+                if (CollectionUtil.isEmpty(sequenceDTOList) || sequenceDTOList.size() == 1) {
+                    continue;
+                }
+                BigStorageCage bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
+                        .eq(BigStorageCage::getRemainWidth, slotWidth)
+                        .eq(BigStorageCage::getEnableState, Const.SLOT_ON)
+                        .in(BigStorageCage::getDeviceId, Arrays.asList(5, 6))
+                        .orderByAsc(BigStorageCage::getDeviceId).orderByAsc(BigStorageCage::getSlot)
+                        .last("limit 1"));
+                List<Integer> slotList = sequenceDTOList.stream().map(BigStorageSequenceDTO::getSlot).collect(Collectors.toList());
+                list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
+                        .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
+                        .in(BigStorageCageDetails::getSlot, slotList)
+                        .orderByAsc(BigStorageCageDetails::getTemperingFeedSequence)
+                );
+                computeOutGlassInfoByVirtualSlot(list, "big_storage_cage_out_one_task",
+                        bigStorageCage.getSlot(), Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH);
+                slotList.add(bigStorageCage.getSlot());
+                updateSlotRemainBySlots(slotList);
+                return;
+            }
             //鏈夛細缁熶竴寰�5鍙风瀛愰��
-//            todo:鏃� 4鍙风瀛愪娇鐢ㄦ暟閲忔槸鍚﹁秴杩囬槇鍊� 鏈� 鐢熸垚璋冨害浠诲姟鎸夌収缁勫彿缁勫簭鐢�1寮�濮嬩緷娆″線5鍙风瀛愰�佸皬鐗�
+//            鏃� 4鍙风瀛愪娇鐢ㄦ暟閲忔槸鍚﹁秴杩囬槇鍊� 鏈� 鐢熸垚璋冨害浠诲姟鎸夌収缁勫彿缁勫簭鐢�1寮�濮嬩緷娆″線5鍙风瀛愰�佸皬鐗�
+            int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>().eq(BigStorageCage::getDeviceId, 4).eq(BigStorageCage::getRemainWidth, slotWidth)
+                    .eq(BigStorageCage::getEnableState, Const.SLOT_ON));
+            //瀹氫箟10涓牸瀛愪负闃堝��
+            if (count <= 10) {
+                //鑾峰彇搴忓彿涓�1鐨勬牸瀛� 灏嗘牸瀛愬唴鐨勬墍鏈夌幓鐠冮�佸埌瀵瑰簲鐨勭瀛�
+                BigStorageCage bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>()
+                        .eq(BigStorageCage::getRemainWidth, slotWidth)
+                        .eq(BigStorageCage::getEnableState, Const.SLOT_ON)
+                        .in(BigStorageCage::getDeviceId, Arrays.asList(5, 6))
+                        .orderByAsc(BigStorageCage::getDeviceId).orderByAsc(BigStorageCage::getSlot)
+                        .last("limit 1"));
+
+                list = bigStorageCageDetailsService.queryNeedDispatch();
+                computeOutGlassInfoByVirtualSlot(list, "big_storage_cage_out_one_task",
+                        bigStorageCage.getSlot(), Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH);
+                List<Integer> slotList = new ArrayList<>();
+                slotList.add(bigStorageCage.getSlot());
+                slotList.add(list.get(0).getSlot());
+                updateSlotRemainBySlots(slotList);
+                return;
+            }
+            //鐢熸垚璋冨害浠诲姟鎸夌収缁勫彿缁勫簭鐢�1寮�濮嬩緷娆″線5鍙风瀛愰�佸皬鐗�
+            BigStorageSlotDTO slotDTO = bigStorageCageDetailsService.queryNeedDispatchSlotBySequence();
+            if (null != slotDTO) {
+                list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
+                        .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
+                        .in(BigStorageCageDetails::getSlot, slotDTO.getStartSlot())
+                        .orderByAsc(BigStorageCageDetails::getTemperingFeedSequence)
+                );
+                computeOutGlassInfoByVirtualSlot(list, "big_storage_cage_out_one_task",
+                        slotDTO.getTargetSlot(), Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH);
+                List<Integer> slotList = new ArrayList<>();
+                slotList.add(slotDTO.getStartSlot());
+                slotList.add(slotDTO.getTargetSlot());
+                updateSlotRemainBySlots(slotList);
+                return;
+            }
             //1-3鍙疯幏鍙栫鍐呭崟鏍煎凡缁忓埌榻愮殑鐜荤拑鏍煎瓙淇℃伅
             virtualList = bigStorageCageDetailsService.queryIsAllNeedDispatchVirtualSlot(Arrays.asList(1, 2, 3));
             if (CollectionUtil.isNotEmpty(virtualList)) {
-                List<BigStorageCageDetails> list = new ArrayList<>();
+
                 loop:
                 for (BigStorageRelationDTO dto : virtualList) {
                     List<BigStorageSequenceDTO> sequenceDTOList = bigStorageCageDetailsService.dispatchBigStorageGlassInfo(dto);
@@ -904,17 +969,17 @@
     computeOutGlassInfoByVirtualSlot(List<T> list, String tableName, int targetSlot, int state, int taskType) {
         //浠诲姟鏁版嵁:鑾峰彇杞﹀瓙瀛樻斁鐜荤拑鏈�澶ф暟閲�,鐜荤拑闂撮殧
         List<T> outGlassList = list;
-        if (!THROUGH_SLOT.equals(list.get(0).getSlot())) {
-            //todo:涓存椂瑙e喅鏂规:鍑虹墖鏃惰�冭檻鐜荤拑纰版挒锛屾敼涓轰竴鐗囦竴鍑�
-            // 鐣岄潰鍏抽棴璋冨害寮�鍏� !Const.BIG_STORAGE_BEFORE_DISPATCH.equals(taskType)
-            if (list.get(0).getThickness() >= 8) {
-                outGlassList = list.subList(0, 1);
-            } else {
-                List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId(
-                        list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence());
-                outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList());
-            }
+//        if (!THROUGH_SLOT.equals(list.get(0).getSlot())) {
+//            涓存椂瑙e喅鏂规:鍑虹墖鏃惰�冭檻鐜荤拑纰版挒锛屾敼涓轰竴鐗囦竴鍑�
+        // 鐣岄潰鍏抽棴璋冨害寮�鍏� !Const.BIG_STORAGE_BEFORE_DISPATCH.equals(taskType)
+        if (list.get(0).getSlot() >= 500 && list.get(0).getThickness() > 8) {
+            outGlassList = list.subList(0, 1);
+        } else {
+            List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId(
+                    list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence());
+            outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList());
         }
+//        }
         Assert.isFalse(CollectionUtil.isEmpty(outGlassList), "鏈幏鍙栧嚭鐗囨暟鎹紝缁撴潫鍑虹墖浠诲姟");
         log.info("鑾峰彇鍑虹墖浠诲姟鏁版嵁{}鏉★紝鎵ц淇濆瓨", outGlassList.size());
         List<BigStorageCageTask> bigStorageCageTaskList = outGlassList.stream()
@@ -922,10 +987,6 @@
 
         List<String> glassIds = bigStorageCageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList());
         int glassCount = bigStorageCageTaskList.size();
-        //鐢熸垚鍑虹墖浠诲姟鏉℃暟涓嶈冻6琛ュ叏
-//        while (bigStorageCageTaskList.size() < 6) {
-//            bigStorageCageTaskList.add(new BigStorageCageTask("", 0, 0, 0));
-//        }
         //娓呯┖浠诲姟琛ㄦ暟鎹�
         extracted(bigStorageCageTaskList);
         S7DataDLPTwo s7DataDLPTwo;
@@ -962,7 +1023,7 @@
      * @return
      */
     private Boolean extracted(List<BigStorageCageTask> bigStorageCageTaskList) {
-        resetOutTask();
+//        resetOutTask();
         S7DataDLPTwo s7DataDLPTwo = new S7DataDLPTwo();
         for (int i = 0; i < bigStorageCageTaskList.size() && i < 6; i++) {
             String glassId = bigStorageCageTaskList.get(i).getGlassId();
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
index bb3e9b2..cd59ad9 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
@@ -301,6 +301,31 @@
         group by bsc.device_id, bsc.slot
         order by bsc.device_id, bsc.slot
     </select>
+    <select id="queryNeedDispatch" resultType="com.mes.bigstorage.entity.BigStorageCageDetails">
+        SELECT * FROM big_storage_cage_details WHERE STATE = 100 AND SLOT = (SELECT SLOT FROM big_storage_cage_details WHERE STATE = 100 AND sequence = 1 order by slot desc LIMIT 1) ORDER BY tempering_feed_sequence
+    </select>
+
+    <select id="queryNeedDispatchSlotBySequence" resultType="com.mes.bigstorage.entity.dto.BigStorageSlotDTO">
+        with glass_temp as (
+        select t.* ,t1.virtual_slot,t1.slot_sequence from big_storage_cage_details t inner join
+        big_storage_glass_relation_info t1 on t.engineer_id = t1.engineer_id
+        and t.tempering_layout_id = t1.tempering_layout_id
+        and t.tempering_feed_sequence = t1.tempering_feed_sequence where t.state = 100
+        ),slot_max_temp as (
+        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence desc)
+        as rn,t.* from glass_temp t where t.device_id in (5,6)
+        ) ,slot_max_message as (select * from slot_max_temp where rn =1)
+        ,slot_min_temp as (
+        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence) as
+        rn,t.* from glass_temp t where t.device_id in (5,6)
+        ) ,slot_min_message as (select * from slot_min_temp where rn =1)
+        ,result as (
+        select t.slot as target_slot ,t1.slot as start_slot from slot_max_message t inner join slot_min_message t1 on
+        t.engineer_id = t1.engineer_id and t.tempering_layout_id = t1.tempering_layout_id and t.virtual_slot =
+        t1.virtual_slot and t.tempering_layout_id = t1.tempering_layout_id and t.tempering_feed_sequence =
+        t1.tempering_feed_sequence -1
+        )select * from result limit 1
+    </select>
     <select id="queryTemperingGlassCountSummary" resultMap="temperingGlassCount">
         with glass_info_temp as (
         select engineer_id, tempering_layout_id, count(*) as total_count

--
Gitblit v1.8.0