From 12c547a039b92263603f189988da9519af60e920 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 09 九月 2023 08:31:46 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   88 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 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 e47ec88..9259abd 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -69,6 +69,8 @@
     @Autowired
     private BasShuttleErrLogService basShuttleErrLogService;
     @Autowired
+    private BasLiftErrLogService basLiftErrLogService;
+    @Autowired
     private BasShuttleErrService basShuttleErrService;
     @Autowired
     private BasCrnErrorMapper basCrnErrorMapper;
@@ -1453,6 +1455,7 @@
     public void recErr() {
         try {
             this.recShuttleErr();
+            this.recLiftErr();
         } catch (Exception e) {
             News.error("recErr fail", e);
         }
@@ -1577,6 +1580,91 @@
         }
     }
 
+    /**
+     * 鎻愬崌鏈哄紓甯镐俊鎭褰�
+     */
+    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());
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     // -------------------------------------------------------------------------------
 
     /**

--
Gitblit v1.9.1