Levi.u 4 роки тому
батько
коміт
375033056d

+ 16 - 17
src/main/java/com/ebei/screen/common/util/EbaUtils.java

@@ -27,7 +27,6 @@ public class EbaUtils {
 
     private static Integer SUCCESS_CODE = 200;
     private static MongoTemplate mongoTemplate;
-    private static List<Map> initEmptyList;
     public static String token;
     public static JSONObject project;
     public static JSONObject deviceSystem;
@@ -38,20 +37,6 @@ public class EbaUtils {
     public static JSONObject realDataDevice;
     public static JSONObject crmProjectInfo;
 
-    static {
-        // 初始化模板
-        List<Map> monthList = new ArrayList<>();
-        Integer monthDays = LeviUtils.getMonthDays(LocalDateTime.now().getMonthValue());
-        for (int b = 1; b <= monthDays; b++) {
-            List<Map> dayList = new ArrayList<>();
-            for (int c = 0; c <= 23; c++) {
-                dayList.add(Levi.by("hour", c).set("data", new ArrayList<>()));
-            }
-            monthList.add(Levi.by("day", b).set("data", dayList));
-        }
-        initEmptyList = monthList;
-    }
-
     @Autowired
     public void setMongoTemplate(MongoTemplate mongoTemplate) {
         EbaUtils.mongoTemplate = mongoTemplate;
@@ -67,6 +52,20 @@ public class EbaUtils {
         return SUCCESS_CODE.equals(JSON.parseObject(result).getInteger("code"));
     }
 
+    public static List<Map> getEmptyTemplate() {
+        // 初始化模板
+        List<Map> monthList = new ArrayList<>();
+        Integer monthDays = LeviUtils.getMonthDays(LocalDateTime.now().getMonthValue());
+        for (int b = 1; b <= monthDays; b++) {
+            List<Map> dayList = new ArrayList<>();
+            for (int c = 0; c <= 23; c++) {
+                dayList.add(Levi.by("hour", c).set("data", new ArrayList<>()));
+            }
+            monthList.add(Levi.by("day", b).set("data", dayList));
+        }
+        return monthList;
+    }
+
     /**
      * 用于存储数据(不带统计数字)
      *
@@ -84,7 +83,7 @@ public class EbaUtils {
         int hour = now.getHour();
         Map monthMap = mongoTemplate.findById(pkId + "_" + year + "_" + month, Map.class, collectionName);
         if (MapUtil.isEmpty(monthMap)) {
-            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", LeviUtils.deepCopy(initEmptyList));
+            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", getEmptyTemplate());
         }
         List<Map> dayList = (List<Map>) monthMap.get("data");
         Map dayMap = dayList.get(day - 1);
@@ -119,7 +118,7 @@ public class EbaUtils {
         List<Map> objList = (List<Map>) obj;
         Map monthMap = mongoTemplate.findById(pkId + "_" + year + "_" + month, Map.class, collectionName);
         if (MapUtil.isEmpty(monthMap)) {
-            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", LeviUtils.deepCopy(initEmptyList));
+            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", getEmptyTemplate());
         }
         List<Map> dayList = (List<Map>) monthMap.get("data");
         Map dayMap = dayList.get(day - 1);

+ 10 - 9
src/main/java/com/ebei/screen/common/util/EnergyUtils.java

@@ -31,14 +31,20 @@ import java.util.*;
 public class EnergyUtils {
 
     private static MongoTemplate mongoTemplate;
-    private static List<Map> initEmptyList;
     public static String token;
     public static String refreshToken;
     public static List<String> boxIds;
     public static Map<String, List<String>> groupIds;
     public static Map<String, List<String>> dmonIds;
 
-    static {
+
+    @Autowired
+    public void setMongoTemplate(MongoTemplate mongoTemplate) {
+        EnergyUtils.mongoTemplate = mongoTemplate;
+    }
+
+
+    public static List<Map> getEmptyTemplate() {
         // 初始化模板
         List<Map> monthList = new ArrayList<>();
         //Integer monthDays = LeviUtils.getMonthDays(LocalDateTime.now().getMonthValue());
@@ -50,12 +56,7 @@ public class EnergyUtils {
             }
             monthList.add(Levi.by("day", b).set("data", dayList));
         }
-        initEmptyList = monthList;
-    }
-
-    @Autowired
-    public void setMongoTemplate(MongoTemplate mongoTemplate) {
-        EnergyUtils.mongoTemplate = mongoTemplate;
+        return monthList;
     }
 
     /**
@@ -132,7 +133,7 @@ public class EnergyUtils {
         List<Map> objList = (List<Map>) obj;
         Map monthMap = mongoTemplate.findById(pkId + "_" + year + "_" + month, Map.class, collectionName);
         if (MapUtil.isEmpty(monthMap)) {
-            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", LeviUtils.deepCopy(initEmptyList));
+            monthMap = Levi.by("_id", pkId + "_" + year + "_" + month).set("data", getEmptyTemplate());
         }
         List<Map> dayList = (List<Map>) monthMap.get("data");
         Map dayMap = dayList.get(day - 1);

+ 1 - 1
src/main/java/com/ebei/screen/controller/eba/EbaSystemController.java

@@ -74,7 +74,7 @@ public class EbaSystemController {
 
     @ApiOperation("删除已有的关联项目")
     @PostMapping("/deleteRelevance/{ebeiProjectId}")
-    public ResponseBean deleteRelevance(@PathVariable String ebeiProjectId){
+    public ResponseBean deleteRelevance(@PathVariable String ebeiProjectId) {
         return ebaSystemService.deleteRelevance(ebeiProjectId);
     }
 

+ 4 - 1
src/main/java/com/ebei/screen/modules/po/VideoScreenListVo.java

@@ -2,7 +2,10 @@ package com.ebei.screen.modules.po;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
 import lombok.experimental.Accessors;
 import org.springframework.data.mongodb.core.mapping.Document;
 

+ 2 - 2
src/main/java/com/ebei/screen/service/impl/EbaSystemServiceImpl.java

@@ -385,7 +385,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
             List<String> collect = data.values().stream().map(x -> (String) x).distinct().collect(Collectors.toList());
             if (data != null) {
                 for (String p : collect) {
-                    if(obj.getJSONObject("data")!=null && obj.getJSONObject("data").getJSONArray(p)!=null){
+                    if (obj.getJSONObject("data") != null && obj.getJSONObject("data").getJSONArray(p) != null) {
                         array.addAll(obj.getJSONObject("data").getJSONArray(p));
                     }
                 }
@@ -485,7 +485,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
         JSONObject obj = mongoTemplate.findById("relevanceProject", JSONObject.class, "relevanceProject");
         JSONObject data = obj != null ? obj.getJSONObject("data") : new JSONObject();
         List<String> collect = data.values().stream().map(x -> (String) x).distinct().collect(Collectors.toList());
-        if(collect.contains(params.get("ebaId"))){
+        if (collect.contains(params.get("ebaId"))) {
             return ResponseBuilder.fail("已关联 请重选");
         }
         data.put(params.get("crmId"), params.get("ebaId"));

+ 2 - 3
src/main/java/com/ebei/screen/service/impl/MachineRoomServiceImpl.java

@@ -24,7 +24,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * @version v1.0
@@ -140,7 +139,7 @@ public class MachineRoomServiceImpl implements MachineRoomService {
                     if (machineRoom.getType().equals(1)) {
                         //萤石设备
                         List<Project> exist = ysProject.stream().filter(x -> x.getId().equals(projectId)).collect(Collectors.toList());
-                        if(CommonUtil.isEmpty(exist)) {
+                        if (CommonUtil.isEmpty(exist)) {
                             //不存在项目
                             Project project = new Project();
                             project.setId(projectId);
@@ -157,7 +156,7 @@ public class MachineRoomServiceImpl implements MachineRoomService {
                     } else {
                         //广联达设备
                         List<Project> exist = gldProject.stream().filter(x -> x.getId().equals(projectId)).collect(Collectors.toList());
-                        if(CommonUtil.isEmpty(exist)) {
+                        if (CommonUtil.isEmpty(exist)) {
                             //不存在项目
                             Project project = new Project();
                             project.setId(projectId);