Ver código fonte

对接MES的正式环境

zhifei 11 meses atrás
pai
commit
5dcb471add

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

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

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

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

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

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

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

@@ -23,6 +23,6 @@
     </sql>
 
     <delete id="cleanUpDataFromAWeekAgo">
-        delete from device_log where DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL 3 MONTH));
+        delete from device_log where DATE(create_time) &lt;= DATE(DATE_SUB(NOW(),INTERVAL 3 MONTH))
     </delete>
 </mapper>