|  |  | 
 |  |  | //                log.error("rgv连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |                 try{ | 
 |  |  |                     DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                     deviceErrorService.addDeviceError("dev", slave.getId(), "rgv连接失败"+e.getMessage()); | 
 |  |  |                     deviceErrorService.addDeviceError("devErr", slave.getId(), "rgv连接失败"+e.getMessage()); | 
 |  |  |                 } catch (Exception e2){ | 
 |  |  | //                    log.error("e2:"+e2.getMessage()); | 
 |  |  |                 } | 
 |  |  | 
 |  |  |             if (System.currentTimeMillis()-currentTimeMilliConnectDev>1000*60*10){ | 
 |  |  |                 try{ | 
 |  |  |                     DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                     deviceErrorService.addDeviceError("devp", slave.getId(), "输送线plc连接失败"); | 
 |  |  |                     deviceErrorService.addDeviceError("devErr", slave.getId(), "输送线plc连接失败"); | 
 |  |  |                 } catch (Exception e2){ | 
 |  |  | //                log.error("e2:"+e2.getMessage()); | 
 |  |  |                 } | 
 |  |  | 
 |  |  |  | 
 |  |  |             } catch (Exception e) { | 
 |  |  |                 connectDev = false; | 
 |  |  |                 log.error("RGV数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |                 log.error("dev数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |                 try{ | 
 |  |  |                     DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                     deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV数据读取线程异常"+e.getMessage()); | 
 |  |  |                     deviceErrorService.addDeviceError("devErr", slave.getId(), "dev数据读取线程异常"+e.getMessage()); | 
 |  |  |                 } catch (Exception e2){ | 
 |  |  | //                    log.error("e2:"+e2.getMessage()); | 
 |  |  |                 } | 
 |  |  | 
 |  |  |                 if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { | 
 |  |  |                     staProtocol.setPakMk(true); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (!staProtocol.isPakMkRun() && !staProtocol.isLoading()) { | 
 |  |  |                     staProtocol.setPakMkRun(true); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (!staProtocol.isPakMkTask() && !staProtocol.isLoading()) { | 
 |  |  |                     staProtocol.setPakMkTask(true); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         int[] staW = new int[]{1004,1014,1020}; | 
 |  |  |  | 
 |  |  |         //条码 | 
 |  |  | //        Thread.sleep(50); | 
 |  |  |         OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB400.100.0",(short) (barcodeSize*8)); | 
 |  |  |         if (result2.IsSuccess) { | 
 |  |  |             for (int i = 0; i < barcodeSize; i++) { | 
 |  |  |                 Integer siteId = staW[i]; // 站点编号 | 
 |  |  |                 StaProtocol staProtocol = station.get(siteId); | 
 |  |  |                 if (null == staProtocol) { | 
 |  |  |                     staProtocol = new StaProtocol(); | 
 |  |  |                     station.put(siteId, staProtocol); | 
 |  |  |                 } | 
 |  |  |                 String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8"); | 
 |  |  |                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); | 
 |  |  |                 if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { | 
 |  |  |                     barcodeThread.setBarcode(barcode); | 
 |  |  |                     if (!Cools.isEmpty(barcode) && !barcode.equals("000000")){ | 
 |  |  |                         staProtocol.setBarcodeNow(barcode); | 
 |  |  |                     } else if (Cools.isEmpty(barcode)){ | 
 |  |  |                         staProtocol.setBarcodeNow("-"); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //条码 | 
 |  |  | //        Thread.sleep(50); | 
 |  |  |         int[] staW = new int[]{1004,1014,1020}; | 
 |  |  |  | 
 |  |  |         OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB400.148.0",(short) (staW.length*4)); | 
 |  |  |         if (result3.IsSuccess) { | 
 |  |  | 
 |  |  |                 staProtocol.setHighErr(status[2]);  // 高超限 | 
 |  |  |                 staProtocol.setLeftErr(status[3]);  // 左超限 | 
 |  |  |                 staProtocol.setRightErr(status[4]); // 右超限 | 
 |  |  |                 staProtocol.setWeightErr(status[5]); // 超重 | 
 |  |  |                 staProtocol.setBarcodeErr(status[6]); // 扫码失败 | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         try{ | 
 |  |  |             OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.922.0",(short) (staNoSize*4)); | 
 |  |  |             if (resultErr.IsSuccess){ | 
 |  |  |                 for (int i = 0; i < staNoSize; i++) { | 
 |  |  |                     Integer siteId = staNos.get(i); // 站点编号 | 
 |  |  |                     StaProtocol staProtocol = station.get(siteId); | 
 |  |  |                     if (null == staProtocol) { | 
 |  |  |                         staProtocol = new StaProtocol(); | 
 |  |  |                         staProtocol.setSiteId(siteId); | 
 |  |  |                         station.put(siteId, staProtocol); | 
 |  |  |                     } | 
 |  |  |                     staProtocol.setSiteId(siteId); | 
 |  |  |                     boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4, 1); | 
 |  |  |                     staProtocol.setErrOther1(statusErr[0]);  // 电路保护器断开 | 
 |  |  |                     staProtocol.setErrOther2(statusErr[1]);  // 光电异常 | 
 |  |  |                     staProtocol.setErrOther3(statusErr[2]);  // 运行超时 | 
 |  |  |                     staProtocol.setErrOther4(statusErr[3]);  // 占位超时 | 
 |  |  |                     staProtocol.setErrOther5(statusErr[4]);  // 有任务无货故障 | 
 |  |  |                     staProtocol.setErrOther6(statusErr[5]);  // 变频器故障 | 
 |  |  |                     staProtocol.setErrOther7(statusErr[6]);  // 接触器故障 | 
 |  |  |                     staProtocol.setErrOther8(statusErr[7]);  // 顶升电机接触器故障 | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } catch (Exception e){ | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (result.IsSuccess) { | 
 |  |  | 
 |  |  |                 log.error("更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             try{ | 
 |  |  |                 DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                 deviceErrorService.deleteDeviceError("devp", slave.getId()); | 
 |  |  |             } catch (Exception e){ | 
 |  |  | //                log.error("e:"+e.getMessage()); | 
 |  |  |             } | 
 |  |  | //            try{ | 
 |  |  | //                DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  | //                deviceErrorService.deleteDeviceError("devp", slave.getId()); | 
 |  |  | //            } catch (Exception e){ | 
 |  |  | ////                log.error("e:"+e.getMessage()); | 
 |  |  | //            } | 
 |  |  |         } else { | 
 |  |  |             OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); | 
 |  |  | //            log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); | 
 |  |  |             DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |             deviceErrorService.addDeviceError("devp", slave.getId(), "读取输送线plc状态信息失败"); | 
 |  |  |             deviceErrorService.addDeviceError("devErr", slave.getId(), "读取输送线plc状态信息失败"); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         ArrayList<Integer> staNos = getStaNo(); | 
 |  |  |  | 
 |  |  |         int index = staNos.indexOf(staProtocol.getSiteId()); | 
 |  |  |  | 
 |  |  |         try{ | 
 |  |  |             DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |             deviceErrorService.addDeviceError("devWrite", staProtocol.getSiteId(), "单站点写入:任务号:"+staProtocol.getWorkNo()+";目标站:"+staProtocol.getStaNo()); | 
 |  |  |         } catch (Exception e2){ | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | //        //更新命令日志 | 
 |  |  | //        CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); | 
 |  |  | 
 |  |  |                         OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令后返回成功,但是读取任务值不一致。输送线plc编号={1},站点数据={2},写入次数={3}", | 
 |  |  |                                 slave.getId(), JSON.toJSON(staProtocol),writeCount)); | 
 |  |  |                         log.error("写入输送线命令后返回成功,但是读取任务值不一致。输送线plc编号={},{},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
 |  |  |                         try{ | 
 |  |  |                             DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                             deviceErrorService.addDeviceError("devErr", staProtocol.getSiteId(), "写入次数"+writeCount+"写入后读取任务值不一致:"+"单站点写入:任务号:"+staProtocol.getWorkNo()+";目标站:"+staProtocol.getStaNo()); | 
 |  |  |                         } catch (Exception e2){ | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } else { | 
 |  |  |                     writeCount++; | 
 |  |  |                     OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令后读取失败。输送线plc编号={1},站点数据={2},写入次数={3}", | 
 |  |  |                             slave.getId(), JSON.toJSON(staProtocol), writeCount)); | 
 |  |  |                     log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
 |  |  |                     try{ | 
 |  |  |                         DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                         deviceErrorService.addDeviceError("devErr", staProtocol.getSiteId(), "写入次数"+writeCount+"写入输送线命令后读取失败:"+"单站点写入:任务号:"+staProtocol.getWorkNo()+";目标站:"+staProtocol.getStaNo()); | 
 |  |  |                     } catch (Exception e2){ | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } else { | 
 |  |  |                 writeCount++; | 
 |  |  |                 OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令失败。输送线plc编号={1},站点数据={2},写入次数={3}", | 
 |  |  |                         slave.getId(), JSON.toJSON(staProtocol),writeCount)); | 
 |  |  |                 log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
 |  |  |  | 
 |  |  |                 try{ | 
 |  |  |                     DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                     deviceErrorService.addDeviceError("devErr", staProtocol.getSiteId(), "写入次数"+writeCount+"写入输送线命令失败:"+"单站点写入:任务号:"+staProtocol.getWorkNo()+";目标站:"+staProtocol.getStaNo()); | 
 |  |  |                 } catch (Exception e2){ | 
 |  |  |                 } | 
 |  |  |                 //更新指令日志 | 
 |  |  | //                commandInfoLog.setDeviceLog("指令下发失败"); | 
 |  |  | //                commandInfoLogService.insert(commandInfoLog); | 
 |  |  | 
 |  |  |             } | 
 |  |  |             OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令尝试5次失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); | 
 |  |  |             log.error("写入输送线命令尝试5次失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); | 
 |  |  |  | 
 |  |  |             try{ | 
 |  |  |                 DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                 deviceErrorService.addDeviceError("devErr", staProtocol.getSiteId(), "写入次数"+writeCount+"写入输送线命令尝试5次失败:"+"单站点写入:任务号:"+staProtocol.getWorkNo()+";目标站:"+staProtocol.getStaNo()); | 
 |  |  |             } catch (Exception e2){ | 
 |  |  |             } | 
 |  |  |             //重新添加数据到任务队列 | 
 |  |  |             boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); | 
 |  |  |             read();//读取1次设备状态 | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 设置入库标记 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void setPakMkTask(Integer siteId, boolean pakMk) { | 
 |  |  |         StaProtocol staProtocol = station.get(siteId); | 
 |  |  |         if (null != staProtocol) { | 
 |  |  |             staProtocol.setPakMkTask(pakMk); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 设置入库标记 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void setPakMkRun(Integer siteId, boolean pakMk) { | 
 |  |  |         StaProtocol staProtocol = station.get(siteId); | 
 |  |  |         if (null != staProtocol) { | 
 |  |  |             staProtocol.setPakMkRun(pakMk); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 设置入库标记 | 
 |  |  |      */ |