3 Commits ce5184bedb ... 6a627e05b4

Author SHA1 Message Date
  zhifei 6a627e05b4 连贯模拟测试,修改设备日志生成问题及铜管追溯生成时间出错问题 1 year ago
  zhifei 536d0cdd1f 编写退火上下料启动读码逻辑 1 year ago
  zhifei 9aa726ead0 修改定时任务日志查询问题 1 year ago
29 changed files with 382 additions and 148 deletions
  1. 12 0
      warewms-admin/src/main/resources/application-dev.yml
  2. 13 1
      warewms-admin/src/main/resources/application-prod.yml
  3. 12 0
      warewms-admin/src/main/resources/application-test.yml
  4. 3 3
      warewms-framework/src/main/java/com/warewms/framework/config/CreateAndUpdateMetaObjectHandler.java
  5. 1 2
      warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobLogMapper.java
  6. 6 5
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java
  7. 31 4
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java
  8. 30 4
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java
  9. 22 14
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java
  10. 8 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java
  11. 6 5
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java
  12. 7 6
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader7Connect.java
  13. 18 15
      warewms-system/src/main/java/com/warewms/hailiang/connect/InkjetPrintersConnect.java
  14. 7 3
      warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveHistoryController.java
  15. 20 2
      warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java
  16. 9 0
      warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java
  17. 2 1
      warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java
  18. 2 1
      warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveHistory.java
  19. 6 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/DaoJiaoPlcEnum.java
  20. 5 1
      warewms-system/src/main/java/com/warewms/hailiang/enums/DeviceNameEnum.java
  21. 20 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/TuiHuoDownPlcEnum.java
  22. 20 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/TuiHuoUPPlcEnum.java
  23. 43 33
      warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java
  24. 2 1
      warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveHistoryService.java
  25. 5 2
      warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveNowService.java
  26. 3 1
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceServiceImpl.java
  27. 14 8
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/ProcessRealizationServiceImpl.java
  28. 3 2
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java
  29. 52 27
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

+ 12 - 0
warewms-admin/src/main/resources/application-dev.yml

@@ -232,3 +232,15 @@ plc:
     name: DaSanPanPlc
     ePlcType: S1500
     heartbeat: BD200.0.0
+  plcList[5]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoUPPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0
+  plcList[6]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoDownPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

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

@@ -167,7 +167,7 @@ mybatis-plus:
     mapUnderscoreToCamelCase: true
     # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
     # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
-    logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
+    logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
   global-config:
     # 是否打印 Logo banner
     banner: false
@@ -232,3 +232,15 @@ plc:
     name: DaSanPanPlc
     ePlcType: S1500
     heartbeat: BD200.0.0
+  plcList[5]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoUPPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0
+  plcList[6]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoDownPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

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

@@ -232,3 +232,15 @@ plc:
     name: DaSanPanPlc
     ePlcType: S1500
     heartbeat: BD200.0.0
+  plcList[5]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoUPPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0
+  plcList[6]:
+    ip: 172.20.54.121
+    enable: false
+    name: TuiHuoDownPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

+ 3 - 3
warewms-framework/src/main/java/com/warewms/framework/config/CreateAndUpdateMetaObjectHandler.java

@@ -49,9 +49,9 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
                 Date current = new Date();
                 // 更新时间填充(不管为不为空)
                 baseEntity.setUpdateTime(current);
-                String username = SecurityUtils.getUsername();
-                // 当前已登录 更新人填充(不管为不为空)
-                if (StringUtils.isNotBlank(username)) {
+                // 当前已登录 更新人填充(为空进行填充)
+                if (StringUtils.isBlank(baseEntity.getUpdateBy())) {
+                    String username = SecurityUtils.getUsername();
                     baseEntity.setUpdateBy(username);
                 }
             }

+ 1 - 2
warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobLogMapper.java

@@ -20,10 +20,9 @@ public interface SysJobLogMapper extends BaseMapper<SysJobLog>
      * 获取quartz调度器日志的计划任务
      *
      * @param jobLog     调度日志信息
-     * @param pageDomain
      * @return 调度任务日志集合
      */
