4 Commits a81b6a2f48 ... c4602cd3a7

Autor SHA1 Mensagem Data
  zhifei c4602cd3a7 对接MES退火上料PDA填写料架信息后上传对应信息 9 meses atrás
  zhifei c6e8dc76d2 完善PDA补码造成数据混乱问题 9 meses atrás
  zhifei 5dcb471add 对接MES的正式环境 9 meses atrás
  zhifei fb064cf7ec 添加设备日志自动清除(删除三个月前的数据) 9 meses atrás
26 arquivos alterados com 238 adições e 216 exclusões
  1. 1 1
      warewms-admin/src/main/resources/application-prod.yml
  2. 3 3
      warewms-admin/src/main/resources/application-test.yml
  3. 1 1
      warewms-admin/src/main/resources/application.yml
  4. 8 1
      warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java
  5. 60 22
      warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java
  6. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java
  7. 6 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java
  8. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java
  9. 2 3
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java
  10. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java
  11. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java
  12. 3 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java
  13. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/connect/InkjetPrintersConnect.java
  14. 1 2
      warewms-system/src/main/java/com/warewms/hailiang/controller/RetroactiveNowController.java
  15. 0 122
      warewms-system/src/main/java/com/warewms/hailiang/controller/TestContoller.java
  16. 63 0
      warewms-system/src/main/java/com/warewms/hailiang/domain/DTO/DeviceLogDTO.java
  17. 5 0
      warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveNow.java
  18. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/enums/DaSanPanPlcEnum.java
  19. 20 9
      warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java
  20. 1 1
      warewms-system/src/main/java/com/warewms/hailiang/mapper/DeviceLogMapper.java
  21. 2 0
      warewms-system/src/main/java/com/warewms/hailiang/service/DeviceLogService.java
  22. 4 0
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceLogServiceImpl.java
  23. 6 8
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/ProcessRealizationServiceImpl.java
  24. 30 26
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java
  25. 6 1
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java
  26. 4 0
      warewms-system/src/main/resources/mapper/hailiang/DeviceLogMapper.xml

+ 1 - 1
warewms-admin/src/main/resources/application-prod.yml

@@ -67,7 +67,7 @@ spring:
     druid:
       # 主库数据源
       master:
-        url: jdbc:mysql://localhost:3306/trace_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
+        url: jdbc:mysql://172.20.2.8:3306/trace_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
         username: warewms
         password: warewms123
       # 从库数据源

+ 3 - 3
warewms-admin/src/main/resources/application-test.yml

@@ -67,9 +67,9 @@ spring:
     druid:
       # 主库数据源
       master:
-        url: jdbc:mysql://localhost:3306/ahhl_tarece?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
-        username: root
-        password: root
+        url: jdbc:mysql://172.20.2.8:3306/trace_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
+        username: warewms
+        password: warewms123
       # 从库数据源
       slave:
         # 从数据源开关/默认关闭

+ 1 - 1
warewms-admin/src/main/resources/application.yml

@@ -5,7 +5,7 @@ spring:
 
 # MES对接接口
 MES:
-  address: http://172.20.2.4:9090
+  address: http://172.20.2.2:9090
   #获取批次号
   getBatchNoUrl: /api/SprayCode/SprayBatchNo
   #获取批次号回调

+ 8 - 1
warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.MES;
 
 import cn.hutool.json.JSONObject;
+import com.warewms.hailiang.domain.RetroactiveNow;
 import org.springframework.stereotype.Service;
 
 /**
@@ -39,7 +40,13 @@ public interface MesService {
      *  绑定批次号
      * @param v 大散盘下料点
      */
-    String bindLotNo(String deviceId,String lotNo);
+    public String bindLotNo(String deviceId,String lotNo);
 
 
+    /**
+     * 退火上料反馈
+     * @param message
+     * @return
+     */
+    public String tuiHuoShangLiao(RetroactiveNow retroactiveNow);
 }

+ 60 - 22
warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.github.rholder.retry.*;
@@ -14,6 +15,7 @@ import com.warewms.hailiang.MES.MesService;
 import com.warewms.hailiang.config.DeviceMessageSocket;
 import com.warewms.hailiang.domain.Device;
 import com.warewms.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.enums.DaSanPanPlcEnum;
 import com.warewms.hailiang.enums.DeviceNameEnum;
 import com.warewms.hailiang.init.PlcConnectServiceRunner;
