From bedc112e8ee3b8b52a5ba7f610fdc69a9b23e394 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 21 八月 2025 15:01:37 +0800
Subject: [PATCH] 新增堆垛机报警日志

---
 src/main/java/com/zy/asrs/task/BasErrLogScheduler.java |   93 +++++++++++++++++++++++++++++++
 src/main/webapp/static/wms/js/basErrLog/basErrLog.js   |    6 +-
 src/main/java/com/zy/asrs/entity/BasCrnp.java          |    5 +
 src/main/java/com/zy/asrs/entity/BasErrLog.java        |   20 ++++++
 4 files changed, 121 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/asrs/entity/BasCrnp.java b/src/main/java/com/zy/asrs/entity/BasCrnp.java
index 0f37f95..e6c1e1d 100644
--- a/src/main/java/com/zy/asrs/entity/BasCrnp.java
+++ b/src/main/java/com/zy/asrs/entity/BasCrnp.java
@@ -124,6 +124,11 @@
     @TableField("hp_mk")
     private String hpMk;
 
+    /**
+     * 寮傚父璁板綍鏍囪
+     * N鍙互瀵瑰紓甯歌繘琛岃褰�
+     * Y寮傚父宸茬粡璁板綍
+     */
     @ApiModelProperty(value= "")
     @TableField("retrieve_mk")
     private String retrieveMk;
diff --git a/src/main/java/com/zy/asrs/entity/BasErrLog.java b/src/main/java/com/zy/asrs/entity/BasErrLog.java
index f135e6b..163a2f8 100644
--- a/src/main/java/com/zy/asrs/entity/BasErrLog.java
+++ b/src/main/java/com/zy/asrs/entity/BasErrLog.java
@@ -6,6 +6,8 @@
 import com.baomidou.mybatisplus.enums.IdType;
 import com.core.common.Cools;
 import com.core.common.SpringUtils;
+import com.zy.asrs.service.BasWrkIotypeService;
+import com.zy.asrs.service.BasWrkStatusService;
 import com.zy.system.entity.User;
 import com.zy.system.service.UserService;
 import io.swagger.annotations.ApiModelProperty;
@@ -170,6 +172,24 @@
 
     public BasErrLog() {}
 
