From b9b44b51b201e2f5a9a1f3665c7fb76b5690f9af Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期一, 23 十二月 2024 16:13:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java | 345 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 255 insertions(+), 90 deletions(-) diff --git a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java index bbfea54..d718fe5 100644 --- a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java +++ b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java @@ -4,6 +4,7 @@ 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; @@ -19,7 +20,10 @@ 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; @@ -74,6 +78,10 @@ private static final String BIG_STORAGE_CAGE_IN_TWO_TASK = "big_storage_cage_in_two_task"; private static final String BIG_STORAGE_CAGE_OUT_TWO_TASK = "big_storage_cage_out_two_task"; + /** + * 鐩撮�氭牸瀛� + */ + private static final Integer THROUGH_SLOT = 920; @Autowired(required = false) MiloService miloService; @Resource @@ -90,6 +98,11 @@ @Value("${mes.outCarMaxSize}") private Integer outCarMaxSize; + + @Value("${mes.slotMaxHeight}") + private Integer slotMaxHeight; + @Value("${mes.slotMaxthickness}") + private Integer slotMaxthickness; @Scheduled(fixedDelay = 1000) public void inBigStorageTask() throws Exception { @@ -137,7 +150,7 @@ } } List<HollowBigStorageCageDetails> detailsList = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>().in(HollowBigStorageCageDetails::getGlassId, glassIdList) - .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); + .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO)); if (CollectionUtil.isNotEmpty(detailsList)) { log.info("鐞嗙墖绗煎瓨鍦ㄧ浉鍚岀殑杩涚墖鐜荤拑{}锛岀粨鏉熸湰娆′换鍔�", detailsList); //todo:鍚憄lc鍙戦�佹姤璀� @@ -150,51 +163,94 @@ //todo:鍚憄lc鍙戦�佹姤璀� return; } + //鎸夌収鐜荤拑鍘氬害鍒嗙粍锛屽垽鏂墿浣欐牸瀛愭槸鍚﹀彲浠ュ瓨鏀� + Map<Double, Long> thickCountMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getThickness, Collectors.counting())); + for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) { + int count = hollowBigStorageCageService.count(new LambdaQueryWrapper<HollowBigStorageCage>() + .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth) + .le(HollowBigStorageCage::getMinThickness, entry.getKey()) + .ge(HollowBigStorageCage::getMaxThickness, entry.getKey())); + if (count < entry.getValue()) { + log.info("绗煎唴鏍煎瓙鍓╀綑鏁伴噺涓嶈冻锛岀粨鏉熸湰娆¤繘鐗�"); + //todo:鍚憄lc鍙戦�佹姤璀� + return; + } + } + //todo:瓒呭ぇ灏哄 + if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() > slotMaxthickness) { + int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>() + .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) + .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); + if (count > 0) { + log.info("鐩撮�氱墖鍙板瓨鍦ㄧ幓鐠冿紝缁撴潫鏈杩涚墖"); + //todo:鍚憄lc鍙戦�佹姤璀� + return; + } + } + + log.info("灏嗛挗鍖栧皬鐗囪〃鍐呯殑鐘舵�佹敼涓洪挗鍖栫粨鏉燂紝鐜荤拑id鏈夛細{}", glassIdList); //淇敼閽㈠寲浠诲姟琛ㄤ腑鐨勭姸鎬� temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() .set(TemperingGlassInfo::getState, Const.TEMPERING_END).in(TemperingGlassInfo::getGlassId, glassIdList)); - + //鎶ュ伐 + log.info("灏嗘帴鏀跺埌鐨勭幓鐠冭繘琛岄挗鍖栬嚜鍔ㄦ姤宸ワ紝鐜荤拑id鏈夛細{}", glassIdList); + for (String glass : glassIdList) { + damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "閽㈠寲", "杩涗腑绌虹悊鐗囩"); + } Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId)); //璁$畻鐩爣鏍煎瓙 List<HollowBigStorageCageHistoryTask> historyTasks = new ArrayList<>(); - for (BigStorageCageTask task : inTaskList) { - GlassInfo info = glassListMap.get(task.getGlassId()).get(0); - HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(), - info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer()); + try { + for (BigStorageCageTask task : inTaskList) { + GlassInfo info = glassListMap.get(task.getGlassId()).get(0); + HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(), + info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer()); // 涓存椂鏇存柊鏍煎瓙鐨勫墿浣欏昂瀵革細闃叉鐩搁偦鐜荤拑杩涘悓涓�鏍煎瓙閫犳垚鍓╀綑灏哄涓嶈冻锛岀幓鐠冭秺鐣岀殑鎯呭喌锛屼换鍔″畬鎴愬悗鍐嶆鏇存柊澶х悊鐗囩琛ㄥ墿浣欏搴︼紙鎸夌収绗煎唴鐜荤拑鏁伴噺鏇存柊澶х悊鐗囩鍓╀綑灏哄锛� - hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>() - .set(HollowBigStorageCage::getRemainWidth, bigStorageDTO.getRemainWidth() - Math.max(info.getWidth(), info.getHeight()) - glassGap) - .eq(HollowBigStorageCage::getSlot, bigStorageDTO.getSlot())); - task.setTargetSlot(bigStorageDTO.getSlot()); - task.setGlassId(info.getGlassId()); - bigStorageCageTaskService.updateTaskMessage(BIG_STORAGE_CAGE_IN_TWO_TASK, task); - //瀛樻斁鍘嗗彶浠诲姟 - HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask(); - BeanUtils.copyProperties(task, historyTask); - historyTask.setTaskType(Const.BIG_STORAGE_AFTER_IN); - historyTask.setGlassCount(glassInfoList.size()); - historyTask.setTaskState(Const.ENGINEERING_NEW); - historyTasks.add(historyTask); - //瀛樻斁璇︽儏鏁版嵁 - HollowBigStorageCageDetails cageDetails = new HollowBigStorageCageDetails(); - BeanUtils.copyProperties(bigStorageDTO, cageDetails); - BeanUtils.copyProperties(info, cageDetails); - cageDetails.setState(Const.GLASS_STATE_NEW); - cageDetails.setSequence(bigStorageDTO.getSlotSequence()); - cageDetails.setGap(glassGap); - cageDetails.setId(null); - hollowBigStorageCageDetailsService.save(cageDetails); + hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>() + .set(HollowBigStorageCage::getRemainWidth, bigStorageDTO.getRemainWidth() - Math.max(info.getWidth(), info.getHeight()) - glassGap) + .eq(HollowBigStorageCage::getSlot, bigStorageDTO.getSlot())); + task.setTargetSlot(bigStorageDTO.getSlot()); + task.setGlassId(info.getGlassId()); + bigStorageCageTaskService.updateTaskMessage(BIG_STORAGE_CAGE_IN_TWO_TASK, task); + //瀛樻斁鍘嗗彶浠诲姟 + HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask(); + BeanUtils.copyProperties(task, historyTask); + historyTask.setTaskType(Const.BIG_STORAGE_AFTER_IN); + historyTask.setGlassCount(glassInfoList.size()); + historyTask.setTaskState(Const.ENGINEERING_NEW); + historyTasks.add(historyTask); + //瀛樻斁璇︽儏鏁版嵁 + HollowBigStorageCageDetails cageDetails = new HollowBigStorageCageDetails(); + BeanUtils.copyProperties(bigStorageDTO, cageDetails); + BeanUtils.copyProperties(info, cageDetails); + cageDetails.setState(Const.GLASS_STATE_NEW); + cageDetails.setSequence(bigStorageDTO.getSlotSequence()); + cageDetails.setGap(glassGap); + cageDetails.setId(null); + hollowBigStorageCageDetailsService.save(cageDetails); + hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>() + .set(HollowGlassRelationInfo::getGlassId, cageDetails.getGlassId()) + .set(HollowGlassRelationInfo::getTemperingLayoutId, cageDetails.getTemperingLayoutId()) + .set(HollowGlassRelationInfo::getTemperingFeedSequence, cageDetails.getTemperingFeedSequence()) + .set(HollowGlassRelationInfo::getEngineerId, cageDetails.getEngineerId()) + .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY) + .eq(HollowGlassRelationInfo::getFlowCardId, bigStorageDTO.getFlowCardId()) + .eq(HollowGlassRelationInfo::getLayer, bigStorageDTO.getLayer()) + .eq(HollowGlassRelationInfo::getVirtualSlot, bigStorageDTO.getVirtualSlot()) + .eq(HollowGlassRelationInfo::getSlotSequence, bigStorageDTO.getSlotSequence()) + .eq(HollowGlassRelationInfo::getHollowSequence, bigStorageDTO.getHollowSequence()) + ); + } + } catch (Exception exception) { + log.info("杩涚墖浠诲姟鎵ц涓彂鐢熷紓甯革細{}", exception); hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>() - .set(HollowGlassRelationInfo::getGlassId, cageDetails.getGlassId()) - .set(HollowGlassRelationInfo::getTemperingLayoutId, cageDetails.getTemperingLayoutId()) - .set(HollowGlassRelationInfo::getTemperingFeedSequence, cageDetails.getTemperingFeedSequence()) - .set(HollowGlassRelationInfo::getEngineerId, cageDetails.getEngineerId()) - .eq(HollowGlassRelationInfo::getFlowCardId, bigStorageDTO.getFlowCardId()) - .eq(HollowGlassRelationInfo::getLayer, bigStorageDTO.getLayer()) - .eq(HollowGlassRelationInfo::getVirtualSlot, bigStorageDTO.getVirtualSlot()) - .eq(HollowGlassRelationInfo::getSlotSequence, bigStorageDTO.getSlotSequence()) - .eq(HollowGlassRelationInfo::getHollowSequence, bigStorageDTO.getHollowSequence()) + .set(HollowGlassRelationInfo::getGlassId, null) + .set(HollowGlassRelationInfo::getTemperingLayoutId, null) + .set(HollowGlassRelationInfo::getTemperingFeedSequence, null) + .set(HollowGlassRelationInfo::getEngineerId, null) + .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW) + .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY) ); } //鍘嗗彶鏁版嵁鍏ュ簱 @@ -270,7 +326,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 +337,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 +419,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); @@ -418,12 +492,38 @@ hollowBigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_IN); log.info("4銆佸ぇ鐞嗙墖绗艰繘鐗囩姸鎬佸凡瀹屾垚宸插畬鎴愮殑鐜荤拑淇℃伅id:{}", v); updateSlotRemainBySlots(inSuccessGlassSlot); + List<String> glassList = v.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); + hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>() + .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_SUCCESS) + .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY) + .in(HollowGlassRelationInfo::getGlassId, glassList) + ); } else if (e1 == 3) { //鐮存崯澶勭悊 dealDamageInTask(v); + List<String> glassList = v.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); + hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>() + .set(HollowGlassRelationInfo::getGlassId, null) + .set(HollowGlassRelationInfo::getTemperingLayoutId, null) + .set(HollowGlassRelationInfo::getTemperingFeedSequence, null) + .set(HollowGlassRelationInfo::getEngineerId, null) + .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW) + .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY) + .in(HollowGlassRelationInfo::getGlassId, glassList) + ); } else { //娓呯┖鐞嗙墖绗肩┖鏁版嵁 noDealInTask(v); + List<String> glassList = v.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); + hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>() + .set(HollowGlassRelationInfo::getGlassId, null) + .set(HollowGlassRelationInfo::getTemperingLayoutId, null) + .set(HollowGlassRelationInfo::getTemperingFeedSequence, null) + .set(HollowGlassRelationInfo::getEngineerId, null) + .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW) + .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY) + .in(HollowGlassRelationInfo::getGlassId, glassList) + ); } }); for (BigStorageCageTask item : inTaskList) { @@ -514,6 +614,7 @@ noDealOutTask(v); } }); + for (BigStorageCageTask item : outTaskList) { //鏇存柊鍘嗗彶浠诲姟琛ㄤ腑鐨勪换鍔$姸鎬� hollowBigStorageCageHistoryTaskService.update(new LambdaUpdateWrapper<HollowBigStorageCageHistoryTask>() @@ -534,8 +635,45 @@ // 绌烘墽琛� } } + 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); + //娓呯┖鍚姩鐘舵�� //鍚憃pc鍙戦�佸惎鍔ㄤ俊鍙� miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 0)); @@ -643,21 +781,42 @@ } - 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; + //鐩墠璋冨害浠诲姟totalLayer涓�0 鍑虹墖璋冨害浠诲姟鏈夊眰鍙凤紝鐢ㄤ簬鍖哄垎璋冨害鏂瑰紡 + // 鍥犱负鍑虹墖瀛樺湪璋冨害锛屽鏋滀负璋冨害锛屾彁鍓嶅崰鐢ㄦ牸瀛愶紝鏇存柊鏍煎瓙鍓╀綑灏哄锛岄伩鍏嶈杩涚墖鐜荤拑鍗犵敤 + if (totalLayer != 0) { + resultList.add(list.get(0)); + HollowBigStorageCage storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>() + .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON) + .le(HollowBigStorageCage::getMinThickness, list.get(0).getThickness()) + .ge(HollowBigStorageCage::getMaxThickness, list.get(0).getThickness()) + .eq(HollowBigStorageCage::getRemainWidth, slotWidth) + .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1")); + targetSlot = storageCage.getSlot(); + hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>() + .set(HollowBigStorageCage::getRemainWidth, 0).eq(HollowBigStorageCage::getSlot, targetSlot)); + } else { + resultList = tempList; + } 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); } /** @@ -668,7 +827,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 +846,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琛ュ叏 @@ -735,6 +897,9 @@ //鏄惁瀛樺湪鏈夋牸瀛愰潪绌虹殑鐜荤拑 if (CollectionUtils.isNotEmpty(inSlotGlassList)) { //瀛樺湪 灏嗘牸瀛愬唴鐨勭幓鐠冨垎鍒繘琛屾洿鏂� +// List<HollowBigStorageCage> hollowBigStorageCageList = hollowBigStorageCageService.list(new LambdaQueryWrapper<HollowBigStorageCage>() +// .lt(HollowBigStorageCage::getRemainWidth, 0).in(HollowBigStorageCage::getSlot, slotList)); +// List<Integer> resultSlotList = hollowBigStorageCageList.stream().map(HollowBigStorageCage::getSlot).collect(Collectors.toList()); slotRemainMap = inSlotGlassList.stream() .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getSlot, Collectors.summingDouble(item -> Math.max(item.getWidth(), item.getHeight()) + glassGap))); slotRemainMap.forEach((e, v) -> { -- Gitblit v1.8.0