From f44f00034483637a48c4cfedf7b6e93b83c8c6af Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 30 十月 2025 03:36:24 +0800
Subject: [PATCH] 1、 中空理片笼任务优化:进片调度增加限制,避免重复生成调度任务

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

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 f24eb99..3d508b1 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
@@ -15,7 +15,9 @@
 import com.mes.hollow.entity.HollowBigStorageCageDetails;
 import com.mes.hollow.entity.HollowGlassOutRelationInfo;
 import com.mes.hollow.entity.HollowGlassRelationInfo;
-import com.mes.hollow.entity.dto.*;
+import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
+import com.mes.hollow.entity.dto.HollowBigStorageDTO;
+import com.mes.hollow.entity.dto.LackDetailsDTO;
 import com.mes.hollow.entity.vo.HollowAllFlowCardVO;
 import com.mes.hollow.entity.vo.HollowBigStorageDetailsQueryVO;
 import com.mes.hollow.mapper.HollowGlassRelationInfoMapper;
@@ -23,6 +25,9 @@
 import com.mes.hollow.service.HollowBigStorageCageService;
 import com.mes.hollow.service.HollowGlassOutRelationInfoService;
 import com.mes.hollow.service.HollowGlassRelationInfoService;
+import com.mes.order.entity.HollowGlassDetailsDTO;
+import com.mes.order.entity.OrderDetailsDTO;
+import com.mes.order.service.OrdersService;
 import com.mes.sysconfig.service.SysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -60,6 +65,8 @@
     SysConfigService sysConfigService;
     @Resource
     DamageService damageService;
+    @Resource
+    OrdersService ordersService;
 //    @Value("${mes.slotWidth}")
 //    private Integer slotWidth;
 //    @Value("${mes.glassGap}")
@@ -107,11 +114,24 @@
         if (null == relationInfoOne) {
             throw new RuntimeException("鐩稿叧娴佺▼鍗℃湭鎵惧埌瀵瑰簲鐨勭粍鍙蜂俊鎭紝鐜荤拑娴佺▼鍗★細" + flowCardId + "锛屽簭鍙凤細" + glassType + "锛屾�诲眰鏁帮細" + totalLayer + "锛屽眰鏁帮細" + layer);
         }
+        Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT);
         Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
+        HollowBigStorageCage storageCage = null;
+        if (Math.min(width, height) > slotMaxHeight) {
+            storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>()
+                    .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth)
+                    .eq(HollowBigStorageCage::getDeviceId, 6)
+                    .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1"));
+            HollowBigStorageDTO storageDTO = new HollowBigStorageDTO();
+            BeanUtils.copyProperties(storageCage, storageDTO);
+            BeanUtils.copyProperties(relationInfoOne, storageDTO);
+            return storageDTO;
+        }
+
         //璇︽儏琛ㄥ唴鑾峰彇鏈粍鏄惁宸茬粡鏈夌幓鐠冨湪绗煎瓙鍐咃紙0琛ㄧず鎻愬墠鍗犵敤锛�
         int taskCount = hollowGlassOutRelationInfoService.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                 .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId));
-        HollowBigStorageCage storageCage = null;
+
         //濡傛灉涓嶅瓨鍦ㄥ垯閫夋嫨绗煎唴鏈敤鐨勬柊鏍煎瓙
         if (taskCount > 0) {
             storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>()
@@ -207,13 +227,13 @@
             return;
         }
         //鎸夌収娴佺▼鍗¤幏鍙栨湰娴佺▼鍗℃渶鍚庝竴灞傛垨绗竴娆$殑鐜荤拑鏁版嵁
-        List<HollowGlassDetailsDTO> glassDetailsDTOS = this.baseMapper.queryFlowCardIdMaxLayerGlassInfo(flowCardId, totalLayer);
+        List<HollowGlassDetailsDTO> glassDetailsDTOS = ordersService.queryFlowCardIdMaxLayerGlassInfo(flowCardId, totalLayer);
         if (CollectionUtil.isEmpty(glassDetailsDTOS)) {
             log.info("褰撳墠娴佺▼鍗℃渶澶栧眰鏁版嵁鏈壘鍒帮紝璇峰湪erp纭鏁版嵁鏃犺锛屾祦绋嬪崱锛歿}锛屾�诲眰鏁皗}", flowCardId, totalLayer);
             return;
         }
         if (totalLayer != layer) {
-            glassDetailsDTOS = this.baseMapper.queryFlowCardIdLayerGlassInfo(flowCardId, totalLayer, layer);
+            glassDetailsDTOS = ordersService.queryFlowCardIdLayerGlassInfo(flowCardId, totalLayer, layer);
         }
         if (CollectionUtil.isEmpty(glassDetailsDTOS)) {
             log.info("褰撳墠娴佺▼鍗℃渶澶栧眰鏁版嵁鏈壘鍒帮紝璇峰湪erp纭鏁版嵁鏃犺锛屾祦绋嬪崱锛歿}锛屾�诲眰鏁皗},灞傛暟{}", flowCardId, totalLayer, layer);
@@ -298,8 +318,12 @@
         for (List<HollowGlassRelationInfo> item : tempHollowList) {
             relationInfoList.addAll(item);
         }
-        log.info("鍒嗛厤瀹屾瘯");
-        this.saveBatch(relationInfoList);
+        log.info("鍒嗛厤瀹屾瘯:{}", relationInfoList);
+        try {
+            this.saveBatch(relationInfoList);
+        } catch (Exception e) {
+            log.error("淇濆瓨澶辫触:{}", e);
+        }
     }
 
     @Override
@@ -404,7 +428,7 @@
     }
 
     @Override
-    public Map<Integer,List<LackDetailsDTO>> queryLackByFlowCard(String flowCardId) {
+    public Map<Integer, List<LackDetailsDTO>> queryLackByFlowCard(String flowCardId) {
         List<LackDetailsDTO> detailsDTOS = baseMapper.queryLackByFlowCard(flowCardId);
         return detailsDTOS.stream().collect(Collectors.groupingBy(item -> item.getLayer()));
     }
@@ -440,13 +464,13 @@
     }
 
     @Override
-    public List<GlassInfo> queryLackGlassByFlowCard(HollowBigStorageDetailsQueryVO query) {
+    public List<LackDetailsDTO> queryLackGlassByFlowCard(HollowBigStorageDetailsQueryVO query) {
         return baseMapper.queryLackGlassByFlowCard(query.getFlowCardId(), query.getOrderSort(), query.getLayer());
     }
 
     @Override
     public OrderDetailsDTO queryProductNameByFlowCardId(String flowCardId, String productName, String customerName) {
-        OrderDetailsDTO dto = hollowGlassOutRelationInfoService.queryProductNameByFlowCardId(flowCardId);
+        OrderDetailsDTO dto = ordersService.queryProductNameByFlowCardId(flowCardId);
         if ((StringUtils.isBlank(productName) || dto.getProductName().contains(productName)) && (StringUtils.isBlank(customerName) || dto.getCustomerName().contains(customerName))) {
             return dto;
         }

--
Gitblit v1.8.0