Levi.u 4 年 前
コミット
3e2591f5f9

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

@@ -1,5 +1,6 @@
 package com.ebei.screen.controller.eba;
 
+import com.alibaba.fastjson.JSON;
 import com.ebei.screen.common.constants.CommonConstants;
 import com.ebei.screen.common.response.ResponseBean;
 import com.ebei.screen.common.util.EbaUtils;
@@ -26,9 +27,10 @@ public class EbaSystemController {
     private EbaSystemService ebaSystemService;
 
     @ApiOperation("实时数据回调接口")
-    @PostMapping("/realTimeCallback")
-    public Integer realTimeCallback(@RequestBody Map<String, String> params) {
-        return ebaSystemService.realTimeCallback(params);
+    @PostMapping(value = "/realTimeCallback", produces = "application/json; charset=utf-8")
+    public Integer realTimeCallback(@RequestBody Map params) {
+        System.out.println("实时数据回调接口:" + JSON.toJSONString(params));
+        return null;
     }
 
     @ApiOperation("获取项目列表 ✔")

+ 11 - 9
src/main/java/com/ebei/screen/service/impl/ParkSystemServiceImpl.java

@@ -247,8 +247,8 @@ public class ParkSystemServiceImpl implements ParkSystemService {
             JSONObject exceptionObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.EXCEPTION.getCode());
             JSONObject exceptionData = exceptionObj != null ? exceptionObj.getJSONObject("data") : null;
             JSONObject exceptionObjOld = mongoTemplate.findById(code + "_" + formatOld, JSONObject.class, ParkType.EXCEPTION.getCode());
-            ParkExceptionType.codeList().forEach(x -> exceptionCountResult.set(exceptionObj == null ? 0 : (exceptionObj.getDouble(x + "Count") == null ? 0 : exceptionObj.getDouble(x + "Count").intValue() + exceptionCountResult.get())));
-            ParkExceptionType.codeList().forEach(x -> exceptionCountOldResult.set(exceptionObjOld == null ? 0 : (exceptionObjOld.getDouble(x + "Count") == null ? 0 : exceptionObjOld.getDouble(x + "Count").intValue() + exceptionCountOldResult.get())));
+            ParkExceptionType.codeList().forEach(x -> exceptionCountResult.set(exceptionObj == null ? 0 : (exceptionObj.getDouble(x + "Count") == null ? 0 : exceptionObj.getDouble(x + "Count").intValue()) + exceptionCountResult.get()));
+            ParkExceptionType.codeList().forEach(x -> exceptionCountOldResult.set(exceptionObjOld == null ? 0 : (exceptionObjOld.getDouble(x + "Count") == null ? 0 : exceptionObjOld.getDouble(x + "Count").intValue()) + exceptionCountOldResult.get()));
             Double inCount = inObj == null ? 0 : inObj.getDouble("count");
             Double inCountOld = inObjOld == null ? 0 : inObjOld.getDouble("count");
             Double outCount = outObj == null ? 0 : outObj.getDouble("count");
@@ -607,13 +607,15 @@ public class ParkSystemServiceImpl implements ParkSystemService {
         List<Levi> list = new ArrayList<>();
         Levi result = Levi.create();
         ParkExceptionType.codeList().forEach(x -> result.set(x, 0));
-        JSONObject obj = mongoTemplate.findById(ParkType.EXCEPTION.getCode(), JSONObject.class, ParkType.EXCEPTION.getCode());
-        if (obj == null) {
-            result.keySet().forEach(x -> list.add(Levi.by("name", ParkExceptionType.getTypeByCode(x.toString()).getName()).set("code", x).set("count", result.get(x))));
-            return ResponseBuilder.ok(list);
-        }
-        parkCodeList.forEach(code -> ParkExceptionType.codeList().forEach(x -> result.set(x, result.getInt(x) + (obj.getInteger(x + "Count") == null ? 0 : obj.getInteger(x + "Count")))));
-        result.keySet().forEach(x -> list.add(Levi.by("name", ParkExceptionType.getTypeByCode(x.toString()).getName()).set("code", x).set("count", result.get(x))));
+        parkCodeList.forEach(code -> {
+            String format = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN);
+            JSONObject obj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.EXCEPTION.getCode());
+            if (obj == null) {
+                return;
+            }
+            ParkExceptionType.codeList().forEach(x -> result.set(x, result.getInt(x) + (obj.getInteger(x + "Count") == null ? 0 : obj.getInteger(x + "Count"))));
+        });
+        result.keySet().forEach(x -> list.add(Levi.by("name", ParkExceptionType.getTypeByCode(x.toString()).getName()).set("code", x).set("count", result.getInt(x))));
         return ResponseBuilder.ok(list);
     }