zhoushihao
2024-12-03 93b488aa57cfd99a94a242c38b007a0d9e35f69b
hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -270,7 +270,7 @@
            if (CollectionUtil.isNotEmpty(unFinishHollowQueueList)) {
                log.info("有正在出片的中空任务");
                Integer isPair = unFinishHollowQueueList.get(0).getIsPair();
                hollowOutGlassByIsPair(unFinishHollowQueueList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer());
                hollowOutGlassByIsPair(unFinishHollowQueueList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(),hollowGlassOutRelationInfo.getIsForce());
                Date endDate = new Date();
                log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
                return;
@@ -281,45 +281,63 @@
                        .eq(HollowGlassOutRelationInfo::getCell, hollowGlassOutRelationInfo.getCell())
                        .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS));
            }
            if (redisUtil.getCacheObject("hollowSwitch")) {
                List<HollowGlassOutRelationInfo> HollowGlassOutRelationInfoList = hollowGlassOutRelationInfoService
                        .list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                .eq(HollowGlassOutRelationInfo::getCell, cell)
                                .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW));
                for (HollowGlassOutRelationInfo e : HollowGlassOutRelationInfoList) {
                    //中空优先:获取理片笼  玻璃小片  破损表 数量   判断笼内版图是否到齐
                    List<FlowCardGlassInfoDTO> flowCardGlassInfoDTO = hollowBigStorageCageDetailsService.hollowIsAll(e.getFlowCardId(), e.getTotalLayer(), Boolean.TRUE);
                    if (CollectionUtil.isNotEmpty(flowCardGlassInfoDTO)) {
                        //玻璃到齐包括已出片的
                        //到齐,将玻璃小片数据存入中空小片表,逻辑生成出片任务  结束
                        for (FlowCardGlassInfoDTO item : flowCardGlassInfoDTO) {
                            List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService.queryOutGlassList(item.getFlowCardId(), cell);
                            int finalCell = cell;
                            List<HollowGlassQueueInfo> hollowQueues = hollowBigStorageCageDetailsList.stream().map(queue -> {
                                HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
                                BeanUtils.copyProperties(queue, queueInfo);
                                queueInfo.setState(Const.TEMPERING_NEW);
                                queueInfo.setCell(finalCell);
                                return queueInfo;
                            }).collect(Collectors.toList());
                            if (CollectionUtil.isNotEmpty(hollowQueues)) {
                                hollowGlassQueueInfoService.saveBatch(hollowQueues);
                                Integer isPair = hollowQueues.get(0).getIsPair();
                                hollowOutGlassByIsPair(hollowQueues, cell, isPair, e.getTotalLayer());
                                //将中空任务状态改为开始
                                hollowGlassOutRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
                                        .eq(HollowGlassOutRelationInfo::getFlowCardId, e.getFlowCardId())
                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
                                        .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START));
                                Date endDate = new Date();
                                log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
                                return;
                            }
                        }
                    }
                }
            }
//            if (redisUtil.getCacheObject("hollowSwitch")) {
//                List<HollowGlassOutRelationInfo> HollowGlassOutRelationInfoList = hollowGlassOutRelationInfoService
//                        .list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
//                                .eq(HollowGlassOutRelationInfo::getCell, cell)
//                                .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW));
//                for (HollowGlassOutRelationInfo e : HollowGlassOutRelationInfoList) {
//                    //中空优先:获取理片笼  玻璃小片  破损表 数量   判断笼内版图是否到齐
//                    List<FlowCardGlassInfoDTO> flowCardGlassInfoDTO = hollowBigStorageCageDetailsService.hollowIsAll(e.getFlowCardId(), e.getTotalLayer(), Boolean.TRUE);
//                    if (CollectionUtil.isNotEmpty(flowCardGlassInfoDTO)) {
//                        //玻璃到齐包括已出片的
//                        //到齐,将玻璃小片数据存入中空小片表,逻辑生成出片任务  结束
//                        for (FlowCardGlassInfoDTO item : flowCardGlassInfoDTO) {
//                            List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService.queryOutGlassList(item.getFlowCardId(), cell);
//                            int finalCell = cell;
//                            List<HollowGlassQueueInfo> hollowQueues = hollowBigStorageCageDetailsList.stream().map(queue -> {
//                                HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
//                                BeanUtils.copyProperties(queue, queueInfo);
//                                queueInfo.setState(Const.TEMPERING_NEW);
//                                queueInfo.setCell(finalCell);
//                                return queueInfo;
//                            }).collect(Collectors.toList());
//
//                            List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService.queryOutGlassList(flowCardId, cell);
//                            int isPairCount = glassInfo.getTotalLayer() * e.getTotalLayer();
//                            List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>();
//                            loop:
//                            for (HollowBigStorageCageDetails queue : hollowBigStorageCageDetailsList) {
//                                HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
//                                BeanUtils.copyProperties(queue, queueInfo);
//                                queueInfo.setState(Const.TEMPERING_NEW);
//                                queueInfo.setCell(cell);
//                                hollowQueues.add(queueInfo);
//                                if (queue.getIsPair() == 1){
//                                    isPairCount -=1;
//                                    if (isPairCount == 0){
//                                        break loop;
//                                    }
//                                }
//                            }
//
//                            if (CollectionUtil.isNotEmpty(hollowQueues)) {
//                                hollowGlassQueueInfoService.saveBatch(hollowQueues);
//                                Integer isPair = hollowQueues.get(0).getIsPair();
//                                hollowOutGlassByIsPair(hollowQueues, cell, isPair, e.getTotalLayer());
//                                //将中空任务状态改为开始
//                                hollowGlassOutRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
//                                        .eq(HollowGlassOutRelationInfo::getFlowCardId, e.getFlowCardId())
//                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
//                                        .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START));
//                                Date endDate = new Date();
//                                log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
//                                return;
//                            }
//                        }
//                    }
//                }
//            }
        }
