From 3c3c818766885ef77b33e5d218e7925bb90bae99 Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 09 一月 2025 13:08:07 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 371 ++++++++++++++++++++++------------------------------ 1 files changed, 157 insertions(+), 214 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index bcd44a1..b1aafc8 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -55,6 +55,8 @@ @Autowired private BasShuttleErrService basShuttleErrService; @Autowired + private BasLiftErrService basLiftErrService; + @Autowired private CommonService commonService; @Autowired private BasMapService basMapService; @@ -1293,221 +1295,162 @@ } } -// /** -// * 寮傚父淇℃伅璁板綍 -// */ -// 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("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [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("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [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("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [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("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [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("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [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("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [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("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [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("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [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("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [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("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", forkLiftSlave.getId(), latest.getId()); + } + } + } + } + } + } // ------------------------------------------------------------------------------- -- Gitblit v1.9.1