From c6cb57f307b0c62a05cac78cfd828c313f10e611 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期二, 15 四月 2025 10:58:25 +0800
Subject: [PATCH] 1、卧式理片笼新增任务逻辑 2、入参时间加入时区

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java |   90 +++++++++++++++++++++++++++++---------------
 1 files changed, 59 insertions(+), 31 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 d35a8a0..75754d3 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
@@ -10,15 +10,18 @@
 import com.mes.glassinfo.service.GlassInfoService;
 import com.mes.hollow.entity.HollowBigStorageCage;
 import com.mes.hollow.entity.HollowBigStorageCageDetails;
+import com.mes.hollow.entity.HollowGlassOutRelationInfo;
 import com.mes.hollow.entity.HollowGlassRelationInfo;
 import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
 import com.mes.hollow.entity.dto.HollowBigStorageDTO;
 import com.mes.hollow.entity.dto.HollowGlassDetailsDTO;
 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;
 import com.mes.hollow.service.HollowBigStorageCageDetailsService;
 import com.mes.hollow.service.HollowBigStorageCageService;
+import com.mes.hollow.service.HollowGlassOutRelationInfoService;
 import com.mes.hollow.service.HollowGlassRelationInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -27,7 +30,7 @@
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -48,6 +51,8 @@
     HollowBigStorageCageService hollowBigStorageCageService;
     @Resource
     HollowGlassRelationInfoService hollowGlassRelationInfoService;
+    @Resource
+    HollowGlassOutRelationInfoService hollowGlassOutRelationInfoService;
     @Resource
     HollowBigStorageCageDetailsService hollowBigStorageCageDetailsService;
     @Value("${mes.slotWidth}")
@@ -72,9 +77,18 @@
                 .last("limit 1")
         );
         if (relationInfoOne == null) {
+            //鏌ョ湅mes鏄惁鏈夊搴旂殑娴佺▼鍗′俊鎭�
+            int count = hollowGlassRelationInfoService.count(new LambdaQueryWrapper<HollowGlassRelationInfo>()
+                    .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
+                    .eq(HollowGlassRelationInfo::getLayer, layer));
+            if (count == 0) {
+                generateHollowGlassInfo(flowCardId, totalLayer, layer);
+            } else {
+                //姣旇緝鍏崇郴琛ㄥ強涓┖鐞嗙墖绗艰鎯呰〃鐨勬祦绋嬪崱鏁版嵁锛屽鐞嗚剰鏁版嵁锛氬皢涓嶅湪绗煎唴鐨勬祦绋嬪崱鍖归厤鏁版嵁鑱屼綅绌�
+                this.baseMapper.clearDirtyFlowCardData(flowCardId, layer);
+            }
             //鐞嗙墖绗煎叧绯昏〃涓病鏈夊搴旂殑鏁版嵁锛屾煡鐪嬬悊鐗囩铏氭嫙浣嶇疆琛ㄦ槸鍚︽湁鏈伐绋嬩笅鐨勬墍鏈夌幓鐠冭櫄鎷熶俊鎭�
             //铏氭嫙浣嶇疆琛ㄦ病鏈夋湰宸ョ▼涓嬬殑鎵�鏈夌幓鐠冭櫄鎷熶俊鎭紝鎸夌収鐜荤拑id鐢熸垚鏈伐绋嬩笅鎵�鏈夌幓鐠冪殑铏氭嫙淇℃伅
-            generateHollowGlassInfo(flowCardId, totalLayer, layer);
             relationInfoOne = this.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>()
                     .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
                     .eq(HollowGlassRelationInfo::getWidth, width)
@@ -87,13 +101,27 @@
             );
         }
         //璇︽儏琛ㄥ唴鑾峰彇鏈粍鏄惁宸茬粡鏈夌幓鐠冨湪绗煎瓙鍐咃紙0琛ㄧず鎻愬墠鍗犵敤锛�
