| | |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.entity.FindCrnNoResult; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.RedisUtil; |
| | |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.DualCrnCommand; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.param.SendDualCrnCommandParam; |
| | | import com.zy.core.model.protocol.DualCrnProtocol; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.DualCrnThread; |
| | |
| | | return; |
| | | } |
| | | |
| | | List<WrkMast> allTaskList = new ArrayList<>(); |
| | | List<WrkMast> inTaskList = getInTaskList(basDualCrnp); |
| | | List<WrkMast> outTaskList = getOutTaskList(basDualCrnp); |
| | | List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp); |
| | | |
| | | if (!locMoveTaskList.isEmpty()) { |
| | | allTaskList.addAll(locMoveTaskList); |
| | | if (!(dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE))) { |
| | | return; |
| | | } |
| | | |
| | | // 如果最近一次是出库模式 |
| | | if (dualCrnProtocol.getLastIo().equals("O")) { |
| | | allTaskList.addAll(inTaskList); |
| | | allTaskList.addAll(outTaskList); |
| | | processLoveMove(basDualCrnp, dualCrnThread); |
| | | processIn(basDualCrnp, dualCrnThread); |
| | | processOut(basDualCrnp, dualCrnThread); |
| | | } |
| | | // 如果最近一次是入库模式 |
| | | else if (dualCrnProtocol.getLastIo().equals("I")) { |
| | | allTaskList.addAll(outTaskList); |
| | | allTaskList.addAll(inTaskList); |
| | | processLoveMove(basDualCrnp, dualCrnThread); |
| | | processOut(basDualCrnp, dualCrnThread); |
| | | processIn(basDualCrnp, dualCrnThread); |
| | | } |
| | | } |
| | | |
| | | private void processIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) { |
| | | List<WrkMast> inTaskList = getInTaskList(basDualCrnp); |
| | | if (inTaskList.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | for (WrkMast wrkMast : allTaskList) { |
| | | if (wrkMast.getIoType() == WrkIoType.IN.id) { |
| | | boolean result = this.crnExecuteIn(basDualCrnp, dualCrnThread, wrkMast); |
| | | if (result) { |
| | | break; |
| | | } |
| | | } else if (wrkMast.getIoType() == WrkIoType.OUT.id) { |
| | | boolean result = this.crnExecuteOut(basDualCrnp, dualCrnThread, wrkMast); |
| | | if (result) { |
| | | break; |
| | | } |
| | | } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) { |
| | | boolean result = this.crnExecuteLocMove(basDualCrnp, dualCrnThread, wrkMast); |
| | | if (result) { |
| | | break; |
| | | WrkMast stationOneWrkMast = inTaskList.get(0); |
| | | WrkMast stationTwoWrkMast = null; |
| | | |
| | | if (inTaskList.size() >= 2) { |
| | | stationTwoWrkMast = inTaskList.get(1); |
| | | } |
| | | |
| | | SendDualCrnCommandParam oneResult = null; |
| | | SendDualCrnCommandParam twoResult = null; |
| | | |
| | | if(stationOneWrkMast != null){ |
| | | oneResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationOneWrkMast); |
| | | } |
| | | |
| | | if(stationTwoWrkMast != null){ |
| | | twoResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationTwoWrkMast); |
| | | } |
| | | |
| | | List<SendDualCrnCommandParam> list = new ArrayList<>(); |
| | | if (oneResult != null) { |
| | | list.add(oneResult); |
| | | } |
| | | |
| | | if (twoResult != null) { |
| | | list.add(twoResult); |
| | | } |
| | | |
| | | if (!list.isEmpty()) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list)); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list)); |
| | | dualCrnProtocol.setLastIo("I"); |
| | | } |
| | | } |
| | | |
| | | private void processOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) { |
| | | List<WrkMast> outTaskList = getOutTaskList(basDualCrnp); |
| | | if (outTaskList.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | WrkMast stationOneWrkMast = null; |
| | | WrkMast stationTwoWrkMast = null; |
| | | |
| | | List<Integer> disableList = basDualCrnp.getDisableStationOneBays$(); |
| | | |
| | | for (WrkMast wrkMast : outTaskList) { |
| | | if (stationOneWrkMast == null) { |
| | | if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) { |
| | | stationOneWrkMast = wrkMast; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (stationTwoWrkMast == null) { |
| | | if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) { |
| | | stationTwoWrkMast = wrkMast; |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | SendDualCrnCommandParam oneResult = null; |
| | | SendDualCrnCommandParam twoResult = null; |
| | | |
| | | if(stationOneWrkMast != null){ |
| | | oneResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationOneWrkMast, 1); |
| | | } |
| | | |
| | | if(stationTwoWrkMast != null){ |
| | | twoResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2); |
| | | } |
| | | |
| | | List<SendDualCrnCommandParam> list = new ArrayList<>(); |
| | | if (oneResult != null) { |
| | | list.add(oneResult); |
| | | } |
| | | |
| | | if (twoResult != null) { |
| | | list.add(twoResult); |
| | | } |
| | | |
| | | if (!list.isEmpty()) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list)); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list)); |
| | | dualCrnProtocol.setLastIo("O"); |
| | | } |
| | | } |
| | | |
| | | private void processLoveMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) { |
| | | List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp); |
| | | if (locMoveTaskList.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | WrkMast stationOneWrkMast = null; |
| | | WrkMast stationTwoWrkMast = null; |
| | | |
| | | List<Integer> disableList = basDualCrnp.getDisableStationOneBays$(); |
| | | |
| | | for (WrkMast wrkMast : locMoveTaskList) { |
| | | if (stationOneWrkMast == null) { |
| | | if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) { |
| | | stationOneWrkMast = wrkMast; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (stationTwoWrkMast == null) { |
| | | if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) { |
| | | stationTwoWrkMast = wrkMast; |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | SendDualCrnCommandParam oneResult = null; |
| | | SendDualCrnCommandParam twoResult = null; |
| | | |
| | | if(stationOneWrkMast != null){ |
| | | oneResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationOneWrkMast, 1); |
| | | } |
| | | |
| | | if(stationTwoWrkMast != null){ |
| | | twoResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2); |
| | | } |
| | | |
| | | List<SendDualCrnCommandParam> list = new ArrayList<>(); |
| | | if (oneResult != null) { |
| | | list.add(oneResult); |
| | | } |
| | | |
| | | if (twoResult != null) { |
| | | list.add(twoResult); |
| | | } |
| | | |
| | | if (!list.isEmpty()) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list)); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list)); |
| | | dualCrnProtocol.setLastIo("O"); |
| | | } |
| | | } |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | List<Integer> taskList = new ArrayList<>(); |
| | | List<StationObjModel> inStationList = basDualCrnp.getInStationList$(); |
| | | if(inStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo()); |
| | | return list; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : inStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId()); |
| | | Map<Integer, StationProtocol> map = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = map.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isAutoing()) { |
| | | continue; |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() > 0 |
| | | ) { |
| | | taskList.add(stationProtocol.getTaskNo()); |
| | | } |
| | | } |
| | | |
| | | if (!stationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.getTaskNo() <= 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isInEnable()) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "取货站点:{} 没有可入信号", stationObjModel.getStationId()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取任务 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (null == wrkMast) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "工作号:{} 任务信息不存在", stationProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取任务 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("dual_crn_no", basDualCrnp.getCrnNo()) |
| | | .in("wrk_no", taskList) |
| | | ); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){ |
| | | continue; |
| | | } |
| | | |
| | | list.add(wrkMast); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) { |
| | | private synchronized SendDualCrnCommandParam crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | if (dualCrnProtocol == null) { |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if (!basDualCrnp.getInEnable().equals("Y")) { |
| | | News.info("双工位堆垛机:{} 可入信号不满足", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | List<StationObjModel> inStationList = basDualCrnp.getInStationList$(); |
| | | if(inStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | |
| | | if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) { |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 信息不存在", wrkMast.getLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("S")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 状态异常", wrkMast.getLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | //检测浅库位状态 |
| | | boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo()); |
| | | if (!checkStatus) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行"); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | StationObjModel inStationObjModel = null; |
| | |
| | | inStationObjModel = stationObjModel; |
| | | break; |
| | | } |
| | | |
| | | StationObjModel dualCrnSlaveStationObjModel = stationObjModel.getDualCrnSlaveStation(); |
| | | if (dualCrnSlaveStationObjModel == null) { |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol slaveStationProtocol = stationProtocolMap.get(dualCrnSlaveStationObjModel.getStationId()); |
| | | if (slaveStationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!slaveStationProtocol.isAutoing()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!slaveStationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (slaveStationProtocol.getTaskNo() <= 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (slaveStationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) { |
| | | inStationObjModel = dualCrnSlaveStationObjModel; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (inStationObjModel == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "未搜索到取货站点"); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | Integer station = inStationObjModel.getDualCrnExecuteStation(); |
| | |
| | | if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) { |
| | | //禁止放货列,申请重新分配 |
| | | reassignTaskLocNo(wrkMast, inStationObjModel); |
| | | return false; |
| | | return null; |
| | | } |
| | | }else { |
| | | List<Integer> basList = basDualCrnp.getDisableStationTwoBays$(); |
| | | if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) { |
| | | //禁止放货列,申请重新分配 |
| | | reassignTaskLocNo(wrkMast, inStationObjModel); |
| | | return false; |
| | | return null; |
| | | } |
| | | } |
| | | |
| | |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList)); |
| | | SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam(); |
| | | sendDualCrnCommandParam.setCrnNo(crnNo); |
| | | sendDualCrnCommandParam.setStation(station); |
| | | sendDualCrnCommandParam.setCommands(commandList); |
| | | sendDualCrnCommandParam.setCommandIdx(0); |
| | | |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_IN_TASK_RUN, null); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList)); |
| | | dualCrnProtocol.setLastIo("I"); |
| | | return true; |
| | | return sendDualCrnCommandParam; |
| | | } |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) { |
| | | private synchronized SendDualCrnCommandParam crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | if (dualCrnProtocol == null) { |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if (!basDualCrnp.getOutEnable().equals("Y")) { |
| | | News.info("双工位堆垛机:{} 可出信号不满足", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | List<StationObjModel> outStationList = basDualCrnp.getOutStationList$(); |
| | | if (outStationList.isEmpty()) { |
| | | News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | int station = calcStation(dualCrnProtocol, "out"); |
| | | if (station == 0) { |
| | | News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationObjModel.getDualCrnExecuteStation() != station) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList)); |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList)); |
| | | dualCrnProtocol.setLastIo("O"); |
| | | |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(stationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24); |
| | | return true; |
| | | |
| | | SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam(); |
| | | sendDualCrnCommandParam.setCrnNo(crnNo); |
| | | sendDualCrnCommandParam.setStation(station); |
| | | sendDualCrnCommandParam.setCommands(commandList); |
| | | sendDualCrnCommandParam.setCommandIdx(0); |
| | | |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null); |
| | | return sendDualCrnCommandParam; |
| | | } |
| | | } |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) { |
| | | private synchronized SendDualCrnCommandParam crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) { |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | if (dualCrnProtocol == null) { |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | int station = calcStation(dualCrnProtocol, "locMove"); |
| | | if (station == 0) { |
| | | News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | } |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts) |
| | | ); |
| | | |
| | | // 获取源库位信息 |
| | | LocMast sourceLocMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (sourceLocMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 信息不存在", wrkMast.getSourceLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if(!sourceLocMast.getLocSts().equals("R")){ |
| | | if (!sourceLocMast.getLocSts().equals("R")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 状态异常,不属于出库预约状态", wrkMast.getSourceLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位:{} 信息不存在", wrkMast.getLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("S")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位:{} 状态异常,不属于入库预约状态", wrkMast.getLocNo()); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | //检测浅库位状态 |
| | | boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo()); |
| | | if (!checkStatus) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行"); |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | List<DualCrnCommand> commandList = new ArrayList<>(); |
| | |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList)); |
| | | SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam(); |
| | | sendDualCrnCommandParam.setCrnNo(crnNo); |
| | | sendDualCrnCommandParam.setStation(station); |
| | | sendDualCrnCommandParam.setCommands(commandList); |
| | | sendDualCrnCommandParam.setCommandIdx(0); |
| | | |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_TRANSFER_TASK_RUN, null); |
| | | News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList)); |
| | | dualCrnProtocol.setLastIo("I"); |
| | | return true; |
| | | return sendDualCrnCommandParam; |
| | | } |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | //双工位堆垛机任务执行完成 |
| | |
| | | return; |
| | | } |
| | | |
| | | Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + wrkMast.getWrkNo()); |
| | | if (commandObj == null) { |
| | | Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + basDualCrnp.getCrnNo()); |
| | | if (commandListObj == null) { |
| | | News.error("双工位堆垛机处于等待确认且任务完成状态,但未找到命令。堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo); |
| | | return; |
| | | } |
| | | List<SendDualCrnCommandParam> dualCrnCommandParamList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class); |
| | | SendDualCrnCommandParam taskCommand = null; |
| | | for (SendDualCrnCommandParam sendDualCrnCommandParam : dualCrnCommandParamList) { |
| | | DualCrnCommand dualCrnCommand = sendDualCrnCommandParam.getCommands().get(0); |
| | | if(dualCrnCommand.getTaskNo() == taskNo){ |
| | | taskCommand = sendDualCrnCommandParam; |
| | | break; |
| | | } |
| | | } |
| | | if (taskCommand == null) { |
| | | News.error("双工位堆垛机处于等待确认且任务完成状态,但未找到命令。堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo); |
| | | return; |
| | | } |
| | | |
| | | JSONObject commandMap = JSON.parseObject(commandObj.toString()); |
| | | Integer idx = commandMap.getInteger("idx"); |
| | | List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class); |
| | | Integer idx = taskCommand.getCommandIdx(); |
| | | List<DualCrnCommand> commandList = taskCommand.getCommands(); |
| | | if (idx >= commandList.size()) { |
| | | Long updateWrkSts = null; |
| | | if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) { |
| | |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) { |
| | | updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts; |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), basDualCrnp.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_COMPLETE, null); |
| | | |
| | | |
| | | List<StationObjModel> outStationList = basDualCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | if(mainProcessPlugin.contains("Fake")) { |
| | | //生成仿真站点数据 |
| | | List<StationObjModel> outStationList = basDualCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_IO_EXECUTE_FINISH_LIMIT.key + basDualCrnp.getCrnNo() + "_" + taskNo, "lock", 10); |
| | | } |
| | | }else { |
| | | DualCrnCommand command = commandList.get(idx - 1); |
| | | if (command.getTaskMode() == DualCrnTaskModeType.PICK.id.shortValue()) { |
| | | //取货后等待下一个任务时长 |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + basDualCrnp.getCrnNo(), "wait", 10); |
| | | } |
| | | |
| | | DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station); |
| | | MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand)); |
| | | News.info("双工位堆垛机命令完成确认成功,堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo); |
| | |
| | | if (lock != null) { |
| | | return false; |
| | | } |
| | | redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5); |
| | | |
| | | Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo)); |
| | | if (shallowRow == null) { |
| | | return true; |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5); |
| | | String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo)); |
| | | LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo); |
| | | if (shallowLocMast == null) { |
| | |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private int calcStation(DualCrnProtocol dualCrnProtocol, String type) { |
| | | List<Integer> idleStationList = new ArrayList<>(); |
| | | |
| | | if (dualCrnProtocol.getTaskNo() == 0 |
| | | && dualCrnProtocol.getLoaded() == 0 |
| | | && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) |
| | | && dualCrnProtocol.getTaskReceive() == 0 |
| | | ) { |
| | | idleStationList.add(1); |
| | | } |
| | | |
| | | if (dualCrnProtocol.getTaskNoTwo() == 0 |
| | | && dualCrnProtocol.getLoadedTwo() == 0 |
| | | && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE) |
| | | && dualCrnProtocol.getTaskReceiveTwo() == 0 |
| | | ) { |
| | | idleStationList.add(2); |
| | | } |
| | | |
| | | if (type.equals("locMove")) { |
| | | if (idleStationList.size() != 2) { |
| | | return 0; |
| | | } |
| | | return idleStationList.get(0); |
| | | } |
| | | |
| | | if (idleStationList.size() == 2) { |
| | | return idleStationList.get(0); |
| | | } |
| | | |
| | | Integer idleStation = idleStationList.get(0); |
| | | int workingStation = idleStation == 1 ? 2 : 1; |
| | | |
| | | int executeTaskNo = 0; |
| | | if (workingStation == 1) { |
| | | executeTaskNo = dualCrnProtocol.getTaskNo(); |
| | | //检测工位已进入放货阶段,放货阶段不接新任务 |
| | | if (dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUT_MOVING) |
| | | || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUTTING) |
| | | || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.WAITING) |
| | | ) { |
| | | return 0; |
| | | } |
| | | } else { |
| | | executeTaskNo = dualCrnProtocol.getTaskNoTwo(); |
| | | //检测工位已进入放货阶段,放货阶段不接新任务 |
| | | if (dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUT_MOVING) |
| | | || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUTTING) |
| | | || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.WAITING) |
| | | ) { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | if (executeTaskNo == 0) { |
| | | return 0; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo); |
| | | if (wrkMast.getIoType().equals(WrkIoType.IN.id) && type.equals("in")) { |
| | | return idleStation; |
| | | } |
| | | |
| | | if (wrkMast.getIoType().equals(WrkIoType.OUT.id) && type.equals("out")) { |
| | | return idleStation; |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) { |