Browse Source

汇总页接口

lmstack 3 years ago
parent
commit
77bfa0f35f

+ 36 - 4
src/main/java/com/qx/didi/controller/ShowDataController.java

@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -49,6 +50,34 @@ public class ShowDataController {
     @Autowired
     SohResultMapper sohResultMapper;
 
+    @ApiOperation(value = "获取汇总数据")
+    @PostMapping("/getTotal")
+    public ApiDTO getTotal(@RequestBody QueryParam param) {
+        List<Response> responses = new ArrayList<>();
+        List<String> sns = new ArrayList<>();
+        QueryWrapper<ResultOriginData> resultOriginDataQueryWrapper = new QueryWrapper<>();
+        if (StringUtils.hasLength(param.getSn())) {
+            resultOriginDataQueryWrapper.like("device_id", param.getSn());
+        }
+        if (param.getTableId() != null) {
+            resultOriginDataQueryWrapper.eq("type", param.getTableId());
+        }
+        if (param.getBatchNum() != null) {
+            resultOriginDataQueryWrapper.like("batch_num", param.getBatchNum());
+        }
+        List<ResultOriginData> resultOriginDataList = resultOriginDataService.list(resultOriginDataQueryWrapper);
+        resultOriginDataList.forEach(p -> sns.add(p.getDeviceId()));
+        sns.forEach(p -> {
+            QueryParam param1 = new QueryParam();
+            param1.setSn(p);
+
+            ApiDTO apiDTO = getRight(param1);
+            responses.add((Response) apiDTO.getData());
+        });
+        return ApiDTO.ok(responses);
+    }
+
+
     @ApiOperation(value = "获取右侧数据")
     @PostMapping("/getRight")
     public ApiDTO getRight(@RequestBody QueryParam param) {
@@ -58,6 +87,7 @@ public class ShowDataController {
             Response response = new Response();
             ResultInfo resultInfo = new ResultInfo();
             // 诊断信息
+
             resultInfo = resultInfoService.getOne(new QueryWrapper<ResultInfo>().eq("sn", param.getSn()));
             if (resultInfo != null) {
                 if (resultInfo.getSafety() != null) {
@@ -69,6 +99,11 @@ public class ShowDataController {
                     response.setSafetyAdvice(Arrays.asList(resultInfo.getSafetyAdvice().split(";")));
                 }
 
+                if (resultInfo.getSafetyText() != null) {
+                    resultInfo.setSafetyText(resultInfo.getSafetyText().replace(";", ";"));
+                    response.setSafetyText(Arrays.asList(resultInfo.getSafetyText().split(";")));
+                }
+
                 if (resultInfo.getSafetyAdvice() != null) {
                     resultInfo.setSafetyAdvice(resultInfo.getSafetyAdvice().replace(";", ";"));
                     response.setSafetyAdvice(Arrays.asList(resultInfo.getSafetyAdvice().split(";")));
@@ -99,7 +134,6 @@ public class ShowDataController {
             }
 
 
-
 //            if (param.getTableId().equals(1)) {
 //                if (resultInfo.getAlarmTime() != null) {
 //                    response.setAlarmTime(new SimpleDateFormat("yyyy-MM-dd").format(resultInfo.getAlarmTime()));
@@ -117,6 +151,7 @@ public class ShowDataController {
 
             // 当前信息
             ResultOriginData resultOriginData = resultOriginDataService.getOne(new QueryWrapper<ResultOriginData>().eq("device_id", param.getSn()));
+            response.setTableId(resultOriginData.getType());
             response.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(resultOriginData.getDate()));
             response.setSoc(resultOriginData.getSoc());
             response.setVoltage(resultOriginData.getVoltage());
@@ -141,7 +176,6 @@ public class ShowDataController {
                         response.setVoltThreshold(new ArrayList<Object>() {{
                             add(r.getThresholdDown());
                             add(r.getThresholdUp());
-
                         }});
                         response.setVoltLevel(r.getLevel());
                     } else if (r.getType().equals("压差离群报警")) {
@@ -151,7 +185,6 @@ public class ShowDataController {
                         response.setVoltDiffThreshold(new ArrayList<Object>() {{
                             add(r.getThresholdDown());
                             add(r.getThresholdUp());
-
                         }});
                         response.setVoltDiffLevel(r.getLevel());
                     } else if (r.getType().equals("内短路报警")) {
@@ -161,7 +194,6 @@ public class ShowDataController {
                         response.setInnershortThreshold(new ArrayList<Object>() {{
                             add(r.getThresholdDown());
                             add(r.getThresholdUp());
-
                         }});
                         response.setInnershortLevel(r.getLevel());
                     }

+ 6 - 0
src/main/java/com/qx/didi/dto/Response.java

@@ -18,6 +18,9 @@ import java.util.*;
 @Data
 public class Response {
 
+    @ApiModelProperty(value = "tableId", name = "tableId", accessMode = AccessMode.READ_ONLY)
+    protected Integer tableId;
+
     @ApiModelProperty(value = "数据时间", name = "time", accessMode = AccessMode.READ_ONLY)
     protected String time;
 
@@ -48,6 +51,9 @@ public class Response {
     @ApiModelProperty(value = "安全诊断", name = "safety", accessMode = AccessMode.READ_ONLY)
     protected List<String> safety = new ArrayList<>();
 
+    @ApiModelProperty(value = "安全诊断处置意见", name = "safetyText", accessMode = AccessMode.READ_ONLY)
+    protected List<String> safetyText = new ArrayList<>();
+
     @ApiModelProperty(value = "安全诊断处置意见", name = "safetyAdvice", accessMode = AccessMode.READ_ONLY)
     protected List<String> safetyAdvice = new ArrayList<>();
 

+ 3 - 0
src/main/java/com/qx/didi/entity/ResultInfo.java

@@ -30,6 +30,9 @@ public class ResultInfo implements Serializable {
     @ApiModelProperty(value = "安全诊断")
     private String safety;
 
+    @ApiModelProperty(value = "安全诊断")
+    private String safetyText;
+
     private String safetyAdvice;
 
     private String riskNotation;

+ 1 - 0
src/main/java/com/qx/didi/entity/ResultOriginData.java

@@ -62,6 +62,7 @@ public class ResultOriginData implements Serializable {
 
     private Integer id;
 
+    private Integer type;
     private Integer batchNum;