-    public IPage<SysJobLog> selectJobLogList(@Param("jobLog") SysJobLog jobLog, @Param("page") Page<SysJobLog> page);
+    public Page<SysJobLog> selectJobLogList(@Param("jobLog") SysJobLog jobLog, @Param("page") Page<SysJobLog> page);
 
     /**
      * 查询所有调度任务日志

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

@@ -17,7 +17,6 @@ import io.netty.channel.socket.nio.NioSocketChannel;
 import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
 
-import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -51,9 +50,11 @@ public class CodeReader12Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
-    @Resource
-    RetroactiveNowService retroactiveNowService;
+    private RetroactiveNowService retroactiveNowService;
 
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+    }
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -157,8 +158,8 @@ public class CodeReader12Connect implements TCPConnectBase {
             } else {
                 //读取到批次号保存到数据库中
                 RetroactiveNow retroactiveNow = new RetroactiveNow();
-                retroactiveNow.setBatchNo(message);
-                retroactiveNow.setStatus("8");
+                retroactiveNow.setLotNo(message);
+                retroactiveNow.setStatus("5");
                 retroactiveNow.setDeviceId("Z1_DaSanPan_DMQ-4-27.12");
                 retroactiveNowService.updateData(retroactiveNow);
                 //添加设备日志

+ 31 - 4
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java

@@ -2,8 +2,12 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
+import com.warewms.hailiang.config.CodeReadProperties;
 import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
+import com.warewms.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.service.RetroactiveNowService;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.*;
@@ -25,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  * Date: 2023/8/9
  * Time: 15:45
  * To change this template use File | Settings | File Templates.
- * Description:倒角读码器连接
+ * Description:退火读码器连接
  **/
 @Slf4j
 public class CodeReader13Connect implements TCPConnectBase {
@@ -36,7 +40,7 @@ public class CodeReader13Connect implements TCPConnectBase {
 
     private final String deviceName ="CodeReader13";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -46,6 +50,12 @@ public class CodeReader13Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
+    private RetroactiveNowService retroactiveNowService;
+
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+    }
+
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -137,11 +147,28 @@ public class CodeReader13Connect implements TCPConnectBase {
 
     @Override
     public ChannelPipeline getChannel() {
-        return null;
+        return pipeline;
     }
 
     @Override
     public void processMessages(String message) {
-
+        try {
+            log.info("退火上料读码器消息:{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoShangLiao_DMQ-1-27.13", deviceName, "未识别到码", "2"));
+            } else {
+                //读取到批次号保存到数据库中
+                RetroactiveNow retroactiveNow = new RetroactiveNow();
+                retroactiveNow.setLotNo(message);
+                retroactiveNow.setStatus("6");
+                retroactiveNow.setDeviceId("Z1_TuiHuoShangLiao_DMQ-1-27.13");
+                retroactiveNowService.updateData(retroactiveNow);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoShangLiao_DMQ-1-27.13", deviceName, "识别到码:" + message, "1"));
+            }
+        }catch (Exception e){
+            log.error("退火上料读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoShangLiao_DMQ-1-27.13", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
     }
 }

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

@@ -2,8 +2,12 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
+import com.warewms.hailiang.config.CodeReadProperties;
 import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
+import com.warewms.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.service.RetroactiveNowService;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.*;
@@ -25,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  * Date: 2023/8/9
  * Time: 15:45
  * To change this template use File | Settings | File Templates.
- * Description:倒角读码器连接
+ * Description:退火读码器连接
  **/
 @Slf4j
 public class CodeReader14Connect implements TCPConnectBase {
@@ -36,7 +40,7 @@ public class CodeReader14Connect implements TCPConnectBase {
 
     private final String deviceName ="CodeReader14";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -46,6 +50,11 @@ public class CodeReader14Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
+    private RetroactiveNowService retroactiveNowService;
+
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+    }
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -137,11 +146,28 @@ public class CodeReader14Connect implements TCPConnectBase {
 
     @Override
     public ChannelPipeline getChannel() {
-        return null;
+        return pipeline;
     }
 
     @Override
     public void processMessages(String message) {
-
+        try {
+            log.info("退货下料读码器消息:{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoXiaLiao_DMQ-1-27.14", deviceName, "未识别到码", "2"));
+            } else {
+                //读取到批次号保存到数据库中
+                RetroactiveNow retroactiveNow = new RetroactiveNow();
+                retroactiveNow.setLotNo(message);
+                retroactiveNow.setStatus("7");
+                retroactiveNow.setDeviceId("Z1_TuiHuoXiaLiao_DMQ-1-27.14");
+                retroactiveNowService.finishProduce(retroactiveNow);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoXiaLiao_DMQ-1-27.14", deviceName, "识别到码:" + message, "1"));
+            }
+        }catch (Exception e){
+            log.error("退货下料读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_TuiHuoXiaLiao_DMQ-1-27.14", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
     }
 }

+ 22 - 14
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java

@@ -2,7 +2,7 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.jhlabs.image.OilFilter;
+import com.warewms.common.utils.StringUtils;
 import com.warewms.hailiang.MES.MesService;
 import com.warewms.hailiang.config.CodeReadProperties;
 import com.warewms.hailiang.connect.base.TCPConnectBase;
@@ -15,16 +15,13 @@ import com.warewms.hailiang.init.PlcConnectServiceRunner;
 import com.warewms.hailiang.service.RetroactiveNowService;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.channel.socket.nio.NioSocketChannel;
 import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -58,13 +55,19 @@ public class CodeReader3Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
-    @Resource
-    MesService mesService;
-    @Resource
-    RetroactiveNowService retroactiveNowService;
-    @Resource
+
+    private MesService mesService;
+
+    private RetroactiveNowService retroactiveNowService;
+
     PlcConnectServiceRunner plcConnectServiceRunner;
 
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+        mesService = SpringUtil.getBean(MesService.class);
+        plcConnectServiceRunner = SpringUtil.getBean(PlcConnectServiceRunner.class);
+    }
+
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -172,15 +175,20 @@ public class CodeReader3Connect implements TCPConnectBase {
             //修改数据库信息
             RetroactiveNow retroactiveNow = new RetroactiveNow();
             retroactiveNow.setBatchNo(message);
-            retroactiveNow.setStatus("");
+            retroactiveNow.setStatus("2");
+            retroactiveNow.setDeviceId("Z1_DaoJia_DMQ-1-27.3");
             retroactiveNowService.updateData(retroactiveNow);
             //上传MES系统
             mesService.getBatchNoResult(message, true);
             //回写PLC读码完成
-            plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeBoolean(DaoJiaoPlcEnum.RETURNOUTCOME.getMetadata(),false);
-        }catch (Exception e){
-            log.error("倒角读码任务执行异常,msg:{}",e.getMessage());
-            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+            plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeBoolean(DaoJiaoPlcEnum.RETURNOUTCOME.getMetadata(), false);
+
+            //添加日志
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "识别到码:" + message, "1"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("倒角读码任务执行异常,msg:{}", e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "读码任务出错,msg:" + StringUtils.substring(e.getMessage(), 0, 2000), "2"));
         }
     }
 

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

@@ -21,7 +21,6 @@ import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -46,7 +45,7 @@ public class CodeReader5Connect implements TCPConnectBase {
 
     private final String deviceName = "CodeReader5";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -57,12 +56,14 @@ public class CodeReader5Connect implements TCPConnectBase {
     private ChannelPipeline pipeline;
 
 
-    @Resource
-    RetroactiveNowService retroactiveNowService;
+    private RetroactiveNowService retroactiveNowService;
 
-    @Resource
-    PlcConnectServiceRunner plcConnectServiceRunner;
+    private PlcConnectServiceRunner plcConnectServiceRunner;
 
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+        plcConnectServiceRunner = SpringUtil.getBean(PlcConnectServiceRunner.class);
+    }
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -170,7 +171,7 @@ public class CodeReader5Connect implements TCPConnectBase {
                 //读取到批次号保存到数据库中
                 RetroactiveNow retroactiveNow = new RetroactiveNow();
                 retroactiveNow.setBatchNo(message);
-                retroactiveNow.setStatus("6");
+                retroactiveNow.setStatus("3");
                 retroactiveNow.setDeviceId("Z1_XiMian_DMQ-1-27.5");
                 retroactiveNowService.updateData(retroactiveNow);
                 plcConnectServiceRunner.getPlcServer(DeviceNameEnum.XIMIANPLC.getDeviceName()).writeBoolean(XiMianPlcEnum.ISREAD.getMetadata(), false);

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

@@ -18,7 +18,6 @@ import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -31,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  * Date: 2023/8/9
  * Time: 15:45
  * To change this template use File | Settings | File Templates.
- * Description:倒角读码器连接
+ * Description:轧制读码器连接
  **/
 @Slf4j
 @Service
@@ -53,9 +52,11 @@ public class CodeReader6Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
-    @Resource
-    RetroactiveNowService retroactiveNowService;
+    private RetroactiveNowService retroactiveNowService;
 
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+    }
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -159,7 +160,7 @@ public class CodeReader6Connect implements TCPConnectBase {
                 //读取到批次号保存到数据库中
                 RetroactiveNow retroactiveNow = new RetroactiveNow();
                 retroactiveNow.setBatchNo(message);
-                retroactiveNow.setStatus("7");
+                retroactiveNow.setStatus("4");
                 retroactiveNow.setDeviceId("Z1_ZhaZhi_DMQ-1-27.6");
                 retroactiveNowService.updateData(retroactiveNow);
                 //添加设备日志

+ 7 - 6
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader7Connect.java

@@ -17,7 +17,6 @@ import io.netty.channel.socket.nio.NioSocketChannel;
 import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
 
-import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -51,9 +50,11 @@ public class CodeReader7Connect implements TCPConnectBase {
 
     private ChannelPipeline pipeline;
 
-    @Resource
-    RetroactiveNowService retroactiveNowService;
+    private RetroactiveNowService retroactiveNowService;
 
+    {
+        retroactiveNowService = SpringUtil.getBean(RetroactiveNowService.class);
+    }
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -155,10 +156,10 @@ public class CodeReader7Connect implements TCPConnectBase {
             if (CodeReadProperties.failureReturnInstruction.equals(message)) {
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-1-27.7", deviceName, "未识别到码", "2"));
             } else {
-                //读取到批次号保存到数据库中
+                //读取到托盘号保存到数据库中
                 RetroactiveNow retroactiveNow = new RetroactiveNow();
-                retroactiveNow.setBatchNo(message);
-                retroactiveNow.setStatus("8");
+                retroactiveNow.setLotNo(message);
+                retroactiveNow.setStatus("5");
                 retroactiveNow.setDeviceId("Z1_DaSanPan_DMQ-1-27.7");
                 retroactiveNowService.updateData(retroactiveNow);
                 //添加设备日志

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

@@ -68,19 +68,20 @@ public class InkjetPrintersConnect implements TCPConnectBase {
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
                                 pipeline = socketChannel.pipeline();
                                 pipeline.addLast(new ChannelInboundHandlerAdapter() {
-                                    @Override
-                                    public void channelInactive(ChannelHandlerContext ctx) {
-                                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "2"));
-                                        log.error("设备:{}连接已断开!", deviceName);
-                                        retry();
-                                    }
-
-                                    @Override
-                                    public void channelRead(ChannelHandlerContext ctx, Object msg) {
-                                        ByteBuf byteBuf = (ByteBuf) msg;
-                                        processMessages(ParseMsgTools.StringTohexString(byteBuf.toString(CharsetUtil.US_ASCII)));
-                                    }
-                                });
+                                            @Override
+                                            public void channelInactive(ChannelHandlerContext ctx) {
+                                                SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "2"));
+                                                log.error("设备:{}连接已断开!", deviceName);
+                                                retry();
+                                            }
+
+                                            @Override
+                                            public void channelRead(ChannelHandlerContext ctx, Object msg) {
+                                                ByteBuf byteBuf = (ByteBuf) msg;
+                                                processMessages(ParseMsgTools.StringTohexString(byteBuf.toString(CharsetUtil.US_ASCII)));
+                                            }
+
+                                        });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -138,6 +139,7 @@ public class InkjetPrintersConnect implements TCPConnectBase {
 
     @Override
     public void close() {
+        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "2"));
         group.shutdownGracefully();
     }
 
@@ -159,8 +161,8 @@ public class InkjetPrintersConnect implements TCPConnectBase {
         if ("f7".equalsIgnoreCase(message)) {
             log.info("喷码机打印成功!");
         }
-        if ("6".equals(message)){
-            log.info(movement+"完成");
+        if ("6".equals(message)) {
+            log.info(movement + "完成");
         }
     }
 
@@ -172,6 +174,7 @@ public class InkjetPrintersConnect implements TCPConnectBase {
             log.info("初始化打印设置");
             movement = "初始化打印设置";
             pipeline.writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(InkjetPrintersDirectivesEnum.CODE41.getCode())));
+            isInitRoutine = true;
         }
     }
 }

+ 7 - 3
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveHistoryController.java

@@ -26,13 +26,17 @@ public class RetroactiveHistoryController {
     @Autowired
     RetroactiveHistoryService retroactiveHistoryService;
 
+    @GetMapping("/pageList")
+    public TableDataInfo<RetroactiveHistory> getListByPage(RetroactiveHistory retroactiveHistory, PageDomain pageDomain){
+       return retroactiveHistoryService.getListByPage(retroactiveHistory,pageDomain);
+    }
     @GetMapping("/list")
-    public TableDataInfo<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory, PageDomain pageDomain){
-       return retroactiveHistoryService.getList(retroactiveHistory,pageDomain);
+    public List<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory){
+        return retroactiveHistoryService.getHistoryList(retroactiveHistory);
     }
 
     @GetMapping("/info")
-    public R<List<RetroactiveHistory>> getList(RetroactiveHistory retroactiveHistory){
+    public R<List<RetroactiveHistory>> getInfoList(RetroactiveHistory retroactiveHistory){
         return R.ok( retroactiveHistoryService.getHistoryList(retroactiveHistory));
     }
 }

+ 20 - 2
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java

@@ -1,8 +1,11 @@
 package com.warewms.hailiang.contoller;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.warewms.common.annotation.Log;
 import com.warewms.common.core.domain.R;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.common.utils.StringUtils;
 import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.service.DeviceLogService;
@@ -12,6 +15,10 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * @author
  * @description 针对表【retroactive_now(生产追溯表)】的数据库操作Controller
@@ -25,10 +32,21 @@ public class RetroactiveNowController {
     RetroactiveNowService retroactiveNowService;
 
     @GetMapping("/list")
-    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain) {
-        return retroactiveNowService.getList(retroactiveNow, pageDomain);
+    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain,String inStatus) {
+        List status = new ArrayList<>();
+        if (StringUtils.isNotEmpty(inStatus)) {
+            String[] split = inStatus.split(",");
+            if (split.length==1){
+                status.add(inStatus);
+            }else{
+                status = Arrays.asList(inStatus);
+            }
+        }
+        System.err.println(status);
+        return retroactiveNowService.getList(retroactiveNow, pageDomain,status);
     }
 
+
     @GetMapping("/info")
     public R<RetroactiveNow> getInfo(RetroactiveNow retroactiveNow) {
         return R.ok(retroactiveNowService.selectTheOneByParameter(retroactiveNow));

+ 9 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java

@@ -55,6 +55,15 @@ public class TestContoller {
             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")

+ 2 - 1
warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.domain;
 
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.warewms.common.core.domain.base.BaseEntity;
@@ -20,7 +21,7 @@ public class DeviceLog extends BaseEntity implements Serializable  {
     /**
      * 日志编号
      */
-    @TableId
+    @TableId(type = IdType.ASSIGN_ID)
     private Long deviceLogId;
 
     /**

+ 2 - 1
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveHistory.java

@@ -1,5 +1,6 @@
 package com.warewms.hailiang.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -20,7 +21,7 @@ public class RetroactiveHistory extends BaseEntity {
     /**
      * 历史追溯编号
      */
-    @TableId
+    @TableId(type = IdType.ASSIGN_ID)
     private Long historyId;
     /**
      * 追溯id

+ 6 - 0
warewms-system/src/main/java/com/warewms/hailiang/enums/DaoJiaoPlcEnum.java

@@ -5,8 +5,14 @@ package com.warewms.hailiang.enums;
  */
 public enum DaoJiaoPlcEnum {
 
+    /**
+     * 验证喷码机喷码内容
+     */
     CHECKFINISH("Q1.6"),
 
+    /**
+     *
+     */
     READCODE("Q1.7"),
 
     RETURNOUTCOME("");

+ 5 - 1
warewms-system/src/main/java/com/warewms/hailiang/enums/DeviceNameEnum.java

@@ -12,7 +12,11 @@ public enum DeviceNameEnum {
 
     ZHAZHIPLC("ZhaZhiPlc"),
 
-    DASANPANPLC("DaSanPanPlc");
+    DASANPANPLC("DaSanPanPlc"),
+
+    TUIHUOUPPLC("TuiHuoUPPcl"),
+
+    TuiHuoDownPcl("TuiHuoDownPlc");
 
     private String deviceName;
 

+ 20 - 0
warewms-system/src/main/java/com/warewms/hailiang/enums/TuiHuoDownPlcEnum.java

@@ -0,0 +1,20 @@
+package com.warewms.hailiang.enums;
+
+public enum TuiHuoDownPlcEnum {
+    /**
+     * 读码信号
+     */
+    ISREAD("DB200.0.1");
+
+
+    private String metadata;
+
+
+    TuiHuoDownPlcEnum(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+}

+ 20 - 0
warewms-system/src/main/java/com/warewms/hailiang/enums/TuiHuoUPPlcEnum.java

@@ -0,0 +1,20 @@
+package com.warewms.hailiang.enums;
+
+public enum TuiHuoUPPlcEnum {
+    /**
+     * 读码信号
+     */
+    ISREAD("DB200.0.1");
+
+
+    private String metadata;
+
+
+    TuiHuoUPPlcEnum(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+}

+ 43 - 33
warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java

@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
+
 /**
  * 溯源系統定時任務
  */
@@ -16,16 +18,16 @@ import org.springframework.stereotype.Component;
 @Slf4j
 public class TraceJob {
 
-    @Autowired
-    PlcConnectServiceRunner plcConnectServiceRunner;
+    @Resource
+    private PlcConnectServiceRunner plcConnectServiceRunner;
 
-    @Autowired
-    TcpServiceRunner tcpServiceRunner;
+    @Resource
+    private TcpServiceRunner tcpServiceRunner;
 
-    @Autowired
-    ProcessRealizationService processRealizationService;
+    @Resource
+    private ProcessRealizationService processRealizationService;
 
-    @Autowired
+    @Resource
     private RedisCache redisCache;
 
 
@@ -53,11 +55,11 @@ public class TraceJob {
      * 获取喷码信号
      */
     public void getTheChamferCompletionSignal() {
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.CHECKFINISH.getMetadata());
-        log.info("喷码信号:{}", b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.CHECKFINISH.getMetadata());
+//        log.info("喷码信号:{}", b);
+//        if (b) {
             processRealizationService.DaoJiaoCodingCodeProcess();
-        }
+//        }
     }
 
     /**
@@ -65,44 +67,44 @@ public class TraceJob {
      */
 
     public void obtainTheChamferingMachineCodeReadingSignal (){
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.READCODE.getMetadata());
-        log.info("倒角机读码信号,{}",b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.READCODE.getMetadata());
+//        log.info("倒角机读码信号,{}",b);
+//        if (b) {
             processRealizationService.CodeReadingProcess("CodeReader3");
-        }
+//        }
     }
 
     /**
      * 获取铣面读码信号
      */
     public void obtainTheMillingFaceReadingSignal() {
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.XIMIANPLC.getDeviceName()).readBoolean(XiMianPlcEnum.ISREAD.getMetadata());
-        log.info("铣面读码信号:{}", b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.XIMIANPLC.getDeviceName()).readBoolean(XiMianPlcEnum.ISREAD.getMetadata());
+//        log.info("铣面读码信号:{}", b);
+//        if (b) {
             processRealizationService.CodeReadingProcess("CodeReader5");
-        }
+//        }
     }
 
     /**
      * 获取轧制读码信号
      */
     public void getARollingReadingSignal() {
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.ZHAZHIPLC.getDeviceName()).readBoolean(ZhaZhiPlcEnum.ISREAD.getMetadata());
-        log.info("轧制读码信号:{}", b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.ZHAZHIPLC.getDeviceName()).readBoolean(ZhaZhiPlcEnum.ISREAD.getMetadata());
+//        log.info("轧制读码信号:{}", b);
+//        if (b) {
             processRealizationService.CodeReadingProcess("CodeReader6");
-        }
+//        }
     }
 
     /**
      * 获取行车1读码信号
      */
     public void getTheDriving1CodeReadingSignal() {
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readBoolean(DaSanPanPlcEnum.ISREAD_one.getMetadata());
-        log.info("大散盘1号行车读码信号:{}", b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readBoolean(DaSanPanPlcEnum.ISREAD_one.getMetadata());
+//        log.info("大散盘1号行车读码信号:{}", b);
+//        if (b) {
             processRealizationService.CodeReadingProcess("CodeReader7");
-        }
+//        }
     }
 
     /**
@@ -123,24 +125,32 @@ public class TraceJob {
      * 获取行车4读码信号
      */
     public void getTheDriving4CodeReadingSignal() {
-        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readBoolean(DaSanPanPlcEnum.ISREAD_fourth.getMetadata());
-        log.info("大散盘4号行车读码信号:{}", b);
-        if (b) {
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DASANPANPLC.getDeviceName()).readBoolean(DaSanPanPlcEnum.ISREAD_fourth.getMetadata());
+//        log.info("大散盘4号行车读码信号:{}", b);
+//        if (b) {
             processRealizationService.CodeReadingProcess("CodeReader12");
-        }
+//        }
     }
 
     /**
      * 获取上料读码信号
      */
     public void obtainTheLoadingReadingSignal() {
-
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.TUIHUOUPPLC.getDeviceName()).readBoolean(TuiHuoUPPlcEnum.ISREAD.getMetadata());
+//        log.info("大散盘4号行车读码信号:{}", b);
+//        if (b) {
+            processRealizationService.CodeReadingProcess("CodeReader13");
+//        }
     }
 
     /**
      * 获取下料读码信号
      */
     public void obtainTheUnloadingReadingSignal() {
-
+//        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.TuiHuoDownPcl.getDeviceName()).readBoolean(TuiHuoDownPlcEnum.ISREAD.getMetadata());
+//        log.info("大散盘4号行车读码信号:{}", b);
+//        if (b) {
+            processRealizationService.CodeReadingProcess("CodeReader14");
+//        }
     }
 }

+ 2 - 1
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveHistoryService.java

@@ -15,7 +15,8 @@ import java.util.List;
 */
 public interface RetroactiveHistoryService extends IService<RetroactiveHistory> {
 
-    TableDataInfo<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory, PageDomain pageDomain);
+    TableDataInfo<RetroactiveHistory> getListByPage(RetroactiveHistory retroactiveHistory, PageDomain pageDomain);
 
     List<RetroactiveHistory> getHistoryList(RetroactiveHistory retroactiveHistory);
+
 }

+ 5 - 2
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveNowService.java

@@ -3,9 +3,10 @@ package com.warewms.hailiang.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
-import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.domain.RetroactiveNow;
 
+import java.util.List;
+
 /**
 * @author AD
 * @description 针对表【retroactive_now(生产追溯表)】的数据库操作Service
@@ -13,11 +14,13 @@ import com.warewms.hailiang.domain.RetroactiveNow;
 */
 public interface RetroactiveNowService extends IService<RetroactiveNow> {
 
-    TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain);
+    TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain, List<String> array);
 
     int insertData(RetroactiveNow retroactiveNow);
 
     RetroactiveNow selectTheOneByParameter(RetroactiveNow retroactiveNow);
 
     int updateData(RetroactiveNow retroactiveNow);
+
+    int finishProduce(RetroactiveNow retroactiveNow);
 }

+ 3 - 1
warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceServiceImpl.java

