| | |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageOutTask; |
| | | import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Slf4j |
| | | public class PlcStorageCageTask { |
| | | |
| | | @Resource |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Resource |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Resource |
| | |
| | | @Resource |
| | | private TemperingGlassInfoService temperingGlassInfoService; |
| | | |
| | | private static final String REQUEST_WORD = "1"; |
| | | |
| | | @Value("${mes.sequence.order}") |
| | | private boolean sequenceOrder; |
| | | |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | |
| | | public static boolean bigStorageCageFullAlarm = false; |
| | | |
| | | private int line1Time = 0; |
| | | private int line2Time = 0; |
| | | |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | // @Scheduled(fixedDelay = 5000) |
| | | // public void plcStorageCageTask() throws InterruptedException { |
| | | // |
| | | // PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | // try { |
| | | // |
| | | // String plcFeedGlassid = ""; |
| | | // String plcFeedReqLine = "0"; |
| | | // if ("1".equals(plcParameterObject.getPlcParameter("D01Request").getValue())) { |
| | | // plcFeedReqLine = "1"; |
| | | // plcFeedGlassid = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | // } |
| | | // if ("1".equals(plcParameterObject.getPlcParameter("D04Request").getValue())) { |
| | | // plcFeedReqLine = "2"; |
| | | // plcFeedGlassid = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | // } |
| | | // line1Time += 1; |
| | | // line2Time += 1; |
| | | // |
| | | // if (!("0".equals(plcFeedReqLine))) { |
| | | // log.info("1、Plc进片请求时"); |
| | | // BigStorageCageDetails bigStorageCageDetails = new BigStorageCageDetails(); |
| | | // GlassInfo glassInfo = glassInfoService.getById(plcFeedGlassid); |
| | | // log.info("2、根据玻璃id获取玻璃信息" + glassInfo); |
| | | // if (bigStorageCageDetailsService.selectGetBoard(plcFeedReqLine) >= 0) { |
| | | // BigStorageCageDetails slotInfo = bigStorageCageService.feedGlass(glassInfo, bigStorageCageDetails); |
| | | // if (slotInfo != null) { |
| | | // int taskType = edgGlassTaskInfoService.judgeTasktype(plcFeedReqLine); |
| | | // log.info("3、查询任务表判断当前任务类型为上车等到还是上车启动" + taskType); |
| | | // bigStorageCageFeedTaskService.addFeedTask(slotInfo, Integer.parseInt(plcFeedReqLine), taskType); |
| | | // log.info("4、添加任务到任务表"); |
| | | // bigStorageCageFullAlarm = false; |
| | | // } else { |
| | | // bigStorageCageFullAlarm = true; |
| | | // } |
| | | // } else { |
| | | // log.info("当前玻璃宽度不够上车" + glassInfo); |
| | | // if (!("1".equals(plcFeedReqLine))) { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D02Go").getAddress(), 1); |
| | | // } else { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D05Go").getAddress(), 1); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // List<BigStorageCageFeedTask> bigStorageCageFeedTaskList = bigStorageCageFeedTaskService.querybigStorageCageFeedTask(1); |
| | | // log.info("5、查询任务表是否有已经完成的进片任务" + bigStorageCageFeedTaskList.size()); |
| | | // for (BigStorageCageFeedTask bigStorageCageFeedTask : bigStorageCageFeedTaskList |
| | | // ) { |
| | | // BigStorageCageDetails bigStorageCageDetails = new BigStorageCageDetails(); |
| | | // bigStorageCageDetails.setId(bigStorageCageFeedTask.getId()); |
| | | // bigStorageCageDetails.setState(1); |
| | | // bigStorageCageDetailsService.updateById(bigStorageCageDetails); |
| | | // log.info("6、修改理片笼详情玻璃状态"); |
| | | // bigStorageCageFeedTaskService.removeById(bigStorageCageFeedTask); |
| | | // log.info("7、删除已经完成的进片任务"); |
| | | // } |
| | | // //启动阈值 |
| | | // if (line1Time >= 300) { |
| | | // if ("0".equals(plcParameterObject.getPlcParameter("D05Go").getValue())) { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D02Go").getAddress(), 1); |
| | | // } |
| | | // } |
| | | // if (line2Time >= 300) { |
| | | // if ("0".equals(plcParameterObject.getPlcParameter("D02Go").getValue())) { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D05Go").getAddress(), 1); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // //查询出片表是否有任务未完成的任务 |
| | | // List<BigStorageCageOutTask> bigStorageCageOutTask = bigStorageCageOutTaskService.querybigStorageCageOutTask(0); |
| | | // if (bigStorageCageOutTask.size() == 0) { |
| | | // boolean result = bigStorageCageService.outGlass(); |
| | | // log.info("8、没有未完成任务时调用出片接口"); |
| | | // if (result == false) { |
| | | // temperingGlassInfoService.schedulingTask(); |
| | | // } |
| | | // } |
| | | // bigStorageCageOutTaskService.updateOutTask(); |
| | | // log.info("9、根据任务表状态修改钢化小片表任务状态"); |
| | | // |
| | | // //来不及送时直接走 |
| | | // String line = Integer.toString(edgGlassTaskInfoService.startTask()); |
| | | // |
| | | // if (!(line.equals(plcFeedReqLine))) { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D02Go").getAddress(), 1); |
| | | // } else { |
| | | // S7object.getinstance().plccontrol.writetime(plcParameterObject.getPlcParameter("D05Go").getAddress(), 1); |
| | | // } |
| | | // |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgScan() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | String d01ID1 = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | String d04ID1 = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | log.info("1、获取到的请求字d01为:{},获取到的扫描ID为:{};获取到的请求字d04为:{},获取到的扫描ID为:{};", |
| | | d01Request, d01ID1, d04Request, d04ID1); |
| | | if (!"1".equals(d01Request) && !"1".equals(d04Request)) { |
| | | d01Request, d01Id, d04Request, d04Id); |
| | | if (!REQUEST_WORD.equals(d01Request) && !REQUEST_WORD.equals(d04Request)) { |
| | | log.info("两条线未收到进片任务,结束本次扫描进卧转立任务"); |
| | | return; |
| | | } |
| | | // 0:不干预 ; 1:条件满足情况下立即发车 |
| | | String d02GoAdress = plcParameterObject.getPlcParameter("D02Go").getAddress(); |
| | | // 0:不干预 ; 1:条件满足情况下立即发车 |
| | | String d05GoAdress = plcParameterObject.getPlcParameter("D05Go").getAddress(); |
| | | Boolean flag01 = Boolean.FALSE; |
| | | Boolean flag04 = Boolean.FALSE; |
| | | //按照线路及玻璃id获取相邻两块玻璃 卧转立上的玻璃 |
| | | if ("1".equals(d01Request)) { |
| | | flag01 = judgeGlassTypeStatus(d01ID1, Const.A09_OUT_TARGET_POSITION); |
| | | if (REQUEST_WORD.equals(d01Request)) { |
| | | flag01 = judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION); |
| | | } |
| | | if ("1".equals(d04Request)) { |
| | | flag04 = judgeGlassTypeStatus(d04ID1, Const.A10_OUT_TARGET_POSITION); |
| | | if (REQUEST_WORD.equals(d04Request)) { |
| | | flag04 = judgeGlassTypeStatus(d04Id, Const.A10_OUT_TARGET_POSITION); |
| | | } |
| | | if (flag01 && flag04) { |
| | | //比较最早一片任务的版图id及版序 求出卧转立的线路 |
| | | Integer startLine = getStartLine(); |
| | | //计算目标格子,发送启动任务 |
| | | computeTargetByLine(startLine, d02GoAdress, d05GoAdress); |
| | | computeTargetByLine(startLine); |
| | | } else if (flag01 || flag04) { |
| | | Integer startLine = flag01.equals(Boolean.TRUE) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; |
| | | //计算目标格子,发送启动任务 |
| | | computeTargetByLine(startLine, d02GoAdress, d05GoAdress); |
| | | computeTargetByLine(startLine); |
| | | } else { |
| | | log.info("两条线未收到进片任务,结束本次扫描进卧转立任务"); |
| | | } |
| | |
| | | public void plcToHomeEdgFreeCarTask() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String freeCar = plcParameterObject.getPlcParameter("freeCar").getValue(); |
| | | if ("1".equals(freeCar)) { |
| | | if (REQUEST_WORD.equals(freeCar)) { |
| | | log.info("大车非空闲"); |
| | | return; |
| | | } |
| | | String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | String d01ID1 = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | String d04ID1 = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | log.info("1、获取到的请求字d01为:{},获取到的扫描ID为:{};获取到的请求字d04为:{},获取到的扫描ID为:{};", |
| | | d01Request, d01ID1, d04Request, d04ID1); |
| | | d01Request, d01Id, d04Request, d04Id); |
| | | //两条线都有进卧转立任务,直接结束 |
| | | if (Const.BIG_STORAGE_REQUEST_IN.equals(d01Request) |
| | | && Const.BIG_STORAGE_REQUEST_IN.equals(d04Request) |
| | | && StringUtils.isNotBlank(d01ID1) |
| | | && StringUtils.isNotBlank(d04ID1)) { |
| | | && StringUtils.isNotBlank(d01Id) |
| | | && StringUtils.isNotBlank(d04Id)) { |
| | | log.info("两条线都存在进片任务,结束任务"); |
| | | return; |
| | | } |
| | |
| | | log.info("两条线卧转立为空或者有进片任务未完成,结束任务"); |
| | | return; |
| | | } |
| | | // 0:不干预 ; 1:条件满足情况下立即发车 |
| | | String d02GoAdress = plcParameterObject.getPlcParameter("D02Go").getAddress(); |
| | | // 0:不干预 ; 1:条件满足情况下立即发车 |
| | | String d05GoAdress = plcParameterObject.getPlcParameter("D05Go").getAddress(); |
| | | String line1 = lineList.get(0); |
| | | String flagLine = line1.equals(Const.A09_OUT_TARGET_POSITION) ? d01ID1 : d04ID1; |
| | | String flagLine = line1.equals(Const.A09_OUT_TARGET_POSITION) ? d01Id : d04Id; |
| | | if (lineList.size() == 1) { |
| | | //发送 |
| | | if (StringUtils.isNotBlank(flagLine)) { |
| | | return; |
| | | } |
| | | //计算任务表进片格子 发送进片任务 |
| | | computeTargetByLine(Integer.parseInt(flagLine), d02GoAdress, d05GoAdress); |
| | | computeTargetByLine(Integer.parseInt(flagLine)); |
| | | return; |
| | | } |
| | | if (StringUtils.isBlank(d01ID1) && StringUtils.isBlank(d04ID1)) { |
| | | if (StringUtils.isBlank(d01Id) && StringUtils.isBlank(d04Id)) { |
| | | //比较最早一片任务的版图id及版序 求出卧转立的线路 |
| | | Integer line = getStartLine(); |
| | | //计算任务表进片格子 发送进片任务 |
| | | computeTargetByLine(line, d02GoAdress, d05GoAdress); |
| | | computeTargetByLine(line); |
| | | return; |
| | | } |
| | | int outLine = StringUtils.isBlank(d01ID1) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; |
| | | int outLine = StringUtils.isBlank(d01Id) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; |
| | | //计算任务表进片格子 发送进片任务 |
| | | computeTargetByLine(outLine, d02GoAdress, d05GoAdress); |
| | | computeTargetByLine(outLine); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgOutTask() { |
| | | //todo:是否有正在出片的钢化任务 |
| | | //任务数据 获取车子存放玻璃最大数量 玻璃间隔 |
| | | List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); |
| | | //是否有正在钢化的玻璃 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlassInfo::getTemperingFeedSequence)); |
| | | //任务数据 获取车子存放玻璃最大数量 玻璃间隔 |
| | | List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfoList)) { |
| | | log.info("有正在出片的钢化任务"); |
| | | //打车剩余尺寸 |
| | | AtomicReference<Integer> remainWidth = new AtomicReference<>(Const.BIG_STORAGE_WIDTH); |
| | | temperingGlassInfoList.stream().forEach(e -> { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth.get()) { |
| | | return; |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (TemperingGlassInfo e : temperingGlassInfoList) { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth) { |
| | | break; |
| | | } |
| | | remainWidth.set(remainWidth.get() - e.getWidth().intValue() - Const.BIG_STORAGE_GAP); |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getState(), Const.A09_OUT_TARGET_POSITION, |
| | | 0, 0, 1)); |
| | | }); |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | return; |
| | | } |
| | | |
| | | //获取状态字 钢化优先 or 人工下片优先 |
| | | if (true) { |
| | | //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 |
| | | TemperingLayoutDTO temperingLayoutDTO = bigStorageCageDetailsService.temperingIsAll(); |
| | | if (null != temperingLayoutDTO) { |
| | | //玻璃到齐 |
| | | //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务 结束 |
| | | List<BigStorageCageDetails> bigStorageCageDetails = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId, temperingLayoutDTO.getTemperingLayoutId()) |
| | | .eq(BigStorageCageDetails::getEngineerId, temperingLayoutDTO.getEngineerId())); |
| | | List<TemperingGlassInfo> temperingGlassInfos = bigStorageCageDetails.stream().map(e -> { |
| | | TemperingGlassInfo info = new TemperingGlassInfo(); |
| | | BeanUtils.copyProperties(e, info); |
| | | return info; |
| | | }).collect(Collectors.toList()); |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | | |
| | | //大车剩余尺寸 |
| | | AtomicReference<Integer> remainWidth = new AtomicReference<>(Const.BIG_STORAGE_WIDTH); |
| | | temperingGlassInfoList.stream().forEach(e -> { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth.get()) { |
| | | return; |
| | | } |
| | | remainWidth.set(remainWidth.get() - e.getWidth().intValue() - Const.BIG_STORAGE_GAP); |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getState(), Const.A09_OUT_TARGET_POSITION, |
| | | 0, 0, 1)); |
| | | }); |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | return; |
| | | } |
| | | //未到齐 执行内部调度任务 结束 |
| | | TemperingLayoutDTO temperingOccupySlot = bigStorageCageDetailsService.queryTemperingOccupySlot(); |
| | | if (null != temperingOccupySlot) { |
| | | List<SlotSequenceDTO> slotSequenceList = bigStorageCageDetailsService.queryGlassMaxAndMin(temperingOccupySlot.getEngineerId(), temperingOccupySlot.getTemperingLayoutId()); |
| | | for (int i = 0; i < slotSequenceList.size() - 1; i++) { |
| | | SlotSequenceDTO first = slotSequenceList.get(i); |
| | | SlotSequenceDTO second = slotSequenceList.get(i + 1); |
| | | if (first.getMinSequence() == second.getMaxSequence() + 1 |
| | | && second.getRemainWidth() > Const.BIG_STORAGE_WIDTH - first.getRemainWidth() - Const.BIG_STORAGE_GAP) { |
| | | List<BigStorageCageDetails> list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getSlot, first.getSlot()).eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)); |
| | | List<BigStorageCageOutTask> outTasks = list.stream().map(e -> new BigStorageCageOutTask(e.getGlassId(), first.getSlot(), second.getSlot(), |
| | | 0, 0, 1)).collect(Collectors.toList()); |
| | | bigStorageCageOutTaskService.saveBatch(outTasks); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | //笼内是否有人工下片玻璃 有直接出 无 结束 |
| | | List<BigStorageCageDetails> oneList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN).orderByDesc(BigStorageCageDetails::getWidth)); |
| | | AtomicReference<Integer> remainWidth = new AtomicReference<>(Const.BIG_STORAGE_WIDTH); |
| | | if (CollectionUtils.isNotEmpty(oneList)) { |
| | | oneList.stream().forEach(e -> { |
| | | if (remainWidth.get() < e.getWidth().intValue()) { |
| | | return; |
| | | //todo:是否有人工下片任务 有直接出 |
| | | //笼内是否有人工下片玻璃 无 结束 |
| | | List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL).orderByDesc(BigStorageCageDetails::getWidth)); |
| | | if (CollectionUtils.isEmpty(artificialList)) { |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (BigStorageCageDetails e : artificialList) { |
| | | if (remainWidth < e.getWidth().intValue()) { |
| | | break; |
| | | } |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), 0, 0, 0, 1)); |
| | | remainWidth.set(remainWidth.get() - e.getWidth().intValue() - Const.BIG_STORAGE_GAP); |
| | | }); |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | return; |
| | | } |
| | | |
| | | //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 |
| | | TemperingLayoutDTO temperingLayoutDTO = bigStorageCageDetailsService.temperingIsAll(); |
| | | if (null != temperingLayoutDTO) { |
| | | //玻璃到齐 |
| | | //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务 结束 |
| | | List<BigStorageCageDetails> bigStorageCageDetails = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId, temperingLayoutDTO.getTemperingLayoutId()) |
| | | .eq(BigStorageCageDetails::getEngineerId, temperingLayoutDTO.getEngineerId())); |
| | | List<TemperingGlassInfo> temperingGlassInfos = bigStorageCageDetails.stream().map(e -> { |
| | | TemperingGlassInfo info = new TemperingGlassInfo(); |
| | | BeanUtils.copyProperties(e, info); |
| | | return info; |
| | | }).collect(Collectors.toList()); |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | | |
| | | //大车剩余尺寸 |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (TemperingGlassInfo e : temperingGlassInfoList) { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth) { |
| | | break; |
| | | } |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getState(), Const.A09_OUT_TARGET_POSITION, |
| | | 0, 0, 1)); |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | return; |
| | | } |
| | | //未到齐 执行内部调度任务 |
| | | TemperingLayoutDTO temperingOccupySlot = bigStorageCageDetailsService.queryTemperingOccupySlot(); |
| | | if (null != temperingOccupySlot) { |
| | | List<SlotSequenceDTO> slotSequenceList = bigStorageCageDetailsService.queryGlassMaxAndMin(temperingOccupySlot.getEngineerId(), temperingOccupySlot.getTemperingLayoutId()); |
| | | for (int i = 0; i < slotSequenceList.size() - 1; i++) { |
| | | SlotSequenceDTO first = slotSequenceList.get(i); |
| | | SlotSequenceDTO second = slotSequenceList.get(i + 1); |
| | | if (first.getMinSequence() == second.getMaxSequence() + 1 |
| | | && second.getRemainWidth() > Const.BIG_STORAGE_WIDTH - first.getRemainWidth() - Const.BIG_STORAGE_GAP) { |
| | | List<BigStorageCageDetails> list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getSlot, first.getSlot()).eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)); |
| | | List<BigStorageCageOutTask> outTasks = list.stream().map(e -> new BigStorageCageOutTask(e.getGlassId(), first.getSlot(), second.getSlot(), |
| | | 0, 0, 1)).collect(Collectors.toList()); |
| | | bigStorageCageOutTaskService.saveBatch(outTasks); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | Assert.isFalse(CollectionUtils.isEmpty(edgGlassTaskInfoList), "识别玻璃信息未出现在尺寸表中,获取相邻两块玻璃失败"); |
| | | //2、获取卧转立剩余宽度 |
| | | Map<String, Object> map = bigStorageCageFeedTaskService.getMap(new QueryWrapper<BigStorageCageFeedTask>() |
| | | .select("cast(5000 - sum(width + 20) as INT)as remainWidth") |
| | | .select("cast(" + Const.BIG_STORAGE_WIDTH + " - sum(width + " + Const.BIG_STORAGE_GAP + ") as INT) as remainWidth") |
| | | .eq("line", line).eq("task_state", Const.BIG_STORAGE_IN_UP)); |
| | | Integer remainWidth = null == map ? 5000 : Integer.parseInt(map.get("remainWidth") + ""); |
| | | Integer remainWidth = null == map ? Const.BIG_STORAGE_WIDTH : Integer.parseInt(map.get("remainWidth") + ""); |
| | | //2、获取卧转立 |
| | | Integer widthFirst = edgGlassTaskInfoList.get(0).getWidth(); |
| | | if (edgGlassTaskInfoList.size() == 1) { |
| | | if (remainWidth >= widthFirst) { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst); |
| | | return Boolean.FALSE; |
| | | } else { |
| | | //记录无法放下玻璃,后续判断启动 |
| | | return Boolean.TRUE; |
| | | } |
| | | } |
| | | Integer widthSecond = edgGlassTaskInfoList.get(1).getWidth(); |
| | | if (remainWidth >= widthFirst) { |
| | | if (remainWidth - widthFirst - Const.BIG_STORAGE_GAP >= widthSecond) { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthSecond); |
| | | } else { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthSecond); |
| | | } |
| | | return Boolean.FALSE; |
| | | |
| | | } else { |
| | | return Boolean.TRUE; |
| | | Integer widthSecond = edgGlassTaskInfoList.get(1).getWidth(); |
| | | if (remainWidth >= widthFirst) { |
| | | if (remainWidth - widthFirst - Const.BIG_STORAGE_GAP >= widthSecond) { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthSecond); |
| | | return Boolean.FALSE; |
| | | } else { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthSecond); |
| | | } |
| | | } |
| | | } |
| | | //记录无法放下玻璃,后续判断启动 |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 获取需要启动的线路:两条线都可启动 获取第一片玻璃版图id最小 版序最大的线路 |
| | | * |
| | | * @return |
| | | * @return 需要启动的线路 |
| | | */ |
| | | public Integer getStartLine() { |
| | | List<BigStorageCageFeedTask> taskList = bigStorageCageFeedTaskService.list(new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | |
| | | /** |
| | | * 计算任务表进片线路的目标格子,并启动任务 |
| | | */ |
| | | public boolean computeTargetByLine(Integer line, String d02GoAdress, String d05GoAdress) { |
| | | public boolean computeTargetByLine(Integer line) { |
| | | //1、获取任务表中的所有玻璃(指定线路且已经进卧转立完成) |
| | | List<BigStorageCageFeedTask> taskList = bigStorageCageFeedTaskService.list(new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | | .eq(BigStorageCageFeedTask::getLine, line) |
| | |
| | | //2、去笼子内查找是否可以继续存放的笼子 |
| | | List<String> glassIds = taskList.stream().map(BigStorageCageFeedTask::getGlassId).collect(Collectors.toList()); |
| | | List<GlassInfo> glassInfos = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIds)); |
| | | AtomicReference<Integer> temperingLayoutIdTemp = new AtomicReference<>(0); |
| | | AtomicReference<Integer> temperingFeedSequenceTemp = new AtomicReference<>(0); |
| | | AtomicReference<BigStorageDTO> bigStorageDTO = new AtomicReference<>(new BigStorageDTO()); |
| | | Map<String, GlassInfo> glassInfoMap = glassInfos.stream().collect(Collectors.toMap(GlassInfo::getGlassId, p -> p)); |
| | | |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = new ArrayList<>(); |
| | | AtomicBoolean taskFlag = new AtomicBoolean(Boolean.TRUE); |
| | | taskList.stream().forEach(e -> { |
| | | BigStorageCageDetails cageDetails = new BigStorageCageDetails(); |
| | | //按照版图信息获取进片笼子格子号 |
| | | List<BigStorageCageDetails> temperingList = computeIsTemperingTargetByLine(glassInfos, taskList, Boolean.TRUE); |
| | | List<BigStorageCageDetails> noTemperingList = computeIsTemperingTargetByLine(glassInfos, taskList, Boolean.FALSE); |
| | | bigStorageCageDetailsList.addAll(temperingList); |
| | | bigStorageCageDetailsList.addAll(noTemperingList); |
| | | //4、在详情表中加入进片玻璃信息 |
| | | bigStorageCageDetailsService.saveBatch(bigStorageCageDetailsList); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | /** |
| | | * 是否钢化玻璃进笼目标位置 |
| | | * |
| | | * @param glassInfos 当条线卧转立所有玻璃 |
| | | * @param taskList 当条线卧转立所有任务 |
| | | * @param isTempering true 钢化 false 不钢化 |
| | | */ |
| | | private List<BigStorageCageDetails> computeIsTemperingTargetByLine(List<GlassInfo> glassInfos, List<BigStorageCageFeedTask> taskList, Boolean isTempering) { |
| | | Map<String, GlassInfo> glassInfoMap; |
| | | if (isTempering) { |
| | | glassInfoMap = glassInfos.stream().filter(e -> e.getTemperingLayoutId() != 0) |
| | | .collect(Collectors.toMap(GlassInfo::getGlassId, p -> p)); |
| | | } else { |
| | | glassInfoMap = glassInfos.stream().filter(e -> e.getTemperingLayoutId() == 0) |
| | | .collect(Collectors.toMap(GlassInfo::getGlassId, p -> p)); |
| | | } |
| | | |
| | | //设置临时变量接受版图id,版序、格子号及剩余宽度 |
| | | Integer temperingLayoutIdTemp = 0; |
| | | Integer temperingFeedSequenceTemp = 0; |
| | | BigStorageDTO bigStorageDTO = new BigStorageDTO(); |
| | | |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList = new ArrayList<>(); |
| | | for (BigStorageCageFeedTask e : taskList) { |
| | | GlassInfo info = glassInfoMap.get(e.getGlassId()); |
| | | if (info == null) { |
| | | continue; |
| | | } |
| | | BigStorageCageDetails cageDetails = new BigStorageCageDetails(); |
| | | BeanUtils.copyProperties(info, cageDetails); |
| | | if (temperingLayoutIdTemp.equals(info.getTemperingLayoutId()) |
| | | && temperingFeedSequenceTemp.equals(info.getTemperingFeedSequence() + 1) |
| | | && info.getWidth() <= bigStorageDTO.get().getWidth()) { |
| | | bigStorageDTO.get().setWidth(bigStorageDTO.get().getWidth() - info.getWidth().intValue() - Const.BIG_STORAGE_GAP); |
| | | && info.getWidth() <= bigStorageDTO.getWidth()) { |
| | | bigStorageDTO.setWidth(bigStorageDTO.getWidth() - info.getWidth().intValue() - Const.BIG_STORAGE_GAP); |
| | | } else { |
| | | bigStorageDTO.set(bigStorageCageDetailsService.queryTargetSlotByTempering(info)); |
| | | bigStorageDTO = bigStorageCageDetailsService.queryTargetSlotByTempering(info); |
| | | } |
| | | e.setTargetSlot(bigStorageDTO.get().getSlot()); |
| | | cageDetails.setSlot(bigStorageDTO.get().getSlot()); |
| | | cageDetails.setState(Const.GLASS_STATE_IN); |
| | | temperingLayoutIdTemp.set(info.getTemperingLayoutId()); |
| | | temperingFeedSequenceTemp.set(info.getTemperingFeedSequence()); |
| | | bigStorageCageDetailsList.add(cageDetails); |
| | | taskFlag.set(bigStorageCageFeedTaskService.updateById(e)); |
| | | if (!taskFlag.get()) { |
| | | return; |
| | | } |
| | | }); |
| | | //3、更新进片任务表 遇到问题:无法批量更新,批量更新无法走指定从库 |
| | | |
| | | //4、在详情表中加入进片玻璃信息 |
| | | bigStorageCageDetailsService.saveBatch(bigStorageCageDetailsList); |
| | | if (taskFlag.get()) { |
| | | String lineAddress = line.equals(Const.A09_OUT_TARGET_POSITION) ? d02GoAdress : d05GoAdress; |
| | | // S7object.getinstance().plccontrol.writeWord(lineAddress, (short) 1); |
| | | cageDetails.setSlot(bigStorageDTO.getSlot()); |
| | | cageDetails.setState(Const.GLASS_STATE_IN); |
| | | |
| | | e.setTargetSlot(bigStorageDTO.getSlot()); |
| | | e.setTaskType(Const.BIG_STORAGE_IN_RUN); |
| | | |
| | | temperingLayoutIdTemp = info.getTemperingLayoutId(); |
| | | temperingFeedSequenceTemp = info.getTemperingFeedSequence(); |
| | | //3、更新进片任务表 遇到问题:无法批量更新,批量更新无法走指定从库 |
| | | bigStorageCageFeedTaskService.updateById(e); |
| | | bigStorageCageDetailsList.add(cageDetails); |
| | | } |
| | | return taskFlag.get(); |
| | | return bigStorageCageDetailsList; |
| | | } |
| | | } |