| | |
| | | private static final String ALARM_TYPE = "中空大理片"; |
| | | private static final String ALARM_CODE_SIZE = "sizeSame"; |
| | | private static final String ALARM_CODE_ID = "idSame"; |
| | | private static final String ALARM_CODE_SLOT = "slotLess"; |
| | | private static final String ALARM_CODE_OVER = "overSize"; |
| | | |
| | | /** |
| | | * 直通格子 |
| | |
| | | .ge(HollowBigStorageCage::getMaxThickness, entry.getKey())); |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | ProductAlarmInfo alarmInfo = new ProductAlarmInfo(); |
| | | alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW); |
| | | alarmInfo.setAlarmModule(ALARM_MODULE); |
| | | alarmInfo.setAlarmType(ALARM_TYPE); |
| | | alarmInfo.setAlarmCode(ALARM_CODE_SLOT); |
| | | alarmInfo.setAlarmMessage(count + ""); |
| | | productAlarmInfoService.save(alarmInfo); |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal(16); |
| | |
| | | } |
| | | } |
| | | // } |
| | | //超大尺寸 |
| | | // Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT); |
| | | // Integer slotMaxthickness = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_THICKNESS); |
| | | // 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("直通片台存在玻璃,结束本次进片"); |
| | | // //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | // s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | // s7DataZKDLPOne.setAlramSignal(64); |
| | | // s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | // return; |
| | | // } |
| | | // } |
| | | |
| | | log.info("将钢化小片表内的状态改为钢化结束,玻璃id有:{}", glassIdList); |
| | | //修改钢化任务表中的状态 |
| | | temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() |
| | |
| | | } |
| | | |
| | | HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null; |
| | | |
| | | //直通台有玻璃时将中空出片队列中对应玻璃id的格子号替换未直通台 |
| | | HollowBigStorageCageDetails details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).last("limit 1")); |
| | | if (details != null) { |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService.getOne( |
| | | new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, details.getFlowCardId()) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | .orderByAsc(HollowGlassOutRelationInfo::getId) |
| | | .last("limit 1") |
| | | ); |
| | | } |
| | | int cell = -1; |
| | | for (Integer i : resultList) { |
| | | if (null == hollowGlassOutRelationInfo) { |
| | |
| | | break; |
| | | } |
| | | } |
| | | for (Integer i : resultList) { |
| | | if (null == hollowGlassOutRelationInfo) { |
| | | cell = i; |
| | | hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | .orderByAsc(HollowGlassOutRelationInfo::getId) |
| | | .last("limit 1") |
| | | ); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | // for (Integer i : resultList) { |
| | | // if (null == hollowGlassOutRelationInfo) { |
| | | // cell = i; |
| | | // hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService |
| | | // .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | // .eq(HollowGlassOutRelationInfo::getCell, cell) |
| | | // .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | | // .orderByAsc(HollowGlassOutRelationInfo::getId) |
| | | // .last("limit 1") |
| | | // ); |
| | | // } else { |
| | | // break; |
| | | // } |
| | | // } |
| | | |
| | | if (null != hollowGlassOutRelationInfo) { |
| | | //是否允许中空 |
| | |
| | | .eq(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW) |
| | | .eq(HollowGlassQueueInfo::getRelationId, hollowGlassOutRelationInfo.getId()) |
| | | .orderByAsc(HollowGlassQueueInfo::getHollowSequence)); |
| | | if (CollectionUtil.isNotEmpty(unFinishHollowQueueList)) { |
| | | //按照任务信息过滤筛选需要出片及调度的玻璃队列 |
| | | List<HollowGlassQueueInfo> resultQueue = computeOutHollowQueue(unFinishHollowQueueList, hollowGlassOutRelationInfo); |
| | | log.info("中空出片任务计算后的出片队列为:{}", resultQueue); |
| | | if (CollectionUtil.isNotEmpty(resultQueue)) { |
| | | //直通台有玻璃时将中空出片队列中对应玻璃id的格子号替换未直通台 |
| | | HollowBigStorageCageDetails details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL).last("limit 1")); |
| | | log.info("中空大理片直通台玻璃信息{}", details); |
| | | if (details != null) { |
| | | unFinishHollowQueueList.stream().forEach(e -> { |
| | | resultQueue.stream().forEach(e -> { |
| | | if (e.getGlassId().equals(details.getGlassId())) { |
| | | e.setSlot(THROUGH_SLOT); |
| | | e.setDeviceId(0); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | List<HollowGlassQueueInfo> infoList = unFinishHollowQueueList.stream().filter(e -> !(e.getSlot() > 500 && e.getSlot() < 900 && e.getIsPair() != 1)).collect(Collectors.toList()); |
| | | log.info("有正在出片的中空任务"); |
| | | Integer isPair = infoList.get(0).getIsPair(); |
| | | hollowOutGlassByIsPair(infoList, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce()); |
| | | log.info("有正在出片的中空任务:{}", hollowGlassOutRelationInfo); |
| | | Integer isPair = resultQueue.get(0).getIsPair(); |
| | | hollowOutGlassByIsPair(resultQueue, hollowGlassOutRelationInfo.getCell(), isPair, hollowGlassOutRelationInfo.getTotalLayer(), hollowGlassOutRelationInfo.getIsForce()); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | |
| | | log.info("当前未收到进片请求,结束进片任务"); |
| | | return; |
| | | } |
| | | if (StringUtils.isNotBlank(s7DataZKDLPOne.getId1())) { |
| | | log.info("当前存在进片任务,结束"); |
| | | return; |
| | | } |
| | | if (StringUtils.isNotBlank(s7DataZKDLPOne.getId1())) { |
| | | log.info("当前存在进片任务请求,结束本次大笼子调度"); |
| | | return; |
| | | } |
| | | //有请求信号 |
| | | List<String> glassIdList = hollowGlassQueueInfoService.queryNeedInCarGlass(); |
| | | if (CollectionUtil.isEmpty(glassIdList)) { |
| | |
| | | int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT)); |
| | | log.info("直通片台的任务数量为:{}", count); |
| | | if (count > 0) { |
| | | return; |
| | | } |
| | | List<HollowBigStorageCageDetails> list = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | // .in(HollowBigStorageCageDetails::getDeviceId, 6) |
| | | .in(HollowBigStorageCageDetails::getGlassId, glassIdList)); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | HollowBigStorageCageDetails details = null; |
| | | for (String glassId : glassIdList) { |
| | | details = hollowBigStorageCageDetailsService.getOne(new LambdaQueryWrapper<HollowBigStorageCageDetails>() |
| | | .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(HollowBigStorageCageDetails::getGlassId, glassId).last("limit 1")); |
| | | log.info("获取调度任务:{}", details); |
| | | if (details != null) { |
| | | break; |
| | | } |
| | | } |
| | | if (details == null) { |
| | | return; |
| | | } |
| | | HollowBigStorageCageDetails details = list.get(0); |
| | | |
| | | //todo:生成进进片大车任务 |
| | | log.info("获取需要调度的单条任务:{}", details); |
| | | //生成进进片大车任务 |
| | | hollowBigStorageCageDetailsService.update(new LambdaUpdateWrapper<HollowBigStorageCageDetails>() |
| | | .set(HollowBigStorageCageDetails::getState, Const.RAW_GLASS_STATE_OUT) |
| | | .eq(HollowBigStorageCageDetails::getGlassId, details.getGlassId())); |
| | |
| | | damage.setWorkingProcedure("磨边"); |
| | | damage.setRemark("进笼前卧转立"); |
| | | damage.setStatus(1); |
| | | damage.setType(item.getTaskState()); |
| | | damage.setType(Const.GLASS_STATE_DAMAGE); |
| | | damageService.insertDamage(damage); |
| | | slotList.add(item.getTargetSlot()); |
| | | } |
| | |
| | | damage.setWorkingProcedure("中空前"); |
| | | damage.setRemark("进笼后卧转立"); |
| | | damage.setStatus(1); |
| | | damage.setType(item.getTaskState()); |
| | | damage.setType(Const.GLASS_STATE_DAMAGE); |
| | | damageService.insertDamage(damage); |
| | | slotList.add(item.getTargetSlot()); |
| | | slotList.add(item.getStartSlot()); |
| | |
| | | log.info("出片任务-无动作执行完成"); |
| | | } |
| | | |
| | | private List<HollowGlassQueueInfo> computeOutHollowQueue(List<HollowGlassQueueInfo> queueInfoList, HollowGlassOutRelationInfo hollowGlassOutRelationInfo) { |
| | | if (CollectionUtil.isEmpty(queueInfoList)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | //任务为强制,只直接返回原有的队列 |
| | | if (hollowGlassOutRelationInfo.getIsForce() == 1) { |
| | | return queueInfoList; |
| | | } |
| | | log.info("领取任务:{}的队列:{}", hollowGlassOutRelationInfo, queueInfoList); |
| | | // 按格子号分组 |
| | | Map<Integer, List<HollowGlassQueueInfo>> gridGroups = queueInfoList.stream() |
| | | .collect(Collectors.groupingBy(HollowGlassQueueInfo::getSlot)); |
| | | List<HollowGlassQueueInfo> resultQueue = new ArrayList<>(); |
| | | |
| | | for (List<HollowGlassQueueInfo> items : gridGroups.values()) { |
| | | // 情况2:格子内全部为未配对的数据 - 过滤掉 |
| | | boolean allUnpaired = items.stream().noneMatch(e -> e.getIsPair() == 1); |
| | | if (allUnpaired) { |
| | | continue; |
| | | } |
| | | // 否则保留这个格子内的所有数据 |
| | | resultQueue.addAll(items); |
| | | } |
| | | Collections.sort(resultQueue, Comparator.comparing(HollowGlassQueueInfo::getId)); |
| | | return resultQueue; |
| | | } |
| | | |
| | | private <T extends HollowBigStorageCageBaseInfo> Boolean hollowOutGlassByIsPair(List<T> list, |
| | | int targetSlot, int isPair, int totalLayer, int isForce) throws Exception { |
| | |
| | | S7DataZKDLPOne s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal(16); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | ProductAlarmInfo alarmInfo = new ProductAlarmInfo(); |
| | | alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW); |
| | | alarmInfo.setAlarmModule(ALARM_MODULE); |
| | | alarmInfo.setAlarmType(ALARM_TYPE); |
| | | alarmInfo.setAlarmCode(ALARM_CODE_SLOT); |
| | | alarmInfo.setAlarmMessage(""); |
| | | productAlarmInfoService.save(alarmInfo); |
| | | Assert.isFalse(storageCage == null, "任务调度没有多余格子,结束调度任务"); |
| | | } |
| | | |