| | |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | |
| | | import com.mes.hollow.entity.HollowBigStorageCageDetails; |
| | | import com.mes.hollow.entity.HollowGlassOutRelationInfo; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | import com.mes.hollow.entity.dto.*; |
| | | import com.mes.hollow.entity.dto.BigStorageSequenceDTO; |
| | | import com.mes.hollow.entity.dto.FlowCardVirtualSlotDTO; |
| | | import com.mes.hollow.entity.dto.HollowBigStorageDTO; |
| | | import com.mes.hollow.entity.dto.UpdateHollowBigStorageCageDTO; |
| | | import com.mes.hollow.service.HollowBigStorageCageDetailsService; |
| | | import com.mes.hollow.service.HollowBigStorageCageService; |
| | | import com.mes.hollow.service.HollowGlassOutRelationInfoService; |
| | |
| | | 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; |
| | |
| | | .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); |
| | | //是否存在需要内部调度的格子:执行内部调度任务 |
| | |
| | | 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); |
| | |
| | | noDealOutTask(v); |
| | | } |
| | | }); |
| | | |
| | | for (BigStorageCageTask item : outTaskList) { |
| | | //更新历史任务表中的任务状态 |
| | | hollowBigStorageCageHistoryTaskService.update(new LambdaUpdateWrapper<HollowBigStorageCageHistoryTask>() |
| | |
| | | // 空执行 |
| | | } |
| | | } |
| | | try { |
| | | //更新数量 |
| | | //按照玻璃id获取需要出片对列表中的数据 |
| | | if(finalTaskType.equals(Const.BIG_STORAGE_AFTER_OUT) ){ |
| | | HollowGlassQueueInfo hollowGlassQueueInfo = hollowGlassQueueInfoService.getOne(new LambdaQueryWrapper<HollowGlassQueueInfo>() |
| | | .eq(HollowGlassQueueInfo::getGlassId, outTaskList.get(0).getGlassId()) |
| | | .orderByDesc(HollowGlassQueueInfo::getUpdateTime).last("limit 1")); |
| | | List<HollowGlassQueueInfo> list = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>() |
| | | .eq(HollowGlassQueueInfo::getFlowCardId, hollowGlassQueueInfo.getFlowCardId()) |
| | | .eq(HollowGlassQueueInfo::getCell, hollowGlassQueueInfo.getCell()) |
| | | .eq(HollowGlassQueueInfo::getIsPair, 1) |
| | | .eq(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW) |
| | | ); |
| | | if (CollectionUtil.isEmpty(list)){ |
| | | // 任务更新为已完成 |
| | | hollowGlassOutRelationInfoService.update(new UpdateWrapper<HollowGlassOutRelationInfo>() |
| | | .eq("flow_card_id",hollowGlassQueueInfo.getFlowCardId()) |
| | | .eq("cell",hollowGlassQueueInfo.getCell()) |
| | | .setSql("pair_quantity = total_pair_quantity") |
| | | .set("state",Const.HOLLOW_FLOW_CARD_SUCCESS) |
| | | ); |
| | | }else{ |
| | | // 计算剩余玻璃对数,用任务总队数减剩余对数 |
| | | int remainCount = list.size() / hollowGlassQueueInfo.getTotalLayer(); |
| | | hollowGlassOutRelationInfoService.update(new UpdateWrapper<HollowGlassOutRelationInfo>() |
| | | .eq("flow_card_id",hollowGlassQueueInfo.getFlowCardId()) |
| | | .eq("cell",hollowGlassQueueInfo.getCell()) |
| | | .setSql("pair_quantity = total_pair_quantity -"+remainCount) |
| | | ); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.info("计算玻璃数量过程中出现错误,错误信息{}",e.getMessage()); |
| | | } |
| | | |
| | | // hollowGlassOutRelationInfoService.update |
| | | // 重置任务表数据 |
| | | bigStorageCageTaskService.updateOutTaskMessage(BIG_STORAGE_CAGE_OUT_TWO_TASK); |
| | | |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 0)); |
| | |
| | | } |
| | | |
| | | |
| | | 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<>(); |
| | | List<T> tempList = new ArrayList<>(); |
| | | int taskType = Const.BIG_STORAGE_AFTER_OUT; |
| | | int taskState = Const.GLASS_STATE_OUT_ING; |
| | | for (T t : list) { |
| | | if (isPair == (t.getIsPair() == null ? 0 : t.getIsPair())) { |
| | | resultList.add(t); |
| | | tempList.add(t); |
| | | }else{ |
| | | break; |
| | | } |
| | | } |
| | | if (isPair == 0) { |
| | | if (isPair == 0 && isForce!=1) { |
| | | taskType = Const.BIG_STORAGE_AFTER_DISPATCH; |
| | | taskState = Const.GLASS_STATE_SCHEDULE_ING; |
| | | resultList.add(list.get(0)); |
| | | //目前调度任务totalLayer为0 出片调度任务有层号,用于区分调度方式 |
| | | if (totalLayer !=0){ |
| | | HollowBigStorageCage storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>() |
| | | .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | targetSlot = storageCage.getSlot(); |
| | | } |
| | | totalLayer = 0; |
| | | }else{ |
| | | resultList = tempList; |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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<>(); |
| | |
| | | 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补全 |