| | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.NyShuttleOperaResult; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.*; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.swing.*; |
| | | import java.io.IOException; |
| | | import java.net.Socket; |
| | | import java.text.MessageFormat; |
| | |
| | | && !shuttleProtocol.getPakMk()) { |
| | | //执行下一步指令 |
| | | executeWork(shuttleProtocol.getTaskNo().shortValue()); |
| | | } |
| | | |
| | | //小车空闲且有跑库程序 |
| | | if (shuttleProtocol.isIdle() && shuttleProtocol.getMoveLoc()) { |
| | | moveLoc(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | |
| | | // //判断数据是否执行完成 |
| | | // if (commandStep < commands.size() - 1) { |
| | | // commandStep++; |
| | | // //更新redis数据 |
| | | // redisCommand.setCommandStep(commandStep); |
| | | // //任务数据保存到redis |
| | | // redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | // }else { |
| | | // //已执行完成 |
| | | // |
| | | // commandStep = commands.size(); |
| | | // //更新redis数据 |
| | | // redisCommand.setCommandStep(commandStep); |
| | | // //任务数据保存到redis |
| | | // redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | //// //最后一段命令为移动命令,则暂缓删除redis等待清除路径时一次性删除 |
| | | //// //最后一段命令为不是移动命令,则删除redis |
| | | //// if (!command.getRequest().getBody().get("requestType").equals("move")) { |
| | | //// //删除redis |
| | | //// redisUtil.del("shuttle_wrk_no_" + redisCommand.getWrkNo()); |
| | | //// } |
| | | //// |
| | | //// if (!assignCommand.getCharge()) { |
| | | //// //对主线程抛出等待确认状态waiting |
| | | //// shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | //// }else { |
| | | //// shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); |
| | | //// } |
| | | //// News.info("四向穿梭车任务执行下发完成等待执行结束,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | // } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | return false;//不可行走 |
| | | } |
| | | |
| | | /** |
| | | * 跑库程序 |
| | | */ |
| | | private void moveLoc() { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | ShuttleDispatchUtils shuttleDispatchUtils = SpringUtils.getBean(ShuttleDispatchUtils.class); |
| | | CommonService commonService = SpringUtils.getBean(CommonService.class); |
| | | WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class); |
| | | int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//小车当前楼层 |
| | | if (!shuttleProtocol.isIdle()) { |
| | | return; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectShuttleHasMoveWorking(shuttleProtocol.getShuttleNo().intValue()); |
| | | if (wrkMast != null) { |
| | | return; |
| | | } |
| | | |
| | | if (shuttleProtocol.getMoveType() == 0) {//跑轨道 |
| | | ArrayList<String> locs = new ArrayList<>(); |
| | | for (int i = shuttleProtocol.getXCurrent(); i <= shuttleProtocol.getXTarget(); i++) { |
| | | String locNo = Utils.getLocNo(i, shuttleProtocol.getYCurrent(), lev); |
| | | locs.add(locNo); |
| | | } |
| | | List<LocMast> locMasts = locMastService.selectEmptyLocNos(locs); |
| | | if (locMasts.isEmpty()) { |
| | | //空库位 |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); |
| | | return; |
| | | } |
| | | |
| | | LocMast start = locMasts.get(0); |
| | | LocMast target = locMasts.get(locMasts.size() - 1); |
| | | //判断小车是否在起点位置 |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(start.getLocNo())) {//不在起点位置,调度去起点位置 |
| | | shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), start.getLocNo()); |
| | | }else { |
| | | //在起点位置,调度去目标位置 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) { |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//小车和目标位置一致,跳过 |
| | | }else { |
| | | boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), target.getLocNo()); |
| | | if (result) {//调度成功 |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); |
| | | } |
| | | } |
| | | } |
| | | }else {//跑库位 |
| | | |
| | | } |
| | | } |
| | | |
| | | } |