|  |  | 
 |  |  |                     } | 
 |  |  |                 } else { | 
 |  |  |                     // 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)); | 
 |  |  |                     } | 
 |  |  | //                    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; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | 
 |  |  |                                 .build() | 
 |  |  |                                 .doPost(); | 
 |  |  |                         JSONObject jsonObject = JSON.parseObject(response); | 
 |  |  | //                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  |                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
 |  |  | //                        Integer code = jsonObject.getInteger("code"); | 
 |  |  |                         if (jsonObject.getInteger("code").equals(200)) { | 
 |  |  |                             StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
 |  |  | 
 |  |  |                             staProtocol.setWorkNo(dto.getWorkNo().shortValue()); | 
 |  |  |                             staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
 |  |  |                             devpThread.setPakMk(staProtocol.getSiteId(), false); | 
 |  |  |                             ledThread.errorReset(); | 
 |  |  |                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
 |  |  |                             if (!result) { | 
 |  |  |                                 throw new CoolException("更新plc站点信息失败"); | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); | 
 |  |  |                 ledCommand.setStaNo(wrkMast.getStaNo()); | 
 |  |  |                 ledCommand.setBarcode(wrkMast.getBarcode()); | 
 |  |  |                 if (wrkMast.getIoType() != 110) { | 
 |  |  |                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
 |  |  |                     wrkDetls.forEach(wrkDetl -> { | 
 |  |  | 
 |  |  |             // led显示默认内容 | 
 |  |  |             if (reset) { | 
 |  |  |                 if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { | 
 |  |  |                     News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                     News.error("{}号LED命令下发失败1565!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 
 |  |  | 
 |  |  | public class MatDto { | 
 |  |  |  | 
 |  |  |     // 物料编号 | 
 |  |  |     private String matNo; | 
 |  |  |     private String matnr; | 
 |  |  |  | 
 |  |  |     // 物料名称 | 
 |  |  |     private String maknx; | 
 |  |  | 
 |  |  |     public MatDto() { | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public MatDto(String matNo, String maknx, Double count) { | 
 |  |  |         this.matNo = matNo; | 
 |  |  |     public MatDto(String matnr, String maknx, Double count) { | 
 |  |  |         this.matnr = matnr; | 
 |  |  |         this.maknx = maknx; | 
 |  |  |         this.count = count; | 
 |  |  |     } | 
 
 |  |  | 
 |  |  |         log.info("初始化条码扫描仪线程..................................................."); | 
 |  |  |         for (Slave barcode : slaveProperties.getBarcode()) { | 
 |  |  |             BarcodeThread barcodeThread = new BarcodeThread(barcode); | 
 |  |  |             if(barcode.getId() > 6) | 
 |  |  |             {//1到6号扫码器数据从PLC中获取,无需start | 
 |  |  |                 new Thread(barcodeThread).start(); | 
 |  |  |             } | 
 |  |  |             new Thread(barcodeThread).start(); | 
 |  |  |             SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread); | 
 |  |  |         } | 
 |  |  | //        for (Slave barcode : slaveProperties.getBarcode()) { | 
 |  |  | //            BarcodeThread barcodeThread = new BarcodeThread(barcode); | 
 |  |  | //            if(barcode.getId() > 6) | 
 |  |  | //            {//1到6号扫码器数据从PLC中获取,无需start | 
 |  |  | //                new Thread(barcodeThread).start(); | 
 |  |  | //            } | 
 |  |  | //            SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread); | 
 |  |  | //        } | 
 |  |  |         // 初始化LED线程 | 
 |  |  |         log.info("初始化LED线程..................................................."); | 
 |  |  |         for (LedSlave led : slaveProperties.getLed()) { | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     private String sourceLocNo; | 
 |  |  |  | 
 |  |  |     private String barcode; | 
 |  |  |  | 
 |  |  |     private List<MatDto> matDtos = new ArrayList<>(); | 
 |  |  |  | 
 |  |  |     private boolean emptyMk = false; | 
 
 |  |  | 
 |  |  |             sb.append("目标站:").append(command.getStaNo()).append("\n"); | 
 |  |  |             if (!command.isEmptyMk()) { | 
 |  |  |                 for (MatDto matDto : command.getMatDtos()) { | 
 |  |  |                     sb.append(matDto.getMatNo()).append("-").append(matDto.getMaknx()).append("\n"); | 
 |  |  |                     sb.append(matDto.getMatnr()).append("-").append(matDto.getMaknx()).append("\n"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             sb.append("\n"); | 
 
 |  |  | 
 |  |  |             log.error("堆垛机写入命令为空"); | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |         // 向堆垛机发任务前的堆垛机状态 | 
 |  |  |         try{ | 
 |  |  |             OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24); | 
 |  |  |             if (resultRead.IsSuccess) { | 
 |  |  |                 CrnCommand one = new CrnCommand(); | 
 |  |  |                 one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); | 
 |  |  |                 one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); | 
 |  |  |                 one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); | 
 |  |  |                 one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); | 
 |  |  |                 one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); | 
 |  |  |                 one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); | 
 |  |  |                 one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); | 
 |  |  |                 one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); | 
 |  |  |                 if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) | 
 |  |  |                         || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) | 
 |  |  |                         || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) | 
 |  |  |                         || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) | 
 |  |  |                 ){ | 
 |  |  |                     log.error("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); | 
 |  |  |                     log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command)); | 
 |  |  |                     MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command)); | 
 |  |  |                     Thread.sleep(100); | 
 |  |  |                     readStatus(); | 
 |  |  |                     return false; | 
 |  |  |                 } else { | 
 |  |  |                     log.info("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("堆垛机命令地址写入后回读出错"); | 
 |  |  |         } | 
 |  |  | //        convertRow(command); | 
 |  |  |         command.setCrnNo(slave.getId()); | 
 |  |  | //        short[] array = new short[10]; | 
 |  |  | 
 |  |  |         array[9] = command.getCommand(); | 
 |  |  |         array[10] = command.getLocType1();   //新增货物类型下发 | 
 |  |  |         OperateResult result = siemensNet.Write("DB100.0", array); | 
 |  |  |         log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), array); | 
 |  |  |  | 
 |  |  |         if(!result.IsSuccess){ | 
 |  |  |             log.error("写入堆垛机plc数据失败,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command)); | 
 |  |  |             MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command)); | 
 |  |  |             Thread.sleep(100); | 
 |  |  |             readStatus(); | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //堆垛机任务写入后,回读一次,看是否成功 | 
 |  |  |         Thread.sleep(200); | 
 |  |  |         try{ | 
 |  |  |             OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24); | 
 |  |  |             if (resultRead.IsSuccess) { | 
 |  |  |                 CrnCommand one = new CrnCommand(); | 
 |  |  |                 one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); | 
 |  |  |                 one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); | 
 |  |  |                 one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); | 
 |  |  |                 one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); | 
 |  |  |                 one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); | 
 |  |  |                 one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); | 
 |  |  |                 one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); | 
 |  |  |                 one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); | 
 |  |  |                 if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) | 
 |  |  |                         || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) | 
 |  |  |                         || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) | 
 |  |  |                         || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) | 
 |  |  |                 ){ | 
 |  |  |                     log.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); | 
 |  |  |                     log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command)); | 
 |  |  |                     MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command)); | 
 |  |  |                     Thread.sleep(100); | 
 |  |  |                     readStatus(); | 
 |  |  |                     return false; | 
 |  |  |                 } else { | 
 |  |  |                     log.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             log.error("堆垛机命令地址写入后回读出错"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (command.getAckFinish() == 0) { | 
 |  |  |             short commandFinish = 1; | 
 
 |  |  | 
 |  |  |   # LED1 | 
 |  |  |   led[0]: | 
 |  |  |     id: 1 | 
 |  |  |     ip: 10.10.10.221 | 
 |  |  |     ip: 10.10.10.220 | 
 |  |  |     port: 5005 | 
 |  |  |     devpPlcId: ${wcs-slave.devp[0].id} | 
 |  |  |     staArr: 100 | 
 |  |  |   # LED2 | 
 |  |  |   led[1]: | 
 |  |  |     id: 2 | 
 |  |  |     ip: 10.10.10.222 | 
 |  |  |     ip: 10.10.10.221 | 
 |  |  |     port: 5005 | 
 |  |  |     devpPlcId: ${wcs-slave.devp[0].id} | 
 |  |  |     staArr: 103 | 
 
 |  |  | 
 |  |  |                         offSet = 1710; //145 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                         crnEl.animate({left: offSet + 'px'}, 1000); | 
 |  |  |                         // if(crns[i].bay === 1){ | 
 |  |  |                         //     crnEl.animate({left: offSet + 'px'}, 1000); | 
 |  |  |                         // } else { | 
 |  |  |                         //     crnEl.animate({left: (offSet - unit + (crns[i].bay * unit)) + 'px'}, 1000); | 
 |  |  |                         // } | 
 |  |  |                         // crnEl.animate({left: offSet + 'px'}, 1000); | 
 |  |  |                         if(crns[i].bay === 1){ | 
 |  |  |                             crnEl.animate({left: offSet + 'px'}, 1000); | 
 |  |  |                         } else { | 
 |  |  |                             crnEl.animate({left: (offSet - unit + (crns[i].bay * unit)) + 'px'}, 1000); | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |                 } else if (res.code === 403) { |