From 83f738105416c9b11e3b7c5246a0980e41b6650e Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 13 十月 2025 16:59:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java |  108 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 71 insertions(+), 37 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 3ce5542..92fd878 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
@@ -7,6 +7,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mes.common.config.Const;
+import com.mes.common.config.ConstSysConfig;
 import com.mes.glassinfo.entity.GlassInfo;
 import com.mes.glassinfo.service.GlassInfoService;
 import com.mes.hollow.controller.HollowBigStorageCageController;
@@ -23,6 +24,11 @@
 import com.mes.hollow.service.HollowGlassRelationInfoService;
 import com.mes.hollowqueue.entity.HollowGlassQueueInfo;
 import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
+import com.mes.largenscreen.entity.PieChartVO;
+import com.mes.order.entity.HollowOrderDTO;
+import com.mes.order.entity.OrderDetailsDTO;
+import com.mes.order.service.OrdersService;
+import com.mes.sysconfig.service.SysConfigService;
 import com.mes.tools.DateUtil;
 import com.mes.utils.Blank;
 import com.mes.utils.RedisUtil;
@@ -32,8 +38,9 @@
 import freemarker.template.Version;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.*;
@@ -61,24 +68,30 @@
     HollowFormulaDetailsService hollowFormulaDetailsService;
     @Resource
     HollowGlassRelationInfoService hollowGlassRelationInfoService;
+    @Resource
+    SysConfigService sysConfigService;
+    @Resource
+    OrdersService ordersService;
 
     @Resource
     RedisUtil redisUtil;
 
-    @Value("${mes.glassGap}")
-    private Integer glassGap;
-
-    @Value("${mes.carWidth}")
-    private Integer carWidth;
+//    @Value("${mes.glassGap}")
+//    private Integer glassGap;
+//
+//    @Value("${mes.carWidth}")
+//    private Integer carWidth;
 
     private static final int ID_RATIO = 10;
 
     @Override
+    @Transactional
     public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) {
         return childrenTask(request, 0);
     }
 
     @Override
+    @Transactional
     public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) {
         return childrenTask(request, 1);
     }
@@ -87,6 +100,12 @@
     public Boolean dispatchHollowSwitch(Boolean flag) {
         redisUtil.setCacheObject("dispatchHollowSwitch", flag);
         return redisUtil.getCacheObject("dispatchHollowSwitch");
+    }
+
+    @Override
+    public Boolean priorityHollowSwitch(Boolean flag) {
+        redisUtil.setCacheObject("priorityHollowSwitch", flag);
+        return redisUtil.getCacheObject("priorityHollowSwitch");
     }
 
     @Override
@@ -102,44 +121,44 @@
     }
 
     @Override
-    public List<HollowGlassQueueInfo> appointHollowTaskDetails(String flowCardId, int cell) {
+    public Map<String, List<HollowGlassQueueInfo>> appointHollowTaskDetails(int cell) {
         //鎸夌収娴佺▼鍗″強璺嚎锛屾煡鎵惧搴旂殑浠诲姟淇℃伅
-        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = this.getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+        List<HollowGlassOutRelationInfo> hollowGlassOutRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                 .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)
-                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
-                .eq(HollowGlassOutRelationInfo::getCell, cell).last("limit 1"));
-        if (null == hollowGlassOutRelationInfo) {
-            return new ArrayList<HollowGlassQueueInfo>();
+                .eq(HollowGlassOutRelationInfo::getCell, cell));
+        if (CollectionUtil.isEmpty(hollowGlassOutRelationInfos)) {
+            return null;
         }
+        List<Long> ids = hollowGlassOutRelationInfos.stream()
+                .map(HollowGlassOutRelationInfo::getId) // 鎻愬彇姣忎釜鍏冪礌鐨刬d
+                .collect(Collectors.toList());
         //鎸夌収浠诲姟id鏌ヨ瀵瑰垪琛ㄤ腑鐨勯槦鍒椾俊鎭�
-        return hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
-                .eq(HollowGlassQueueInfo::getRelationId, hollowGlassOutRelationInfo.getId()));
+        List<HollowGlassQueueInfo> hollowGlassQueueInfos = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
+                .in(HollowGlassQueueInfo::getRelationId, ids)
+                .orderByAsc(HollowGlassQueueInfo::getId));
+        Map<String, List<HollowGlassQueueInfo>> groupedByFlowCardId = hollowGlassQueueInfos.stream()
+                .collect(Collectors.groupingBy(
+                        HollowGlassQueueInfo::getFlowCardId,
+                        LinkedHashMap::new,
+                        Collectors.toList()
+                ));
+        return groupedByFlowCardId;
     }
 
     @Override
-    public Boolean startTask(String flowCardId, int cell) {
-        log.info("鏌ョ湅璇ユ祦绋嬪崱鏄惁鐢辨鍦ㄦ墽琛岀殑浠诲姟锛屾祦绋嬪崱锛歿}", flowCardId);
-        int taskCount = this.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
-                .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)
-                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId));
-        if (taskCount == 0 || taskCount > 1) {
-            log.info("璇ユ祦绋嬪崱涓嶅瓨鍦ㄤ换鍔℃垨鑰呮湁姝e湪鎵ц涓紝鏃犳硶鍐嶆鎵ц");
-            return Boolean.FALSE;
-        }
+    public Boolean startTask(int cell) {
         //鏇存柊浠诲姟鐘舵�佷负寮�濮�
         return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
                 .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
-                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
                 .ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
                 .eq(HollowGlassOutRelationInfo::getCell, cell));
     }
 
     @Override
