From 1025124051633ed086e1a53d8a2f01a7e6f833d2 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期四, 07 九月 2023 16:50:21 +0800
Subject: [PATCH] 设备健康接口
---
ard-work/src/main/java/com/ruoyi/health/param/GetTrendParam.java | 13 +++
ard-work/src/main/java/com/ruoyi/health/param/GetFMTrendParam.java | 13 +++
ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | 174 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 196 insertions(+), 4 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
index 0bff24a..c3cdb5a 100644
--- a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
+++ b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
@@ -2,6 +2,9 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.health.param.GetFMTrendParam;
+import com.ruoyi.health.param.GetTrendParam;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.utils.result.Results;
import com.ruoyi.utils.soap.ARDSoapUtil;
@@ -13,6 +16,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,7 +43,7 @@
String result = ARDSoapUtil.postSoapResult(url, "GetEquipmentList", map);
if ("".equals(result)) {
//杩斿洖缁撴灉涓虹┖
- return Results.error("娌℃湁璁惧淇℃伅");
+ return Results.succeed("娌℃湁璁惧淇℃伅");
}
Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
if ((int) mapResult.get("code") == 200) {
@@ -47,6 +52,11 @@
for (int i = 0; i < listResult.size(); i++) {
Map<String, Object> mapTemp = listResult.get(i);
int id = (Integer) mapTemp.get("id"); //涓婚敭id
+// String equipKey = (String) mapTemp.get("EquipKey"); //璁惧Key
+// String equipNumber = (String) mapTemp.get("EquipNumber"); //璁惧缂栧彿
+// String equipName = (String) mapTemp.get("EquipName"); //璁惧鍚嶇О
+// String equipLevel = (String) mapTemp.get("EquipLevel"); //璁惧鎶ヨ绛夌骇 0姝e父 1娉ㄦ剰 2涓ラ噸
+// String measureDate = (String) mapTemp.get("MeasureDate"); //鏈�杩戜竴娆℃祴閲忔椂闂�
j.put(id + "", mapTemp);
}
} else {
@@ -68,7 +78,7 @@
String equipKey = "";
if ("".equals(result)) {
//杩斿洖缁撴灉涓虹┖
- return Results.error("娌℃湁璁惧淇℃伅");
+ return Results.succeed("娌℃湁璁惧淇℃伅");
}
Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
if ((int) mapResult.get("code") == 200) {
@@ -83,7 +93,7 @@
}
}
if ("".equals(equipKey)) {
- return Results.error("娌℃湁娴嬬偣淇℃伅");
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
}
//鑾峰彇璁惧鐨勬祴鐐瑰垪琛�
Map<String, Object> hashMap = new HashMap<String, Object>();
@@ -91,12 +101,22 @@
String eResult = ARDSoapUtil.postSoapResult(url, "GetMeasureByEquipKey", hashMap);
if ("".equals(eResult)) {
//杩斿洖缁撴灉涓虹┖
- return Results.error("娌℃湁娴嬬偣淇℃伅");
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
}
Map<String, Object> map1 = (Map<String, Object>) JSON.parse((String) eResult);
if ((int) map1.get("code") == 200) {
j.put("code", map1.get("code"));
List<Map<String, Object>> list = (List<Map<String, Object>>) JSON.parse((String) map1.get("resdata"));
+// for (int i = 0; i < listResult.size(); i++) {
+// Map<String, Object> mapTemp = listResult.get(i);
+// int id = (Integer) mapTemp.get("id"); //涓婚敭id
+// String measureKey = (String) mapTemp.get("MeasureKey"); //娴嬬偣key
+// String measureNumber = (String) mapTemp.get("MeasureNumber"); //娴嬬偣缂栧彿
+// String measureName = (String) mapTemp.get("MeasureName"); //娴嬬偣鍚嶇О
+// String measureLevel = (String) mapTemp.get("MeasureLevel"); //娴嬬偣鎶ヨ绛夌骇 0姝e父 1娉ㄦ剰 2涓ラ噸
+// String sensorType = (String) mapTemp.get("SensorType"); //浼犳劅鍣ㄧ被鍨�
+// String betry = (String) mapTemp.get("BETRY");//鐢甸噺
+// }
j.put("listResult", list);
} else {
//閿欒鎻愮ず
@@ -111,4 +131,150 @@
return Results.succeed(j);
}
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getTrend')")
+ @ApiOperation("鑾峰彇鏌愭补浜曚竴娈垫椂闂寸殑娴嬮噺瓒嬪娍")
+ @GetMapping("getTrend")
+ public Results getTrend(GetTrendParam getTrendParam){
+ String url = configService.getHealth();
+ Map<String , Object> map = new HashMap<String , Object>();
+ map.put("MeasureKey", getTrendParam.getMeasureKey());
+ map.put("StartTime", getTrendParam.getStartTime());
+ map.put("EndTime", getTrendParam.getEndTime());
+ JSONObject j = new JSONObject();
+ String result = ARDSoapUtil.postSoapResult(url ,"GetTrend" , map);
+ if ("".equals(result)){
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
+ }
+ Map<String,Object> mapResult = (Map<String, Object>) JSON.parse((String)result);
+ if ( (int) mapResult.get("code") == 200){
+ j.put("code", mapResult.get("code"));
+ List<Map<String , Object>> listResult = (List<Map<String, Object>>)JSON.parse((String)mapResult.get("resdata"));
+ for(int i = 0 ; i<listResult.size(); i++){
+ Map<String , Object> mapTemp = listResult.get(i);
+ int id = (Integer)mapTemp.get("id"); //涓婚敭id
+ BigDecimal value = (BigDecimal)mapTemp.get("Value"); //鏁板��
+ String measureStr = (String)mapTemp.get("MeasureDate"); //娴嬮噺鏃堕棿
+ measureStr = measureStr.substring(measureStr.indexOf("(")+1, measureStr.indexOf(")",2));
+ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String measureDate = f.format(Long.valueOf(measureStr));
+ mapTemp.put("MeasureDate", measureDate);
+ j.put(id +"" , mapTemp);
+ }
+ }else{
+ //閿欒鎻愮ず
+ j.put("errmsg", mapResult.get("errmsg"));
+ j.put("code", mapResult.get("code"));
+ }
+ return Results.succeed(j);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getWaveDataByIndex')")
+ @ApiOperation("鑾峰彇鏌愭娴嬮噺鏁版嵁鐨勫浘璋�")
+ @GetMapping("getWaveDataByIndex")
+ public Results getWaveDataByIndex(String id){
+ String url = configService.getHealth();
+ Map<String , Object> map = new HashMap<String , Object>();
+ map.put("id", id);
+ JSONObject j = new JSONObject();
+ String result = ARDSoapUtil.postSoapResult(url ,"GetWaveDataByIndex" , map);
+ if ("".equals(result)){
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
+ }
+ Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
+ if ((int) mapResult.get("code") == 200) {
+ j.put("code", mapResult.get("code"));
+ List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
+ int frequency = (Integer) listResult.get(0).get("Frequency"); //棰戝
+ int lines = (Integer) listResult.get(0).get("Lines");//绾挎暟
+ int measureCycle = (Integer) listResult.get(0).get("MeasureCycle");//閲囨牱鏃堕棿
+ List waveDataImage = (List) listResult.get(0).get("WaveDataImage");//鏃跺煙鍥捐氨
+ List FrequencyDataImage = (List) listResult.get(0).get("FrequencyDataImage"); //棰戝煙鍥捐氨
+ j.put("frequency", frequency);
+ j.put("lines", lines);
+ j.put("measureCycle", measureCycle);
+ j.put("waveDataImage", waveDataImage);
+ j.put("FrequencyDataImage", FrequencyDataImage);
+ } else {
+ //閿欒鎻愮ず
+ j.put("errmsg", mapResult.get("errmsg"));
+ j.put("code", mapResult.get("code"));
+ }
+ return Results.succeed(j);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getAlertInfo')")
+ @ApiOperation("鑾峰彇鏌愪釜娴嬬偣鐨勬渶鍚庝竴娆℃姤璀︿俊鎭�")
+ @GetMapping("getAlertInfo")
+ public Results getAlertInfo(String number){
+ String url = configService.getHealth();
+ Map<String , Object> map = new HashMap<String , Object>();
+ map.put("WellNumber", number);
+ JSONObject j = new JSONObject();
+ String result = ARDSoapUtil.postSoapResult(url ,"GetWellAlertInfo" , map);
+ if ("".equals(result)){
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
+ }
+ Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
+ if ((int) mapResult.get("code") == 200) {
+ j.put("code", mapResult.get("code"));
+
+ List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
+ j.put("listResult", listResult);
+ for (int i = 0; i < listResult.size(); i++) {
+ Map<String, Object> mapTemp = listResult.get(i);
+ int id = (Integer) mapTemp.get("id"); //涓婚敭id
+ String position = (String) mapTemp.get("position"); //寮傚父閮ㄤ綅
+ String problem = (String) mapTemp.get("problem"); //寮傚父闂(澶辨晥妯″紡)
+ String suggestion = (String) mapTemp.get("suggestion"); //鏀瑰杽寤鸿
+ }
+ } else {
+ //閿欒鎻愮ず
+ j.put("errmsg", mapResult.get("errmsg"));
+ j.put("code", mapResult.get("code"));
+ }
+ return Results.succeed(j);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getFMTrend')")
+ @ApiOperation("鑾峰彇鏌愬紓甯搁棶棰�(澶辨晥妯″紡)鐨勮秼鍔�")
+ @GetMapping("getFMTrend")
+ public Results getFMTrend(GetFMTrendParam getFMTrendParam){
+ String url = configService.getHealth();
+ Map<String , Object> map = new HashMap<String , Object>();
+ map.put("id", getFMTrendParam.getId());
+ map.put("StartTime", getFMTrendParam.getStartTime());
+ map.put("EndTime", getFMTrendParam.getEndTime());
+ JSONObject j = new JSONObject();
+ String result = ARDSoapUtil.postSoapResult(url ,"GetFMTrend" , map);
+ if ("".equals(result)){
+ return Results.succeed("娌℃湁娴嬬偣淇℃伅");
+ }
+ Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
+ if ((int) mapResult.get("code") == 200) {
+ j.put("code", mapResult.get("code"));
+
+ List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
+ j.put("listResult", listResult);
+ for (int i = 0; i < listResult.size(); i++) {
+ Map<String, Object> mapTemp = listResult.get(i);
+ int id = (Integer) mapTemp.get("id"); //涓婚敭id
+ String value = (String) mapTemp.get("Value"); //鏁板��
+ String measureStr = (String) mapTemp.get("MeasureDate"); //娴嬮噺鏃堕棿
+ }
+ } else {
+ //閿欒鎻愮ず
+ j.put("errmsg", mapResult.get("errmsg"));
+ j.put("code", mapResult.get("code"));
+ }
+ return Results.succeed(j);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getMeasureByEquipKey')")
+ @ApiOperation("鑾峰彇鏌愪釜娌逛簳娴嬬偣鍒楄〃")
+ @GetMapping("getMeasureByEquipKey")
+ public Results getMeasureByEquipKey(GetFMTrendParam getFMTrendParam){
+ String url = configService.getHealth();
+
+ return Results.succeed();
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/health/param/GetFMTrendParam.java b/ard-work/src/main/java/com/ruoyi/health/param/GetFMTrendParam.java
new file mode 100644
index 0000000..c9f1b39
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/health/param/GetFMTrendParam.java
@@ -0,0 +1,13 @@
+package com.ruoyi.health.param;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class GetFMTrendParam {
+ private String id;
+ private String startTime;
+ private String endTime;
+}
diff --git a/ard-work/src/main/java/com/ruoyi/health/param/GetTrendParam.java b/ard-work/src/main/java/com/ruoyi/health/param/GetTrendParam.java
new file mode 100644
index 0000000..3edc4fa
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/health/param/GetTrendParam.java
@@ -0,0 +1,13 @@
+package com.ruoyi.health.param;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class GetTrendParam {
+ private String measureKey;
+ private String startTime;
+ private String endTime;
+}
--
Gitblit v1.9.3