|
@@ -1,9 +1,17 @@
|
|
|
package com.persagy.apm.dmpalarm.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -105,5 +113,33 @@ public class AlarmConfigController {
|
|
|
return alarmConfigService.init(alarmConfig);
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String filePath = "/Users/lixing/Desktop/response.json";
|
|
|
+ Path path = Paths.get(filePath);
|
|
|
+ try {
|
|
|
+ byte[] bytes = Files.readAllBytes(path);
|
|
|
+ String content = new String(bytes);
|
|
|
+
|
|
|
+ JSONObject parse = (JSONObject)JSONObject.parse(content);
|
|
|
+ JSONArray data = parse.getJSONArray("data");
|
|
|
+ System.out.println("报警条件共:" + data.size());
|
|
|
+
|
|
|
+ Map<String, List<String>> objMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (Object datum : data) {
|
|
|
+ JSONObject datum1 = (JSONObject) datum;
|
|
|
+ String objId = datum1.getString("objId");
|
|
|
+ String itemCode = datum1.getString("itemCode");
|
|
|
+
|
|
|
+ List<String> itemCodes = objMap.computeIfAbsent(objId, k -> Lists.newArrayList());
|
|
|
+ itemCodes.add(itemCode);
|
|
|
+ }
|
|
|
+ System.out.println("共有设备:" + objMap.keySet().size());
|
|
|
+ objMap.forEach((k,v) -> System.out.println("设备:" + k + ",报警类型:" + v));
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|