@@ -55,6 +57,9 @@ public class MesServiceImpl implements MesService {
     @Value("${MES.sanPanGetBatchNoUrl}")
     private String sanPanGetBatchNoUrl;
 
+    @Value("${MES.tuiHuoShangLiaoUrl}")
+    private String tuiHuoShangLiaoUrl;
+
     @Autowired
     private DeviceMessageSocket deviceMessageSocket;
 
@@ -75,12 +80,12 @@ public class MesServiceImpl implements MesService {
             body = HttpRequest.post(MESAddress + getBatchNoUrl).body(entries.toString()).execute().body();
         } catch (Exception e) {
             log.error("调用MES系统拿铜管批次号失败,msg:{}", e.getMessage());
-            return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!");
+            return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!"+e.getMessage());
         }
         JSONObject jsonObject = JSONUtil.parseObj(body);
-        if ("false".equals(jsonObject.get("ret"))) {
+        if ("false".equals(jsonObject.get("ret").toString())) {
             log.error("调用MES系统拿铜管批次号失败,msg:{}", jsonObject.get("message"));
-            return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!");
+            return invokeAlarms("称重辊道PLC", "获取MES铜管批次号失败!"+jsonObject.get("message"));
         }
         return JSONUtil.parseObj(body).get("BatchNo").toString();
     }
@@ -102,7 +107,7 @@ public class MesServiceImpl implements MesService {
         entries.set("type", result);
         String body = HttpRequest.post(MESAddress + getBatchNoResultURl).body(entries.toString()).execute().body();
         JSONObject jsonObject = JSONUtil.parseObj(body);
-        if ("false".equals(jsonObject.get("ret"))) {
+        if ("false".equals(jsonObject.get("ret").toString())) {
             retryTofeedback(MESAddress + processFeedbackUrl, entries, "BatchNoResult");
             return null;
         }
@@ -115,10 +120,10 @@ public class MesServiceImpl implements MesService {
         JSONObject entries = new JSONObject();
         entries.set("BatchNo", batchNo);
         entries.set("Type", type);
-        entries.set("d", "Z1");
+        entries.set("LineNo", "Z1");
         String body = HttpRequest.post(MESAddress + processFeedbackUrl).body(entries.toString()).execute().body();
         JSONObject jsonObject = JSONUtil.parseObj(body);
-        if ("0".equals(jsonObject.get("RES_FLAG"))) {
+        if ("false".equals(jsonObject.get("ret"))) {
             retryTofeedback(MESAddress + processFeedbackUrl, entries, "process");
             return null;
         }
@@ -129,20 +134,46 @@ public class MesServiceImpl implements MesService {
 
     @Override
     public String bindLotNo(String deviceId,String lotNot) {
-        log.info("散盘产出设备:{}",deviceId);
-        JSONObject entries = new JSONObject();
-        entries.set("StockNo", lotNot);
-        entries.set("UnitNo",deviceId );
-        entries.set("LineNo", "Z1");
-        String body = HttpRequest.post( MESAddress+ sanPanGetBatchNoUrl).body(entries.toString()).execute().body();
-        JSONObject jsonObject = JSONUtil.parseObj(body);
-        if ("0".equals(jsonObject.get("RES_FLAG"))) {
+        JSONObject entries = null;
+        String body = null;
+        try {
+            log.info("散盘产出设备:{}",deviceId);
+            entries = new JSONObject();
+            entries.set("StockNo", lotNot);
+            entries.set("UnitNo",deviceId );
+            entries.set("LineNo", "Z1");
+            body = HttpRequest.post( MESAddress+ sanPanGetBatchNoUrl).body(entries.toString()).execute().body();
+            JSONObject jsonObject = JSONUtil.parseObj(body);
+            if ("0".equals(jsonObject.get("RES_FLAG").toString())) {
             retryTofeedback(MESAddress + sanPanGetBatchNoUrl, entries, "sanpan");
+
+            }
+            return JSONUtil.parseObj(jsonObject.get("Result")).get("mat_no").toString();
+
+        }catch (Exception e){
+            log.error("大散盘绑定批次号发生错误,json:{},body:{},msg",entries,body,e);
             return null;
         }
-        log.info(body);
-        return JSONUtil.parseObj(jsonObject.get("Result")).get("mat_no").toString();
+    }
 
+    @Override
+    public String tuiHuoShangLiao(RetroactiveNow retroactiveNow) {
+        JSONObject entries = new JSONObject();
+        JSONArray matDatas = new JSONArray();
+        entries.set("matDatas",matDatas);
+        entries.set("unit_code",retroactiveNow.getUniuCode());
+        JSONObject matDate = new JSONObject();
+        matDate.set("mat_no",retroactiveNow.getBatchNo());
+        matDate.set("stand_no",retroactiveNow.getShelfNumber());
+        matDate.set("stand_position",retroactiveNow.getNumberOfLayers());
+        matDate.set("loaction",retroactiveNow.getLotAddress());
+        matDate.set("layerno",retroactiveNow.getLayerno());
+        String body = HttpRequest.post( MESAddress+ tuiHuoShangLiaoUrl).body(entries.toString()).execute().body();
+        JSONObject jsonObject = JSONUtil.parseObj(body);
+        if ("0".equals(jsonObject.get("res_flag").toString())) {
+            retryTofeedback(MESAddress + tuiHuoShangLiaoUrl, entries, "tuiHuoUP");
+        }
+        return null;
     }
 
     /**
@@ -165,23 +196,30 @@ public class MesServiceImpl implements MesService {
                     String data = HttpRequest.post(URl).body(body.toString()).execute().body();
                     JSONObject jsonObject = JSONUtil.parseObj(data);
                     if ("process".equals(type)) {
-                        if ("0".equals(jsonObject.get("RES_FLAG"))) {
+                        if ("false".equals(jsonObject.get("ret").toString())) {
                             log.error("工序读码成功反馈失败,msg:{}", jsonObject.get("message"));
-                            invokeAlarms("1".equals(type) ? "铣面工序" : "轧制工序", "工序读码成功反馈MES失败!");
+                            invokeAlarms("1".equals(type) ? "铣面工序" : "轧制工序", "工序读码成功反馈MES失败!"+ jsonObject.get("message"));
                             return false;
                         }
                     }
                     if ("BatchNoResult".equals(type)){
-                        if ("false".equals(jsonObject.get("ret"))) {
+                        if ("false".equals(jsonObject.get("ret").toString())) {
                             log.error("喷码成功反馈MES失败,msg:{}", jsonObject.get("message"));
-                            invokeAlarms("喷码器", "喷码成功反馈MES失败!");
+                            invokeAlarms("喷码器", "喷码成功反馈MES失败!"+ jsonObject.get("message"));
                             return false;
                         }
                     }
                     if ("sanpan".equals(type)){
-                        if ("false".equals(jsonObject.get("ret"))) {
+                        if ("0".equals(jsonObject.get("RES_FLAG").toString())) {
                             log.error("散盘托盘号反馈MES失败,msg:{}", jsonObject.get("message"));
-                            invokeAlarms("大散盘", "获取批次号失败!");
+                            invokeAlarms("大散盘", "获取批次号失败!"+ jsonObject.get("message"));
+                            return false;
+                        }
+                    }
+                    if ("tuiHuoUP".equals(type)) {
+                        if ("0".equals(jsonObject.get("res_flag").toString())) {
+                            log.error("退火上料料架信息反馈失败,msg:{}", jsonObject.get("message"));
+                            invokeAlarms("退货上料工序", "工序读码成功反馈MES失败!"+ jsonObject.get("message"));
                             return false;
                         }
                     }

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java

@@ -159,7 +159,7 @@ public class CodeReader12Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -237,7 +237,7 @@ public class CodeReader12Connect implements TCPConnectBase {
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-4-27.12", deviceName, "识别到码:" + message, "1"));
             }
         }catch (Exception e){
-            log.error("大散盘4号行车读码任务执行异常,msg:{}",e.getMessage());
+            log.error("大散盘4号行车读码任务执行异常,msg:",e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-4-27.12", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
         }
     }

+ 6 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java

@@ -2,6 +2,7 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
+import com.warewms.hailiang.MES.MesService;
 import com.warewms.hailiang.config.CodeReadProperties;
 import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
@@ -56,7 +57,10 @@ public class CodeReader13Connect implements TCPConnectBase {
 
     private ScheduledExecutorService scheduledExecutorService;
 
+    private MesService mesService;
+
     {
+        mesService = SpringUtil.getBean(MesService.class);
         retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
         scheduledExecutorService = SpringUtil.getBean(ScheduledExecutorService.class);
     }
@@ -150,7 +154,7 @@ public class CodeReader13Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -194,7 +198,7 @@ public class CodeReader13Connect implements TCPConnectBase {
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoShangLiao_DMQ-1-27.13", deviceName, "识别到码:" + message, "1"));
             }
         }catch (Exception e){
-            log.error("退火上料读码任务执行异常,msg:{}",e.getMessage());
+            log.error("退火上料读码任务执行异常,msg:",e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoShangLiao_DMQ-1-27.13", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
         }
     }

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java

@@ -151,7 +151,7 @@ public class CodeReader14Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -196,7 +196,7 @@ public class CodeReader14Connect implements TCPConnectBase {
             }
             Thread.sleep(500);
         }catch (Exception e){
-            log.error("退货下料读码任务执行异常,msg:{}",e.getMessage());
+            log.error("退货下料读码任务执行异常,msg:",e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoXiaLiao_DMQ-1-27.14", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
         }
     }

+ 2 - 3
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java

@@ -180,7 +180,7 @@ public class CodeReader3Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -240,8 +240,7 @@ public class CodeReader3Connect implements TCPConnectBase {
             //添加日志
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_DMQ-1-27.3", deviceName, "识别到码:" + message, "1"));
         } catch (Exception e) {
-            e.printStackTrace();
-            log.error("倒角读码任务执行异常,msg:{}", e.getMessage());
+            log.error("倒角读码任务执行异常,msg:",e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_DMQ-1-27.3", deviceName, "读码任务出错,msg:" + StringUtils.substring(e.getMessage(), 0, 2000), "2"));
         }
     }

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java

@@ -191,7 +191,7 @@ public class CodeReader5Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -244,7 +244,7 @@ public class CodeReader5Connect implements TCPConnectBase {
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_XiMian_DMQ-1-27.5", deviceName, "识别到码:" + message, "1"));
             }
         } catch (Exception e) {
-            log.error("铣面读码任务执行异常,msg:{}", e.getMessage());
+            log.error("铣面读码任务执行异常,msg:", e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_XiMian_DMQ-1-27.5", deviceName, "读码任务出错,msg:" + e.getMessage(), "2"));
         }
     }

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java

@@ -161,7 +161,7 @@ public class CodeReader6Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -229,7 +229,7 @@ public class CodeReader6Connect implements TCPConnectBase {
                 redisCache.setCacheObject(DeviceNameEnum.ZHAZHIPLC.getDeviceName(),DeviceNameEnum.ZHAZHIPLC.getDeviceName(),30,TimeUnit.SECONDS);
             }
         }catch (Exception e){
-            log.error("轧制读码任务执行异常,msg:{}",e.getMessage());
+            log.error("轧制读码任务执行异常,msg:",e);
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_ZhaZhi_DMQ-1-27.6", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
         }
     }

+ 3 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java

@@ -161,7 +161,7 @@ public class CodeReader8Connect implements TCPConnectBase {
     private void ConnectsTheHeartbeat() {
         scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
             try {
-                log.info("发送心跳,设备:{}", deviceName);
+//                log.info("发送心跳,设备:{}", deviceName);
                 pipeline.writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.heartbeat, CharsetUtil.UTF_8));
             } catch (Exception e) {
                 log.error("设备:{},连接中断", deviceName);
@@ -217,7 +217,8 @@ public class CodeReader8Connect implements TCPConnectBase {
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-2-27.8", deviceName, "读码器识别到码:" + message, "1"));
             }
         }catch (Exception e){
-            log.error("大散盘2号行车读码任务执行异常,msg:{}",e.getMessage());
+            log.error("大散盘2号行车读码任务执行异常,msg:",e);
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-2-27.8", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
         }
     }
 }

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/connect/InkjetPrintersConnect.java

@@ -133,7 +133,7 @@ public class InkjetPrintersConnect implements TCPConnectBase {
                 }
             });
         } catch (RetryException | ExecutionException e) {
-            e.printStackTrace();
+            log.error("喷码机连接故障,msg:",e);
         }
     }
 
@@ -172,7 +172,7 @@ public class InkjetPrintersConnect implements TCPConnectBase {
     private void initRoutine() {
         if (!isInitRoutine) {
             log.info("初始化打印设置");
-            movement = "初始化打印设置";
+            movement = "更新喷码机喷码内容";
             pipeline.writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(InkjetPrintersDirectivesEnum.CODE41.getCode())));
             isInitRoutine = true;
         }

+ 1 - 2
warewms-system/src/main/java/com/warewms/hailiang/controller/RetroactiveNowController.java

@@ -86,8 +86,7 @@ public class RetroactiveNowController {
             return R.fail("机组号不能为空");
         }
         System.out.println(retroactiveNow);
-        return R.ok();
-//        return retroactiveNowService.update(retroactiveNow);
+        return retroactiveNowService.update(retroactiveNow);
     }
 
 

+ 0 - 122
warewms-system/src/main/java/com/warewms/hailiang/controller/TestContoller.java

@@ -1,122 +0,0 @@
-package com.warewms.hailiang.controller;
-
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
-import com.warewms.common.annotation.Anonymous;
-import com.warewms.common.core.domain.R;
-import com.warewms.hailiang.config.DeviceMessageSocket;
-import com.warewms.hailiang.domain.DeviceLog;
-import com.warewms.hailiang.init.PlcConnectServiceRunner;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import com.warewms.hailiang.util.InkjetPrintersSetUpTools;
-import com.warewms.hailiang.util.ParseMsgTools;
-import io.netty.buffer.Unpooled;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/7
- * Time: 16:41
- * To change this template use File | Settings | File Templates.
- * Description:
- **/
-@RestController
-@RequestMapping("/test")
-@Slf4j
-public class TestContoller {
-
-    @Autowired
-    PlcConnectServiceRunner plcConnectServiceRunner;
-
-    @Autowired
-    DeviceMessageSocket deviceMessageSocket;
-
-    @GetMapping("/pclTest")
-    public Object testPlc(String plcName, String db, String type, String value) {
-        if (type.equals("1")) {
-            db = "V" + db;
-            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
-        }
-        if (type.equals("2")) {
-            db = "Q" + db;
-            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
-        }
-        if (type.equals("3")) {
-            db = "I" + db;
-            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
-        }
-        if (type.equals("4")) {
-            db = "DB" + db;
-            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
-        }
-        if (type.equals("5")) {
-            db = "DB" + db;
-            plcConnectServiceRunner.getPlcServer(plcName).writeBoolean(db, Boolean.parseBoolean(value));
-            return "yes";
-        }
-        if (type.equals("6")) {
-            db = "Q" + db;
-            plcConnectServiceRunner.getPlcServer(plcName).writeBoolean(db, Boolean.parseBoolean(value));
-            return "yes";
-        }
-        if (type.equals("7")) {
-            db = "I" + db;
-            plcConnectServiceRunner.getPlcServer(plcName).writeBoolean(db, Boolean.parseBoolean(value));
-            return "yes";
-        }
-        if (type.equals("8")) {
-            db = "M" + db;
-            return plcConnectServiceRunner.getPlcServer(plcName).readBoolean(db);
-        }
-        if (type.equals("9")) {
-            db = "M" + db;
-            plcConnectServiceRunner.getPlcServer(plcName).writeBoolean(db, Boolean.parseBoolean(value));
-            return "yes";
-        }
-        return null;
-    }
-
-    @GetMapping("/getStatus")
-    public Object getStatus(String plcName) {
-        return plcConnectServiceRunner.getPlcServer(plcName).checkConnected();
-    }
-
-    @GetMapping("/testNotify")
-    @Anonymous
-    public R testNotify(String content, String status) throws InterruptedException {
-        Thread.sleep(3000);
-        DeviceLog deviceLog = new DeviceLog("1", "倒角读码器", content, status);
-        deviceLog.setCreateBy("system");
-        deviceLog.setUpdateBy("system");
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.set("type", "notify");
-        jsonObject.set("content", JSONUtil.parse(deviceLog));
-        //推送消息
-        deviceMessageSocket.sendAllMessage(jsonObject.toString());
-        return R.ok();
-    }
-
-    @Autowired
-    TcpServiceRunner tcpServiceRunner;
-
-    @GetMapping("/testCode")
-    @Anonymous
-    public R testCode(String code) {
-        String updateCode = InkjetPrintersSetUpTools.updateCode(code);
-        log.info(code);
-        tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(updateCode)));
-        return R.ok();
-    }
-
-    public static void main(String[] args) {
-        System.out.println(InkjetPrintersSetUpTools.updateCode("237191409000"));
-    }
-
-
-}

+ 63 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/DTO/DeviceLogDTO.java

@@ -0,0 +1,63 @@
+package com.warewms.hailiang.domain.DTO;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.warewms.common.annotation.Excel;
+import com.warewms.common.core.domain.base.BaseEntity;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 设备日志表
+ * @TableName device_log
+ */
+@Data
+@NoArgsConstructor
+public class DeviceLogDTO extends BaseEntity implements Serializable  {
+    /**
+     * 日志编号
+     */
+    private Long deviceLogId;
+
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /**
+     * 日志内容
+     */
+    @Excel(name = "日志内容")
+    private String content;
+
+    /**
+     * 状态(1:信息:2报警)
+     */
+    @Excel(name = "类型",readConverterExp="1=信息,2=报警")
+    private String status;
+
+    /** 时间 */
+    @Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
+    private Date createTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public DeviceLogDTO(String deviceId, String deviceName, String content, String status) {
+        this.deviceId = deviceId;
+        this.deviceName = deviceName;
+        this.content = content;
+        this.status = status;
+    }
+}

+ 5 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveNow.java

@@ -59,6 +59,11 @@ public class RetroactiveNow extends BaseEntity {
      */
     private String numberOfLayers;
 
+    /**
+     * 列内层
+     */
+    private String layerno;
+
     /**
      * 托盘号
      */

+ 2 - 2
warewms-system/src/main/java/com/warewms/hailiang/enums/DaSanPanPlcEnum.java

@@ -11,9 +11,9 @@ public enum DaSanPanPlcEnum {
     ISREAD_fourth("DB200.2.0"),
 
     /**
-     *号车任务位置
+     *号车任务位置
      */
-    TASK_ADD_1("DB200.2.0"),
+    TASK_ADD_1("DB200.4.0"),
 
 
     /**

+ 20 - 9
warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java

@@ -5,6 +5,7 @@ import com.warewms.common.core.redis.RedisCache;
 import com.warewms.hailiang.enums.*;
 import com.warewms.hailiang.init.PlcConnectServiceRunner;
 import com.warewms.hailiang.init.TcpServiceRunner;
+import com.warewms.hailiang.service.DeviceLogService;
 import com.warewms.hailiang.service.ProcessRealizationService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +32,8 @@ public class TraceJob {
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    DeviceLogService deviceLogService;
 
     /**
      * 测试
@@ -45,7 +48,7 @@ public class TraceJob {
     public void getWeightSignal() throws InterruptedException {
         //获取plc实例对象读取称重信号
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).readBoolean(WeighPlcEnum.IsRead.getMetadata());
-        log.info("称重信号:{}", b);
+//        log.info("称重信号:{}", b);
         if (b) {
             processRealizationService.weightProcess();
         }
@@ -57,7 +60,7 @@ public class TraceJob {
      */
     public void getTheChamferCompletionSignal() throws InterruptedException {
         byte i = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readByte(DaoJiaoPlcEnum.CHECKFINISH.getMetadata());
-        log.info("喷码信号:{}", i);
+//        log.info("喷码信号:{}", i);
         if (i == 6) {
             plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.returnWeight.getMetadata(), false);
             processRealizationService.DaoJiaoCodingCodeProcess();
@@ -70,7 +73,7 @@ public class TraceJob {
 
     public void obtainTheChamferingMachineCodeReadingSignal() {
         byte i = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readByte(DaoJiaoPlcEnum.READCODE.getMetadata());
-        log.info("倒角机读码信号,{}", i);
+//        log.info("倒角机读码信号,{}", i);
         if (i == 16) {
             plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeByte(DaoJiaoPlcEnum.CHECKFINISH.getMetadata(), (byte) 0);
             processRealizationService.CodeReadingProcess("CodeReader3");
@@ -82,7 +85,7 @@ public class TraceJob {
      */
     public void obtainTheMillingFaceReadingSignal() {
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.XIMIANPLC.getDeviceName()).readBoolean(XiMianPlcEnum.ISREAD.getMetadata());
-        log.info("铣面读码信号:{}", b);
+//        log.info("铣面读码信号:{}", b);
         if (b) {
             processRealizationService.CodeReadingProcess("CodeReader5");
         }
@@ -93,7 +96,7 @@ public class TraceJob {
      */
     public void getARollingReadingSignal() {
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.ZHAZHIPLC.getDeviceName()).readBoolean(ZhaZhiPlcEnum.ISREAD.getMetadata());
-        log.info("轧制读码信号:{}", b);
+//        log.info("轧制读码信号:{}", b);
         if (b) {
             if (ObjectUtil.isNull(redisCache.getCacheObject(DeviceNameEnum.ZHAZHIPLC.getDeviceName()))){
                 processRealizationService.CodeReadingProcess("CodeReader6");
@@ -113,7 +116,7 @@ public class TraceJob {
      */
     public void getTheDriving2CodeReadingSignal() {
         byte b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readByte(DaSanPanPlcEnum.ISREAD_two.getMetadata());
-        log.info("大散盘2号行车读码信号:{}", b);
+//        log.info("大散盘2号行车读码信号:{}", b);
         if (b==1) {
             processRealizationService.CodeReadingProcess("CodeReader8");
         }
@@ -131,7 +134,7 @@ public class TraceJob {
      */
     public void getTheDriving4CodeReadingSignal() {
         byte b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readByte(DaSanPanPlcEnum.ISREAD_fourth.getMetadata());
-        log.info("大散盘4号行车读码信号:{}", b);
+//        log.info("大散盘4号行车读码信号:{}", b);
         if (b==1) {
             processRealizationService.CodeReadingProcess("CodeReader12");
         }
@@ -142,7 +145,7 @@ public class TraceJob {
      */
     public void obtainTheLoadingReadingSignal() {
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.TUIHUOUPPLC.getDeviceName()).readBoolean(TuiHuoUPPlcEnum.ISREAD.getMetadata());
-        log.info("大散盘4号行车读码信号:{}", b);
+//        log.info("大散盘4号行车读码信号:{}", b);
         if (b) {
             processRealizationService.CodeReadingProcess("CodeReader13");
         }
@@ -153,9 +156,17 @@ public class TraceJob {
      */
     public void obtainTheUnloadingReadingSignal() {
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.TuiHuoDownPcl.getDeviceName()).readBoolean(TuiHuoDownPlcEnum.ISREAD.getMetadata());
-        log.info("大散盘4号行车读码信号:{}", b);
+//        log.info("大散盘4号行车读码信号:{}", b);
         if (b) {
             processRealizationService.CodeReadingProcess("CodeReader14");
         }
     }
+
+    /**
+     * 清空PLC信号日志
+     */
+    public void cleanDeviceLog() {
+        int i = deviceLogService.cleanUpDataFromAWeekAgo();
+        log.info("已清除三个月前的数据,数量:{}",i);
+    }
 }

+ 1 - 1
warewms-system/src/main/java/com/warewms/hailiang/mapper/DeviceLogMapper.java

@@ -11,7 +11,7 @@ import com.warewms.hailiang.domain.DeviceLog;
 * @Entity  DeviceLog
 */
 public interface DeviceLogMapper extends BaseMapper<DeviceLog> {
-
+    int cleanUpDataFromAWeekAgo();
 }
 
 

+ 2 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/DeviceLogService.java

@@ -20,4 +20,6 @@ public interface DeviceLogService extends IService<DeviceLog> {
     void createLog(DeviceLog deviceLog);
 
     List<DeviceLog> getList(DeviceLog deviceLog);
+
+    int cleanUpDataFromAWeekAgo();
 }

+ 4 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceLogServiceImpl.java

@@ -95,6 +95,10 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
         }).collect(Collectors.toList());
     }
 
+    @Override
+    public int cleanUpDataFromAWeekAgo() {
+        return  deviceLogMapper.cleanUpDataFromAWeekAgo();
+    }
 }
 
 

+ 6 - 8
warewms-system/src/main/java/com/warewms/hailiang/service/impl/ProcessRealizationServiceImpl.java

@@ -104,14 +104,12 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
         if (ObjectUtil.isNotNull(retroactiveNow)) {
             //更新喷码机条码内容
             String updateCode = InkjetPrintersSetUpTools.updateCode(retroactiveNow.getBatchNo());
-            ChannelFuture channelFuture = tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(updateCode)));
-            if (channelFuture.isSuccess()) {
-                redisCache.setCacheObject("InkjetPrinters", retroactiveNow.getBatchNo());
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码内容修改完成,内容为:" + retroactiveNow.getBatchNo(), "1"));
-                //回写plc信号进行喷码
-                plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeByte(DaoJiaoPlcEnum.CHECKFINISH.getMetadata(), (byte) 8);
-            }
-        }else {
+            tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(updateCode)));
+            redisCache.setCacheObject("InkjetPrinters", retroactiveNow.getBatchNo());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码内容修改完成,内容为:" + retroactiveNow.getBatchNo(), "1"));
+            //回写plc信号进行喷码
+            plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeByte(DaoJiaoPlcEnum.CHECKFINISH.getMetadata(), (byte) 8);
+        } else {
             SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_PLC-1-27.2", "DaoJiaoJiPlc", "数据不存在已称重状态的铜管信息", "1"));
         }
     }

+ 30 - 26
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -25,13 +26,13 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
-* @author AD
-* @description 针对表【retroactive_history(生产历史追溯表)】的数据库操作Service实现
-* @createDate 2023-08-22 14:02:21
-*/
+ * @author AD
+ * @description 针对表【retroactive_history(生产历史追溯表)】的数据库操作Service实现
+ * @createDate 2023-08-22 14:02:21
+ */
 @Service
 public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistoryMapper, RetroactiveHistory>
-    implements RetroactiveHistoryService{
+        implements RetroactiveHistoryService {
 
     @Autowired
     RetroactiveHistoryMapper retroactiveHistoryMapper;
@@ -44,13 +45,13 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
 
     @Override
     public TableDataInfo<RetroactiveHistory> getListByPage(RetroactiveHistory retroactiveHistory, PageDomain pageDomain) {
-        return TableDataInfo.build(retroactiveHistoryMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<RetroactiveHistory>()
-                .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()),RetroactiveHistory::getRetroactiveId,retroactiveHistory.getRetroactiveId())
-                .like(StringUtils.isNotEmpty(retroactiveHistory.getProductionLine()),RetroactiveHistory::getProductionLine,retroactiveHistory.getProductionLine())
-                .like(StringUtils.isNotEmpty(retroactiveHistory.getBatchNo()),RetroactiveHistory::getBatchNo,retroactiveHistory.getBatchNo())
-                .like(StringUtils.isNotEmpty(retroactiveHistory.getLotNo()),RetroactiveHistory::getLotNo,retroactiveHistory.getLotNo())
-                .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
-                .eq(RetroactiveHistory::getDelFlag,"0")
+        return TableDataInfo.build(retroactiveHistoryMapper.selectPage(pageDomain.build(), new LambdaQueryWrapper<RetroactiveHistory>()
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()), RetroactiveHistory::getRetroactiveId, retroactiveHistory.getRetroactiveId())
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getProductionLine()), RetroactiveHistory::getProductionLine, retroactiveHistory.getProductionLine())
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getBatchNo()), RetroactiveHistory::getBatchNo, retroactiveHistory.getBatchNo())
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getLotNo()), RetroactiveHistory::getLotNo, retroactiveHistory.getLotNo())
+                .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()), RetroactiveHistory::getStatus, retroactiveHistory.getStatus())
+                .eq(RetroactiveHistory::getDelFlag, "0")
                 .orderByDesc(RetroactiveHistory::getCreateTime)
 
         ));
@@ -72,13 +73,16 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
                 .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()), RetroactiveHistory::getStatus, retroactiveHistory.getStatus())
                 .orderByAsc(RetroactiveHistory::getCreateTime)).stream().collect(Collectors.groupingBy(RetroactiveHistory::getStatus));
 
-        for (RetroactiveHistory history : collect.get("5")) {
-            for (Device device : deviceService.getList()) {
-                if (device.getDeviceId().equals(history.getDeviceId())){
-                    history.setDeviceId(device.getAbbreviation());
+        if (ObjectUtil.isNotNull(collect.get("5"))) {
+            for (RetroactiveHistory history : collect.get("5")) {
+                for (Device device : deviceService.getList()) {
+                    if (device.getDeviceId().equals(history.getDeviceId())) {
+                        history.setDeviceId(device.getAbbreviation());
+                    }
                 }
             }
         }
+
         return collect;
     }
 
@@ -86,31 +90,31 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
     public List<RetroactiveHistoryDTO> export(RetroactiveHistory retroactiveHistory, String ids) {
         LambdaQueryWrapper<RetroactiveHistory> retroactiveHistoryLambdaQueryWrapper = Wrappers.lambdaQuery(RetroactiveHistory.class);
         List<String> longs = new ArrayList<>();
-        if (StringUtils.isNotEmpty(ids)){
+        if (StringUtils.isNotEmpty(ids)) {
             String[] split = ids.split(",");
-            if (split.length==1){
+            if (split.length == 1) {
                 longs.add(ids);
-            }else{
+            } else {
                 longs = Arrays.asList(split);
                 System.out.println(longs);
-                retroactiveHistoryLambdaQueryWrapper.in(RetroactiveHistory::getHistoryId,longs)
+                retroactiveHistoryLambdaQueryWrapper.in(RetroactiveHistory::getHistoryId, longs)
                         .orderByAsc(RetroactiveHistory::getCreateTime);
             }
-        }else {
+        } else {
             retroactiveHistoryLambdaQueryWrapper
-                    .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()),RetroactiveHistory::getRetroactiveId,retroactiveHistory.getRetroactiveId())
-                    .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
+                    .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()), RetroactiveHistory::getRetroactiveId, retroactiveHistory.getRetroactiveId())
+                    .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()), RetroactiveHistory::getStatus, retroactiveHistory.getStatus())
                     .orderByAsc(RetroactiveHistory::getCreateTime);
         }
