| | |
| | | import com.zy.core.action.LiftAction; |
| | | import com.zy.core.action.ShuttleAction; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.dispatcher.LiftDispatchUtils; |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.command.*; |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private NavigateMapUtils navigateMapUtils; |
| | | @Autowired |
| | | private NavigateMapData navigateMapData; |
| | | @Autowired |
| | | private NavigateUtils navigateUtils; |
| | |
| | | private BasShuttleChargeService basShuttleChargeService; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private LiftDispatchUtils liftDispatchUtils; |
| | | |
| | | /** |
| | | * 初始化实时地图 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 货叉提升机任务 |
| | | * 提升机任务 |
| | | */ |
| | | public synchronized void forkLiftIoExecute() { |
| | | public synchronized void liftIoExecute() { |
| | | try { |
| | | //搜索是否有待处理的任务 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | |
| | | } |
| | | |
| | | /** |
| | | * 货叉提升机任务完成 |
| | | * 提升机任务完成 |
| | | */ |
| | | public synchronized void forkLiftFinished() { |
| | | public synchronized void liftFinished() { |
| | | try { |
| | | List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.ForkLift))); |
| | | for (DeviceConfig device : forkliftList) { |
| | | List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Lift))); |
| | | for (DeviceConfig device : liftList) { |
| | | //获取提升机信息 |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo()); |
| | | if(forkLiftThread == null) { |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo()); |
| | | if(liftThread == null) { |
| | | continue; |
| | | } |
| | | ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); |
| | | if (forkLiftProtocol == null) { |
| | | LiftProtocol liftProtocol = liftThread.getStatus(); |
| | | if (liftProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | //提升机为等待确认且空闲 |
| | | if (forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.WAITING.id |
| | | && forkLiftProtocol.getWrkNo() != 0 |
| | | if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id |
| | | && liftProtocol.getTaskNo() != 0 |
| | | ) { |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(forkLiftProtocol.getWrkNo()); |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | if (wrkMast.getWrkSts() == WrkStsType.INBOUND_LIFT_RUN.sts) { |
| | | //3.提升机搬运中 ==> 4.提升机搬运完成 |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts); |
| | | wrkMast.setLiftNo(null);//释放提升机 |
| | | forkLiftThread.setSyncTaskNo(0); |
| | | }else if (wrkMast.getWrkSts() == WrkStsType.MOVE_NEARBY_COMPLETE.sts) { |
| | | //303.小车移动至近点完成 -- 调度提升机到小车层 |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_LIFT_RUN.sts) { |
| | | //104.提升机搬运中 ==> 109.出库完成 |
| | | //304.提升机搬运中 ==> 109.出库完成 |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts); |
| | | wrkMast.setLiftNo(null);//释放提升机 |
| | | forkLiftThread.setSyncTaskNo(0); |
| | | redisUtil.set(RedisKeyType.FORK_LIFT_PUT_COMPLETE.key + forkLiftProtocol.getLiftNo(), wrkMast.getWmsWrkNo(), 60 * 3); |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_LIFT_RUN.sts) { |
| | | //306.提升机搬运中 ==> 307.提升机搬运完成 |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN_COMPLETE.sts); |
| | | forkLiftThread.setSyncTaskNo(0); |
| | | } else { |
| | | News.error("提升机确认失败,提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); |
| | | return; |
| | | } |
| | | |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | forkLiftThread.reset(); |
| | | News.info("提升机已确认且任务完成状态。提升机号={}", forkLiftProtocol.getLiftNo()); |
| | | liftThread.reset(); |
| | | News.info("提升机已确认且任务完成状态。提升机号={}", liftProtocol.getLiftNo()); |
| | | } else { |
| | | News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", forkLiftProtocol.getLiftNo(), forkLiftProtocol.getWrkNo()); |
| | | News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); |
| | | } |
| | | }else { |
| | | boolean checkPreviewDispatchForkLift = commonService.checkWorkNoContainMk(forkLiftProtocol.getWrkNo(), WrkIoType.FORKLIFT_MOVE.id); |
| | | boolean checkPreviewDispatchForkLift = commonService.checkWorkNoContainMk(liftProtocol.getTaskNo(), WrkIoType.PREVIEW_LIFT_MOVE.id); |
| | | if (checkPreviewDispatchForkLift) { |
| | | //属于提升机预调度移动任务 |
| | | //无工作档支撑,直接确认完成 |
| | | forkLiftThread.setSyncTaskNo(0); |
| | | forkLiftThread.reset(); |
| | | News.info("已确认提升机预调度移动任务。提升机号={}", forkLiftProtocol.getLiftNo()); |
| | | liftThread.setSyncTaskNo(0); |
| | | liftThread.reset(); |
| | | News.info("已确认提升机预调度移动任务。提升机号={}", liftProtocol.getLiftNo()); |
| | | } |
| | | } |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | //获取源输送站 |
| | | LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); |
| | | if (liftSta == null) { |
| | | return false;//找不到站点 |
| | | } |
| | | |
| | | if (liftSta.getHasCar()) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,源站存在小车", wrkMast.getWrkNo()); |
| | | //搜索最近且无故障提升机 |
| | | LiftStaProtocol recentLiftStation = liftDispatchUtils.getRecentLiftStation(shuttleProtocol.getShuttleNo(), Utils.getLev(wrkMast.getLocNo())); |
| | | if(recentLiftStation == null) { |
| | | News.info("{}号小车,{}目标库位,没有可用空闲输送站点", shuttleProtocol.getShuttleNo(), wrkMast.getLocNo()); |
| | | return false; |
| | | } |
| | | |
| | | //获取目标输送站 |
| | | LiftStaProtocol liftStaTarget = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); |
| | | if (liftStaTarget == null) { |
| | | return false;//找不到站点 |
| | | } |
| | | |
| | | if (liftStaTarget.getHasCar()) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,目标站存在小车", wrkMast.getWrkNo()); |
| | | LiftStaProtocol targetLiftSta = LiftUtils.getLiftStaByLev(recentLiftStation.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); |
| | | if(targetLiftSta == null) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //计算近点位置 |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1); |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), recentLiftStation.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1); |
| | | if (endLocation == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,小车近点位置计算失败", wrkMast.getWrkNo()); |
| | | return false; |
| | |
| | | //小车已在近点位置无需前往 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(endLocation)) { |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY_COMPLETE.sts);//小车移动到提升机中 301.生成小车移库任务 ==> 303.小车移动至近点完成 |
| | | wrkMast.setSourceStaNo(recentLiftStation.getStaNo()); |
| | | wrkMast.setStaNo(targetLiftSta.getStaNo()); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setSystemMsg("");//清空消息 |
| | | wrkMastService.updateById(wrkMast); |
| | |
| | | assignCommand.setCommands(commands); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY.sts);//小车移动到提升机中 301.生成小车移库任务 ==> 302.小车移动至近点中 |
| | | wrkMast.setSourceStaNo(recentLiftStation.getStaNo()); |
| | | wrkMast.setStaNo(targetLiftSta.getStaNo()); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setSystemMsg("");//清空消息 |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | int targetLev = Utils.getLev(wrkMast.getLocNo()); |
| | | int targetLev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); |
| | | if (liftProtocol.getLev() != targetLev) { |
| | | //获取提升机命令 |
| | | LiftCommand liftCommand = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), targetLev); |
| | |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setLiftNo(wrkMast.getLiftNo()); |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo()); |
| | | assignCommand.setTaskMode(ForkLiftTaskModeType.MOVE.id); |
| | | assignCommand.setTaskMode(LiftTaskModeType.MOVE.id); |
| | | //下发任务 |
| | | liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}号提升机在{}层,提升机不在小车层,调度移动中", wrkMast.getWrkNo(), liftProtocol.getLev(), wrkMast.getLiftNo()); |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到提升机行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getCurrentLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getCurrentLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread, "inLift"); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false;//路径解锁失败 |
| | |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setLiftNo(wrkMast.getLiftNo()); |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo()); |
| | | assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id); |
| | | assignCommand.setTaskMode(LiftTaskModeType.SHUTTLE_SWITCH.id); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//提升机搬运中 305.小车迁入提升机完成 ==> 306.提升机搬运中 |
| | | wrkMast.setSystemMsg("");//清空消息 |
| | |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //自动切换出入库模式 |
| | | public void autoSwitchForkLiftIOMode() { |
| | | // List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | // .eq("device_type", String.valueOf(SlaveType.ForkLift))); |
| | | // for (DeviceConfig device : forkliftList) { |
| | | // Integer liftNo = device.getDeviceNo(); |
| | | // ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo); |
| | | // if (forkLiftThread == null) { |
| | | // continue; |
| | | // } |
| | | // ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); |
| | | // if (forkLiftProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // List<Integer> liftAllStaNo = ForkLiftUtils.getLiftAllStaNo(liftNo); |
| | | // if (liftAllStaNo.isEmpty()) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // List<Integer> conveyorBindLiftAllStaNo = ForkLiftUtils.getConveyorBindLiftAllStaNo(liftNo); |
| | | // if (conveyorBindLiftAllStaNo.isEmpty()) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // //获取入库任务 |
| | | // List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | // .in("sta_no", liftAllStaNo) |
| | | // .in("wrk_sts" |
| | | // , WrkStsType.NEW_INBOUND.sts |
| | | // , WrkStsType.INBOUND_DEVICE_RUN.sts |
| | | // , WrkStsType.INBOUND_LIFT_RUN.sts |
| | | // , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts |
| | | // , WrkStsType.INBOUND_SHUTTLE_RUN.sts |
| | | // , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts |
| | | // )); |
| | | // |
| | | // //获取出库任务 |
| | | // List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | // .in("sta_no", conveyorBindLiftAllStaNo) |
| | | // .in("wrk_sts" |
| | | // , WrkStsType.NEW_OUTBOUND.sts |
| | | // , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts |
| | | // , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts |
| | | // , WrkStsType.OUTBOUND_LIFT_RUN.sts |
| | | // , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts |
| | | // )); |
| | | // |
| | | // if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) { |
| | | // //未知模式 |
| | | // if (!inWrkMasts.isEmpty()) { |
| | | // forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); |
| | | // } else if (!outWrkMasts.isEmpty()) { |
| | | // forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); |
| | | // }else { |
| | | // forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); |
| | | // } |
| | | // } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) { |
| | | // //入库模式 |
| | | // if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) { |
| | | // forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT); |
| | | // } |
| | | // } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) { |
| | | // //出库模式 |
| | | // if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) { |
| | | // forkLiftThread.switchIOMode(ForkLiftIoModeType.IN); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | } |