|  |  | 
 |  |  | import com.zy.core.enums.SlaveType; | 
 |  |  | import com.zy.core.enums.WrkIoType; | 
 |  |  | import com.zy.core.model.protocol.ForkLiftProtocol; | 
 |  |  | import com.zy.core.model.protocol.LiftProtocol; | 
 |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
 |  |  | import com.zy.core.thread.ForkLiftThread; | 
 |  |  | import com.zy.core.thread.LiftThread; | 
 |  |  | import com.zy.core.thread.ShuttleThread; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  |         return R.error("任务取消失败"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/deviceStatus") | 
 |  |  |     @RequestMapping("/deviceStatus") | 
 |  |  |     @OpenApiLog(memo = "获取设备状态") | 
 |  |  |     public R getDeviceStatus() { | 
 |  |  |         HashMap<String, Object> map = new HashMap<>(); | 
 |  |  | 
 |  |  |             forkLiftProtocols.add(forkLiftProtocol); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //获取提升机数据 | 
 |  |  |         ArrayList<LiftProtocol> liftProtocols = new ArrayList<>(); | 
 |  |  |         List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Lift))); | 
 |  |  |         for (DeviceConfig device : liftList) { | 
 |  |  |             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo()); | 
 |  |  |             if (liftThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             LiftProtocol liftProtocol = liftThread.getStatus(); | 
 |  |  |             if (liftProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             liftProtocols.add(liftProtocol); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         map.put("shuttle", shuttleProtocols); | 
 |  |  |         map.put("forkLift", forkLiftProtocols); | 
 |  |  |         map.put("lift", liftProtocols); | 
 |  |  |  | 
 |  |  |         apiLogService.insert(new ApiLog( | 
 |  |  |                 null | 
 |  |  | 
 |  |  |         return R.ok().add(map); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping("/liftDeviceOriginData") | 
 |  |  |     @OpenApiLog(memo = "获取提升机原始数据") | 
 |  |  |     public R getLiftDeviceOriginData() { | 
 |  |  |         HashMap<Integer, String> map = new HashMap<>(); | 
 |  |  |  | 
 |  |  |         //获取提升机数据 | 
 |  |  |         List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Lift))); | 
 |  |  |         for (DeviceConfig device : liftList) { | 
 |  |  |             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo()); | 
 |  |  |             if (liftThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             map.put(device.getDeviceNo(), liftThread.getRealtimeOriginData()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         apiLogService.insert(new ApiLog( | 
 |  |  |                 null | 
 |  |  |                 , "获取提升机原始数据" | 
 |  |  |                 , "/liftDeviceOriginData" | 
 |  |  |                 , null | 
 |  |  |                 , null | 
 |  |  |                 , null | 
 |  |  |                 , null | 
 |  |  |                 , JSON.toJSONString(map) | 
 |  |  |                 , null | 
 |  |  |                 , null | 
 |  |  |                 , 1 | 
 |  |  |                 , new Date() | 
 |  |  |                 , null | 
 |  |  |                 , null | 
 |  |  |         )); | 
 |  |  |  | 
 |  |  |         return R.ok().add(map); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/getLocInformation") | 
 |  |  |     @OpenApiLog(memo = "获取指定库位信息") | 
 |  |  |     public R getLocInformation(@RequestBody GetLocInformationParam param) { | 
 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasCar()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasTray()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点有托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点有托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             assignCommand.setCommands(commands); | 
 |  |  |  | 
 |  |  |             wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN.sts);//小车搬运中  101.生成出库任务 ==> 102.小车搬运中 | 
 |  |  |             wrkMast.setSourceStaNo(liftSta.getStaNo()); | 
 |  |  |             wrkMast.setSourceStaNo(liftSta.getSiteId()); | 
 |  |  |             wrkMast.setModiTime(new Date()); | 
 |  |  |             wrkMast.setSystemMsg("");//清空消息 | 
 |  |  |             if (wrkMastService.updateById(wrkMast)) { | 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasCar()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!liftSta.getHasTray()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点无托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点无托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             assignCommand.setCommands(commands); | 
 |  |  |  | 
 |  |  |             wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY.sts);//小车移动到提升机中  301.生成小车移库任务 ==> 302.小车移动至近点中 | 
 |  |  |             wrkMast.setSourceStaNo(recentLiftStation.getStaNo()); | 
 |  |  |             wrkMast.setStaNo(liftStaTarget.getStaNo()); | 
 |  |  |             wrkMast.setSourceStaNo(recentLiftStation.getSiteId()); | 
 |  |  |             wrkMast.setStaNo(liftStaTarget.getSiteId()); | 
 |  |  |             wrkMast.setModiTime(now); | 
 |  |  |             wrkMast.setSystemMsg("");//清空消息 | 
 |  |  |             if (wrkMastService.updateById(wrkMast)) { | 
 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasCar()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasTray()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点有托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点有托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             assignCommand.setCommands(commands); | 
 |  |  |  | 
 |  |  |             wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN.sts);//小车搬运中  101.生成出库任务 ==> 102.小车搬运中 | 
 |  |  |             wrkMast.setSourceStaNo(liftSta.getStaNo()); | 
 |  |  |             wrkMast.setSourceStaNo(liftSta.getSiteId()); | 
 |  |  |             wrkMast.setModiTime(new Date()); | 
 |  |  |             wrkMast.setSystemMsg("");//清空消息 | 
 |  |  |             if (wrkMastService.updateById(wrkMast)) { | 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (liftSta.getHasCar()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点存在小车,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!liftSta.getHasTray()) { | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点无托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getStaNo()); | 
 |  |  |                 News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}站点无托盘,禁止派发", wrkMast.getWrkNo(), liftSta.getSiteId()); | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             //小车已在近点位置无需前往 | 
 |  |  |             if (shuttleProtocol.getCurrentLocNo().equals(endLocation)) { | 
 |  |  |                 wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY_COMPLETE.sts);//小车移动到提升机中  301.生成小车移库任务 ==> 303.小车移动至近点完成 | 
 |  |  |                 wrkMast.setSourceStaNo(recentLiftStation.getStaNo()); | 
 |  |  |                 wrkMast.setStaNo(targetLiftSta.getStaNo()); | 
 |  |  |                 wrkMast.setSourceStaNo(recentLiftStation.getSiteId()); | 
 |  |  |                 wrkMast.setStaNo(targetLiftSta.getSiteId()); | 
 |  |  |                 wrkMast.setModiTime(now); | 
 |  |  |                 wrkMast.setSystemMsg("");//清空消息 | 
 |  |  |                 wrkMastService.updateById(wrkMast); | 
 |  |  | 
 |  |  |             assignCommand.setCommands(commands); | 
 |  |  |  | 
 |  |  |             wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY.sts);//小车移动到提升机中  301.生成小车移库任务 ==> 302.小车移动至近点中 | 
 |  |  |             wrkMast.setSourceStaNo(recentLiftStation.getStaNo()); | 
 |  |  |             wrkMast.setStaNo(targetLiftSta.getStaNo()); | 
 |  |  |             wrkMast.setSourceStaNo(recentLiftStation.getSiteId()); | 
 |  |  |             wrkMast.setStaNo(targetLiftSta.getSiteId()); | 
 |  |  |             wrkMast.setModiTime(now); | 
 |  |  |             wrkMast.setSystemMsg("");//清空消息 | 
 |  |  |             if (wrkMastService.updateById(wrkMast)) { | 
 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) { | 
 |  |  |             list.add(forkLiftStaProtocol.getStaNo()); | 
 |  |  |             list.add(forkLiftStaProtocol.getSiteId()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return list; | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //获取提升机站点 | 
 |  |  |     public static ForkLiftStaProtocol getLiftStaByStaNo(Integer staNo) { | 
 |  |  |     public static ForkLiftStaProtocol getLiftStaByStaNo(Integer siteId) { | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.ForkLift))); | 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) { | 
 |  |  |                 if (forkLiftStaProtocol.getStaNo().equals(staNo)) { | 
 |  |  |                 if (forkLiftStaProtocol.getSiteId().equals(siteId)) { | 
 |  |  |                     return forkLiftStaProtocol; | 
 |  |  |                 } | 
 |  |  |             } | 
 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { | 
 |  |  |             list.add(liftStaProtocol.getStaNo()); | 
 |  |  |             list.add(liftStaProtocol.getSiteId()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return list; | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //获取提升机站点 | 
 |  |  |     public static LiftStaProtocol getLiftStaByStaNo(Integer staNo) { | 
 |  |  |     public static LiftStaProtocol getLiftStaByStaNo(Integer siteId) { | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Lift))); | 
 |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { | 
 |  |  |                 if (liftStaProtocol.getStaNo().equals(staNo)) { | 
 |  |  |                 if (liftStaProtocol.getSiteId().equals(siteId)) { | 
 |  |  |                     return liftStaProtocol; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  | 
 |  |  |         if (liftThread == null) { | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) { | 
 |  |  |             if (liftStaProtocol.getLev().equals(lev)) { | 
 |  |  |                 return liftStaProtocol; | 
 
 |  |  | 
 |  |  |             for (NavigateNode node : nodes) { | 
 |  |  |                 if (node.getNodeValue() == MapNodeType.MAIN_PATH.id) { | 
 |  |  |                     continue; | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |                 targetNode = node; | 
 |  |  |                 break; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (targetNode == null) { | 
 |  |  |             List<NavigateNode> list = partList.get(partList.size() - 1); | 
 |  |  |             targetNode = list.get(0); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         String locNo = NavigatePositionConvert.nodeToLocNo(targetNode); | 
 |  |  |         return locNo; | 
 |  |  |     } | 
 
 |  |  | 
 |  |  |         ForkLiftStaProtocol recentSta = null;//最近站点 | 
 |  |  |         //搜索距离小车最近的站点 | 
 |  |  |         for (ForkLiftStaProtocol forkLiftStaProtocol : list) { | 
 |  |  |             Integer staNo = forkLiftStaProtocol.getStaNo();//站点号 | 
 |  |  |             Integer siteId = forkLiftStaProtocol.getSiteId();//站点号 | 
 |  |  |             String locNo = forkLiftStaProtocol.getLocNo();//站点库位号 | 
 |  |  |  | 
 |  |  |             //当前穿梭车线程到目标地点距离 | 
 
 |  |  | 
 |  |  |         LiftStaProtocol recentSta = null;//最近站点 | 
 |  |  |         //搜索距离小车最近的站点 | 
 |  |  |         for (LiftStaProtocol liftStaProtocol : list) { | 
 |  |  |             Integer staNo = liftStaProtocol.getStaNo();//站点号 | 
 |  |  |             Integer siteId = liftStaProtocol.getSiteId();//站点号 | 
 |  |  |             String locNo = liftStaProtocol.getLocNo();//站点库位号 | 
 |  |  |  | 
 |  |  |             //当前穿梭车线程到目标地点距离 | 
 
 |  |  | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { | 
 |  |  |             News.info("{}号小车,移动目标位置与小车当前位置一致无法移动", shuttleNo); | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //判断穿梭车是否存在未完成的小车移库任务 | 
 |  |  |         WrkMast hasMoveWorking = wrkMastService.selectShuttleHasMoveWorking(shuttleNo); | 
 |  |  |         if (hasMoveWorking != null) {//小车存在移库任务,等待执行完成后再生成新的任务 | 
 
 |  |  | 
 |  |  |     private Integer liftNo; | 
 |  |  |  | 
 |  |  |     // 提升机站点号 | 
 |  |  |     private Integer staNo; | 
 |  |  |     private Integer siteId; | 
 |  |  |  | 
 |  |  |     // 排 | 
 |  |  |     private Integer row; | 
 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 站点号 | 
 |  |  |      */ | 
 |  |  |     private Integer staNo; | 
 |  |  |     private Integer siteId; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 有托盘 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     private Short taskNo; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 目标站 | 
 |  |  |      */ | 
 |  |  |     private Integer staNo; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 层 | 
 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 站点号 | 
 |  |  |      */ | 
 |  |  |     private Integer staNo; | 
 |  |  |     private Integer siteId; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 模式 | 
 |  |  |      * 模式 1:自动 0:手动 | 
 |  |  |      */ | 
 |  |  |     private Boolean model; | 
 |  |  |  | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 任务号 | 
 |  |  |      */ | 
 |  |  |     private Short taskNo; | 
 |  |  |     private Integer taskNo; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 条码 | 
 |  |  |      */ | 
 |  |  |     private String barcode; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 目标位置 | 
 |  |  |      */ | 
 |  |  |     private Integer staNo; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 层 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     private Integer liftNo; | 
 |  |  |  | 
 |  |  |     public boolean getHasCar() { | 
 |  |  |         if (this.hasCar == null) { | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |         return this.hasCar; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public boolean getHasTray() { | 
 |  |  |         if (this.hasTray == null) { | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |         return this.hasTray; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     String getCurrentLocNo(); | 
 |  |  |  | 
 |  |  |     String getRealtimeOriginData();//获取实时原始数据 | 
 |  |  |  | 
 |  |  |     //***************获取命令***************** | 
 |  |  |  | 
 |  |  |     LiftCommand getPickAndPutCommand(Integer taskNo, Integer pick, Integer put);//取放货指令 | 
 
 |  |  | 
 |  |  |     private DeviceConfig device; | 
 |  |  |     private LiftProtocol liftProtocol; | 
 |  |  |     private RedisUtil redisUtil; | 
 |  |  |     LiftPointModel liftPointModel; | 
 |  |  |     private LiftPointModel liftPointModel; | 
 |  |  |     private List<LiftStaProtocol> liftStaProtocols = new ArrayList<>(); | 
 |  |  |     private List<DeviceMsgModel> readResultList = new ArrayList<>(); | 
 |  |  |     private List<DeviceMsgModel> resultList = new ArrayList<>(); | 
 |  |  |     private String realtimeOriginData = ""; | 
 |  |  |  | 
 |  |  |     public NyLiftThread(DeviceConfig device, LiftPointModel liftPointModel, List<LiftStation> stationList, RedisUtil redisUtil) { | 
 |  |  |         this.device = device; | 
 |  |  | 
 |  |  |         //初始化站点 | 
 |  |  |         for (LiftStation station : stationList) { | 
 |  |  |             LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); | 
 |  |  |             liftStaProtocol.setStaNo(station.getStaNo());//站点号 | 
 |  |  |             liftStaProtocol.setSiteId(station.getSiteId());//站点号 | 
 |  |  |             liftStaProtocol.setLev(station.getLev());//站点楼层 | 
 |  |  |             String locNo = Utils.getLocNo(station.getRow(), station.getBay(), station.getLev()); | 
 |  |  |             liftStaProtocol.setLocNo(locNo);//站点库位号 | 
 |  |  | 
 |  |  |             liftExtend.setOverHeight(data.getBoolean("overHeight")); | 
 |  |  |             liftExtend.setOverWeight(data.getBoolean("overWeight")); | 
 |  |  |  | 
 |  |  |             JSONArray trayList = data.getJSONArray("trayList"); | 
 |  |  |             for (int i = 0; i < trayList.size(); i++) { | 
 |  |  |                 int hasTray = (int) trayList.get(i); | 
 |  |  |                 LiftStaProtocol liftStaProtocol = liftStaProtocols.get(i); | 
 |  |  |                 liftStaProtocol.setHasTray(hasTray == 1); | 
 |  |  |             //读取站点 | 
 |  |  |             JSONArray stationList = data.getJSONArray("stationList"); | 
 |  |  |             if (stationList != null) { | 
 |  |  |                 for (int i = 0; i < stationList.size(); i++) { | 
 |  |  |                     JSONObject staObj = stationList.getJSONObject(i); | 
 |  |  |                     LiftStaProtocol liftStaProtocol = null; | 
 |  |  |                     for (LiftStaProtocol staProtocol : liftStaProtocols) { | 
 |  |  |                         if(staProtocol.getSiteId().equals(staObj.getInteger("siteId"))){ | 
 |  |  |                             liftStaProtocol = staProtocol; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if(liftStaProtocol == null){ | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     liftStaProtocol.setModel(staObj.getInteger("model") == 1); | 
 |  |  |                     liftStaProtocol.setBusy(staObj.getInteger("busy") == 1); | 
 |  |  |                     liftStaProtocol.setHasTray(staObj.getInteger("hasTray") == 1); | 
 |  |  |                     liftStaProtocol.setDeviceError(staObj.getInteger("deviceError") == 1); | 
 |  |  |                     liftStaProtocol.setTaskNo(staObj.getInteger("taskNo")); | 
 |  |  |                     liftStaProtocol.setBarcode(staObj.getString("barcode")); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             JSONArray carList = data.getJSONArray("carList"); | 
 |  |  |             for (int i = 0; i < carList.size(); i++) { | 
 |  |  |                 int hasCar = (int) carList.get(i); | 
 |  |  |                 LiftStaProtocol liftStaProtocol = liftStaProtocols.get(i); | 
 |  |  |                 liftStaProtocol.setHasCar(hasCar == 1); | 
 |  |  |             } | 
 |  |  |             this.realtimeOriginData = JSON.toJSONString(data); | 
 |  |  |  | 
 |  |  |             if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) { | 
 |  |  |                 //采集时间超过5s,保存一次数据记录 | 
 |  |  | 
 |  |  |                 liftProtocol.setDeviceDataLog(System.currentTimeMillis()); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //将提升机状态保存至数据库 | 
 |  |  |             BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); | 
 |  |  |             BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>() | 
 |  |  |                     .eq("lift_no", device.getDeviceNo())); | 
 |  |  |             if (basLift == null) { | 
 |  |  |                 basLift = new BasLift(); | 
 |  |  |                 //提升机号 | 
 |  |  |                 basLift.setLiftNo(liftProtocol.getLiftNo()); | 
 |  |  |                 basLift.setStatus(1); | 
 |  |  |                 basLiftService.insert(basLift); | 
 |  |  |             } | 
 |  |  |             //任务号 | 
 |  |  |             basLift.setWrkNo(liftProtocol.getTaskNo()); | 
 |  |  |             //修改时间 | 
 |  |  |             basLift.setUpdateTime(new Date()); | 
 |  |  |             //设备状态 | 
 |  |  |             basLift.setDeviceStatus(JSON.toJSONString(liftProtocol)); | 
 |  |  |             if (basLiftService.updateById(basLift)) { | 
 |  |  |                 OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), liftProtocol.getLiftNo())); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), liftProtocol.getLiftNo())); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getDeviceNo(), device.getIp(), device.getPort())); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String getRealtimeOriginData() { | 
 |  |  |         return this.realtimeOriginData; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public LiftCommand getPickAndPutCommand(Integer taskNo, Integer pick, Integer put) { | 
 |  |  |         LiftCommand command = new LiftCommand(); | 
 |  |  |         command.setLiftNo(device.getDeviceNo()); | 
 |  |  | 
 |  |  |          */ | 
 |  |  |         private Boolean overWeight; | 
 |  |  |  | 
 |  |  |         //提升机站点 | 
 |  |  |         private List<LiftStaProtocol> liftStaProtocols; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |         //初始化站点 | 
 |  |  |         for (LiftStation station : stationList) { | 
 |  |  |             ForkLiftStaProtocol forkLiftStaProtocol = new ForkLiftStaProtocol(); | 
 |  |  |             forkLiftStaProtocol.setStaNo(station.getStaNo());//站点号 | 
 |  |  |             forkLiftStaProtocol.setSiteId(station.getSiteId());//站点号 | 
 |  |  |             forkLiftStaProtocol.setLev(station.getLev());//站点楼层 | 
 |  |  |             String locNo = Utils.getLocNo(station.getRow(), station.getBay(), station.getLev()); | 
 |  |  |             forkLiftStaProtocol.setLocNo(locNo);//站点库位号 | 
 
 |  |  | 
 |  |  |   redis: | 
 |  |  |     host: 127.0.0.1 | 
 |  |  |     port: 6379 | 
 |  |  |     database: 0 | 
 |  |  | #    password: 123456 | 
 |  |  |     database: 3 | 
 |  |  |   #    password: 123456 | 
 |  |  |   task: | 
 |  |  |     scheduling: | 
 |  |  |       pool: | 
 |  |  | 
 |  |  | deviceExecuteConfig: | 
 |  |  |   # 每个线程管控设备执行数量 | 
 |  |  |   threadControlCount: 10 | 
 |  |  |   liftType: lift | 
 |  |  |  | 
 |  |  | ## 下位机配置 | 
 |  |  | #wcs-slave: | 
 |  |  | #  # 四向穿梭车1 | 
 |  |  | #  shuttle[0]: | 
 |  |  | #    id: 1 | 
 |  |  | #    ip: 10.10.20.11 | 
 |  |  | #    port: 8888 | 
 |  |  | #    rack: 0 | 
 |  |  | #    slot: 0 | 
 |  |  | #    threadImpl: NyShuttleThread | 
 |  |  | #  # 四向穿梭车2 | 
 |  |  | #  shuttle[1]: | 
 |  |  | #    id: 2 | 
 |  |  | #    ip: 10.10.20.12 | 
 |  |  | #    port: 8888 | 
 |  |  | #    rack: 0 | 
 |  |  | #    slot: 0 | 
 |  |  | #    threadImpl: NyShuttleThread | 
 |  |  | #  # 货叉提升机主线程 | 
 |  |  | #  forkLiftMaster[0]: | 
 |  |  | #    id: 99 | 
 |  |  | #    ip: 10.10.20.20 | 
 |  |  | #    port: 102 | 
 |  |  | #    rack: 0 | 
 |  |  | #    slot: 0 | 
 |  |  | #    threadImpl: LfdZyForkLiftMasterThread | 
 |  |  | #  # 货叉提升机1 | 
 |  |  | #  forkLift[0]: | 
 |  |  | #    id: 1 | 
 |  |  | #    ip: 10.10.20.20 | 
 |  |  | #    port: 102 | 
 |  |  | #    rack: 0 | 
 |  |  | #    slot: 0 | 
 |  |  | #    threadImpl: LfdZyForkLiftSlaveThread | 
 |  |  | #    masterId: 99 | 
 |  |  | #    staRow: 9 | 
 |  |  | #    staBay: 6 | 
 |  |  | #    sta[0]: | 
 |  |  | #      staNo: 1001 | 
 |  |  | #      lev: 1 | 
 |  |  | #      liftNo: ${wcs-slave.forkLift[0].id} | 
 |  |  | #    sta[1]: | 
 |  |  | #      staNo: 1002 | 
 |  |  | #      lev: 2 | 
 |  |  | #      liftNo: ${wcs-slave.forkLift[0].id} | 
 |  |  | #    sta[2]: | 
 |  |  | #      staNo: 1003 | 
 |  |  | #      lev: 3 | 
 |  |  | #      liftNo: ${wcs-slave.forkLift[0].id} | 
 |  |  | #    sta[3]: | 
 |  |  | #      staNo: 1004 | 
 |  |  | #      lev: 4 | 
 |  |  | #      liftNo: ${wcs-slave.forkLift[0].id} | 
 |  |  |   liftType: lift | 
 
 |  |  | 
 |  |  |                                     <td class="py-3 px-4">{{ item.lev }}</td> | 
 |  |  |                                     <td class="py-3 px-4"> | 
 |  |  |                                         <div v-for="(sta,id) in item.liftStaProtocols" :key="id"> | 
 |  |  |                                             {{ sta.lev }}层,托盘:{{ sta.hasTray ? 'Y':'N' }},小车:{{ sta.hasCar ? 'Y':'N' }} | 
 |  |  |                                             {{ sta.siteId }}站,托盘:{{ sta.hasTray ? 'Y':'N' }},小车:{{ sta.hasCar ? 'Y':'N' }} | 
 |  |  |                                         </div> | 
 |  |  |                                     </td> | 
 |  |  |                                 </tr> |