wangfei
2025-04-10 91a453198edfc4450ecc91adfcccee6ccf25a3f0
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -16,6 +16,7 @@
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;
@@ -28,7 +29,10 @@
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;
/**
@@ -286,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())
@@ -296,39 +300,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);
            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);
            for (FlowCardGlassInfoDTO item : flowCardInfoList) {
                item.setProductName(productName);
                dtos.add(item);
            }
            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(e -> e.getFlowCardId() + ":" + e.getProductName()));
        return resultList;
//        return dtos.stream().collect(Collectors.groupingBy(e -> e.getFlowCardId() + ":" + e.getProductName()));
    }
    @Override