-        return retroactiveHistoryMapper.selectList(retroactiveHistoryLambdaQueryWrapper).stream().map(itme->{
+        return retroactiveHistoryMapper.selectList(retroactiveHistoryLambdaQueryWrapper).stream().map(itme -> {
             RetroactiveHistoryDTO retroactiveHistoryDTO = BeanUtil.copyProperties(itme, RetroactiveHistoryDTO.class);
             for (Device device : deviceService.getList()) {
-                if(device.getDeviceId().equals(retroactiveHistoryDTO.getDeviceId())){
+                if (device.getDeviceId().equals(retroactiveHistoryDTO.getDeviceId())) {
                     retroactiveHistoryDTO.setDeviceId(device.getAbbreviation());
                 }
             }
             for (SysDictData process : dictTypeService.selectDictDataByType("process")) {
-                if (process.getDictValue().equals(retroactiveHistoryDTO.getStatus())){
+                if (process.getDictValue().equals(retroactiveHistoryDTO.getStatus())) {
                     retroactiveHistoryDTO.setStatus(process.getDictLabel());
                 }
             }

+ 6 - 1
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -191,12 +191,17 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     public R update(RetroactiveNow retroactiveNow) {
         RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
                 .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq (RetroactiveNow::getStatus, "6")
         );
         if (ObjectUtil.isNull(baseData)) {
             throw new ServiceException("数据库中不存在该批次号," + retroactiveNow.getBatchNo());
         }
-        baseData.setLotNo(retroactiveNow.getLotNo());
+        baseData.setUniuCode(retroactiveNow.getUniuCode());
+        baseData.setShelfNumber(retroactiveNow.getShelfNumber());
+        baseData.setLotAddress(retroactiveNow.getLotAddress());
+        baseData.setNumberOfLayers(retroactiveNow.getNumberOfLayers());
         retroactiveNowMapper.updateById(baseData);
+        mesService .tuiHuoShangLiao(baseData);
         return R.ok();
     }
 

+ 4 - 0
warewms-system/src/main/resources/mapper/hailiang/DeviceLogMapper.xml

@@ -21,4 +21,8 @@
         content,status,create_time,
         update_by,update_time,remark
     </sql>
+
+    <delete id="cleanUpDataFromAWeekAgo">
+        delete from device_log where DATE(create_time) &lt;= DATE(DATE_SUB(NOW(),INTERVAL 3 MONTH))
+    </delete>
 </mapper>