-    public Boolean pauseTask(String flowCardId, int cell) {
+    public Boolean pauseTask(int cell) {
 //        鏇存柊浠诲姟鐘舵�佷负鏆傚仠
         return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
                 .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_PAUSE)
-                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
                 .ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
                 .eq(HollowGlassOutRelationInfo::getCell, cell));
     }
@@ -186,7 +205,7 @@
             return "浠诲姟鎬诲眰鏁板皬浜�2锛屼笉鐢熸垚鏉庤禌鍏嬫枃浠�";
         }
         //鑾峰彇璁㈠崟鐩稿叧淇℃伅
-        OrderDTO order = baseMapper.queryOrderByFlowCardId(flowCardId);
+        HollowOrderDTO order = ordersService.queryOrderByFlowCardId(flowCardId);
         if (null == order) {
             return "鐢熸垚澶辫触锛岀浉鍏宠鍗曚俊鎭笉瀛樺湪";
         }
@@ -213,14 +232,16 @@
 
         //璁剧疆鏂囦欢绗竴灞傚垪琛ㄦ暟鎹�
         //鏆傛椂鐢熸垚绗煎唴鎵�鏈夌殑鐜荤拑淇℃伅锛堝凡閰嶅鍜屾湭閰嶅鐨勶級
-//        List<HollowGlassRelationInfo> hollowGlassRelationInfos = hollowGlassRelationInfoService.list(new LambdaQueryWrapper<HollowGlassRelationInfo>()
-//                .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId).orderByAsc(HollowGlassRelationInfo::getHollowSequence));
         List<HollowBigStorageCageDetails> hollowGlassRelationInfos = hollowBigStorageCageDetailsService.queryPairGlassList(flowCardId, relationInfo.getTotalLayer(), relationInfo.getTotalPairQuantity(), isOut);
-        Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
-
+        Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream()
+                .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence,
+                        Collectors.collectingAndThen(Collectors.toList(),
+                                list -> list.stream().sorted(Comparator.comparing(HollowBigStorageCageDetails::getLayer)).collect(Collectors.toList()))));
+        Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
+        sortListMap.putAll(listMap);
         //璁剧疆闂撮殧鏉挎暟鎹叡鎵�鏈夐厤瀵圭幓鐠冧娇鐢�
         List<LisecHollowGlassAndFrameDetails> glassAndFrameList = new ArrayList<>();
-        listMap.forEach((e, v) -> {
+        sortListMap.forEach((e, v) -> {
             LisecHollowGlassAndFrameDetails glassAndFrame = new LisecHollowGlassAndFrameDetails();
             List<LisecHollowGlassDetails> glassList = new ArrayList<>();
             List<LisecHollowFrameDetails> frameList = new ArrayList<>();
@@ -281,10 +302,7 @@
             glassAndFrame.setFrameList(frameList);
             glassAndFrameList.add(glassAndFrame);
         });
-        Collections.sort(glassAndFrameList, (s1, s2) -> Integer.parseInt(s1.getItemNum()) - Integer.parseInt(s2.getItemNum()));
         details.setGlassAndFrameList(glassAndFrameList);
-
-
         Configuration cfg = new Configuration(new Version("2.3.29"));
         cfg.setClassForTemplateLoading(HollowBigStorageCageController.class, "/templates/");
         // 鍒涘缓Calculator瀹炰緥
@@ -330,6 +348,12 @@
         return this.page(page, wrapper);
     }
 
+    @Override
+    @Cacheable(value = "orderDetails", key = "#flowCardId")
+    public OrderDetailsDTO queryProductNameByFlowCardId(String flowCardId) {
+        log.info("鏌ヨ鏁版嵁搴撲竴娆★細{}", flowCardId);
+        return ordersService.queryProductNameByFlowCardId(flowCardId);
+    }
 
     private HollowGlassOutRelationInfo childrenTask(HollowTaskRequest request, int isForce) {
         GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1"));
@@ -359,11 +383,15 @@
                 .queryOutGlassList(request.getFlowCardId(), request.getCell());
         int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity();
         List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>();
-
+        Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH);
+//        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP);
+        Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness());
         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()) {
+            Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
+            sortListMap.putAll(listMap);
+            for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) {
                 //鍒涘缓闃熷垪鎺ユ敹涓嶆弧瓒虫垚瀵规儏鍐典笅锛氫竴瀵圭幓鐠冨垎鍑犳涓婅溅鐨勬搴忛棶棰�
                 List<HollowGlassQueueInfo> tempList = new ArrayList<>();
                 //鍏堝皢鐜荤拑鎸夌収姝e父椤哄簭鎺掑垪锛岃绠椾竴杞︽渶澶氭斁鍑犲潡锛岀畻濂藉潡鏁颁箣鍚庡皢涓�杞︾殑鐜荤拑鎸夌収鍊掑簭瀛樺偍
@@ -389,6 +417,7 @@
                     }
                 }
             }
+
         } else {
             loop:
             for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) {
@@ -423,5 +452,10 @@
         queueInfo.setUpdateTime(new Date());
         return queueInfo;
     }
+
+    @Override
+    public List<PieChartVO> queryPieChart() {
+        return baseMapper.queryPieChart();
+    }
 }
 

--
Gitblit v1.8.0