Compare commits
158 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de6922e9cb | ||
|
|
3e7bba6434 | ||
|
|
bd90965597 | ||
|
|
5b0cdb5c18 | ||
|
|
1e64382a98 | ||
|
|
9d6f8155fd | ||
|
|
2c70ae0696 | ||
|
|
92b34ac4c1 | ||
|
|
8bc0498b9f | ||
|
|
d2a8ddfbd2 | ||
|
|
1c69b3010b | ||
|
|
c045b2921c | ||
|
|
2def1546a9 | ||
|
|
776141bea7 | ||
|
|
ccb11142d1 | ||
|
|
1cc1a9ecf2 | ||
|
|
c374b4e438 | ||
|
|
30ae8aaffb | ||
|
|
2bb6a506de | ||
| 7ce35772ef | |||
| 0db2ebf4fc | |||
|
|
340dd6237e | ||
|
|
576beb10c8 | ||
|
|
ab3d90fd24 | ||
| 8a2ef975ea | |||
|
|
7da5d7c1f8 | ||
|
|
bd9f518241 | ||
|
|
7e4119771c | ||
|
|
45cac83b9b | ||
|
|
ba18a1310d | ||
|
|
1ad3fe48b4 | ||
| 413f668179 | |||
|
|
e3a19da34e | ||
|
|
491abdd18e | ||
|
|
1b3bc9f0f2 | ||
|
|
c9aaf82f3f | ||
|
|
1d87a607df | ||
| 6b33a40200 | |||
| a0e8e093fe | |||
| 12e805ccc1 | |||
| bdc3df38a3 | |||
| 6435d7135d | |||
|
|
99052f17f8 | ||
| 17f9ecee29 | |||
|
|
659f1e1ed5 | ||
|
|
dd9662091a | ||
|
|
dfa0daf70c | ||
|
|
61f7981ee5 | ||
|
|
8c75ecb09f | ||
|
|
de53e41f2c | ||
|
|
5b6ddacbf7 | ||
| 8d41510358 | |||
|
|
46948118dd | ||
| 4e0b16fad1 | |||
|
|
bab07585a9 | ||
|
|
ec2242bc35 | ||
| d58e957dae | |||
| 6ce4a97169 | |||
| ba301200b0 | |||
| 96c72acf72 | |||
| a25e1c7e15 | |||
| 7d4d925158 | |||
| 4f657669ad | |||
|
|
b6b1e9c9cb | ||
|
|
c571f870d8 | ||
| f3a0bb75ee | |||
| 1ee77361ff | |||
| 188b091f8d | |||
|
|
d41471f152 | ||
|
|
257dfa2221 | ||
| f4b7b3bdfe | |||
|
|
9c8ea385ed | ||
| ed3b91b2d8 | |||
|
|
c6d02d8724 | ||
| 2e9d640a75 | |||
|
|
d4dba1617d | ||
| 7163f387f6 | |||
| 3afa32bda4 | |||
| 4416459877 | |||
|
|
e7b0ce96f5 | ||
|
|
9fc1baad28 | ||
| dd4cf1eede | |||
| f5afc2e9bc | |||
| d44b511988 | |||
| f3a48ca345 | |||
|
|
3f6af65763 | ||
|
|
1572276448 | ||
|
|
8fa69a6876 | ||
| ec6e90e37a | |||
| 7054098b76 | |||
|
|
2a78f695dc | ||
|
|
cd82ea6c43 | ||
|
|
93973b6c6f | ||
|
|
f9c8c812ee | ||
| 9b6543bbb6 | |||
|
|
173aa100bd | ||
| 6bb50bdd01 | |||
| 54c909324c | |||
|
|
03c245758d | ||
| 9ca34607cc | |||
|
|
23d8bf8870 | ||
|
|
14fb79b1cc | ||
|
|
495b045e6d | ||
|
|
92887b773c | ||
|
|
db8205fbaa | ||
|
|
f971c3f2fa | ||
| fd74a00de9 | |||
| 534018b2f8 | |||
| f2fc74d27d | |||
|
|
ccb7bafda1 | ||
|
|
51539f1137 | ||
| ec5aae048d | |||
| d52c3e680b | |||
| e5eef6b1d1 | |||
|
|
e6e92a5503 | ||
| a415a410bf | |||
|
|
8d78cede68 | ||
| 07f1cd6f2f | |||
| 4e87c83556 | |||
| f2cfc383fd | |||
|
|
d91960700b | ||
| 55e7f1ce69 | |||
| 0b35ce08b0 | |||
|
|
cd78ad0588 | ||
| 12e1dc258a | |||
| 2b49a8b268 | |||
| 84fdd18f4e | |||
| ce3eb8f916 | |||
| e49ebf51ac | |||
|
|
bbbe729568 | ||
| 6de6c0955d | |||
| b24b282cbb | |||
| af47617d37 | |||
| 6bb8448db3 | |||
|
|
a0a42f8fa3 | ||
|
|
be232d390f | ||
| 28b8ca4ea7 | |||
| a5227c372f | |||
|
|
bf11f4c820 | ||
| ed69e53d69 | |||
|
|
a5e4baeb16 | ||
|
|
b13d34dcfc | ||
|
|
bb113720bc | ||
|
|
6040dee569 | ||
|
|
6b6ec07be2 | ||
|
|
83f5c10532 | ||
|
|
8cf4d04c65 | ||
|
|
2c7d465809 | ||
|
|
7bc1f768f9 | ||
|
|
a7b794b4d0 | ||
|
|
ea8a2bd8e7 | ||
|
|
949aa83539 | ||
|
|
11c95b6b42 | ||
| 38ffc6926d | |||
|
|
97c6e7a1e1 | ||
| 82acf16593 | |||
|
|
5c8a4fbfb8 | ||
|
|
8cfad7b57d |
@@ -1,8 +1,9 @@
|
||||
#### 简介
|
||||
设备模块主要包含以下功能:
|
||||
* 检测计划管理
|
||||
* 被检设备管理
|
||||
* 检测脚本管理
|
||||
* 被检设备下监测点管理
|
||||
* 误差体系管理
|
||||
* 检测脚本管理
|
||||
* 检测源管理
|
||||
|
||||
|
||||
* 检测报告管理
|
||||
@@ -8,10 +8,9 @@
|
||||
<artifactId>CN_Gather</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>detection</artifactId>
|
||||
<dependencies>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>njcn-common</artifactId>
|
||||
@@ -29,20 +28,12 @@
|
||||
<artifactId>spingboot2.3.12</artifactId>
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.68.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>device</artifactId>
|
||||
<artifactId>system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
@@ -54,6 +45,36 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.68.Final</version>
|
||||
</dependency>
|
||||
<!-- WordToHtml .doc .odcx poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!-- 操作excel的库 注意版本保持一致 poi poi-ooxml poi-scratchpad -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!--poi-ooxml和*poi-ooxml-schemas*是poi对2007及以上版本的扩充。-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.njcn.gather.detection.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -22,9 +19,9 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -47,33 +44,62 @@ public class PreDetectionController extends BaseController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 终止预检测
|
||||
*/
|
||||
@PostMapping("/closePreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("终止预检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closePreTest(@RequestBody PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("closePreTest");
|
||||
preDetectionService.closePreTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始预检测
|
||||
* 开始检测
|
||||
*/
|
||||
@PostMapping("/startPreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("开始预检测")
|
||||
@ApiOperation("开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startPreTest(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("startPreTest");
|
||||
preDetectionService.sourceCommunicationCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系数校验
|
||||
*/
|
||||
@PostMapping("/coefficientCheck")
|
||||
@OperateInfo
|
||||
@ApiOperation("系数校验")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("coefficientCheck");
|
||||
preDetectionService.coefficientCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂停检测
|
||||
*/
|
||||
@GetMapping("/closePreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("暂停检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> temStopTest(){
|
||||
String methodDescribe = getMethodDescribe("temStopTest");
|
||||
preDetectionService.temStopTest();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新开始检测
|
||||
*/
|
||||
@PostMapping("/restartTemTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("重新开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("restartTemTest");
|
||||
preDetectionService.restartTemTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -87,39 +113,104 @@ public class PreDetectionController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("startTest");
|
||||
//preDetectionService.startTest(param);
|
||||
|
||||
String a = "{\"Time\":\"2025-01-02T14:14:44.958\",\"ID\":\"192.168.1.186_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.035600\"}}],\"SqlDataHarm\":[]}";
|
||||
String b = "{\"Time\":\"2025-01-02T14:14:39.004\",\"ID\":\"192.168.1.203_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.000000\"}}],\"SqlDataHarm\":[]}";
|
||||
String c = "{\"Time\":\"2025-01-02T14:14:39.004\",\"ID\":\"192.168.1.203_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.000000\"}}],\"SqlDataHarm\":[]}";
|
||||
String d = "{\"Time\":\"2025-01-02T14:14:47.956\",\"ID\":\"192.168.1.186_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.032300\"}}],\"SqlDataHarm\":[]}";
|
||||
String e = "{\"Time\":\"2025-01-02T14:14:42.004\",\"ID\":\"192.168.1.203_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.000000\"}}],\"SqlDataHarm\":[]}";
|
||||
String f = "{\"Time\":\"2025-01-02T14:14:42.004\",\"ID\":\"192.168.1.203_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.000000\"}}],\"SqlDataHarm\":[]}";
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
|
||||
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
|
||||
|
||||
List<DevData> devDataList = new ArrayList<>();
|
||||
DevData aa = JSON.parseObject(a, DevData.class);
|
||||
DevData bb = JSON.parseObject(a, DevData.class);
|
||||
DevData cc = JSON.parseObject(a, DevData.class);
|
||||
DevData dd = JSON.parseObject(a, DevData.class);
|
||||
DevData ee = JSON.parseObject(a, DevData.class);
|
||||
DevData ff = JSON.parseObject(a, DevData.class);
|
||||
devDataList.add(aa);
|
||||
devDataList.add(bb);
|
||||
devDataList.add(cc);
|
||||
devDataList.add(dd);
|
||||
devDataList.add(ee);
|
||||
devDataList.add(ff);
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId("a303b2224845fcc6f60198b8ca23dca9");
|
||||
issueParam.setIsPhaseSequence(false);
|
||||
//issueParam.setIsPhaseSequence(false);
|
||||
SourceIssue sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam).get(0);
|
||||
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
Map<String, String> devIdMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevId));
|
||||
|
||||
detectionServiceImpl.text(devDataList,param.getErrorSysId(),devIdMapComm,sourceIssues, DictDataEnum.AT_WILL_VALUE);
|
||||
//detectionServiceImpl.processing(devDataList,param,devIdMapComm,sourceIssues, DictDataEnum.AT_WILL_VALUE);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,14 +10,16 @@ import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -32,13 +34,17 @@ public class SocketSourceResponseService {
|
||||
/**
|
||||
* 向webSocket客户端发送消息
|
||||
*/
|
||||
private final WebSocketHandler webSocketHandler;
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
private final String DEV = "_Dev";
|
||||
private final String source = "_Source";
|
||||
|
||||
private final String stepTag = "&&";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
|
||||
|
||||
@Value("${socket.device.ip}")
|
||||
private String ip;
|
||||
@@ -47,12 +53,12 @@ public class SocketSourceResponseService {
|
||||
private Integer port;
|
||||
|
||||
private List<PreDetection> devList = new ArrayList<>();
|
||||
|
||||
private List<String> monitorIdList = new ArrayList<>();
|
||||
|
||||
|
||||
public void deal(PreDetectionParam param, String msg) throws Exception {
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split("&&");
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
if (ObjectUtil.isNotNull(enumByCode)) {
|
||||
switch (enumByCode) {
|
||||
@@ -68,19 +74,64 @@ public class SocketSourceResponseService {
|
||||
case FORMAL_REAL:
|
||||
senParamToDev(param, socketDataMsg);
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
coefficient(param, socketDataMsg);
|
||||
break;
|
||||
case QUITE_SOURCE:
|
||||
quitDeal(socketDataMsg,param);
|
||||
// System.out.println("关闭源回调:"+msg);
|
||||
quitDeal(socketDataMsg, param);
|
||||
break;
|
||||
case YXT:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
System.out.println("1");
|
||||
System.out.println("fggggggggggggggggggggg" + enumByCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系数校验源数据返回处理
|
||||
*/
|
||||
private void coefficient(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
//向前端推送信息
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(monitorIdList);
|
||||
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
|
||||
phaseSequenceParam.setReadCount(10);
|
||||
phaseSequenceParam.setIgnoreCount(7);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
|
||||
*
|
||||
@@ -94,13 +145,12 @@ public class SocketSourceResponseService {
|
||||
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
String s = param.getUserPageId() + DEV;
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
Map<String, List<PreDetection>> map = new HashMap(1);
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
@@ -108,17 +158,44 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
// SocketManager.sendMsg(s,json);
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), json, new NettyDevClientHandler(param, socketDevResponseService));
|
||||
NettyClient.socketClient(ip, port, param, json, new NettyDevClientHandler(param, socketDevResponseService));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case SOURCE_CONNECTION_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
case CONTROLLED_SOURCE_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case TEST_ITEM_PARSING_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case SOURCE_CONTROL_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case TARGET_SOURCE_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case NOT_INITIALIZED:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case UNABLE_TO_RESPOND:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
default:
|
||||
socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -133,11 +210,11 @@ public class SocketSourceResponseService {
|
||||
private void phaseSequenceDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg();
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
//向前端推送信息
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
@@ -146,29 +223,33 @@ public class SocketSourceResponseService {
|
||||
List<String> moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
phaseSequenceParam.setDataType(Arrays.asList("实时数据/电压有效值", "实时数据/电流有效值"));
|
||||
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$VA", "real$IRMS", "real$IA"));
|
||||
phaseSequenceParam.setReadCount(1);
|
||||
phaseSequenceParam.setIgnoreCount(10);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case MESSAGE_PARSING_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 组装和装置要数据
|
||||
*
|
||||
@@ -186,44 +267,61 @@ public class SocketSourceResponseService {
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
String comm = sourceIssue.getDevValueTypeList().get(0);
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue()+"&&"+sourceIssue.getType());
|
||||
List<String> comm = sourceIssue.getDevValueTypeList();
|
||||
System.out.println("向装置下发的参数>>>>>>>>" + comm);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
int ignoreCount;
|
||||
int readData;
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
ignoreCount = 1;
|
||||
readData = 2;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
ignoreCount = 2;
|
||||
readData = 5;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
} else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) {
|
||||
ignoreCount = 5;
|
||||
readData = 1;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_03.getValue());
|
||||
} else {
|
||||
ignoreCount = 5;
|
||||
readData = 5;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
}
|
||||
|
||||
List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
|
||||
System.out.println("向装置下发的参数"+comm);
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
phaseSequenceParam.setDataType(Arrays.asList(comm));
|
||||
phaseSequenceParam.setReadCount(2);
|
||||
phaseSequenceParam.setIgnoreCount(10);
|
||||
phaseSequenceParam.setDataType(comm);
|
||||
phaseSequenceParam.setReadCount(readData);
|
||||
phaseSequenceParam.setIgnoreCount(ignoreCount);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split("&&")[1]+"_Start");
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
devList.forEach(item->{
|
||||
devList.forEach(item -> {
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
devLineTestResult.setDeviceId(item.getDevId());
|
||||
devLineTestResult.setDeviceName(item.getDevName());
|
||||
devListRes.add(devLineTestResult);
|
||||
});
|
||||
webSocketVO.setData(devListRes);
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1] + stepBegin);
|
||||
webSocketVO.setDesc(SocketManager.getSourceList().get(0).getDesc());
|
||||
webSocketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -235,9 +333,7 @@ public class SocketSourceResponseService {
|
||||
*/
|
||||
private void quitDeal(SocketDataMsg socketDataMsg, PreDetectionParam param) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
SourceOperateCodeEnum operateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getOperateCode());
|
||||
SocketMsg socketMsg = new SocketMsg();
|
||||
switch (dictDataEnumByCode) {
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
@@ -245,19 +341,26 @@ public class SocketSourceResponseService {
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case MESSAGE_PARSING_ERROR:
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
break;
|
||||
case UNABLE_TO_RESPOND:
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
break;
|
||||
|
||||
default:
|
||||
WebSocketVO webSocketVO = new WebSocketVO();
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initList(PreDetectionParam param){
|
||||
public void initList(PreDetectionParam param) {
|
||||
devList.clear();
|
||||
monitorIdList.clear();
|
||||
this.devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
this.monitorIdList = devList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.gather.detection.pojo.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-04
|
||||
* @Description: 给装置下发的系数
|
||||
*/
|
||||
@Data
|
||||
public class DevXiNumData {
|
||||
|
||||
private String devIP;
|
||||
|
||||
private Integer chnNum;
|
||||
|
||||
private List<GF> gf;
|
||||
|
||||
private Integer resultFlag;
|
||||
|
||||
|
||||
@Data
|
||||
public static class GF{
|
||||
|
||||
private Integer uMonitorPoint;
|
||||
|
||||
private F f;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class F{
|
||||
|
||||
private Integer count;
|
||||
|
||||
@JSONField(name = "Ua_gain", ordinal = 1)
|
||||
private Integer Ua_gain;
|
||||
@JSONField(name = "Ub_gain", ordinal = 2)
|
||||
private Integer Ub_gain;
|
||||
@JSONField(name = "Uc_gain", ordinal = 3)
|
||||
private Integer Uc_gain;
|
||||
@JSONField(name = "U0_gain", ordinal = 4)
|
||||
private Integer U0_gain;
|
||||
|
||||
@JSONField(name = "Ia_gain", ordinal = 5)
|
||||
private Integer Ia_gain;
|
||||
@JSONField(name = "Ib_gain", ordinal = 6)
|
||||
private Integer Ib_gain;
|
||||
@JSONField(name = "Ic_gain", ordinal = 7)
|
||||
private Integer Ic_gain;
|
||||
@JSONField(name = "I0_gain", ordinal = 8)
|
||||
private Integer I0_gain;
|
||||
|
||||
@JSONField(name = "Uab_gain", ordinal = 9)
|
||||
private Integer Uab_gain;
|
||||
@JSONField(name = "Ubc_gain", ordinal = 10)
|
||||
private Integer Ubc_gain;
|
||||
@JSONField(name = "Uca_gain", ordinal = 11)
|
||||
private Integer Uca_gain;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,13 @@ import lombok.Getter;
|
||||
public enum DetectionResponseEnum {
|
||||
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
||||
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在")
|
||||
|
||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
||||
ITEM_TEST_NOT("A020004", "检测项为空"),
|
||||
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复")
|
||||
;
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
DetectionResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
|
||||
@@ -35,35 +35,59 @@ public enum SourceOperateCodeEnum {
|
||||
QUIT_INIT_03("QUIT_FUNEND$03", "关闭暂态申请"),
|
||||
|
||||
|
||||
DATA_CHNFACTOR$01("DATA_CHNFACTOR$01","校验系数获取"),
|
||||
DATA_CHNFACTOR$02("DATA_CHNFACTOR$02","校验系数下发"),
|
||||
|
||||
|
||||
/**
|
||||
* 请求操作类型对应实体中 requestId
|
||||
*/
|
||||
YJC_YTXJY("yjc_ytxjy", "预检测_源通讯检测"),
|
||||
YJC_SBTXJY("yjc_sbtxjy", "预检测_设备通讯检测"),
|
||||
YJC_XYJY("yjc_xyjy", "预检测_协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "预检测_相序校验"),
|
||||
YJC_YTXJY("yjc_ytxjy", "源通讯检测"),
|
||||
YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"),
|
||||
YJC_XYJY("yjc_xyjy", "协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "相序校验"),
|
||||
FORMAL_REAL("formal_real","正式检测"),
|
||||
Coefficient_Check("Coefficient_Check","系数校验"),
|
||||
QUITE("quit","关闭设备通讯初始化"),
|
||||
QUITE_SOURCE("close_source","关闭源通讯"),
|
||||
ERROR_FLOW_END("error_flow_end","当前流程存在异常结束"),
|
||||
YXT("yxt","心跳"),
|
||||
|
||||
FORMAL_REAL("formal_real","正式检测_获取实时数据"),
|
||||
FORMAL_STATISTIC("formal_statistic","正式检测_获取统计数据"),
|
||||
FORMAL_EVENT("formal_event","正式检测_获取暂态数据"),
|
||||
|
||||
QUITE("quit","预监测_关闭设备通讯初始化"),
|
||||
QUITE_SOURCE("close_source","预监测_关闭源通讯"),
|
||||
UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"),
|
||||
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
|
||||
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
|
||||
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),
|
||||
|
||||
|
||||
|
||||
PRE_TEST("0","预检测"),
|
||||
FORMAL_TEST("1","正式检测"),
|
||||
TIME_TEST("2","守时检测"),
|
||||
|
||||
|
||||
/**
|
||||
* 检测类型
|
||||
*
|
||||
*/
|
||||
Test_Freq("formal_real&&Test_Freq","频率检测"),
|
||||
Test_VOL("formal_real&&Test_VOL","电压检测"),
|
||||
COEFFICIENT_TEST("0","系数校验"),
|
||||
PRE_TEST("1","预检测"),
|
||||
FORMAL_TEST("2","正式检测"),
|
||||
TIME_TEST("3","守时检测"),
|
||||
PHASE_TEST("4","相序检测"),
|
||||
TEST_TEM_STOP("5","临时停止"),
|
||||
TEST_TEM_START("6","继续检测"),
|
||||
TEST_STOP("7","停止检测"),
|
||||
RE_ERROR_TEST("8","不合格项复检"),
|
||||
|
||||
|
||||
/**
|
||||
* 系数校验步骤
|
||||
*/
|
||||
big_start("big_start","大电压系数下装开始"),
|
||||
big_end("big_end","大电压系数下装结束"),
|
||||
small_start("small_start","小电压系数下装开始"),
|
||||
small_end("small_end","小电压系数下装结束"),
|
||||
big_comp_start("big_comp_start","大电压校准开始"),
|
||||
big_comp_end("big_comp_end","大电压校准结束"),
|
||||
small_comp_start("small_comp_start","小电压校准开始"),
|
||||
small_comp_end("small_comp_end","小电压校准结束"),
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
@@ -23,6 +23,7 @@ public enum SourceResponseCodeEnum {
|
||||
NOT_INITIALIZED(10527, "源未进行初始化"),
|
||||
TARGET_SOURCE_ERROR(10528, "目标源有误(该用户已控制其他源,在关闭前无法操作新的源)"),
|
||||
UNABLE_TO_RESPOND(10529, "源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)"),
|
||||
UNKNOWN_ERROR(-1, "未知异常"),
|
||||
|
||||
|
||||
//通讯模块
|
||||
@@ -35,7 +36,9 @@ public enum SourceResponseCodeEnum {
|
||||
|
||||
//自定义前端展示消息
|
||||
SOCKET_ERROR(25000,"服务端连接失败"),
|
||||
DEV_COMM_ALL_SUCCESS(25001,"校验成功")
|
||||
DEV_COMM_ALL_SUCCESS(25001,"校验成功"),
|
||||
DEV_COMM_TEST_FAIL(25002,"设备通讯校验失败"),
|
||||
PHASE_CHECK_FAIL(25003,"相序校验未通过"),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.njcn.gather.detection.pojo.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -13,15 +15,26 @@ import java.util.List;
|
||||
public class PreDetectionParam {
|
||||
|
||||
/**
|
||||
* 操作类型 0.预检测 1.正式检测
|
||||
* 操作类型 0.预检测 1.正式检测 2.系数校验
|
||||
*/
|
||||
private String operateType = "0";
|
||||
|
||||
/**
|
||||
* 检测计划id
|
||||
*/
|
||||
@NotBlank(message = "计划id不可为空")
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 检测计划code
|
||||
*/
|
||||
private String planCode;
|
||||
|
||||
/**
|
||||
* 数字、模拟、比对
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 用户功能组成唯一标识 zhangsan_test
|
||||
*/
|
||||
@@ -30,6 +43,7 @@ public class PreDetectionParam {
|
||||
/**
|
||||
* 检测终端id集合
|
||||
*/
|
||||
@NotEmpty(message = "装置不能为空")
|
||||
private List<String> devIds;
|
||||
|
||||
/**
|
||||
@@ -46,4 +60,9 @@ public class PreDetectionParam {
|
||||
* 所属误差体系
|
||||
*/
|
||||
private String errorSysId;
|
||||
|
||||
/**
|
||||
* 自动生成,用于生成数据表后缀
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.njcn.gather.detection.pojo.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-04
|
||||
* @Description: 系数校准前端返回实体
|
||||
*/
|
||||
@Data
|
||||
public class CoefficientVO {
|
||||
|
||||
@JSONField(name = "type", ordinal = 0)
|
||||
private String type;
|
||||
|
||||
@JSONField(name = "devName", ordinal = 1)
|
||||
private String devName;
|
||||
|
||||
@JSONField(name = "monitorNum", ordinal = 2)
|
||||
private String monitorNum;
|
||||
|
||||
@JSONField(name = "desc", ordinal = 3)
|
||||
private String desc;
|
||||
|
||||
|
||||
@JSONField(name = "aVuData", ordinal = 4)
|
||||
private String aVuData;
|
||||
|
||||
@JSONField(name = "aVuXi", ordinal = 5)
|
||||
private String aVuXi;
|
||||
|
||||
@JSONField(name = "bVuData", ordinal = 6)
|
||||
private String bVuData;
|
||||
|
||||
@JSONField(name = "bVuXi", ordinal = 7)
|
||||
private String bVuXi;
|
||||
|
||||
@JSONField(name = "cVuData", ordinal = 8)
|
||||
private String cVuData;
|
||||
|
||||
@JSONField(name = "cVuXi", ordinal = 9)
|
||||
private String cVuXi;
|
||||
|
||||
@JSONField(name = "aIeData", ordinal = 10)
|
||||
private String aIeData;
|
||||
|
||||
@JSONField(name = "aIeXi", ordinal = 11)
|
||||
private String aIeXi;
|
||||
|
||||
@JSONField(name = "bIeData", ordinal = 12)
|
||||
private String bIeData;
|
||||
|
||||
@JSONField(name = "bIeXi", ordinal = 13)
|
||||
private String bIeXi;
|
||||
|
||||
@JSONField(name = "cIeData", ordinal = 14)
|
||||
private String cIeData;
|
||||
|
||||
@JSONField(name = "cIeXi", ordinal = 15)
|
||||
private String cIeXi;
|
||||
|
||||
|
||||
@JSONField(name = "aV", ordinal = 16)
|
||||
private String aV;
|
||||
|
||||
@JSONField(name = "bV", ordinal = 17)
|
||||
private String bV;
|
||||
|
||||
@JSONField(name = "cV", ordinal = 18)
|
||||
private String cV;
|
||||
|
||||
@JSONField(name = "aI", ordinal = 19)
|
||||
private String aI;
|
||||
|
||||
@JSONField(name = "bI", ordinal = 20)
|
||||
private String bI;
|
||||
|
||||
@JSONField(name = "cI", ordinal = 21)
|
||||
private String cI;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 标识校验不合格的为 0 合格项为 1
|
||||
*/
|
||||
private Integer resultFlag;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class DevParameter{
|
||||
|
||||
private Double devVolt;
|
||||
|
||||
private Double devCurr;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,9 @@ public class DetectionData {
|
||||
*/
|
||||
private Double resultData;
|
||||
|
||||
/**
|
||||
* 误差范围
|
||||
*/
|
||||
private String radius;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* @author chendaofei
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -17,7 +20,9 @@ public class WebSocketVO<T> {
|
||||
|
||||
private String operateCode;
|
||||
|
||||
private String code;
|
||||
private Integer code;
|
||||
|
||||
private String desc;
|
||||
|
||||
private T data;
|
||||
|
||||
|
||||
@@ -20,12 +20,17 @@ public interface PreDetectionService {
|
||||
void sourceCommunicationCheck(PreDetectionParam param);
|
||||
|
||||
|
||||
void coefficientCheck(PreDetectionParam param);
|
||||
|
||||
|
||||
boolean startTest(PreDetectionParam param);
|
||||
|
||||
|
||||
boolean closePreTest(PreDetectionParam param);
|
||||
boolean temStopTest();
|
||||
|
||||
|
||||
boolean restartTemTest(PreDetectionParam param);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -10,19 +11,23 @@ import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.device.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.device.source.service.IPqSourceService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -30,12 +35,13 @@ import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -54,7 +60,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
private final SocketSourceResponseService socketSourceResponseService;
|
||||
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
|
||||
@Value("${socket.source.ip:192.168.1.136}")
|
||||
private String ip;
|
||||
@@ -67,46 +73,14 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||
|
||||
|
||||
System.out.println("进来了啊啊啊啊啊啊啊啊啊啊啊啊啊----------------------------------------------------------------");
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
System.out.println("存活的源=========================="+channel);
|
||||
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
SocketDataMsg socketDataMsg = new SocketDataMsg();
|
||||
socketDataMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
socketDataMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId()+source,JSON.toJSONString(socketDataMsg));
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
commCheck(param);
|
||||
specialDeal(param);
|
||||
/*
|
||||
先组装源通讯协议
|
||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||
*/
|
||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
PqSource pqSource = pqSourceService.getById(plan.getDatasourceId());
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
plan.setErrorSysId(plan.getId());
|
||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||
switch (dictDataEnumByCode) {
|
||||
@@ -124,7 +98,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
}
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
@Override
|
||||
public void coefficientCheck(PreDetectionParam param) {
|
||||
specialDeal(param);
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||
.eq(AdPlanSource::getPlanId, param.getPlanId())
|
||||
);
|
||||
@@ -134,12 +110,40 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
//开始组装socket报文请求头
|
||||
socketDevResponseService.initList(param);
|
||||
socketSourceResponseService.initList(param);
|
||||
SocketMsg msg = new SocketMsg();
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), MsgUtil.toJsonWithNewLinePlain(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_AND_SOURCE_NOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
param.setSourceId(planSource.getSourceId());
|
||||
param.setScriptId(plan.getScriptId());
|
||||
param.setErrorSysId(plan.getErrorSysId());
|
||||
param.setCode(String.valueOf(plan.getCode()));
|
||||
if (ObjectUtil.isNotNull(planSource)) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
socketDevResponseService.initList(param);
|
||||
socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -151,26 +155,80 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public boolean startTest(PreDetectionParam param) {
|
||||
|
||||
socketDevResponseService.initList(param);
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), "start\n", new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param, "start\n", new NettySourceClientHandler(param, sourceResponseService));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closePreTest(PreDetectionParam param) {
|
||||
public boolean temStopTest() {
|
||||
FormalTestManager.stopFlag = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
SocketMsg socketMsg = new SocketMsg();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + dev, JSON.toJSONString(socketMsg));
|
||||
@Override
|
||||
public boolean restartTemTest(PreDetectionParam param) {
|
||||
FormalTestManager.stopFlag = false;
|
||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam=new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(socketMsg));
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType,param.getCode());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作
|
||||
* @param param
|
||||
*/
|
||||
private void specialDeal(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验
|
||||
*/
|
||||
private void commCheck(PreDetectionParam param){
|
||||
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
|
||||
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
|
||||
if(ipList.size()!=param.getDevIds().size()){
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
@@ -12,8 +14,8 @@ import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
*/
|
||||
public class CnSocketUtil {
|
||||
|
||||
private final static String handlerStr = "_Dev";
|
||||
private final static String handlerSourceStr = "_Source";
|
||||
private final static String devTag = "_Dev";
|
||||
private final static String sourceTag = "_Source";
|
||||
|
||||
/**
|
||||
* 退出检测
|
||||
@@ -22,7 +24,7 @@ public class CnSocketUtil {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +34,33 @@ public class CnSocketUtil {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("sourceId", param.getSourceId());
|
||||
socketMsg.setData(jsonObject.toJSONString());
|
||||
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送webSocket数据
|
||||
*/
|
||||
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc){
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(requestId);
|
||||
webSocketVO.setOperateCode(operatorType);
|
||||
webSocketVO.setData(data);
|
||||
webSocketVO.setDesc(desc);
|
||||
WebServiceManager.sendMessage(userId,webSocketVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送未知异常的webSocket数据
|
||||
*/
|
||||
public static void sendUnSocket(String userId){
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
WebServiceManager.sendMessage(userId,webSocketVO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-08
|
||||
* @Description: 正式检测对象管理
|
||||
*/
|
||||
public class FormalTestManager {
|
||||
|
||||
|
||||
/**
|
||||
* key:设备ip,value:当前设备下面的通道序号
|
||||
*/
|
||||
public static Map<String,List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的装置
|
||||
*/
|
||||
public static List<PreDetection> devList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的监测点
|
||||
*/
|
||||
public static List<String> monitorIdListComm = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* key:设备ip,value:装置名称
|
||||
*/
|
||||
public static Map<String, String> devNameMapComm = new HashMap<>();
|
||||
/**
|
||||
* key:设备ip,value:装置id
|
||||
*/
|
||||
public static Map<String, String> devIdMapComm = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 停止触发标识
|
||||
*/
|
||||
public static Boolean stopFlag = false;
|
||||
|
||||
|
||||
/**
|
||||
* 已经暂停后的标识
|
||||
*/
|
||||
public static Boolean hasStopFlag = false;
|
||||
|
||||
|
||||
/**
|
||||
* 暂停后的超时计时时间
|
||||
*/
|
||||
public static Integer stopTime = 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -75,11 +77,22 @@ public class SocketManager {
|
||||
*/
|
||||
private static List<SourceIssue> sourceIssueList = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* 用于存储pq_script_checkdata表里Value_Type与树字典表code
|
||||
*/
|
||||
public static Map<String, String> valueTypeMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 用于存储每个测试小项超时时长key key:检测项 value:时间秒
|
||||
*/
|
||||
public static volatile Map<Integer,Long> clockMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
|
||||
|
||||
public static void addSourceList(List<SourceIssue> sList) {
|
||||
sourceIssueList = sList;
|
||||
System.out.println(sList);
|
||||
}
|
||||
|
||||
public static List<SourceIssue> getSourceList() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Iterator;
|
||||
@@ -24,15 +25,10 @@ public class WebServiceManager {
|
||||
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
|
||||
public static void addUser(String userId, Channel channel) {
|
||||
userSessions.put(userId, channel);
|
||||
}
|
||||
|
||||
public static void removeUser(String userId) {
|
||||
String id = userSessions.get(userId).id().toString();
|
||||
userSessions.remove(userId);
|
||||
}
|
||||
|
||||
public static void removeChannel(String channelId) {
|
||||
// 遍历并删除
|
||||
@@ -60,7 +56,7 @@ public class WebServiceManager {
|
||||
|
||||
}
|
||||
|
||||
public static void sendMessage(String userId, WebSocketVO webSocketVO) {
|
||||
public static void sendMessage(String userId, WebSocketVO<Object> webSocketVO) {
|
||||
Channel channel = userSessions.get(userId);
|
||||
if(Objects.nonNull(channel) && channel.isActive()){
|
||||
TextWebSocketFrame wd = new TextWebSocketFrame(JSON.toJSONString(webSocketVO));
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||
import com.njcn.gather.detection.pojo.vo.CoefficientVO;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-05
|
||||
* @Description: 系数校验管理器
|
||||
*/
|
||||
public class XiNumberManager {
|
||||
|
||||
/**
|
||||
* 存储大电压,小电压源控制脚本
|
||||
*/
|
||||
public static List<SourceIssue> xiSourceIssueList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 存储校验系数的装置ip,校验完一个则删除一个
|
||||
*/
|
||||
public static List<String> devXiList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 存储所有测点的大电压系数
|
||||
*/
|
||||
public static Map<String, DevXiNumData> devXiNumDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 存储所有测点的小电压系数
|
||||
*/
|
||||
public static Map<String, DevXiNumData> smallDevXiNumDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 系数校验步数计数器 0.大电压 1.小电压 2.小电压 3.大电压
|
||||
*/
|
||||
public static Integer stepNumber = 0;
|
||||
|
||||
|
||||
public static List<CoefficientVO.DevParameter> devParameterList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,8 +4,9 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
@@ -30,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Getter
|
||||
public class NettyClient {
|
||||
|
||||
public static void socketClient(String ip, Integer port, String userPageId,String msg, SimpleChannelInboundHandler<String> handler) {
|
||||
public static void socketClient(String ip, Integer port, PreDetectionParam param, String msg, SimpleChannelInboundHandler<String> handler) {
|
||||
NioEventLoopGroup group = new NioEventLoopGroup();
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
try {
|
||||
@@ -44,8 +45,8 @@ public class NettyClient {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
// .addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(20, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(handler);
|
||||
@@ -54,7 +55,7 @@ public class NettyClient {
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(handler);
|
||||
@@ -69,17 +70,17 @@ public class NettyClient {
|
||||
} else {
|
||||
System.out.println("链接服务端成功...");
|
||||
System.out.println("客户端向服务端发送消息:"+msg);
|
||||
channelFuture.channel().writeAndFlush(msg);
|
||||
channelFuture.channel().writeAndFlush(msg+"\n");
|
||||
}
|
||||
});
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(userPageId + "_Dev");
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + "_Dev");
|
||||
if(ObjectUtil.isNotNull(groupByUserId)){
|
||||
groupByUserId.shutdownGracefully();
|
||||
}else{
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
SocketManager.addGroup(userPageId+"_Source",group);
|
||||
SocketManager.addGroup(param.getUserPageId()+"_Source",group);
|
||||
}else{
|
||||
SocketManager.addGroup(userPageId+"_Dev",group);
|
||||
SocketManager.addGroup(param.getUserPageId()+"_Dev",group);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -94,9 +95,10 @@ public class NettyClient {
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
socketDataMsg.setOperateCode("Source");
|
||||
}else{
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketDataMsg.setOperateCode("Dev");
|
||||
}
|
||||
WebServiceManager.sendMsg(userPageId, JSON.toJSONString(socketDataMsg));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
} finally {
|
||||
// System.out.println("进入clientSocket最后步骤---------------------");
|
||||
}
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.handler.timeout.TimeoutException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -34,16 +45,21 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
/**
|
||||
* 当通道进行连接时推送消息
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId()+dev);
|
||||
if(Objects.nonNull(channel)){
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId()+dev,ctx.channel());
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId() + dev, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,9 +67,9 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
*/
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
||||
System.out.println("devhandler接收server端数据>>>>>>"+msg);
|
||||
System.out.println("devhandler接收server端数据>>>>>>" + msg);
|
||||
try {
|
||||
socketResponseService.deal(param,msg);
|
||||
socketResponseService.deal(param, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
CnSocketUtil.quitSend(param);
|
||||
@@ -64,12 +80,15 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
/**
|
||||
* 当通道断线时,支持重连
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
System.out.println("客户端断线");
|
||||
//SocketManager.addUser(webUser,ctx.channel());
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("设备通讯客户端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,11 +99,71 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
*/
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
System.out.println("进入超时。。。。。。");
|
||||
//当连接超过10S和发送消息后10S无响应时候,关闭channel
|
||||
Boolean fly = false;
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
if(!FormalTestManager.hasStopFlag) {
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), SocketManager.clockMap.get(sourceIssue.getIndex()) + 60L);
|
||||
} else {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 60L);
|
||||
}
|
||||
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
//闪变,正常抛一轮最大等待20分钟超时
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
|
||||
fly=true;
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
CnSocketUtil.quitSend(param);
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
//统计数据项,正常抛一轮数据,超时
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
|
||||
fly=true;
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
|
||||
} else {
|
||||
//实时数据
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
|
||||
fly=true;
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fly=true;
|
||||
//为空则认为是常规步骤,设定一分钟超时
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
if(fly){
|
||||
socketResponseService.backCheckState(param);
|
||||
}
|
||||
System.out.println("已经等了一分钟了。。。。。。。。。。。。");
|
||||
}else {
|
||||
//如果是暂停操作后
|
||||
FormalTestManager.stopTime+=60;
|
||||
System.out.println("当前进入暂停操作超时函数-----------------"+FormalTestManager.stopTime);
|
||||
if(FormalTestManager.stopTime > 600){
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(),SourceOperateCodeEnum.FORMAL_REAL.getValue(),SourceOperateCodeEnum.STOP_TIMEOUT.getValue(),SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(),null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有通道准备接入" + ctx.channel());
|
||||
@@ -93,6 +172,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
System.out.println("捕获到设备服务异常。。。。。。。");
|
||||
// 处理异常,例如记录日志、关闭连接等
|
||||
cause.printStackTrace();
|
||||
// 根据异常类型进行不同的处理
|
||||
@@ -103,6 +183,8 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else if (cause instanceof IOException) {
|
||||
// 处理I/O异常,例如读写错误
|
||||
System.out.println("IOException caught: There was an I/O error.");
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
// 处理超时异常
|
||||
@@ -117,7 +199,32 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
// 可以记录未知异常信息
|
||||
}
|
||||
CnSocketUtil.quitSend(param);
|
||||
socketResponseService.backCheckState(param);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void timeoutSend(SourceIssue sourceIssue){
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
FormalTestManager.devList.forEach(dev -> {
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
devLineTestResult.setDeviceId(dev.getDevId());
|
||||
devLineTestResult.setDeviceName(dev.getDevName());
|
||||
List<Integer> resultFlagList = new ArrayList<>();
|
||||
List<PreDetection.MonitorListDTO> monitorListDTOList = dev.getMonitorList();
|
||||
monitorListDTOList.forEach(i -> resultFlagList.add(3));
|
||||
devLineTestResult.setChnResult(resultFlagList.toArray(new Integer[monitorListDTOList.size()]));
|
||||
devListRes.add(devLineTestResult);
|
||||
});
|
||||
WebSocketVO<List<DevLineTestResult>> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(sourceIssue.getType()+"_End");
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
@@ -32,6 +34,7 @@ import java.util.Objects;
|
||||
public class NettySourceClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private final PreDetectionParam webUser;
|
||||
private final String sourceTag = "_Source";
|
||||
private final SocketSourceResponseService sourceResponseService;
|
||||
|
||||
/**
|
||||
@@ -43,7 +46,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
|
||||
SocketManager.addUser(webUser.getUserPageId() + "_Source", ctx.channel());
|
||||
SocketManager.addUser(webUser.getUserPageId() + sourceTag, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +54,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
*/
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
||||
System.out.println("接收server端数据>>>>>>" + msg);
|
||||
System.out.println("source接收server端数据>>>>>>" + msg);
|
||||
try {
|
||||
sourceResponseService.deal(webUser, msg);
|
||||
} catch (Exception e) {
|
||||
@@ -68,7 +71,10 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception{
|
||||
System.out.println("源通讯客户端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(webUser.getUserPageId()+sourceTag);
|
||||
// System.out.println("断线了......" + ctx.channel());
|
||||
// ctx.channel().eventLoop().schedule(() -> {
|
||||
// System.out.println("断线重连......");
|
||||
@@ -87,13 +93,13 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
//如果是空闲状态事件
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.WRITER_IDLE) {
|
||||
//发送ping 保持心跳链接
|
||||
SocketMsg msg = new SocketMsg();
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.writeAndFlush(MsgUtil.toJsonWithNewLinePlain(msg));
|
||||
ctx.writeAndFlush(JSON.toJSONString(msg)+"\n");
|
||||
}
|
||||
} else {
|
||||
//防止堆栈溢出
|
||||
@@ -110,6 +116,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
// 处理异常,例如记录日志、关闭连接等
|
||||
System.out.println("捕获到源异常。。。。。。。");
|
||||
cause.printStackTrace();
|
||||
// 根据异常类型进行不同的处理
|
||||
if (cause instanceof ConnectException) {
|
||||
@@ -118,7 +125,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
|
||||
} else if (cause instanceof IOException) {
|
||||
// 处理I/O异常,例如读写错误
|
||||
System.out.println("IOException caught: There was an I/O error.");
|
||||
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
// 处理超时异常
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.gather.detection.util.socket.service;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.string.StringDecoder;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.gather.detection.util.socket.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.njcn.gather.detection.util.socket.web;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -17,17 +23,19 @@ import org.springframework.stereotype.Component;
|
||||
* @Date: 2024/12/10 13:56
|
||||
*/
|
||||
|
||||
@Component
|
||||
@ChannelHandler.Sharable
|
||||
|
||||
@Slf4j
|
||||
public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
|
||||
|
||||
private int times;
|
||||
|
||||
private final static String QUESTION_MARK = "?";
|
||||
private final static String EQUAL_TO = "=";
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("服务端通道已建立" + ctx.channel().remoteAddress());
|
||||
System.out.println("webSocket服务端通道已建立" + ctx.channel().id());
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +57,11 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
} else if (msg instanceof TextWebSocketFrame) {
|
||||
//正常的TEXT消息类型
|
||||
TextWebSocketFrame frame = (TextWebSocketFrame) msg;
|
||||
log.info("客户端收到服务器数据:{}", frame.text());
|
||||
log.info("webSocket服务器收到客户端心跳信息:{}", frame.text());
|
||||
/*if ("alive".equals(frame.text())) {
|
||||
TextWebSocketFrame wd = new TextWebSocketFrame("over");
|
||||
ctx.writeAndFlush(wd);
|
||||
}*/
|
||||
}
|
||||
super.channelRead(ctx, msg);
|
||||
|
||||
@@ -92,31 +104,53 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
//WebServiceManager.addUser(userId, ctx.channel());
|
||||
System.out.println("有新的连接接入:" + ctx);
|
||||
System.out.println("webSocket有新的连接接入:" + ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
public void handlerRemoved(ChannelHandlerContext ctx){
|
||||
// 假设用户 ID 是从某个地方获取的,这里简单示例为 "userId"
|
||||
System.out.println("weoSocket退出: " + ctx);
|
||||
System.out.println("weoSocket客户端退出: " + ctx.channel().id());
|
||||
WebServiceManager.removeChannel(ctx.channel().id().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
System.out.println("weoSocket断线" + ctx.channel().id());
|
||||
ctx.close();
|
||||
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setUserPageId("cdf");
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
//空闲状态的事件
|
||||
// if (evt instanceof IdleStateEvent) {
|
||||
// IdleStateEvent event = (IdleStateEvent) evt;
|
||||
// System.out.println(event.state() + ">>>" + ctx.channel().id());
|
||||
// //已经10秒钟没有读时间了
|
||||
// if (event.state().equals(IdleState.READER_IDLE)){
|
||||
// // 心跳包丢失,10秒没有收到客户端心跳 (断开连接)
|
||||
// ctx.channel().close().sync();
|
||||
// System.out.println("已与 "+ctx.channel().remoteAddress()+" 断开连接");
|
||||
// }
|
||||
// }
|
||||
IdleStateEvent event = (IdleStateEvent) evt;
|
||||
String eventDesc = null;
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
eventDesc = "读空闲";
|
||||
System.out.println(ctx.channel().remoteAddress() + "发生超时事件--" + eventDesc);
|
||||
times++;
|
||||
if (times > 3) {
|
||||
System.out.println("空闲次数超过三次 关闭连接");
|
||||
ctx.channel().close();
|
||||
}
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
eventDesc = "写空闲";
|
||||
break;
|
||||
case ALL_IDLE:
|
||||
eventDesc = "读写空闲";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//super.userEventTriggered(ctx, evt);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,19 +10,18 @@ import io.netty.handler.codec.http.HttpResponseDecoder;
|
||||
import io.netty.handler.codec.http.HttpServerCodec;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
|
||||
import io.netty.handler.stream.ChunkedWriteHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Description: webSocket服务端自定义配置
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:20
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
|
||||
public class WebSocketInitializer extends ChannelInitializer<SocketChannel> {
|
||||
|
||||
private final WebSocketHandler webSocketHandler;
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +43,8 @@ public class WebSocketInitializer extends ChannelInitializer<SocketChannel> {
|
||||
* 这个时候我们只需要访问 ws://127.0.0.1:7777/hello 就可以了
|
||||
* 这个handler是将http协议升级为websocket 并且使用 101 作为响应码
|
||||
* */
|
||||
pipeline.addLast(webSocketHandler);
|
||||
pipeline.addLast(new IdleStateHandler(13, 0, 0, TimeUnit.SECONDS));
|
||||
pipeline.addLast(new WebSocketHandler());
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler("/hello"));
|
||||
|
||||
pipeline.addLast(new ChannelInboundHandlerAdapter() {
|
||||
|
||||
@@ -25,7 +25,6 @@ import javax.annotation.PreDestroy;
|
||||
@RequiredArgsConstructor
|
||||
public class WebSocketService {
|
||||
|
||||
private final WebSocketInitializer webSocketInitializer;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
@@ -57,7 +56,7 @@ public class WebSocketService {
|
||||
|
||||
//设置连接保持为活动状态
|
||||
.childOption(ChannelOption.SO_KEEPALIVE, true)
|
||||
.childHandler(webSocketInitializer);
|
||||
.childHandler(new WebSocketInitializer());
|
||||
ChannelFuture future = serverBootstrap.bind(port).sync();
|
||||
future.addListener(f -> {
|
||||
if (future.isSuccess()) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.njcn.gather.device.device.controller;
|
||||
package com.njcn.gather.device.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -14,18 +15,22 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -40,7 +45,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -59,6 +63,7 @@ public class PqDevController extends BaseController {
|
||||
|
||||
private final IPqDevService pqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDevTypeService devTypeService;
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@@ -68,8 +73,8 @@ public class PqDevController extends BaseController {
|
||||
public HttpResult<List<PreDetection>> aaa() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
List<PreDetection> devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
||||
Map<String,List<PreDetection> > map=new HashMap();
|
||||
map.put("deviceList",devInfo);
|
||||
Map<String, List<PreDetection>> map = new HashMap();
|
||||
map.put("deviceList", devInfo);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
|
||||
}
|
||||
@@ -79,10 +84,10 @@ public class PqDevController extends BaseController {
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqDev>> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
public HttpResult<Page<PqDevVO>> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<PqDev> result = pqDevService.listPqDevs(queryParam);
|
||||
Page<PqDevVO> result = pqDevService.listPqDevs(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -142,12 +147,6 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
pqDevService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@@ -168,12 +167,19 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
pqDevService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@PostMapping(value = "/importContrast")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importContrastData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(2);
|
||||
@@ -198,6 +204,76 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/exportCNDev")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void exportCNDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("exportCNDev");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
|
||||
pqDevService.exportCNDev(queryParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载灿能二楼设备导入文件模板
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadCNDevTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadCNDevTemplate() {
|
||||
pqDevService.downloadCNDevTemplate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/importCNDev")
|
||||
@ApiOperation("批量导入设备数据")
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file, String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
|
||||
ImportParams params = new ImportParams();
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
|
||||
List<CNDevExcel> cnDevExcelList;
|
||||
try {
|
||||
ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
return null;
|
||||
} else {
|
||||
cnDevExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listUnbound")
|
||||
@ApiOperation("获取指定模式下所有未绑定的设备")
|
||||
@@ -211,23 +287,33 @@ public class PqDevController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("根据查询参数查询出所有已绑定的设备")
|
||||
@ApiOperation("查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDev>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<PqDev> result = pqDevService.listByPlanId(param);
|
||||
List<PqDev> pqDevList = pqDevService.listByPlanId(param);
|
||||
|
||||
List<PqDevVO> result = BeanUtil.copyToList(pqDevList, PqDevVO.class);
|
||||
result.forEach(pqDevVO -> {
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
pqDevVO.setDevVolt(devType.getDevVolt());
|
||||
pqDevVO.setDevCurr(devType.getDevCurr());
|
||||
}
|
||||
});
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@GetMapping("/documented")
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<List<PqDev>> documented(@RequestParam String id) {
|
||||
public HttpResult<List<PqDev>> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, id);
|
||||
boolean result = pqDevService.documented(id);
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqDevService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-06
|
||||
*/
|
||||
public interface PqDevMapper extends MPJBaseMapper<PqDev> {
|
||||
|
||||
/**
|
||||
* 根据装置id集合获取装置信息
|
||||
* @param devIds 装置id
|
||||
* @return: java.util.List<com.njcn.gather.device.pojo.vo.PreDetection>
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/12 11:46
|
||||
*/
|
||||
List<PreDetection> selectDevInfo(@Param("devIds") List<String> devIds);
|
||||
|
||||
void finishPlan(@Param("planId")String planId);
|
||||
|
||||
void updateReportState(@Param("id")String id);
|
||||
|
||||
void updatePlanCheckResult(@Param("planId")String planId, @Param("checkResult")Integer checkResult);
|
||||
|
||||
void updatePlanTestState(@Param("planId")String planId, @Param("testState")Integer testState);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.mapper.PqDevMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="DevResultMap" type="com.njcn.gather.device.pojo.vo.PreDetection">
|
||||
<id column="Id" property="devId" />
|
||||
<id column="Name" property="devName" />
|
||||
<id column="IP" property="devIP" />
|
||||
<result column="Port" property="port" />
|
||||
<result column="Dev_Type" property="devType" />
|
||||
<result column="Series" property="devCode" />
|
||||
<result column="Dev_Key" property="devKey" />
|
||||
<result column="icdType" property="icdType" />
|
||||
<result column="Dev_Chns" property="devChns" />
|
||||
<result column="Dev_Volt" property="devVolt" />
|
||||
<result column="Dev_Curr" property="devCurr" />
|
||||
|
||||
<collection
|
||||
property="monitorList"
|
||||
column="{ devId = Id}"
|
||||
select="com.njcn.gather.monitor.mapper.PqMonitorMapper.selectMonitorInfo"
|
||||
>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="selectDevInfo" resultMap="DevResultMap">
|
||||
SELECT
|
||||
d.Id,
|
||||
d.Name,
|
||||
d.IP,
|
||||
d.Port,
|
||||
t.name as Dev_Type,
|
||||
d.Series,
|
||||
d.Dev_Key,
|
||||
p.name as icdType,
|
||||
t.Dev_Chns,
|
||||
t.Dev_Volt,
|
||||
t.Dev_Curr
|
||||
FROM
|
||||
pq_dev d
|
||||
inner join pq_dev_type t on d.Dev_Type = t.id
|
||||
inner join pq_icd_path p on t.icd = p.id
|
||||
<where>
|
||||
<if test="devIds !=null and devIds.size()!=0">
|
||||
AND d.Id in
|
||||
<foreach collection="devIds" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="finishPlan" >
|
||||
update ad_plan set Test_State = 2 where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updateReportState" >
|
||||
update pq_dev set Report_State = 1 where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanCheckResult">
|
||||
update ad_plan set Result = #{checkResult} where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanTestState">
|
||||
update ad_plan set Test_State = #{testState} where id = #{planId}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -68,8 +68,6 @@ public interface DevValidMessage {
|
||||
|
||||
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误,请检查devType参数";
|
||||
|
||||
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误,请检查devChns参数";
|
||||
|
||||
String MANUFACTURER_FORMAT_ERROR = "设备厂家格式错误,请检查manufacturer参数";
|
||||
|
||||
String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误,请检查protocol参数";
|
||||
@@ -12,6 +12,13 @@ public enum CommonEnum {
|
||||
|
||||
NO("0", "否"),
|
||||
YES("1", "是"),
|
||||
|
||||
|
||||
COEFFICIENT_TEST("0","系数校验"),
|
||||
PRE_TEST("1","预检测"),
|
||||
FORMAL_TEST("2","正式检测"),
|
||||
TIME_TEST("3","守时检测"),
|
||||
PHASE_TEST("4","相序检测"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
@@ -7,7 +7,7 @@ public enum DevResponseEnum {
|
||||
//NAME_REPEAT("A001001", "名称重复"),
|
||||
|
||||
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
|
||||
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空"),
|
||||
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "当为加密设备时,加密设备的序列号和设备密钥不能为空"),
|
||||
PQ_SOURCE_GEN_NAME_ERROR("A001004", "检测源生成名称出错"),
|
||||
ERR_SOURCE_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
|
||||
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
|
||||
@@ -18,7 +18,13 @@ public enum DevResponseEnum {
|
||||
IMPORT_PLAN_DATA_FAIL("A001010", "导入的检测计划为空"),
|
||||
IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"),
|
||||
IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ),
|
||||
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" );
|
||||
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" ),
|
||||
DEV_UN_CHECKED("A001013","装置还未检测完成!" ),
|
||||
DEV_UN_REPORT("A001013","装置报告未生成!" ),
|
||||
DEVICE_DIS_ERROR("A001014","装置配置异常" ),
|
||||
DEVICE_DELETE("A001015","设备无法删除,已绑定计划!" )
|
||||
|
||||
;
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.device.pojo.param;
|
||||
package com.njcn.gather.device.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
@@ -22,8 +22,8 @@ import java.util.List;
|
||||
public class PqDevParam {
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
//@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
//@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
|
||||
@@ -36,27 +36,14 @@ public class PqDevParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "设备通道数", required = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
@Min(value = 1, message = DevValidMessage.DEV_CHNS_RANGE_ERROR)
|
||||
private Integer devChns;
|
||||
|
||||
@ApiModelProperty(value = "额定电压(V)", required = true)
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@ApiModelProperty(value = "额定电流(A)", required = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@ApiModelProperty(value = "设备厂家,字典表", required = true)
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
|
||||
//@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期", required = true)
|
||||
@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
//@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@ApiModelProperty(value = "设备序列号", required = true)
|
||||
@@ -64,11 +51,11 @@ public class PqDevParam {
|
||||
private String createId;
|
||||
|
||||
@ApiModelProperty(value = "固件版本", required = true)
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
//@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@ApiModelProperty(value = "软件版本", required = true)
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
//@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@ApiModelProperty(value = "通讯协议", required = true)
|
||||
@@ -134,6 +121,15 @@ public class PqDevParam {
|
||||
@Valid
|
||||
private List<PqMonitorParam> monitorList;
|
||||
|
||||
@ApiModelProperty("icdId")
|
||||
private String icdId;
|
||||
//
|
||||
// @ApiModelProperty("power")
|
||||
// private String power;
|
||||
|
||||
@ApiModelProperty("预投计划")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@@ -174,7 +170,7 @@ public class PqDevParam {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
// @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
|
||||
@@ -184,7 +180,7 @@ public class PqDevParam {
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("检测状态列表")
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.device.device.pojo.po;
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -14,6 +15,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -45,21 +47,6 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 设备通道数
|
||||
*/
|
||||
private Integer devChns;
|
||||
|
||||
/**
|
||||
* 额定电压(V)
|
||||
*/
|
||||
private Double devVolt;
|
||||
|
||||
/**
|
||||
* 额定电流(A)
|
||||
*/
|
||||
private Double devCurr;
|
||||
|
||||
/**
|
||||
* 设备厂家,字典表
|
||||
*/
|
||||
@@ -111,11 +98,13 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 装置识别码(3ds加密)
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private String series;
|
||||
|
||||
/**
|
||||
* 装置秘钥(3ds加密)
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private String devKey;
|
||||
|
||||
/**
|
||||
@@ -162,11 +151,6 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 归档状态
|
||||
*/
|
||||
private Integer documentState;
|
||||
|
||||
/**
|
||||
* 报告路径
|
||||
*/
|
||||
@@ -207,5 +191,12 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
* 系数校准结果(0:不合格,1:合格)
|
||||
*/
|
||||
private Integer factorCheckResult;
|
||||
|
||||
@TableField("Check_Time")
|
||||
private LocalDateTime checkTime;
|
||||
|
||||
@TableField("Preinvestment_Plan")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-01-15
|
||||
*/
|
||||
@Data
|
||||
public class CNDevExcel {
|
||||
|
||||
@Excel(name = "预投计划*", width = 20, orderNum = "1")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, orderNum = "3")
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "通讯协议*", width = 15, orderNum = "4")
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "5")
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码", width = 30, orderNum = "6")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥", width = 30, orderNum = "7")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "8")
|
||||
private Integer factorFlag;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, replace = {"否_0", "是_1"}, orderNum = "9")
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "10")
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.njcn.gather.device.device.pojo.vo;
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
@@ -134,8 +134,8 @@ public class PqDevExcel implements Serializable {
|
||||
@Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "27", needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "28", needMerge = true)
|
||||
private Integer documentState;
|
||||
// @Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "28", needMerge = true)
|
||||
// private Integer documentState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "29", needMerge = true)
|
||||
private String reportPath;
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-13
|
||||
*/
|
||||
@Data
|
||||
public class PqDevVO extends PqDev {
|
||||
|
||||
private Integer devChns;
|
||||
|
||||
private Double devVolt;
|
||||
|
||||
private Double devCurr;
|
||||
|
||||
private List<PqMonitor> monitorList;
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.njcn.gather.device.device.pojo.vo;
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.njcn.gather.device.device.util.DeviceUtil;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -69,6 +68,10 @@ public class PreDetection {
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private Integer devChns;
|
||||
|
||||
private Double devVolt;
|
||||
|
||||
private Double devCurr;
|
||||
/**
|
||||
* 监测点信息
|
||||
*/
|
||||
@@ -106,7 +109,7 @@ public class PreDetection {
|
||||
|
||||
public String getDevKey() {
|
||||
if (StrUtil.isNotBlank(devKey)) {
|
||||
String key = DeviceUtil.decoderString(1, devKey);
|
||||
String key = EncryptionUtil.decoderString(1, devKey);
|
||||
if (StrUtil.isNotBlank(key)) {
|
||||
return key;
|
||||
}
|
||||
@@ -116,7 +119,7 @@ public class PreDetection {
|
||||
|
||||
public String getDevCode() {
|
||||
if (StrUtil.isNotBlank(devCode)) {
|
||||
String code = DeviceUtil.decoderString(1, devCode);
|
||||
String code = EncryptionUtil.decoderString(1, devCode);
|
||||
if (StrUtil.isNotBlank(code)) {
|
||||
return code;
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.njcn.gather.device.device.service;
|
||||
package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.device.pojo.enums.TimeCheckResultEnum;
|
||||
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.pojo.enums.TimeCheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,7 +26,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param queryParam 查询参数
|
||||
* @return 分页数据,包含被检设备列表
|
||||
*/
|
||||
Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam);
|
||||
Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增被检设备信息
|
||||
@@ -118,7 +119,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param devIds 设备id列表
|
||||
* @return 绑定成功返回true,否则返回false
|
||||
*/
|
||||
boolean bind(String planId, List<String> devIds);
|
||||
Integer bind(String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 获取饼图数据
|
||||
@@ -159,7 +160,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* 获取装置信息和装置下监测点信息
|
||||
*
|
||||
* @param devIds
|
||||
* @return: java.util.List<com.njcn.gather.device.device.pojo.vo.PreDetection>
|
||||
* @return: java.util.List<com.njcn.gather.device.pojo.vo.PreDetection>
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/12 15:50
|
||||
*/
|
||||
@@ -167,8 +168,44 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(String id);
|
||||
boolean documented(List<String> id);
|
||||
|
||||
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
*
|
||||
* @param ids
|
||||
* @param valueType
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
boolean updateResult(List<String> ids, List<String> valueType, String code);
|
||||
|
||||
void updatePqDevReportState(String devId, int i);
|
||||
|
||||
int countUnReportDev(String planId);
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备数据
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
void exportCNDev(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下载灿能二楼设备模板文件
|
||||
*/
|
||||
void downloadCNDevTemplate();
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
*
|
||||
* @param cnDevExcelList 灿能二楼设备数据列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId);
|
||||
}
|
||||
@@ -0,0 +1,925 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.poi.PullDown;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.device.mapper.PqDevMapper;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
private final DetectionDataDealService detectionDataDealService;
|
||||
private final IDevTypeService devTypeService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
|
||||
page1.getRecords().forEach(p -> {
|
||||
if (ObjectUtil.isNotNull(p.getSeries())) {
|
||||
p.setSeries(EncryptionUtil.decoderString(1, p.getSeries()));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(p.getDevKey())) {
|
||||
p.setDevKey(EncryptionUtil.decoderString(1, p.getDevKey()));
|
||||
}
|
||||
});
|
||||
|
||||
Page<PqDevVO> page2 = new Page<>();
|
||||
BeanUtil.copyProperties(page1, page2);
|
||||
List<PqDevVO> voList = BeanUtil.copyToList(page1.getRecords(), PqDevVO.class);
|
||||
page2.setRecords(voList);
|
||||
page2.getRecords().forEach(p -> {
|
||||
DevType devType = devTypeService.getById(p.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
p.setDevChns(devType.getDevChns());
|
||||
p.setDevVolt(devType.getDevVolt());
|
||||
p.setDevCurr(devType.getDevCurr());
|
||||
}
|
||||
});
|
||||
return page2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||
this.checkRepeat(pqDevParam, false);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevParam, pqDev);
|
||||
if (pqDevParam.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
// 新增时默认设置
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
pqDev.setId(id);
|
||||
// 比对式设备添加监测点
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(pqDevParam.getPattern()).getCode())) {
|
||||
if (ObjectUtil.isNotEmpty(pqDevParam.getMonitorList())) {
|
||||
pqMonitorService.addPqMonitorByDevId(id, pqDevParam.getMonitorList());
|
||||
}
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
|
||||
this.checkRepeat(updateParam, true);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(updateParam, pqDev);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
// 比对式设备修改监测点
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
|
||||
if (ObjectUtil.isNotEmpty(updateParam.getMonitorList())) {
|
||||
pqMonitorService.updatePqMonitorByDevId(updateParam.getId(), updateParam.getMonitorList());
|
||||
}
|
||||
}
|
||||
return this.updateById(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deletePqDev(PqDevParam.DeleteParam param) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(param.getPattern()).getCode())) {
|
||||
for (String id : param.getIds()) {
|
||||
if (ObjectUtils.isEmpty(pqMonitorService.listPqMonitorByDevId(id))) {
|
||||
throw new BusinessException(DevResponseEnum.PQ_DEV_HAS_MONITOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(param.getIds())) {
|
||||
MPJLambdaWrapper<PqDev> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(PqDev.class)
|
||||
.selectAs("t1.Name", PqDev::getPlanId)
|
||||
.leftJoin("ad_plan t1 on t1.Id = t.Plan_Id")
|
||||
.in(PqDev::getId, param.getIds())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<PqDev> devList = this.baseMapper.selectJoinList(PqDev.class, queryWrapper);
|
||||
Map<String, List<PqDev>> collect = devList.stream().filter(x -> StrUtil.isNotBlank(x.getPlanId())).collect(Collectors.groupingBy(PqDev::getPlanId));
|
||||
StringBuffer str;
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
str = new StringBuffer();
|
||||
str.append("&&");
|
||||
collect.forEach((k, v) -> {
|
||||
str.append(k + ": ");
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
if (i == v.size() - 1) {
|
||||
str.append(v.get(i).getName());
|
||||
} else {
|
||||
str.append(v.get(i).getName() + ",");
|
||||
}
|
||||
}
|
||||
str.append(" &&");
|
||||
});
|
||||
} else {
|
||||
str = null;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(str)) {
|
||||
throw new BusinessException(DevResponseEnum.DEVICE_DELETE, str.toString());
|
||||
}
|
||||
return this.lambdaUpdate().set(PqDev::getState, DataStateEnum.DELETED.getCode()).in(PqDev::getId, param.getIds()).update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result) {
|
||||
return this.lambdaUpdate().set(PqDev::getTimeCheckResult, result.getValue()).in(PqDev::getId, ids).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotNull(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
|
||||
for (int i = 0; i < pqDevs.size(); i++) {
|
||||
List<PqMonitorExcel.ExportData> monitorExportList = BeanUtil.copyToList(pqMonitorService.listPqMonitorByDevId(pqDevs.get(i).getId()), PqMonitorExcel.ExportData.class);
|
||||
monitorExportList.forEach(monitor -> {
|
||||
monitor.setPtType(dictDataService.getDictDataById(monitor.getPtType()).getName());
|
||||
});
|
||||
pqDevExcels.get(i).setMonitorList(monitorExportList);
|
||||
}
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("被检设备模板.xlsx", PqDevExcel.ContrastImportData.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void importContrastData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
List<PqDev> devList = new ArrayList<>();
|
||||
List<PqMonitor> monitorList = new ArrayList<>();
|
||||
String patternId = dictDataService.getDictDataByName(PatternEnum.CONTRAST.getMsg()).getId();
|
||||
pqDevExcelList.forEach(pqDevExcel -> {
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevExcel, pqDev);
|
||||
pqDev.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
pqDev.setPattern(patternId);
|
||||
// pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
// pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
// pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
// pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
devList.add(pqDev);
|
||||
|
||||
// 新增与被检设备绑定的监测点
|
||||
List<PqMonitor> monitors = pqDevExcel.getMonitorList().stream()
|
||||
.map(monitor -> {
|
||||
PqMonitor monitorPo = new PqMonitor();
|
||||
BeanUtil.copyProperties(monitor, monitorPo);
|
||||
monitorPo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
monitorPo.setDevId(pqDev.getId());
|
||||
monitorPo.setPtType(dictDataService.getDictDataByName(monitor.getPtType()).getId());
|
||||
return monitorPo;
|
||||
}).collect(Collectors.toList());
|
||||
monitorList.addAll(monitors);
|
||||
});
|
||||
|
||||
//逆向可视化
|
||||
this.reverseVisualize(devList);
|
||||
this.saveBatch(devList);
|
||||
|
||||
pqMonitorService.saveBatch(monitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualize(pqDevList);
|
||||
this.saveBatch(pqDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listUnbound(String pattern) {
|
||||
List<PqDev> pqDevList = this.lambdaQuery()
|
||||
.eq(PqDev::getPattern, pattern)
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.isNull(PqDev::getPlanId)
|
||||
.orderByDesc(PqDev::getCreateTime)
|
||||
.orderByAsc(PqDev::getName).list();
|
||||
List<Map<String, Object>> result = pqDevList.stream().map(pqDev -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqDev.getId());
|
||||
map.put("name", pqDev.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listByPlanId(PqDevParam.QueryParam param) {
|
||||
if (StrUtil.isBlank(param.getPlanId())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PqDev> pqDevList = this.lambdaQuery()
|
||||
.eq(PqDev::getPlanId, param.getPlanId())
|
||||
.like(StrUtil.isNotBlank(param.getName()), PqDev::getName, param.getName())
|
||||
.in(ObjectUtil.isNotEmpty(param.getCheckStateList()), PqDev::getCheckState, param.getCheckStateList())
|
||||
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
|
||||
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
|
||||
.eq(ObjectUtil.isNotNull(param.getReportState()), PqDev::getReportState, param.getReportState())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc(PqDev::getCreateTime)
|
||||
.orderByAsc(PqDev::getName)
|
||||
.list();
|
||||
|
||||
return pqDevList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Integer bind(String planId, List<String> devIds) {
|
||||
//先将这个绑定的计划全部剔除掉
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, null).eq(PqDev::getPlanId, planId).update();
|
||||
//然后进行状态绑定
|
||||
if (ObjectUtil.isNotEmpty(devIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, devIds).update();
|
||||
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, devIds));
|
||||
//判断是否有处了未检的其他设备
|
||||
List<Integer> notUnchecked = list.stream().map(PqDev::getCheckState).filter(x -> !x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(notUnchecked)) {
|
||||
List<Integer> unchecked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
|
||||
//计划未检测
|
||||
if (CollUtil.isNotEmpty(unchecked)) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
}
|
||||
//计划检测中
|
||||
List<String> checking = list.stream().filter(x -> CheckStateEnum.CHECKING.getValue().equals(x.getCheckState()) ||
|
||||
CheckStateEnum.CHECKED.getValue().equals(x.getCheckState()) ||
|
||||
!DevDocumentStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
|
||||
).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
if (checking.size() == notUnchecked.size()) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
}
|
||||
//检测完成
|
||||
List<Integer> checked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.DOCUMENTED.getValue())).distinct().collect(Collectors.toList());
|
||||
if (checked.size() == notUnchecked.size()) {
|
||||
return CheckStateEnum.CHECKED.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return CheckStateEnum.UNCHECKED.getValue();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List getPieData(String planId) {
|
||||
// List<PqDev> pqDevList = this.lambdaQuery().eq(PqDev::getPlanId, planId).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
// Map<Integer, Long> checkStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckState, Collectors.counting()));
|
||||
// Map<Integer, Long> checkResultMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckResult, Collectors.counting()));
|
||||
// Map<Integer, Long> reportStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getReportState, Collectors.counting()));
|
||||
//
|
||||
// List<Map<String, Object>> checkStateData = getCheckStatePieData(checkStateMap);
|
||||
// List<Map<String, Object>> checkResultData = getCheckResultPieData(checkResultMap);
|
||||
// List<Map<String, Object>> reportStateData = getReportStatePieData(reportStateMap);
|
||||
//
|
||||
// List<List<Map<String, Object>>> result = new ArrayList<>();
|
||||
// result.add(checkStateData);
|
||||
// result.add(checkResultData);
|
||||
// result.add(reportStateData);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public PqDevVO getPqDevById(String id) {
|
||||
PqDev pqDev = this.getById(id);
|
||||
PqDevVO pqDevVO = new PqDevVO();
|
||||
BeanUtil.copyProperties(pqDev, pqDevVO);
|
||||
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
pqDevVO.setDevVolt(devType.getDevVolt());
|
||||
pqDevVO.setDevCurr(devType.getDevCurr());
|
||||
}
|
||||
|
||||
List<PqMonitor> monitorList = pqMonitorService.listPqMonitorByDevId(id);
|
||||
if (ObjectUtil.isNotEmpty(monitorList)) {
|
||||
pqDevVO.setMonitorList(monitorList);
|
||||
}
|
||||
return pqDevVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listUnchecked() {
|
||||
return this.lambdaQuery()
|
||||
.eq(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqDev::getCreateTime).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (StrUtil.isNotBlank(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(EncryptionUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(EncryptionUtil.decoderString(1, pqDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reverseVisualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
// if (StrUtil.isNotBlank(pqDev.getPattern())) {
|
||||
// DictData dictData = dictDataService.getDictDataByName(pqDev.getPattern());
|
||||
// if (ObjectUtil.isNotNull(dictData)) {
|
||||
// pqDev.setPattern(dictData.getId());
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询条件wrapper
|
||||
*
|
||||
* @param queryParam 查询条件
|
||||
* @return
|
||||
*/
|
||||
private Wrapper getQueryWrapper(PqDevParam.QueryParam queryParam) {
|
||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(queryParam.getName()), "pq_dev.name", queryParam.getName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getPattern()), "pq_dev.pattern", queryParam.getPattern())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "pq_dev.manufacturer", queryParam.getManufacturer())
|
||||
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.Create_Date", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc("pq_dev.Create_Time")
|
||||
.orderByAsc("pq_dev.name");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PreDetection> getDevInfo(List<String> devIds) {
|
||||
List<PreDetection> preDetections = this.baseMapper.selectDevInfo(devIds);
|
||||
if (devIds.size() != preDetections.size()) {
|
||||
throw new BusinessException(DevResponseEnum.DEVICE_DIS_ERROR);
|
||||
}
|
||||
|
||||
for (PreDetection preDetection : preDetections) {
|
||||
List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||
if (CollUtil.isEmpty(monitorList)) {
|
||||
PreDetection.MonitorListDTO monitorListDTO;
|
||||
for (int i = 1; i <= preDetection.getDevChns(); i++) {
|
||||
monitorListDTO = new PreDetection.MonitorListDTO();
|
||||
monitorListDTO.setLineId(preDetection.getDevIP() + "_" + i);
|
||||
monitorListDTO.setLine(i);
|
||||
monitorListDTO.setPt(1);
|
||||
monitorListDTO.setCt(1);
|
||||
monitorList.add(monitorListDTO);
|
||||
}
|
||||
preDetection.setMonitorList(monitorList);
|
||||
}
|
||||
}
|
||||
return preDetections;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
public boolean documented(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
for (String id : ids) {
|
||||
// 只有检测完成的设备才可以进行归档
|
||||
PqDev pqDev = this.getById(id);
|
||||
if (ObjectUtil.isNotNull(pqDev)) {
|
||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_REPORT);
|
||||
}
|
||||
boolean update = this.lambdaUpdate()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
|
||||
.eq(PqDev::getId, id)
|
||||
.update();
|
||||
if (update) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateResult(List<String> ids, List<String> valueType, String code) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
SysTestConfig config = sysTestConfigService.getOneConfig();
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
|
||||
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, ids));
|
||||
for (PqDev pqDev : list) {
|
||||
if (result.containsKey(pqDev.getId())) {
|
||||
Integer checkState;
|
||||
if (pqDev.getReCheckNum() >= config.getMaxTime()) {
|
||||
// 装置报告生成 todo...
|
||||
this.baseMapper.updateReportState(pqDev.getId());
|
||||
// 装置归档
|
||||
checkState = CheckStateEnum.DOCUMENTED.getValue();
|
||||
} else {
|
||||
checkState = CheckStateEnum.CHECKED.getValue();
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getReCheckNum, pqDev.getReCheckNum() + 1)
|
||||
.set(PqDev::getCheckState, checkState)
|
||||
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
|
||||
.set(PqDev::getCheckTime, LocalDateTime.now())
|
||||
.set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue())
|
||||
.eq(PqDev::getId, pqDev.getId()));
|
||||
|
||||
if (pqDev.getCheckState().equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<PqDev> pqDevList = this.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(pqDevList)) {
|
||||
Set<Integer> set = pqDevList.stream().map(PqDev::getCheckResult).collect(Collectors.toSet());
|
||||
if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
|
||||
this.baseMapper.updatePlanCheckResult(pqDev.getPlanId(), CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) {
|
||||
this.baseMapper.updatePlanCheckResult(pqDev.getPlanId(), CheckResultEnum.UNCHECKED.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckResult(pqDev.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
||||
}
|
||||
|
||||
// set = pqDevList.stream().map(PqDev::getCheckState).collect(Collectors.toSet());
|
||||
// if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||
// this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.UNCHECKED.getValue());
|
||||
// } else {
|
||||
// this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.CHECKED.getValue());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePqDevReportState(String devId, int reportState) {
|
||||
LambdaUpdateWrapper<PqDev> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(PqDev::getId, devId)
|
||||
.set(PqDev::getReportState, reportState);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countUnReportDev(String planId) {
|
||||
// 查询该计划下所有设备的检测状态,是否有未生成的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, planId)
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportCNDev(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
List<CNDevExcel> pqDevExcels = null;
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualizeCNDev(pqDevs);
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadCNDevTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId) {
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeCNDev(oldDevList);
|
||||
|
||||
List<PqDev> newDevList = new ArrayList<>();
|
||||
PqDevParam param = new PqDevParam.UpdateParam();
|
||||
oldDevList.forEach(pqDev -> {
|
||||
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
if (name.contains("-")) {
|
||||
String[] split = name.split("-");
|
||||
if (split.length == 2) {
|
||||
long start = Long.parseLong(split[0]);
|
||||
long end = Long.parseLong(split[1]);
|
||||
// 避免起始大于结束
|
||||
if (start > end) {
|
||||
long temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
for (long i = start; i <= end; i++) {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
|
||||
param.setName(dev.getName());
|
||||
param.setCreateId(dev.getName());
|
||||
param.setDevType(dev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(d -> d.getName().equals(dev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
}
|
||||
} else {
|
||||
|
||||
param.setName(pqDev.getName());
|
||||
param.setCreateId(pqDev.getCreateId());
|
||||
param.setDevType(pqDev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.saveBatch(newDevList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
* @param map 检测状态分组map
|
||||
* @return 检测状态饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getCheckStatePieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (CheckStateEnum e : CheckStateEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取检测结果饼状图数据
|
||||
*
|
||||
* @param map 检测结果分组map
|
||||
* @return 检测结果饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getCheckResultPieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (CheckResultEnum e : CheckResultEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取报告状态饼状图数据
|
||||
*
|
||||
* @param map 报告状态分组map
|
||||
* @return 报告状态饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getReportStatePieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (DevReportStateEnum e : DevReportStateEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 检查设备是否重复
|
||||
*
|
||||
* @param param 设备参数
|
||||
* @param isExcludeSelf 是否排除自己
|
||||
*/
|
||||
private void checkRepeat(PqDevParam param, boolean isExcludeSelf) {
|
||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper
|
||||
.eq("state", DataStateEnum.ENABLE.getCode())
|
||||
.eq("Dev_Type", param.getDevType())
|
||||
.and(q -> q.eq("name", param.getName()).or()
|
||||
.eq("Create_Id", param.getCreateId())); //设备序列号重复
|
||||
// .eq("pattern", param.getPattern())
|
||||
// .eq("manufacturer", param.getManufacturer())
|
||||
// .eq("Dev_Type", param.getDevType()).or()
|
||||
if (isExcludeSelf) {
|
||||
if (param instanceof PqDevParam.UpdateParam) {
|
||||
queryWrapper.ne("id", ((PqDevParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(DevResponseEnum.PQ_DEV_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<PullDown> getCNDevPullDownList() {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
// 预投计划
|
||||
List<DictData> dictDataList = null;
|
||||
PullDown pullDown = null;
|
||||
|
||||
DictType dictType = dictTypeService.getByCode("Preinvestment_Plan");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(0);
|
||||
pullDown.setLastCol(0);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 设备类型
|
||||
List<DevType> devTypeList = devTypeService.listAll();
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(2);
|
||||
pullDown.setLastCol(2);
|
||||
pullDown.setStrings(devTypeList.stream().map(DevType::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
|
||||
// 通讯协议
|
||||
dictType = dictTypeService.getByCode("Protocol");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(3);
|
||||
pullDown.setLastCol(3);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 是否加密
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(4);
|
||||
pullDown.setLastCol(4);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
|
||||
// 是否支持系数校准
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
private void visualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
// pqDev.setIcdId(devType.getIcd());
|
||||
// pqDev.setDevVolt(devType.getDevVolt());
|
||||
// pqDev.setDevCurr(devType.getDevCurr());
|
||||
// pqDev.setDevChns(devType.getDevChns());
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.controller;
|
||||
package com.njcn.gather.err.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -7,10 +7,10 @@ import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.err.mapper;
|
||||
package com.njcn.gather.err.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.err.mapper;
|
||||
package com.njcn.gather.err.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.err.mapper.PqErrSysDtlsMapper">
|
||||
<mapper namespace="com.njcn.gather.err.mapper.PqErrSysDtlsMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.script.mapper.PqScriptDtlsMapper">
|
||||
<mapper namespace="com.njcn.gather.err.mapper.PqErrSysMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.pojo.param;
|
||||
package com.njcn.gather.err.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.pojo.param;
|
||||
package com.njcn.gather.err.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.pojo.po;
|
||||
package com.njcn.gather.err.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.pojo.po;
|
||||
package com.njcn.gather.err.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -46,7 +46,7 @@ public class PqErrSysDtls implements Serializable {
|
||||
private Double startValue;
|
||||
|
||||
/**
|
||||
* 是否包含起始值
|
||||
* 是否包含起始值(0> 1>= 2无)
|
||||
*/
|
||||
private Integer startFlag;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.gather.err.pojo.vo;
|
||||
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Data
|
||||
public class ErrDtlsCheckDataVO implements Serializable {
|
||||
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
private String checkDataId;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
*检测指标类型code
|
||||
*/
|
||||
private String valueTypeCode;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Double value;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 误差体系
|
||||
*/
|
||||
private List<PqErrSysDtls> errSysDtls;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.pojo.vo;
|
||||
package com.njcn.gather.err.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.njcn.gather.device.err.service;
|
||||
package com.njcn.gather.err.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,4 +50,11 @@ public interface IPqErrSysDtlsService extends IService<PqErrSysDtls> {
|
||||
* @return
|
||||
*/
|
||||
List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param);
|
||||
|
||||
/**
|
||||
* 根据查询误差体系
|
||||
* @param param 误差体系id
|
||||
* @return
|
||||
*/
|
||||
List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param);
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.njcn.gather.device.err.service;
|
||||
package com.njcn.gather.err.service;
|
||||
|
||||
import cn.hutool.core.date.StopWatch;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1,15 +1,18 @@
|
||||
package com.njcn.gather.device.err.service.impl;
|
||||
package com.njcn.gather.err.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.gather.device.err.mapper.PqErrSysDtlsMapper;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.err.mapper.PqErrSysDtlsMapper;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
||||
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -17,9 +20,8 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -86,4 +88,40 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
|
||||
List<ErrDtlsCheckDataVO> info=new ArrayList<>();
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIndex(param.getIndex());
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
|
||||
|
||||
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList());
|
||||
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
|
||||
if(CollUtil.isNotEmpty(valueType)){
|
||||
List<PqErrSysDtls> errSysDtls = this.list(new MPJLambdaWrapper<PqErrSysDtls>().selectAll(PqErrSysDtls.class)
|
||||
.selectAll(PqErrSysDtls.class)
|
||||
.selectAs(DictTree::getCode, PqErrSysDtls::getScriptCode)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType)
|
||||
.eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
||||
.in(PqErrSysDtls::getScriptType, valueType)
|
||||
);
|
||||
errMap= errSysDtls.stream().collect(Collectors.groupingBy(PqErrSysDtls::getScriptType));
|
||||
}
|
||||
ErrDtlsCheckDataVO dataVO;
|
||||
for (PqScriptCheckData script : list) {
|
||||
dataVO=new ErrDtlsCheckDataVO();
|
||||
dataVO.setCheckDataId(script.getScriptId());
|
||||
dataVO.setValueTypeCode(script.getValueTypeCode());
|
||||
dataVO.setValueType(script.getValueType());
|
||||
dataVO.setValue(script.getValue());
|
||||
dataVO.setPhase(script.getPhase());
|
||||
if(errMap.containsKey(script.getValueType())){
|
||||
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
|
||||
}
|
||||
info.add(dataVO);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.err.service.impl;
|
||||
package com.njcn.gather.err.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -7,13 +7,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.device.err.mapper.PqErrSysMapper;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.err.mapper.PqErrSysMapper;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
@@ -50,7 +50,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.between(ObjectUtil.isNotEmpty(param.getStandardTime()), "pq_err_sys.Standard_Time", param.getStandardTime() + "-01-01", param.getStandardTime() + "-12-31").eq(ObjectUtil.isNotEmpty(param.getDevLevel()), "pq_err_sys.Dev_Level", param.getDevLevel());
|
||||
}
|
||||
queryWrapper.eq("pq_err_sys.state", DataStateEnum.ENABLE.getCode());
|
||||
queryWrapper.eq("pq_err_sys.state", DataStateEnum.ENABLE.getCode()).orderByDesc("pq_err_sys.Create_Time");
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.njcn.gather.icd.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caozehui
|
||||
* @date 2025-02-10
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="icd管理")
|
||||
@RestController
|
||||
@RequestMapping("/icd")
|
||||
@RequiredArgsConstructor
|
||||
public class PqIcdPathController extends BaseController{
|
||||
private final IPqIcdPathService pqIcdPathService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listAll")
|
||||
@ApiOperation("获取所有icd")
|
||||
public HttpResult<List<PqIcdPath>> listAll() {
|
||||
String methodDescribe = getMethodDescribe("listAll");
|
||||
List<PqIcdPath> result = pqIcdPathService.listAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询icd")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqIcdPath>> list(@RequestBody @Validated PqIcdPathParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<PqIcdPath> result = pqIcdPathService.listIcd(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated PqIcdPathParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
|
||||
boolean result = pqIcdPathService.addIcd(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
|
||||
public HttpResult<String> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
|
||||
boolean result = pqIcdPathService.updateIcd(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除icd")
|
||||
@ApiImplicitParam(name = "ids", value = "icd的id列表", required = true)
|
||||
public HttpResult<String> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
boolean result = pqIcdPathService.deleteIcd(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.icd.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-02-10
|
||||
*/
|
||||
public interface PqIcdPathMapper extends MPJBaseMapper<PqIcdPath> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.icd.mapper.PqIcdPathMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.gather.icd.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-02-11
|
||||
*/
|
||||
public interface PqIcdPathValidMessage {
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||
String NAME_NOT_BLANK = "名称不能为空";
|
||||
String PATH_NOT_BLANK = "icd存储路径不能为空";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.icd.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-02-11
|
||||
*/
|
||||
@Getter
|
||||
public enum IcdPathResponseEnum {
|
||||
|
||||
ICD_PATH_NAME_REPEAT("A004007", "icd名称重复");
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
IcdPathResponseEnum(String code, String message) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.gather.icd.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.icd.pojo.constant.PqIcdPathValidMessage;
|
||||
import com.njcn.gather.type.pojo.constant.DevTypeValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-02-11
|
||||
*/
|
||||
@Data
|
||||
public class PqIcdPathParam {
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = PqIcdPathValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "存储路径", required = true)
|
||||
@NotBlank(message = PqIcdPathValidMessage.PATH_NOT_BLANK)
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
private String name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新参数
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqIcdPathParam {
|
||||
@ApiModelProperty(value = "id", required = true)
|
||||
@NotBlank(message = PqIcdPathValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = PqIcdPathValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.gather.icd.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_icd_path")
|
||||
public class PqIcdPath extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -93625299788915474L;
|
||||
|
||||
/**
|
||||
* icdID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* icd名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* icd存储地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.gather.icd.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-02-10
|
||||
*/
|
||||
public interface IPqIcdPathService extends IService<PqIcdPath> {
|
||||
|
||||
/**
|
||||
* 获取所有Icd
|
||||
*
|
||||
* @return 所有Icd
|
||||
*/
|
||||
List<PqIcdPath> listAll();
|
||||
|
||||
/**
|
||||
* 分页获取Icd
|
||||
*
|
||||
* @param param 分页查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 新增Icd
|
||||
*
|
||||
* @param param 新增Icd参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addIcd(PqIcdPathParam param);
|
||||
|
||||
/**
|
||||
* 修改Icd
|
||||
*
|
||||
* @param param 修改Icd参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updateIcd(PqIcdPathParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 批量删除Icd
|
||||
*
|
||||
* @param ids Icd id列表
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deleteIcd(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.njcn.gather.icd.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||
import com.njcn.gather.icd.pojo.enums.IcdPathResponseEnum;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-02-10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath> implements IPqIcdPathService {
|
||||
|
||||
@Override
|
||||
public List<PqIcdPath> listAll() {
|
||||
return this.lambdaQuery().eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param) {
|
||||
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode())
|
||||
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
||||
.orderByDesc(PqIcdPath::getCreateTime);
|
||||
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addIcd(PqIcdPathParam param) {
|
||||
this.checkRepeat(param, false);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
return this.updateById(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteIcd(List<String> ids) {
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
private void checkRepeat(PqIcdPathParam param, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PqIcdPath::getName, param.getName())
|
||||
.eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode());
|
||||
if (isExcludeSelf) {
|
||||
if (param instanceof PqIcdPathParam.UpdateParam) {
|
||||
wrapper.ne(PqIcdPath::getId, ((PqIcdPathParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(IcdPathResponseEnum.ICD_PATH_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.gather.device.monitor.controller;
|
||||
package com.njcn.gather.monitor.controller;
|
||||
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.njcn.gather.device.monitor.mapper;
|
||||
package com.njcn.gather.monitor.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,7 +16,7 @@ public interface PqMonitorMapper extends MPJBaseMapper<PqMonitor> {
|
||||
/**
|
||||
* 根据终端id获取监测点集合
|
||||
* @param devId
|
||||
* @return: java.util.List<com.njcn.gather.device.device.pojo.vo.PreDetection.MonitorListDTO>
|
||||
* @return: java.util.List<com.njcn.gather.device.pojo.vo.PreDetection.MonitorListDTO>
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/12 13:15
|
||||
*/
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.monitor.mapper.PqMonitorMapper">
|
||||
<mapper namespace="com.njcn.gather.monitor.mapper.PqMonitorMapper">
|
||||
|
||||
<select id="selectMonitorInfo"
|
||||
resultType="com.njcn.gather.device.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
SELECT
|
||||
Id as lineId,
|
||||
Num as line,
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.monitor.pojo.param;
|
||||
package com.njcn.gather.monitor.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.monitor.pojo.po;
|
||||
package com.njcn.gather.monitor.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.monitor.pojo.vo;
|
||||
package com.njcn.gather.monitor.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.njcn.gather.device.monitor.service;
|
||||
package com.njcn.gather.monitor.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -1,26 +1,20 @@
|
||||
package com.njcn.gather.device.monitor.service.impl;
|
||||
package com.njcn.gather.monitor.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -13,14 +13,12 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -67,7 +65,7 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测计划")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测计划", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "检测计划", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated AdPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.njcn.gather.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanSourceMapper">
|
||||
|
||||
|
||||
<select id="selectPqSourceByPlanId" resultType="com.njcn.gather.device.source.pojo.po.PqSource">
|
||||
<select id="selectPqSourceByPlanId" resultType="com.njcn.gather.source.pojo.po.PqSource">
|
||||
SELECT pq_source.*
|
||||
FROM pq_source,
|
||||
ad_plan_source
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
package com.njcn.gather.plan.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.gather.plan.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-01-16
|
||||
*/
|
||||
@Getter
|
||||
public enum PlanResponseEnum {
|
||||
PLAN_REPEATED("A003014", "当前模式下,该计划已存在"),
|
||||
PLAN_NOT_EXIST("A003015", "该计划不存在"),
|
||||
SCRIPT_RELATE_DICT_NOT_EXIST("A003016","脚本关联的字典不存在");
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
|
||||
PlanResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class AdPlanExcel {
|
||||
// private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<AdPlanExcel.BoundExportData> devices;
|
||||
private List<BoundExportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -91,7 +91,7 @@ public class AdPlanExcel {
|
||||
private String result;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<AdPlanExcel.BoundImportData> devices;
|
||||
private List<BoundImportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -92,4 +92,9 @@ public class AdPlanVO {
|
||||
* 自动生成,用于生成数据表后缀
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
}
|
||||
|
||||
@@ -92,4 +92,22 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, String>> getBigTestItem(String planId);
|
||||
|
||||
/**
|
||||
* 修改计划状态
|
||||
* @param planId
|
||||
* @param devIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateTestState(String planId,List<String> devIds);
|
||||
|
||||
/**
|
||||
* 数据状态回退
|
||||
* @param planId
|
||||
* @param devIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateBackTestState(String planId,List<String> devIds);
|
||||
|
||||
void finishPlan(String planId);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.njcn.gather.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
package com.njcn.gather.plan.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.device.device.pojo.enums.TimeCheckResultEnum;
|
||||
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.device.source.service.IPqSourceService;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanResponseEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.service.IPqScriptService;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.storage.service.TableGenService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
@@ -59,6 +65,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private final IPqSourceService pqSourceService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final TableGenService tableGenService;
|
||||
|
||||
@Override
|
||||
public Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
||||
@@ -67,6 +74,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<AdPlanVO> adPlanVOList = adPlans.stream().map(adPlan -> {
|
||||
AdPlanVO adPlanVO = new AdPlanVO();
|
||||
BeanUtil.copyProperties(adPlan, adPlanVO);
|
||||
adPlanVO.setCreateTime(adPlanVO.getCreateTime().replace("T", " "));
|
||||
adPlanVO.setDatasourceIds(Arrays.asList(adPlan.getDatasourceId().split(StrUtil.COMMA)));
|
||||
return adPlanVO;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -90,6 +98,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addAdPlan(AdPlanParam param) {
|
||||
this.checkRepeat(param, false);
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
|
||||
@@ -103,9 +112,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
// todo code 生成
|
||||
// 日期生成 MMdd
|
||||
//String dateStr = DateFormatUtils.format(new Date(), "MMdd");
|
||||
adPlan.setCode(this.generateCode());
|
||||
|
||||
// 新增检测计划、检测源关联
|
||||
@@ -118,12 +124,17 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
pqDevService.updatePqDevTimeCheckResult(param.getDevIds(), TimeCheckResultEnum.UNKNOWN);
|
||||
}
|
||||
|
||||
return this.save(adPlan);
|
||||
//新增相关计划
|
||||
this.save(adPlan);
|
||||
tableGenService.deleteTable(Arrays.asList(adPlan.getCode().toString()));
|
||||
tableGenService.genAdNonHarmonicTable(adPlan.getCode().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
|
||||
@@ -132,7 +143,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
|
||||
pqDevService.bind(param.getId(), param.getDevIds());
|
||||
adPlan.setTestState(pqDevService.bind(param.getId(), param.getDevIds()));
|
||||
|
||||
return this.updateById(adPlan);
|
||||
}
|
||||
@@ -150,6 +161,10 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 删除检测计划、检测源关联
|
||||
adPlanSourceService.deleteAdPlanSourceByPlanIds(ids);
|
||||
|
||||
// 删除相关检测表格
|
||||
List<String> codeList = this.listByIds(ids).stream().map(plan->String.valueOf(plan.getCode())).collect(Collectors.toList());
|
||||
tableGenService.deleteTable(codeList);
|
||||
|
||||
return this.lambdaUpdate().in(AdPlan::getId, ids).set(AdPlan::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@@ -269,9 +284,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
|
||||
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern()).eq(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName()).eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState()).eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState()).eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName())
|
||||
.eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState())
|
||||
.eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState())
|
||||
.eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
|
||||
}
|
||||
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderBy(true, true, "Create_Time");
|
||||
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderByDesc("Create_Time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@@ -304,6 +323,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
public List<Map<String, String>> getBigTestItem(String planId) {
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
AdPlan adPlan = this.getById(planId);
|
||||
if (ObjectUtil.isNull(adPlan)) {
|
||||
throw new BusinessException(PlanResponseEnum.PLAN_NOT_EXIST);
|
||||
}
|
||||
String scriptId = adPlan.getScriptId();
|
||||
|
||||
List<PqScriptDtls> scriptDtlsList = pqScriptDtlsService.listPqScriptDtlByScriptId(scriptId);
|
||||
@@ -316,14 +338,65 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("id", key);
|
||||
DictTree dictTree = dictTreeService.getById(key);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
map.put("code", dictTree.getCode());
|
||||
map.put("scriptName", dictTree.getName());
|
||||
} else {
|
||||
throw new BusinessException(PlanResponseEnum.SCRIPT_RELATE_DICT_NOT_EXIST);
|
||||
}
|
||||
result.add(map);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTestState(String planId, List<String> devIds) {
|
||||
if (CollUtil.isNotEmpty(devIds)) {
|
||||
pqDevService.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.CHECKING.getValue())
|
||||
.in(PqDev::getId, devIds));
|
||||
return this.update(new LambdaUpdateWrapper<AdPlan>()
|
||||
.set(AdPlan::getTestState, CheckStateEnum.CHECKING.getValue())
|
||||
.eq(AdPlan::getId, planId));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateBackTestState(String planId, List<String> devIds) {
|
||||
//当前如果第二次进行测试,则需要将判断之前状态是否不是非检测状态
|
||||
List<PqDev> devList = pqDevService.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, devIds));
|
||||
if (CollUtil.isNotEmpty(devList)) {
|
||||
for (PqDev pqDev : devList) {
|
||||
if (!pqDev.getCheckResult().equals(CheckResultEnum.UNCHECKED.getValue())) {
|
||||
pqDevService.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.CHECKED.getValue())
|
||||
.in(PqDev::getId, devIds));
|
||||
} else {
|
||||
pqDevService.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue())
|
||||
.in(PqDev::getId, devIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getPlanId, planId));
|
||||
List<PqDev> collect = list.stream().filter(x -> !x.getCheckState().equals(CheckStateEnum.UNCHECKED.getValue())).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
return this.update(new LambdaUpdateWrapper<AdPlan>()
|
||||
.set(AdPlan::getTestState, CheckStateEnum.UNCHECKED.getValue())
|
||||
.eq(AdPlan::getId, planId));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishPlan(String planId) {
|
||||
this.lambdaUpdate().eq(AdPlan::getId, planId)
|
||||
.set(AdPlan::getTestState, CheckStateEnum.CHECKED.getValue());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 逆向可视化
|
||||
*
|
||||
@@ -354,6 +427,32 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
* @return
|
||||
*/
|
||||
private Integer generateCode() {
|
||||
return this.count() + 1;
|
||||
AdPlan plan = this.lambdaQuery().select(AdPlan::getCode).orderByDesc(AdPlan::getCode).last("LIMIT 1").one();
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
return plan.getCode() + 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查计划是否重复
|
||||
*
|
||||
* @param param 计划参数
|
||||
* @param isExcludeSelf 是否排除自己
|
||||
*/
|
||||
private void checkRepeat(AdPlanParam param, boolean isExcludeSelf) {
|
||||
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("state", DataStateEnum.ENABLE.getCode())
|
||||
.eq("Name", param.getName())
|
||||
.eq("Pattern", param.getPattern());
|
||||
if (isExcludeSelf) {
|
||||
if (param instanceof AdPlanParam.UpdateParam) {
|
||||
queryWrapper.ne("id", ((AdPlanParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PlanResponseEnum.PLAN_REPEATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.plan.mapper.AdPlanSourceMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.njcn.gather.report.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
import com.njcn.gather.report.service.IReportService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/1/9 14:02
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "报表管理")
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
@RequiredArgsConstructor
|
||||
public class ReportController extends BaseController {
|
||||
|
||||
private final IReportService reportService;
|
||||
|
||||
/**
|
||||
* 此方法临时的,给楼下使用,实际需要优化
|
||||
* 1、不同的设备需要不同的模板;
|
||||
* 2、数据页的内容暂时是固定的,后期可能是动态的;
|
||||
*/
|
||||
@OperateInfo
|
||||
@PostMapping("/generateReport")
|
||||
@ApiOperation("生成测试报告")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Object> generateReport(@RequestBody DevReportParam devReportParam) {
|
||||
String methodDescribe = getMethodDescribe("generateReport");
|
||||
LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam);
|
||||
reportService.generateReport(devReportParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载报告
|
||||
*/
|
||||
@OperateInfo
|
||||
@PostMapping("/downloadReport")
|
||||
@ApiOperation("下载测试报告")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public void downloadReport(@RequestBody DevReportParam devReportParam, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("downloadReport");
|
||||
LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam);
|
||||
reportService.downloadReport(devReportParam,response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.gather.report.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/1/9 20:55
|
||||
*/
|
||||
@Data
|
||||
public class DevReportParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 计划ID
|
||||
*/
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 被检设备ID
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.gather.report.service;
|
||||
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/1/9 20:59
|
||||
*/
|
||||
public interface IReportService {
|
||||
void generateReport(DevReportParam devReportParam);
|
||||
|
||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||
}
|
||||
@@ -0,0 +1,557 @@
|
||||
package com.njcn.gather.report.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
import com.njcn.gather.report.service.IReportService;
|
||||
import com.njcn.gather.report.utils.WordUtil;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/1/9 21:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReportServiceImpl implements IReportService {
|
||||
|
||||
@Value("${report.template:D:\\template\\}")
|
||||
private String templatePath;
|
||||
|
||||
@Value("${report.reportDir:D:\\report}")
|
||||
private String reportPath;
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
|
||||
private final AdNonHarmonicService adNonHarmonicService;
|
||||
|
||||
private final AdHarmonicService adHarmonicService;
|
||||
|
||||
private final IDevTypeService devTypeService;
|
||||
|
||||
|
||||
@Override
|
||||
public void generateReport(DevReportParam devReportParam) {
|
||||
// 读取模板文件
|
||||
ClassPathResource resource = new ClassPathResource("/model/BaseModel.docx");
|
||||
try (InputStream inputStream = resource.getInputStream()) {
|
||||
// 加载Word文档
|
||||
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
|
||||
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
||||
if (Objects.isNull(pqDevVO)) {
|
||||
throw new BusinessException("请检查装置是否存在!");
|
||||
}
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException("设备类型丢失,请联系管理员!");
|
||||
}
|
||||
// 处理基础模版中的信息
|
||||
dealBaseModel(baseModelDocument, pqDevVO);
|
||||
// 处理数据页中的信息
|
||||
dealDataModel(baseModelDocument, devReportParam, pqDevVO);
|
||||
// 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx
|
||||
// 最终文件输出的路径
|
||||
String dirPath = reportPath.concat(File.separator).concat(devType.getName());
|
||||
ensureDirectoryExists(dirPath); // 确保目录存在
|
||||
FileOutputStream out = new FileOutputStream(dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(".docx"));
|
||||
// 4. 保存新的Word文档
|
||||
try {
|
||||
baseModelDocument.write(out);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException("生成报告文件失败");
|
||||
}
|
||||
out.close();
|
||||
|
||||
System.out.println("报告生成成功!");
|
||||
|
||||
// 将改设备的报告生成状态调整为已生成
|
||||
iPqDevService.updatePqDevReportState(devReportParam.getDevId(), DevReportStateEnum.GENERATED.getValue());
|
||||
|
||||
// 判断该计划下是否所有设备报告已生成,如果已生成则将计划的报告状态给为已生成
|
||||
int count = iPqDevService.countUnReportDev(devReportParam.getPlanId());
|
||||
LambdaUpdateWrapper<AdPlan> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(AdPlan::getId, devReportParam.getPlanId());
|
||||
if (count == 0) {
|
||||
updateWrapper.set(AdPlan::getReportState, PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getValue());
|
||||
} else {
|
||||
updateWrapper.set(AdPlan::getReportState, PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||
}
|
||||
adPlanService.update(updateWrapper);
|
||||
} catch (Exception e) {
|
||||
log.error("生成报告文件失败", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadReport(DevReportParam devReportParam, HttpServletResponse response) {
|
||||
PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId());
|
||||
if (Objects.isNull(pqDevVO)) {
|
||||
throw new BusinessException("请检查装置是否存在!");
|
||||
}
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException("设备类型丢失,请联系管理员!");
|
||||
}
|
||||
// 找到该文件的路径
|
||||
String filePath = reportPath.concat(File.separator).concat(devType.getName()).concat(File.separator).concat(pqDevVO.getCreateId()).concat(".docx");
|
||||
File reportFile = new File(filePath);
|
||||
if (!reportFile.exists()) {
|
||||
// 如果文件不存在,则将改设备的报告生成状态调整为未生成
|
||||
iPqDevService.updatePqDevReportState(devReportParam.getDevId(), 0);
|
||||
throw new BusinessException("报告文件不存在,请重新生成报告!");
|
||||
} else {
|
||||
try (FileInputStream fis = new FileInputStream(reportFile);
|
||||
OutputStream os = response.getOutputStream()) {
|
||||
|
||||
// 设置响应头
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
String fileName = pqDevVO.getCreateId() + ".docx";
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
|
||||
// 将文件内容写入响应输出流
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
}
|
||||
// 刷新输出流
|
||||
os.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理基础模版中的信息,非数据页报告
|
||||
*
|
||||
* @param baseModelDocument 模板文件
|
||||
*/
|
||||
private void dealBaseModel(XWPFDocument baseModelDocument, PqDevVO pqDevVO) {
|
||||
// 首先获取非数据页中需要的信息
|
||||
Map<String, String> baseModelMap = new HashMap<>(16);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
baseModelMap.put("${devType}", devType.getName());
|
||||
// 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死
|
||||
baseModelMap.put("${userName}", "管理员");
|
||||
// 调试日期
|
||||
if (pqDevVO.getCheckTime() != null) {
|
||||
baseModelMap.put("${testDate}", DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
|
||||
} else {
|
||||
baseModelMap.put("${testDate}", DateUtil.format(new Date(), DatePattern.CHINESE_DATE_PATTERN));
|
||||
}
|
||||
// 装置编码
|
||||
baseModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||
// 额定电流
|
||||
baseModelMap.put("${devCurr}", pqDevVO.getDevCurr().toString().concat("A"));
|
||||
// 额定电压
|
||||
baseModelMap.put("${devVolt}", pqDevVO.getDevVolt().toString().concat("V"));
|
||||
|
||||
// 共有多少通道参与测试
|
||||
// if (CollectionUtil.isEmpty(pqDevById.getMonitorList())) {
|
||||
// baseModelMap.put("${count}", "0");
|
||||
// } else {
|
||||
// baseModelMap.put("${count}", pqDevById.getMonitorList().size() + "");
|
||||
// }
|
||||
|
||||
baseModelMap.put("${count}", pqDevVO.getDevChns().toString());
|
||||
|
||||
// 替换模板中的信息,避免信息丢失,段落和表格均参与替换
|
||||
WordUtil.replacePlaceholdersInParagraphs(baseModelDocument, baseModelMap);
|
||||
WordUtil.replacePlaceholdersInTables(baseModelDocument, baseModelMap);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据页的信息
|
||||
*
|
||||
* @param baseModelDocument 非数据页的内容
|
||||
* @param devReportParam 查询参数
|
||||
*/
|
||||
private void dealDataModel(XWPFDocument baseModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO) throws IOException {
|
||||
AdPlan adPlan = adPlanService.getById(devReportParam.getPlanId());
|
||||
String scriptId = adPlan.getScriptId();
|
||||
Integer devChns = pqDevVO.getDevChns();
|
||||
for (int i = 1; i <= devChns; i++) {
|
||||
ClassPathResource resource = new ClassPathResource("/model/BaseDataModel.docx");
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||
|
||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||
singleNonHarmParam.setPlanCode(adPlan.getCode());
|
||||
singleNonHarmParam.setDevId(pqDevVO.getId());
|
||||
singleNonHarmParam.setChannelNo(i);
|
||||
|
||||
// 获取数据
|
||||
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||
dataModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||
dataModelMap.put("${total}", pqDevVO.getDevChns().toString());
|
||||
dataModelMap.put("${count}", i + "");
|
||||
// 区分谐波和非谐波数据
|
||||
// 谐波类
|
||||
|
||||
|
||||
// 非谐波类
|
||||
// 57V电压 电压&相角 index 不用计算了,固定为1
|
||||
// Integer testItemIndex = getTestItemIndex(scriptId, "e797c4b940389404e64fb92e4507c5f4", "Base", "VOL", 57);
|
||||
// 获取输出脚本ID
|
||||
Integer testItemIndex = 1;
|
||||
// String pqScriptCheckDataService = getPqScriptCheckDataByScriptId(scriptId,testItemIndex,1,Arrays.asList("A","B","C"));
|
||||
String pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "57Ua", "57Ub", "57Uc");
|
||||
|
||||
// 57V相角
|
||||
testItemIndex = 1;
|
||||
pqScriptCheckDataService = "e8bbfaad7a3fa343d3c46d345fb45fa3";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "57UaA", "57UbA", "57UcA");
|
||||
|
||||
// 10V电压
|
||||
testItemIndex = 2;
|
||||
pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "10Ua", "10Ub", "10Uc");
|
||||
|
||||
|
||||
// 电压偏差
|
||||
testItemIndex = 3;
|
||||
pqScriptCheckDataService = "8e221487f242c77f1eff05234580d4c5";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "DELTA_Ua", "DELTA_Ub", "DELTA_Uc");
|
||||
// 特殊处理电压偏差
|
||||
specialDealVoltage(dataModelMap, "${DELTA_Ua}");
|
||||
specialDealVoltage(dataModelMap, "${DELTA_Ub}");
|
||||
specialDealVoltage(dataModelMap, "${DELTA_Uc}");
|
||||
|
||||
// 5A 电流
|
||||
testItemIndex = 4;
|
||||
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "5Ia", "5Ib", "5Ic");
|
||||
|
||||
// 5A 电流相角
|
||||
testItemIndex = 4;
|
||||
pqScriptCheckDataService = "fdffc6b5dfdc8751b9fde9b599b8ea51";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "5IaA", "5IbA", "5IcA");
|
||||
|
||||
// 1A 电流
|
||||
testItemIndex = 5;
|
||||
pqScriptCheckDataService = "7fbadbeb9dd5ccb69d216f4f9ad60b4f";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValue(singleNonHarmParam, dataModelMap, "1Ia", "1Ib", "1Ic");
|
||||
|
||||
|
||||
// 三相电压不平衡度
|
||||
testItemIndex = 6;
|
||||
pqScriptCheckDataService = "9e9910f3627870c7fcf5846342f29d26";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueT(singleNonHarmParam, dataModelMap, "V_UNBAN");
|
||||
|
||||
|
||||
// 频率 45
|
||||
testItemIndex = 7;
|
||||
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ45");
|
||||
|
||||
|
||||
// 频率 50
|
||||
testItemIndex = 8;
|
||||
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ50");
|
||||
|
||||
|
||||
// 频率 55
|
||||
testItemIndex = 9;
|
||||
pqScriptCheckDataService = "2da2a32c0cd19fb6368b9f4c249c2b3c";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ55");
|
||||
|
||||
// 谐波电压,少了基波 todo...
|
||||
testItemIndex = 10;
|
||||
pqScriptCheckDataService = "cce92410f1902897a61f644d875f2216";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Uha", "Uhb", "Uhc", 57.74, 100);
|
||||
|
||||
// 谐波电电流,少了基波 todo...
|
||||
testItemIndex = 11;
|
||||
pqScriptCheckDataService = "3e5e384d38485ca4242152fba336de1d";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Iha", "Ihb", "Ihc", 1, 1);
|
||||
|
||||
// 间谐波电压
|
||||
testItemIndex = 12;
|
||||
pqScriptCheckDataService = "d57ea0e085ecf6c4e9f4da09b948befe";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InUa", "InUb", "InUc", 57.74, 100);
|
||||
|
||||
// 间谐波电流
|
||||
testItemIndex = 13;
|
||||
pqScriptCheckDataService = "6bc58769dcbb2f83a13ff965a20a3cf3";
|
||||
// 获取数据
|
||||
singleNonHarmParam.setAdType(pqScriptCheckDataService);
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueHarm(singleNonHarmParam, dataModelMap, "InIa", "InIb", "InIc", 1, 1);
|
||||
|
||||
|
||||
// 替换文档内容
|
||||
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
|
||||
WordUtil.replacePlaceholdersInTables(dataModelDocumentTemp, dataModelMap);
|
||||
WordUtil.appendDocument(baseModelDocument, dataModelDocumentTemp);
|
||||
}
|
||||
}
|
||||
|
||||
private void specialDealVoltage(Map<String, String> dataModelMap, String symbol) {
|
||||
String value = dataModelMap.get(symbol);
|
||||
if (Objects.nonNull(value) && !value.equals("/")) {
|
||||
Double valueDouble = Double.valueOf(value);
|
||||
double result = ((valueDouble - 57.74) / 57.74) * 100;
|
||||
dataModelMap.put(symbol, doubleRound(4, result));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充谐波Map数据
|
||||
*/
|
||||
private void fillMapValueHarm(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol, double baseValue, int percent) {
|
||||
AdHarmonicResult adHarmonicResult = adHarmonicService.getSingleResult(singleNonHarmParam);
|
||||
if (Objects.nonNull(adHarmonicResult)) {
|
||||
// 要处理 2 5 7 11 23 35 43 50
|
||||
dataModelMap.put("${" + aSymbol + "2}", devValue(adHarmonicResult.getAValue2(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "2}", devValue(adHarmonicResult.getBValue2(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "2}", devValue(adHarmonicResult.getCValue2(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "5}", devValue(adHarmonicResult.getAValue5(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "5}", devValue(adHarmonicResult.getBValue5(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "5}", devValue(adHarmonicResult.getCValue5(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "7}", devValue(adHarmonicResult.getAValue7(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "7}", devValue(adHarmonicResult.getBValue7(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "7}", devValue(adHarmonicResult.getCValue7(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "11}", devValue(adHarmonicResult.getAValue11(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "11}", devValue(adHarmonicResult.getBValue11(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "11}", devValue(adHarmonicResult.getCValue11(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "23}", devValue(adHarmonicResult.getAValue23(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "23}", devValue(adHarmonicResult.getBValue23(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "23}", devValue(adHarmonicResult.getCValue23(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "35}", devValue(adHarmonicResult.getAValue35(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "35}", devValue(adHarmonicResult.getBValue35(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "35}", devValue(adHarmonicResult.getCValue35(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "43}", devValue(adHarmonicResult.getAValue43(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "43}", devValue(adHarmonicResult.getBValue43(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "43}", devValue(adHarmonicResult.getCValue43(), baseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "50}", devValue(adHarmonicResult.getAValue50(), baseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "50}", devValue(adHarmonicResult.getBValue50(), baseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "50}", devValue(adHarmonicResult.getCValue50(), baseValue, percent));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String devValue(String dataJson, double baseValue, Integer percent) {
|
||||
DetectionData tempA = JSONUtil.toBean(dataJson, DetectionData.class);
|
||||
if (Objects.nonNull(tempA) && Objects.nonNull(tempA.getData())) {
|
||||
return doubleRound(4, (tempA.getData() / percent) * baseValue);
|
||||
}
|
||||
return "/";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 填充非谐波Map数据,ABC三相
|
||||
*/
|
||||
private void fillMapValue(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String aSymbol, String bSymbol, String cSymbol) {
|
||||
AdNonHarmonicResult adNonHarmonicResult = adNonHarmonicService.getSingleResult(singleNonHarmParam);
|
||||
if (Objects.nonNull(adNonHarmonicResult)) {
|
||||
dataModelMap.put("${".concat(aSymbol).concat("}"), devValue(adNonHarmonicResult.getAValue(), 1, 1));
|
||||
dataModelMap.put("${".concat(bSymbol).concat("}"), devValue(adNonHarmonicResult.getBValue(), 1, 1));
|
||||
dataModelMap.put("${".concat(cSymbol).concat("}"), devValue(adNonHarmonicResult.getCValue(), 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充非谐波Map数据,T相
|
||||
*/
|
||||
private void fillMapValueT(SingleNonHarmParam singleNonHarmParam, Map<String, String> dataModelMap, String tSymbol) {
|
||||
AdNonHarmonicResult adNonHarmonicResult = adNonHarmonicService.getSingleResult(singleNonHarmParam);
|
||||
if (Objects.nonNull(adNonHarmonicResult)) {
|
||||
dataModelMap.put("${".concat(tSymbol).concat("}"), devValue(adNonHarmonicResult.getTValue(), 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getPqScriptCheckDataByScriptId(String scriptId, Integer index, Integer errFlag, List<String> phase) {
|
||||
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// todo... 不参与比较的数据没有了
|
||||
queryWrapper.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.in(PqScriptCheckData::getPhase, phase)
|
||||
.eq(PqScriptCheckData::getIndex, index);
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return list.get(0).getValueType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String path = "F:\\gitea\\fusionForce\\CN_Gather\\entrance\\src\\main\\resources\\model\\BaseDataModel.docx";
|
||||
FileInputStream dataModelFis = new FileInputStream(new File(path));
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(dataModelFis);
|
||||
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||
dataModelMap.put("${CreateId}", "123");
|
||||
dataModelMap.put("${total}", "123");
|
||||
dataModelMap.put("${count}", "1");
|
||||
dataModelMap.put("${57Ua}", "123456");
|
||||
dataModelMap.put("${Uha1}", "123456");
|
||||
dataModelMap.put("${Uha2}", "123456");
|
||||
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
|
||||
WordUtil.replacePlaceholdersInTables(dataModelDocumentTemp, dataModelMap);
|
||||
//最终文件输出的路径
|
||||
FileOutputStream out = new FileOutputStream("C:\\Users\\hongawen\\Desktop\\testModel\\BaseDataModel" + DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_PATTERN) + ".docx");
|
||||
// 4. 保存新的Word文档
|
||||
try {
|
||||
dataModelDocumentTemp.write(out);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException("生成报告文件失败");
|
||||
}
|
||||
out.close();
|
||||
System.out.println("报告生成成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试小项的index
|
||||
* 注:测试项下发的ABCT的index均是一样的
|
||||
*/
|
||||
private Integer getTestItemIndex(String scriptId, String sourceScriptId, String subType, String valueType, Integer value) {
|
||||
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqScriptDtls::getScriptId, scriptId)
|
||||
.eq(PqScriptDtls::getScriptType, sourceScriptId)
|
||||
.eq(PqScriptDtls::getScriptSubType, subType)
|
||||
.eq(PqScriptDtls::getValueType, valueType)
|
||||
.in(PqScriptDtls::getPhase, Arrays.asList("A", "B", "C"))
|
||||
.eq(PqScriptDtls::getValue, value);
|
||||
List<PqScriptDtls> pqScriptDtls = pqScriptDtlsService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(pqScriptDtls)) {
|
||||
return pqScriptDtls.get(0).getIndex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据参数返回double的四舍五入值
|
||||
*
|
||||
* @param i 保留的位数
|
||||
* @param value double原值
|
||||
*/
|
||||
public static String doubleRound(int i, double value) {
|
||||
BigDecimal bp = new BigDecimal(value);
|
||||
return String.format("%.4f", bp.setScale(i, RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
|
||||
|
||||
private void ensureDirectoryExists(String directoryPath) {
|
||||
File directory = new File(directoryPath);
|
||||
if (!directory.exists()) {
|
||||
boolean created = directory.mkdirs();
|
||||
if (!created) {
|
||||
throw new BusinessException("目录创建失败: " + directoryPath);
|
||||
}
|
||||
} else {
|
||||
System.out.println("目录已存在: " + directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/1/9 20:52
|
||||
*/
|
||||
public class WordUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 将源文档的内容(包括段落、表格等)追加到目标文档中
|
||||
*
|
||||
* @param target 目标文档
|
||||
* @param source 源文档
|
||||
*/
|
||||
public static void appendDocument(XWPFDocument target, XWPFDocument source) {
|
||||
// 在追加内容之前,插入分页符
|
||||
// insertPageBreak(target);
|
||||
// 遍历源文档的所有块(段落、表格等)
|
||||
source.getBodyElements().forEach(bodyElement -> {
|
||||
switch (bodyElement.getElementType()) {
|
||||
case PARAGRAPH:
|
||||
// 处理段落
|
||||
XWPFParagraph sourceParagraph = (XWPFParagraph) bodyElement;
|
||||
XWPFParagraph newParagraph = target.createParagraph();
|
||||
newParagraph.getCTP().set(sourceParagraph.getCTP());
|
||||
break;
|
||||
case TABLE:
|
||||
// 处理表格
|
||||
XWPFTable sourceTable = (XWPFTable) bodyElement;
|
||||
XWPFTable newTable = target.createTable();
|
||||
newTable.getCTTbl().set(sourceTable.getCTTbl());
|
||||
break;
|
||||
default:
|
||||
// 针对其他类型(如图片、页眉页脚等)可以扩展处理逻辑
|
||||
System.out.println("未处理的内容类型:" + bodyElement.getElementType());
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void insertPageBreak(XWPFDocument target) {
|
||||
if(!isDocumentEmpty(target)){
|
||||
// 获取最后一个页面的段落
|
||||
XWPFParagraph pageBreakParagraph = getLastPageParagraph(target);
|
||||
// 设置分页符
|
||||
pageBreakParagraph.setPageBreak(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDocumentEmpty(XWPFDocument document) {
|
||||
// 检查段落
|
||||
List<XWPFParagraph> paragraphs = document.getParagraphs();
|
||||
if (paragraphs != null && !paragraphs.isEmpty()) {
|
||||
for (XWPFParagraph paragraph : paragraphs) {
|
||||
if (paragraph.getText() != null && !paragraph.getText().trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查表格
|
||||
List<XWPFTable> tables = document.getTables();
|
||||
if (tables != null && !tables.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static XWPFParagraph getLastPageParagraph(XWPFDocument document) {
|
||||
XWPFParagraph lastPageParagraph = null;
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
lastPageParagraph = paragraph;
|
||||
}
|
||||
|
||||
return lastPageParagraph;
|
||||
}
|
||||
|
||||
private static boolean containsPageBreak(XWPFParagraph paragraph) {
|
||||
for (XWPFRun run : paragraph.getRuns()) {
|
||||
if (run.getText(0) != null && run.getText(0).contains("\f")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 替换表格中的占位符
|
||||
* @param document 文档
|
||||
* @param placeholders 待替换的占位符
|
||||
*/
|
||||
public static void replacePlaceholdersInTables(XWPFDocument document, Map<String, String> placeholders) {
|
||||
for (XWPFTable table : document.getTables()) {
|
||||
for (XWPFTableRow row : table.getRows()) {
|
||||
for (XWPFTableCell cell : row.getTableCells()) {
|
||||
for (XWPFParagraph paragraph : cell.getParagraphs()) {
|
||||
List<XWPFRun> runs = paragraph.getRuns();
|
||||
if (runs != null) {
|
||||
for (XWPFRun run : runs) {
|
||||
String text = run.getText(0);
|
||||
if (text != null) {
|
||||
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||
text = text.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
run.setText(text, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 替换段落中的占位符
|
||||
* @param document 文档
|
||||
* @param placeholders 待替换的占位符
|
||||
*/
|
||||
public static void replacePlaceholdersInParagraphs(XWPFDocument document, Map<String, String> placeholders) {
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
List<XWPFRun> runs = paragraph.getRuns();
|
||||
if (runs != null) {
|
||||
for (XWPFRun run : runs) {
|
||||
String text = run.getText(0);
|
||||
if (text != null) {
|
||||
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||
text = text.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
run.setText(text, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.njcn.gather.result.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -55,4 +59,31 @@ public class ResultController extends BaseController {
|
||||
List<TreeDataVO> infoVOS = resultService.treeData(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, infoVOS, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/resultData")
|
||||
@ApiOperation("查询检测结果-表格具体检测项")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<ResultVO> resultData(@RequestBody @Validated ResultParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("resultData");
|
||||
ResultVO resultVO = resultService.resultData(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resultVO, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/exportRawData")
|
||||
@ApiOperation("导出原始数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void exportCNDev(@RequestBody @Validated ResultParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("exportRawData");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
|
||||
resultService.exportRawData(queryParam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.result.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-01-16
|
||||
*/
|
||||
@Getter
|
||||
public enum ResultResponseEnum {
|
||||
|
||||
RAW_DATA_NOT_EXIST("原始数据不存在!", "A001014");
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
ResultResponseEnum(String code,String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user