| | |
| | | @Autowired |
| | | private BasShuttleErrService basShuttleErrService; |
| | | @Autowired |
| | | private BasLiftErrService basLiftErrService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private BasMapService basMapService; |
| | |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 异常信息记录 |
| | | // */ |
| | | // public void recErr() { |
| | | // try { |
| | | // this.recShuttleErr(); |
| | | // this.recLiftErr(); |
| | | // } catch (Exception e) { |
| | | // News.error("recErr fail", e); |
| | | // } |
| | | // } |
| | | /** |
| | | * 异常信息记录 |
| | | */ |
| | | public void recErr() { |
| | | try { |
| | | this.recShuttleErr(); |
| | | this.recLiftErr(); |
| | | } catch (Exception e) { |
| | | News.error("recErr fail", e); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 四向穿梭车异常信息记录 |
| | | // */ |
| | | // private void recShuttleErr() { |
| | | // Date now = new Date(); |
| | | // for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) { |
| | | // // 获取四向穿梭车信息 |
| | | // NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId()); |
| | | // if (shuttleThread == null) { |
| | | // continue; |
| | | // } |
| | | // NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (shuttleProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if (shuttleProtocol.getTaskNo() != 0) { |
| | | // //有任务 |
| | | // BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo()); |
| | | // // 有异常 |
| | | // if (latest == null) { |
| | | // if (shuttleProtocol.getErrState() != null && shuttleProtocol.getErrState() == 1) { |
| | | // WrkMast wrkMast = wrkMastMapper.selectById(shuttleProtocol.getTaskNo()); |
| | | // if (wrkMast == null) { |
| | | // continue; |
| | | // } |
| | | // BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getErrCode()); |
| | | // String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); |
| | | // BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | // null, // 编号 |
| | | // wrkMast.getWrkNo(), // 工作号 |
| | | // now, // 发生时间 |
| | | // null, // 结束时间 |
| | | // wrkMast.getWrkSts(), // 工作状态 |
| | | // wrkMast.getIoType(), // 入出库类型 |
| | | // shuttleSlave.getId(), // 四向穿梭车 |
| | | // null, // plc |
| | | // wrkMast.getLocNo(), // 目标库位 |
| | | // wrkMast.getStaNo(), // 目标站 |
| | | // wrkMast.getSourceStaNo(), // 源站 |
| | | // wrkMast.getSourceLocNo(), // 源库位 |
| | | // wrkMast.getBarcode(), // 条码 |
| | | // shuttleProtocol.getErrCode(), // 异常码 |
| | | // errName, // 异常 |
| | | // 1, // 异常情况 |
| | | // now, // 添加时间 |
| | | // null, // 添加人员 |
| | | // now, // 修改时间 |
| | | // null, // 修改人员 |
| | | // "任务中异常", // 备注 |
| | | // JSON.toJSONString(shuttleProtocol) // 系统状态数据 |
| | | // ); |
| | | // if (!basShuttleErrLogService.insert(basShuttleErrLog)) { |
| | | // News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 异常修复 |
| | | // if (shuttleProtocol.getErrState() == null || shuttleProtocol.getErrState() == 0) { |
| | | // latest.setEndTime(now); |
| | | // latest.setUpdateTime(now); |
| | | // latest.setStatus(2); |
| | | // if (!basShuttleErrLogService.updateById(latest)) { |
| | | // News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // }else { |
| | | //// //无任务 |
| | | //// BasShuttleErrLog latest = basShuttleErrLogService.findLatest(shuttleSlave.getId()); |
| | | //// // 有异常 |
| | | //// if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) { |
| | | //// // 记录新异常 |
| | | //// if (latest == null || (latest.getErrCode() != shuttleProtocol.getStatusErrorCode().intValue())) { |
| | | //// BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue()); |
| | | //// String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); |
| | | //// BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | //// null, // 编号 |
| | | //// null, // 工作号 |
| | | //// now, // 发生时间 |
| | | //// null, // 结束时间 |
| | | //// null, // 工作状态 |
| | | //// null, // 入出库类型 |
| | | //// shuttleSlave.getId(), // 四向穿梭车 |
| | | //// null, // plc |
| | | //// null, // 目标库位 |
| | | //// null, // 目标站 |
| | | //// null, // 源站 |
| | | //// null, // 源库位 |
| | | //// null, // 条码 |
| | | //// (int)shuttleProtocol.getStatusErrorCode(), // 异常码 |
| | | //// errName, // 异常 |
| | | //// 1, // 异常情况 |
| | | //// now, // 添加时间 |
| | | //// null, // 添加人员 |
| | | //// now, // 修改时间 |
| | | //// null, // 修改人员 |
| | | //// "无任务异常" // 备注 |
| | | //// ); |
| | | //// if (!basShuttleErrLogService.insert(basShuttleErrLog)) { |
| | | //// News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); |
| | | //// } |
| | | //// } |
| | | //// // 无异常 |
| | | //// } else { |
| | | //// // 异常修复 |
| | | //// if (latest != null && latest.getStatus() == 1) { |
| | | //// latest.setEndTime(now); |
| | | //// latest.setUpdateTime(now); |
| | | //// latest.setStatus(2); |
| | | //// if (!basShuttleErrLogService.updateById(latest)) { |
| | | //// News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // /** |
| | | // * 提升机异常信息记录 |
| | | // */ |
| | | // private void recLiftErr() { |
| | | // Date now = new Date(); |
| | | // 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.getTaskNo() != 0) { |
| | | // //有任务 |
| | | // BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(liftSlave.getId(), liftProtocol.getTaskNo().intValue()); |
| | | // // 有异常 |
| | | // if (latest == null) { |
| | | // if (liftProtocol.getDeviceError() != null && liftProtocol.getDeviceError()) { |
| | | // WrkMast wrkMast = wrkMastMapper.selectById(liftProtocol.getTaskNo()); |
| | | // if (wrkMast == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // String errName = ""; |
| | | // if (liftProtocol.getFrontOverrun()) { |
| | | // errName = "前超限"; |
| | | // } else if (liftProtocol.getBackOverrun()) { |
| | | // errName = "后超限"; |
| | | // } else if (liftProtocol.getLeftOverrun()) { |
| | | // errName = "左超限"; |
| | | // } else if (liftProtocol.getRightOverrun()) { |
| | | // errName = "右超限"; |
| | | // } else if (liftProtocol.getOverHeight()) { |
| | | // errName = "超高"; |
| | | // } else if (liftProtocol.getOverWeight()) { |
| | | // errName = "超重"; |
| | | // } |
| | | // |
| | | // BasLiftErrLog basLiftErrLog = new BasLiftErrLog( |
| | | // null, // 编号 |
| | | // wrkMast.getWrkNo(), // 工作号 |
| | | // now, // 发生时间 |
| | | // null, // 结束时间 |
| | | // wrkMast.getWrkSts(), // 工作状态 |
| | | // wrkMast.getIoType(), // 入出库类型 |
| | | // liftSlave.getId(), // 提升机 |
| | | // null, // plc |
| | | // wrkMast.getLocNo(), // 目标库位 |
| | | // wrkMast.getStaNo(), // 目标站 |
| | | // wrkMast.getSourceStaNo(), // 源站 |
| | | // wrkMast.getSourceLocNo(), // 源库位 |
| | | // wrkMast.getBarcode(), // 条码 |
| | | // null, // 异常码 |
| | | // errName, // 异常 |
| | | // 1, // 异常情况 |
| | | // now, // 添加时间 |
| | | // null, // 添加人员 |
| | | // now, // 修改时间 |
| | | // null, // 修改人员 |
| | | // "任务中异常", // 备注 |
| | | // JSON.toJSONString(liftProtocol) // 系统状态数据 |
| | | // ); |
| | | // if (!basLiftErrLogService.insert(basLiftErrLog)) { |
| | | // News.error("提升机plc异常记录失败 ===>> [id:{}] [error:{}]", liftSlave.getId(), errName); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 异常修复 |
| | | // if (liftProtocol.getDeviceError() == null || !liftProtocol.getDeviceError()) { |
| | | // latest.setEndTime(now); |
| | | // latest.setUpdateTime(now); |
| | | // latest.setStatus(2); |
| | | // if (!basLiftErrLogService.updateById(latest)) { |
| | | // News.error("提升机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", liftSlave.getId(), latest.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | /** |
| | | * 四向穿梭车异常信息记录 |
| | | */ |
| | | private void recShuttleErr() { |
| | | Date now = new Date(); |
| | | for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) { |
| | | // 获取四向穿梭车信息 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getTaskNo() != 0) { |
| | | //有任务 |
| | | BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (shuttleProtocol.getErrorCode() != null && Integer.parseInt(shuttleProtocol.getErrorCode()) != 0) { |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(shuttleProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | int errorCode = Integer.parseInt(shuttleProtocol.getErrorCode()); |
| | | BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(errorCode); |
| | | String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); |
| | | BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | shuttleSlave.getId(), // 四向穿梭车 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | errorCode, // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "任务中异常", // 备注 |
| | | JSON.toJSONString(shuttleProtocol) // 系统状态数据 |
| | | ); |
| | | if (!basShuttleErrLogService.insert(basShuttleErrLog)) { |
| | | News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); |
| | | } |
| | | } |
| | | } else { |
| | | // 异常修复 |
| | | if (shuttleProtocol.getErrorCode() == null || Integer.parseInt(shuttleProtocol.getErrorCode()) == 0) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basShuttleErrLogService.updateById(latest)) { |
| | | News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 提升机异常信息记录 |
| | | */ |
| | | private void recLiftErr() { |
| | | Date now = new Date(); |
| | | for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { |
| | | // 获取提升机信息 |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId()); |
| | | if (forkLiftThread == null) { |
| | | continue; |
| | | } |
| | | ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); |
| | | if (forkLiftProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (forkLiftProtocol.getTaskNo() != 0) { |
| | | //有任务 |
| | | BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(forkLiftSlave.getId(), forkLiftProtocol.getTaskNo()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (forkLiftProtocol.getErrorCode() != null && forkLiftProtocol.getErrorCode() != 0) { |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(forkLiftProtocol.getWrkNo()); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | |
| | | BasLiftErr basLiftErr = basLiftErrService.queryByCode(forkLiftProtocol.getErrorCode()); |
| | | String errName = basLiftErr==null? "未知异常":basLiftErr.getErrName(); |
| | | |
| | | BasLiftErrLog basLiftErrLog = new BasLiftErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | forkLiftSlave.getId(), // 提升机 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | null, // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "任务中异常", // 备注 |
| | | JSON.toJSONString(forkLiftProtocol) // 系统状态数据 |
| | | ); |
| | | if (!basLiftErrLogService.insert(basLiftErrLog)) { |
| | | News.error("提升机plc异常记录失败 ===>> [id:{}] [error:{}]", forkLiftSlave.getId(), errName); |
| | | } |
| | | } |
| | | } else { |
| | | // 异常修复 |
| | | if (forkLiftProtocol.getErrorCode() == null || forkLiftProtocol.getErrorCode() == 0) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basLiftErrLogService.updateById(latest)) { |
| | | News.error("提升机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", forkLiftSlave.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // ------------------------------------------------------------------------------- |
| | | |