zhoushihao
2025-04-14 e42b239ac2c2a922172badbe32afaa4ba4f615f8
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
@@ -1,8 +1,10 @@
package com.mes.hollow.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.smallbun.screw.core.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mes.common.config.Const;
import com.mes.glassinfo.entity.GlassInfo;
@@ -12,6 +14,7 @@
import com.mes.hollow.entity.HollowFormulaDetails;
import com.mes.hollow.entity.HollowGlassOutRelationInfo;
import com.mes.hollow.entity.dto.*;
import com.mes.hollow.entity.request.HollowHistoryTaskRequest;
import com.mes.hollow.entity.request.HollowTaskRequest;
import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper;
import com.mes.hollow.service.HollowBigStorageCageDetailsService;
@@ -20,6 +23,8 @@
import com.mes.hollow.service.HollowGlassRelationInfoService;
import com.mes.hollowqueue.entity.HollowGlassQueueInfo;
import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
import com.mes.largenscreen.entity.PieChartVO;
import com.mes.tools.DateUtil;
import com.mes.utils.Blank;
import com.mes.utils.RedisUtil;
import freemarker.template.Configuration;
@@ -126,6 +131,7 @@
        return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
                .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
                .ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
                .eq(HollowGlassOutRelationInfo::getCell, cell));
    }
@@ -135,6 +141,7 @@
        return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
                .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_PAUSE)
                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
                .ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
                .eq(HollowGlassOutRelationInfo::getCell, cell));
    }
@@ -207,14 +214,16 @@
        //设置文件第一层列表数据
        //暂时生成笼内所有的玻璃信息(已配对和未配对的)
//        List<HollowGlassRelationInfo> hollowGlassRelationInfos = hollowGlassRelationInfoService.list(new LambdaQueryWrapper<HollowGlassRelationInfo>()
//                .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId).orderByAsc(HollowGlassRelationInfo::getHollowSequence));
        List<HollowBigStorageCageDetails> hollowGlassRelationInfos = hollowBigStorageCageDetailsService.queryPairGlassList(flowCardId, relationInfo.getTotalLayer(), relationInfo.getTotalPairQuantity(), isOut);
        Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
        Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream()
                .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence,
                        Collectors.collectingAndThen(Collectors.toList(),
                                list -> list.stream().sorted(Comparator.comparing(HollowBigStorageCageDetails::getLayer)).collect(Collectors.toList()))));
        Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
        sortListMap.putAll(listMap);
        //设置间隔板数据共所有配对玻璃使用
        List<LisecHollowGlassAndFrameDetails> glassAndFrameList = new ArrayList<>();
        listMap.forEach((e, v) -> {
        sortListMap.forEach((e, v) -> {
            LisecHollowGlassAndFrameDetails glassAndFrame = new LisecHollowGlassAndFrameDetails();
            List<LisecHollowGlassDetails> glassList = new ArrayList<>();
            List<LisecHollowFrameDetails> frameList = new ArrayList<>();
@@ -276,8 +285,6 @@
            glassAndFrameList.add(glassAndFrame);
        });
        details.setGlassAndFrameList(glassAndFrameList);
        Configuration cfg = new Configuration(new Version("2.3.29"));
        cfg.setClassForTemplateLoading(HollowBigStorageCageController.class, "/templates/");
        // 创建Calculator实例
@@ -304,6 +311,23 @@
            e.printStackTrace();
        }
        return "success";
    }
    @Override
    public Page<HollowGlassOutRelationInfo> queryHollowHistoryTask(HollowHistoryTaskRequest request) {
        Page<HollowGlassOutRelationInfo> page = new Page<>(request.getPageNo(), request.getPageSize());
        if (null == request.getBeginDate()) {
            request.setBeginDate(DateUtil.getBeginDate());
            request.setEndDate(DateUtil.getEndDate());
        }
        LambdaQueryWrapper<HollowGlassOutRelationInfo> wrapper = new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                .eq(HollowGlassOutRelationInfo::getCell, request.getCell())
                .like(StringUtils.isNotBlank(request.getFlowCardId()), HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId())
                .in(CollectionUtil.isNotEmpty(request.getIsForceList()), HollowGlassOutRelationInfo::getIsForce, request.getIsForceList())
                .in(CollectionUtil.isNotEmpty(request.getStateList()), HollowGlassOutRelationInfo::getState, request.getStateList())
                .between(HollowGlassOutRelationInfo::getCreateTime, request.getBeginDate(), request.getEndDate())
                .orderByDesc(HollowGlassOutRelationInfo::getCreateTime);
        return this.page(page, wrapper);
    }
@@ -339,7 +363,9 @@
        if (930 == request.getCell()) {
            Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream()
                    .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
            for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : listMap.entrySet()) {
            Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
            sortListMap.putAll(listMap);
            for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) {
                //创建队列接收不满足成对情况下:一对玻璃分几次上车的次序问题
                List<HollowGlassQueueInfo> tempList = new ArrayList<>();
                //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储
@@ -348,14 +374,15 @@
                for (HollowBigStorageCageDetails item : reverse) {
                    remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight());
                    if (remainWidth < 0) {
                        tempList = CollectionUtil.reverse(tempList);
                        hollowQueues.addAll(CollectionUtil.reverse(tempList));
                        tempList = new ArrayList<>();
                        remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight());
                    }
                    HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
                    tempList.add(queueInfo);
                    remainWidth = remainWidth - glassGap;
                }
                hollowQueues.addAll(tempList);
                hollowQueues.addAll(CollectionUtil.reverse(tempList));
                HollowBigStorageCageDetails cageDetails = entry.getValue().get(0);
                if (cageDetails.getIsPair() == 1) {
                    isPairCount = isPairCount - cageDetails.getTotalLayer();
@@ -364,6 +391,7 @@
                    }
                }
            }
        } else {
            loop:
            for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) {
@@ -398,5 +426,10 @@
        queueInfo.setUpdateTime(new Date());
        return queueInfo;
    }
    @Override
    public List<PieChartVO> queryPieChart(){
        return baseMapper.queryPieChart();
    }
}