| | |
| | | for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) { |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:同一车进片玻璃存在相同 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 2)); |
| | | return; |
| | | } |
| | | } |
| | |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO)); |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:理片笼存在相同的进片玻璃 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 4)); |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | | |
| | | if (glassInfoList.size() != inTaskList.size()) { |
| | | log.info("进片任务数量{}与玻璃数量{}不匹配,结束本次进片", inTaskList.size(), glassInfoList.size()); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:进片任务数量与系统查询到的玻璃数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 8)); |
| | | return; |
| | | } |
| | | //按照玻璃厚度分组,判断剩余格子是否可以存放 |
| | |
| | | .ge(HollowBigStorageCage::getMaxThickness, entry.getKey())); |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 16)); |
| | | return; |
| | | } |
| | | } |
| | | //todo:超大尺寸 |
| | | if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() > slotMaxthickness) { |
| | | //超大尺寸 |
| | | 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:向plc发送报警 |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 64)); |
| | | return; |
| | | } |
| | | } |
| | |
| | | //计算目标格子 |
| | | List<HollowBigStorageCageHistoryTask> historyTasks = new ArrayList<>(); |
| | | 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()); |
| | | if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) { |
| | | 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); |
| | | 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()) |
| | | ); |
| | | } |
| | | } else { |
| | | BigStorageCageTask task = inTaskList.get(0); |
| | | task.setTargetSlot(THROUGH_SLOT); |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_two_task", task); |
| | | //存放历史任务 |
| | | HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(task, historyTask); |
| | |
| | | historyTask.setGlassCount(glassInfoList.size()); |
| | | historyTask.setTaskState(Const.ENGINEERING_NEW); |
| | | historyTasks.add(historyTask); |
| | | //存放详情数据 |
| | | GlassInfo info = glassInfoList.get(0); |
| | | HollowBigStorageCageDetails cageDetails = new HollowBigStorageCageDetails(); |
| | | BeanUtils.copyProperties(bigStorageDTO, cageDetails); |
| | | BeanUtils.copyProperties(info, cageDetails); |
| | | cageDetails.setSlot(THROUGH_SLOT); |
| | | cageDetails.setState(Const.GLASS_STATE_NEW); |
| | | cageDetails.setSequence(bigStorageDTO.getSlotSequence()); |
| | | cageDetails.setDeviceId(0); |
| | | cageDetails.setSequence(0); |
| | | cageDetails.setHollowSequence(0); |
| | | cageDetails.setGap(glassGap); |
| | | cageDetails.setFilmsId(info.getFilmsid()); |
| | | 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); |
| | |
| | | } |
| | | |
| | | //获取空闲且领取任务的数据信息,没有任务直接走玻璃调度 |
| | | HashMap<Integer, ReadWriteEntity> map = new HashMap<>(); |
| | | ReadWriteEntity oneEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree"); |
| | | ReadWriteEntity twoEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree"); |
| | | ReadWriteEntity threeEntity = miloService.readFromOpcUa("ZKQ3.ZKQ3.isFree"); |
| | | map.put(930, oneEntity); |
| | | map.put(931, twoEntity); |
| | | map.put(932, threeEntity); |
| | | HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null; |
| | | int cell = -1; |
| | | //李赛克线需要获取韩江plc的线路空闲状态:10000000第8位为 1表示忙碌 0表示空闲 |
| | | if (null != oneEntity.getValue() && "1".equals(oneEntity.getValue() + "")) { |
| | | cell = 930; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | for (int i = 930; i < 931; i++) { |
| | | if (null == hollowGlassOutRelationInfo) { |
| | | ReadWriteEntity entity = map.get(i); |
| | | cell = i; |
| | | if (null != entity.getValue() && ("1".equals(entity.getValue() + "") || Boolean.parseBoolean(twoEntity.getValue() + ""))) { |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | } |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | ReadWriteEntity twoEntity = miloService.readFromOpcUa("ZKQ2.ZKQ2.isFree"); |
| | | if (null == hollowGlassOutRelationInfo && null != twoEntity.getValue() && Boolean.parseBoolean(twoEntity.getValue() + "")) { |
| | | cell = 931; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | } |
| | | if (null == hollowGlassOutRelationInfo) { |
| | | cell = 930; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | } |
| | | |
| | | if (null == hollowGlassOutRelationInfo) { |
| | | cell = 931; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | for (int i = 930; i <= 932; i++) { |
| | | if (null == hollowGlassOutRelationInfo) { |
| | | cell = i; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | ); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (null != hollowGlassOutRelationInfo) { |
| | |
| | | } |
| | | |
| | | |
| | | private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, int targetSlot, int isPair, int totalLayer, int isForce) { |
| | | private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, |
| | | int targetSlot, int isPair, int totalLayer, int isForce) throws Exception { |
| | | List<T> resultList = new ArrayList<>(); |
| | | List<T> tempList = new ArrayList<>(); |
| | | int taskType = Const.BIG_STORAGE_AFTER_OUT; |
| | |
| | | .ge(HollowBigStorageCage::getMaxThickness, list.get(0).getThickness()) |
| | | .eq(HollowBigStorageCage::getRemainWidth, slotWidth) |
| | | .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1")); |
| | | |
| | | if (null == storageCage) { |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | Assert.isFalse(storageCage == null, "任务调度没有多余格子,结束调度任务"); |
| | | } |
| | | |
| | | targetSlot = storageCage.getSlot(); |
| | | hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>() |
| | | .set(HollowBigStorageCage::getRemainWidth, 0).eq(HollowBigStorageCage::getSlot, targetSlot)); |
| | |
| | | * @param totalLayer |
| | | * @return |
| | | */ |
| | | private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, int targetSlot, int state, int taskType, int totalLayer, int isForce) { |
| | | private <T extends HollowBigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, |
| | | int targetSlot, int state, int taskType, int totalLayer, int isForce) { |
| | | //任务数据:获取车子存放玻璃最大数量,玻璃间隔 |
| | | List<T> templist = new ArrayList<>(); |
| | | //打车剩余尺寸 |
| | |
| | | } |
| | | Assert.isFalse(CollectionUtil.isEmpty(templist), "未获取出片数据,结束出片任务"); |
| | | log.info("获取出片任务数据{}条,执行保存", templist.size()); |
| | | List<T> baseInfoList = new ArrayList<>(); |
| | | List<T> baseInfoList = templist; |
| | | if (1 != isForce) { |
| | | if (taskType == Const.BIG_STORAGE_AFTER_OUT) { |
| | | //校验防止小于等于总层数玻璃片序不匹配的问题,该问题多出现在大片玻璃,3层 |
| | |
| | | } else { |
| | | //大于总层数先取totalLyaer倍数数量的玻璃,保证大车上的玻璃成对传 |
| | | int remainCount = templist.size() % totalLayer; |
| | | if (targetSlot == 931) { |
| | | baseInfoList = templist.subList(0, templist.size() - remainCount); |
| | | if (targetSlot == 930) { |
| | | baseInfoList = templist.subList(0, totalLayer); |
| | | } else { |
| | | //930时玻璃顺序倒序、同一对玻璃倒序 |
| | | baseInfoList = templist.subList(0, templist.size() - remainCount); |
| | | Map<Integer, List<T>> listMap = baseInfoList.stream().collect(Collectors.groupingBy(T::getHollowSequence)); |
| | | Map<Integer, List<T>> sortListMap = new TreeMap<>(Collections.reverseOrder()); |
| | | sortListMap.putAll(listMap); |
| | | List<T> resultList = new ArrayList<>(); |
| | | for (Map.Entry<Integer, List<T>> e : sortListMap.entrySet()) { |
| | | for (T t : e.getValue()) { |
| | | resultList.add(t); |
| | | } |
| | | } |
| | | baseInfoList = resultList; |
| | | } |
| | | } |
| | | } |
| | |
| | | for (T t : baseInfoList) { |
| | | bigStorageCageTaskList.add(new BigStorageCageTask(t.getGlassId(), t.getSlot(), targetSlot, 0)); |
| | | } |
| | | while (baseInfoList.size() < 6) { |
| | | while (bigStorageCageTaskList.size() < 6) { |
| | | bigStorageCageTaskList.add(new BigStorageCageTask("", 0, 0, 0)); |
| | | } |
| | | //清空任务表数据 |
| | | bigStorageCageTaskService.removeAll(tableName); |
| | | bigStorageCageTaskService.saveTaskMessage(tableName, bigStorageCageTaskList); |
| | | List<HollowBigStorageCageHistoryTask> historyList = baseInfoList.stream().filter(e -> StringUtils.isNotBlank(e.getGlassId())).map(e -> { |
| | | List<HollowBigStorageCageHistoryTask> historyList = bigStorageCageTaskList.stream().filter(e -> StringUtils.isNotBlank(e.getGlassId())).map(e -> { |
| | | HollowBigStorageCageHistoryTask history = new HollowBigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(e, history); |
| | | history.setGlassCount(glassCount); |