From db3d5331c74d29806622dd272630243a74745c82 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期三, 05 三月 2025 17:04:00 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/YiWuProject

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java |   71 ++++++++++++++++++++++++++++-------
 1 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
index 5099eb5..7aa6875 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
@@ -28,6 +28,7 @@
 import freemarker.template.Version;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -59,6 +60,12 @@
 
     @Resource
     RedisUtil redisUtil;
+
+    @Value("${mes.glassGap}")
+    private Integer glassGap;
+
+    @Value("${mes.carWidth}")
+    private Integer carWidth;
 
     private static final int ID_RATIO = 10;
 
@@ -328,20 +335,45 @@
                 .queryOutGlassList(request.getFlowCardId(), request.getCell());
         int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity();
         List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>();
-        loop:
-        for (HollowBigStorageCageDetails queue : hollowBigStorageCageDetailsList) {
-            HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
-            BeanUtils.copyProperties(queue, queueInfo);
-            queueInfo.setRelationId(info.getId());
-            queueInfo.setState(Const.TEMPERING_NEW);
-            queueInfo.setCell(request.getCell());
-            queueInfo.setCreateTime(new Date());
-            queueInfo.setUpdateTime(new Date());
-            hollowQueues.add(queueInfo);
-            if (queue.getIsPair() == 1) {
-                isPairCount -= 1;
-                if (isPairCount == 0) {
-                    break loop;
+
+        if (930 == request.getCell()) {
+            Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream()
+                    .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
+            for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : listMap.entrySet()) {
+                //鍒涘缓闃熷垪鎺ユ敹涓嶆弧瓒虫垚瀵规儏鍐典笅锛氫竴瀵圭幓鐠冨垎鍑犳涓婅溅鐨勬搴忛棶棰�
+                List<HollowGlassQueueInfo> tempList = new ArrayList<>();
+                //鍏堝皢鐜荤拑鎸夌収姝e父椤哄簭鎺掑垪锛岃绠椾竴杞︽渶澶氭斁鍑犲潡锛岀畻濂藉潡鏁颁箣鍚庡皢涓�杞︾殑鐜荤拑鎸夌収鍊掑簭瀛樺偍
+                List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue());
+                int remainWidth = carWidth;
+                for (HollowBigStorageCageDetails item : reverse) {
+                    remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight());
+                    if (remainWidth < 0) {
+                        tempList = CollectionUtil.reverse(tempList);
+                        remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight());
+                    }
+                    HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
+                    tempList.add(queueInfo);
+                    remainWidth = remainWidth - glassGap;
+                }
+                hollowQueues.addAll(tempList);
+                HollowBigStorageCageDetails cageDetails = entry.getValue().get(0);
+                if (cageDetails.getIsPair() == 1) {
+                    isPairCount = isPairCount - cageDetails.getTotalLayer();
+                    if (isPairCount == 0) {
+                        break;
+                    }
+                }
+            }
+        } else {
+            loop:
+            for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) {
+                HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
+                hollowQueues.add(queueInfo);
+                if (item.getIsPair() == 1) {
+                    isPairCount = isPairCount - 1;
+                    if (isPairCount == 0) {
+                        break loop;
+                    }
                 }
             }
         }
@@ -355,5 +387,16 @@
         }
         return info;
     }
+
+    private HollowGlassQueueInfo HollowBDetailToQueue(HollowBigStorageCageDetails details, Long taskId, int targetCell) {
+        HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
+        BeanUtils.copyProperties(details, queueInfo);
+        queueInfo.setRelationId(taskId);
+        queueInfo.setState(Const.TEMPERING_NEW);
+        queueInfo.setCell(targetCell);
+        queueInfo.setCreateTime(new Date());
+        queueInfo.setUpdateTime(new Date());
+        return queueInfo;
+    }
 }
 

--
Gitblit v1.8.0