+        int taskCount = hollowGlassOutRelationInfoService.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId));
+        HollowBigStorageCage storageCage = null;
+        //濡傛灉涓嶅瓨鍦ㄥ垯閫夋嫨绗煎唴鏈敤鐨勬柊鏍煎瓙
+        if (taskCount > 0) {
+            storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>()
+                    .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth)
+                    .le(HollowBigStorageCage::getMinThickness, relationInfoOne.getThickness())
+                    .ge(HollowBigStorageCage::getMaxThickness, relationInfoOne.getThickness())
+                    .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1"));
+            HollowBigStorageDTO storageDTO = new HollowBigStorageDTO();
+            BeanUtils.copyProperties(storageCage, storageDTO);
+            BeanUtils.copyProperties(relationInfoOne, storageDTO);
+            return storageDTO;
+        }       //璇︽儏琛ㄥ唴鑾峰彇鏈粍鏄惁宸茬粡鏈夌幓鐠冨湪绗煎瓙鍐咃紙0琛ㄧず鎻愬墠鍗犵敤锛�
         List<HollowBigStorageCageDetails> hollowDetailsList = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                 .eq(HollowBigStorageCageDetails::getFlowCardId, relationInfoOne.getFlowCardId())
                 .eq(HollowBigStorageCageDetails::getTotalLayer, totalLayer)
                 .eq(HollowBigStorageCageDetails::getLayer, layer)
                 .eq(HollowBigStorageCageDetails::getVirtualSlot, relationInfoOne.getVirtualSlot())
                 .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO));
-        HollowBigStorageCage storageCage = null;
         //濡傛灉涓嶅瓨鍦ㄥ垯閫夋嫨绗煎唴鏈敤鐨勬柊鏍煎瓙
         if (CollectionUtil.isEmpty(hollowDetailsList)) {
             storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>()
@@ -165,7 +193,7 @@
     public void generateHollowGlassInfo(String flowCardId, int totalLayer, int layer) {
 
         GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, flowCardId)
-                .eq(GlassInfo::getLayer, layer).last("limit 1"));
+                .eq(GlassInfo::getLayer, layer).orderByDesc(GlassInfo::getId).last("limit 1"));
         if (null == glassInfo) {
             log.info("褰撳墠娴佺▼鍗′俊鎭负瀵煎叆mes绯荤粺娴佺▼鍗★細{}锛屽眰鏁皗}", flowCardId, layer);
             return;
@@ -262,7 +290,7 @@
     }
 
     @Override
-    public Map<String, List<FlowCardGlassInfoDTO>> queryHollowAllFlowCard(HollowBigStorageDetailsQueryVO query) {
+    public List<HollowAllFlowCardVO> queryHollowAllFlowCard(HollowBigStorageDetailsQueryVO query) {
         List<HollowBigStorageCageDetails> detailsList = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                 .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                 .like(StringUtils.isNotBlank(query.getFilmsId()), HollowBigStorageCageDetails::getFilmsId, query.getFilmsId())
@@ -272,37 +300,32 @@
         );
         if (CollectionUtil.isEmpty(detailsList)) {
             log.info("绗煎唴鏃犵幓鐠�");
-            return new HashMap<>();
+            return new ArrayList<>();
         }
         Map<String, List<HollowBigStorageCageDetails>> listMap = detailsList.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getFlowCardId));
-        List<FlowCardGlassInfoDTO> dtos = new ArrayList<>();
+        List<HollowAllFlowCardVO> resultList = new ArrayList<>();
         listMap.forEach((e, v) -> {
+            HollowAllFlowCardVO hollowAllFlowCardVO = new HollowAllFlowCardVO();
             HollowBigStorageCageDetails cageDetails = v.get(0);
-            dtos.addAll(hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE));
+            hollowAllFlowCardVO.setFlowCardId(e);
+            if (cageDetails.getHollowSequence() == 0) {
+                hollowAllFlowCardVO.setIsThroughSlot(Boolean.TRUE);
+            } else {
+                hollowAllFlowCardVO.setIsThroughSlot(Boolean.FALSE);
+            }
+            //鎸夌収娴佺▼鍗¤幏鍙栧搴旂殑浜у搧鍚嶇О
+            String productName = baseMapper.queryProductNameByFlowCardId(cageDetails.getFlowCardId());
+            hollowAllFlowCardVO.setProductName(productName);
+            List<FlowCardGlassInfoDTO> flowCardInfoList = hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE);
+            hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(flowCardInfoList);
+            resultList.add(hollowAllFlowCardVO);
         });
