|  |  | 
 |  |  | import com.core.common.R; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.domain.enums.CrnStatusType; | 
 |  |  | import com.zy.asrs.domain.param.CrnDemoParam; | 
 |  |  | import com.zy.asrs.domain.param.SteModeParam; | 
 |  |  | import com.zy.asrs.domain.param.SteOperatorParam; | 
 |  |  | import com.zy.asrs.domain.vo.SteMsgTableVo; | 
 |  |  | import com.zy.asrs.domain.vo.SteStateTableVo; | 
 |  |  | import com.zy.asrs.domain.vo.SteDataVo; | 
 |  |  | import com.zy.asrs.entity.BasSte; | 
 |  |  | import com.zy.asrs.entity.BasSteErr; | 
 |  |  | import com.zy.asrs.entity.WrkMast; | 
 |  |  | import com.zy.asrs.mapper.BasSteErrMapper; | 
 |  |  | import com.zy.asrs.service.BasSteService; | 
 |  |  | import com.zy.asrs.service.WrkMastService; | 
 |  |  | import com.zy.core.cache.MessageQueue; | 
 |  |  | 
 |  |  | import com.zy.core.cache.SlaveConnection; | 
 |  |  | import com.zy.core.enums.SlaveType; | 
 |  |  | import com.zy.core.enums.SteTaskModeType; | 
 |  |  | import com.zy.core.model.CrnSlave; | 
 |  |  | import com.zy.core.model.SteSlave; | 
 |  |  | import com.zy.core.model.Task; | 
 |  |  | import com.zy.core.model.command.SteCommand; | 
 |  |  | import com.zy.core.model.protocol.SteProtocol; | 
 |  |  | import com.zy.core.properties.SlaveProperties; | 
 |  |  | import com.zy.core.properties.SystemProperties; | 
 |  |  | import com.zy.core.thread.SteThread; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  |     private BasSteService basSteService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkMastService wrkMastService; | 
 |  |  |     @Autowired | 
 |  |  |     private BasSteErrMapper basSteErrMapper; | 
 |  |  |  | 
 |  |  |     @PostMapping("/table/ste/state") | 
 |  |  |     @ManagerAuth(memo = "穿梭车信息表") | 
 |  |  | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             vo.setTaskNo(steProtocol.getTaskNo().intValue());  //  任务号 | 
 |  |  |             vo.setStatusType(steProtocol.mode == 0 ? "离线" : "在线");   //  模式状态 | 
 |  |  |             vo.setStatusVal(steProtocol.getMode().intValue());  // 在线状态 | 
 |  |  |             String modeName = "离线"; | 
 |  |  |             switch (steProtocol.mode){ | 
 |  |  |                 case -1: | 
 |  |  |                     modeName = "离线"; | 
 |  |  |                     break; | 
 |  |  |                 case 0: | 
 |  |  |                     modeName = "脱机"; | 
 |  |  |                     break; | 
 |  |  |                 case 1: | 
 |  |  |                     modeName = "联机"; | 
 |  |  |                     break; | 
 |  |  |             } | 
 |  |  |             vo.setStatusType(modeName);   //  模式 | 
 |  |  | //            vo.setStatusType(steProtocol.mode == 0 ? "离线" : "在线");   //  模式状态 | 
 |  |  |             if (!Cools.isEmpty(steProtocol.getStatus())) { | 
 |  |  |                 vo.setStatus(steProtocol.getStatusType().desc);     //  状态 | 
 |  |  |             } | 
 |  |  | 
 |  |  |             if (!Cools.isEmpty(steProtocol.getTrack())) { | 
 |  |  |                 vo.setTrack(steProtocol.getTrack()==0?"✔":"×"); | 
 |  |  |             } | 
 |  |  |             if (!Cools.isEmpty(steProtocol.getChargeStatus())) { | 
 |  |  |                 vo.setChargeStatus(steProtocol.getChargeStatus()==1?"✔":"×"); | 
 |  |  |             } | 
 |  |  |             if(steProtocol.getAlarm() > 0){ | 
 |  |  |                 BasSteErr steErr = basSteErrMapper.selectById(steProtocol.getAlarm()); | 
 |  |  |                 vo.setAlarm1(steErr==null?"未知异常":steErr.getErrName()); | 
 |  |  |             } | 
 |  |  |             vo.setAlarm2(steProtocol.getAlarm0().toString()); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(list); | 
 |  |  |     } | 
 |  |  | 
 |  |  |     /************************** 手动操作 ******************************/ | 
 |  |  |     /****************************************************************/ | 
 |  |  |  | 
 |  |  |     @PostMapping("/mode/switch") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R crnDemo(SteModeParam param) throws InterruptedException { | 
 |  |  |         if (Cools.isEmpty(param.getSteNo())){ | 
 |  |  |             return R.error(); | 
 |  |  |         } | 
 |  |  |         if (Cools.isEmpty(param.getPassword())){ | 
 |  |  |             return R.error("请输入口令"); | 
 |  |  |         } | 
 |  |  |         if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){ | 
 |  |  |             return R.error("口令错误"); | 
 |  |  |         } | 
 |  |  |         Thread.sleep(200L); | 
 |  |  |         for (SteSlave steSlave : slaveProperties.getSte()) { | 
 |  |  |             if (steSlave.getId().equals(param.getSteNo())) { | 
 |  |  |                 // 获取穿梭车信息 | 
 |  |  |                 SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steSlave.getId()); | 
 |  |  |                 SteProtocol steProtocol = steThread.getSteProtocol(); | 
 |  |  |                 if (steProtocol == null) { continue; } | 
 |  |  |                 SteCommand steCommand = new SteCommand(); | 
 |  |  |                 steCommand.setSteNo(param.getSteNo()); // 穿梭车编号 | 
 |  |  |                 if (steProtocol.getMode() == 0) { | 
 |  |  |                     steCommand.setControlMode((short) 1); | 
 |  |  |                 } else { | 
 |  |  |                     steCommand.setControlMode((short) 0); | 
 |  |  |                 } | 
 |  |  |                 if (MessageQueue.offer(SlaveType.Ste, param.getSteNo(), new Task(2, steCommand))) { | 
 |  |  |                     return R.ok(); | 
 |  |  |                 } else { | 
 |  |  |                     throw new CoolException("命令下发失败"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ManagerAuth(memo = "手动操作") | 
 |  |  |     @PostMapping("/operator/ste") | 
 |  |  |     public R steOperator(SteOperatorParam param){ | 
 |  |  | 
 |  |  |                 steCommand.setSteNo(ste.getId()); // 穿梭车编号 | 
 |  |  |                 if (param.getSteTaskMode() == 16) { | 
 |  |  |                     steCommand.setComplete(true); | 
 |  |  |                 } else if (param.getSteTaskMode() == 17) { | 
 |  |  |                 } else if (param.getSteTaskMode() == 99) { | 
 |  |  |                     steCommand.setControlMode((short) 1); | 
 |  |  |                 } else if (param.getSteTaskMode() == 18) { | 
 |  |  |                 } else if (param.getSteTaskMode() == 100) { | 
 |  |  |                     steCommand.setControlMode((short) 0); | 
 |  |  |                 } else { | 
 |  |  |                     if (steTaskModeType == null) { |