| | |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.action.LiftAction; |
| | | import com.zy.asrs.wcs.core.action.ShuttleAction; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.entity.*; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.command.*; |
| | | import com.zy.asrs.wcs.core.model.enums.*; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.service.*; |
| | | import com.zy.asrs.wcs.core.utils.*; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private LiftAction liftAction; |
| | | @Autowired |
| | | private LiftDispatcher liftDispatcher; |
| | | @Autowired |
| | | private BasConveyorService basConveyorService; |
| | | @Autowired |
| | | private BasConveyorStaService basConveyorStaService; |
| | | @Autowired |
| | | private ShuttleDispatcher shuttleDispatcher; |
| | | |
| | | // 计算 |
| | | public Boolean accept(Motion motion) { |
| | |
| | | if (shuttleThread == null) { |
| | | return false; |
| | | } |
| | | Device shuttleDevice = shuttleThread.getDevice(); |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (null == shuttleProtocol) { |
| | | return false; |
| | |
| | | return false; |
| | | } |
| | | |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo())); |
| | | if (task == null) { |
| | | return false; |
| | | } |
| | | |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | | assignCommand.setShuttleNo(deviceNo); |
| | | assignCommand.setTaskNo(motion.getTaskNo()); |
| | |
| | | if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocNo, motion.getTarget()) |
| | | .eq(Loc::getHostId, motion.getHostId())).getCode())) { |
| | | return true; |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | break; |
| | | case SHUTTLE_TRANSPORT://穿梭车载货行走 |
| | | // 如果已经在当前条码则过滤 |
| | | if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocNo, motion.getTarget()) |
| | | .eq(Loc::getHostId, motion.getHostId())).getCode())) { |
| | | return true; |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT; |
| | | break; |
| | | case SHUTTLE_TRANSPORT_TO_CONVEYOR://穿梭车载货进输送线 |
| | | BasConveyorSta originStaObj = basConveyorStaService.selectBySiteNo(motion.getDockNo());//获取输送站点 |
| | | if (originStaObj == null) { |
| | | return false; |
| | | } |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(originStaObj.getConveyorId()); |
| | | if(basConveyor == null) { |
| | | return false; |
| | | } |
| | | |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | if (devpThread == null) { |
| | | return false; |
| | | } |
| | | StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getDockNo()));//输送站 |
| | | if (staProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!(staProtocol.isAutoing() && !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable())) { |
| | | return false; |
| | | } |
| | | |
| | | // 如果已经在当前条码则过滤 |
| | | if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocNo, motion.getTarget()) |
| | | .eq(Loc::getHostId, motion.getHostId())).getCode())) { |
| | | return true; |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | |
| | | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_UPDATE_LOCATION; |
| | | shuttleCommands.add(shuttleThread.getUpdateLocationCommand(motion.getTaskNo(), motion.getTarget())); |
| | | break; |
| | | case SHUTTLE_MOVE_STANDBY://穿梭车移动到待机位 |
| | | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | |
| | | //获取全部待机位 |
| | | List<String> standbyLocs = JSON.parseArray(motion.getTemp(), String.class); |
| | | //获取可用待机位 |
| | | String shuttleFromLiftStandbyLoc = shuttleDispatcher.searchAvailableLocNo(Integer.valueOf(shuttleDevice.getDeviceNo()), shuttleDevice.getHostId(), shuttleThread.getStatus().getCurrentLocNo(), standbyLocs); |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), shuttleFromLiftStandbyLoc, NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | |
| | | //更新动作可用待机位 |
| | | motion.setTarget(shuttleFromLiftStandbyLoc); |
| | | motion.setUpdateTime(new Date()); |
| | | motionService.updateById(motion); |
| | | |
| | | break; |
| | | default: |
| | | throw new CoolException(motion.getMotionCtgEl() + "没有指定任务作业流程!!!"); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo())); |
| | | if (task == null) { |
| | | return false; |
| | | } |
| | | |
| | | LiftThread liftThread = null; |
| | | LiftProtocol liftProtocol = null; |
| | | |
| | |
| | | case SHUTTLE_MOVE_DOWN_PALLET: |
| | | case SHUTTLE_MOVE_TO_CONVEYOR: |
| | | case SHUTTLE_MOVE_FROM_CONVEYOR: |
| | | case SHUTTLE_TRANSPORT_TO_CONVEYOR://穿梭车载货进输送线 |
| | | case SHUTTLE_TRANSPORT://穿梭车载货行走 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { |
| | | return false; |
| | | } |
| | | |
| | | if (Optional.ofNullable(motion.getReleaseShuttle()).orElse(0) == 1) {//释放穿梭车 |
| | | task.setShuttleNo(0); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case SHUTTLE_MOVE_TO_LIFT: |
| | | liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | |
| | | return false; |
| | | } |
| | | break; |
| | | case SHUTTLE_MOVE_STANDBY://穿梭车移动到待机位 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { |
| | | return false; |
| | | } |
| | | |
| | | if (Optional.ofNullable(motion.getReleaseShuttle()).orElse(0) == 1) {//释放穿梭车 |
| | | task.setShuttleNo(0); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | return false; |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |