| | |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnForkPosType; |
| | | import com.zy.core.enums.CrnModeType; |
| | | import com.zy.core.enums.CrnStatusType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | |
| | | staProtocol.setStaNo(startupDto.getStaNo()); |
| | | staProtocol.setPakMk(false); |
| | | staProtocol.setInreq1(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol)); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | staProtocol.setStaNo(wrkMast.getStaNo()); |
| | | staProtocol.setPakMk(false); |
| | | staProtocol.setInreq1(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol)); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | // 1.复位堆垛机 更新堆垛机信息 且 下发plc命令 todo:luxiaotao |
| | | crnProtocol.setStatus(CrnStatusType.IDLE); |
| | | crnProtocol.setTaskNo((short)0); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(4, crnProtocol))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(4, crnProtocol))) { |
| | | throw new CoolException("更新堆垛机信息失败"); |
| | | } |
| | | |
| | | // 2.下发站点信息 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo()); |
| | | if (!MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task<>(4, staProtocol))) { |
| | | if (!MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol))) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | // 库位移转 |
| | | this.locToLoc(); |
| | | |
| | | this.locToLoc(crn); |
| | | } |
| | | } |
| | | |
| | |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(2, crnCommand))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | } |
| | |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 1); // 任务完成确认位 |
| | | |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(2, crnCommand))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 库位移转 |
| | | */ |
| | | private void locToLoc(){ |
| | | |
| | | private void locToLoc(CrnSlave slave){ |
| | | // 获取工作档信息 |
| | | WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); |
| | | if (null == wrkMast) { |
| | | return; |
| | | } |
| | | // 获取源库位信息 |
| | | LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (null == sourceSta) { |
| | | log.error("工作档库位移转失败,原因:检索源库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); |
| | | return; |
| | | } |
| | | // 源库位 库位状态判断 |
| | | if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("S")) { |
| | | return; |
| | | } |
| | | // 获取目标库位信息 |
| | | LocMast sta = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (null == sta) { |
| | | log.error("工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | return; |
| | | } |
| | | // 获取堆垛机信息 并 判断是否可入出 |
| | | BasCrnp basCrnp = basCrnpService.selectById(slave.getId()); |
| | | if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { |
| | | return; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | } |
| | | |
| | | /** |