|  |  | 
 |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
 |  |  | import com.baomidou.mybatisplus.mapper.Wrapper; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.SpringUtils; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.entity.*; | 
 |  |  | import com.zy.asrs.mapper.*; | 
 |  |  | 
 |  |  |  */ | 
 |  |  | @Slf4j | 
 |  |  | @Service("mainService") | 
 |  |  | @Transactional | 
 |  |  | public class MainServiceImpl { | 
 |  |  |  | 
 |  |  |     @Value("${wms.url}") | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RedisUtil redisUtil; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkMastLocMapper wrkMastLocMapper; | 
 |  |  |     private WrkMastLogMapper wrkMastLogMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private BasLiftOptService basLiftOptService; | 
 |  |  |     @Autowired | 
 |  |  |     private ConfigService configService; | 
 |  |  |     @Autowired | 
 |  |  |     private NavigateMapUtils navigateMapUtils; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkDetlLogService wrkDetlLogService; | 
 |  |  |     @Autowired | 
 |  |  |     private MatService matService; | 
 |  |  |     @Autowired | 
 |  |  |     private NavigateMapData navigateMapData; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * 入库站,根据条码扫描生成入库工作档,工作状态 2 | 
 |  |  |      */ | 
 |  |  |     public void generateStoreWrkFile() { | 
 |  |  |         // 根据输送线plc遍历 | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 遍历入库口 | 
 |  |  |             for (DevpSlave.Sta inSta : devp.getInSta()) { | 
 |  |  |                 // 获取入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 Short workNo = staProtocol.getWorkNo(); | 
 |  |  |                 // 尺寸检测异常 | 
 |  |  |                 boolean back = false; | 
 |  |  |                 String errMsg = "异常:"; | 
 |  |  |                 if (staProtocol.isFrontErr()) { | 
 |  |  |                     errMsg = errMsg+"前超限;"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isBackErr()) { | 
 |  |  |                     errMsg = errMsg+"后超限"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isHighErr()) { | 
 |  |  |                     errMsg = errMsg+"高超限"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isLeftErr()) { | 
 |  |  |                     errMsg = errMsg+"左超限"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isRightErr()) { | 
 |  |  |                     errMsg = errMsg+"右超限"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isWeightErr()) { | 
 |  |  |                     errMsg = errMsg+"超重"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isBarcodeErr()) { | 
 |  |  |                     errMsg = errMsg+"扫码失败"; | 
 |  |  |                     back = true; | 
 |  |  |                 } | 
 |  |  |                 // 退回 | 
 |  |  |                 if (back) { | 
 |  |  |                     // led 异常显示 | 
 |  |  |                     LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                     if (ledThread != null) { | 
 |  |  |                         MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
 |  |  |         try { | 
 |  |  |             // 根据输送线plc遍历 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 遍历入库口 | 
 |  |  |                 for (DevpSlave.Sta inSta : devp.getInSta()) { | 
 |  |  |                     // 获取入库站信息 | 
 |  |  |                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 // 判断是否满足入库条件 | 
 |  |  |                 if (staProtocol.isAutoing() && staProtocol.isLoading() | 
 |  |  |                         && staProtocol.isInEnable() | 
 |  |  |                         && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) | 
 |  |  |                         ) { | 
 |  |  |  | 
 |  |  |                     // 获取条码扫描仪信息 | 
 |  |  |                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
 |  |  |                     if (barcodeThread == null) { | 
 |  |  |                     Short workNo = staProtocol.getWorkNo(); | 
 |  |  |                     // 尺寸检测异常 | 
 |  |  |                     boolean back = false; | 
 |  |  |                     String errMsg = "异常:"; | 
 |  |  |                     if (staProtocol.isFrontErr()) { | 
 |  |  |                         errMsg = errMsg + "前超限;"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isBackErr()) { | 
 |  |  |                         errMsg = errMsg + "后超限"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isHighErr()) { | 
 |  |  |                         errMsg = errMsg + "高超限"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isLeftErr()) { | 
 |  |  |                         errMsg = errMsg + "左超限"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isRightErr()) { | 
 |  |  |                         errMsg = errMsg + "右超限"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isWeightErr()) { | 
 |  |  |                         errMsg = errMsg + "超重"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isBarcodeErr()) { | 
 |  |  |                         errMsg = errMsg + "扫码失败"; | 
 |  |  |                         back = true; | 
 |  |  |                     } | 
 |  |  |                     // 退回 | 
 |  |  |                     if (back) { | 
 |  |  |                         // led 异常显示 | 
 |  |  |                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                         if (ledThread != null) { | 
 |  |  |                             MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
 |  |  |                         } | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     String barcode = barcodeThread.getBarcode(); | 
 |  |  |                     if(!Cools.isEmpty(barcode)) { | 
 |  |  |  | 
 |  |  |                     // 判断是否满足入库条件 | 
 |  |  |                     if (staProtocol.isAutoing() && staProtocol.isLoading() | 
 |  |  |                             && staProtocol.isInEnable() | 
 |  |  |                             && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) | 
 |  |  |                     ) { | 
 |  |  |  | 
 |  |  |                         // 获取条码扫描仪信息 | 
 |  |  |                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
 |  |  |                         if (barcodeThread == null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         String barcode = barcodeThread.getBarcode(); | 
 |  |  |                         if (!Cools.isEmpty(barcode)) { | 
 |  |  | //                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
 |  |  |                         if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)|| "00000000".equals(barcode)) { | 
 |  |  |                             if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode) || "00000000".equals(barcode)) { | 
 |  |  | //                            staProtocol.setWorkNo((short) 32002); | 
 |  |  | //                            staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
 |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |  | 
 |  |  |                             // led 异常显示 | 
 |  |  |                             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                             if (ledThread != null) { | 
 |  |  |                                 String errorMsg = "扫码失败,请重试"; | 
 |  |  |                                 MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                 // led 异常显示 | 
 |  |  |                                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                                 if (ledThread != null) { | 
 |  |  |                                     String errorMsg = "扫码失败,请重试"; | 
 |  |  |                                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                 } | 
 |  |  |                                 continue; | 
 |  |  |                             } | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                     } else { | 
 |  |  |                         } else { | 
 |  |  | //                        staProtocol.setWorkNo((short) 32002); | 
 |  |  | //                        staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
 |  |  | //                        devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |  | 
 |  |  |                         // led 异常显示 | 
 |  |  |                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                         if (ledThread != null) { | 
 |  |  |                             String errorMsg = "扫码失败,请重试"; | 
 |  |  |                             MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                        // led 异常显示 | 
 |  |  | //                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  | //                        if (ledThread != null) { | 
 |  |  | //                            String errorMsg = "扫码失败,请重试"; | 
 |  |  | //                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                        } | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     // 过滤盘点/拣料/并板任务 | 
 |  |  |                     WrkMast wrkMast1 = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  |                     if (null != wrkMast1) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                         // 过滤盘点/拣料/并板任务 | 
 |  |  |                         WrkMast wrkMast1 = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  |                         if (null != wrkMast1) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     // 判断重复工作档 | 
 |  |  |                     WrkMast wrkMast2 = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
 |  |  |                     if (wrkMast2 != null) { | 
 |  |  |                         News.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast2.getWrkNo()); | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                         // 判断重复工作档 | 
 |  |  |                         WrkMast wrkMast2 = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
 |  |  |                         if (wrkMast2 != null) { | 
 |  |  |                             News.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast2.getWrkNo()); | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     try { | 
 |  |  |                         LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  |                         SearchLocParam param = new SearchLocParam(); | 
 |  |  |                         param.setBarcode(barcode); | 
 |  |  |                         param.setIoType(1); | 
 |  |  |                         param.setSourceStaNo(inSta.getStaNo()); | 
 |  |  |                         param.setLocType1(locTypeDto.getLocType1()); | 
 |  |  |                         String response = new HttpHandler.Builder() | 
 |  |  |                                 .setUri(wmsUrl) | 
 |  |  |                                 .setPath("/rpc/pakin/loc/v1") | 
 |  |  |                                 .setJson(JSON.toJSONString(param)) | 
 |  |  |                                 .build() | 
 |  |  |                                 .doPost(); | 
 |  |  |                         JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                         Integer code = jsonObject.getInteger("code"); | 
 |  |  |                         if (code.equals(200)) { | 
 |  |  |                             StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |                             // plc 处理 | 
 |  |  |                             barcodeThread.setBarcode(""); | 
 |  |  |                         try { | 
 |  |  |                             LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  |                             SearchLocParam param = new SearchLocParam(); | 
 |  |  |                             param.setBarcode(barcode); | 
 |  |  |                             param.setIoType(1); | 
 |  |  |                             param.setSourceStaNo(inSta.getStaNo()); | 
 |  |  |                             param.setLocType1(locTypeDto.getLocType1()); | 
 |  |  |                             String response = new HttpHandler.Builder() | 
 |  |  |                                     .setUri(wmsUrl) | 
 |  |  |                                     .setPath("/rpc/pakin/loc/v2") | 
 |  |  |                                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                                     .build() | 
 |  |  |                                     .doPost(); | 
 |  |  |                             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                             Integer code = jsonObject.getInteger("code"); | 
 |  |  |                             if (code.equals(200)) { | 
 |  |  |                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |                                 // plc 处理 | 
 |  |  |                                 barcodeThread.setBarcode(""); | 
 |  |  | //                            staProtocol.setWorkNo(dto.getWorkNo().shortValue()); | 
 |  |  | //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
 |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | 
 |  |  | //                                throw new CoolException("更新plc站点信息失败"); | 
 |  |  | //                            } | 
 |  |  |  | 
 |  |  |                             // 判断重复工作档 | 
 |  |  |                             WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); | 
 |  |  |                             if (wrkMast == null) { continue; } | 
 |  |  |  | 
 |  |  |                             // 更新工作主档 | 
 |  |  |                             wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 | 
 |  |  |                             wrkMast.setModiTime(new Date()); | 
 |  |  |                             if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  |                                 News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo()); | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  |                         } else if (code == 500){ | 
 |  |  |                             if (ledThread != null) { | 
 |  |  |                                 String errorMsg = jsonObject.getString("msg"); | 
 |  |  |                                 if (!Cools.isEmpty(errorMsg)) { | 
 |  |  |                                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                     ledThread.setLedMk(false); | 
 |  |  |                                 // 判断重复工作档 | 
 |  |  |                                 WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); | 
 |  |  |                                 if (wrkMast == null) { | 
 |  |  |                                     continue; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                             News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
 |  |  |                         } else if (code == 700) { | 
 |  |  |  | 
 |  |  |                                 // 更新工作主档 | 
 |  |  |                                 wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 | 
 |  |  |                                 wrkMast.setModiTime(new Date()); | 
 |  |  |                                 if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  |                                     News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo()); | 
 |  |  |                                 } | 
 |  |  |  | 
 |  |  |                             } else if (code == 500) { | 
 |  |  |                                 if (ledThread != null) { | 
 |  |  |                                     String errorMsg = jsonObject.getString("msg"); | 
 |  |  |                                     if (!Cools.isEmpty(errorMsg)) { | 
 |  |  |                                         MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                         ledThread.setLedMk(false); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
 |  |  |                             } else if (code == 700) { | 
 |  |  | //                            staProtocol.setWorkNo((short) 32002); | 
 |  |  | //                            staProtocol.setRollback102(1);//102站回退信号 | 
 |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol)); | 
 |  |  |  | 
 |  |  |                             // led 异常显示 | 
 |  |  |                             if (ledThread != null) { | 
 |  |  |                                 String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
 |  |  |                                 MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                 ledThread.setLedMk(false); | 
 |  |  |                                 // led 异常显示 | 
 |  |  |                                 if (ledThread != null) { | 
 |  |  |                                     String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
 |  |  |                                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                     ledThread.setLedMk(false); | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                         } | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         e.printStackTrace(); | 
 |  |  |                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 拣料、并板、盘点再入库 | 
 |  |  |      * 拣料、并板再入库 | 
 |  |  |      */ | 
 |  |  |     @Transactional | 
 |  |  |     public synchronized void stnToCrnStnPick(){ | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 遍历拣料入库口 | 
 |  |  |             for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
 |  |  |  | 
 |  |  |                 // 获取拣料入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isAutoing() | 
 |  |  |                         && staProtocol.isLoading() | 
 |  |  | //                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999) | 
 |  |  | //                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) | 
 |  |  |                         && staProtocol.isPakMk()){ | 
 |  |  |  | 
 |  |  |                     // 获取条码扫描仪信息 | 
 |  |  |                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
 |  |  |                     if (barcodeThread == null) { | 
 |  |  |         try { | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 遍历拣料入库口 | 
 |  |  |                 for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
 |  |  |                     // 获取拣料入库站信息 | 
 |  |  |                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     String barcode = barcodeThread.getBarcode(); | 
 |  |  |                     if (staProtocol.isAutoing() | 
 |  |  |                             && staProtocol.isLoading() | 
 |  |  |                             && staProtocol.isInEnable() | 
 |  |  | //                        && (staProtocol.getWorkNo() > 0) | 
 |  |  |                             && staProtocol.isPakMk()) { | 
 |  |  |  | 
 |  |  |                     WrkMast wrkMast = null; | 
 |  |  |                     wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  | //                    if (staProtocol.getWorkNo() == 9996) { | 
 |  |  | //                        String barcode = barcodeThread.getBarcode(); | 
 |  |  | //                        if(!Cools.isEmpty(barcode)) { | 
 |  |  | //                            News.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); | 
 |  |  | //                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
 |  |  | //                                staProtocol.setWorkNo((short) 32002); | 
 |  |  | //                                staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
 |  |  | //                                devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | // | 
 |  |  | //                                // led 异常显示 | 
 |  |  | //                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | //                                if (ledThread != null) { | 
 |  |  | //                                    String errorMsg = "扫码失败,请重试"; | 
 |  |  | //                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                                } | 
 |  |  |                         // 获取条码扫描仪信息 | 
 |  |  |                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
 |  |  |                         if (barcodeThread == null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         String barcode = barcodeThread.getBarcode(); | 
 |  |  |                         if (Cools.isEmpty(barcode)) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         WrkMast wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  |                         if (wrkMast == null) {//找不到工作档 | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) | 
 |  |  |                                 || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  | //                        //*********************同库位组校验********************* | 
 |  |  | //                        boolean flag = false; | 
 |  |  | //                        String th = ""; | 
 |  |  | //                        List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); | 
 |  |  | //                        for (String loc : innerLoc) { | 
 |  |  | //                            LocMast locMast = locMastService.selectById(loc); | 
 |  |  | //                            if (locMast == null) { | 
 |  |  | //                                continue; | 
 |  |  | //                            } | 
 |  |  | //                        } else { | 
 |  |  | //                            staProtocol.setWorkNo((short) 32002); | 
 |  |  | //                            staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
 |  |  | //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | // | 
 |  |  | //                            // led 异常显示 | 
 |  |  | //                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | //                            if (ledThread != null) { | 
 |  |  | //                                String errorMsg = "扫码失败,请重试"; | 
 |  |  | //                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                            if (!locMast.getLocSts().equals("F")) { | 
 |  |  | //                                flag = true; | 
 |  |  | //                                th = loc + "库位存在未回库任务"; | 
 |  |  | //                                break; | 
 |  |  | //                            } | 
 |  |  | //                        } | 
 |  |  | //                        if (flag) { | 
 |  |  | //                            News.info(th); | 
 |  |  | //                            continue; | 
 |  |  | //                        } | 
 |  |  | //                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  | //                        if (null == wrkMast) { | 
 |  |  | //                            News.error("{}条码错误,暂无拣料任务!", barcode); | 
 |  |  | //                        //*********************同库位组校验********************* | 
 |  |  |  | 
 |  |  | //                        // 保存工作主档历史档 | 
 |  |  | //                        if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                            News.info(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  | //                            continue; | 
 |  |  | //                        } | 
 |  |  | //                    } | 
 |  |  |  | 
 |  |  |                     if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) | 
 |  |  |                         || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                         try { | 
 |  |  |                             LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//源库位 | 
 |  |  |                             SearchLocParam param = new SearchLocParam(); | 
 |  |  |                             param.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  |                             param.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                             param.setIoType(wrkMast.getIoType()); | 
 |  |  |                             param.setSourceStaNo(pickSta.getStaNo()); | 
 |  |  |                             param.setLiftNo(pickSta.getLiftNo()); | 
 |  |  |                             param.setLocType1(locMast.getLocType1()); | 
 |  |  |                             String response = new HttpHandler.Builder() | 
 |  |  |                                     .setUri(wmsUrl) | 
 |  |  |                                     .setPath("/rpc/pakin/loc/v2") | 
 |  |  |                                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                                     .build() | 
 |  |  |                                     .doPost(); | 
 |  |  |                             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                             Integer code = jsonObject.getInteger("code"); | 
 |  |  |                             if (code.equals(200)) { | 
 |  |  |                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |  | 
 |  |  |                     // 保存工作主档历史档 | 
 |  |  |                     if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  |                         throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
 |  |  |                     LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
 |  |  |                     if (liftStaProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     // 更新工作档数据状态 | 
 |  |  |                     wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
 |  |  |                     wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  |                     wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
 |  |  | //                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
 |  |  | //                            wrkMast.setCrnNo(dto.getCrnNo()); | 
 |  |  |                     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() + "更新工作档数据状态失败"); | 
 |  |  |                     } | 
 |  |  |                     if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
 |  |  |                         throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     // 修改库位状态 Q.拣料/盘点/并板再入库 | 
 |  |  |                     LocMast locMast = locMastService.selectById(sourceLocNo); | 
 |  |  |                     locMast.setLocSts("Q"); | 
 |  |  |                     locMast.setModiTime(new Date()); | 
 |  |  |                     if (!locMastService.updateById(locMast)) { | 
 |  |  |                         throw new CoolException("修改库位状态失败"); | 
 |  |  |                     } | 
 |  |  |                     barcodeThread.setBarcode("");//清理条码 | 
 |  |  |  | 
 |  |  | //                    try { | 
 |  |  | //                        // 访问 WMS 获取入库库位 | 
 |  |  | //                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  | //                        SearchLocParam param = new SearchLocParam(); | 
 |  |  | //                        param.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  | //                        param.setIoType(wrkMast.getIoType()); | 
 |  |  | //                        param.setSourceStaNo(pickSta.getStaNo()); | 
 |  |  | ////                        param.setLocType1(locTypeDto.getLocType1()); | 
 |  |  | //                        String response = new HttpHandler.Builder() | 
 |  |  | //                                .setUri(wmsUrl) | 
 |  |  | //                                .setPath("/rpc/pakin/loc/v1") | 
 |  |  | //                                .setJson(JSON.toJSONString(param)) | 
 |  |  | //                                .build() | 
 |  |  | //                                .doPost(); | 
 |  |  | //                        JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  | //                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | //                        Integer code = jsonObject.getInteger("code"); | 
 |  |  | //                        if (code.equals(200)) { | 
 |  |  | //                            StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  | //                                //获取回库提升机目标站 | 
 |  |  | //                                LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); | 
 |  |  | //                                if (liftStaProtocol == null) { | 
 |  |  | //                                    News.info(wrkMast.getWrkNo() + "获取回库提升机目标站失败"); | 
 |  |  | //                                    continue; | 
 |  |  | //                                } | 
 |  |  | // | 
 |  |  | ////                            // 获取目标站 | 
 |  |  | ////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
 |  |  | ////                                    .eq("type_no", wrkMast.getIoType() - 50) | 
 |  |  | ////                                    .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 | 
 |  |  | ////                                    .eq("crn_no", dto.getCrnNo()); // 堆垛机号 | 
 |  |  | ////                            StaDesc staDesc = staDescService.selectOne(wrapper); | 
 |  |  | ////                            if (Cools.isEmpty(staDesc)) { | 
 |  |  | ////                                News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); | 
 |  |  | //                                // 更新工作档数据状态 | 
 |  |  | //                                wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54 | 
 |  |  | //                                wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  | //                                wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 源站 | 
 |  |  | //                                wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
 |  |  | //                                wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
 |  |  | //                                wrkMast.setShuttleNo(null); // 穿梭车清空 | 
 |  |  | //                                wrkMast.setLiftNo(null);// 提升机清空 | 
 |  |  | //                                wrkMast.setModiTime(new Date()); | 
 |  |  | //                                if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  | //                                    News.info(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  | //                                    continue; | 
 |  |  | //                                } | 
 |  |  |                             } else if (code == 500) { | 
 |  |  |                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
 |  |  |                             } | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 拣料、并板再入库(325、331、333、339) | 
 |  |  |      */ | 
 |  |  |     @Transactional | 
 |  |  |     public synchronized void stnToCrnStnPick2(){ | 
 |  |  |         try { | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 遍历拣料入库口 | 
 |  |  |                 for (DevpSlave.Sta pickSta : devp.getPickInSta2()) { | 
 |  |  |                     // 获取拣料入库站信息 | 
 |  |  |                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isAutoing() | 
 |  |  |                             && staProtocol.isLoading() | 
 |  |  |                             && staProtocol.isInEnable() | 
 |  |  |                             && (staProtocol.getWorkNo() > 0) | 
 |  |  |                             && staProtocol.isPakMk()) { | 
 |  |  |  | 
 |  |  |                         WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                         if (wrkMast == null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         if (wrkMast.getSteNo() == null) { | 
 |  |  |                             wrkMast.setSteNo(1); | 
 |  |  |                             wrkMastMapper.updateById(wrkMast); | 
 |  |  |                             staProtocol.setStaNo((short) 341);//写入目标站 | 
 |  |  |                             staProtocol.setPakMk(false); | 
 |  |  |                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 盘点再入库 | 
 |  |  |      */ | 
 |  |  |     @Transactional | 
 |  |  |     public synchronized void stnToCrnStnPlate(){ | 
 |  |  |         try { | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 遍历拣料入库口 | 
 |  |  |                 for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
 |  |  |                     // 获取拣料入库站信息 | 
 |  |  |                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isAutoing() | 
 |  |  |                             && staProtocol.isLoading() | 
 |  |  |                             && staProtocol.isInEnable() | 
 |  |  | //                            && (staProtocol.getWorkNo() > 0) | 
 |  |  |                             && staProtocol.isPakMk()) { | 
 |  |  |  | 
 |  |  |                         // 获取条码扫描仪信息 | 
 |  |  |                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
 |  |  |                         if (barcodeThread == null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         String barcode = barcodeThread.getBarcode(); | 
 |  |  |                         if (Cools.isEmpty(barcode)) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode); | 
 |  |  |                         if (wrkMast == null) {//找不到工作档 | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         if ((wrkMast.getIoType() != 107) | 
 |  |  |                                 || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  | //                        // 保存工作主档历史档 | 
 |  |  | //                        if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                            News.info(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  | //                            continue; | 
 |  |  | //                        } | 
 |  |  |  | 
 |  |  |                         //盘点找新库位 | 
 |  |  |                         try { | 
 |  |  |                             LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//源库位 | 
 |  |  |                             SearchLocParam param = new SearchLocParam(); | 
 |  |  |                             param.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  |                             param.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                             param.setIoType(107);//盘点 | 
 |  |  |                             param.setSourceStaNo(pickSta.getStaNo()); | 
 |  |  |                             param.setLiftNo(pickSta.getLiftNo()); | 
 |  |  |                             param.setLocType1(locMast.getLocType1()); | 
 |  |  |                             String response = new HttpHandler.Builder() | 
 |  |  |                                     .setUri(wmsUrl) | 
 |  |  |                                     .setPath("/rpc/pakin/loc/v2") | 
 |  |  |                                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                                     .build() | 
 |  |  |                                     .doPost(); | 
 |  |  |                             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                             Integer code = jsonObject.getInteger("code"); | 
 |  |  |                             if (code.equals(200)) { | 
 |  |  |                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |  | 
 |  |  | //                                //获取回库提升机目标站 | 
 |  |  | //                                LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); | 
 |  |  | //                                if (liftStaProtocol == null) { | 
 |  |  | //                                    News.info(wrkMast.getWrkNo() + "获取回库提升机目标站失败"); | 
 |  |  | //                                    continue; | 
 |  |  | //                                } | 
 |  |  | // | 
 |  |  | //                                // 更新工作档数据状态 | 
 |  |  | //                                wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 107->57 | 
 |  |  | //                                wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  | //                                wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 源站 | 
 |  |  | //                                wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
 |  |  | //                                wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
 |  |  | //                                wrkMast.setShuttleNo(null); // 穿梭车清空 | 
 |  |  | //                                wrkMast.setLiftNo(null);// 提升机清空 | 
 |  |  | //                                wrkMast.setModiTime(new Date()); | 
 |  |  | //                                if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  | //                                    News.info(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  | //                                    continue; | 
 |  |  | //                                } | 
 |  |  |  | 
 |  |  | //                                staProtocol.setStaNo(dto.getSourceStaNo().shortValue());//写入目标站 | 
 |  |  | //                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |  | 
 |  |  |                             } else if (code == 500) { | 
 |  |  |                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
 |  |  |                             } | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | //    /** | 
 |  |  | //     * 拣料、并板、盘点再入库 | 
 |  |  | //     */ | 
 |  |  | //    @Transactional | 
 |  |  | //    public synchronized void stnToCrnStnPick(){ | 
 |  |  | //        for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  | //            // 遍历拣料入库口 | 
 |  |  | //            for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
 |  |  | // | 
 |  |  | //                // 获取拣料入库站信息 | 
 |  |  | //                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  | //                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
 |  |  | //                if (staProtocol == null) { | 
 |  |  | //                    continue; | 
 |  |  | //                } else { | 
 |  |  | //                    staProtocol = staProtocol.clone(); | 
 |  |  | //                } | 
 |  |  | //                if (staProtocol.isAutoing() | 
 |  |  | //                        && staProtocol.isLoading() | 
 |  |  | ////                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999) | 
 |  |  | ////                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) | 
 |  |  | //                        && staProtocol.isPakMk()){ | 
 |  |  | // | 
 |  |  | //                    // 获取条码扫描仪信息 | 
 |  |  | //                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
 |  |  | //                    if (barcodeThread == null) { | 
 |  |  | //                        continue; | 
 |  |  | //                    } | 
 |  |  | //                    String barcode = barcodeThread.getBarcode(); | 
 |  |  | // | 
 |  |  | //                    WrkMast wrkMast = null; | 
 |  |  | //                    wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  | //                    if (wrkMast == null) { | 
 |  |  | //                        continue; | 
 |  |  | //                    } | 
 |  |  | ////                    if (staProtocol.getWorkNo() == 9996) { | 
 |  |  | ////                        String barcode = barcodeThread.getBarcode(); | 
 |  |  | ////                        if(!Cools.isEmpty(barcode)) { | 
 |  |  | ////                            News.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); | 
 |  |  | ////                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
 |  |  | ////                                staProtocol.setWorkNo((short) 32002); | 
 |  |  | ////                                staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
 |  |  | ////                                devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | ////                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | //// | 
 |  |  | ////                                // led 异常显示 | 
 |  |  | ////                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | ////                                if (ledThread != null) { | 
 |  |  | ////                                    String errorMsg = "扫码失败,请重试"; | 
 |  |  | ////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | ////                                } | 
 |  |  | ////                                continue; | 
 |  |  | ////                            } | 
 |  |  | ////                            // 堆垛机站点(目标站) | 
 |  |  | ////                            Integer staNo = staDesc.getCrnStn(); | 
 |  |  | // | 
 |  |  | //                            // 保存工作明细档历史档 | 
 |  |  | ////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | ////                            throw new CoolException("保存工作明细档历史档失败"); | 
 |  |  | ////                        } | 
 |  |  | //                            // 保存工作主档历史档 | 
 |  |  | //                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                                throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  | //                            } | 
 |  |  | // | 
 |  |  | //                            String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
 |  |  | //                            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
 |  |  | //                            if (liftStaProtocol == null) { | 
 |  |  | //                                continue; | 
 |  |  | //                            } | 
 |  |  | // | 
 |  |  | //                            // 更新工作档数据状态 | 
 |  |  | //                            wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
 |  |  | //                            wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  | //                            wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
 |  |  | ////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
 |  |  | ////                            wrkMast.setCrnNo(dto.getCrnNo()); | 
 |  |  | //                            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() + "更新工作档数据状态失败"); | 
 |  |  | //                            } | 
 |  |  | //                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  | //                            } | 
 |  |  | // | 
 |  |  | //                            // 修改库位状态 Q.拣料/盘点/并板再入库 | 
 |  |  | //                            LocMast locMast = locMastService.selectById(sourceLocNo); | 
 |  |  | //                            locMast.setLocSts("Q"); | 
 |  |  | //                            locMast.setModiTime(new Date()); | 
 |  |  | //                            if (!locMastService.updateById(locMast)) { | 
 |  |  | //                                throw new CoolException("修改库位状态失败"); | 
 |  |  | //                            } | 
 |  |  | // | 
 |  |  | ////                            // 更新站点信息 且 下发plc命令 | 
 |  |  | ////                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); | 
 |  |  | ////                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); | 
 |  |  | ////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | ////                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | ////                            if (!result) { | 
 |  |  | ////                                News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); | 
 |  |  | ////                            } | 
 |  |  | // | 
 |  |  | //                            barcodeThread.setBarcode("");//清理条码 | 
 |  |  | // | 
 |  |  | //                        } else if (code == 500){ | 
 |  |  | //                            if (ledThread != null) { | 
 |  |  | //                                String errorMsg = jsonObject.getString("msg"); | 
 |  |  | //                                if (!Cools.isEmpty(errorMsg)) { | 
 |  |  | //                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                                } | 
 |  |  | //                            } | 
 |  |  | //                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
 |  |  | //                        } else { | 
 |  |  | ////                        } else { | 
 |  |  | ////                            staProtocol.setWorkNo((short) 32002); | 
 |  |  | ////                            staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
 |  |  | ////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | ////                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | //// | 
 |  |  | ////                            // led 异常显示 | 
 |  |  | ////                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | ////                            if (ledThread != null) { | 
 |  |  | ////                                String errorMsg = "扫码失败,请重试"; | 
 |  |  | ////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | ////                            } | 
 |  |  | ////                            continue; | 
 |  |  | ////                        } | 
 |  |  | ////                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
 |  |  | ////                        if (null == wrkMast) { | 
 |  |  | ////                            News.error("{}条码错误,暂无拣料任务!", barcode); | 
 |  |  | ////                        } | 
 |  |  | ////                    } | 
 |  |  | // | 
 |  |  | //                            // led 异常显示 | 
 |  |  | //                            if (ledThread != null) { | 
 |  |  | //                                String errorMsg = jsonObject.getString("msg"); | 
 |  |  | ////                                String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
 |  |  | //                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | //                            } | 
 |  |  | //                        } | 
 |  |  | // | 
 |  |  | //                    } catch (Exception e) { | 
 |  |  | //                        e.printStackTrace(); | 
 |  |  | //                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  | //                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) | 
 |  |  | //                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { | 
 |  |  | //                        continue; | 
 |  |  | //                    } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | // | 
 |  |  | //                    // 保存工作主档历史档 | 
 |  |  | //                    if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                        throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  | //                    } | 
 |  |  | // | 
 |  |  | //                    String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
 |  |  | //                    LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
 |  |  | //                    if (liftStaProtocol == null) { | 
 |  |  | //                        continue; | 
 |  |  | //                    } | 
 |  |  | // | 
 |  |  | //                    // 更新工作档数据状态 | 
 |  |  | //                    wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
 |  |  | //                    wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  | //                    wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
 |  |  | ////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
 |  |  | ////                            wrkMast.setCrnNo(dto.getCrnNo()); | 
 |  |  | //                    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() + "更新工作档数据状态失败"); | 
 |  |  | //                    } | 
 |  |  | //                    if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //                        throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  | //                    } | 
 |  |  | // | 
 |  |  | //                    // 修改库位状态 Q.拣料/盘点/并板再入库 | 
 |  |  | //                    LocMast locMast = locMastService.selectById(sourceLocNo); | 
 |  |  | //                    locMast.setLocSts("Q"); | 
 |  |  | //                    locMast.setModiTime(new Date()); | 
 |  |  | //                    if (!locMastService.updateById(locMast)) { | 
 |  |  | //                        throw new CoolException("修改库位状态失败"); | 
 |  |  | //                    } | 
 |  |  | //                    barcodeThread.setBarcode("");//清理条码 | 
 |  |  | // | 
 |  |  | ////                    try { | 
 |  |  | ////                        // 访问 WMS 获取入库库位 | 
 |  |  | ////                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  | ////                        SearchLocParam param = new SearchLocParam(); | 
 |  |  | ////                        param.setWrkNo(wrkMast.getWrkNo()); | 
 |  |  | ////                        param.setIoType(wrkMast.getIoType()); | 
 |  |  | ////                        param.setSourceStaNo(pickSta.getStaNo()); | 
 |  |  | //////                        param.setLocType1(locTypeDto.getLocType1()); | 
 |  |  | ////                        String response = new HttpHandler.Builder() | 
 |  |  | ////                                .setUri(wmsUrl) | 
 |  |  | ////                                .setPath("/rpc/pakin/loc/v1") | 
 |  |  | ////                                .setJson(JSON.toJSONString(param)) | 
 |  |  | ////                                .build() | 
 |  |  | ////                                .doPost(); | 
 |  |  | ////                        JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  | ////                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
 |  |  | ////                        Integer code = jsonObject.getInteger("code"); | 
 |  |  | ////                        if (code.equals(200)) { | 
 |  |  | ////                            StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  | //// | 
 |  |  | //////                            // 获取目标站 | 
 |  |  | //////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
 |  |  | //////                                    .eq("type_no", wrkMast.getIoType() - 50) | 
 |  |  | //////                                    .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 | 
 |  |  | //////                                    .eq("crn_no", dto.getCrnNo()); // 堆垛机号 | 
 |  |  | //////                            StaDesc staDesc = staDescService.selectOne(wrapper); | 
 |  |  | //////                            if (Cools.isEmpty(staDesc)) { | 
 |  |  | //////                                News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); | 
 |  |  | //////                                continue; | 
 |  |  | //////                            } | 
 |  |  | //////                            // 堆垛机站点(目标站) | 
 |  |  | //////                            Integer staNo = staDesc.getCrnStn(); | 
 |  |  | //// | 
 |  |  | ////                            // 保存工作明细档历史档 | 
 |  |  | //////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | //////                            throw new CoolException("保存工作明细档历史档失败"); | 
 |  |  | //////                        } | 
 |  |  | ////                            // 保存工作主档历史档 | 
 |  |  | ////                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
 |  |  | ////                                throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
 |  |  | ////                            } | 
 |  |  | //// | 
 |  |  | ////                            String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
 |  |  | ////                            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
 |  |  | ////                            if (liftStaProtocol == null) { | 
 |  |  | ////                                continue; | 
 |  |  | ////                            } | 
 |  |  | //// | 
 |  |  | ////                            // 更新工作档数据状态 | 
 |  |  | ////                            wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
 |  |  | ////                            wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
 |  |  | ////                            wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
 |  |  | //////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
 |  |  | //////                            wrkMast.setCrnNo(dto.getCrnNo()); | 
 |  |  | ////                            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() + "更新工作档数据状态失败"); | 
 |  |  | ////                            } | 
 |  |  | ////                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
 |  |  | ////                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
 |  |  | ////                            } | 
 |  |  | //// | 
 |  |  | ////                            // 修改库位状态 Q.拣料/盘点/并板再入库 | 
 |  |  | ////                            LocMast locMast = locMastService.selectById(sourceLocNo); | 
 |  |  | ////                            locMast.setLocSts("Q"); | 
 |  |  | ////                            locMast.setModiTime(new Date()); | 
 |  |  | ////                            if (!locMastService.updateById(locMast)) { | 
 |  |  | ////                                throw new CoolException("修改库位状态失败"); | 
 |  |  | ////                            } | 
 |  |  | //// | 
 |  |  | //////                            // 更新站点信息 且 下发plc命令 | 
 |  |  | //////                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); | 
 |  |  | //////                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); | 
 |  |  | //////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //////                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | //////                            if (!result) { | 
 |  |  | //////                                News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); | 
 |  |  | //////                            } | 
 |  |  | //// | 
 |  |  | ////                            barcodeThread.setBarcode("");//清理条码 | 
 |  |  | //// | 
 |  |  | ////                        } else if (code == 500){ | 
 |  |  | ////                            if (ledThread != null) { | 
 |  |  | ////                                String errorMsg = jsonObject.getString("msg"); | 
 |  |  | ////                                if (!Cools.isEmpty(errorMsg)) { | 
 |  |  | ////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | ////                                } | 
 |  |  | ////                            } | 
 |  |  | ////                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
 |  |  | ////                        } else { | 
 |  |  | //////                            staProtocol.setWorkNo((short) 32002); | 
 |  |  | //////                            staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
 |  |  | //////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  | //////                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  | //// | 
 |  |  | ////                            // led 异常显示 | 
 |  |  | ////                            if (ledThread != null) { | 
 |  |  | ////                                String errorMsg = jsonObject.getString("msg"); | 
 |  |  | //////                                String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
 |  |  | ////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
 |  |  | ////                            } | 
 |  |  | ////                        } | 
 |  |  | //// | 
 |  |  | ////                    } catch (Exception e) { | 
 |  |  | ////                        e.printStackTrace(); | 
 |  |  | ////                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  | ////                    } | 
 |  |  | // | 
 |  |  | //                } | 
 |  |  | //            } | 
 |  |  | // | 
 |  |  | //        } | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 初始化实时地图 | 
 |  |  |      */ | 
 |  |  |     public synchronized void initRealtimeBasMap() { | 
 |  |  |         for (int i = 1; i <= 10; i++) {//总共四层楼 | 
 |  |  |             Object data = redisUtil.get(RedisKeyType.MAP.key + i); | 
 |  |  |             if (data == null) {//redis地图数据为空,从数据库中获取 | 
 |  |  |                 BasMap basMap = basMapService.selectLatestMap(i); | 
 |  |  |                 if (basMap == null) { | 
 |  |  |                     //数据库中也不存在地图数据,从地图文件中获取 | 
 |  |  |                     //载入地图 | 
 |  |  |                     NavigateMapData mapData = new NavigateMapData(i); | 
 |  |  |                     List<List<MapNode>> lists = mapData.getJsonData(-1, null, null);//获取完整地图(包括入库出库) | 
 |  |  |         try { | 
 |  |  |             for (int i = 1; i <= 10; i++) {//总共四层楼 | 
 |  |  |                 Object data = redisUtil.get(RedisKeyType.MAP.key + i); | 
 |  |  |                 if (data == null) {//redis地图数据为空,从数据库中获取 | 
 |  |  |                     BasMap basMap = basMapService.selectLatestMap(i); | 
 |  |  |                     if (basMap == null) { | 
 |  |  |                         //数据库中也不存在地图数据,从地图文件中获取 | 
 |  |  |                         //载入地图 | 
 |  |  |                         navigateMapData.setLev(i); | 
 |  |  |                         List<List<MapNode>> lists = navigateMapData.getJsonData(-1, null, null);//获取完整地图(包括入库出库) | 
 |  |  |  | 
 |  |  |                     //存入数据库 | 
 |  |  |                     basMap = new BasMap(); | 
 |  |  |                     basMap.setData(JSON.toJSONString(lists)); | 
 |  |  |                     basMap.setCreateTime(new Date()); | 
 |  |  |                     basMap.setUpdateTime(new Date()); | 
 |  |  |                     basMap.setLev(i); | 
 |  |  |                         //存入数据库 | 
 |  |  |                         basMap = new BasMap(); | 
 |  |  |                         basMap.setData(JSON.toJSONString(lists)); | 
 |  |  |                         basMap.setCreateTime(new Date()); | 
 |  |  |                         basMap.setUpdateTime(new Date()); | 
 |  |  |                         basMap.setLev(i); | 
 |  |  |  | 
 |  |  |                     if (!basMapService.insert(basMap)) { | 
 |  |  |                         log.info("地图数据存储失败"); | 
 |  |  |                         if (!basMapService.insert(basMap)) { | 
 |  |  |                             log.info("地图数据存储失败"); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //将数据库地图数据存入redis | 
 |  |  |                 redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); | 
 |  |  |                     //将数据库地图数据存入redis | 
 |  |  |                     redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 入库  ===>>  四向穿梭车入库作业下发 | 
 |  |  |      */ | 
 |  |  |     public synchronized void shuttleInExecute() { | 
 |  |  |         List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4(); | 
 |  |  |         for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |             //获取源站 | 
 |  |  |             BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); | 
 |  |  |             if (sourceBasDevp == null) { | 
 |  |  |                 continue;//站点不存在 | 
 |  |  |             } | 
 |  |  |         try { | 
 |  |  |             List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4(); | 
 |  |  |             for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                 //获取源站 | 
 |  |  |                 BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); | 
 |  |  |                 if (sourceBasDevp == null) { | 
 |  |  |                     continue;//站点不存在 | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             //获取目标站 | 
 |  |  |             LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); | 
 |  |  |             if (liftStaProtocol == null) { | 
 |  |  |                 continue;//站点不存在 | 
 |  |  |             } | 
 |  |  |                 //获取目标站 | 
 |  |  |                 LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); | 
 |  |  |                 if (liftStaProtocol == null) { | 
 |  |  |                     continue;//站点不存在 | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             // 判断是否满足入库条件,自动、空闲、有物 | 
 |  |  |             if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { | 
 |  |  |                 News.info("{}任务,输送站点状态不满足入库。输送站点:{}", wrkMast.getWrkNo(), JSON.toJSONString(liftStaProtocol)); | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 // 判断是否满足入库条件,自动、空闲、有物 | 
 |  |  |                 if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { | 
 |  |  |                     News.info("{}任务,输送站点状态不满足入库。输送站点:{}", wrkMast.getWrkNo(), JSON.toJSONString(liftStaProtocol)); | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//小车搬入库中 | 
 |  |  |             if (!step1) { | 
 |  |  |                 continue; | 
 |  |  |                 boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//小车搬入库中 | 
 |  |  |                 if (!step1) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 出库  ===>>  四向穿梭车出库作业下发 | 
 |  |  |      */ | 
 |  |  |     public synchronized void shuttleOutExecute() { | 
 |  |  |         for (WrkMast wrkMast : wrkMastMapper.selectBy2125()) { | 
 |  |  |             boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//小车搬出库中 | 
 |  |  |             if (!step1) { | 
 |  |  |                 continue; | 
 |  |  |         try { | 
 |  |  |             for (WrkMast wrkMast : wrkMastMapper.selectBy2125()) { | 
 |  |  |                 boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//小车搬出库中 | 
 |  |  |                 if (!step1) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 return false;//出库站点不存在 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!basDevp.getAutoing().equals("Y")) { | 
 |  |  |                 News.info("{}任务,{}站点,不是自动状态",wrkMast.getWrkNo(),basDevp.getDevNo()); | 
 |  |  |                 return false;//不是自动状态 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!basDevp.getOutEnable().equals("Y")) { | 
 |  |  |                 News.info("{}任务,{}站点,没有可出信号", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
 |  |  |                 return false;//出库站点不可出 | 
 |  |  |             } | 
 |  |  | //            if (!basDevp.getAutoing().equals("Y")) { | 
 |  |  | //                News.info("{}任务,{}站点,不是自动状态",wrkMast.getWrkNo(),basDevp.getDevNo()); | 
 |  |  | //                return false;//不是自动状态 | 
 |  |  | //            } | 
 |  |  | // | 
 |  |  | //            if (!basDevp.getOutEnable().equals("Y")) { | 
 |  |  | //                News.info("{}任务,{}站点,没有可出信号", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
 |  |  | //                return false;//出库站点不可出 | 
 |  |  | //            } | 
 |  |  |  | 
 |  |  |             Integer liftNo = basDevp.getLiftNo();//搜索出库提升机是否存在入库任务,如存在禁止出库 | 
 |  |  |             List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo); | 
 |  |  | 
 |  |  |                 return false;//站点必须自动、空闲、没有托盘 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (wrkMast.getStaNo() == 300) { | 
 |  |  |                 //出300站,检测300站任务数量 | 
 |  |  |                 List<WrkMast> wrkMasts = wrkMastMapper.select300Wrk(); | 
 |  |  |                 if (wrkMasts.size() >= 20) { | 
 |  |  |                     News.info("{}任务,输送线任务过载{}", wrkMast.getWrkNo(), wrkMasts.size()); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (wrkMast.getShuttleNo() == null) {//没有绑定小车,进行调度 | 
 |  |  |                 //强制预留一台小车给入库任务 | 
 |  |  |                 int lev = Utils.getLev(wrkMast.getSourceLocNo()); | 
 |  |  |                 //获取当前楼层有几台可用小车 | 
 |  |  |                 int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev); | 
 |  |  |                 if (shuttleCount >= 2) {//只有可用小车数量大于2,才进行入库任务预留小车 | 
 |  |  |                     int shuttleWrkInObligateCount = 1;//预留小车数量 | 
 |  |  |                     Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1)); | 
 |  |  |                     if (config != null) { | 
 |  |  |                         shuttleWrkInObligateCount = Integer.parseInt(config.getValue()); | 
 |  |  |                     } | 
 |  |  |                     //可用出库小车数量(给入库任务预留一台车) | 
 |  |  |                     int useShuttleCount = shuttleCount - shuttleWrkInObligateCount; | 
 |  |  |                     //查询楼层已分配车辆的出库任务数量 | 
 |  |  |                     List<WrkMast> wrkMasts = wrkMastService.selectShuttleOutWrkByLev(lev); | 
 |  |  |                     if (wrkMasts.size() >= useShuttleCount) { | 
 |  |  |                         News.info("{}任务,当前楼层可用小车{}台,出库任务已分配{}台,系统等待中。", wrkMast.getWrkNo(), useShuttleCount, wrkMasts.size()); | 
 |  |  |                         return false; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 boolean result = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到货物所在库位进行取货 | 
 |  |  |                 News.info("{}任务,调度小车{}系统等待中。", wrkMast.getWrkNo(), result ? "成功" : "失败"); | 
 |  |  |                 return false; | 
 |  |  | 
 |  |  |      * 四向穿梭车任务完成 | 
 |  |  |      */ | 
 |  |  |     public synchronized void shuttleFinished() { | 
 |  |  |         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |             //获取四向穿梭车信息 | 
 |  |  |             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
 |  |  |             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |             if (shuttleProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |         try { | 
 |  |  |             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |                 //获取四向穿梭车信息 | 
 |  |  |                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
 |  |  |                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |                 if (shuttleProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             //四向穿梭车状态为等待确认、小车处于空闲状态 | 
 |  |  |             if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id  //任务完成等待确认 | 
 |  |  |                     && shuttleProtocol.getTaskNo() != 0 | 
 |  |  |                     && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id | 
 |  |  |             ) { | 
 |  |  |                 //将任务档标记为完成 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); | 
 |  |  |                 if (wrkMast != null) { | 
 |  |  |                     switch (wrkMast.getWrkSts().intValue()) { | 
 |  |  |                         case 5://5.小车搬运中 ==> 9.入库完成 | 
 |  |  |                             wrkMast.setWrkSts(9L); | 
 |  |  |                             shuttleProtocol.setTaskNo(0); | 
 |  |  |                             if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                 //释放小车令牌 | 
 |  |  |                                 shuttleProtocol.setToken(0); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         case 22://22.小车搬运中 ==> 23.小车搬运完成 | 
 |  |  |                             wrkMast.setWrkSts(23L); | 
 |  |  |                             shuttleProtocol.setTaskNo(0); | 
 |  |  |                             if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                 //释放小车令牌 | 
 |  |  |                                 shuttleProtocol.setToken(0); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         case 102://102.小车移动至站点 ==> 103.小车移动至站点完成 | 
 |  |  |                             wrkMast.setWrkSts(103L); | 
 |  |  |                             break; | 
 |  |  |                         case 104://104.小车迁入提升机中 ==> 105.小车迁入提升机完成 | 
 |  |  |                             wrkMast.setWrkSts(105L); | 
 |  |  |                             shuttleProtocol.setTaskNo(0);//清理工作号 | 
 |  |  |                             break; | 
 |  |  |                         case 108://108.小车迁出提升机中 ==> 109.小车迁出提升机完成 | 
 |  |  |                             wrkMast.setWrkSts(109L); | 
 |  |  |                             break; | 
 |  |  |                         case 110://110.小车移动中 ==> 111.小车移动完成 | 
 |  |  |                             wrkMast.setWrkSts(111L); | 
 |  |  |                             shuttleProtocol.setTaskNo(0); | 
 |  |  |                             if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                 //释放小车令牌 | 
 |  |  |                                 shuttleProtocol.setToken(0); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         default: | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                         if (wrkMast.getWrkSts() == 111) { | 
 |  |  |                             // 保存工作主档历史档 | 
 |  |  |                             if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) { | 
 |  |  |                                 log.info("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
 |  |  |                             } | 
 |  |  |                             // 删除工作主档 | 
 |  |  |                             if (!wrkMastService.deleteById(wrkMast)) { | 
 |  |  |                                 log.info("删除工作主档[workNo={0}]失败", wrkMast.getWrkNo()); | 
 |  |  |                             } | 
 |  |  |                 //四向穿梭车状态为等待确认、小车处于空闲状态 | 
 |  |  |                 if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id  //任务完成等待确认 | 
 |  |  |                         && shuttleProtocol.getTaskNo() != 0 | 
 |  |  |                         && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id | 
 |  |  |                 ) { | 
 |  |  |                     //将任务档标记为完成 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); | 
 |  |  |                     if (wrkMast != null) { | 
 |  |  |                         switch (wrkMast.getWrkSts().intValue()) { | 
 |  |  |                             case 5://5.小车搬运中 ==> 9.入库完成 | 
 |  |  |                                 wrkMast.setWrkSts(9L); | 
 |  |  |                                 shuttleProtocol.setTaskNo(0); | 
 |  |  |                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                     //释放小车令牌 | 
 |  |  |                                     shuttleProtocol.setToken(0); | 
 |  |  |                                 } | 
 |  |  |                                 break; | 
 |  |  |                             case 22://22.小车搬运中 ==> 23.小车搬运完成 | 
 |  |  |                                 wrkMast.setWrkSts(23L); | 
 |  |  |                                 shuttleProtocol.setTaskNo(0); | 
 |  |  |                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                     //释放小车令牌 | 
 |  |  |                                     shuttleProtocol.setToken(0); | 
 |  |  |                                 } | 
 |  |  |                                 break; | 
 |  |  |                             case 102://102.小车移动至站点 ==> 103.小车移动至站点完成 | 
 |  |  |                                 wrkMast.setWrkSts(103L); | 
 |  |  |                                 break; | 
 |  |  |                             case 104://104.小车迁入提升机中 ==> 105.小车迁入提升机完成 | 
 |  |  |                                 wrkMast.setWrkSts(105L); | 
 |  |  |                                 shuttleProtocol.setTaskNo(0);//清理工作号 | 
 |  |  |                                 break; | 
 |  |  |                             case 108://108.小车迁出提升机中 ==> 109.小车迁出提升机完成 | 
 |  |  |                                 wrkMast.setWrkSts(109L); | 
 |  |  |                                 break; | 
 |  |  |                             case 110://110.小车移动中 ==> 111.小车移动完成 | 
 |  |  |                                 wrkMast.setWrkSts(111L); | 
 |  |  |                                 shuttleProtocol.setTaskNo(0); | 
 |  |  |                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                     //释放小车令牌 | 
 |  |  |                                     shuttleProtocol.setToken(0); | 
 |  |  |                                 } | 
 |  |  |                                 break; | 
 |  |  |                             default: | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         //设置四向穿梭车为空闲状态 | 
 |  |  |                         shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
 |  |  |                         //源库位清零 | 
 |  |  |                         shuttleProtocol.setSourceLocNo(null); | 
 |  |  |                         //目标库位清零 | 
 |  |  |                         shuttleProtocol.setLocNo(null); | 
 |  |  |                         //任务指令清零 | 
 |  |  |                         shuttleProtocol.setAssignCommand(null); | 
 |  |  |                         News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
 |  |  |                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                             if (wrkMast.getWrkSts() == 111) { | 
 |  |  |                                 // 保存工作主档历史档 | 
 |  |  |                                 if (wrkMastLogMapper.save(wrkMast.getWrkNo()) <= 0) { | 
 |  |  |                                     log.info("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
 |  |  |                                 } | 
 |  |  |                                 // 删除工作主档 | 
 |  |  |                                 if (!wrkMastService.deleteById(wrkMast)) { | 
 |  |  |                                     log.info("删除工作主档[workNo={0}]失败", wrkMast.getWrkNo()); | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  |                             //设置四向穿梭车为空闲状态 | 
 |  |  |                             shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
 |  |  |                             //源库位清零 | 
 |  |  |                             shuttleProtocol.setSourceLocNo(null); | 
 |  |  |                             //目标库位清零 | 
 |  |  |                             shuttleProtocol.setLocNo(null); | 
 |  |  |                             //任务指令清零 | 
 |  |  |                             shuttleProtocol.setAssignCommand(null); | 
 |  |  |                             News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
 |  |  |                         } else { | 
 |  |  |                             News.error("四向穿梭车已确认且任务完成状态,复位失败,但未找到工作档。四向穿梭车号={},工作号={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); | 
 |  |  |                         } | 
 |  |  |                     } else { | 
 |  |  |                         News.error("四向穿梭车已确认且任务完成状态,复位失败,但未找到工作档。四向穿梭车号={},工作号={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); | 
 |  |  |                         ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand(); | 
 |  |  |                         if (!assignCommand.getAuto()) { | 
 |  |  |                             //手动模式 | 
 |  |  |                             //工作号清零 | 
 |  |  |                             shuttleProtocol.setTaskNo(0); | 
 |  |  |                             //设置四向穿梭车为空闲状态 | 
 |  |  |                             shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
 |  |  |                             //源库位清零 | 
 |  |  |                             shuttleProtocol.setSourceLocNo(null); | 
 |  |  |                             //目标库位清零 | 
 |  |  |                             shuttleProtocol.setLocNo(null); | 
 |  |  |                             //任务指令清零 | 
 |  |  |                             shuttleProtocol.setAssignCommand(null); | 
 |  |  |                             //清零令牌 | 
 |  |  |                             shuttleProtocol.setToken(0); | 
 |  |  |                             News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 }else { | 
 |  |  |                     ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand(); | 
 |  |  |                     if (!assignCommand.getAuto()) { | 
 |  |  |                         //手动模式 | 
 |  |  |                         //工作号清零 | 
 |  |  |                         shuttleProtocol.setTaskNo(0); | 
 |  |  |                         //设置四向穿梭车为空闲状态 | 
 |  |  |                         shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
 |  |  |                         //源库位清零 | 
 |  |  |                         shuttleProtocol.setSourceLocNo(null); | 
 |  |  |                         //目标库位清零 | 
 |  |  |                         shuttleProtocol.setLocNo(null); | 
 |  |  |                         //任务指令清零 | 
 |  |  |                         shuttleProtocol.setAssignCommand(null); | 
 |  |  |                         //清零令牌 | 
 |  |  |                         shuttleProtocol.setToken(0); | 
 |  |  |                         News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 提升机任务 | 
 |  |  |      */ | 
 |  |  |     public synchronized void liftIoExecute() { | 
 |  |  |         for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
 |  |  |             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
 |  |  |             if (liftThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
 |  |  |             if (liftProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!liftProtocol.isIdle()) { | 
 |  |  |                 News.info("{}号提升机,忙碌中", liftSlave.getId()); | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //判断提升机令牌是否被占用 | 
 |  |  |             if (liftProtocol.getToken() != 0) { | 
 |  |  |                 News.info("{}号提升机,令牌已被独占", liftSlave.getId()); | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //搜索是否有待处理的任务 | 
 |  |  |             List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103(); | 
 |  |  |             if (wrkMasts.isEmpty()) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                 //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 | 
 |  |  |                 WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); | 
 |  |  |                 if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { | 
 |  |  |                     News.info("{}号提升机,被其他任务{}占用且和当前任务{}不相同,禁止派发", liftSlave.getId(), wrkMast1.getWrkNo(), wrkMast.getWrkNo()); | 
 |  |  |         try { | 
 |  |  |             for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
 |  |  |                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
 |  |  |                 if (liftThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
 |  |  |                 if (liftProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//提升机入库 | 
 |  |  |                 if (!stepIn) { | 
 |  |  |                 if (!liftProtocol.isIdle()) { | 
 |  |  |                     News.info("{}号提升机,忙碌中", liftSlave.getId()); | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//提升机出库 | 
 |  |  |                 if (!stepOut) { | 
 |  |  |                 //判断提升机令牌是否被占用 | 
 |  |  |                 if (liftProtocol.getToken() != 0) { | 
 |  |  |                     News.info("{}号提升机,令牌已被独占", liftSlave.getId()); | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //搜索是否有待处理的任务 | 
 |  |  |                 List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103(); | 
 |  |  |                 if (wrkMasts.isEmpty()) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                     //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 | 
 |  |  |                     WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); | 
 |  |  |                     if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { | 
 |  |  |                         News.info("{}号提升机,被其他任务{}占用且和当前任务{}不相同,禁止派发", liftSlave.getId(), wrkMast1.getWrkNo(), wrkMast.getWrkNo()); | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//提升机入库 | 
 |  |  |                     if (!stepIn) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//提升机出库 | 
 |  |  |                     if (!stepOut) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |             if (!sourceBasDevp.getInEnable().equals("Y")) { | 
 |  |  |                 News.info("{}任务,{}源站,没有可入信号", wrkMast.getWrkNo(), sourceBasDevp.getDevNo()); | 
 |  |  |                 return false;//站点不可入 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             Integer barcodeId = Utils.getBarcodeIdByStaNo(wrkMast.getSourceStaNo()); | 
 |  |  |             if (barcodeId == null) { | 
 |  |  |                 News.info("{}任务,{}源站,找不到可用条码器ID", wrkMast.getWrkNo(), sourceBasDevp.getDevNo()); | 
 |  |  |                 return false;//站点不可入 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); | 
 |  |  |             if (barcodeThread == null) { | 
 |  |  |                 News.info("{}任务,{}源站,条码器{}线程为空", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId); | 
 |  |  |                 return false;//站点不可入 | 
 |  |  |             } | 
 |  |  |             String barcode = barcodeThread.getBarcode(); | 
 |  |  |             if(!Cools.isEmpty(barcode)) { | 
 |  |  |                 if(!("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode))) { | 
 |  |  |                     //存在条码值,判断是否和当前工作档一致 | 
 |  |  |                     if (!barcode.equals(wrkMast.getBarcode())) { | 
 |  |  |                         News.info("{}任务,{}站点,条码器{}值{}与工作档条码值{}不一致,系统跳过执行", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId, barcode,wrkMast.getBarcode()); | 
 |  |  |                         return false;//站点不可入 | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             }else { | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //判断提升机整个三楼是否都处于入库模式 | 
 |  |  | 
 |  |  |             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo()); | 
 |  |  |             if (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57) { | 
 |  |  |                 //拣料再回库,重新分配设备工作号 | 
 |  |  |                 Random random = new Random(); | 
 |  |  |                 int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//获取设备工作号 | 
 |  |  |                 int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号 | 
 |  |  |                 BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(String.valueOf(deviceWrk), liftThread.getSlave().getId()); | 
 |  |  |                 if (basLiftOpt != null) { | 
 |  |  |                     News.info("{}任务,{}号提升机,设备工作号出现重复情况,请联系技术人员支持。", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |                 liftCommand.setTaskNo((short) deviceWrk); | 
 |  |  |             } | 
 |  |  |             ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
 |  |  | 
 |  |  |                     News.info("{}任务,{}小车,小车在输送站点调度小车避让失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!basDevp.getAutoing().equals("Y")) { | 
 |  |  |                 News.info("{}任务,{}站点,没有自动信号,禁止派发", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
 |  |  |                 return false;//出库站点不可出 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (basDevp.getLoading().equals("Y")) { | 
 |  |  |                 News.info("{}任务,{}站点,存在有物信号,禁止派发", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
 |  |  |                 return false;//出库站点不可出 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!basDevp.getOutEnable().equals("Y")) { | 
 |  |  | 
 |  |  |      * 提升机任务完成 | 
 |  |  |      */ | 
 |  |  |     public synchronized void liftFinished() { | 
 |  |  |         for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
 |  |  |             //获取提升机信息 | 
 |  |  |             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
 |  |  |             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
 |  |  |             if (liftProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //提升机为等待确认且空闲 | 
 |  |  |             if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id | 
 |  |  |                     && liftProtocol.getTaskNo() != 0 | 
 |  |  |                     && !liftProtocol.getBusy() | 
 |  |  |             ) { | 
 |  |  |                 BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString()); | 
 |  |  |                 int taskNo = liftProtocol.getTaskNo().intValue(); | 
 |  |  |                 if (basLiftOpt != null) { | 
 |  |  |                     taskNo = basLiftOpt.getWrkNo(); | 
 |  |  |         try { | 
 |  |  |             for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
 |  |  |                 //获取提升机信息 | 
 |  |  |                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
 |  |  |                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
 |  |  |                 if (liftProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //将任务档标记为完成 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); | 
 |  |  |                 if (wrkMast != null) { | 
 |  |  |                     switch (wrkMast.getWrkSts().intValue()) { | 
 |  |  |                         case 3://3.提升机搬运中 ==> 4.提升机搬运完成 | 
 |  |  |                             wrkMast.setWrkSts(4L); | 
 |  |  |                             wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                             if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                 //释放提升机令牌 | 
 |  |  |                                 liftProtocol.setToken(0); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         case 24://24.提升机搬运中 ==> 25.提升机搬运完成 | 
 |  |  |                             wrkMast.setWrkSts(25L); | 
 |  |  |                             if (wrkMast.getIoType() == 11) {//库位移转 | 
 |  |  |                                 wrkMast.setWrkSts(4L);//4.提升机搬运完成 | 
 |  |  |                             }else { | 
 |  |  |                                 if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { | 
 |  |  |                                     //不需要用到机械臂,直接转29.出库完成 | 
 |  |  |                                     wrkMast.setWrkSts(29L); | 
 |  |  |                                     wrkMast.setShuttleNo(null);//释放小车 | 
 |  |  |                                     wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                 //提升机为等待确认且空闲 | 
 |  |  |                 if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id | 
 |  |  |                         && liftProtocol.getTaskNo() != 0 | 
 |  |  |                         && !liftProtocol.getBusy() | 
 |  |  |                 ) { | 
 |  |  |                     int taskNo = liftProtocol.getTaskNo().intValue(); | 
 |  |  |                     if (taskNo >= 20000 && taskNo <= 30000) { | 
 |  |  |                         //提升机设备工作号,需要查询对应任务号 | 
 |  |  |                         BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString(), liftSlave.getId()); | 
 |  |  |                         if (basLiftOpt != null) { | 
 |  |  |                             taskNo = basLiftOpt.getWrkNo(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //将任务档标记为完成 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); | 
 |  |  |                     if (wrkMast != null) { | 
 |  |  |                         switch (wrkMast.getWrkSts().intValue()) { | 
 |  |  |                             case 3://3.提升机搬运中 ==> 4.提升机搬运完成 | 
 |  |  |                                 wrkMast.setWrkSts(4L); | 
 |  |  |                                 wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                                 if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                     //释放提升机令牌 | 
 |  |  |                                     liftProtocol.setToken(0); | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                                 break; | 
 |  |  |                             case 24://24.提升机搬运中 ==> 25.提升机搬运完成 | 
 |  |  |                                 wrkMast.setWrkSts(25L); | 
 |  |  |                                 if (wrkMast.getIoType() == 11) {//库位移转 | 
 |  |  |                                     wrkMast.setWrkSts(4L);//4.提升机搬运完成 | 
 |  |  |                                 } else { | 
 |  |  |                                     if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { | 
 |  |  |                                         //不需要用到机械臂,直接转29.出库完成 | 
 |  |  |                                         wrkMast.setWrkSts(29L); | 
 |  |  |                                         wrkMast.setShuttleNo(null);//释放小车 | 
 |  |  |                                         wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                                         wrkMast.setModiTime(new Date()); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |  | 
 |  |  |                             if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                 //释放提升机令牌 | 
 |  |  |                                 liftProtocol.setToken(0); | 
 |  |  |                             } | 
 |  |  |                                 if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
 |  |  |                                     //释放提升机令牌 | 
 |  |  |                                     liftProtocol.setToken(0); | 
 |  |  |                                 } | 
 |  |  |  | 
 |  |  |                             break; | 
 |  |  |                         case 106://106.提升机搬运中 ==> 107.提升机搬运完成 | 
 |  |  |                             wrkMast.setWrkSts(107L); | 
 |  |  |                             break; | 
 |  |  |                         default: | 
 |  |  |                     } | 
 |  |  |                                 break; | 
 |  |  |                             case 106://106.提升机搬运中 ==> 107.提升机搬运完成 | 
 |  |  |                                 wrkMast.setWrkSts(107L); | 
 |  |  |                                 break; | 
 |  |  |                             default: | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                         //设置提升机为空闲状态 | 
 |  |  |                         liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); | 
 |  |  |                         //任务指令清零 | 
 |  |  |                         liftProtocol.setAssignCommand(null); | 
 |  |  |                         News.info("提升机已确认且任务完成状态。提升机号={}", liftProtocol.getLiftNo()); | 
 |  |  |                     } else { | 
 |  |  |                         News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); | 
 |  |  |                     } | 
 |  |  |                 }else { | 
 |  |  |                     LiftAssignCommand assignCommand = liftProtocol.getAssignCommand(); | 
 |  |  |                     if (assignCommand != null) { | 
 |  |  |                         if (!assignCommand.getAuto()) { | 
 |  |  |                             //手动操作 | 
 |  |  |                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                             //设置提升机为空闲状态 | 
 |  |  |                             liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); | 
 |  |  |                             //任务指令清零 | 
 |  |  |                             liftProtocol.setAssignCommand(null); | 
 |  |  |                             News.info("提升机已确认手动操作。提升机号={}", liftProtocol.getLiftNo()); | 
 |  |  |                             News.info("提升机已确认且任务完成状态。提升机号={}", liftProtocol.getLiftNo()); | 
 |  |  |                         } else { | 
 |  |  |                             News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); | 
 |  |  |                         } | 
 |  |  |                     } else { | 
 |  |  |                         LiftAssignCommand assignCommand = liftProtocol.getAssignCommand(); | 
 |  |  |                         if (assignCommand != null) { | 
 |  |  |                             if (!assignCommand.getAuto()) { | 
 |  |  |                                 //手动操作 | 
 |  |  |                                 //设置提升机为空闲状态 | 
 |  |  |                                 liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); | 
 |  |  |                                 //任务指令清零 | 
 |  |  |                                 liftProtocol.setAssignCommand(null); | 
 |  |  |                                 News.info("提升机已确认手动操作。提升机号={}", liftProtocol.getLiftNo()); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 库位移转 | 
 |  |  |      */ | 
 |  |  |     public synchronized void locToLocExecute() { | 
 |  |  |         //获取出入库工作档 | 
 |  |  |         List<WrkMast> wrkMasts = wrkMastMapper.selectInOutWrkMast(); | 
 |  |  |         if (wrkMasts.size() > 0) { | 
 |  |  |             //有出入库任务,必须等待任务执行完毕再执行库位移转 | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         try { | 
 |  |  |             //获取出入库工作档 | 
 |  |  | //        List<WrkMast> wrkMasts = wrkMastMapper.selectInOutWrkMast(); | 
 |  |  | //        if (wrkMasts.size() > 0) { | 
 |  |  | //            //有出入库任务,必须等待任务执行完毕再执行库位移转 | 
 |  |  | //            return; | 
 |  |  | //        } | 
 |  |  |  | 
 |  |  |         //查询库位移转工作档 | 
 |  |  |         List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); | 
 |  |  |         for (WrkMast wrkMast : wrkMasts1) { | 
 |  |  |             if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { | 
 |  |  |                 boolean step1 = this.locToLocExecuteStep1(wrkMast);//同楼层库位移转 | 
 |  |  |                 if (!step1) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |             }else { | 
 |  |  |                 //跨楼层库位移转 | 
 |  |  |                 boolean step2 = this.locToLocExecuteStep2(wrkMast);//调度车辆取货并运送到出库口 | 
 |  |  |                 if (!step2) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |             //查询库位移转工作档 | 
 |  |  |             List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); | 
 |  |  |             for (WrkMast wrkMast : wrkMasts1) { | 
 |  |  |                 if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { | 
 |  |  |                     boolean step1 = this.locToLocExecuteStep1(wrkMast);//同楼层库位移转 | 
 |  |  |                     if (!step1) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                 } else { | 
 |  |  |                     //跨楼层库位移转 | 
 |  |  |                     boolean step2 = this.locToLocExecuteStep2(wrkMast);//调度车辆取货并运送到出库口 | 
 |  |  |                     if (!step2) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 boolean step3 = this.locToLocExecuteStep3(wrkMast);//提升机搬运货物 | 
 |  |  |                 if (!step3) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                     boolean step3 = this.locToLocExecuteStep3(wrkMast);//提升机搬运货物 | 
 |  |  |                     if (!step3) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 boolean step4 = this.locToLocExecuteStep4(wrkMast);//调度车辆取货并运送到目标库位 | 
 |  |  |                 if (!step4) { | 
 |  |  |                     continue; | 
 |  |  |                     boolean step4 = this.locToLocExecuteStep4(wrkMast);//调度车辆取货并运送到目标库位 | 
 |  |  |                     if (!step4) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 空栈板初始化入库,叉车入库站放货 | 
 |  |  |      */ | 
 |  |  |     public void storeEmptyPlt(){ | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 遍历空板入库口 | 
 |  |  |             for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { | 
 |  |  |                 // 获取空板入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 // 站点条件判断 | 
 |  |  |                 if (staProtocol.isAutoing() | 
 |  |  |                         && staProtocol.isLoading() | 
 |  |  |                         && staProtocol.isInEnable() | 
 |  |  |                         && staProtocol.isEmptyMk() | 
 |  |  |                         && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) | 
 |  |  |                         && staProtocol.isPakMk()) { | 
 |  |  |         try { | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 遍历空板入库口 | 
 |  |  |                 for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { | 
 |  |  |                     // 获取空板入库站信息 | 
 |  |  |                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     // 站点条件判断 | 
 |  |  |                     if (staProtocol.isAutoing() | 
 |  |  |                             && staProtocol.isLoading() | 
 |  |  |                             && staProtocol.isInEnable() | 
 |  |  |                             && staProtocol.isEmptyMk() | 
 |  |  |                             && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) | 
 |  |  |                             && staProtocol.isPakMk()) { | 
 |  |  |  | 
 |  |  |                     // 获取条码扫描仪信息 | 
 |  |  |                     String barcode = null; | 
 |  |  |                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); | 
 |  |  |                     if (barcodeThread != null) { | 
 |  |  |                         String barcode0 = barcodeThread.getBarcode(); | 
 |  |  |                         if(!Cools.isEmpty(barcode0)) { | 
 |  |  |                         // 获取条码扫描仪信息 | 
 |  |  |                         String barcode = null; | 
 |  |  |                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); | 
 |  |  |                         if (barcodeThread != null) { | 
 |  |  |                             String barcode0 = barcodeThread.getBarcode(); | 
 |  |  |                             if (!Cools.isEmpty(barcode0)) { | 
 |  |  | //                            News.info("{}号条码扫描器检测条码信息:{}", emptyInSta.getBarcode(), barcode0); | 
 |  |  |                             if(!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { | 
 |  |  |                                 barcode = barcode0; | 
 |  |  |                                 if (!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { | 
 |  |  |                                     barcode = barcode0; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (!Cools.isEmpty(barcode)) { | 
 |  |  |                         WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//条码存在工作档 | 
 |  |  |                         if (wrkMast != null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); | 
 |  |  |  | 
 |  |  |                     try { | 
 |  |  |                         LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  |  | 
 |  |  |                         SearchLocParam param = new SearchLocParam(); | 
 |  |  |                         param.setIoType(10); | 
 |  |  |                         if (!Cools.isEmpty(barcode)) { | 
 |  |  |                             param.setBarcode(barcode); | 
 |  |  |                             WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//条码存在工作档 | 
 |  |  |                             if (wrkMast != null) { | 
 |  |  |                                 continue; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         param.setSourceStaNo(emptyInSta.getStaNo()); | 
 |  |  |  | 
 |  |  |                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); | 
 |  |  |  | 
 |  |  |                         try { | 
 |  |  |                             LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
 |  |  |  | 
 |  |  |                             SearchLocParam param = new SearchLocParam(); | 
 |  |  |                             param.setIoType(10); | 
 |  |  |                             if (!Cools.isEmpty(barcode)) { | 
 |  |  |                                 param.setBarcode(barcode); | 
 |  |  |                             } | 
 |  |  |                             param.setSourceStaNo(emptyInSta.getStaNo()); | 
 |  |  | //                        param.setLocType1(locTypeDto.getLocType1()); | 
 |  |  |                         String response = new HttpHandler.Builder() | 
 |  |  |                                 .setUri(wmsUrl) | 
 |  |  |                                 .setPath("/rpc/pakin/loc/v1") | 
 |  |  |                                 .setJson(JSON.toJSONString(param)) | 
 |  |  |                                 .build() | 
 |  |  |                                 .doPost(); | 
 |  |  |                         JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                         Integer code = jsonObject.getInteger("code"); | 
 |  |  |                         if (code.equals(200)) { | 
 |  |  |                             StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |                             barcodeThread.setBarcode(""); | 
 |  |  |                             String response = new HttpHandler.Builder() | 
 |  |  |                                     .setUri(wmsUrl) | 
 |  |  |                                     .setPath("/rpc/pakin/loc/v2") | 
 |  |  |                                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                                     .build() | 
 |  |  |                                     .doPost(); | 
 |  |  |                             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                             Integer code = jsonObject.getInteger("code"); | 
 |  |  |                             if (code.equals(200)) { | 
 |  |  |                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  |                                 barcodeThread.setBarcode(""); | 
 |  |  | //                            // 更新站点信息 且 下发plc命令 | 
 |  |  | //                            staProtocol.setWorkNo(dto.getWorkNo().shortValue()); | 
 |  |  | //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
 |  |  | 
 |  |  | //                            if (!result) { | 
 |  |  | //                                throw new CoolException("更新plc站点信息失败"); | 
 |  |  | //                            } | 
 |  |  |                         } else { | 
 |  |  |                             if (ledThread != null) { | 
 |  |  |                                 String errorMsg = jsonObject.getString("msg"); | 
 |  |  |                                 if (!Cools.isEmpty(errorMsg)) { | 
 |  |  |                                     MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                             } else { | 
 |  |  |                                 if (ledThread != null) { | 
 |  |  |                                     String errorMsg = jsonObject.getString("msg"); | 
 |  |  |                                     if (!Cools.isEmpty(errorMsg)) { | 
 |  |  |                                         MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
 |  |  |                             } | 
 |  |  |                             News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                         } | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         e.printStackTrace(); | 
 |  |  |                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * AGV补货 => 生成入库通知档 | 
 |  |  |      */ | 
 |  |  |     public void robotGenerateAgvTask() { | 
 |  |  | //检测300站是否自动、有物、工作号 | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 获取入库站信息 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |             StaProtocol staProtocol = devpThread.getStation().get(300); | 
 |  |  |             if (staProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
 |  |  |                 //查询是否有工作档 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                 if (wrkMast == null) { | 
 |  |  |     public synchronized void robotGenerateAgvTask() { | 
 |  |  |         try { | 
 |  |  |             //检测300站是否自动、有物、工作号 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 获取入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(300); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成 | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//标记为Y表示需要用到机械臂拣料 | 
 |  |  |                     Short targetSta = null;//目标站 | 
 |  |  |                     //判断机械臂拣料站是否空闲 | 
 |  |  |                     StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
 |  |  |                     StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
 |  |  |                     if (staProtocol303.isAutoing() && !staProtocol303.isLoading()) { | 
 |  |  |                         //自动、无物 | 
 |  |  |                         targetSta = (short) 303; | 
 |  |  |                     } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) { | 
 |  |  |                         //自动、无物 | 
 |  |  |                         targetSta = (short) 317; | 
 |  |  |                     } else { | 
 |  |  |                         continue;//没有空闲站点 | 
 |  |  |                 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
 |  |  |                     //查询是否有工作档 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { | 
 |  |  |                         //向AGV发起组托请求 | 
 |  |  |                         try { | 
 |  |  |                             HashMap<String, Object> param = new HashMap<>(); | 
 |  |  |                             param.put("wrkNo", wrkMast.getWrkNo()); | 
 |  |  |                             String response = new HttpHandler.Builder() | 
 |  |  |                                     .setUri(wmsUrl) | 
 |  |  |                                     .setPath("/rpc/replenishment") | 
 |  |  |                                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                                     .build() | 
 |  |  |                                     .doPost(); | 
 |  |  |                             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                             Integer code = jsonObject.getInteger("code"); | 
 |  |  |                             if (code.equals(200)) {//AGV组托成功 | 
 |  |  |                                 //覆盖工作档目标站 | 
 |  |  |                                 wrkMast.setStaNo(targetSta.intValue()); | 
 |  |  |                                 wrkMast.setShuttleNo(null);//释放小车 | 
 |  |  |                                 wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                                 if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                                     //向300站写入目标站 | 
 |  |  |                                     staProtocol = staProtocol.clone(); | 
 |  |  |                                     staProtocol.setStaNo(targetSta);//移动到目标站 | 
 |  |  |                                     boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                                     try { | 
 |  |  |                                         Thread.sleep(500); | 
 |  |  |                                     } catch (Exception e) { | 
 |  |  |                                         e.printStackTrace(); | 
 |  |  |                                     } | 
 |  |  |                                     continue; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                     if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成 | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//标记为Y表示需要用到机械臂拣料 | 
 |  |  |                         Short targetSta = null;//目标站 | 
 |  |  |                         //判断机械臂拣料站是否空闲 | 
 |  |  |                         StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
 |  |  |                         StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
 |  |  |  | 
 |  |  |                         List<WrkMast> wrkMasts303 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 303)); | 
 |  |  |                         List<WrkMast> wrkMasts317 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 317)); | 
 |  |  |                         if (staProtocol303.isAutoing() && !staProtocol303.isLoading() && wrkMasts303.isEmpty()) { | 
 |  |  |                             //自动、无物 | 
 |  |  |                             targetSta = (short) 303; | 
 |  |  |                         } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading() && wrkMasts317.isEmpty()) { | 
 |  |  |                             //自动、无物 | 
 |  |  |                             targetSta = (short) 317; | 
 |  |  |                         } else { | 
 |  |  |                             continue;//没有空闲站点 | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { | 
 |  |  |                             //向AGV发起组托请求 | 
 |  |  |                             try { | 
 |  |  |                                 HashMap<String, Object> param = new HashMap<>(); | 
 |  |  |                                 param.put("wrkNo", wrkMast.getWrkNo()); | 
 |  |  |                                 String response = new HttpHandler.Builder() | 
 |  |  |                                         .setUri(wmsUrl) | 
 |  |  |                                         .setPath("/rpc/replenishment") | 
 |  |  |                                         .setJson(JSON.toJSONString(param)) | 
 |  |  |                                         .build() | 
 |  |  |                                         .doPost(); | 
 |  |  |                                 JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |                                 Integer code = jsonObject.getInteger("code"); | 
 |  |  |                                 if (code.equals(200)) {//AGV组托成功 | 
 |  |  |                                     //覆盖工作档目标站 | 
 |  |  |                                     wrkMast.setStaNo(targetSta.intValue()); | 
 |  |  |                                     wrkMast.setShuttleNo(null);//释放小车 | 
 |  |  |                                     wrkMast.setLiftNo(null);//释放提升机 | 
 |  |  |                                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                                         //向300站写入目标站 | 
 |  |  |                                         staProtocol = staProtocol.clone(); | 
 |  |  |                                         staProtocol.setStaNo(targetSta);//移动到目标站 | 
 |  |  |                                         boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                                         try { | 
 |  |  |                                             Thread.sleep(500); | 
 |  |  |                                         } catch (Exception e) { | 
 |  |  |                                             e.printStackTrace(); | 
 |  |  |                                         } | 
 |  |  |                                         continue; | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                             } catch (Exception e) { | 
 |  |  | //                                e.printStackTrace(); | 
 |  |  |                                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  | //                        //覆盖工作档目标站 | 
 |  |  | //                        wrkMast.setStaNo(targetSta.intValue()); | 
 |  |  | 
 |  |  | //                            } | 
 |  |  | //                            continue; | 
 |  |  | //                        } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  | //            e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * AGV补货 => 机械臂拣料 | 
 |  |  |      */ | 
 |  |  |     public void agvRestockByRobot() { | 
 |  |  |         //检测300站是否自动、有物、工作号 | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 获取入库站信息 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |             StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
 |  |  |             StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
 |  |  |             if (staProtocol303 == null || staProtocol317 == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { | 
 |  |  |                 //调度机械臂 | 
 |  |  |                 //查询是否有工作档 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue()); | 
 |  |  |                 if (wrkMast == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                 if (wrkDetls.isEmpty()) { | 
 |  |  |     public synchronized void agvRestockByRobot() { | 
 |  |  |         try { | 
 |  |  |             //检测300站是否自动、有物、工作号 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 获取入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
 |  |  |                 StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
 |  |  |                 if (staProtocol303 == null || staProtocol317 == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getInvWh() == null) { | 
 |  |  |                     wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                         RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303"); | 
 |  |  |                 if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { | 
 |  |  |                     //调度机械臂 | 
 |  |  |                     //查询是否有工作档 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue()); | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                     if (wrkDetls.isEmpty()) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (wrkMast.getInvWh() == null) { | 
 |  |  |                         boolean result = RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303"); | 
 |  |  |                         if (result) { | 
 |  |  |                             wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
 |  |  |                             wrkMastMapper.updateById(wrkMast); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             }else if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) { | 
 |  |  |                 //调度机械臂 | 
 |  |  |                 //查询是否有工作档 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue()); | 
 |  |  |                 if (wrkMast == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                 if (wrkDetls.isEmpty()) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 if (wrkMast.getInvWh() == null) { | 
 |  |  |                     wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                         RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317"); | 
 |  |  |  | 
 |  |  |                 if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) { | 
 |  |  |                     //调度机械臂 | 
 |  |  |                     //查询是否有工作档 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue()); | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                     if (wrkDetls.isEmpty()) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     if (wrkMast.getInvWh() == null) { | 
 |  |  |                         boolean result = RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317"); | 
 |  |  |                         if (result) { | 
 |  |  |                             wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
 |  |  |                             wrkMastMapper.updateById(wrkMast); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * AGV补货(通知AGV取货) | 
 |  |  |      */ | 
 |  |  |     public void agvRestockInto() { | 
 |  |  |         //检测309和312站是否自动、有物 | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 获取入库站信息 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |             StaProtocol staProtocol309 = devpThread.getStation().get(309); | 
 |  |  |             StaProtocol staProtocol312 = devpThread.getStation().get(312); | 
 |  |  |             if (staProtocol309 == null || staProtocol312 == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) { | 
 |  |  |                 // 获取条码扫描仪信息 | 
 |  |  |                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器 | 
 |  |  |                 if (barcodeThread == null) { | 
 |  |  |     public synchronized void agvRestockInto() { | 
 |  |  |         try { | 
 |  |  |             //检测309和312站是否自动、有物 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 获取入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol309 = devpThread.getStation().get(309); | 
 |  |  |                 StaProtocol staProtocol312 = devpThread.getStation().get(312); | 
 |  |  |                 if (staProtocol309 == null || staProtocol312 == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 String barcode = barcodeThread.getBarcode(); | 
 |  |  |                 if(!Cools.isEmpty(barcode)) { | 
 |  |  |                     //通知AGV取货 | 
 |  |  |                     agvRestockCall("301-1", barcode); | 
 |  |  |                     log.info("通知AGV取货,条码号:" + barcode); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) { | 
 |  |  |                 // 获取条码扫描仪信息 | 
 |  |  |                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器 | 
 |  |  |                 if (barcodeThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) { | 
 |  |  |                     // 获取条码扫描仪信息 | 
 |  |  |                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器 | 
 |  |  |                     if (barcodeThread == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     String barcode = barcodeThread.getBarcode(); | 
 |  |  |                     if (!Cools.isEmpty(barcode)) { | 
 |  |  |                         //通知AGV取货 | 
 |  |  |                         boolean result = agvRestockCall("301-1", barcode); | 
 |  |  |                         log.info("机械臂通知AGV取货,条码号:" + barcode); | 
 |  |  |                         if (result) { | 
 |  |  |                             barcodeThread.setBarcode(""); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 String barcode = barcodeThread.getBarcode(); | 
 |  |  |                 if(!Cools.isEmpty(barcode)) { | 
 |  |  |                     //通知AGV取货 | 
 |  |  |                     agvRestockCall("302-1", barcode); | 
 |  |  |                     log.info("通知AGV取货,条码号:" + barcode); | 
 |  |  |  | 
 |  |  |                 if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) { | 
 |  |  |                     // 获取条码扫描仪信息 | 
 |  |  |                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器 | 
 |  |  |                     if (barcodeThread == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     String barcode = barcodeThread.getBarcode(); | 
 |  |  |                     if (!Cools.isEmpty(barcode)) { | 
 |  |  |                         //通知AGV取货 | 
 |  |  |                         boolean result = agvRestockCall("302-1", barcode); | 
 |  |  |                         log.info("机械臂通知AGV取货,条码号:" + barcode); | 
 |  |  |                         if (result) { | 
 |  |  |                             barcodeThread.setBarcode(""); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                     .build() | 
 |  |  |                     .doPost(); | 
 |  |  |             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |             log.info("悬挂线,wms返回结果:" + jsonObject); | 
 |  |  |             News.info("悬挂线,WMS返回结果:" + jsonObject); | 
 |  |  |             Integer code = jsonObject.getInteger("code"); | 
 |  |  |             if (code.equals(200)) {//呼叫AGV | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |         } | 
 |  |  |         return false; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //通知WMS当前拣料站点信息 | 
 |  |  |     private boolean agvCureentCall(String staNo, String barcode) { | 
 |  |  |         try { | 
 |  |  |             HashMap<String, Object> param = new HashMap<>(); | 
 |  |  |             param.put("devNo", staNo); | 
 |  |  |             param.put("containerCode", barcode); | 
 |  |  |             String response = new HttpHandler.Builder() | 
 |  |  |                     .setUri(wmsUrl) | 
 |  |  |                     .setPath("/rpc/current/containerCode") | 
 |  |  |                     .setJson(JSON.toJSONString(param)) | 
 |  |  |                     .build() | 
 |  |  |                     .doPost(); | 
 |  |  |             JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  |             News.info("悬挂线,WMS返回结果:" + jsonObject); | 
 |  |  |             Integer code = jsonObject.getInteger("code"); | 
 |  |  |             if (code.equals(200)) {//呼叫AGV | 
 |  |  |                 return true; | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * AGV补货(悬挂线通知AGV取货) | 
 |  |  |      */ | 
 |  |  |     public void agvRestockIntoByHangingWire() { | 
 |  |  |         //检测350和351扫码器 | 
 |  |  |         int[] barcodeStaNo = {11, 12};//11 => 350站扫码器,12 => 351站扫码器 | 
 |  |  |         for (int staNo : barcodeStaNo) { | 
 |  |  |             // 获取条码扫描仪信息 | 
 |  |  |             BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); | 
 |  |  |             if (barcodeThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             String barcode = barcodeThread.getBarcode(); | 
 |  |  |             if(!Cools.isEmpty(barcode)) { | 
 |  |  |                 if (barcode.contains("NoRead")) { | 
 |  |  |     public synchronized void agvRestockIntoByHangingWire() { | 
 |  |  |         try { | 
 |  |  |             //检测350和351扫码器 | 
 |  |  |             int[] barcodeStaNo = {11, 12,14,16,18,20};//11 => 350站扫码器,12 => 351站扫码器 | 
 |  |  |             for (int staNo : barcodeStaNo) { | 
 |  |  |                 // 获取条码扫描仪信息 | 
 |  |  |                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); | 
 |  |  |                 if (barcodeThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 String barcode = barcodeThread.getBarcode(); | 
 |  |  |                 if (!Cools.isEmpty(barcode)) { | 
 |  |  |                     if (barcode.contains("NoRead")) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 String agvStaNo = null; | 
 |  |  |                 if (staNo == 11) { | 
 |  |  |                     agvStaNo = "303-1"; | 
 |  |  |                 }else { | 
 |  |  |                     agvStaNo = "304-1"; | 
 |  |  |                     String agvStaNo = null; | 
 |  |  |                     if (staNo == 11) { | 
 |  |  |                         agvStaNo = "303-1"; | 
 |  |  |                     } else if(staNo == 12){ | 
 |  |  |                         agvStaNo = "304-1"; | 
 |  |  |                     } else if(staNo == 14){ | 
 |  |  |                         agvStaNo = "311-1"; | 
 |  |  |                     } else if(staNo == 16){ | 
 |  |  |                         agvStaNo = "313-1"; | 
 |  |  |                     } else if(staNo == 18){ | 
 |  |  |                         agvStaNo = "315-1"; | 
 |  |  |                     } else if(staNo == 20){ | 
 |  |  |                         agvStaNo = "317-1"; | 
 |  |  |                     } | 
 |  |  |                     //通知AGV取货 | 
 |  |  |                     boolean result = agvRestockCall(agvStaNo, barcode); | 
 |  |  |                     if (result) { | 
 |  |  |                         barcodeThread.setBarcode(""); | 
 |  |  |                     } | 
 |  |  |                     log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode); | 
 |  |  |                 } | 
 |  |  |                 //通知AGV取货 | 
 |  |  |                 boolean result = agvRestockCall(agvStaNo, barcode); | 
 |  |  |                 if (result) { | 
 |  |  |                     barcodeThread.setBarcode(""); | 
 |  |  |                 } | 
 |  |  |                 log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * AGV拣料站点信息 | 
 |  |  |      */ | 
 |  |  |     public synchronized void agvCurrentContainerCodeInfoWire() { | 
 |  |  |         try { | 
 |  |  |             //检测350和351扫码器 | 
 |  |  |             int[] barcodeStaNo = {13, 15,17,19};//11 => 350站扫码器,12 => 351站扫码器 | 
 |  |  |             for (int staNo : barcodeStaNo) { | 
 |  |  |                 // 获取条码扫描仪信息 | 
 |  |  |                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); | 
 |  |  |                 if (barcodeThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 String barcode = barcodeThread.getBarcode(); | 
 |  |  |                 if (!Cools.isEmpty(barcode)) { | 
 |  |  |                     if (barcode.contains("NoRead")) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     String agvStaNo = null; | 
 |  |  |                     if (staNo == 13) { | 
 |  |  |                         agvStaNo = "CS-310"; | 
 |  |  |                     } else if(staNo == 15){ | 
 |  |  |                         agvStaNo = "CS-311"; | 
 |  |  |                     } else if(staNo == 17){ | 
 |  |  |                         agvStaNo = "CS-312"; | 
 |  |  |                     } else if(staNo == 19){ | 
 |  |  |                         agvStaNo = "CS-313"; | 
 |  |  |                     } | 
 |  |  |                     //通知WMS当前容器码 | 
 |  |  |                     boolean result = agvCureentCall(agvStaNo, barcode); | 
 |  |  |                     if (result) { | 
 |  |  |                         barcodeThread.setBarcode(""); | 
 |  |  |                     } | 
 |  |  |                     log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 300站拣料 | 
 |  |  |     public void pick300() { | 
 |  |  |         //检测300站是否自动、有物、工作号 | 
 |  |  |         for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |             // 获取入库站信息 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |             StaProtocol staProtocol = devpThread.getStation().get(300); | 
 |  |  |             if (staProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
 |  |  |                 //查询是否有工作档 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                 if (wrkMast == null) { | 
 |  |  |         try { | 
 |  |  |             //检测300站是否自动、有物、工作号 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 // 获取入库站信息 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(300); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 }else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getWrkSts() != 29) {//29.出库完成 | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
 |  |  |                     //查询是否有工作档 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getMk() == null) { | 
 |  |  |                     Integer sourceStaNo = wrkMast.getSourceStaNo();//源站 | 
 |  |  |                     Integer staNo = wrkMast.getStaNo();//目标站 | 
 |  |  |                     //覆盖工作档目标站 | 
 |  |  |                     wrkMast.setStaNo(sourceStaNo); | 
 |  |  |                     wrkMast.setSourceStaNo(staNo); | 
 |  |  |                     wrkMast.setMk("N"); | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                         //向300站写入目标站 | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                         staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//移动到目标站 | 
 |  |  |                         boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                         try { | 
 |  |  |                             Thread.sleep(500); | 
 |  |  |                         } catch (Exception e) { | 
 |  |  |                             e.printStackTrace(); | 
 |  |  |                     if (wrkMast.getWrkSts() != 29) {//29.出库完成 | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (wrkMast.getMk() == null) { | 
 |  |  |                         Integer sourceStaNo = wrkMast.getSourceStaNo();//源站 | 
 |  |  |                         Integer staNo = wrkMast.getStaNo();//目标站 | 
 |  |  |                         //覆盖工作档目标站 | 
 |  |  |                         wrkMast.setStaNo(sourceStaNo); | 
 |  |  |                         wrkMast.setSourceStaNo(staNo); | 
 |  |  |                         wrkMast.setMk("N"); | 
 |  |  |                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
 |  |  |                             //向300站写入目标站 | 
 |  |  |                             staProtocol = staProtocol.clone(); | 
 |  |  |                             staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//移动到目标站 | 
 |  |  |                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                             try { | 
 |  |  |                                 Thread.sleep(500); | 
 |  |  |                             } catch (Exception e) { | 
 |  |  |                                 e.printStackTrace(); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 出库  ===>> 工作档信息写入led显示器 | 
 |  |  |      */ | 
 |  |  |     public void ledExecute() { | 
 |  |  |         for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  |             // 获取输送线plc线程 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
 |  |  |             // 命令集合 | 
 |  |  |             List<LedCommand> commands = new ArrayList<>(); | 
 |  |  |             // 工作档集合 | 
 |  |  |             List<WrkMast> wrkMasts = new ArrayList<>(); | 
 |  |  |             for (Integer staNo : led.getStaArr()) { | 
 |  |  |                 // 获取叉车站点 | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
 |  |  |                 if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { | 
 |  |  |                     continue; | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 // 获取工作档数据 | 
 |  |  |                 WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); | 
 |  |  |                 if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } | 
 |  |  |                 wrkMasts.add(wrkMast); | 
 |  |  |                 // 组装命令 | 
 |  |  |                 LedCommand ledCommand = new LedCommand(); | 
 |  |  |                 ledCommand.setWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                 ledCommand.setIoType(wrkMast.getIoType()); | 
 |  |  |                 // 出库模式 | 
 |  |  |                 switch (wrkMast.getIoType()) { | 
 |  |  |                     case 101: | 
 |  |  |                         ledCommand.setTitle("全板出库"); | 
 |  |  |                         break; | 
 |  |  |                     case 103: | 
 |  |  |                         ledCommand.setTitle("拣料出库"); | 
 |  |  |                         break; | 
 |  |  |                     case 104: | 
 |  |  |                         ledCommand.setTitle("并板出库"); | 
 |  |  |                         break; | 
 |  |  |                     case 107: | 
 |  |  |                         ledCommand.setTitle("盘点出库"); | 
 |  |  |                         break; | 
 |  |  |                     case 110: | 
 |  |  |                         ledCommand.setTitle("空板出库"); | 
 |  |  |                         ledCommand.setEmptyMk(true); | 
 |  |  |                         break; | 
 |  |  |                     default: | 
 |  |  |                         News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); | 
 |  |  |                         break; | 
 |  |  |                 } | 
 |  |  |                 ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); | 
 |  |  |                 ledCommand.setLocNo(wrkMast.getLocNo()); | 
 |  |  |                 ledCommand.setStaNo(wrkMast.getStaNo()); | 
 |  |  |                 if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { | 
 |  |  |                     //for (WrkDetl wrkDetl : wrkDetls) { | 
 |  |  |                     //    LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); | 
 |  |  |                     // | 
 |  |  |                     //    locDetls.forEach(locDetl1 -> { | 
 |  |  |                     //        //工作档中存在该物料则跳过 | 
 |  |  |                     //        String suppCode = ""; | 
 |  |  |                     // | 
 |  |  |                     //        if (wrkDetl.getMatnr().equals(locDetl1.getMatnr())) { | 
 |  |  |                     //            Double anfme = 0D; | 
 |  |  |                     //            if (locDetl != null) { | 
 |  |  |                     //                anfme = locDetl.getAnfme(); | 
 |  |  |                     //            } | 
 |  |  |                     //            if (wrkDetl.getSuppCode() != null) { | 
 |  |  |                     //                suppCode = wrkDetl.getSuppCode(); | 
 |  |  |                     //            } | 
 |  |  |                     //            ledCommand.getMatDtos() | 
 |  |  |                     //                    .add(new MatDto(wrkDetl.getMatnr() | 
 |  |  |                     //                            , wrkDetl.getMaktx() | 
 |  |  |                     //                            , wrkDetl.getAnfme() | 
 |  |  |                     //                            , (wrkDetl.getAnfme()-anfme) | 
 |  |  |                     //                            , wrkDetl.getSpecs() | 
 |  |  |                     //                            , suppCode)); | 
 |  |  |                     //        } else { | 
 |  |  |                     //            if (locDetl1.getSuppCode() != null) { | 
 |  |  |                     //                suppCode = locDetl1.getSuppCode(); | 
 |  |  |                     //            } | 
 |  |  |                     //            ledCommand.getMatDtos() | 
 |  |  |                     //                    .add(new MatDto(locDetl1.getMatnr() | 
 |  |  |                     //                            , locDetl1.getMaktx() | 
 |  |  |                     //                            , 0D | 
 |  |  |                     //                            , locDetl1.getAnfme() | 
 |  |  |                     //                            , locDetl1.getSpecs() | 
 |  |  |                     //                            , suppCode)); | 
 |  |  |                     //        } | 
 |  |  |                     //    }); | 
 |  |  |                     //    //LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); | 
 |  |  |                     //} | 
 |  |  |                     List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); | 
 |  |  |                     locDetls.forEach(locDetl -> { | 
 |  |  |                         Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no",wrkMast.getWrkNo()); | 
 |  |  |                         Utils.wapperSetCondition(wrapper,"batch",locDetl.getBatch()); | 
 |  |  |                         Utils.wapperSetCondition(wrapper,"three_code",locDetl.getThreeCode()); | 
 |  |  |                         Utils.wapperSetCondition(wrapper,"dead_time",locDetl.getDeadTime()); | 
 |  |  |                         Utils.wapperSetCondition(wrapper,"supp_code",locDetl.getSuppCode());//料箱码 | 
 |  |  |                         WrkDetl detl = wrkDetlService.selectOne(wrapper); | 
 |  |  |                         if (Cools.isEmpty(detl)) { | 
 |  |  |                             String suppCode = ""; | 
 |  |  |                             if (locDetl.getSuppCode() != null) { | 
 |  |  |                                 suppCode = locDetl.getSuppCode(); | 
 |  |  |                             } | 
 |  |  |                             ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
 |  |  |                         } else { | 
 |  |  |                             String suppCode = ""; | 
 |  |  |                             if (detl.getSuppCode() != null) { | 
 |  |  |                                 suppCode = detl.getSuppCode(); | 
 |  |  |                             } | 
 |  |  |                             ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode)); | 
 |  |  |         try { | 
 |  |  |             for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  |                 // 获取输送线plc线程 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
 |  |  |                 // 命令集合 | 
 |  |  |                 List<LedCommand> commands = new ArrayList<>(); | 
 |  |  |                 // 工作档集合 | 
 |  |  |                 List<WrkMast> wrkMasts = new ArrayList<>(); | 
 |  |  |                 List<WrkMastLog> wrkMastLogs = new ArrayList<>(); | 
 |  |  |                 for (Integer staNo : led.getStaArr()) { | 
 |  |  |                     // 获取叉车站点 | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
 |  |  |                     if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         staProtocol = staProtocol.clone(); | 
 |  |  |                     } | 
 |  |  |                     // 获取工作档数据 | 
 |  |  |                     WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); | 
 |  |  |                     Integer wrkNo = staProtocol.getWorkNo().intValue(); | 
 |  |  |                     Integer ioType = null; | 
 |  |  |                     String sourceLocNo = null; | 
 |  |  |                     String locNo = null; | 
 |  |  |                     Integer wrkStaNo = null; | 
 |  |  |                     String barcode = null; | 
 |  |  |                     if (wrkMast == null) { | 
 |  |  |                         //查询历史档 | 
 |  |  |                         WrkMastLog wrkMastLog = wrkMastLogMapper.selectLatestByWorkNo(staProtocol.getWorkNo().intValue()); | 
 |  |  |                         if (wrkMastLog == null) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                     }); | 
 |  |  |                 } | 
 |  |  |                 commands.add(ledCommand); | 
 |  |  |             } | 
 |  |  |             Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); | 
 |  |  |             // 获取LED线程 | 
 |  |  |             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
 |  |  |             // 相同工作号集合则过滤 | 
 |  |  |             if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             // 命令下发 ------------------------------------------------------------------------------- | 
 |  |  |             if (!commands.isEmpty()) { | 
 |  |  |                 if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { | 
 |  |  |                     log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                     continue; | 
 |  |  |                 }else { | 
 |  |  |                     ledThread.setLedMk(false); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |                         ioType = wrkMastLog.getIoType(); | 
 |  |  |                         sourceLocNo = wrkMastLog.getSourceLocNo(); | 
 |  |  |                         locNo = wrkMastLog.getLocNo(); | 
 |  |  |                         wrkStaNo = wrkMastLog.getStaNo(); | 
 |  |  |                         barcode = wrkMastLog.getBarcode(); | 
 |  |  |                         wrkMastLogs.add(wrkMastLog); | 
 |  |  |                     }else { | 
 |  |  |                         if (wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                         ioType = wrkMast.getIoType(); | 
 |  |  |                         sourceLocNo = wrkMast.getSourceLocNo(); | 
 |  |  |                         locNo = wrkMast.getLocNo(); | 
 |  |  |                         wrkStaNo = wrkMast.getStaNo(); | 
 |  |  |                         barcode = wrkMast.getBarcode(); | 
 |  |  |                         wrkMasts.add(wrkMast); | 
 |  |  |                     } | 
 |  |  |                     // 组装命令 | 
 |  |  |                     LedCommand ledCommand = new LedCommand(); | 
 |  |  |                     ledCommand.setWorkNo(wrkNo); | 
 |  |  |                     ledCommand.setIoType(ioType); | 
 |  |  |                     // 出库模式 | 
 |  |  |                     switch (ioType) { | 
 |  |  |                         case 101: | 
 |  |  |                             ledCommand.setTitle("全板出库"); | 
 |  |  |                             break; | 
 |  |  |                         case 103: | 
 |  |  |                             ledCommand.setTitle("拣料出库"); | 
 |  |  |                             break; | 
 |  |  |                         case 104: | 
 |  |  |                             ledCommand.setTitle("并板出库"); | 
 |  |  |                             break; | 
 |  |  |                         case 107: | 
 |  |  |                             ledCommand.setTitle("盘点出库"); | 
 |  |  |                             break; | 
 |  |  |                         case 110: | 
 |  |  |                             ledCommand.setTitle("空板出库"); | 
 |  |  |                             ledCommand.setEmptyMk(true); | 
 |  |  |                             break; | 
 |  |  |                         default: | 
 |  |  |                             News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkNo, ioType); | 
 |  |  |                             break; | 
 |  |  |                     } | 
 |  |  |                     ledCommand.setSourceLocNo(sourceLocNo); | 
 |  |  |                     ledCommand.setLocNo(locNo); | 
 |  |  |                     ledCommand.setStaNo(wrkStaNo); | 
 |  |  |                     ledCommand.setBarcode(barcode); | 
 |  |  |                     if (ioType != 110 && ioType != 10) { | 
 |  |  |                         List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
 |  |  |                         if (!wrkDetls.isEmpty()) { | 
 |  |  |                             wrkDetls.forEach(wrkDetl -> { | 
 |  |  |                                 double remainNum = wrkDetl.getStock() - wrkDetl.getAnfme();//剩余数量 | 
 |  |  |                                 if (remainNum < 0) { | 
 |  |  |                                     remainNum = 0; | 
 |  |  |                                 } | 
 |  |  |                                 String matnr = wrkDetl.getMatnr(); | 
 |  |  |                                 Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); | 
 |  |  |                                 if (mat != null) { | 
 |  |  |                                     if (!mat.getMatnr().equals(mat.getMatnr2())) { | 
 |  |  |                                         matnr += " - " + mat.getMatnr2(); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                                 ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetl.getMaktx(), wrkDetl.getAnfme(), remainNum, wrkDetl.getSpecs(), wrkDetl.getSuppCode(), wrkDetl.getOrderNo())); | 
 |  |  |                             }); | 
 |  |  |                         }else { | 
 |  |  |                             List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode); | 
 |  |  |                             for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { | 
 |  |  |                                 double remainNum = wrkDetlLog.getStock() - wrkDetlLog.getAnfme();//剩余数量 | 
 |  |  |                                 if (remainNum < 0) { | 
 |  |  |                                     remainNum = 0; | 
 |  |  |                                 } | 
 |  |  |                                 String matnr = wrkDetlLog.getMatnr(); | 
 |  |  |                                 Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr()); | 
 |  |  |                                 if (mat != null) { | 
 |  |  |                                     if (!mat.getMatnr().equals(mat.getMatnr2())) { | 
 |  |  |                                         matnr += " - " + mat.getMatnr2(); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                                 ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), remainNum, wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode())); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |             try { | 
 |  |  |                 // 修改主档led标记 | 
 |  |  |                 for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                     wrkMast.setOveMk("Y"); | 
 |  |  |                     wrkMast.setModiTime(new Date()); | 
 |  |  |                     if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  |                         throw new CoolException("更新工作档失败"); | 
 |  |  | //                        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); | 
 |  |  | //                        if (ioType == 101) { | 
 |  |  | //                            List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
 |  |  | //                            wrkDetls.forEach(wrkDetl -> { | 
 |  |  | //                                ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), 0D, wrkDetl.getSpecs(), wrkDetl.getSuppCode())); | 
 |  |  | //                            }); | 
 |  |  | ////                            locDetls.forEach(locDetl -> { | 
 |  |  | ////                                Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo); | 
 |  |  | ////                                Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); | 
 |  |  | ////                                Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); | 
 |  |  | ////                                Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); | 
 |  |  | ////                                Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//料箱码 | 
 |  |  | ////                                List<WrkDetl> detl = wrkDetlService.selectList(wrapper); | 
 |  |  | ////                                if (Cools.isEmpty(detl)) { | 
 |  |  | ////                                    String suppCode = ""; | 
 |  |  | ////                                    if (locDetl.getSuppCode() != null) { | 
 |  |  | ////                                        suppCode = locDetl.getSuppCode(); | 
 |  |  | ////                                    } | 
 |  |  | ////                                    ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
 |  |  | ////                                } else { | 
 |  |  | ////                                    //出库数量累计 | 
 |  |  | ////                                    Double conut = 0.0; | 
 |  |  | ////                                    for (WrkDetl wrkDetl : detl) { | 
 |  |  | ////                                        conut = conut + wrkDetl.getAnfme(); | 
 |  |  | ////                                    } | 
 |  |  | //// | 
 |  |  | ////                                    for (WrkDetl wrkDetl : detl) { | 
 |  |  | ////                                        String suppCode = ""; | 
 |  |  | ////                                        if (wrkDetl.getSuppCode() != null) { | 
 |  |  | ////                                            suppCode = wrkDetl.getSuppCode(); | 
 |  |  | ////                                        } | 
 |  |  | ////                                        ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (locDetl.getAnfme() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo())); | 
 |  |  | ////                                    } | 
 |  |  | ////                                } | 
 |  |  | //// | 
 |  |  | ////                            }); | 
 |  |  | //                        } else { | 
 |  |  | //                            locDetls.forEach(locDetl -> { | 
 |  |  | //                                Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo); | 
 |  |  | //                                Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); | 
 |  |  | //                                Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); | 
 |  |  | //                                Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); | 
 |  |  | //                                Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//料箱码 | 
 |  |  | //                                List<WrkDetl> detl = wrkDetlService.selectList(wrapper); | 
 |  |  | //                                if (Cools.isEmpty(detl)) { | 
 |  |  | //                                    String suppCode = ""; | 
 |  |  | //                                    if (locDetl.getSuppCode() != null) { | 
 |  |  | //                                        suppCode = locDetl.getSuppCode(); | 
 |  |  | //                                    } | 
 |  |  | //                                    ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
 |  |  | //                                } else { | 
 |  |  | //                                    //出库数量累计 | 
 |  |  | //                                    Double conut = 0.0; | 
 |  |  | //                                    for (WrkDetl wrkDetl : detl) { | 
 |  |  | //                                        conut = conut + wrkDetl.getAnfme(); | 
 |  |  | //                                    } | 
 |  |  | // | 
 |  |  | //                                    for (WrkDetl wrkDetl : detl) { | 
 |  |  | //                                        String suppCode = ""; | 
 |  |  | //                                        if (wrkDetl.getSuppCode() != null) { | 
 |  |  | //                                            suppCode = wrkDetl.getSuppCode(); | 
 |  |  | //                                        } | 
 |  |  | //                                        ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (wrkDetl.getStock() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo())); | 
 |  |  | //                                    } | 
 |  |  | //                                } | 
 |  |  | // | 
 |  |  | //                            }); | 
 |  |  | //                        } | 
 |  |  | // | 
 |  |  | // | 
 |  |  | //                        if (ioType == 107) { | 
 |  |  | //                            locDetls = new ArrayList<>(); | 
 |  |  | //                            ledCommand.setMatDtos(new ArrayList<>()); | 
 |  |  | //                        } | 
 |  |  | // | 
 |  |  | //                        if (locDetls.isEmpty() && ioType != 101) { | 
 |  |  | //                            List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
 |  |  | //                            wrkDetls.forEach(wrkDetl -> { | 
 |  |  | //                                if (wrkDetl.getAnfme() > 0D) { | 
 |  |  | //                                    ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode())); | 
 |  |  | //                                } | 
 |  |  | //                            }); | 
 |  |  | // | 
 |  |  | //                            if (wrkDetls.isEmpty()) {//从历史档查询 | 
 |  |  | //                                List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode); | 
 |  |  | //                                for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { | 
 |  |  | //                                    if (wrkDetlLog.getAnfme() > 0D) { | 
 |  |  | //                                        ledCommand.getMatDtos().add(new MatDto(wrkDetlLog.getMatnr(), wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), wrkDetlLog.getAnfme(), wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode())); | 
 |  |  | //                                    } | 
 |  |  | //                                } | 
 |  |  | //                            } | 
 |  |  | //                        } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     commands.add(ledCommand); | 
 |  |  |                 } | 
 |  |  |                 Set<Integer> workNos = null; | 
 |  |  |                 if (!wrkMasts.isEmpty()) { | 
 |  |  |                     workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); | 
 |  |  |                 }else { | 
 |  |  |                     workNos = wrkMastLogs.stream().map(WrkMastLog::getWrkNo).collect(Collectors.toSet()); | 
 |  |  |                 } | 
 |  |  |                 // 获取LED线程 | 
 |  |  |                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
 |  |  |                 // 相同工作号集合则过滤 | 
 |  |  |                 if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 // 命令下发 ------------------------------------------------------------------------------- | 
 |  |  |                 if (!commands.isEmpty()) { | 
 |  |  |                     if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { | 
 |  |  |                         log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                         continue; | 
 |  |  |                     } else { | 
 |  |  |                         ledThread.setLedMk(false); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 // 更新线程当前工作号集合 | 
 |  |  |                 ledThread.setWorkNos(workNos); | 
 |  |  |                 try { | 
 |  |  |                     // 修改主档led标记 | 
 |  |  |                     for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                         wrkMast.setOveMk("Y"); | 
 |  |  |                         wrkMast.setModiTime(new Date()); | 
 |  |  |                         if (wrkMastMapper.updateById(wrkMast) == 0) { | 
 |  |  |                             throw new CoolException("更新工作档失败"); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |             } catch (Exception e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                     // 更新线程当前工作号集合 | 
 |  |  |                     ledThread.setWorkNos(workNos); | 
 |  |  |  | 
 |  |  |                 } catch (Exception e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 其他  ===>> LED显示器复位,显示默认信息 | 
 |  |  |      */ | 
 |  |  |     public void ledReset() { | 
 |  |  | //        for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  |         try { | 
 |  |  |             //        for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  | // | 
 |  |  | //            // 获取输送线plc线程 | 
 |  |  | //            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
 |  |  | 
 |  |  | //                } | 
 |  |  | //            } | 
 |  |  | //        } | 
 |  |  |         for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  |             // 获取输送线plc线程 | 
 |  |  |             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
 |  |  |             // 命令集合 | 
 |  |  |             boolean reset = true; | 
 |  |  |             for (Integer staNo : led.getStaArr()) { | 
 |  |  |                 // 获取叉车站点 | 
 |  |  |                 StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
 |  |  |                 if (staProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |             for (LedSlave led : slaveProperties.getLed()) { | 
 |  |  |                 // 获取输送线plc线程 | 
 |  |  |                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
 |  |  |                 // 命令集合 | 
 |  |  |                 boolean reset = true; | 
 |  |  |                 for (Integer staNo : led.getStaArr()) { | 
 |  |  |                     // 获取叉车站点 | 
 |  |  |                     StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
 |  |  |                     if (staProtocol == null) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |                     if (staProtocol.isLoading()) { | 
 |  |  |                         reset = false; | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 if (staProtocol.isLoading()) { | 
 |  |  |                     reset = false; | 
 |  |  |                     break; | 
 |  |  |                 // 获取led线程 | 
 |  |  |                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
 |  |  |                 // led显示默认内容 | 
 |  |  |                 if (reset) { | 
 |  |  |                     ledThread.setLedMk(true); | 
 |  |  |                     if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { | 
 |  |  |                         log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             // 获取led线程 | 
 |  |  |             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
 |  |  |             // led显示默认内容 | 
 |  |  |             if (reset && !ledThread.isLedMk()) { | 
 |  |  |                 ledThread.setLedMk(true); | 
 |  |  |                 if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { | 
 |  |  |                     log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 四向穿梭车电量检测 ===>> 发起充电 | 
 |  |  |      */ | 
 |  |  |     public synchronized void loopShuttleCharge() { | 
 |  |  |         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |             //获取四向穿梭车线程 | 
 |  |  |             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
 |  |  |             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |             if (shuttleProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //判断当前小车是否满足需要充电要求 | 
 |  |  |             if (!shuttleProtocol.isRequireCharge()) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttleProtocol.getShuttleNo().intValue()); | 
 |  |  |             if (wrkCharge != null) {//已有充电任务 | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //小车所在楼层 | 
 |  |  |             int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); | 
 |  |  |             ShuttleChargeType shuttleCharge = null; | 
 |  |  |  | 
 |  |  |             //搜索小车所在楼层有没有充电桩 | 
 |  |  |             for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { | 
 |  |  |                 if (lev != Utils.getLev(chargeType.locNo)) { | 
 |  |  |                     continue;//小车和充电桩不在同一层 | 
 |  |  |         try { | 
 |  |  |             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |                 //获取四向穿梭车线程 | 
 |  |  |                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
 |  |  |                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |                 if (shuttleProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //小车和充电桩在同一层 | 
 |  |  |                 if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
 |  |  |                     shuttleCharge = chargeType; | 
 |  |  |                     break; | 
 |  |  |                 //判断当前小车是否满足需要充电要求 | 
 |  |  |                 if (!shuttleProtocol.isRequireCharge()) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (shuttleCharge == null) { | 
 |  |  |                 //同楼层没有找到充电桩,找可用充电桩 | 
 |  |  |                 //小车同楼层没有充电桩,只要充电桩可用就生成充电任务 | 
 |  |  |                 WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttleProtocol.getShuttleNo().intValue()); | 
 |  |  |                 if (wrkCharge != null) {//已有充电任务 | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //小车所在楼层 | 
 |  |  |                 int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); | 
 |  |  |                 ShuttleChargeType shuttleCharge = null; | 
 |  |  |  | 
 |  |  |                 //搜索小车所在楼层有没有充电桩 | 
 |  |  |                 for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { | 
 |  |  |                     if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
 |  |  |                         //判断当前充电桩楼层是否有小车,如有小车,不分配该充电桩 | 
 |  |  |                         int chargeLev = Utils.getLev(chargeType.locNo);//充电桩楼层 | 
 |  |  |                         boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//检测楼层是否有穿梭车 | 
 |  |  |                         if (checkLevHasShuttle) { | 
 |  |  |                             //当前充电桩楼层有穿梭车,不分配该充电桩 | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |                     if (lev != Utils.getLev(chargeType.locNo)) { | 
 |  |  |                         continue;//小车和充电桩不在同一层 | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //小车和充电桩在同一层 | 
 |  |  |                     if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
 |  |  |                         shuttleCharge = chargeType; | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (shuttleCharge == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 if (shuttleCharge == null) { | 
 |  |  |                     //同楼层没有找到充电桩,找可用充电桩 | 
 |  |  |                     //小车同楼层没有充电桩,只要充电桩可用就生成充电任务 | 
 |  |  |                     for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { | 
 |  |  |                         if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
 |  |  |                             //判断当前充电桩楼层是否有小车,如有小车,不分配该充电桩 | 
 |  |  |                             int chargeLev = Utils.getLev(chargeType.locNo);//充电桩楼层 | 
 |  |  |                             boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//检测楼层是否有穿梭车 | 
 |  |  |                             if (checkLevHasShuttle) { | 
 |  |  |                                 //当前充电桩楼层有穿梭车,不分配该充电桩 | 
 |  |  |                                 continue; | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  |             String chargeLocNo = shuttleCharge.locNo; | 
 |  |  |             wrkCharge = new WrkCharge(); | 
 |  |  |             wrkCharge.setShuttleNo(shuttle.getId()); | 
 |  |  |             wrkCharge.setCharge(shuttleCharge.id); | 
 |  |  |             wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); | 
 |  |  |             wrkCharge.setWrkSts(51L);   // 51.准备充电 | 
 |  |  |             wrkCharge.setIoPri((double) 10); | 
 |  |  |             wrkCharge.setLocNo(chargeLocNo); | 
 |  |  |             wrkCharge.setMemo("charge"); | 
 |  |  |             wrkCharge.setAppeTime(new Date()); | 
 |  |  |             if (!wrkChargeService.insert(wrkCharge)) { | 
 |  |  |                 News.error("保存{}号四向穿梭车充电任务失败!!!", shuttle.getId()); | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                             shuttleCharge = chargeType; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             News.info("保存{}号四向穿梭车充电任务成功!!!", shuttle.getId()); | 
 |  |  |                 if (shuttleCharge == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 String chargeLocNo = shuttleCharge.locNo; | 
 |  |  |                 wrkCharge = new WrkCharge(); | 
 |  |  |                 wrkCharge.setShuttleNo(shuttle.getId()); | 
 |  |  |                 wrkCharge.setCharge(shuttleCharge.id); | 
 |  |  |                 wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); | 
 |  |  |                 wrkCharge.setWrkSts(51L);   // 51.准备充电 | 
 |  |  |                 wrkCharge.setIoPri((double) 10); | 
 |  |  |                 wrkCharge.setLocNo(chargeLocNo); | 
 |  |  |                 wrkCharge.setMemo("charge"); | 
 |  |  |                 wrkCharge.setAppeTime(new Date()); | 
 |  |  |                 if (!wrkChargeService.insert(wrkCharge)) { | 
 |  |  |                     News.error("保存{}号四向穿梭车充电任务失败!!!", shuttle.getId()); | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 News.info("保存{}号四向穿梭车充电任务成功!!!", shuttle.getId()); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * 执行四向穿梭车充电任务 | 
 |  |  |      */ | 
 |  |  |     public synchronized void executeShuttleCharge() { | 
 |  |  |         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |             WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); | 
 |  |  |             if (wrkCharge == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); | 
 |  |  |             if (shuttleThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |             if (shuttleProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (wrkCharge.getWrkSts() == 51) { | 
 |  |  |                 if (!shuttleProtocol.isIdleNoCharge()) { | 
 |  |  |         try { | 
 |  |  |             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |                 WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); | 
 |  |  |                 if (wrkCharge == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) { | 
 |  |  |                     //小车不在充电桩位置 | 
 |  |  |                     shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//调度小车去充电桩 | 
 |  |  |                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); | 
 |  |  |                 if (shuttleThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |                 if (shuttleProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //小车已经在充电桩位置,下发充电命令 | 
 |  |  |                 NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), true); | 
 |  |  |                 ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
 |  |  |                 commands.add(chargeCommand); | 
 |  |  |                 //创建分配命令 | 
 |  |  |                 ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
 |  |  |                 assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
 |  |  |                 assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
 |  |  |                 assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
 |  |  |                 assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
 |  |  |                 assignCommand.setCommands(commands);//运行命令 | 
 |  |  |  | 
 |  |  |                 wrkCharge.setWrkSts(52L);//51.生成充电任务 => 52.小车去充电中 | 
 |  |  |                 wrkCharge.setModiTime(new Date()); | 
 |  |  |                 if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
 |  |  |                     //下发任务 | 
 |  |  |                     MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
 |  |  |                 } | 
 |  |  |             } 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; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //小车满电,结束充电任务 | 
 |  |  |                 NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false); | 
 |  |  |                 ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
 |  |  |                 commands.add(chargeCommand); | 
 |  |  |                 //创建分配命令 | 
 |  |  |                 ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
 |  |  |                 assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
 |  |  |                 assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
 |  |  |                 assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
 |  |  |                 assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
 |  |  |                 assignCommand.setCommands(commands);//运行命令 | 
 |  |  |  | 
 |  |  |                 //下发任务 | 
 |  |  |                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
 |  |  |                 try { | 
 |  |  |                     Thread.sleep(3000); | 
 |  |  |                 } catch (Exception e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 wrkCharge.setWrkSts(53L);//52.小车去充电中 => 53.小车充电完成 | 
 |  |  |                 wrkCharge.setModiTime(new Date()); | 
 |  |  |                 if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
 |  |  |                     shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id); | 
 |  |  |                     shuttleProtocol.setTaskNo(0); | 
 |  |  |                     shuttleProtocol.setPakMk(false); | 
 |  |  |                 } | 
 |  |  |             } else if (wrkCharge.getWrkSts() == 53) { | 
 |  |  |                 if (shuttleProtocol.getChargState() == 0) {//小车处于未充电状态 | 
 |  |  |                     boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread); | 
 |  |  |                     if (!result) { | 
 |  |  |                 if (wrkCharge.getWrkSts() == 51) { | 
 |  |  |                     if (!shuttleProtocol.isIdleNoCharge()) { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     wrkCharge.setWrkSts(60L);//53.小车充电完成 => 60.充电任务完成 | 
 |  |  |                     if (shuttleProtocol.getSuspendState() == 1) { | 
 |  |  |                         continue;//管制中 | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) { | 
 |  |  |                         //小车不在充电桩位置 | 
 |  |  |                         shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//调度小车去充电桩 | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //小车已经在充电桩位置,下发充电命令 | 
 |  |  |                     NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), true); | 
 |  |  |                     ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
 |  |  |                     commands.add(chargeCommand); | 
 |  |  |                     //创建分配命令 | 
 |  |  |                     ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
 |  |  |                     assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
 |  |  |                     assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
 |  |  |                     assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
 |  |  |                     assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
 |  |  |                     assignCommand.setCommands(commands);//运行命令 | 
 |  |  |  | 
 |  |  |                     wrkCharge.setWrkSts(52L);//51.生成充电任务 => 52.小车去充电中 | 
 |  |  |                     wrkCharge.setModiTime(new Date()); | 
 |  |  |                     if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
 |  |  |                         //下发任务 | 
 |  |  |                         MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
 |  |  |                     } | 
 |  |  |                 } 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; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //***************判断是否满充校准*************** | 
 |  |  |                     EntityWrapper<Config> wrapper1 = new EntityWrapper<>(); | 
 |  |  |                     wrapper.eq("code", "shuttleMaxPowerVerify"); | 
 |  |  |                     Config config1 = configService.selectOne(wrapper1); | 
 |  |  |                     if (config1 != null) { | 
 |  |  |                         if (config1.getValue().equals("true")) { | 
 |  |  |                             if (shuttleProtocol.getVoltage() < 5630) { | 
 |  |  |                                 continue;//电压不够继续充电 | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     //***************判断是否满充校准*************** | 
 |  |  |  | 
 |  |  |                     //小车满电,结束充电任务 | 
 |  |  |                     NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false); | 
 |  |  |                     ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
 |  |  |                     commands.add(chargeCommand); | 
 |  |  |                     //创建分配命令 | 
 |  |  |                     ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
 |  |  |                     assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
 |  |  |                     assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
 |  |  |                     assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
 |  |  |                     assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
 |  |  |                     assignCommand.setCommands(commands);//运行命令 | 
 |  |  |  | 
 |  |  |                     //下发任务 | 
 |  |  |                     MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
 |  |  |                     try { | 
 |  |  |                         Thread.sleep(3000); | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         e.printStackTrace(); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     wrkCharge.setWrkSts(53L);//52.小车去充电中 => 53.小车充电完成 | 
 |  |  |                     wrkCharge.setModiTime(new Date()); | 
 |  |  |                     if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
 |  |  |                         shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id); | 
 |  |  |                         shuttleProtocol.setTaskNo(0); | 
 |  |  |                         shuttleProtocol.setPakMk(false); | 
 |  |  |                     } | 
 |  |  |                 } else if (wrkCharge.getWrkSts() == 53) { | 
 |  |  |                     if (shuttleProtocol.getChargState() == 0) {//小车处于未充电状态 | 
 |  |  |                         boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread); | 
 |  |  |                         if (!result) { | 
 |  |  |                             continue; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         wrkCharge.setWrkSts(60L);//53.小车充电完成 => 60.充电任务完成 | 
 |  |  |                         wrkCharge.setModiTime(new Date()); | 
 |  |  |                         if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
 |  |  |  | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 执行小车移库任务 | 
 |  |  |      */ | 
 |  |  |     public synchronized void shuttleMoveExecute() { | 
 |  |  |         //查询小车移库任务 | 
 |  |  |         List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk(); | 
 |  |  |         for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |             boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//小车移动到站点 | 
 |  |  |             if (!stepMoveSta) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |         try { | 
 |  |  |             //查询小车移库任务 | 
 |  |  |             List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk(); | 
 |  |  |             for (WrkMast wrkMast : wrkMasts) { | 
 |  |  |                 boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//小车移动到站点 | 
 |  |  |                 if (!stepMoveSta) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//小车迁入提升机 | 
 |  |  |             if (!stepIntoLift) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//小车迁入提升机 | 
 |  |  |                 if (!stepIntoLift) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//提升机搬运中 | 
 |  |  |             if (!stepLiftMove) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//提升机搬运中 | 
 |  |  |                 if (!stepLiftMove) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//小车迁出提升机 | 
 |  |  |             if (!stepOutLift) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//小车迁出提升机 | 
 |  |  |                 if (!stepOutLift) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//小车移动到目标库位中 | 
 |  |  |             if (!stepMoveLoc) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |                 boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//小车移动到目标库位中 | 
 |  |  |                 if (!stepMoveLoc) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 return false;//检测目标站点路径是否未被占用 | 
 |  |  |             } | 
 |  |  |             //尝试锁定目标站路径 | 
 |  |  |             boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, true);//所使用的路径进行锁定禁用 | 
 |  |  |             boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo().intValue(), targetNodes, true);//所使用的路径进行锁定禁用 | 
 |  |  |             if (!result2) { | 
 |  |  |                 News.info("{}任务,{}小车,路径锁定失败,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
 |  |  |                 return false;//路径锁定失败 | 
 |  |  | 
 |  |  |  | 
 |  |  |             //获取小车到输送站点行走命令 | 
 |  |  |             NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id); | 
 |  |  |             if (result == null) { | 
 |  |  |                 //路径获取失败,需要解锁上面锁定的路径 | 
 |  |  |                 //尝试解锁目标站路径 | 
 |  |  |                 boolean result3 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo().intValue(), targetNodes, false);//所使用的路径进行解锁 | 
 |  |  |                 if (!result3) { | 
 |  |  |                     News.info("{}任务,{}小车,路径解锁失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
 |  |  |                     return false;//路径解锁失败 | 
 |  |  |                 } | 
 |  |  |                 News.info("{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
 |  |  |                 return false;//路径解锁失败 | 
 |  |  |             } | 
 |  |  |             List<NyShuttleHttpCommand> commands = result.getCommands(); | 
 |  |  |  | 
 |  |  |             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
 |  |  | 
 |  |  |                 //获取提升机命令,调度提升机到源站位置 | 
 |  |  |                 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo()); | 
 |  |  |  | 
 |  |  |                 Random random = new Random(); | 
 |  |  |                 int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//获取设备工作号 | 
 |  |  |                 int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号 | 
 |  |  |                 BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(String.valueOf(deviceWrk), liftThread.getSlave().getId()); | 
 |  |  |                 if (basLiftOpt != null) { | 
 |  |  |                     News.info("{}任务,{}号提升机,设备工作号出现重复情况,请联系技术人员支持。", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
 |  |  |                     return false; | 
 |  |  |                 } | 
 |  |  |                 liftCommand.setTaskNo((short) deviceWrk);//更换随机任务号 | 
 |  |  |  | 
 |  |  |                 ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
 |  |  | 
 |  |  |  | 
 |  |  |                 if (wrkMast.getWrkSts() == 111) { | 
 |  |  |                     // 保存工作主档历史档 | 
 |  |  |                     if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) { | 
 |  |  |                     if (wrkMastLogMapper.save(wrkMast.getWrkNo()) <= 0) { | 
 |  |  |                         log.info("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
 |  |  |                     } | 
 |  |  |                     // 删除工作主档 | 
 |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 出入库模式切换 | 
 |  |  |      */ | 
 |  |  |     public synchronized void outAndIn() { | 
 |  |  |     //扫描设备PakMk标记是否超时 | 
 |  |  |     public synchronized void scanDevicePakMk() { | 
 |  |  |         try { | 
 |  |  |             // 根据输送线plc遍历 | 
 |  |  |             for (DevpSlave devp : slaveProperties.getDevp()) { | 
 |  |  |                 for (DevpSlave.Sta inSta : devp.getInSta()) { | 
 |  |  |                     Thread.sleep(500); | 
 |  |  |                     boolean a=true,b=true; | 
 |  |  |                     List<WrkMast> wrkMasts = wrkMastMapper.selectAll(inSta.getStaNo()); | 
 |  |  |                     if (Cools.isEmpty(wrkMasts)){ | 
 |  |  |                         b=false; | 
 |  |  |                     }else { | 
 |  |  |                         for (WrkMast wrkMast:wrkMasts){ | 
 |  |  |                             if (wrkMast.getSourceStaNo() > wrkMast.getStaNo()){ | 
 |  |  |                                 a=false; | 
 |  |  |                                 break; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     switch (inSta.getStaNo()) { | 
 |  |  |                         case 102://1F | 
 |  |  |                             if (a && b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 11)); | 
 |  |  |                             }else if (b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 12)); | 
 |  |  |                             }else { | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 10)); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         case 202://2F | 
 |  |  |                             if (a && b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 21)); | 
 |  |  |                             }else if (b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 22)); | 
 |  |  |                             }else { | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 20)); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                         case 302://3F | 
 |  |  |                             if (a && b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 31)); | 
 |  |  |                             }else if (b){ | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 32)); | 
 |  |  |                             }else { | 
 |  |  |                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 30)); | 
 |  |  |                             } | 
 |  |  |                             break; | 
 |  |  |                     } | 
 |  |  |             //扫描小车 | 
 |  |  |             for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
 |  |  |                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
 |  |  |                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
 |  |  |                 if (shuttleProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000 * 60 * 5)) && shuttleProtocol.getPakMk()) { | 
 |  |  |                     //设备超过5分钟还没复位标记 | 
 |  |  |                     shuttleProtocol.setPakMk(false);//复位标记 | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //扫描提升机 | 
 |  |  |             for (LiftSlave slave : slaveProperties.getLift()) { | 
 |  |  |                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); | 
 |  |  |                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
 |  |  |                 if (liftProtocol == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000 * 60 * 5)) && liftProtocol.getPakMk()) { | 
 |  |  |                     //设备超过5分钟还没复位标记 | 
 |  |  |                     liftProtocol.setPakMk(false);//复位标记 | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |