| | |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.*; |
| | | import com.zy.core.model.command.*; |
| | | import com.zy.core.model.protocol.*; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.*; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | |
| | | @Service("mainService") |
| | | public class MainServiceImpl { |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到输送站点行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false; |
| | |
| | | //强制预留一台小车给入库任务 |
| | | int lev = Utils.getLev(wrkMast.getSourceLocNo()); |
| | | //获取当前楼层有几台可用小车 |
| | | int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev); |
| | | int shuttleCount = shuttleDispatchUtils.getShuttleEnableUseCountByLev(lev); |
| | | if (shuttleCount >= 2) {//只有可用小车数量大于2,才进行入库任务预留小车 |
| | | int shuttleWrkInObligateCount = 1;//预留小车数量 |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1)); |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到输送站点行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false; |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到输送站点行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false; |
| | |
| | | } |
| | | |
| | | //获取提升机命令 |
| | | List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); |
| | | ForkLiftCommand liftCommand = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev()); |
| | | ArrayList<ForkLiftCommand> commands = new ArrayList<>(); |
| | | commands.addAll(liftCommands); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | |
| | | } |
| | | |
| | | //获取提升机命令 |
| | | List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); |
| | | ForkLiftCommand liftCommand = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo()); |
| | | ArrayList<ForkLiftCommand> commands = new ArrayList<>(); |
| | | commands.addAll(liftCommands); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | |
| | | for (DeviceConfig device : forkliftList) { |
| | | //获取提升机信息 |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo()); |
| | | if(forkLiftThread == null) { |
| | | continue; |
| | | } |
| | | ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); |
| | | if (forkLiftProtocol == null) { |
| | | continue; |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //计算近点位置 |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, null, null, 1); |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1); |
| | | if (endLocation == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,小车近点位置计算失败", wrkMast.getWrkNo()); |
| | | return false; |
| | |
| | | } |
| | | |
| | | //获取小车到近点行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.SHUTTLE), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false;//路径解锁失败 |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到提升机行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false;//路径解锁失败 |
| | |
| | | } |
| | | |
| | | //获取提升机命令 |
| | | List<ForkLiftCommand> liftCommands = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev()); |
| | | ForkLiftCommand liftCommand = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev()); |
| | | ArrayList<ForkLiftCommand> commands = new ArrayList<>(); |
| | | commands.addAll(liftCommands); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | |
| | | assignCommand.setLocNo(wrkMast.getLocNo());//目标库位 |
| | | |
| | | //获取小车到目标库位命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false;//路径计算失败 |
| | |
| | | |
| | | //自动切换出入库模式 |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | // 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); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | //出库任务预调度提升机 |
| | |
| | | int workNo = commonService.getWorkNo(WrkIoType.FORKLIFT_MOVE.id);//获取任务号 |
| | | |
| | | //获取提升机命令 |
| | | List<ForkLiftCommand> liftCommand = forkLiftThread.getMoveCommand(workNo, forkLiftProtocol.getLev(), Utils.getLev(wrkMast.getSourceLocNo())); |
| | | ForkLiftCommand liftCommand = forkLiftThread.getMoveCommand(workNo, forkLiftProtocol.getLev(), Utils.getLev(wrkMast.getSourceLocNo())); |
| | | ArrayList<ForkLiftCommand> commands = new ArrayList<>(); |
| | | commands.addAll(liftCommand); |
| | | commands.add(liftCommand); |
| | | |
| | | //提交到线程去工作 |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |