瀏覽代碼

- 新增报警信息上传;

Gizmo 2 年之前
父節點
當前提交
206f1b8ebc

+ 19 - 0
src/main/java/com/warewms/common/utils/HeXunResponse.java

@@ -0,0 +1,19 @@
+package com.warewms.common.utils;
+
+import lombok.Data;
+
+/**
+ * PackageName:com.warewms.common.utils
+ * Description:
+ * Author:Gizmo
+ * Date:2022/10/23
+ */
+@Data
+public class HeXunResponse {
+
+    private String msg;
+
+    private String code;
+
+    private String data;
+}

+ 11 - 0
src/main/java/com/warewms/service/impl/HeXunDataServiceImpl.java

@@ -1,5 +1,7 @@
 package com.warewms.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.warewms.common.utils.HeXunResponse;
 import com.warewms.common.utils.HttpRequest;
 import com.warewms.common.utils.JsonUtils;
 import com.warewms.model.HeXunAlarmData;
@@ -10,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -51,6 +54,14 @@ public class HeXunDataServiceImpl implements HeXunDataService {
             try {
 
                 String response = HttpRequest.postData("http://hxetm.com:20974/Interface_JCHGJT/info/addAlarm.do", JsonUtils.toJson(heXunAlarmData));
+
+                HeXunResponse heXunResponse = (HeXunResponse) JSONObject.parse(response);
+                if ("200".equals(heXunResponse.getCode())) {
+
+                    machAlarmRecords.setUploadFlag("1");
+                    machAlarmRecords.setUploadTime(new Date());
+                    machAlarmRecords.update();
+                }
                 log.info("http response:" + response);
             } catch (Exception e) {
                 e.printStackTrace();

+ 6 - 0
src/test/java/com/warewms/dao/ProcTest.java

@@ -1,6 +1,7 @@
 package com.warewms.dao;
 
 import com.warewms.service.HeXunDataService;
+import com.warewms.service.MachAlarmRecordsService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -21,8 +22,13 @@ public class ProcTest {
     @Autowired
     HeXunDataService heXunDataService;
 
+    @Autowired
+    MachAlarmRecordsService machAlarmRecordsService;
+
     @Test
     public void doProc(){
 
+        machAlarmRecordsService.saveUnrecordedAlarm4MachineOne();
+        machAlarmRecordsService.saveUnrecordedAlarm4MachineTwo();
     }
 }

二進制
target/classes/com/warewms/model/_MappingKit.class