@@ -16,7 +16,7 @@ public class DeviceServiceImpl implements DeviceService {
 
     {
         devices.add(new Device("Z1_ChengZhong_PLC-1-52.21", "ChengZhongPlc", "称重辊道PLC", "Z1", "172.20.52.21", 102, "S7", "2"));
-        devices.add(new Device("Z1_Daojiao_PlC-1-27.2", "DaoJiaoJiPlc", "倒角机", "Z1", "172.20.27.2", 102, "S7", "2"));
+        devices.add(new Device("Z1_Daojiao_PLC-1-27.2", "DaoJiaoJiPlc", "倒角机", "Z1", "172.20.27.2", 102, "S7", "2"));
         devices.add(new Device("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码器", "Z1", "172.20.27.4", 102, "TCP", "2"));
         devices.add(new Device("Z1_DaoJia_DMQ-1-27.3", "CodeReader3", "倒角读码器", "Z1", "172.20.27.3", 51236, "TCP", "2"));
         devices.add(new Device("Z1_Ximian_PLC-1-52.22", "XiMianPlc", "铣面辊道PLC", "Z1", "172.20.52.22", 102, "S7", "2"));
@@ -28,6 +28,8 @@ public class DeviceServiceImpl implements DeviceService {
         devices.add(new Device("Z1_DaSanPan_DMQ-2-27.8", "CodeReader8", "大散盘读码器2", "Z1", "172.20.27.8", 51236, "TCP", "2"));
         devices.add(new Device("Z1_DaSanPan_DMQ-3-27.9", "CodeReader9", "大散盘读码器3", "Z1", "172.20.27.9", 51236, "TCP", "2"));
         devices.add(new Device("Z1_DaSanPan_DMQ-4-27.12", "CodeReader12", "大散盘读码器4", "Z1", "172.20.27.12", 51236, "TCP", "2"));
+        devices.add(new Device("Z1_TuiHuoShangLiao_PLC-1-", "TuiHuoUPPlc", "退货上料plc", "Z1", "172.20.27.13", 51236, "s7", "2"));
+        devices.add(new Device("Z1_TuiHuoXiaLiao_PLC-1-", "TuiHuoDownPlc", "退货上料plc", "Z1", "172.20.27.13", 51236, "s7", "2"));
         devices.add(new Device("Z1_TuiHuoShangLiao_DMQ-1-27.13", "CodeReader13", "退货上料读码器", "Z1", "172.20.27.13", 51236, "TCP", "2"));
         devices.add(new Device("Z1_TuiHuoXiaLiao_DMQ-1-27.14", "CodeReader14", "退货下料读码器", "Z1", "172.20.27.14", 51236, "TCP", "2"));
     }

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

@@ -55,6 +55,7 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
         if (weight == 0) {
             log.error("重量信息有误,为0");
         } else {
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_ChengZhong_PLC-1-52.21", "ChengZhongPlc", "成功获取重量信息,重量为:" + weight, "1"));
             //调用MES系统拿到批次号
             String BatchNo = mesService.getBatchNoByWeight(weight, "Z1");
             if (StringUtils.isNotEmpty(BatchNo)) {
@@ -62,6 +63,7 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
                 RetroactiveNow retroactiveNow = new RetroactiveNow(weight, BatchNo, "Z1");
                 retroactiveNow.setCreateBy("system");
                 retroactiveNow.setStatus("1");
+                retroactiveNow.setDeviceId("Z1_ChengZhong_PLC-1-52.21");
                 retroactiveNowService.insertData(retroactiveNow);
                 //反馈plc成功拿到重量生成追溯记录
                 plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.returnWeight.getMetadata(), true);
@@ -70,7 +72,8 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
                 //更新喷码机条码内容
                 String updateCode = InkjetPrintersSetUpTools.updateCode(retroactiveNow.getBatchNo());
                 tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(ParseMsgTools.hexString2Bytes(updateCode));
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", "InkjetPrinters", "喷码内容修改完成,内容为:"+retroactiveNow.getBatchNo(), "1"));
+                redisCache.setCacheObject("InkjetPrinters", updateCode);
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码内容修改完成,内容为:" + retroactiveNow.getBatchNo(), "1"));
                 log.info("追溯记录生成成功,BatchNo:{}", BatchNo);
             }
         }
@@ -84,20 +87,23 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
         retroactiveNow.setStatus("1");
         retroactiveNow = retroactiveNowService.selectTheOneByParameter(retroactiveNow);
         if (ObjectUtil.isNotNull(retroactiveNow)) {
-            //更新喷码机条码内容
-            String updateCode = InkjetPrintersSetUpTools.updateCode(retroactiveNow.getBatchNo());
-            tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(ParseMsgTools.hexString2Bytes(updateCode));
-
+            if (!redisCache.getCacheObject("InkjetPrinters").equals(retroactiveNow.getBatchNo())) {
+                //更新喷码机条码内容
+                String updateCode = InkjetPrintersSetUpTools.updateCode(retroactiveNow.getBatchNo());
+                tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(ParseMsgTools.hexString2Bytes(updateCode));
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码内容修改完成,内容为:" + retroactiveNow.getBatchNo(), "1"));
+            }
+            //回写plc信号进行喷码
         }
     }
 
     @Override
     public void CodeReadingProcess(String codeReadName) {
-        if (redisCache.hasKey(codeReadName)){
-            log.info("读码器{}正在读码!",codeReadName);
+        if (redisCache.hasKey(codeReadName)) {
+            log.info("读码器{}正在读码!", codeReadName);
             return;
         }
         tcpServiceRunner.getTCPInstanceList(codeReadName).getChannel().writeAndFlush(Unpooled.copiedBuffer(CodeReadProperties.startTheCommand, CharsetUtil.UTF_8));
-        redisCache.expire(codeReadName,30, TimeUnit.SECONDS);
+        redisCache.expire(codeReadName, 30, TimeUnit.SECONDS);
     }
 }

+ 3 - 2
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java

@@ -27,7 +27,7 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
     RetroactiveHistoryMapper retroactiveHistoryMapper;
 
     @Override
-    public TableDataInfo<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory, PageDomain pageDomain) {
+    public TableDataInfo<RetroactiveHistory> getListByPage(RetroactiveHistory retroactiveHistory, PageDomain pageDomain) {
         return TableDataInfo.build(retroactiveHistoryMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<RetroactiveHistory>()
                 .like(StringUtils.isNotEmpty(retroactiveHistory.getProductionLine()),RetroactiveHistory::getProductionLine,retroactiveHistory.getProductionLine())
                 .like(StringUtils.isNotEmpty(retroactiveHistory.getBatchNo()),RetroactiveHistory::getBatchNo,retroactiveHistory.getBatchNo())
@@ -42,7 +42,8 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
     public List<RetroactiveHistory> getHistoryList(RetroactiveHistory retroactiveHistory) {
         return retroactiveHistoryMapper.selectList(new LambdaQueryWrapper<RetroactiveHistory>()
                 .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()),RetroactiveHistory::getRetroactiveId,retroactiveHistory.getRetroactiveId())
-                .orderByDesc(RetroactiveHistory::getCreateTime));
+                .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
+                .orderByAsc(RetroactiveHistory::getCreateTime));
     }
 }
 

