| | |
| | | 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; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private WrkMastLocMapper wrkMastLocMapper; |
| | | @Autowired |
| | | private BasLiftOptService basLiftOptService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | |
| | | /** |
| | |
| | | wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 |
| | | wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setShuttleNo(null); // 穿梭车清空 |
| | | wrkMast.setLiftNo(null);// 提升机清空 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | |
| | | && liftProtocol.getTaskNo() != 0 |
| | | && !liftProtocol.getBusy() |
| | | ) { |
| | | BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString()); |
| | | int taskNo = liftProtocol.getTaskNo().intValue(); |
| | | if (basLiftOpt != null) { |
| | | taskNo = basLiftOpt.getWrkNo(); |
| | | } |
| | | |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(liftProtocol.getTaskNo().intValue()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); |
| | | if (wrkMast != null) { |
| | | switch (wrkMast.getWrkSts().intValue()) { |
| | | case 3://3.提升机搬运中 ==> 4.提升机搬运完成 |
| | |
| | | wrkMast.setWrkSts(25L); |
| | | if (wrkMast.getIoType() == 11) {//库位移转 |
| | | wrkMast.setWrkSts(4L);//4.提升机搬运完成 |
| | | }else { |
| | | if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { |
| | | //不需要用到机械臂,直接转29.出库完成 |
| | | wrkMast.setWrkSts(29L); |
| | | } |
| | | } |
| | | |
| | | if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { |
| | | //释放提升机令牌 |
| | | liftProtocol.setToken(0); |
| | | } |
| | | |
| | | if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { |
| | | //不需要用到机械臂,直接转29.出库完成 |
| | | wrkMast.setWrkSts(29L); |
| | | } |
| | | |
| | | break; |
| | |
| | | } |
| | | |
| | | //获取穿梭车最近且空闲的提升机输送站点 |
| | | LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId()); |
| | | LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo())); |
| | | if (liftSta == null) { |
| | | return false;//没有可用且空闲的输送站点 |
| | | } |
| | |
| | | private boolean locToLocExecuteStep3(WrkMast wrkMast) { |
| | | Date now = new Date(); |
| | | if (wrkMast.getWrkSts() == 23) {//23.小车搬运完成 |
| | | //源站 |
| | | Integer sourceStaNo = wrkMast.getSourceStaNo(); |
| | | //目标站 |
| | | Integer staNo = wrkMast.getStaNo(); |
| | | if (sourceStaNo == null || staNo == null) { |
| | | return false;//源站或目标站为空 |
| | | } |
| | | |
| | | int liftNo = staNo / 100;//获取提升机号 |
| | | |
| | | //获取提升机线程 |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); |
| | | if (liftThread == null) { |
| | | return false; |
| | | } |
| | | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | if (liftProtocol == null) { |
| | | return false; |
| | | } |
| | | |
| | | //获取源站对应的输送站点 |
| | | LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo())); |
| | | if (liftStaProtocol == null) { |
| | | return false;//找不到站点 |
| | | } |
| | | |
| | | if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { |
| | | return false;//站点必须自动、空闲、有托盘 |
| | | } |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | return false; |
| | | } |
| | | NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { |
| | | //小车还在输送站点 |
| | | //调度小车避让 |
| | | boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (!liftProtocol.isIdle()) { |
| | |
| | | WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); |
| | | if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { |
| | | return false; |
| | | } |
| | | |
| | | //源站 |
| | | Integer sourceStaNo = wrkMast.getSourceStaNo(); |
| | | //目标站 |
| | | Integer staNo = wrkMast.getStaNo(); |
| | | if (sourceStaNo == null || staNo == null) { |
| | | return false;//源站或目标站为空 |
| | | } |
| | | |
| | | //获取提升机命令 |
| | |
| | | private boolean locToLocExecuteStep4(WrkMast wrkMast) { |
| | | if (wrkMast.getWrkSts() == 4) {//4.提升机搬运完成 |
| | | //获取目标站对应的输送站点 |
| | | BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo()); |
| | | if (targetBasDevp == null) { |
| | | return false;//缺少站点信息 |
| | | LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(wrkMast.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); |
| | | if (liftStaProtocol == null) { |
| | | return false;//找不到站点 |
| | | } |
| | | |
| | | if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { |
| | | return false;//站点必须自动、空闲、有托盘 |
| | | } |
| | | |
| | | if (wrkMast.getShuttleNo() == null) { |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo());//调度小车到目标输送站点进行取货 |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//调度小车到目标输送站点进行取货 |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //判断小车是否到达目标输送站点 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(targetBasDevp.getLocNo())) { |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { |
| | | //小车不在目标输送站点 |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getShuttleNo());//调度小车到目标输送站点进行取货 |
| | | shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//调度小车到目标输送站点进行取货 |
| | | return false; |
| | | } |
| | | |
| | | //小车已抵达目标输送站点,将货物搬运到目标库位 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo()); |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getLocNo()); |
| | | if (result == null) {//路径计算失败 |
| | | return false; |
| | | } |
| | |
| | | continue;//没有空闲站点 |
| | | } |
| | | |
| | | targetSta = (short) 317; |
| | | |
| | | if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { |
| | | //向AGV发起组托请求 |
| | | try { |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成 |
| | | if (wrkMast.getWrkSts() != 29) {//29.出库完成 |
| | | continue; |
| | | } |
| | | |
| | |
| | | //覆盖工作档目标站 |
| | | wrkMast.setStaNo(sourceStaNo); |
| | | wrkMast.setSourceStaNo(staNo); |
| | | wrkMast.setMk("N"); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //向300站写入目标站 |
| | | staProtocol = staProtocol.clone(); |
| | |
| | | } |
| | | } else if (wrkCharge.getWrkSts() == 52) { |
| | | //检测小车是否满电 |
| | | |
| | | //获取满电阈值 |
| | | int maxPower = 95; |
| | | EntityWrapper<Config> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("code", "chargeMaxValue"); |
| | | Config config = configService.selectOne(wrapper); |
| | | if (config != null) { |
| | | maxPower = Integer.parseInt(config.getValue()); |
| | | } |
| | | |
| | | if (shuttleProtocol.getPowerPercent() < maxPower) { |
| | | continue; |
| | | } |