1
0

6 کامیت‌ها e6a710d998 ... ce5184bedb

نویسنده SHA1 پیام تاریخ
  zhifei ce5184bedb 开发设备日志模块、铜管追溯接口 1 سال پیش
  zhifei b64a48fe5c 编写称重、倒角、铣面、轧制、大散盘定时任务及对接mes系统 1 سال پیش
  zhifei 00985edcc5 删除设备连接冗余代码 1 سال پیش
  zhifei 3f7812c378 对接读码器 1 سال پیش
  zhifei 8a50ba4768 修改定时任务问题 1 سال پیش
  zhifei 8b4f04a649 pcl设备连接添加心跳 1 سال پیش
83فایلهای تغییر یافته به همراه1639 افزوده شده و 1607 حذف شده
  1. 33 0
      warewms-admin/src/main/resources/application-dev.yml
  2. 32 1
      warewms-admin/src/main/resources/application-prod.yml
  3. 234 0
      warewms-admin/src/main/resources/application-test.yml
  4. 4 26
      warewms-admin/src/main/resources/application.yml
  5. 4 4
      warewms-common/src/main/java/com/warewms/common/constant/Constants.java
  6. 11 10
      warewms-quartz/src/main/java/com/warewms/quartz/controller/SysJobController.java
  7. 12 11
      warewms-quartz/src/main/java/com/warewms/quartz/controller/SysJobLogController.java
  8. 7 2
      warewms-quartz/src/main/java/com/warewms/quartz/domain/SysJobLog.java
  9. 16 9
      warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobLogMapper.java
  10. 9 9
      warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobMapper.java
  11. 12 9
      warewms-quartz/src/main/java/com/warewms/quartz/task/service/ISysJobLogService.java
  12. 18 14
      warewms-quartz/src/main/java/com/warewms/quartz/task/service/ISysJobService.java
  13. 22 24
      warewms-quartz/src/main/java/com/warewms/quartz/task/service/impl/SysJobLogServiceImpl.java
  14. 27 16
      warewms-quartz/src/main/java/com/warewms/quartz/task/service/impl/SysJobServiceImpl.java
  15. 2 1
      warewms-quartz/src/main/java/com/warewms/quartz/util/AbstractQuartzJob.java
  16. 22 22
      warewms-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
  17. 6 0
      warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java
  18. 24 2
      warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java
  19. 0 70
      warewms-system/src/main/java/com/warewms/hailiang/common/ChannelMap.java
  20. 0 75
      warewms-system/src/main/java/com/warewms/hailiang/common/DtuManage.java
  21. 0 51
      warewms-system/src/main/java/com/warewms/hailiang/common/MyDecoder.java
  22. 0 90
      warewms-system/src/main/java/com/warewms/hailiang/common/MyEncoder.java
  23. 0 55
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServer.java
  24. 0 28
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerChannelInitializer.java
  25. 0 152
      warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerHandler.java
  26. 14 0
      warewms-system/src/main/java/com/warewms/hailiang/config/CodeReadProperties.java
  27. 0 63
      warewms-system/src/main/java/com/warewms/hailiang/config/LaunchRunner.java
  28. 3 0
      warewms-system/src/main/java/com/warewms/hailiang/config/PlcConfig.java
  29. 0 29
      warewms-system/src/main/java/com/warewms/hailiang/config/SocketProperties.java
  30. 54 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader12Connect.java
  31. 29 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java
  32. 29 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader14Connect.java
  33. 82 20
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java
  34. 77 14
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader5Connect.java
  35. 56 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader6Connect.java
  36. 54 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader7Connect.java
  37. 29 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java
  38. 29 7
      warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader9Connect.java
  39. 91 30
      warewms-system/src/main/java/com/warewms/hailiang/connect/InkjetPrintersConnect.java
  40. 7 1
      warewms-system/src/main/java/com/warewms/hailiang/connect/TCPConnectBase.java
  41. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader12Handler.java
  42. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader13Handler.java
  43. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader14Handler.java
  44. 0 49
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader3Handler.java
  45. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader5Handler.java
  46. 0 46
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader6Handler.java
  47. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader7Handler.java
  48. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader8Handler.java
  49. 0 45
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader9Handler.java
  50. 0 50
      warewms-system/src/main/java/com/warewms/hailiang/connect/handler/InkjetPrintersHandler.java
  51. 3 2
      warewms-system/src/main/java/com/warewms/hailiang/contoller/DeviceController.java
  52. 2 0
      warewms-system/src/main/java/com/warewms/hailiang/contoller/DeviceLogController.java
  53. 38 0
      warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveHistoryController.java
  54. 36 0
      warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java
  55. 33 2
      warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java
  56. 3 1
      warewms-system/src/main/java/com/warewms/hailiang/domain/Device.java
  57. 8 0
      warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java
  58. 9 97
      warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveHistory.java
  59. 4 92
      warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveNow.java
  60. 24 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/DaSanPanPlcEnum.java
  61. 5 1
      warewms-system/src/main/java/com/warewms/hailiang/enums/DaoJiaoPlcEnum.java
  62. 9 1
      warewms-system/src/main/java/com/warewms/hailiang/enums/DeviceNameEnum.java
  63. 2 2
      warewms-system/src/main/java/com/warewms/hailiang/enums/InkjetPrintersDirectivesEnum.java
  64. 3 3
      warewms-system/src/main/java/com/warewms/hailiang/enums/WeighPlcEnum.java
  65. 20 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/XiMianPlcEnum.java
  66. 20 0
      warewms-system/src/main/java/com/warewms/hailiang/enums/ZhaZhiPlcEnum.java
  67. 54 4
      warewms-system/src/main/java/com/warewms/hailiang/init/PlcConnectServiceRunner.java
  68. 28 14
      warewms-system/src/main/java/com/warewms/hailiang/init/TcpServiceRunner.java
  69. 47 10
      warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java
  70. 3 0
      warewms-system/src/main/java/com/warewms/hailiang/service/DeviceLogService.java
  71. 2 0
      warewms-system/src/main/java/com/warewms/hailiang/service/DeviceService.java
  72. 8 2
      warewms-system/src/main/java/com/warewms/hailiang/service/ProcessRealizationService.java
  73. 8 0
      warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveHistoryService.java
  74. 7 0
      warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveNowService.java
  75. 6 1
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceLogServiceImpl.java
  76. 18 3
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceServiceImpl.java
  77. 48 19
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/ProcessRealizationServiceImpl.java
  78. 29 0
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java
  79. 40 3
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java
  80. 67 0
      warewms-system/src/main/java/com/warewms/hailiang/util/InkjetPrintersSetUpTools.java
  81. 3 1
      warewms-system/src/main/java/com/warewms/hailiang/util/ParseMsgTools.java
  82. 1 1
      warewms-system/src/main/resources/mapper/hailiang/DeviceLogMapper.xml
  83. 2 1
      warewms-system/src/main/resources/mapper/hailiang/RetroactiveHistoryMapper.xml

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

@@ -199,3 +199,36 @@ xss:
   excludes: /system/notice
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
+
+# plc连接配置
+plc:
+  plcList[0]:
+    ip: 172.20.52.21
+    enable: false
+    name: ChengZhongPlc
+    ePlcType: S1200
+    heartbeat:
+  plcList[1]:
+    ip: 172.20.27.2
+    enable: false
+    name: DaoJiaoJiPlc
+    ePlcType: S200_SMART
+    heartbeat:
+  plcList[2]:
+    ip: 172.20.52.22
+    enable: false
+    name: XiMianPlc
+    ePlcType: S1200
+    heartbeat: BD200.0.0
+  plcList[3]:
+    ip: 172.20.52.24
+    enable: false
+    name: ZhaZhiPlc
+    ePlcType: S1500
+    heartbeat: BD300.0.0
+  plcList[4]:
+    ip: 172.20.54.121
+    enable: false
+    name: DaSanPanPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

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

@@ -200,4 +200,35 @@ xss:
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
 
-
+# plc连接配置
+plc:
+  plcList[0]:
+    ip: 172.20.52.21
+    enable: true
+    name: ChengZhongPlc
+    ePlcType: S1200
+    heartbeat:
+  plcList[1]:
+    ip: 172.20.27.2
+    enable: true
+    name: DaoJiaoJiPlc
+    ePlcType: S200_SMART
+    heartbeat:
+  plcList[2]:
+    ip: 172.20.52.22
+    enable: true
+    name: XiMianPlc
+    ePlcType: S1200
+    heartbeat: BD200.0.0
+  plcList[3]:
+    ip: 172.20.52.24
+    enable: true
+    name: ZhaZhiPlc
+    ePlcType: S1500
+    heartbeat: BD300.0.0
+  plcList[4]:
+    ip: 172.20.54.121
+    enable: true
+    name: DaSanPanPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

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

@@ -0,0 +1,234 @@
+# 项目相关配置
+warewms:
+  # 名称
+  name: automated warehouse management system
+  # 版本
+  version: 1.0
+  # 版权年份
+  copyrightYear: 2023
+  # 实例演示开关
+  demoEnabled: true
+  # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
+  profile: D:/warewms/uploadPath
+  # 获取ip地址开关
+  addressEnabled: false
+  # 验证码类型 math 数组计算 char 字符验证
+  captchaType: math
+
+# 开发环境配置
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 8080
+  servlet:
+    # 应用的访问路径
+    context-path: /
+  tomcat:
+    # tomcat的URI编码
+    uri-encoding: UTF-8
+    # 连接数满后的排队数,默认为100
+    accept-count: 1000
+    threads:
+      # tomcat最大线程数,默认为200
+      max: 800
+      # Tomcat启动初始化的线程数,默认值10
+      min-spare: 100
+
+# 日志配置
+logging:
+  level:
+    com.ruoyi: debug
+    org.springframework: warn
+
+# 用户配置
+user:
+  password:
+    # 密码最大错误次数
+    maxRetryCount: 5
+    # 密码锁定时间(默认10分钟)
+    lockTime: 10
+
+# Spring配置
+spring:
+  # 资源信息
+  messages:
+    # 国际化资源文件路径
+    basename: i18n/messages
+  # 文件上传
+  servlet:
+     multipart:
+       # 单个文件大小
+       max-file-size:  10MB
+       # 设置总上传的文件大小
+       max-request-size:  20MB
+  # 数据源配置
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://localhost:3306/ahhl_tarece?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
+        username: root
+        password: root
+      # 从库数据源
+      slave:
+        # 从数据源开关/默认关闭
+        enabled: false
+        url:
+        username:
+        password:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: admin
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+  # redis 配置
+  redis:
+    # 地址
+    host: localhost
+    # 端口,默认为6379
+    port: 6379
+    # 数据库索引
+    database: 0
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+
+# token配置
+token:
+    # 令牌自定义标识
+    header: Authorization
+    # 令牌密钥
+    secret: abcdefghijklmnopqrstuvwxyz
+    # 令牌有效期(默认30分钟)
+    expireTime: 30
+
+# MyBatis Plus配置
+mybatis-plus:
+
+  mapper-locations: classpath*:/mapper/**/*.xml,classpath:/META-INF/modeler-mybatis-mappings/*.xml
+  #实体扫描,多个package用逗号或者分号分隔
+  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级
+  # 例如 com.**.**.mapper
+  mapperPackage: com.warewms.**.mapper
+  # 实体扫描,多个package用逗号或者分号分隔
+  typeAliasesPackage: com.warewms.**.domain
+  configuration:
+    # 自动驼峰命名规则(camel case)映射
+    mapUnderscoreToCamelCase: true
+    # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
+    # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
+    logImpl: org.apache.ibatis.logging.stdout.StdOutImpl
+  global-config:
+    # 是否打印 Logo banner
+    banner: false
+    dbConfig:
+      # 主键类型
+      # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
+      idType: AUTO
+      logic-delete-field: deleted # 全局逻辑删除的实体字段名
+      logic-delete-value: 1 # 逻辑已删除值(默认为 1)
+      logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
+
+
+# Knife4j配置
+knife4j:
+  #开启增强配置
+  enable: true
+  #开启生产环境屏蔽
+  production: false
+  basic:
+    enable: false
+    username: admin
+    password: 123456
+
+# 防止XSS攻击
+xss:
+  # 过滤开关
+  enabled: true
+  # 排除链接(多个用逗号分隔)
+  excludes: /system/notice
+  # 匹配链接
+  urlPatterns: /system/*,/monitor/*,/tool/*
+
+# plc连接配置
+plc:
+  plcList[0]:
+    ip: 172.20.52.21
+    enable: false
+    name: ChengZhongPlc
+    ePlcType: S1200
+    heartbeat:
+  plcList[1]:
+    ip: 172.20.27.2
+    enable: false
+    name: DaoJiaoJiPlc
+    ePlcType: S200_SMART
+    heartbeat:
+  plcList[2]:
+    ip: 172.20.52.22
+    enable: false
+    name: XiMianPlc
+    ePlcType: S1200
+    heartbeat: BD200.0.0
+  plcList[3]:
+    ip: 172.20.52.24
+    enable: false
+    name: ZhaZhiPlc
+    ePlcType: S1500
+    heartbeat: BD300.0.0
+  plcList[4]:
+    ip: 172.20.54.121
+    enable: false
+    name: DaSanPanPlc
+    ePlcType: S1500
+    heartbeat: BD200.0.0

+ 4 - 26
warewms-admin/src/main/resources/application.yml

@@ -2,36 +2,14 @@
 spring:
   profiles:
     active: test
-socket:
-  InkjetPrinters:
-
-
-plc:
-  plcList[0]:
-    ip: 172.20.52.21
-    enable: false
-    name: ChengZhongPlc
-    ePlcType: S1200
-    heartbeat: DB11.0.0
-  plcList[1]:
-    ip: 172.20.27.2
-    enable: false
-    name: DaoJiaoJiPlc
-    ePlcType: S200_SMART
-    heartbeat:
-  plcList[2]:
-    ip: 172.20.52.24
-    enable: false
-    name: ZaZhiPlc
-    ePlcType: S1500
-    heartbeat:
 
+# MES对接接口
 MES:
-  address: http://192.20.2.4:9090
+  address: http://172.20.2.2:9090
   #获取批次号
   getBatchNoUrl: /api/SprayCode/SprayBatchNo
   #获取批次号回调
   getBatchNoResultUrl: /api/SprayCode/SprayBatchNoResult
-  #铣面
-  MillingSurfaceUrl: /api/SprayCode/SprayMillingSurface
+  #工艺读码反馈
+  processFeedbackUrl: /api/SprayCode/SprayMillingSurface
 

+ 4 - 4
warewms-common/src/main/java/com/warewms/common/constant/Constants.java

@@ -4,7 +4,7 @@ import io.jsonwebtoken.Claims;
 
 /**
  * 通用常量信息
- * 
+ *
  * @author ruoyi
  */
 public class Constants
@@ -63,7 +63,7 @@ public class Constants
      * 登录失败
      */
     public static final String LOGIN_FAIL = "Error";
- 
+
     /**
      * 验证码有效期(分钟)
      */
@@ -132,13 +132,13 @@ public class Constants
     /**
      * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
      */
-    public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
+    public static final String[] JOB_WHITELIST_STR = { "com.warewms" };
 
     /**
      * 定时任务违规的字符
      */
     public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
-            "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" };
+            "org.springframework", "org.apache", "com.warewms.common.utils.file", "com.warewms.common.config" };
 
 
 

+ 11 - 10
warewms-quartz/src/main/java/com/warewms/quartz/controller/SysJobController.java

@@ -2,6 +2,9 @@ package com.warewms.quartz.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.warewms.common.core.domain.base.page.PageDomain;
+import com.warewms.common.core.domain.base.page.TableDataInfo;
 import org.quartz.SchedulerException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -28,7 +31,7 @@ import com.warewms.quartz.util.ScheduleUtils;
 
 /**
  * 调度任务信息操作处理
- * 
+ *
  * @author ruoyi
  */
 @RestController
@@ -41,14 +44,12 @@ public class SysJobController extends BaseController
     /**
      * 查询定时任务列表
      */
-    /*@PreAuthorize("@ss.hasPermi('monitor:job:list')")
+    @PreAuthorize("@ss.hasPermi('monitor:job:list')")
     @GetMapping("/list")
-    public TableDataInfo list(SysJob sysJob)
+    public TableDataInfo list(SysJob sysJob, PageDomain pageDomain)
     {
-        startPage();
-        List<SysJob> list = jobService.selectJobList(sysJob);
-        return getDataTable(list);
-    }*/
+        return jobService.selectJobList(sysJob,pageDomain);
+    }
 
     /**
      * 导出定时任务列表
@@ -56,11 +57,11 @@ public class SysJobController extends BaseController
     @PreAuthorize("@ss.hasPermi('monitor:job:export')")
     @Log(title = "定时任务", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, SysJob sysJob)
+    public void export(HttpServletResponse response, SysJob sysJob, PageDomain pageDomain)
     {
-        List<SysJob> list = jobService.selectJobList(sysJob);
+        TableDataInfo<SysJob> sysJobTableDataInfo = jobService.selectJobList(sysJob, pageDomain);
         ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
-        util.exportExcel(response, list, "定时任务");
+        util.exportExcel(response, sysJobTableDataInfo.getRows(), "定时任务");
     }
 
     /**

+ 12 - 11
warewms-quartz/src/main/java/com/warewms/quartz/controller/SysJobLogController.java

@@ -2,6 +2,9 @@ package com.warewms.quartz.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.warewms.common.core.domain.base.page.PageDomain;
+import com.warewms.common.core.domain.base.page.TableDataInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -20,7 +23,7 @@ import com.warewms.quartz.task.service.ISysJobLogService;
 
 /**
  * 调度日志操作处理
- * 
+ *
  * @author ruoyi
  */
 @RestController
@@ -33,14 +36,12 @@ public class SysJobLogController extends BaseController
     /**
      * 查询定时任务调度日志列表
      */
-    /*@PreAuthorize("@ss.hasPermi('monitor:job:list')")
+    @PreAuthorize("@ss.hasPermi('monitor:job:list')")
     @GetMapping("/list")
-    public TableDataInfo list(SysJobLog sysJobLog)
+    public TableDataInfo<SysJobLog> list(SysJobLog sysJobLog, PageDomain pageDomain)
     {
-        startPage();
-        List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
-        return getDataTable(list);
-    }*/
+        return jobLogService.selectJobLogList(sysJobLog,pageDomain);
+    }
 
     /**
      * 导出定时任务调度日志列表
@@ -48,13 +49,13 @@ public class SysJobLogController extends BaseController
     @PreAuthorize("@ss.hasPermi('monitor:job:export')")
     @Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, SysJobLog sysJobLog)
+    public void export(HttpServletResponse response, SysJobLog sysJobLog, PageDomain pageDomain)
     {
-        List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
+        TableDataInfo<SysJobLog>  sysJobLogTableDataInfo= jobLogService.selectJobLogList(sysJobLog, pageDomain);
         ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
-        util.exportExcel(response, list, "调度日志");
+        util.exportExcel(response, sysJobLogTableDataInfo.getRows(), "调度日志");
     }
-    
+
     /**
      * 根据调度编号获取详细信息
      */

+ 7 - 2
warewms-quartz/src/main/java/com/warewms/quartz/domain/SysJobLog.java

@@ -1,6 +1,9 @@
 package com.warewms.quartz.domain;
 
 import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.warewms.common.annotation.Excel;
@@ -8,15 +11,17 @@ import com.warewms.common.core.domain.base.BaseEntity;
 
 /**
  * 定时任务调度日志表 sys_job_log
- * 
+ *
  * @author ruoyi
  */
+@TableName("sys_job_log")
 public class SysJobLog extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
 
     /** ID */
     @Excel(name = "日志序号")
+    @TableId
     private Long jobLogId;
 
     /** 任务名称 */
@@ -128,7 +133,7 @@ public class SysJobLog extends BaseEntity
     {
         this.startTime = startTime;
     }
-    
+
     public Date getStopTime()
     {
         return stopTime;

+ 16 - 9
warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobLogMapper.java

@@ -1,22 +1,29 @@
 package com.warewms.quartz.mapper;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.quartz.domain.SysJobLog;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 调度任务日志信息 数据层
- * 
+ *
  * @author ruoyi
  */
-public interface SysJobLogMapper
+public interface SysJobLogMapper extends BaseMapper<SysJobLog>
 {
     /**
      * 获取quartz调度器日志的计划任务
-     * 
-     * @param jobLog 调度日志信息
+     *
+     * @param jobLog     调度日志信息
+     * @param pageDomain
      * @return 调度任务日志集合
      */
-    public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
+    public IPage<SysJobLog> selectJobLogList(@Param("jobLog") SysJobLog jobLog, @Param("page") Page<SysJobLog> page);
 
     /**
      * 查询所有调度任务日志
@@ -27,7 +34,7 @@ public interface SysJobLogMapper
 
     /**
      * 通过调度任务日志ID查询调度信息
-     * 
+     *
      * @param jobLogId 调度任务日志ID
      * @return 调度任务日志对象信息
      */
@@ -35,7 +42,7 @@ public interface SysJobLogMapper
 
     /**
      * 新增任务日志
-     * 
+     *
      * @param jobLog 调度日志信息
      * @return 结果
      */
@@ -43,7 +50,7 @@ public interface SysJobLogMapper
 
     /**
      * 批量删除调度日志信息
-     * 
+     *
      * @param logIds 需要删除的数据ID
      * @return 结果
      */
@@ -51,7 +58,7 @@ public interface SysJobLogMapper
 
     /**
      * 删除任务日志
-     * 
+     *
      * @param jobId 调度日志ID
      * @return 结果
      */

+ 9 - 9
warewms-quartz/src/main/java/com/warewms/quartz/mapper/SysJobMapper.java

@@ -7,14 +7,14 @@ import com.warewms.quartz.domain.SysJob;
 
 /**
  * 调度任务信息 数据层
- * 
+ *
  * @author ruoyi
  */
-public interface SysJobMapper
+public interface SysJobMapper extends BaseMapper<SysJob>
 {
     /**
      * 查询调度任务日志集合
-     * 
+     *
      * @param job 调度信息
      * @return 操作日志集合
      */
@@ -22,14 +22,14 @@ public interface SysJobMapper
 
     /**
      * 查询所有调度任务
-     * 
+     *
      * @return 调度任务列表
      */
     public List<SysJob> selectJobAll();
 
     /**
      * 通过调度ID查询调度任务信息
-     * 
+     *
      * @param jobId 调度ID
      * @return 角色对象信息
      */
@@ -37,7 +37,7 @@ public interface SysJobMapper
 
     /**
      * 通过调度ID删除调度任务信息
-     * 
+     *
      * @param jobId 调度ID
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface SysJobMapper
 
     /**
      * 批量删除调度任务信息
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
@@ -53,7 +53,7 @@ public interface SysJobMapper
 
     /**
      * 修改调度任务信息
-     * 
+     *
      * @param job 调度任务信息
      * @return 结果
      */
@@ -61,7 +61,7 @@ public interface SysJobMapper
 
     /**
      * 新增调度任务信息
-     * 
+     *
      * @param job 调度任务信息
      * @return 结果
      */

+ 12 - 9
warewms-quartz/src/main/java/com/warewms/quartz/task/service/ISysJobLogService.java

@@ -1,26 +1,29 @@
 package com.warewms.quartz.task.service;
 
-import java.util.List;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.warewms.common.core.domain.base.page.PageDomain;
+import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.quartz.domain.SysJobLog;
 
 /**
  * 定时任务调度日志信息信息 服务层
- * 
+ *
  * @author ruoyi
  */
 public interface ISysJobLogService
 {
     /**
      * 获取quartz调度器日志的计划任务
-     * 
-     * @param jobLog 调度日志信息
+     *
+     * @param jobLog     调度日志信息
+     * @param pageDomain
      * @return 调度任务日志集合
      */
-    public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
+    public TableDataInfo<SysJobLog> selectJobLogList(SysJobLog jobLog, PageDomain pageDomain);
 
     /**
      * 通过调度任务日志ID查询调度信息
-     * 
+     *
      * @param jobLogId 调度任务日志ID
      * @return 调度任务日志对象信息
      */
@@ -28,14 +31,14 @@ public interface ISysJobLogService
 
     /**
      * 新增任务日志
-     * 
+     *
      * @param jobLog 调度日志信息
      */
     public void addJobLog(SysJobLog jobLog);
 
     /**
      * 批量删除调度日志信息
-     * 
+     *
      * @param logIds 需要删除的日志ID
      * @return 结果
      */
@@ -43,7 +46,7 @@ public interface ISysJobLogService
 
     /**
      * 删除任务日志
-     * 
+     *
      * @param jobId 调度日志ID
      * @return 结果
      */

+ 18 - 14
warewms-quartz/src/main/java/com/warewms/quartz/task/service/ISysJobService.java

@@ -1,28 +1,32 @@
 package com.warewms.quartz.task.service;
 
 import java.util.List;
+
+import com.warewms.common.core.domain.base.page.PageDomain;
+import com.warewms.common.core.domain.base.page.TableDataInfo;
 import org.quartz.SchedulerException;
 import com.warewms.common.exception.job.TaskException;
 import com.warewms.quartz.domain.SysJob;
 
 /**
  * 定时任务调度信息信息 服务层
- * 
+ *
  * @author ruoyi
  */
 public interface ISysJobService
 {
     /**
      * 获取quartz调度器的计划任务
-     * 
-     * @param job 调度信息
+     *
+     * @param job        调度信息
+     * @param pageDomain
      * @return 调度任务集合
      */
-    public List<SysJob> selectJobList(SysJob job);
+    public TableDataInfo selectJobList(SysJob job, PageDomain pageDomain);
 
     /**
      * 通过调度任务ID查询调度信息
-     * 
+     *
      * @param jobId 调度任务ID
      * @return 调度任务对象信息
      */
@@ -30,7 +34,7 @@ public interface ISysJobService
 
     /**
      * 暂停任务
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -38,7 +42,7 @@ public interface ISysJobService
 
     /**
      * 恢复任务
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -46,7 +50,7 @@ public interface ISysJobService
 
     /**
      * 删除任务后,所对应的trigger也将被删除
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -54,7 +58,7 @@ public interface ISysJobService
 
     /**
      * 批量删除调度信息
-     * 
+     *
      * @param jobIds 需要删除的任务ID
      * @return 结果
      */
@@ -62,7 +66,7 @@ public interface ISysJobService
 
     /**
      * 任务调度状态修改
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -70,7 +74,7 @@ public interface ISysJobService
 
     /**
      * 立即运行任务
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -78,7 +82,7 @@ public interface ISysJobService
 
     /**
      * 新增任务
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -86,7 +90,7 @@ public interface ISysJobService
 
     /**
      * 更新任务
-     * 
+     *
      * @param job 调度信息
      * @return 结果
      */
@@ -94,7 +98,7 @@ public interface ISysJobService
 
     /**
      * 校验cron表达式是否有效
-     * 
+     *
      * @param cronExpression 表达式
      * @return 结果
      */

+ 22 - 24
warewms-quartz/src/main/java/com/warewms/quartz/task/service/impl/SysJobLogServiceImpl.java

@@ -1,79 +1,78 @@
 package com.warewms.quartz.task.service.impl;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.quartz.task.service.ISysJobLogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.warewms.quartz.domain.SysJobLog;
 import com.warewms.quartz.mapper.SysJobLogMapper;
 
+import java.util.Map;
+
 /**
  * 定时任务调度日志信息 服务层
- * 
+ *
  * @author ruoyi
  */
 @Service
-public class SysJobLogServiceImpl implements ISysJobLogService
-{
+public class SysJobLogServiceImpl implements ISysJobLogService {
     @Autowired
     private SysJobLogMapper jobLogMapper;
 
     /**
      * 获取quartz调度器日志的计划任务
-     * 
-     * @param jobLog 调度日志信息
+     *
+     * @param jobLog     调度日志信息
+     * @param pageDomain
      * @return 调度任务日志集合
      */
     @Override
-    public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
-    {
-        return jobLogMapper.selectJobLogList(jobLog);
+    public TableDataInfo<SysJobLog> selectJobLogList(SysJobLog jobLog, PageDomain pageDomain) {
+       return TableDataInfo.build( jobLogMapper.selectJobLogList(jobLog,pageDomain.build()));
     }
 
     /**
      * 通过调度任务日志ID查询调度信息
-     * 
+     *
      * @param jobLogId 调度任务日志ID
      * @return 调度任务日志对象信息
      */
     @Override
-    public SysJobLog selectJobLogById(Long jobLogId)
-    {
+    public SysJobLog selectJobLogById(Long jobLogId) {
         return jobLogMapper.selectJobLogById(jobLogId);
     }
 
     /**
      * 新增任务日志
-     * 
+     *
      * @param jobLog 调度日志信息
      */
     @Override
-    public void addJobLog(SysJobLog jobLog)
-    {
+    public void addJobLog(SysJobLog jobLog) {
         jobLogMapper.insertJobLog(jobLog);
     }
 
     /**
      * 批量删除调度日志信息
-     * 
+     *
      * @param logIds 需要删除的数据ID
      * @return 结果
      */
     @Override
-    public int deleteJobLogByIds(Long[] logIds)
-    {
+    public int deleteJobLogByIds(Long[] logIds) {
         return jobLogMapper.deleteJobLogByIds(logIds);
     }
 
     /**
      * 删除任务日志
-     * 
+     *
      * @param jobId 调度日志ID
      */
     @Override
-    public int deleteJobLogById(Long jobId)
-    {
+    public int deleteJobLogById(Long jobId) {
         return jobLogMapper.deleteJobLogById(jobId);
     }
 
@@ -81,8 +80,7 @@ public class SysJobLogServiceImpl implements ISysJobLogService
      * 清空任务日志
      */
     @Override
-    public void cleanJobLog()
-    {
+    public void cleanJobLog() {
         jobLogMapper.cleanJobLog();
     }
 }

+ 27 - 16
warewms-quartz/src/main/java/com/warewms/quartz/task/service/impl/SysJobServiceImpl.java

@@ -2,6 +2,12 @@ package com.warewms.quartz.task.service.impl;
 
 import java.util.List;
 import javax.annotation.PostConstruct;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.quartz.domain.SysJobLog;
 import org.quartz.JobDataMap;
 import org.quartz.JobKey;
 import org.quartz.Scheduler;
@@ -19,7 +25,7 @@ import com.warewms.quartz.util.ScheduleUtils;
 
 /**
  * 定时任务调度信息 服务层
- * 
+ *
  * @author ruoyi
  */
 @Service
@@ -47,19 +53,24 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 获取quartz调度器的计划任务列表
-     * 
-     * @param job 调度信息
+     *
+     * @param job        调度信息
+     * @param pageDomain
      * @return
      */
     @Override
-    public List<SysJob> selectJobList(SysJob job)
+    public TableDataInfo selectJobList(SysJob job, PageDomain pageDomain)
     {
-        return jobMapper.selectJobList(job);
+        return TableDataInfo.build( jobMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<SysJob>()
+                .eq(StringUtils.isNotEmpty(job.getJobName()), SysJob::getJobName, job.getJobName())
+                .eq(StringUtils.isNotEmpty(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup())
+                .eq(StringUtils.isNotEmpty(job.getStatus()), SysJob::getStatus, job.getStatus())
+        ));
     }
 
     /**
      * 通过调度任务ID查询调度信息
-     * 
+     *
      * @param jobId 调度任务ID
      * @return 调度任务对象信息
      */
@@ -71,7 +82,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 暂停任务
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -91,7 +102,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 恢复任务
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -111,7 +122,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 删除任务后,所对应的trigger也将被删除
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -130,7 +141,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 批量删除调度信息
-     * 
+     *
      * @param jobIds 需要删除的任务ID
      * @return 结果
      */
@@ -147,7 +158,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 任务调度状态修改
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -169,7 +180,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 立即运行任务
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -194,7 +205,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 新增任务
-     * 
+     *
      * @param job 调度信息 调度信息
      */
     @Override
@@ -212,7 +223,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 更新任务的时间表达式
-     * 
+     *
      * @param job 调度信息
      */
     @Override
@@ -230,7 +241,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 更新任务
-     * 
+     *
      * @param job 任务对象
      * @param jobGroup 任务组名
      */
@@ -249,7 +260,7 @@ public class SysJobServiceImpl implements ISysJobService
 
     /**
      * 校验cron表达式是否有效
-     * 
+     *
      * @param cronExpression 表达式
      * @return 结果
      */

+ 2 - 1
warewms-quartz/src/main/java/com/warewms/quartz/util/AbstractQuartzJob.java

@@ -91,7 +91,8 @@ public abstract class AbstractQuartzJob implements Job
         {
             sysJobLog.setStatus(Constants.SUCCESS);
         }
-
+        sysJobLog.setCreateBy("admin");
+        sysJobLog.setUpdateBy("admin");
         // 写入数据库当中
         SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
     }

+ 22 - 22
warewms-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml

@@ -14,60 +14,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="exceptionInfo"  column="exception_info"  />
 		<result property="createTime"     column="create_time"     />
 	</resultMap>
-	
+
 	<sql id="selectJobLogVo">
-        select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time 
+        select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
 		from sys_job_log
     </sql>
-	
+
 	<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 		<where>
-			<if test="jobName != null and jobName != ''">
-				AND job_name like concat('%', #{jobName}, '%')
+			<if test="jobLog.jobName != null and jobLog.jobName != ''">
+				AND job_name like concat('%', #{jobLog.jobName}, '%')
 			</if>
-			<if test="jobGroup != null and jobGroup != ''">
+			<if test="jobLog.jobGroup != null and jobLog.jobGroup != ''">
 				AND job_group = #{jobGroup}
 			</if>
-			<if test="status != null and status != ''">
-				AND status = #{status}
+			<if test="jobLog.status != null and jobLog.status != ''">
+				AND status = #{jobLog.status}
 			</if>
-			<if test="invokeTarget != null and invokeTarget != ''">
-				AND invoke_target like concat('%', #{invokeTarget}, '%')
+			<if test="jobLog.invokeTarget != null and jobLog.invokeTarget != ''">
+				AND invoke_target like concat('%', #{jobLog.invokeTarget}, '%')
 			</if>
-			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
+			<if test="jobLog.params.beginTime != null and jobLog.params.beginTime != ''"><!-- 开始时间检索 -->
+				and date_format(create_time,'%y%m%d') &gt;= date_format(#{jobLog.params.beginTime},'%y%m%d')
 			</if>
-			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+			<if test="jobLog.params.endTime != null and jobLog.params.endTime != ''"><!-- 结束时间检索 -->
+				and date_format(create_time,'%y%m%d') &lt;= date_format(#{jobLog.params.endTime},'%y%m%d')
 			</if>
 		</where>
 	</select>
-	
+
 	<select id="selectJobLogAll" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 	</select>
-	
+
 	<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
 		<include refid="selectJobLogVo"/>
 		where job_log_id = #{jobLogId}
 	</select>
-	
+
 	<delete id="deleteJobLogById" parameterType="Long">
  		delete from sys_job_log where job_log_id = #{jobLogId}
  	</delete>
- 	
+
  	<delete id="deleteJobLogByIds" parameterType="Long">
  		delete from sys_job_log where job_log_id in
  		<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
  			#{jobLogId}
-        </foreach> 
+        </foreach>
  	</delete>
- 	
+
  	<update id="cleanJobLog">
         truncate table sys_job_log
     </update>
- 	
+
  	<insert id="insertJobLog" parameterType="SysJobLog">
  		insert into sys_job_log(
  			<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
@@ -90,4 +90,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		)
 	</insert>
 
-</mapper> 
+</mapper>

+ 6 - 0
warewms-system/src/main/java/com/warewms/hailiang/MES/MesService.java

@@ -28,4 +28,10 @@ public interface MesService {
      * @return
      */
     public JSONObject getBatchNoResult(String batchNo,boolean result);
+
+
+    /**
+     * 工艺反馈接口
+     */
+    public JSONObject processFeedback(String batchNo,String type);
 }

+ 24 - 2
warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java

@@ -34,6 +34,8 @@ public class MesServiceImpl implements MesService {
     @Value("${MES.getBatchNoResultUrl}")
     private String getBatchNoResultURl;
 
+    @Value("${MES.processFeedbackUrl}")
+    private String processFeedbackUrl;
 
 
     @Override
@@ -45,7 +47,6 @@ public class MesServiceImpl implements MesService {
         String body = null;
         try {
           body = HttpRequest.post(MESAddress + getBatchNoUrl).body(entries.toString()).execute().body();
-
         }catch (Exception e){
             log.error("调用MES系统拿铜管批次号失败,msg:{}",e.getMessage());
             return null;
@@ -64,6 +65,27 @@ public class MesServiceImpl implements MesService {
         entries.set("BatchNo",batchNo);
         entries.set("Result",result);
         String body = HttpRequest.post(MESAddress + getBatchNoResultURl).body(entries.toString()).execute().body();
-        return  JSONUtil.parseObj(body);
+        JSONObject jsonObject = JSONUtil.parseObj(body);
+        if ("false".equals(jsonObject.get("ret"))){
+            log.error("喷码成功反馈MES失败,msg:{}",jsonObject.get("message"));
+            return null;
+        }
+
+        return jsonObject;
+    }
+
+    @Override
+    public JSONObject processFeedback(String batchNo, String type) {
+        JSONObject entries = new JSONObject();
+        entries.set("BatchNo",batchNo);
+        entries.set("Type",type);
+        String body = HttpRequest.post(MESAddress + processFeedbackUrl).body(entries.toString()).execute().body();
+        JSONObject jsonObject = JSONUtil.parseObj(body);
+        if ("false".equals(jsonObject.get("ret"))){
+            log.error("喷码成功反馈MES失败,msg:{}",jsonObject.get("message"));
+            return null;
+        }
+
+        return jsonObject;
     }
 }

+ 0 - 70
warewms-system/src/main/java/com/warewms/hailiang/common/ChannelMap.java

@@ -1,70 +0,0 @@
-package com.warewms.hailiang.common;
-
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelId;
-import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
-import org.springframework.util.CollectionUtils;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 功能描述: 管理通道Map类
- *
- * @Author keLe
- * @Date 2022/8/26
- */
-public class ChannelMap {
-
-    /**
-     * 管理一个全局map,保存连接进服务端的通道数量
-     */
-    private static final ConcurrentHashMap<ChannelId, Channel> CHANNEL_MAP = new ConcurrentHashMap<>(128);
-
-    public static ConcurrentHashMap<ChannelId, Channel> getChannelMap() {
-        return CHANNEL_MAP;
-    }
-
-    /**
-     *  获取指定name的channel
-     */
-    public static Channel getChannelByName(ChannelId channelId){
-        if(CollectionUtils.isEmpty(CHANNEL_MAP)){
-            return null;
-        }
-        return CHANNEL_MAP.get(channelId);
-    }
-
-    /**
-     *  将通道中的消息推送到每一个客户端
-     */
-    public static boolean pushNewsToAllClient(String obj){
-        if(CollectionUtils.isEmpty(CHANNEL_MAP)){
-            return false;
-        }
-        for(ChannelId channelId: CHANNEL_MAP.keySet()) {
-            Channel channel = CHANNEL_MAP.get(channelId);
-            channel.writeAndFlush(new TextWebSocketFrame(obj));
-        }
-        return true;
-    }
-
-    /**
-     *  将channel和对应的name添加到ConcurrentHashMap
-     */
-    public static void addChannel(ChannelId channelId,Channel channel){
-        CHANNEL_MAP.put(channelId,channel);
-    }
-
-    /**
-     *  移除掉name对应的channel
-     */
-    public static boolean removeChannelByName(ChannelId channelId){
-        if(CHANNEL_MAP.containsKey(channelId)){
-            CHANNEL_MAP.remove(channelId);
-            return true;
-        }
-        return false;
-    }
-
-}

+ 0 - 75
warewms-system/src/main/java/com/warewms/hailiang/common/DtuManage.java

@@ -1,75 +0,0 @@
-package com.warewms.hailiang.common;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelId;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.util.Arrays;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 功能描述: 定时发送Dtu报文
- *
- * @Author keLe
- * @Date 2022/8/29
- */
-@Slf4j
-@Component
-public class DtuManage {
-
-
-    public void sendMsg(){
-        ConcurrentHashMap<ChannelId, Channel> channelMap = ChannelMap.getChannelMap();
-        if(CollectionUtils.isEmpty(channelMap)){
-            return;
-        }
-        ConcurrentHashMap.KeySetView<ChannelId, Channel> channelIds = channelMap.keySet();
-        byte[] msgBytes = {0x01, 0x03, 0x00, 0x02, 0x00, 0x01, 0x25, (byte) 0xCA};
-        for(ChannelId channelId : channelIds){
-            Channel channel = ChannelMap.getChannelByName(channelId);
-            // 判断是否活跃
-            if(channel==null || !channel.isActive()){
-                ChannelMap.getChannelMap().remove(channelId);
-                log.info("客户端:{},连接已经中断",channelId);
-                return ;
-            }
-            // 指令发送
-            ByteBuf buffer = Unpooled.buffer();
-            log.info("开始发送报文:{}",Arrays.toString(msgBytes));
-            buffer.writeBytes(msgBytes);
-            channel.writeAndFlush(buffer).addListener((ChannelFutureListener) future -> {
-                if (future.isSuccess()) {
-                    log.info("客户端:{},回写成功:{}",channelId,Arrays.toString(msgBytes));
-                } else {
-                    log.info("客户端:{},回写失败:{}",channelId,Arrays.toString(msgBytes));
-                }
-            });
-        }
-    }
-
-    /**
-     * 功能描述: 定时删除不活跃的连接
-     * @Author keLe
-     * @Date 2022/8/26
-     * @return void
-     */
-    public void deleteInactiveConnections(){
-        ConcurrentHashMap<ChannelId, Channel> channelMap = ChannelMap.getChannelMap();
-        if(!CollectionUtils.isEmpty(channelMap)){
-            for (Map.Entry<ChannelId, Channel> next : channelMap.entrySet()) {
-                ChannelId channelId = next.getKey();
-                Channel channel = next.getValue();
-                if (!channel.isActive()) {
-                    channelMap.remove(channelId);
-                    log.info("客户端:{},连接已经中断",channelId);
-                }
-            }
-        }
-    }
-}

+ 0 - 51
warewms-system/src/main/java/com/warewms/hailiang/common/MyDecoder.java

@@ -1,51 +0,0 @@
-package com.warewms.hailiang.common;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
-import java.util.List;
-
-/**
- * 功能描述: 自定义接收消息格式
- */
-public class MyDecoder extends ByteToMessageDecoder {
-    @Override
-    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> out) throws Exception {
-        byte[] data = new byte[in.readableBytes()];
-        in.readBytes(data);
-        String msg = bytesToHexString(data);
-        out.add(msg);
-    }
-
-    public String bytesToHexString(byte[] bArray) {
-        StringBuffer sb = new StringBuffer(bArray.length);
-        String sTemp;
-        for (int i = 0; i < bArray.length; i++) {
-            sTemp = Integer.toHexString(0xFF & bArray[i]);
-            if (sTemp.length() < 2) {
-                sb.append(0);
-            }
-            sb.append(sTemp.toUpperCase());
-        }
-        return sb.toString();
-    }
-
-    public static String toHexString1(byte[] b) {
-        StringBuffer buffer = new StringBuffer();
-        for (int i = 0; i < b.length; ++i) {
-            buffer.append(toHexString1(b[i]));
-        }
-        return buffer.toString();
-    }
-
-    public static String toHexString1(byte b) {
-        String s = Integer.toHexString(b & 0xFF);
-        if (s.length() == 1) {
-            return "0" + s;
-        } else {
-            return s;
-        }
-    }
-
-}

+ 0 - 90
warewms-system/src/main/java/com/warewms/hailiang/common/MyEncoder.java

@@ -1,90 +0,0 @@
-package com.warewms.hailiang.common;
-
-import cn.hutool.core.util.ByteUtil;
-import cn.hutool.extra.spring.SpringUtil;
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Scanner;
-import java.util.Stack;
-
-/**
- * 功能描述: 自定义发送消息格式
- *
- */
-public class MyEncoder extends MessageToByteEncoder<String> {
-
-    @Override
-    protected void encode(ChannelHandlerContext channelHandlerContext, String s, ByteBuf byteBuf) throws Exception {
-        //将16进制字符串转为数组
-        byteBuf.writeBytes(hexString2Bytes(s));
-    }
-
-    /**
-     * 功能描述: 16进制字符串转字节数组
-     * @param src 16进制字符串
-     * @return byte[]
-     */
-    public static byte[] hexString2Bytes(String src) {
-        int l = src.length() / 2;
-        byte[] ret = new byte[l];
-        for (int i = 0; i < l; i++) {
-            ret[i] = (byte) Integer.valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue();
-        }
-        return ret;
-    }
-
-    /**
-     * 字符串转16进制字符串
-     * @param str
-     * @return
-     */
-    public static String StringTohexString(String str){
-        StringBuffer sb = new StringBuffer();
-        //将字符串转换为字符数组
-        char ch[] = str.toCharArray();
-        for(int i = 0; i < ch.    length; i++) {
-            String hexString = Integer.toHexString(ch[i]);
-            sb.append(hexString);
-        }
-        return sb.toString();
-    }
-    public static void main(String[] args) throws UnsupportedEncodingException {
-//        String str = "23";
-//        StringBuffer sb = new StringBuffer();
-//        //将字符串转换为字符数组
-//        char ch[] = str.toCharArray();
-//        for(int i = 0; i < ch.    length; i++) {
-//            String hexString = Integer.toHexString(ch[i]);
-//            sb.append(hexString);
-//        }
-//        String result = sb.toString();
-
-//        System.out.println(result);
-//        byte[] bytes = new byte[37];
-//        bytes[0] = 00;
-//        String s ="E800230100063132333332310200173131313131313131313131313131313131313131313131";
-
-//        String s ="E8 00 23 01 00 06 31 32 33 33 32 31 02 00 17 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31";
-//        String[] s2 = s.split(" ");
-//        int i  =Integer.parseInt(s2[0],16) ^ Integer.parseInt(s2[1],16) ;
-//        for (int i1 = 1; i1 < s2.length-1; i1++) {
-//            i = i ^ Integer.parseInt(s2[i1+1],16);
-//        }
-//        System.out.println(Integer.toHexString(i));
-
-//        System.out.println(Integer.parseInt("23",16));
-//        System.out.println(Arrays.toString(hexString2Bytes("8000")));
-
-//        System.out.println(Integer.parseInt("E8",16));
-//        for (int i = 1; i < bytes.length -1; i++) {
-//            y = y ^ bytes[i + 1];
-//            System.out.println(y);
-//        }
-//        System.out.println(Integer.toHexString(y));
-    }
-
-}

+ 0 - 55
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServer.java

@@ -1,55 +0,0 @@
-package com.warewms.hailiang.common;
-
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import java.net.InetSocketAddress;
-
-/**
- * 功能描述: netty服务启动类
- *
- */
-@Slf4j
-@Component
-public class NettyServer {
-    public void start(InetSocketAddress address) {
-        //配置服务端的NIO线程组
-        EventLoopGroup bossGroup = new NioEventLoopGroup();
-        EventLoopGroup workerGroup = new NioEventLoopGroup();
-        try {
-            // 绑定线程池,编码解码
-            //服务端接受连接的队列长度,如果队列已满,客户端连接将被拒绝
-            ServerBootstrap bootstrap = new ServerBootstrap()
-                    .group(bossGroup, workerGroup)
-                    // 指定Channel
-                    .channel(NioServerSocketChannel.class)
-                    //使用指定的端口设置套接字地址
-                    .localAddress(address)
-                    //使用自定义处理类
-                    .childHandler(new NettyServerChannelInitializer())
-                    //服务端可连接队列数,对应TCP/IP协议listen函数中backlog参数
-                    .option(ChannelOption.SO_BACKLOG, 128)
-                    //保持长连接,2小时无数据激活心跳机制
-                    .childOption(ChannelOption.SO_KEEPALIVE, true)
-                    //将小的数据包包装成更大的帧进行传送,提高网络的负载
-                    .childOption(ChannelOption.TCP_NODELAY, true);
-            // 绑定端口,开始接收进来的连接
-            ChannelFuture future = bootstrap.bind(address).sync();
-            if (future.isSuccess()) {
-                log.info("netty服务器开始监听端口:{}",address.getPort());
-            }
-            //关闭channel和块,直到它被关闭
-            future.channel().closeFuture().sync();
-        } catch (Exception e) {
-            e.printStackTrace();
-            bossGroup.shutdownGracefully();
-            workerGroup.shutdownGracefully();
-        }
-    }
-}

+ 0 - 28
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerChannelInitializer.java

@@ -1,28 +0,0 @@
-package com.warewms.hailiang.common;
-
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.socket.SocketChannel;
-
-/**
- * 功能描述: 服务端初始化,客户端与服务器端连接一旦创建,这个类中方法就会被回调,设置出站编码器和入站解码器
- *
- * @Author keLe
- * @Date 2022/8/26
- */
-public class NettyServerChannelInitializer extends ChannelInitializer<SocketChannel> {
-    @Override
-    protected void initChannel(SocketChannel socketChannel) throws Exception {
-        ChannelPipeline pipeline = socketChannel.pipeline();
-        //接收消息格式,使用自定义解析数据格式
-        pipeline.addLast("decoder",new MyDecoder());
-        //发送消息格式,使用自定义解析数据格式
-        pipeline.addLast("encoder",new MyEncoder());
-
-        //针对客户端,如果在1分钟时没有想服务端发送写心跳(ALL),则主动断开
-        //如果是读空闲或者写空闲,不处理,这里根据自己业务考虑使用
-        //pipeline.addLast(new IdleStateHandler(600,0,0, TimeUnit.SECONDS));
-        //自定义的空闲检测
-        pipeline.addLast(new NettyServerHandler());
-    }
-}

+ 0 - 152
warewms-system/src/main/java/com/warewms/hailiang/common/NettyServerHandler.java

@@ -1,152 +0,0 @@
-package com.warewms.hailiang.common;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelId;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.handler.timeout.IdleState;
-import io.netty.handler.timeout.IdleStateEvent;
-import lombok.extern.slf4j.Slf4j;
-
-import java.net.InetSocketAddress;
-
-/**
- * 功能描述: netty服务端处理类
- *
- */
-@Slf4j
-public class NettyServerHandler extends ChannelInboundHandlerAdapter {
-
-    /**
-     * 功能描述: 有客户端连接服务器会触发此函数
-     *
-     * @param ctx 通道
-     * @return void
-     */
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) {
-        InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress();
-        String clientIp = insocket.getAddress().getHostAddress();
-        int clientPort = insocket.getPort();
-        //获取连接通道唯一标识
-        ChannelId channelId = ctx.channel().id();
-        //如果map中不包含此连接,就保存连接
-        if (ChannelMap.getChannelMap().containsKey(channelId)) {
-            log.info("客户端:{},是连接状态,连接通道数量:{} ", channelId, ChannelMap.getChannelMap().size());
-        } else {
-            //保存连接
-            ChannelMap.addChannel(channelId, ctx.channel());
-            log.info("客户端:{},连接netty服务器[IP:{}-->PORT:{}]", channelId, clientIp, clientPort);
-            log.info("连接通道数量: {}", ChannelMap.getChannelMap().size());
-        }
-    }
-
-    /**
-     * 功能描述: 有客户端终止连接服务器会触发此函数
-     *
-     * @param ctx 通道处理程序上下文
-     * @return void
-     */
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) {
-        InetSocketAddress inSocket = (InetSocketAddress) ctx.channel().remoteAddress();
-        String clientIp = inSocket.getAddress().getHostAddress();
-        ChannelId channelId = ctx.channel().id();
-        //包含此客户端才去删除
-        if (ChannelMap.getChannelMap().containsKey(channelId)) {
-            //删除连接
-            ChannelMap.getChannelMap().remove(channelId);
-            log.info("客户端:{},连接netty服务器[IP:{}-->PORT:{}]", channelId, clientIp, inSocket.getPort());
-            log.info("连接通道数量: " + ChannelMap.getChannelMap().size());
-        }
-    }
-
-    /**
-     * 功能描述: 有客户端发消息会触发此函数
-     *
-     * @param ctx 通道处理程序上下文
-     * @param msg 客户端发送的消息
-     * @return void
-     */
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        log.info("加载客户端报文,客户端id:{},客户端消息:{}", ctx.channel().id(), msg);
-        String data = String.valueOf(msg);
-        Integer water = Integer.parseInt(data.substring(6, 10), 16);
-        log.info("当前水位:{}cm", water);
-        //响应客户端
-        this.channelWrite(ctx.channel().id(), msg);
-    }
-
-    @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
-        String bytes = "01 03 00 02 00 01 25 CA";
-        ctx.writeAndFlush(bytes);
-    }
-
-    /**
-     * 功能描述: 服务端给客户端发送消息
-     *
-     * @param channelId 连接通道唯一id
-     * @param msg       需要发送的消息内容
-     * @return void
-     */
-    public void channelWrite(ChannelId channelId, Object msg) throws Exception {
-        Channel channel = ChannelMap.getChannelMap().get(channelId);
-        if (channel == null) {
-            log.info("通道:{},不存在", channelId);
-            return;
-        }
-        if (msg == null || msg == "") {
-            log.info("服务端响应空的消息");
-            return;
-        }
-        //将客户端的信息直接返回写入ctx
-        channel.write(msg);
-        //刷新缓存区
-        channel.flush();
-    }
-
-    @Override
-    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
-        String socketString = ctx.channel().remoteAddress().toString();
-        if (evt instanceof IdleStateEvent) {
-            IdleStateEvent event = (IdleStateEvent) evt;
-            if (event.state() == IdleState.READER_IDLE) {
-                log.info("Client:{},READER_IDLE 读超时", socketString);
-                ctx.disconnect();
-                Channel channel = ctx.channel();
-                ChannelId id = channel.id();
-                ChannelMap.removeChannelByName(id);
-            } else if (event.state() == IdleState.WRITER_IDLE) {
-                log.info("Client:{}, WRITER_IDLE 写超时", socketString);
-                ctx.disconnect();
-                Channel channel = ctx.channel();
-                ChannelId id = channel.id();
-                ChannelMap.removeChannelByName(id);
-            } else if (event.state() == IdleState.ALL_IDLE) {
-                log.info("Client:{},ALL_IDLE 总超时", socketString);
-                ctx.disconnect();
-                Channel channel = ctx.channel();
-                ChannelId id = channel.id();
-                ChannelMap.removeChannelByName(id);
-            }
-        }
-    }
-
-    /**
-     * 功能描述: 发生异常会触发此函数
-     *
-     * @param ctx   通道处理程序上下文
-     * @param cause 异常
-     * @return void
-     * @Author keLe
-     * @Date 2022/8/26
-     */
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        ctx.close();
-        log.info("{}:发生了错误,此连接被关闭。此时连通数量:{}", ctx.channel().id(), ChannelMap.getChannelMap().size());
-    }
-
-}

+ 14 - 0
warewms-system/src/main/java/com/warewms/hailiang/config/CodeReadProperties.java

@@ -0,0 +1,14 @@
+package com.warewms.hailiang.config;
+
+
+public class CodeReadProperties {
+    /**
+     * 触发读码
+     */
+    public static String startTheCommand = "T";
+
+    /**
+     * 失败返回
+     */
+    public static String failureReturnInstruction ="NG";
+}

+ 0 - 63
warewms-system/src/main/java/com/warewms/hailiang/config/LaunchRunner.java

@@ -1,63 +0,0 @@
-/*
-package com.warewms.hailiang.config;
-
-
-import cn.hutool.cron.CronUtil;
-import com.warewms.hailiang.common.NettyServer;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.net.InetSocketAddress;
-
-*/
-/**
- * 功能描述: 任务队列
- * @Author keLe
- * @Date 2022/7/20
- *//*
-
-@Component
-@Order(2)
-@Slf4j
-public class LaunchRunner implements CommandLineRunner {
-
-    @Resource
-    private NettyServer nettyServer;
-
-    @Resource
-    private SocketProperties socketProperties;
-
-
-    @Override
-    public void run(String... args) throws Exception {
-        TaskRunner();
-        InetSocketAddress address = new InetSocketAddress(socketProperties.getHost(),socketProperties.getPort());
-        log.info("netty服务器启动地址:"+socketProperties.getHost());
-        nettyServer.start(address);
-    }
-    */
-/**
-     * 执行正在运行的任务
-     *//*
-
-    private  void TaskRunner() {
-        */
-/**
-         * 任务队列启动
-         *//*
-
-        CronUtil.setMatchSecond(true);
-        CronUtil.start();
-        log.info("\n-----------------------任务服务启动------------------------\n\t" +
-                        "当前正在启动的{}个任务"+
-                        "\n-----------------------------------------------------------\n\t"
-                , CronUtil.getScheduler().size()
-
-        );
-
-    }
-}
-*/

+ 3 - 0
warewms-system/src/main/java/com/warewms/hailiang/config/PlcConfig.java

@@ -25,8 +25,11 @@ public class PlcConfig {
 
     private EPlcType ePlcType;
 
+    private String heartbeat;
+
     public void setSiemensPLCS(String  ePlcType) {
         this.ePlcType = EPlcType.valueOf(ePlcType);
     }
 
+
 }

+ 0 - 29
warewms-system/src/main/java/com/warewms/hailiang/config/SocketProperties.java

@@ -1,29 +0,0 @@
-package com.warewms.hailiang.config;
-
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
-
-/**
- * 功能描述: 配置类
- *
- * @Author keLe
- * @Date 2022/8/26
- */
-@Setter
-@Getter
-@ToString
-@Component
-@Configuration
-@PropertySource("classpath:application.yml")
-@ConfigurationProperties(prefix = "socket")
-public class SocketProperties {
-    private Integer port;
-    private String host;
-
-}

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

@@ -2,18 +2,22 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader12Handler;
+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.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -37,7 +41,7 @@ public class CodeReader12Connect implements TCPConnectBase {
 
     private final String deviceName ="CodeReader12";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -45,7 +49,10 @@ public class CodeReader12Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
 
+    @Resource
+    RetroactiveNowService retroactiveNowService;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +66,20 @@ public class CodeReader12Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader12Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +142,31 @@ public class CodeReader12Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+    @Override
+    public void processMessages(String message) {
+        try {
+            log.info("大散盘4号行车读码器消息:{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-4-27.12", deviceName, "未识别到码", "2"));
+            } else {
+                //读取到批次号保存到数据库中
+                RetroactiveNow retroactiveNow = new RetroactiveNow();
+                retroactiveNow.setBatchNo(message);
+                retroactiveNow.setStatus("8");
+                retroactiveNow.setDeviceId("Z1_DaSanPan_DMQ-4-27.12");
+                retroactiveNowService.updateData(retroactiveNow);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-4-27.12", deviceName, "识别到码:" + message, "1"));
+            }
+        }catch (Exception e){
+            log.error("大散盘4号行车读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-4-27.12", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
+    }
 }

+ 29 - 7
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader13Connect.java

@@ -2,16 +2,15 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader13Handler;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 java.util.concurrent.Callable;
@@ -45,7 +44,7 @@ public class CodeReader13Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
-
+    private ChannelPipeline pipeline;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +58,20 @@ public class CodeReader13Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader13Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +134,14 @@ public class CodeReader13Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return null;
+    }
+
+    @Override
+    public void processMessages(String message) {
+
+    }
 }

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

@@ -2,16 +2,15 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader14Handler;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 java.util.concurrent.Callable;
@@ -45,7 +44,7 @@ public class CodeReader14Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
-
+    private ChannelPipeline pipeline;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +58,20 @@ public class CodeReader14Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader14Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +134,14 @@ public class CodeReader14Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return null;
+    }
+
+    @Override
+    public void processMessages(String message) {
+
+    }
 }

+ 82 - 20
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java

@@ -2,18 +2,29 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader3Handler;
+import com.jhlabs.image.OilFilter;
+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;
+import com.warewms.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.enums.DaoJiaoPlcEnum;
+import com.warewms.hailiang.enums.DeviceNameEnum;
+import com.warewms.hailiang.init.PlcConnectServiceRunner;
+import com.warewms.hailiang.service.RetroactiveNowService;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+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;
@@ -33,11 +44,11 @@ public class CodeReader3Connect implements TCPConnectBase {
 
     private final String IP_ADDR = "172.20.27.3";
 
-    private final String deviceName ="CodeReader3";
+    private final String deviceName = "CodeReader3";
 
     private final int PORT = 51236;
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -45,12 +56,19 @@ public class CodeReader3Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
 
+    @Resource
+    MesService mesService;
+    @Resource
+    RetroactiveNowService retroactiveNowService;
+    @Resource
+    PlcConnectServiceRunner plcConnectServiceRunner;
 
     @Override
     public void init() throws InterruptedException {
-        if (enable){
-            log.info("ip:{},deviceName:{}正在进行连接",IP_ADDR,deviceName);
+        if (enable) {
+            log.info("ip:{},deviceName:{}正在进行连接", IP_ADDR, deviceName);
             group = new NioEventLoopGroup();
             try {
                 bootstrap = new Bootstrap();
@@ -59,21 +77,35 @@ public class CodeReader3Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader3Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
                 future.addListener((channelFuture) -> {
                     if (channelFuture.isSuccess()) {
-                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
-                        log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
-                    }else {
-                        log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                    } else {
+                        log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
                         retry();
                     }
                 });
             } catch (Exception e) {
-                log.error("ip:{},deviceName:{}连接异常,{},准备重试",IP_ADDR,deviceName, e.getMessage());
+                log.error("ip:{},deviceName:{}连接异常,{},准备重试", IP_ADDR, deviceName, e.getMessage());
                 retry();
             }
         }
@@ -90,17 +122,18 @@ public class CodeReader3Connect implements TCPConnectBase {
         try {
             retryer.call(new Callable<Boolean>() {
                 AtomicBoolean isSuccess = new AtomicBoolean(false);
+
                 @Override
                 public Boolean call() throws Exception {
-                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    log.info("ip:{},deviceName:{}连接重试", IP_ADDR, deviceName);
                     future = bootstrap.connect(IP_ADDR, PORT).sync();
                     future.addListener((channelFuture) -> {
                         isSuccess.set(channelFuture.isSuccess());
                         if (channelFuture.isSuccess()) {
-                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
-                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
-                        }else {
-                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                            log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                        } else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
                         }
                     });
                     Thread.sleep(3000);
@@ -122,4 +155,33 @@ public class CodeReader3Connect implements TCPConnectBase {
         return deviceName;
     }
 
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+    @Override
+    public void processMessages(String message) {
+        try {
+            log.info("倒角机读码器读码结果,{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                //读码失败
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "未识别到码", "2"));
+                return;
+            }
+            //修改数据库信息
+            RetroactiveNow retroactiveNow = new RetroactiveNow();
+            retroactiveNow.setBatchNo(message);
+            retroactiveNow.setStatus("");
+            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"));
+        }
+    }
+
 }

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

@@ -2,18 +2,26 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader5Handler;
+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.enums.DeviceNameEnum;
+import com.warewms.hailiang.enums.XiMianPlcEnum;
+import com.warewms.hailiang.init.PlcConnectServiceRunner;
+import com.warewms.hailiang.service.RetroactiveNowService;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -26,16 +34,17 @@ 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
 public class CodeReader5Connect implements TCPConnectBase {
 
     private final String IP_ADDR = "172.20.27.5";
 
     private final int PORT = 51236;
 
-    private final String deviceName ="CodeReader5";
+    private final String deviceName = "CodeReader5";
 
     private boolean enable = false;
 
@@ -45,8 +54,15 @@ public class CodeReader5Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
 
 
+    @Resource
+    RetroactiveNowService retroactiveNowService;
+
+    @Resource
+    PlcConnectServiceRunner plcConnectServiceRunner;
+
     @Override
     public void init() throws InterruptedException {
         if (enable) {
@@ -58,14 +74,30 @@ public class CodeReader5Connect implements TCPConnectBase {
                         .option(ChannelOption.TCP_NODELAY, true)
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
-                            protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader5Handler());
+                            protected void initChannel(SocketChannel socketChannel) {
+                                pipeline = socketChannel.pipeline();
+                                pipeline.addLast(new ChannelInboundHandlerAdapter() {
+                                    @Override
+                                    public void channelInactive(ChannelHandlerContext ctx) {
+                                        log.error("设备:{}连接已断开!", deviceName);
+                                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "2"));
+                                        retry();
+                                    }
+
+                                    @Override
+                                    public void channelRead(ChannelHandlerContext ctx, Object msg) {
+                                        ByteBuf byteBuf = (ByteBuf) msg;
+                                        processMessages(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
                 future.addListener((channelFuture) -> {
                     if (channelFuture.isSuccess()) {
+
                         SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+
                         log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
                     } else {
                         log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
@@ -90,17 +122,18 @@ public class CodeReader5Connect implements TCPConnectBase {
         try {
             retryer.call(new Callable<Boolean>() {
                 AtomicBoolean isSuccess = new AtomicBoolean(false);
+
                 @Override
                 public Boolean call() throws Exception {
-                    log.info("ip:{},deviceName:{}连接重试",IP_ADDR,deviceName);
+                    log.info("ip:{},deviceName:{}连接重试", IP_ADDR, deviceName);
                     future = bootstrap.connect(IP_ADDR, PORT).sync();
                     future.addListener((channelFuture) -> {
                         isSuccess.set(channelFuture.isSuccess());
                         if (channelFuture.isSuccess()) {
-                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName,"1"));
-                            log.info("ip:{},deviceName:{}连接成功",IP_ADDR,deviceName);
-                        }else {
-                            log.info("ip:{},deviceName:{}连接失败等待重试!",IP_ADDR,deviceName);
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                            log.info("ip:{},deviceName:{}连接成功", IP_ADDR, deviceName);
+                        } else {
+                            log.info("ip:{},deviceName:{}连接失败等待重试!", IP_ADDR, deviceName);
                         }
                     });
                     Thread.sleep(3000);
@@ -121,4 +154,34 @@ public class CodeReader5Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+    @Override
+    public void processMessages(String message) {
+        try {
+            log.info("铣面读码器消息:{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_XiMian_DMQ-1-27.5", deviceName, "未识别到码", "2"));
+            } else {
+                //读取到批次号保存到数据库中
+                RetroactiveNow retroactiveNow = new RetroactiveNow();
+                retroactiveNow.setBatchNo(message);
+                retroactiveNow.setStatus("6");
+                retroactiveNow.setDeviceId("Z1_XiMian_DMQ-1-27.5");
+                retroactiveNowService.updateData(retroactiveNow);
+                plcConnectServiceRunner.getPlcServer(DeviceNameEnum.XIMIANPLC.getDeviceName()).writeBoolean(XiMianPlcEnum.ISREAD.getMetadata(), false);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_XiMian_DMQ-1-27.5", deviceName, "识别到码:" + message, "1"));
+            }
+        } catch (Exception e) {
+            log.error("铣面读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_XiMian_DMQ-1-27.5", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
+    }
+
+
 }

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

@@ -2,18 +2,23 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader6Handler;
+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.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -29,6 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  * Description:倒角读码器连接
  **/
 @Slf4j
+@Service
 public class CodeReader6Connect implements TCPConnectBase {
 
     private final String IP_ADDR = "172.20.27.6";
@@ -37,7 +43,7 @@ public class CodeReader6Connect implements TCPConnectBase {
 
     private final String deviceName ="CodeReader6";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -45,7 +51,10 @@ public class CodeReader6Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
 
+    @Resource
+    RetroactiveNowService retroactiveNowService;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +68,20 @@ public class CodeReader6Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader6Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -121,4 +143,31 @@ public class CodeReader6Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+    @Override
+    public void processMessages(String message) {
+        try {
+            log.info("轧制读码器消息:{}", message);
+            if (CodeReadProperties.failureReturnInstruction.equals(message)) {
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_ZhaZhi_DMQ-1-27.6", deviceName, "未识别到码", "2"));
+            } else {
+                //读取到批次号保存到数据库中
+                RetroactiveNow retroactiveNow = new RetroactiveNow();
+                retroactiveNow.setBatchNo(message);
+                retroactiveNow.setStatus("7");
+                retroactiveNow.setDeviceId("Z1_ZhaZhi_DMQ-1-27.6");
+                retroactiveNowService.updateData(retroactiveNow);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_ZhaZhi_DMQ-1-27.6", deviceName, "识别到码:" + message, "1"));
+            }
+        }catch (Exception e){
+            log.error("轧制读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_ZhaZhi_DMQ-1-27.6", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
+    }
 }

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

@@ -2,18 +2,22 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader7Handler;
+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.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 javax.annotation.Resource;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -37,7 +41,7 @@ public class CodeReader7Connect implements TCPConnectBase {
 
     private final String deviceName ="CodeReader7";
 
-    private boolean enable = false;
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -45,7 +49,10 @@ public class CodeReader7Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
 
+    @Resource
+    RetroactiveNowService retroactiveNowService;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +66,20 @@ public class CodeReader7Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader7Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +142,31 @@ public class CodeReader7Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+    @Override
+    public void processMessages(String message) {
+        try {
+            log.info("大散盘1号行车读码器消息:{}", message);
+            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.setDeviceId("Z1_DaSanPan_DMQ-1-27.7");
+                retroactiveNowService.updateData(retroactiveNow);
+                //添加设备日志
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-1-27.7", deviceName, "识别到码:" + message, "1"));
+            }
+        }catch (Exception e){
+            log.error("大散盘1号行车读码任务执行异常,msg:{}",e.getMessage());
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaSanPan_DMQ-1-27.7", deviceName, "读码任务出错,msg:"+e.getMessage(), "2"));
+        }
+    }
 }

+ 29 - 7
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader8Connect.java

@@ -2,16 +2,15 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader8Handler;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 java.util.concurrent.Callable;
@@ -45,7 +44,7 @@ public class CodeReader8Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
-
+    private ChannelPipeline pipeline;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +58,20 @@ public class CodeReader8Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader8Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +134,14 @@ public class CodeReader8Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return null;
+    }
+
+    @Override
+    public void processMessages(String message) {
+
+    }
 }

+ 29 - 7
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader9Connect.java

@@ -2,16 +2,15 @@ package com.warewms.hailiang.connect;
 
 import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.CodeReader9Handler;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
 import com.warewms.hailiang.domain.Device;
 import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
+import io.netty.buffer.ByteBuf;
+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 java.util.concurrent.Callable;
@@ -45,7 +44,7 @@ public class CodeReader9Connect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
-
+    private ChannelPipeline pipeline;
 
     @Override
     public void init() throws InterruptedException {
@@ -59,7 +58,20 @@ public class CodeReader9Connect implements TCPConnectBase {
                         .handler(new ChannelInitializer<SocketChannel>() {
                             @Override
                             protected void initChannel(SocketChannel socketChannel) throws Exception {
-                                socketChannel.pipeline().addLast(new CodeReader9Handler());
+                                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(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
+                                    }
+                                });
                             }
                         });
                 future = bootstrap.connect(IP_ADDR, PORT).sync();
@@ -122,4 +134,14 @@ public class CodeReader9Connect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return null;
+    }
+
+    @Override
+    public void processMessages(String message) {
+
+    }
 }

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

@@ -1,15 +1,20 @@
 package com.warewms.hailiang.connect;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
-import com.warewms.hailiang.connect.handler.InkjetPrintersHandler;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
+import com.warewms.hailiang.domain.Device;
+import com.warewms.hailiang.enums.InkjetPrintersDirectivesEnum;
+import com.warewms.hailiang.util.ParseMsgTools;
 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 lombok.CustomLog;
+import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -30,9 +35,11 @@ public class InkjetPrintersConnect implements TCPConnectBase {
 
     private final String IP_ADDR = "172.20.27.4";
 
-    private final int PORT = 9999;
+    private final int PORT = 51236;
 
-    private final String deviceName ="InkjetPrinters";
+    private final String deviceName = "InkjetPrinters";
+
+    private boolean enable = true;
 
     private ChannelFuture future;
 
@@ -40,34 +47,57 @@ public class InkjetPrintersConnect implements TCPConnectBase {
 
     private EventLoopGroup group;
 
+    private ChannelPipeline pipeline;
+
+    private boolean isInitRoutine = false;
+
+    private String movement;
 
 
     @Override
     public void init() throws InterruptedException {
-        log.info("喷码机正在进行连接");
-        group = new NioEventLoopGroup();
-        try {
-            bootstrap = new Bootstrap();
-            bootstrap.group(group).channel(NioSocketChannel.class)
-                    .option(ChannelOption.TCP_NODELAY, true)
-                    .handler(new ChannelInitializer<SocketChannel>() {
-                        @Override
-                        protected void initChannel(SocketChannel socketChannel) throws Exception {
-                            socketChannel.pipeline().addLast(new InkjetPrintersHandler());
-                        }
-                    });
-            future = bootstrap.connect(IP_ADDR, PORT).sync();
-            future.addListener((channelFuture) -> {
-                if (channelFuture.isSuccess()) {
-                    log.info("喷码机连接成功");
-                }else {
-                    log.info("连接失败等待重试!");
-                    retry();
-                }
-            });
-        } catch (Exception e) {
-            log.error("喷码设备连接异常,{},准备重试", e.getMessage());
-            retry();
+        if (enable) {
+            log.info("喷码机正在进行连接");
+            group = new NioEventLoopGroup();
+            try {
+                bootstrap = new Bootstrap();
+                bootstrap.group(group).channel(NioSocketChannel.class)
+                        .option(ChannelOption.TCP_NODELAY, true)
+                        .handler(new ChannelInitializer<SocketChannel>() {
+                            @Override
+                            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)));
+                                    }
+                                });
+                            }
+                        });
+                future = bootstrap.connect(IP_ADDR, PORT).sync();
+                future.addListener((channelFuture) -> {
+                    if (channelFuture.isSuccess()) {
+                        initRoutine();
+                        SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
+                        log.info("喷码机连接成功");
+                    } else {
+                        log.info("连接失败等待重试!");
+                        retry();
+                    }
+                });
+            } catch (Exception e) {
+                log.error("喷码设备连接异常,{},准备重试", e.getMessage());
+                retry();
+            }
         }
     }
 
@@ -82,6 +112,7 @@ public class InkjetPrintersConnect implements TCPConnectBase {
         try {
             retryer.call(new Callable<Boolean>() {
                 AtomicBoolean isSuccess = new AtomicBoolean(false);
+
                 @Override
                 public Boolean call() throws Exception {
                     log.info("喷码机连接重试");
@@ -89,8 +120,10 @@ public class InkjetPrintersConnect implements TCPConnectBase {
                     future.addListener((channelFuture) -> {
                         isSuccess.set(channelFuture.isSuccess());
                         if (channelFuture.isSuccess()) {
+                            initRoutine();
+                            SpringUtil.getApplicationContext().publishEvent(new Device(deviceName, "1"));
                             log.info("喷码机连接成功");
-                        }else {
+                        } else {
                             log.info("连接失败等待重试!");
                         }
                     });
@@ -113,4 +146,32 @@ public class InkjetPrintersConnect implements TCPConnectBase {
     public String getDeviceName() {
         return deviceName;
     }
+
+    @Override
+    public ChannelPipeline getChannel() {
+        return pipeline;
+    }
+
+
+    @Override
+    public void processMessages(String message) {
+        log.info("喷码器消息:{}", message);
+        if ("f7".equalsIgnoreCase(message)) {
+            log.info("喷码机打印成功!");
+        }
+        if ("6".equals(message)){
+            log.info(movement+"完成");
+        }
+    }
+
+    /**
+     * 初始化打印设置
+     */
+    private void initRoutine() {
+        if (!isInitRoutine) {
+            log.info("初始化打印设置");
+            movement = "初始化打印设置";
+            pipeline.writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.hexString2Bytes(InkjetPrintersDirectivesEnum.CODE41.getCode())));
+        }
+    }
 }

+ 7 - 1
warewms-system/src/main/java/com/warewms/hailiang/connect/TCPConnectBase.java

@@ -1,4 +1,6 @@
-package com.warewms.hailiang.connect;
+package com.warewms.hailiang.connect.base;
+
+import io.netty.channel.ChannelPipeline;
 
 import java.io.IOException;
 
@@ -21,4 +23,8 @@ public interface TCPConnectBase {
     void close();
 
     String getDeviceName();
+
+    ChannelPipeline getChannel();
+
+    void processMessages(String message);
 }

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader12Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader12Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader12";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader13Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader13Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader13";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader14Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader14Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader14";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 49
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader3Handler.java

@@ -1,49 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.enums.CodeReaderEnum;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import com.warewms.hailiang.util.ParseMsgTools;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader3Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader3";
-
-
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer(CodeReaderEnum.readCode.toString(), CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader5Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader5Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader5";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 46
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader6Handler.java

@@ -1,46 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader6Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader6";
-
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader7Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader7Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader7";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader8Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader8Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader8";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 45
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/CodeReader9Handler.java

@@ -1,45 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class CodeReader9Handler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="CodeReader9";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer("T", CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 0 - 50
warewms-system/src/main/java/com/warewms/hailiang/connect/handler/InkjetPrintersHandler.java

@@ -1,50 +0,0 @@
-package com.warewms.hailiang.connect.handler;
-
-import com.warewms.common.annotation.Log;
-import com.warewms.hailiang.connect.InkjetPrintersConnect;
-import com.warewms.hailiang.init.TcpServiceRunner;
-import com.warewms.hailiang.util.ParseMsgTools;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-
-/**
- * Created with IntelliJ IDEA.
- *
- * @author: liuzhifei
- * Date: 2023/8/9
- * Time: 17:07
- * To change this template use File | Settings | File Templates.
- * Description: 喷码机连接消息处理类
- **/
-@Slf4j
-@Component
-public class InkjetPrintersHandler extends ChannelInboundHandlerAdapter  {
-
-    private final String deviceName ="InkjetPrinters";
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        ctx.writeAndFlush(Unpooled.copiedBuffer(ParseMsgTools.StringTohexString(""), CharsetUtil.UTF_8));
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        ByteBuf byteBuf = (ByteBuf) msg;
-        log.info(String.valueOf(byteBuf.toString(CharsetUtil.UTF_8)));
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("设备:{}连接已断开!",deviceName);
-        InkjetPrintersConnect inkjetPrintersConnect = (InkjetPrintersConnect) TcpServiceRunner.getTCPInstanceList((deviceName));
-        inkjetPrintersConnect.retry();
-        super.channelInactive(ctx);
-    }
-}

+ 3 - 2
warewms-system/src/main/java/com/warewms/hailiang/contoller/DeviceController.java

@@ -1,5 +1,6 @@
 package com.warewms.hailiang.contoller;
 
+import com.warewms.common.core.domain.R;
 import com.warewms.hailiang.domain.Device;
 import com.warewms.hailiang.service.DeviceService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,7 +23,7 @@ public class DeviceController {
     DeviceService deviceService;
 
     @GetMapping("/list")
-    public List<Device> getList(){
-       return deviceService.getList();
+    public R<List<Device>> getList() {
+        return R.ok(deviceService.getList());
     }
 }

+ 2 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/DeviceLogController.java

@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @author AD
  * @description 针对表【device_log(设备日志表)】的数据库操作Controller

+ 38 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveHistoryController.java

@@ -0,0 +1,38 @@
+package com.warewms.hailiang.contoller;
+
+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.hailiang.domain.RetroactiveHistory;
+import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.service.RetroactiveHistoryService;
+import com.warewms.hailiang.service.RetroactiveNowService;
+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;
+
+import java.util.List;
+
+/**
+ * @author
+ * @description 针对表【retroactive_history(生产追溯表)】的数据库操作Controller
+ * @createDate 2023-08-29 10:21:29
+ */
+@RestController
+@RequestMapping("/retroactive/history")
+public class RetroactiveHistoryController {
+
+    @Autowired
+    RetroactiveHistoryService retroactiveHistoryService;
+
+    @GetMapping("/list")
+    public TableDataInfo<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory, PageDomain pageDomain){
+       return retroactiveHistoryService.getList(retroactiveHistory,pageDomain);
+    }
+
+    @GetMapping("/info")
+    public R<List<RetroactiveHistory>> getList(RetroactiveHistory retroactiveHistory){
+        return R.ok( retroactiveHistoryService.getHistoryList(retroactiveHistory));
+    }
+}

+ 36 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java

@@ -0,0 +1,36 @@
+package com.warewms.hailiang.contoller;
+
+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.hailiang.domain.DeviceLog;
+import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.service.DeviceLogService;
+import com.warewms.hailiang.service.RetroactiveNowService;
+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;
+
+/**
+ * @author
+ * @description 针对表【retroactive_now(生产追溯表)】的数据库操作Controller
+ * @createDate 2023-08-29 10:21:29
+ */
+@RestController
+@RequestMapping("/retroactive/now")
+public class RetroactiveNowController {
+
+    @Autowired
+    RetroactiveNowService retroactiveNowService;
+
+    @GetMapping("/list")
+    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain) {
+        return retroactiveNowService.getList(retroactiveNow, pageDomain);
+    }
+
+    @GetMapping("/info")
+    public R<RetroactiveNow> getInfo(RetroactiveNow retroactiveNow) {
+        return R.ok(retroactiveNowService.selectTheOneByParameter(retroactiveNow));
+    }
+}

+ 33 - 2
warewms-system/src/main/java/com/warewms/hailiang/contoller/TestContoller.java

@@ -23,11 +23,42 @@ public class TestContoller {
     PlcConnectServiceRunner plcConnectServiceRunner;
 
     @GetMapping("/pclTest")
-    public Object testPlc(String plcName,String db,String type){
-        db = "V"+db;
+    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";
+        }
         return null;
     }
+    @GetMapping("/getStatus")
+    public Object getStatus(String plcName){
+        return plcConnectServiceRunner.getPlcServer(plcName).checkConnected();
+    }
 }

+ 3 - 1
warewms-system/src/main/java/com/warewms/hailiang/domain/Device.java

@@ -10,10 +10,11 @@ import java.io.Serializable;
 
 /**
  * 设备表
+ *
  * @TableName device
  */
 @Data
-public class Device extends BaseEntity implements Serializable  {
+public class Device extends BaseEntity implements Serializable {
 
     /**
      * 设备编号
@@ -63,6 +64,7 @@ public class Device extends BaseEntity implements Serializable  {
         this.ip = ip;
         this.port = port;
         this.connectionType = connectionType;
+        this.status = status;
     }
 
     public Device(String deviceName, String status) {

+ 8 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.warewms.common.core.domain.base.BaseEntity;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
 
@@ -14,6 +15,7 @@ import java.io.Serializable;
  */
 @Data
 @TableName("device_log")
+@NoArgsConstructor
 public class DeviceLog extends BaseEntity implements Serializable  {
     /**
      * 日志编号
@@ -43,4 +45,10 @@ public class DeviceLog extends BaseEntity implements Serializable  {
 
     private static final long serialVersionUID = 1L;
 
+    public DeviceLog(String deviceId, String deviceName, String content, String status) {
+        this.deviceId = deviceId;
+        this.deviceName = deviceName;
+        this.content = content;
+        this.status = status;
+    }
 }

+ 9 - 97
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveHistory.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.time.LocalDateTime;
+
+import com.warewms.common.core.domain.base.BaseEntity;
 import lombok.Data;
 
 /**
@@ -13,11 +15,16 @@ import lombok.Data;
  */
 @TableName(value ="retroactive_history")
 @Data
-public class RetroactiveHistory implements Serializable {
+public class RetroactiveHistory extends BaseEntity {
+
     /**
-     * 追溯id
+     * 历史追溯编号
      */
     @TableId
+    private Long historyId;
+    /**
+     * 追溯id
+     */
     private String retroactiveId;
 
     /**
@@ -50,99 +57,4 @@ public class RetroactiveHistory implements Serializable {
      */
     private String deviceId;
 
-    /**
-     * 创建者
-     */
-    private String createBy;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新者
-     */
-    private String updateBy;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-    /**
-     * 备注
-     */
-    private String remark;
-
-    @TableField(exist = false)
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (that == null) {
-            return false;
-        }
-        if (getClass() != that.getClass()) {
-            return false;
-        }
-        RetroactiveHistory other = (RetroactiveHistory) that;
-        return (this.getRetroactiveId() == null ? other.getRetroactiveId() == null : this.getRetroactiveId().equals(other.getRetroactiveId()))
-            && (this.getProductionLine() == null ? other.getProductionLine() == null : this.getProductionLine().equals(other.getProductionLine()))
-            && (this.getBatchNo() == null ? other.getBatchNo() == null : this.getBatchNo().equals(other.getBatchNo()))
-            && (this.getLotNo() == null ? other.getLotNo() == null : this.getLotNo().equals(other.getLotNo()))
-            && (this.getWeight() == null ? other.getWeight() == null : this.getWeight().equals(other.getWeight()))
-            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
-            && (this.getDeviceId() == null ? other.getDeviceId() == null : this.getDeviceId().equals(other.getDeviceId()))
-            && (this.getCreateBy() == null ? other.getCreateBy() == null : this.getCreateBy().equals(other.getCreateBy()))
-            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
-            && (this.getUpdateBy() == null ? other.getUpdateBy() == null : this.getUpdateBy().equals(other.getUpdateBy()))
-            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
-            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()));
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getRetroactiveId() == null) ? 0 : getRetroactiveId().hashCode());
-        result = prime * result + ((getProductionLine() == null) ? 0 : getProductionLine().hashCode());
-        result = prime * result + ((getBatchNo() == null) ? 0 : getBatchNo().hashCode());
-        result = prime * result + ((getLotNo() == null) ? 0 : getLotNo().hashCode());
-        result = prime * result + ((getWeight() == null) ? 0 : getWeight().hashCode());
-        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
-        result = prime * result + ((getDeviceId() == null) ? 0 : getDeviceId().hashCode());
-        result = prime * result + ((getCreateBy() == null) ? 0 : getCreateBy().hashCode());
-        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
-        result = prime * result + ((getUpdateBy() == null) ? 0 : getUpdateBy().hashCode());
-        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
-        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", retroactiveId=").append(retroactiveId);
-        sb.append(", productionLine=").append(productionLine);
-        sb.append(", batchNo=").append(batchNo);
-        sb.append(", lotNo=").append(lotNo);
-        sb.append(", weight=").append(weight);
-        sb.append(", status=").append(status);
-        sb.append(", deviceId=").append(deviceId);
-        sb.append(", createBy=").append(createBy);
-        sb.append(", createTime=").append(createTime);
-        sb.append(", updateBy=").append(updateBy);
-        sb.append(", updateTime=").append(updateTime);
-        sb.append(", remark=").append(remark);
-        sb.append(", serialVersionUID=").append(serialVersionUID);
-        sb.append("]");
-        return sb.toString();
-    }
 }

+ 4 - 92
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveNow.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.time.LocalDateTime;
+
+import com.warewms.common.core.domain.base.BaseEntity;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -15,7 +17,7 @@ import lombok.NoArgsConstructor;
 @TableName(value ="retroactive_now")
 @Data
 @NoArgsConstructor
-public class RetroactiveNow implements Serializable {
+public class RetroactiveNow extends BaseEntity {
     /**
      * 追溯id
      */
@@ -52,101 +54,10 @@ public class RetroactiveNow implements Serializable {
      */
     private String deviceId;
 
-    /**
-     * 创建者
-     */
-    private String createBy;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新者
-     */
-    private String updateBy;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-    /**
-     * 备注
-     */
-    private String remark;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (that == null) {
-            return false;
-        }
-        if (getClass() != that.getClass()) {
-            return false;
-        }
-        RetroactiveHistory other = (RetroactiveHistory) that;
-        return (this.getRetroactiveId() == null ? other.getRetroactiveId() == null : this.getRetroactiveId().equals(other.getRetroactiveId()))
-                && (this.getProductionLine() == null ? other.getProductionLine() == null : this.getProductionLine().equals(other.getProductionLine()))
-                && (this.getBatchNo() == null ? other.getBatchNo() == null : this.getBatchNo().equals(other.getBatchNo()))
-                && (this.getLotNo() == null ? other.getLotNo() == null : this.getLotNo().equals(other.getLotNo()))
-                && (this.getWeight() == null ? other.getWeight() == null : this.getWeight().equals(other.getWeight()))
-                && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
-                && (this.getDeviceId() == null ? other.getDeviceId() == null : this.getDeviceId().equals(other.getDeviceId()))
-                && (this.getCreateBy() == null ? other.getCreateBy() == null : this.getCreateBy().equals(other.getCreateBy()))
-                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
-                && (this.getUpdateBy() == null ? other.getUpdateBy() == null : this.getUpdateBy().equals(other.getUpdateBy()))
-                && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
-                && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()));
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getRetroactiveId() == null) ? 0 : getRetroactiveId().hashCode());
-        result = prime * result + ((getProductionLine() == null) ? 0 : getProductionLine().hashCode());
-        result = prime * result + ((getBatchNo() == null) ? 0 : getBatchNo().hashCode());
-        result = prime * result + ((getLotNo() == null) ? 0 : getLotNo().hashCode());
-        result = prime * result + ((getWeight() == null) ? 0 : getWeight().hashCode());
-        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
-        result = prime * result + ((getDeviceId() == null) ? 0 : getDeviceId().hashCode());
-        result = prime * result + ((getCreateBy() == null) ? 0 : getCreateBy().hashCode());
-        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
-        result = prime * result + ((getUpdateBy() == null) ? 0 : getUpdateBy().hashCode());
-        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
-        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", retroactiveId=").append(retroactiveId);
-        sb.append(", productionLine=").append(productionLine);
-        sb.append(", batchNo=").append(batchNo);
-        sb.append(", lotNo=").append(lotNo);
-        sb.append(", weight=").append(weight);
-        sb.append(", status=").append(status);
-        sb.append(", deviceId=").append(deviceId);
-        sb.append(", createBy=").append(createBy);
-        sb.append(", createTime=").append(createTime);
-        sb.append(", updateBy=").append(updateBy);
-        sb.append(", updateTime=").append(updateTime);
-        sb.append(", remark=").append(remark);
-        sb.append(", serialVersionUID=").append(serialVersionUID);
-        sb.append("]");
-        return sb.toString();
-    }
 
     /**
      *
@@ -165,4 +76,5 @@ public class RetroactiveNow implements Serializable {
                 .append(String.valueOf(weight).split("\\.")[0]).toString();
     }
 
+
 }

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

@@ -0,0 +1,24 @@
+package com.warewms.hailiang.enums;
+
+public enum DaSanPanPlcEnum {
+    /**
+     * 一号下料读码信号
+     */
+    ISREAD_one("DB200.0.1"),
+    /**
+     * 四号下料读码信号
+     */
+    ISREAD_fourth("DB200.0.2");
+
+
+    private String metadata;
+
+
+    DaSanPanPlcEnum(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+}

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

@@ -5,7 +5,11 @@ package com.warewms.hailiang.enums;
  */
 public enum DaoJiaoPlcEnum {
 
-    CHECKFINISH("");
+    CHECKFINISH("Q1.6"),
+
+    READCODE("Q1.7"),
+
+    RETURNOUTCOME("");
 
     private String metadata;
 

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

@@ -6,7 +6,13 @@ package com.warewms.hailiang.enums;
 public enum DeviceNameEnum {
     WEIGHTPLC("ChengZhongPlc"),
 
-    DAOJIAOPLC("DaoJiaoJiPlc");
+    DAOJIAOPLC("DaoJiaoJiPlc"),
+
+    XIMIANPLC("XiMianPlc"),
+
+    ZHAZHIPLC("ZhaZhiPlc"),
+
+    DASANPANPLC("DaSanPanPlc");
 
     private String deviceName;
 
@@ -22,4 +28,6 @@ public enum DeviceNameEnum {
     public void setDeviceName(String deviceName) {
         this.deviceName = deviceName;
     }
+
+
 }

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

@@ -27,9 +27,9 @@ public enum InkjetPrintersDirectivesEnum {
     CODEE6("E6 00 00 E6"),
 
     /**
-     * 运行发码程序
+     * 设置打印反馈
      */
-    CODE41("41 00 01 01 41"),
+    CODE41("4100010141"),
 
     /**
      * 触发打印

+ 3 - 3
warewms-system/src/main/java/com/warewms/hailiang/enums/WeighPlcEnum.java

@@ -13,17 +13,17 @@ public enum WeighPlcEnum {
     /**
      * 是否可以读取重量
      */
-    IsRead(""),
+    IsRead("DB200.0.0"),
 
     /**
      * 读取重量
      */
-    ReadWeight(""),
+    ReadWeight("DB200.2.0"),
 
     /**
      * 读取重量反馈
      */
-    returnWeight("");
+    returnWeight("DB200.10.0");
 
     private String metadata;
 

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

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

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

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

+ 54 - 4
warewms-system/src/main/java/com/warewms/hailiang/init/PlcConnectServiceRunner.java

@@ -1,11 +1,17 @@
 package com.warewms.hailiang.init;
 
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import com.github.rholder.retry.*;
 import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import com.warewms.common.exception.ServiceException;
+import com.warewms.common.utils.StringUtils;
 import com.warewms.hailiang.config.PlcConfig;
 import com.warewms.hailiang.config.PlcProperties;
+import com.warewms.hailiang.domain.Device;
+import com.warewms.hailiang.service.DeviceService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
@@ -13,8 +19,11 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -31,9 +40,12 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
     @Resource
     ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
-    private HashMap<String, S7PLC> plcToolsMap = new HashMap<>();
+    @Resource
+    DeviceService deviceService;
 
 
+    @Resource
+    private ScheduledExecutorService scheduledExecutorService;
 
     @Override
     public void run(String... args) throws Exception {
@@ -41,6 +53,10 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
         log.info("plc初始化完成!");
     }
 
+    private HashMap<String, S7PLC> plcToolsMap = new HashMap<>();
+
+    private ArrayList<String> reTryPlc = new ArrayList<>();
+
     /**
      * 初始化
      */
@@ -53,6 +69,7 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
                     s7PLC.connect();
                     if (s7PLC.checkConnected()){
                         plcToolsMap.put(plcConfig.getName(),s7PLC);
+                        SpringUtil.getApplicationContext().publishEvent(new Device(plcConfig.getName(), "1"));
                         log.info("plc:{},ip:{},连接成功",plcConfig.getName(),plcConfig.getIp());
                     }
                 }catch (Exception e){
@@ -65,6 +82,7 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
     }
 
     public void retry(PlcConfig plcConfig) {
+        reTryPlc.add(plcConfig.getName());
         threadPoolTaskExecutor.execute (() -> {
             Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
                     .retryIfResult(Boolean.FALSE::equals)
@@ -80,7 +98,10 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
                         s7PLC.connect();
                         if (s7PLC.checkConnected()){
                             plcToolsMap.put(plcConfig.getName(),s7PLC);
+                            SpringUtil.getApplicationContext().publishEvent(new Device(plcConfig.getName(), "1"));
                             log.info("plc:{},ip:{},重试连接成功",plcConfig.getName(),plcConfig.getIp());
+                            reTryPlc.remove(plcConfig.getName());
+                            plcConnectsTheHeartbeat(plcConfig,s7PLC);
                             return true;
                         }
                     }catch (Exception e){
@@ -95,13 +116,42 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
         });
     }
 
+    /**
+     *  plc连接心跳
+     * @param plcConfig
+     * @param s7PLC
+     */
+    private void plcConnectsTheHeartbeat(PlcConfig plcConfig,S7PLC s7PLC){
+        String heartbeatAdd = plcConfig.getHeartbeat();
+        if (StringUtils.isNotEmpty(heartbeatAdd)){
+            scheduledExecutorService.scheduleWithFixedDelay(()->{
+                if (!reTryPlc.contains(plcConfig.getName())){
+                    try {
+                        s7PLC.readBoolean(plcConfig.getHeartbeat());
+                    }catch (Exception e){
+                        log.error("设备:{},连接中断",plcConfig.getName());
+                        SpringUtil.getApplicationContext().publishEvent(new Device(plcConfig.getName(), "2"));
+                        retry(plcConfig);
+                    }
+                }
+            },0,3,TimeUnit.SECONDS);
+        }
+    }
+
 
     /**
      *
-     * @param key plc设备名
+     * @param pclName plc设备名
      * @return
      */
-    public S7PLC getPlcServer(String key) {
-        return plcToolsMap.get(key);
+    public S7PLC getPlcServer(String pclName) {
+        S7PLC s7PLC = plcToolsMap.get(pclName);
+        if(ObjectUtil.isNull(s7PLC)){
+            throw new ServiceException("设备未连接");
+        }
+        if (!deviceService.IsConnect(pclName)){
+            throw new ServiceException("设备连接中断");
+        }
+        return plcToolsMap.get(pclName);
     }
 }

+ 28 - 14
warewms-system/src/main/java/com/warewms/hailiang/init/TcpServiceRunner.java

@@ -1,7 +1,10 @@
 package com.warewms.hailiang.init;
 
 import cn.hutool.core.util.ClassUtil;
-import com.warewms.hailiang.connect.TCPConnectBase;
+import cn.hutool.core.util.ObjectUtil;
+import com.warewms.common.exception.ServiceException;
+import com.warewms.hailiang.connect.base.TCPConnectBase;
+import com.warewms.hailiang.service.DeviceService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
@@ -9,6 +12,7 @@ import org.springframework.core.annotation.Order;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Set;
@@ -31,7 +35,10 @@ public class TcpServiceRunner implements CommandLineRunner {
     @Autowired
     ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
-    private static HashMap<String,TCPConnectBase> TCPInstanceList = new HashMap<>();
+    @Resource
+    DeviceService deviceService;
+
+    private HashMap<String,TCPConnectBase> TCPInstanceList = new HashMap<>();
 
     @Override
     public void run(String... args) throws Exception {
@@ -40,22 +47,29 @@ public class TcpServiceRunner implements CommandLineRunner {
             Object o = aClass.newInstance();
             if (o instanceof TCPConnectBase) {
                 TCPConnectBase nodeModel = (TCPConnectBase) o;
-                threadPoolTaskExecutor.execute(() -> {
-                    try {
-                        nodeModel.init();
-                        TCPInstanceList.put(nodeModel.getDeviceName(),nodeModel);
-                    } catch (IOException e) {
-                        nodeModel.close();
-                        throw new RuntimeException(e);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                });
+//                threadPoolTaskExecutor.execute(() -> {
+//                    try {
+//                        nodeModel.init();
+//                        TCPInstanceList.put(nodeModel.getDeviceName(),nodeModel);
+//                    } catch (IOException e) {
+//                        nodeModel.close();
+//                        throw new RuntimeException(e);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                });
             }
         }
     }
 
-    public static TCPConnectBase getTCPInstanceList(String key){
+    public TCPConnectBase getTCPInstanceList(String key){
+        TCPConnectBase tcpConnectBase = TCPInstanceList.get(key);
+        if(ObjectUtil.isNull(tcpConnectBase)){
+            throw new ServiceException("设备未连接");
+        }
+        if (!deviceService.IsConnect(key)){
+            throw new ServiceException("设备连接中断");
+        }
         return TCPInstanceList.get(key);
     }
 }

+ 47 - 10
warewms-system/src/main/java/com/warewms/hailiang/job/TraceJob.java

@@ -1,8 +1,7 @@
 package com.warewms.hailiang.job;
 
-import com.warewms.hailiang.enums.DaoJiaoPlcEnum;
-import com.warewms.hailiang.enums.DeviceNameEnum;
-import com.warewms.hailiang.enums.WeighPlcEnum;
+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.ProcessRealizationService;
@@ -26,6 +25,16 @@ public class TraceJob {
     @Autowired
     ProcessRealizationService processRealizationService;
 
+    @Autowired
+    private RedisCache redisCache;
+
+
+    /**
+     * 测试
+     */
+    public void test() throws InterruptedException {
+
+    }
 
     /**
      * 获取称重信号
@@ -41,13 +50,25 @@ public class TraceJob {
     }
 
     /**
-     * 获取倒角完成信号
+     * 获取喷码信号
      */
     public void getTheChamferCompletionSignal() {
         boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.CHECKFINISH.getMetadata());
-        log.info("倒角完成信号:{}", b);
+        log.info("喷码信号:{}", b);
+        if (b) {
+            processRealizationService.DaoJiaoCodingCodeProcess();
+        }
+    }
+
+    /**
+     * 获取倒角机读码信号
+     */
+
+    public void obtainTheChamferingMachineCodeReadingSignal (){
+        boolean b = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).readBoolean(DaoJiaoPlcEnum.READCODE.getMetadata());
+        log.info("倒角机读码信号,{}",b);
         if (b) {
-            processRealizationService.DaoJiaoProcess();
+            processRealizationService.CodeReadingProcess("CodeReader3");
         }
     }
 
@@ -55,21 +76,33 @@ public class TraceJob {
      * 获取铣面读码信号
      */
     public void obtainTheMillingFaceReadingSignal() {
-
+        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) {
+            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) {
+            processRealizationService.CodeReadingProcess("CodeReader7");
+        }
     }
 
     /**
@@ -90,7 +123,11 @@ 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) {
+            processRealizationService.CodeReadingProcess("CodeReader12");
+        }
     }
 
     /**

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

@@ -6,6 +6,8 @@ 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 java.util.List;
+
 /**
 * @author AD
 * @description 针对表【device_log(设备日志表)】的数据库操作Service
@@ -16,4 +18,5 @@ public interface DeviceLogService extends IService<DeviceLog> {
     TableDataInfo<DeviceLog> getList(DeviceLog deviceLog, PageDomain pageDomain);
 
     void crateLog(DeviceLog deviceLog);
+
 }

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

@@ -9,4 +9,6 @@ import java.util.List;
  */
 public interface DeviceService {
     List<Device> getList();
+
+    boolean IsConnect(String key);
 }

+ 8 - 2
warewms-system/src/main/java/com/warewms/hailiang/service/ProcessRealizationService.java

@@ -11,7 +11,13 @@ public interface ProcessRealizationService {
     void weightProcess() throws InterruptedException;
 
     /**
-     * 倒角工艺完成喷码、读码流程实现
+     * 倒角工艺中喷码流程实现
      */
-    void DaoJiaoProcess();
+    void DaoJiaoCodingCodeProcess();
+
+    /**
+     * 读码触发实现
+     */
+    void CodeReadingProcess(String codeReadName);
+
 }

+ 8 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveHistoryService.java

@@ -1,7 +1,12 @@
 package com.warewms.hailiang.service;
 
+import com.warewms.common.core.domain.base.page.PageDomain;
+import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.warewms.hailiang.domain.RetroactiveNow;
+
+import java.util.List;
 
 /**
 * @author AD
@@ -10,4 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 */
 public interface RetroactiveHistoryService extends IService<RetroactiveHistory> {
 
+    TableDataInfo<RetroactiveHistory> getList(RetroactiveHistory retroactiveHistory, PageDomain pageDomain);
+
+    List<RetroactiveHistory> getHistoryList(RetroactiveHistory retroactiveHistory);
 }

+ 7 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveNowService.java

@@ -1,6 +1,9 @@
 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;
 
 /**
@@ -10,7 +13,11 @@ import com.warewms.hailiang.domain.RetroactiveNow;
 */
 public interface RetroactiveNowService extends IService<RetroactiveNow> {
 
+    TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain);
+
     int insertData(RetroactiveNow retroactiveNow);
 
     RetroactiveNow selectTheOneByParameter(RetroactiveNow retroactiveNow);
+
+    int updateData(RetroactiveNow retroactiveNow);
 }

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

@@ -15,6 +15,7 @@ import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -38,7 +39,8 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
                 .eq(StringUtils.isNotEmpty(deviceLog.getDeviceName()), DeviceLog::getDeviceName, deviceLog.getDeviceName())
                 .eq(StringUtils.isNotEmpty(deviceLog.getStatus()), DeviceLog::getStatus, deviceLog.getStatus())
                 .between(params.get("beginTime") != null && params.get("endTime") != null,
-                        DeviceLog::getCreateTime, params.get("beginTime"), params.get("endTime")));
+                        DeviceLog::getCreateTime, params.get("beginTime"), params.get("endTime"))
+                .orderByDesc(DeviceLog::getCreateTime));
         return TableDataInfo.build(deviceLogIPage);
     }
 
@@ -46,8 +48,11 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
     @Async
     @EventListener
     public void crateLog(DeviceLog deviceLog) {
+        deviceLog.setCreateBy("system");
+        deviceLog.setUpdateBy("system");
         deviceLogMapper.insert(deviceLog);
     }
+
 }
 
 

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

@@ -15,16 +15,20 @@ public class DeviceServiceImpl implements DeviceService {
     private List<Device> devices = new ArrayList<>();
 
     {
-        devices.add(new Device("Z1_Daojia_PMJG-1-27.2", "DaoJiaoJiPlc", "倒角机", "Z1", "172.20.27.2", 102, "S7", "2"));
-        devices.add(new Device("Z1_DaoJiao_PMQ-1-27.4", "PanMaQi", "喷码器", "Z1", "172.20.27.4", 102, "TCP", "2"));
+        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_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"));
         devices.add(new Device("Z1_XiMian_DMQ-1-27.5", "CodeReader5", "铣面读码器", "Z1", "172.20.27.5", 51236, "TCP", "2"));
+        devices.add(new Device("Z1_Zhazhi_PLC-1-52.24", "ZhaZhiPlc", "轧制辊道PLC", "Z1", "172.20.52.24", 102, "S7", "2"));
         devices.add(new Device("Z1_ZhaZhi_DMQ-1-27.6", "CodeReader6", "轧制读码器", "Z1", "172.20.27.6", 51236, "TCP", "2"));
+        devices.add(new Device("Z1_DaSanPan_PLC-1-54.121", "DaSanPanPlc", "大散盘PLC", "Z1", "172.20.54.121", 102, "S7", "2"));
         devices.add(new Device("Z1_DaSanPan_DMQ-1-27.7", "CodeReader7", "大散盘读码器1", "Z1", "172.20.27.7", 51236, "TCP", "2"));
         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_TuiHuoSShangLiao_DMQ-1-27.13", "CodeReader13", "退货上料读码器", "Z1", "172.20.27.13", 51236, "TCP", "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"));
     }
 
@@ -33,6 +37,17 @@ public class DeviceServiceImpl implements DeviceService {
         return devices;
     }
 
+    @Override
+    public boolean IsConnect(String key) {
+        boolean a = false;
+        for (Device device : devices) {
+            if (device.getDeviceName().equals(key)) {
+                a = "1".equals(device.getStatus()) ;
+            }
+        }
+        return a;
+    }
+
     @Async
     @EventListener
     void updateStatus(Device d){

+ 48 - 19
warewms-system/src/main/java/com/warewms/hailiang/service/impl/ProcessRealizationServiceImpl.java

@@ -1,8 +1,12 @@
 package com.warewms.hailiang.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.warewms.common.core.redis.RedisCache;
 import com.warewms.common.utils.StringUtils;
 import com.warewms.hailiang.MES.MesService;
+import com.warewms.hailiang.config.CodeReadProperties;
+import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.enums.DeviceNameEnum;
 import com.warewms.hailiang.enums.WeighPlcEnum;
@@ -10,9 +14,17 @@ import com.warewms.hailiang.init.PlcConnectServiceRunner;
 import com.warewms.hailiang.init.TcpServiceRunner;
 import com.warewms.hailiang.service.ProcessRealizationService;
 import com.warewms.hailiang.service.RetroactiveNowService;
+import com.warewms.hailiang.util.InkjetPrintersSetUpTools;
+import com.warewms.hailiang.util.ParseMsgTools;
+import io.netty.buffer.Unpooled;
+import io.netty.util.CharsetUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.concurrent.TimeUnit;
+
 /**
  * 工艺流程实现
  */
@@ -31,44 +43,61 @@ public class ProcessRealizationServiceImpl implements ProcessRealizationService
 
     @Autowired
     RetroactiveNowService retroactiveNowService;
+
+    @Autowired
+    private RedisCache redisCache;
+
     @Override
+    @Transactional
     public void weightProcess() throws InterruptedException {
         //读取称重信息
         double weight = plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).readFloat64(WeighPlcEnum.ReadWeight.getMetadata());
-        if(weight==0){
+        if (weight == 0) {
             log.error("重量信息有误,为0");
-        }else {
+        } else {
             //调用MES系统拿到批次号
             String BatchNo = mesService.getBatchNoByWeight(weight, "Z1");
-            if (StringUtils.isNotEmpty(BatchNo)){
+            if (StringUtils.isNotEmpty(BatchNo)) {
                 //数据库记录批次号
-                RetroactiveNow z1 = new RetroactiveNow(weight,BatchNo,"Z1");
-                z1.setCreateBy("system");
-                z1.setStatus("1");
-                int insert = retroactiveNowService.insertData(z1);
-                if (insert==1){
-                    log.info("追溯记录生成成功,BatchNo:{}",BatchNo);
-                    //反馈plc成功拿到重量生成追溯记录
-                    plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.returnWeight.getMetadata(),true);
-                    Thread.sleep(5000);
-                    plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.IsRead.getMetadata(),false);
-                }else {
-                    log.info("追溯记录生成失败,BatchNo:{}",BatchNo);
-                }
+                RetroactiveNow retroactiveNow = new RetroactiveNow(weight, BatchNo, "Z1");
+                retroactiveNow.setCreateBy("system");
+                retroactiveNow.setStatus("1");
+                retroactiveNowService.insertData(retroactiveNow);
+                //反馈plc成功拿到重量生成追溯记录
+                plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.returnWeight.getMetadata(), true);
+                Thread.sleep(5000);
+                plcConnectServiceRunner.getPlcServer(DeviceNameEnum.WEIGHTPLC.getDeviceName()).writeBoolean(WeighPlcEnum.returnWeight.getMetadata(), false);
+                //更新喷码机条码内容
+                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"));
+                log.info("追溯记录生成成功,BatchNo:{}", BatchNo);
             }
         }
 
     }
 
     @Override
-    public void DaoJiaoProcess() {
+    public void DaoJiaoCodingCodeProcess() {
         //获取数据库中的批次号
         RetroactiveNow retroactiveNow = new RetroactiveNow();
         retroactiveNow.setStatus("1");
-        retroactiveNow =  retroactiveNowService.selectTheOneByParameter(retroactiveNow);
-        if (ObjectUtil.isNotNull(retroactiveNow)){
+        retroactiveNow = retroactiveNowService.selectTheOneByParameter(retroactiveNow);
+        if (ObjectUtil.isNotNull(retroactiveNow)) {
             //更新喷码机条码内容
+            String updateCode = InkjetPrintersSetUpTools.updateCode(retroactiveNow.getBatchNo());
+            tcpServiceRunner.getTCPInstanceList("InkjetPrinters").getChannel().writeAndFlush(ParseMsgTools.hexString2Bytes(updateCode));
 
         }
     }
+
+    @Override
+    public void CodeReadingProcess(String 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);
+    }
 }

+ 29 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java

@@ -1,11 +1,19 @@
 package com.warewms.hailiang.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.RetroactiveHistory;
+import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.service.RetroactiveHistoryService;
 import com.warewms.hailiang.mapper.RetroactiveHistoryMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
 * @author AD
 * @description 针对表【retroactive_history(生产历史追溯表)】的数据库操作Service实现
@@ -15,6 +23,27 @@ import org.springframework.stereotype.Service;
 public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistoryMapper, RetroactiveHistory>
     implements RetroactiveHistoryService{
 
+    @Autowired
+    RetroactiveHistoryMapper retroactiveHistoryMapper;
+
+    @Override
+    public TableDataInfo<RetroactiveHistory> getList(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())
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getLotNo()),RetroactiveHistory::getLotNo,retroactiveHistory.getLotNo())
+                .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
+                .orderByDesc(RetroactiveHistory::getCreateTime)
+
+        ));
+    }
+
+    @Override
+    public List<RetroactiveHistory> getHistoryList(RetroactiveHistory retroactiveHistory) {
+        return retroactiveHistoryMapper.selectList(new LambdaQueryWrapper<RetroactiveHistory>()
+                .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()),RetroactiveHistory::getRetroactiveId,retroactiveHistory.getRetroactiveId())
+                .orderByDesc(RetroactiveHistory::getCreateTime));
+    }
 }
 
 

+ 40 - 3
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -1,9 +1,14 @@
 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.extension.service.impl.ServiceImpl;
+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;
@@ -15,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Map;
 
 /**
 * @author AD
@@ -33,14 +39,24 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     private RetroactiveHistoryMapper retroactiveHistoryMapper;
 
     @Override
-    @Transactional
+    public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain) {
+        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())
+                .orderByDesc(RetroactiveNow::getCreateTime)
+        ));
+    }
+
+    @Override
     public int insertData(RetroactiveNow retroactiveNow) {
         List<RetroactiveNow> retroactiveNows = retroactiveNowMapper.selectList(new LambdaQueryWrapper<RetroactiveNow>()
                 .eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
         );
         if (retroactiveNows.size()>0){
-            log.info("数据库中已存在相同批次号");
-            return 0;
+            throw new ServiceException("数据库中已存在相同批次号");
         }
         retroactiveNowMapper.insert(retroactiveNow);
         return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(retroactiveNow,RetroactiveHistory.class));
@@ -49,10 +65,31 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     @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())
         );
     }
+
+    @Override
+    @Transactional
+    public int updateData(RetroactiveNow retroactiveNow) {
+        RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
+                .eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+        );
+        if (ObjectUtil.isNull(baseData)){
+            throw new ServiceException("数据库中不存在该批次号,"+ retroactiveNow.getBatchNo());
+        }
+        if (baseData.getStatus().equals(retroactiveNow)){
+            log.info("数据库存在该状态的数据");
+            return 0;
+        }
+            baseData.setStatus(retroactiveNow.getStatus());
+            baseData.setDeviceId(retroactiveNow.getDeviceId());
+            retroactiveNowMapper.updateById(baseData);
+            return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(baseData,RetroactiveHistory.class));
+
+    }
 }
 
 

+ 67 - 0
warewms-system/src/main/java/com/warewms/hailiang/util/InkjetPrintersSetUpTools.java

@@ -0,0 +1,67 @@
+package com.warewms.hailiang.util;
+
+import com.warewms.hailiang.enums.InkjetPrintersDirectivesEnum;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.util.CharsetUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+
+@Component
+public class InkjetPrintersSetUpTools {
+
+    private boolean isFirst = true;
+
+    /**
+     * 生成修改条码内容的命令
+     */
+    public static String updateCode(String code){
+        StringBuffer stringBuffer = new StringBuffer();
+        stringBuffer.append("E800");
+        stringBuffer.append("0").append(Integer.toHexString(code.length()+3));
+        stringBuffer.append("01000").append(Integer.toHexString((code.length())));
+        for (char c : code.toCharArray()) {
+            stringBuffer.append(Integer.toHexString(c));
+        }
+        return addAChecksum(stringBuffer.toString());
+    }
+
+    /**
+     *  添加校验和
+     * @param code
+     * @return
+     */
+   public static String addAChecksum(String code){
+       int l = code.length() / 2;
+       String[] s2 =new String[l];
+       for (int i = 0; i < l; i++) {
+           s2[i] = code.substring(i * 2, i * 2 + 2);
+       }
+       int i  =Integer.parseInt(s2[0],16) ^ Integer.parseInt(s2[1],16) ;
+       for (int i1 = 1; i1 < s2.length-1; i1++) {
+           i = i ^ Integer.parseInt(s2[i1+1],16);
+       }
+       return code+Integer.toHexString(i);
+   }
+
+
+
+    public static void main(String[] args) {
+        String a ="237191209000";
+//        StringBuffer stringBuffer = new StringBuffer();
+//        stringBuffer.append("E8 ");
+//        int length = a.length();
+//        System.out.println(Integer.toHexString(length));
+//        System.out.println(Integer.toHexString(length+3));
+//        int length =  ;
+//        System.out.println(ParseMsgTools.StringTohexString("237191209000"));
+//        String b ="E8 00 0F 01 00 0C 32 33 37 31 39 31 32 30 39 30 30 30";
+//        System.out.println(InkjetPrintersSetUpTools.addAChecksum(b));
+//        String s = "E8000f01000c323337313931323039303030EE";
+        System.out.println(updateCode(a));
+//        ByteBuf byteBuf = Unpooled.copiedBuffer(s, CharsetUtil.UTF_16);
+//        System.out.println(Arrays.toString(byteBuf.array()));
+//        System.out.println(Arrays.toString(ParseMsgTools.hexString2Bytes(s)));
+    }
+}

+ 3 - 1
warewms-system/src/main/java/com/warewms/hailiang/util/ParseMsgTools.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.util;
 
 import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
 
 /**
  * Created with IntelliJ IDEA.
@@ -41,6 +42,7 @@ public class ParseMsgTools {
         }
         return sb.toString();
     }
+
     public static void main(String[] args) throws UnsupportedEncodingException {
 //        String str = "23";
 //        StringBuffer sb = new StringBuffer();
@@ -65,7 +67,7 @@ public class ParseMsgTools {
 //        }
 //        System.out.println(Integer.toHexString(i));
 
-//        System.out.println(Integer.parseInt("23",16));
+        System.out.println(Integer.parseInt("30",16));
 //        System.out.println(Arrays.toString(hexString2Bytes("8000")));
 
 //        System.out.println(Integer.parseInt("E8",16));

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

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.warewms.hailiang.mapper.DeviceLogMapper">
 
-    <resultMap id="BaseResultMap" type="com.warewms.hailiang.domian.DeviceLog">
+    <resultMap id="BaseResultMap" type="com.warewms.hailiang.domain.DeviceLog">
             <id property="deviceLogId" column="device_log_id" jdbcType="BIGINT"/>
             <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
             <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>

+ 2 - 1
warewms-system/src/main/resources/mapper/hailiang/RetroactiveHistoryMapper.xml

@@ -5,7 +5,8 @@
 <mapper namespace="com.warewms.hailiang.mapper.RetroactiveHistoryMapper">
 
     <resultMap id="BaseResultMap" type="com.warewms.hailiang.domain.RetroactiveHistory">
-            <id property="retroactiveId" column="retroactive_id" jdbcType="VARCHAR"/>
+            <id property="historyId" column="history_id" jdbcType="BIGINT"/>
+            <result property="retroactiveId" column="retroactive_id" jdbcType="VARCHAR"/>
             <result property="productionLine" column="production_line" jdbcType="VARCHAR"/>
             <result property="batchNo" column="batch_no" jdbcType="VARCHAR"/>
             <result property="lotNo" column="lot_no" jdbcType="VARCHAR"/>