+    public String getIoType$(){
+        BasWrkIotypeService service = SpringUtils.getBean(BasWrkIotypeService.class);
+        BasWrkIotype basWrkIotype = service.selectById(this.ioType);
+        if (!Cools.isEmpty(basWrkIotype)){
+            return String.valueOf(basWrkIotype.getIoDesc());
+        }
+        return null;
+    }
+
+    public String getWrkSts$(){
+        BasWrkStatusService service = SpringUtils.getBean(BasWrkStatusService.class);
+        BasWrkStatus basWrkStatus = service.selectById(this.wrkSts);
+        if (!Cools.isEmpty(basWrkStatus)){
+            return String.valueOf(basWrkStatus.getWrkDesc());
+        }
+        return null;
+    }
+
     public BasErrLog(String uuid,Integer wrkNo,Date startTime,Date endTime,Long wrkSts,Integer ioType,Integer crnNo,Integer plcNo,String locNo,Integer staNo,Integer sourceStaNo,String sourceLocNo,String barcode,Integer errCode,String error,Integer status,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) {
         this.uuid = uuid;
         this.wrkNo = wrkNo;
diff --git a/src/main/java/com/zy/asrs/task/BasErrLogScheduler.java b/src/main/java/com/zy/asrs/task/BasErrLogScheduler.java
new file mode 100644
index 0000000..94eeac2
--- /dev/null
+++ b/src/main/java/com/zy/asrs/task/BasErrLogScheduler.java
@@ -0,0 +1,93 @@
+package com.zy.asrs.task;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.BasCrnError;
+import com.zy.asrs.entity.BasCrnp;
+import com.zy.asrs.entity.BasErrLog;
+import com.zy.asrs.entity.TaskWrk;
+import com.zy.asrs.service.BasCrnErrorService;
+import com.zy.asrs.service.BasCrnpService;
+import com.zy.asrs.service.BasErrLogService;
+import com.zy.asrs.service.TaskWrkService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 瀹氭椂鑾峰彇鍫嗗灈鏈烘姤璀︼紝杩涜璁板綍
+ */
+@Slf4j
+@Component
+public class BasErrLogScheduler {
+
+    @Autowired
+    private BasErrLogService basErrLogService;
+    @Autowired
+    private BasCrnpService basCrnpService;
+    @Autowired
+    private TaskWrkService taskWrkService;
+    @Autowired
+    private BasCrnErrorService  basCrnErrorService;
+
+
+
+
+    @Scheduled(cron = "0/3 * * * * ? ")
+    public void execute() throws IOException {
+
+        //瀵规湁寮傚父鐨勫爢鍨涙満杩涜寮傚父璁板綍
+        List<BasCrnp> basCrnps=basCrnpService.selectList(new EntityWrapper<BasCrnp>().ge("crn_err",1));
+        if(!Cools.isEmpty(basCrnps)){
+            for(BasCrnp basCrnp:basCrnps){
+                Integer wrkNo=basCrnp.getWrkNo();
+                Integer ioType = 0;
+                Long wrkSts= 0L;
+                String error="";
+
+                if(Cools.isEmpty(basCrnp.getRetrieveMk())||basCrnp.getRetrieveMk().equals("N")){
+                    BasCrnError basCrnError=basCrnErrorService.selectOne(new EntityWrapper<BasCrnError>().eq("error_code",Math.toIntExact(basCrnp.getCrnErr())));
+                    if(!Cools.isEmpty(basCrnError)){
+                        error = basCrnError.getErrName();
+                    }
+                    BasErrLog basErrLog=new BasErrLog();
+                    if(basCrnp.getWrkNo()>0){
+                        TaskWrk taskWrk=taskWrkService.selectOne(new EntityWrapper<TaskWrk>()
+                                .eq("crn_no",basCrnp.getCrnNo())
+                                .eq("wrk_no",basCrnp.getWrkNo()));
+                        if(taskWrk!=null){
+                            wrkNo=taskWrk.getWrkNo();
+                            ioType=taskWrk.getIoType();
+                            wrkSts=taskWrk.getWrkSts().longValue();
+                        }
+                    }
+                    basErrLog.setWrkNo(wrkNo);
+                    basErrLog.setWrkSts(wrkSts);
+                    basErrLog.setIoType(ioType);
+                    basErrLog.setStartTime(new Date());
+                    basErrLog.setCrnNo(basCrnp.getCrnNo());
+                    basErrLog.setErrCode(Math.toIntExact(basCrnp.getCrnErr()));
+                    basErrLog.setError(error);
+                    if(basErrLogService.insert(basErrLog)){
+                        basCrnp.setRetrieveMk("Y");
+                        basCrnpService.updateById(basCrnp);
+                    }
+                }
+            }
+        }
+
+        //瀵规病寮傚父鐨勫爢鍨涙満杩涜寮傚父璁板彿澶嶄綅
+        List<BasCrnp> basCrnps1 = basCrnpService.selectList(new EntityWrapper<BasCrnp>().eq("crn_err", 0).eq("retrieve_mk", "Y"));
+        for(BasCrnp basCrnp:basCrnps1){
+            basCrnp.setRetrieveMk("N");
+            basCrnpService.updateById(basCrnp);
+        }
+    }
+}
diff --git a/src/main/webapp/static/wms/js/basErrLog/basErrLog.js b/src/main/webapp/static/wms/js/basErrLog/basErrLog.js
index cdc88ff..2c6a249 100644
--- a/src/main/webapp/static/wms/js/basErrLog/basErrLog.js
+++ b/src/main/webapp/static/wms/js/basErrLog/basErrLog.js
@@ -22,8 +22,8 @@
 //            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
             ,{field: 'uuid', align: 'center',title: '缂栧彿', hide: true}
             ,{field: 'wrkNo', align: 'center',title: '浠诲姟鍙�'}
-            ,{field: 'startTime$', align: 'center',title: '鍙戠敓鏃堕棿'}
-            ,{field: 'endTime$', align: 'center',title: '缁撴潫鏃堕棿'}
+            ,{field: 'startTime$', align: 'center',title: '鍒涘缓鏃堕棿'}
+            ,{field: 'endTime$', align: 'center',title: '缁撴潫鏃堕棿', hide: true}
             ,{field: 'wrkSts$', align: 'center',title: '浠诲姟鐘舵��'}
             ,{field: 'ioType$', align: 'center',title: '鍏ュ嚭搴撶被鍨�'}
             ,{field: 'crnNo', align: 'center',title: '鍫嗗灈鏈�'}
@@ -35,7 +35,7 @@
             ,{field: 'barcode', align: 'center',title: '鏉$爜', hide: true}
             ,{field: 'errCode', align: 'center',title: '寮傚父鐮�'}
             ,{field: 'error', align: 'center',title: '寮傚父鎻忚堪'}
-            ,{field: 'status$', align: 'center',title: '寮傚父鎯呭喌'}
+            ,{field: 'status$', align: 'center',title: '寮傚父鎯呭喌', hide: true}
             // ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
             // ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'}
             ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿', hide: true}

--
Gitblit v1.9.1