wangfei
2025-10-14 d271d4f365b0f76b415d49725652d8a575028fba
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -23,10 +23,12 @@
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;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -61,6 +63,8 @@
    SysConfigService sysConfigService;
    @Resource
    DamageService damageService;
    @Resource
    OrdersService ordersService;
//    @Value("${mes.slotWidth}")
//    private Integer slotWidth;
//    @Value("${mes.glassGap}")
@@ -208,13 +212,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);
@@ -299,33 +303,32 @@
        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
    public List<HollowAllFlowCardVO> queryHollowAllFlowCard(HollowBigStorageDetailsQueryVO query) {
        Date startDate = new Date();
        log.info("开始查询中空流程卡任务信息,开始时间{}", startDate);
        List<HollowBigStorageCageDetails> detailsList = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                .like(StringUtils.isNotBlank(query.getFilmsId()), HollowBigStorageCageDetails::getFilmsId, query.getFilmsId())
                .like(StringUtils.isNotBlank(query.getFlowCardId()), HollowBigStorageCageDetails::getFlowCardId, query.getFlowCardId())
                .eq(query.getThickness() != 0, HollowBigStorageCageDetails::getThickness, query.getThickness())
                .orderByAsc(HollowBigStorageCageDetails::getFlowCardId)
        );
        List<FlowCardGlassInfoDTO> detailsList = hollowBigStorageCageDetailsService.queryHollowAllFlowCard(query);
        if (CollectionUtil.isEmpty(detailsList)) {
            log.info("笼内无玻璃");
            return new ArrayList<>();
        }
        Date middleDate = new Date();
        log.info("中空理片笼详情数据已查询完毕,耗时:{}ms", middleDate.getTime() - startDate.getTime());
        Map<String, List<HollowBigStorageCageDetails>> listMap = detailsList.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getFlowCardId));
        Map<String, List<FlowCardGlassInfoDTO>> listMap = detailsList.stream().collect(Collectors.groupingBy(FlowCardGlassInfoDTO::getFlowCardId));
        List<HollowAllFlowCardVO> resultList = new ArrayList<>();
        AtomicInteger pairTotalCount = new AtomicInteger();
        listMap.forEach((e, v) -> {
            HollowAllFlowCardVO hollowAllFlowCardVO = new HollowAllFlowCardVO();
            HollowBigStorageCageDetails cageDetails = v.get(0);
            FlowCardGlassInfoDTO cageDetails = v.get(0);
            //按照流程卡获取对应的产品名称
            OrderDetailsDTO orderDetails = this.queryProductNameByFlowCardId(cageDetails.getFlowCardId(), query.getProductName(), query.getCustomerName());
            if (null != orderDetails) {
@@ -336,12 +339,8 @@
                } else {
                    hollowAllFlowCardVO.setIsThroughSlot(Boolean.FALSE);
                }
                List<FlowCardGlassInfoDTO> flowCardInfoList = hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE);
                log.info("获取到的流程卡信息为:{}", flowCardInfoList);
                if (CollectionUtil.isNotEmpty(flowCardInfoList)) {
                    hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(flowCardInfoList);
                    pairTotalCount.addAndGet(flowCardInfoList.get(0).getPairCount());
                }
                hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(v);
                pairTotalCount.addAndGet(cageDetails.getPairCount());
                resultList.add(hollowAllFlowCardVO);
            }
        });
@@ -403,14 +402,20 @@
    }
    @Override
    public List<LackDetailsDTO> queryLackByFlowCard() {
        List<LackDetailsDTO> lackDetailsList = this.baseMapper.queryLackByFlowCard();
    public List<LackDetailsDTO> queryAllLackByFlowCard() {
        List<LackDetailsDTO> lackDetailsList = this.baseMapper.queryAllLackByFlowCard();
        return lackDetailsList;
    }
    @Override
    public int queryLayerByFlowCardId(String flowCardId) {
        return baseMapper.queryLayerByFlowCardId(flowCardId);
    }
    @Override
    public Map<Integer, List<LackDetailsDTO>> queryLackByFlowCard(String flowCardId) {
        List<LackDetailsDTO> detailsDTOS = baseMapper.queryLackByFlowCard(flowCardId);
        return detailsDTOS.stream().collect(Collectors.groupingBy(item -> item.getLayer()));
    }
    @Override
@@ -444,13 +449,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;
        }