Levi.u před 4 roky
rodič
revize
232e707857

+ 0 - 1
src/main/java/com/ebei/screen/common/util/MyRunner.java

@@ -28,7 +28,6 @@ public class MyRunner implements ApplicationRunner {
     public void run(ApplicationArguments args) {
         energyPlatformService.initData();
         ebaSystemService.initData();
-        ScheduledUtils.stop();
         log.info("=============全部初始化完毕=============");
     }
 }

+ 1 - 1
src/main/java/com/ebei/screen/common/util/ScheduledUtils.java

@@ -17,7 +17,7 @@ import java.util.concurrent.*;
 public class ScheduledUtils {
 
     private static final int IN_USE_SIZE = Runtime.getRuntime().availableProcessors() + 1;
-    private static final ScheduledExecutorService scheduleService = new ScheduledThreadPoolExecutor(IN_USE_SIZE,
+    private static ScheduledExecutorService scheduleService = new ScheduledThreadPoolExecutor(IN_USE_SIZE,
             new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build());
 
     public static void start(Callable run, Long time) {

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

@@ -35,15 +35,14 @@ public class EbaSystemController {
     }
 
     @ApiOperation("获取实时设备列表 ✔")
-    @PostMapping("/getDeviceList/{projectId}")
-    public ResponseBean getDeviceList(@PathVariable String projectId) {
-        projectId = EbaUtils.getProjectId(projectId);
+    @PostMapping(value = {"/getDeviceList/{projectId}", "/getDeviceList"})
+    public ResponseBean getDeviceList(@PathVariable(required = false) String projectId) {
         return ebaSystemService.getDeviceList(projectId);
     }
 
     @ApiOperation("获取实时火警和预警 ✔")
-    @PostMapping("/getRealTimeList/{projectId}")
-    public ResponseBean getRealTimeList(@PathVariable String projectId) {
+    @PostMapping(value = {"/getRealTimeList/{projectId}", "/getRealTimeList"})
+    public ResponseBean getRealTimeList(@PathVariable(required = false) String projectId) {
         projectId = EbaUtils.getProjectId(projectId);
         return ebaSystemService.getRealTimeList(projectId);
     }

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

@@ -17,6 +17,7 @@ import com.ebei.screen.common.util.LeviUtils;
 import com.ebei.screen.common.util.ScheduledUtils;
 import com.ebei.screen.service.EbaSystemService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.mongodb.core.MongoTemplate;
@@ -370,7 +371,20 @@ public class EbaSystemServiceImpl implements EbaSystemService {
     @Override
     public ResponseBean getDeviceList(String projectId) {
         JSONObject obj = mongoTemplate.findById("mobjectList", JSONObject.class, "ebaAuth");
-        JSONArray array = obj.getJSONObject("data").getJSONArray(projectId);
+        JSONArray array = new JSONArray();
+        if (StringUtils.isNotBlank(projectId)) {
+            projectId = EbaUtils.getProjectId(projectId);
+            array = obj.getJSONObject("data").getJSONArray(projectId);
+        } else {
+            JSONObject obj2 = mongoTemplate.findById("relevanceProject", JSONObject.class, "relevanceProject");
+            JSONObject data = obj2 != null ? obj2.getJSONObject("data") : new JSONObject();
+            List<String> collect = data.values().stream().map(x -> (String) x).distinct().collect(Collectors.toList());
+            if (data != null) {
+                for (String p : collect) {
+                    array.addAll(obj.getJSONObject("data").getJSONArray(p));
+                }
+            }
+        }
         if (array == null || array.size() <= 0) {
             return ResponseBuilder.ok(Levi.by("electricity", new JSONArray()).set("water", new JSONArray()));
         }
@@ -393,6 +407,7 @@ public class EbaSystemServiceImpl implements EbaSystemService {
      */
     @Override
     public ResponseBean getRealTimeList(String projectId) {
+        boolean flag = StringUtils.isNotBlank(projectId);
         LocalDateTime now = LocalDateTime.now();
         int year = now.getYear();
         int month = now.getMonthValue();
@@ -417,7 +432,15 @@ public class EbaSystemServiceImpl implements EbaSystemService {
                 Integer alarmType = (Integer) y.get("AlarmType");
                 Integer pid = (Integer) y.get("ProjectId");
                 y.put("AlarmTimeStr", LeviUtils.convertTime(y.get("AlarmTime")));
-                if ((pid.toString()).equals(projectId)) {
+                if (flag) {
+                    if ((pid.toString()).equals(projectId)) {
+                        if (alarmType == 1) {
+                            huojing.add(y);
+                        } else if (alarmType == 2) {
+                            guzhang.add(y);
+                        }
+                    }
+                } else {
                     if (alarmType == 1) {
                         huojing.add(y);
                     } else if (alarmType == 2) {