wangfei
2025-04-21 09402133807b1e774e658a13ad365b2e6efca25b
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
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.entity.HollowBigStorageCage;
@@ -16,19 +17,23 @@
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 com.mes.sysconfig.service.SysConfigService;
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;
import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -51,13 +56,15 @@
    HollowGlassOutRelationInfoService hollowGlassOutRelationInfoService;
    @Resource
    HollowBigStorageCageDetailsService hollowBigStorageCageDetailsService;
    @Value("${mes.slotWidth}")
    private Integer slotWidth;
    @Value("${mes.glassGap}")
    private Integer glassGap;
    @Value("${mes.outCarMaxSize}")
    private Integer outCarMaxSize;
    @Resource
    SysConfigService sysConfigService;
//    @Value("${mes.slotWidth}")
//    private Integer slotWidth;
//    @Value("${mes.glassGap}")
//    private Integer glassGap;
//
//    @Value("${mes.outCarMaxSize}")
//    private Integer outCarMaxSize;
    @Override
    public HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, double width, double height, int totalLayer, int layer) {
@@ -96,6 +103,7 @@
                    .last("limit 1")
            );
        }
        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
        //详情表内获取本组是否已经有玻璃在笼子内(0表示提前占用)
        int taskCount = hollowGlassOutRelationInfoService.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId));
@@ -240,6 +248,10 @@
//        List<HollowBigStorageCage> hollowSlotList = HollowBigStorageCageService.list(new LambdaQueryWrapper<HollowBigStorageCage>()
//                .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth));
        //方式二:将玻璃按流程卡、尺寸、版图、版序 ,优先将格子全部补全后 依次计算后面的格子号
        Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH);
        Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP);
        Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_OUT_CAR_SIZE);
        List<HollowGlassRelationInfo> relationInfoList = new ArrayList();
        List<List<HollowGlassRelationInfo>> tempHollowList = new ArrayList<>();
        int slotNumber = 1;
@@ -286,7 +298,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())
@@ -296,33 +308,28 @@
        );
        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
@@ -359,7 +366,7 @@
                        },
                        (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; // 返回合并后的对象
                        }