//        redisUtil.setCacheObject("dispatchHollowSwitch",true);
        //是否存在需要内部调度的格子:执行内部调度任务
@@ -345,7 +363,7 @@
                        int targetSlot = item.getSlot();
                        list = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>()
                                .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN).eq(HollowBigStorageCageDetails::getSlot, startSlot));
                        hollowOutGlassByIsPair(list, targetSlot, 0, 0);
                        hollowOutGlassByIsPair(list, targetSlot, 0, 0,0);
                        List<Integer> slotList = new ArrayList<>();
                        slotList.add(targetSlot);
                        updateSlotRemainBySlots(slotList);
@@ -534,8 +552,11 @@
//                空执行
            }
        }
        //更新数量
//        hollowGlassOutRelationInfoService.update
//       重置任务表数据
        bigStorageCageTaskService.updateOutTaskMessage(BIG_STORAGE_CAGE_OUT_TWO_TASK);
        //清空启动状态
        //向opc发送启动信号
        miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 0));
@@ -643,7 +664,7 @@
    }
    private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, int targetSlot, int isPair, int totalLayer) {
    private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, int targetSlot, int isPair, int totalLayer,int isForce) {
        List<T> resultList = new ArrayList<>();
        int taskType = Const.BIG_STORAGE_AFTER_OUT;
        int taskState = Const.GLASS_STATE_OUT_ING;
@@ -652,12 +673,12 @@
                resultList.add(t);
            }
        }
        if (isPair == 0) {
        if (isPair == 0 && isForce!=1) {
            taskType = Const.BIG_STORAGE_AFTER_DISPATCH;
            taskState = Const.GLASS_STATE_SCHEDULE_ING;
            totalLayer = 0;
        }
        return computeOutGlassInfo(resultList, BIG_STORAGE_CAGE_OUT_TWO_TASK, targetSlot, taskState, taskType, totalLayer);
        return computeOutGlassInfo(resultList, BIG_STORAGE_CAGE_OUT_TWO_TASK, targetSlot, taskState, taskType, totalLayer,isForce);
    }
    /**
@@ -668,7 +689,7 @@
     * @param totalLayer
     * @return
     */
    private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, int targetSlot, int state, int taskType, int totalLayer) {
    private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, int targetSlot, int state, int taskType, int totalLayer,int isForce) {
        //任务数据:获取车子存放玻璃最大数量,玻璃间隔
        List<BigStorageCageTask> tempList = new ArrayList<>();
        List<T> tempTList = new ArrayList<>();
@@ -687,14 +708,17 @@
        Assert.isFalse(CollectionUtil.isEmpty(tempList), "未获取出片数据,结束出片任务");
        log.info("获取出片任务数据{}条,执行保存", tempList.size());
        List<BigStorageCageTask> bigStorageCageTaskList = tempList;
        if (taskType == Const.BIG_STORAGE_AFTER_OUT) {
            if (tempList.size() <= totalLayer) {
                bigStorageCageTaskList = tempList;
            } else {
                int remainCount = tempList.size() % totalLayer;
//                tempList.subList(0,)
        if (1!= isForce){
            if (taskType == Const.BIG_STORAGE_AFTER_OUT) {
                if (tempList.size() <= totalLayer) {
                    bigStorageCageTaskList = tempList;
                } else {
                    int remainCount = tempList.size() % totalLayer;
                    bigStorageCageTaskList = tempList.subList(0,tempList.size() - remainCount);
                }
            }
        }
        List<String> glassIds = bigStorageCageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList());
        int glassCount = bigStorageCageTaskList.size();
        //生成出片任务条数不足6补全