+ 52 - 27
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -8,7 +8,6 @@ import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.common.exception.ServiceException;
 import com.warewms.common.utils.StringUtils;
-import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.mapper.RetroactiveHistoryMapper;
@@ -19,18 +18,19 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 /**
-* @author AD
-* @description 针对表【retroactive_now(生产追溯表)】的数据库操作Service实现
-* @createDate 2023-08-22 11:02:17
-*/
+ * @author AD
+ * @description 针对表【retroactive_now(生产追溯表)】的数据库操作Service实现
+ * @createDate 2023-08-22 11:02:17
+ */
 @Service
 @Slf4j
 public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper, RetroactiveNow>
-    implements RetroactiveNowService{
+        implements RetroactiveNowService {
 
     @Autowired
     private RetroactiveNowMapper retroactiveNowMapper;
@@ -39,13 +39,13 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     private RetroactiveHistoryMapper retroactiveHistoryMapper;
 
     @Override
-    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain) {
+    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain, List<String> inStatus) {
         Map<String, Object> params = retroactiveNow.getParams();
-        return TableDataInfo.build(retroactiveNowMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<RetroactiveNow>()
-                .like(StringUtils.isNotEmpty(retroactiveNow.getProductionLine()),RetroactiveNow::getProductionLine,retroactiveNow.getProductionLine())
-                .like(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()),RetroactiveNow::getBatchNo,retroactiveNow.getBatchNo())
-                .like(StringUtils.isNotEmpty(retroactiveNow.getLotNo()),RetroactiveNow::getLotNo,retroactiveNow.getLotNo())
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()),RetroactiveNow::getStatus,retroactiveNow.getStatus())
+        return TableDataInfo.build(retroactiveNowMapper.selectPage(pageDomain.build(), new LambdaQueryWrapper<RetroactiveNow>()
+                .like(StringUtils.isNotEmpty(retroactiveNow.getProductionLine()), RetroactiveNow::getProductionLine, retroactiveNow.getProductionLine())
+                .like(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .like(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
+                .in(inStatus.size() > 0, RetroactiveNow::getStatus, inStatus)
                 .orderByDesc(RetroactiveNow::getCreateTime)
         ));
     }
@@ -55,19 +55,19 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
         List<RetroactiveNow> retroactiveNows = retroactiveNowMapper.selectList(new LambdaQueryWrapper<RetroactiveNow>()
                 .eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
         );
-        if (retroactiveNows.size()>0){
+        if (retroactiveNows.size() > 0) {
             throw new ServiceException("数据库中已存在相同批次号");
         }
         retroactiveNowMapper.insert(retroactiveNow);
-        return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(retroactiveNow,RetroactiveHistory.class));
+        return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(retroactiveNow, RetroactiveHistory.class));
     }
 
     @Override
     public RetroactiveNow selectTheOneByParameter(RetroactiveNow retroactiveNow) {
         return retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getRetroactiveId()),RetroactiveNow::getRetroactiveId,retroactiveNow.getRetroactiveId())
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()),RetroactiveNow::getBatchNo,retroactiveNow.getBatchNo())
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()),RetroactiveNow::getStatus,retroactiveNow.getStatus())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getRetroactiveId()), RetroactiveNow::getRetroactiveId, retroactiveNow.getRetroactiveId())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()), RetroactiveNow::getStatus, retroactiveNow.getStatus())
         );
     }
 
@@ -75,20 +75,45 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     @Transactional
     public int updateData(RetroactiveNow retroactiveNow) {
         RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
-                .eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
         );
-        if (ObjectUtil.isNull(baseData)){
-            throw new ServiceException("数据库中不存在该批次号,"+ retroactiveNow.getBatchNo());
+        if (ObjectUtil.isNull(baseData)) {
+            throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
         }
-        if (baseData.getStatus().equals(retroactiveNow)){
-            log.info("数据库存在该状态的数据");
-            return 0;
+        if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
+            throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
         }
-            baseData.setStatus(retroactiveNow.getStatus());
-            baseData.setDeviceId(retroactiveNow.getDeviceId());
-            retroactiveNowMapper.updateById(baseData);
-            return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(baseData,RetroactiveHistory.class));
+        baseData.setStatus(retroactiveNow.getStatus());
+        baseData.setDeviceId(retroactiveNow.getDeviceId());
+        baseData.setUpdateBy("system");
+        retroactiveNowMapper.updateById(baseData);
+        RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
+        retroactiveHistory.setCreateTime(baseData.getUpdateTime());
+        return retroactiveHistoryMapper.insert(retroactiveHistory);
+
+    }
 
+    @Override
+    @Transactional
+    public int finishProduce(RetroactiveNow retroactiveNow) {
+        RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
+        );
+        if (ObjectUtil.isNull(baseData)) {
+            throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
+        }
+        if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
+            throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
+        }
+        baseData.setStatus(retroactiveNow.getStatus());
+        baseData.setDeviceId(retroactiveNow.getDeviceId());
+        baseData.setUpdateBy("system");
+        RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
+        retroactiveHistory.setCreateTime(new Date());
+        retroactiveHistoryMapper.insert(retroactiveHistory);
+        return retroactiveNowMapper.deleteById(baseData);
     }
 }