-        Map<String, FlowCardGlassInfoDTO> result = dtos.stream()
-                .collect(Collectors.toMap(
-                        FlowCardGlassInfoDTO::getFlowCardId,
-                        dto -> {
-                            FlowCardGlassInfoDTO newDto = new FlowCardGlassInfoDTO();
-                            newDto.setFlowCardId(dto.getFlowCardId());
-                            newDto.setSumCount(dto.getSumCount());
-                            newDto.setPairCount(dto.getPairCount());
-                            newDto.setRealCount(dto.getRealCount());
-                            newDto.setLayer(dto.getLayer());
-                            return newDto;
-                        },
-                        (dto1, dto2) -> {
-                            dto1.setRealCount(dto1.getRealCount() + dto2.getRealCount()); // 绱姞 realCount
-                            dto1.setLayer(Math.max(dto1.getLayer(),dto2.getLayer())); // 绱姞 鏈�澶у眰鏁�
-                            return dto1; // 杩斿洖鍚堝苟鍚庣殑瀵硅薄
-                        }
-                ));
-        return dtos.stream().collect(Collectors.groupingBy(FlowCardGlassInfoDTO::getFlowCardId));
+        return resultList;
+//        return dtos.stream().collect(Collectors.groupingBy(e -> e.getFlowCardId() + ":" + e.getProductName()));
     }
 
     @Override
-    public Map<String, FlowCardGlassInfoDTO> queryHollowAllFlowCardSummary(HollowBigStorageDetailsQueryVO query) {
+    public List<FlowCardGlassInfoDTO> queryHollowAllFlowCardSummary(HollowBigStorageDetailsQueryVO query) {
         List<HollowBigStorageCageDetails> detailsList = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                 .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                 .like(StringUtils.isNotBlank(query.getFilmsId()), HollowBigStorageCageDetails::getFilmsId, query.getFilmsId())
@@ -312,7 +335,7 @@
         );
         if (CollectionUtil.isEmpty(detailsList)) {
             log.info("绗煎唴鏃犵幓鐠�");
-            return new HashMap<>();
+            return null;
         }
         Map<String, List<HollowBigStorageCageDetails>> listMap = detailsList.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getFlowCardId));
         List<FlowCardGlassInfoDTO> dtos = new ArrayList<>();
@@ -335,12 +358,17 @@
                         },
                         (dto1, dto2) -> {
                             dto1.setRealCount(dto1.getRealCount() + dto2.getRealCount()); // 绱姞 realCount
-                            dto1.setLayer(Math.max(dto1.getLayer(),dto2.getLayer())); // 绱姞 鏈�澶у眰鏁�
+                            dto1.setLayer(Math.max(dto1.getLayer(), dto2.getLayer())); // 绱姞 鏈�澶у眰鏁�
                             dto1.setSlotCount(dto1.getSlotCount() + dto2.getSlotCount());
                             return dto1; // 杩斿洖鍚堝苟鍚庣殑瀵硅薄
                         }
                 ));
-        return result;
+        List<FlowCardGlassInfoDTO> resultList = new ArrayList<>(result.values());
+        List<FlowCardGlassInfoDTO> sortedList = resultList.stream()
+                .sorted(Comparator.comparing(FlowCardGlassInfoDTO::getRealCount).reversed()  // 绗竴涓瓧娈靛�掑簭
+                        .thenComparing(FlowCardGlassInfoDTO::getSumCount, Comparator.reverseOrder()))  // 绗簩涓瓧娈靛�掑簭
+                .collect(Collectors.toList());
+        return sortedList;
     }
 
     @Override

--
Gitblit v1.8.0