Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c80ae2f95f | ||
|
|
d633b0bd35 | ||
|
|
81645ae1ba | ||
|
|
708a4e6fbd | ||
|
|
c60d41af10 | ||
|
|
91e2e9e7fe | ||
|
|
d1101cd157 | ||
|
|
7594657021 | ||
|
|
9bef1331f2 | ||
|
|
77e2a73345 | ||
|
|
1b518e508e | ||
|
|
1c12187d93 | ||
|
|
67b6f822c3 | ||
|
|
337797b0ed | ||
|
|
1075a72375 | ||
|
|
9fcf4e39a4 | ||
|
|
189ffad11d | ||
|
|
efccaae69e | ||
|
|
34d4321290 | ||
|
|
6cca428d62 | ||
|
|
653c556867 | ||
|
|
8c4ce5d8af | ||
|
|
2261a786a4 | ||
|
|
1f5916e898 | ||
|
|
fe9a81a3a3 | ||
|
|
c0466ed189 | ||
|
|
bc37e47b43 | ||
|
|
6968bf437d | ||
|
|
08be6c15fb | ||
|
|
1d7440b4f7 | ||
|
|
e0e1b6ea9e | ||
|
|
646e33d93a | ||
|
|
8419450427 | ||
|
|
ae94e35607 | ||
|
|
6fb6733727 | ||
|
|
273dd18405 | ||
|
|
8e78ae4e4c | ||
|
|
dda18320f8 | ||
|
|
993ac5f019 | ||
|
|
98dd7894b8 | ||
|
|
f34a996705 | ||
|
|
bc20fc0705 | ||
| 5d606673a6 | |||
|
|
a4f5034c7f | ||
|
|
6e6a6512c9 | ||
|
|
c7ac87c930 | ||
|
|
06b13fdfe1 | ||
|
|
a2ac240150 | ||
|
|
19e99fda9e | ||
|
|
bf94ed37d9 | ||
|
|
5ee33fabdf | ||
|
|
d65b68bbf4 | ||
|
|
6fb57f8422 | ||
|
|
cbbf2db4eb | ||
| 837ea9e369 | |||
|
|
496c7a7908 | ||
|
|
758b2a9033 | ||
|
|
913a86dcc7 | ||
|
|
84879b8d18 | ||
|
|
79b89e7e8b | ||
|
|
cb06b77aef | ||
|
|
b746a6445f | ||
|
|
c062e2a47f | ||
|
|
5828a52329 | ||
|
|
bb9a0f586f | ||
| 8cef3c8358 | |||
|
|
0c012152bb | ||
|
|
76ec26dca0 | ||
|
|
a5472781de | ||
|
|
ff7fbf92e6 | ||
| 158422860d | |||
| 422645bcfd | |||
|
|
dd96bc4171 | ||
|
|
2c950b3ac5 | ||
|
|
25e975fbc8 | ||
|
|
a006c0df33 | ||
|
|
b5cee74731 | ||
|
|
801e17e274 | ||
|
|
93d649162d | ||
| cc529b7e91 | |||
|
|
8f719e5a73 | ||
|
|
8f8788b43c | ||
|
|
04135f7044 | ||
|
|
aca953e827 |
@@ -1,16 +1,21 @@
|
||||
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.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
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.detection.util.socket.XiNumberManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
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;
|
||||
@@ -22,9 +27,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@@ -42,8 +47,7 @@ public class PreDetectionController extends BaseController {
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,12 +57,48 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startPreTest(@RequestBody @Validated 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("/ytxCheckSimulate")
|
||||
@OperateInfo
|
||||
@ApiOperation("源通讯校验")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("ytxCheckSimulate");
|
||||
preDetectionService.ytxCheckSimulate(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟检测
|
||||
*/
|
||||
@PostMapping("/startSimulateTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("启动")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startTestSimulate");
|
||||
preDetectionService.sendScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭检测
|
||||
*/
|
||||
@PostMapping("/closeSimulateTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("停止")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("closeSimulateTest");
|
||||
preDetectionService.closeTestSimulate(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系数校验
|
||||
@@ -67,7 +107,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("系数校验")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("coefficientCheck");
|
||||
preDetectionService.coefficientCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -81,7 +121,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("暂停检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> temStopTest(){
|
||||
public HttpResult<String> temStopTest() {
|
||||
String methodDescribe = getMethodDescribe("temStopTest");
|
||||
preDetectionService.temStopTest();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -94,14 +134,13 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("重新开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("restartTemTest");
|
||||
preDetectionService.restartTemTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
@@ -109,111 +148,28 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("测试")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startTest(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> startTest(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startTest");
|
||||
//preDetectionService.startTest(param);
|
||||
|
||||
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\":[]}");
|
||||
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId("a303b2224845fcc6f60198b8ca23dca9");
|
||||
//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));
|
||||
XiNumberManager.xiDevList = pqDevList;
|
||||
String s = param.getUserPageId() + "_Dev";
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
PreDetection preDetection = pqDevList.get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
|
||||
|
||||
NettyClient.socketClient("192.168.1.138", 61000, param, JSON.toJSONString(socketMsg), new NettyDevClientHandler(param, socketDevResponseService));
|
||||
|
||||
//detectionServiceImpl.processing(devDataList,param,devIdMapComm,sourceIssues, DictDataEnum.AT_WILL_VALUE);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.po.SourceCompareDev;
|
||||
@@ -142,13 +143,12 @@ public class SocketDevResponseService {
|
||||
case QUITE:
|
||||
quitDeal(socketDataMsg, param, msg);
|
||||
break;
|
||||
case YXT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//用于存储所有测点的试试数据
|
||||
private final List<DevData> realDataXiList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 系数校验
|
||||
*/
|
||||
@@ -161,6 +161,39 @@ public class SocketDevResponseService {
|
||||
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||
case DATA_CHNFACTOR$01:
|
||||
//获取系数
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) {
|
||||
List<DevXiNumData.GF> gfList = JSON.parseArray(socketDataMsg.getData(), DevXiNumData.GF.class);
|
||||
DevXiNumData devXiNumData = new DevXiNumData();
|
||||
devXiNumData.setDevIP(XiNumberManager.xiDevList.get(0).getDevIP());
|
||||
devXiNumData.setGf(gfList);
|
||||
XiNumberManager.devXiNumDataMap.put(XiNumberManager.xiDevList.get(0).getDevIP(), devXiNumData);
|
||||
XiNumberManager.xiDevList.remove(0);
|
||||
if (CollUtil.isEmpty(XiNumberManager.xiDevList)) {
|
||||
xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
|
||||
break;
|
||||
case NORMAL_RESPONSE:
|
||||
|
||||
break;
|
||||
case DATA_RESOLVE:
|
||||
|
||||
|
||||
break;
|
||||
case COMMUNICATION_ERR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case DATA_CHNFACTOR$02:
|
||||
@@ -183,7 +216,6 @@ public class SocketDevResponseService {
|
||||
//为空则认为所有装置都已经下发,开始进行小电压的申请,步骤进行+1
|
||||
XiNumberManager.stepNumber = 1;
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.big_end.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_start.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
|
||||
System.out.println("第一步结束开始配置小电压电流参数下发给源----------------------");
|
||||
@@ -200,7 +232,7 @@ public class SocketDevResponseService {
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 2;
|
||||
}
|
||||
realDataXiList.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
successComm.clear();
|
||||
XiNumberManager.devXiList.clear();
|
||||
}
|
||||
@@ -222,7 +254,7 @@ public class SocketDevResponseService {
|
||||
case COMMUNICATION_ERR:
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DEV_DATA_REQUEST_02:
|
||||
@@ -232,195 +264,19 @@ public class SocketDevResponseService {
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
realDataXiList.add(devData);
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
|
||||
System.out.println(successComm.size() + " ==" + FormalTestManager.monitorIdListComm.size() + "realDataXiList:" + realDataXiList.size() + "当前步骤" + XiNumberManager.stepNumber);
|
||||
System.out.println(successComm.size() + " ==" + FormalTestManager.monitorIdListComm.size() + "FormalTestManager.realDataXiList:" + FormalTestManager.realDataXiList.size() + "当前步骤" + XiNumberManager.stepNumber);
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println("从装置中已经完成获取原始数据,准备开始计算----------------------");
|
||||
//获取数据流程结束,先把所有数据存到内存中
|
||||
Map<String, List<DevData>> realDataXiMap = realDataXiList.stream().collect(Collectors.groupingBy(it -> it.getId().split(splitTag)[0]));
|
||||
realDataXiMap.forEach((devIp, dataList) -> {
|
||||
AtomicBoolean xiFlag = new AtomicBoolean(true);
|
||||
|
||||
XiNumberManager.devXiList.add(devIp);
|
||||
Map<String, List<DevData>> monitorMap = dataList.stream().collect(Collectors.groupingBy(DevData::getId));
|
||||
|
||||
List<DevXiNumData.GF> gf = new ArrayList<>();
|
||||
monitorMap.forEach((monitorId, list) -> {
|
||||
DevXiNumData.F F = new DevXiNumData.F();
|
||||
CoefficientVO.DevParameter devParameter;
|
||||
|
||||
CoefficientVO coefficientVO = new CoefficientVO();
|
||||
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 2) {
|
||||
devParameter = XiNumberManager.devParameterList.get(0);
|
||||
coefficientVO.setType("big");
|
||||
} else {
|
||||
devParameter = XiNumberManager.devParameterList.get(1);
|
||||
coefficientVO.setType("small");
|
||||
}
|
||||
|
||||
String[] splitStr = monitorId.split(splitTag);
|
||||
coefficientVO.setMonitorNum(splitStr[1]);
|
||||
coefficientVO.setDevName(FormalTestManager.devNameMapComm.get(splitStr[0]));
|
||||
coefficientVO.setDesc((XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) ? "系数下装" : "系数校准");
|
||||
|
||||
assemblyEntity(list, F, coefficientVO, devParameter);
|
||||
if (Objects.nonNull(coefficientVO.getResultFlag()) && coefficientVO.getResultFlag() == 0) {
|
||||
xiFlag.set(false);
|
||||
}
|
||||
|
||||
DevXiNumData.GF gfItem = new DevXiNumData.GF();
|
||||
gfItem.setUMonitorPoint(Integer.parseInt(splitStr[1]) - 1);
|
||||
gfItem.setF(F);
|
||||
gf.add(gfItem);
|
||||
|
||||
//表格数据
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
webSocketVO.setData(coefficientVO);
|
||||
|
||||
WebServiceManager.sendMessage(param.getUserPageId(), webSocketVO);
|
||||
});
|
||||
DevXiNumData devXiNumData = new DevXiNumData();
|
||||
devXiNumData.setChnNum(0);
|
||||
devXiNumData.setDevIP(devIp);
|
||||
devXiNumData.setGf(gf);
|
||||
if (xiFlag.get()) {
|
||||
devXiNumData.setResultFlag(1);
|
||||
} else {
|
||||
devXiNumData.setResultFlag(0);
|
||||
}
|
||||
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 2) {
|
||||
XiNumberManager.devXiNumDataMap.put(devIp, devXiNumData);
|
||||
} else if (XiNumberManager.stepNumber == 1 || XiNumberManager.stepNumber == 3) {
|
||||
XiNumberManager.smallDevXiNumDataMap.put(devIp, devXiNumData);
|
||||
}
|
||||
});
|
||||
if (XiNumberManager.stepNumber == 0) {
|
||||
//开始发送修改系数命令
|
||||
|
||||
xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.devXiList.get(0))));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(xiSocket));
|
||||
} else if (XiNumberManager.stepNumber == 1) {
|
||||
System.out.println("进入小电压步骤》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
|
||||
//判断小电压是否系数超过大电压10%
|
||||
double limit = 0.1;
|
||||
XiNumberManager.smallDevXiNumDataMap.forEach((devIp, devXiNumDataSmall) -> {
|
||||
//定义一个标识: false:表示小电流系数和大电流系数
|
||||
boolean flag = true;
|
||||
DevXiNumData devXiNumDataBig = XiNumberManager.devXiNumDataMap.get(devIp);
|
||||
Map<Integer, DevXiNumData.GF> gfMapSmall = devXiNumDataSmall.getGf().stream().collect(Collectors.toMap(DevXiNumData.GF::getUMonitorPoint, Function.identity()));
|
||||
|
||||
for (DevXiNumData.GF bigGf : devXiNumDataBig.getGf()) {
|
||||
DevXiNumData.F smallF = gfMapSmall.get(bigGf.getUMonitorPoint()).getF();
|
||||
DevXiNumData.F bigF = bigGf.getF();
|
||||
|
||||
boolean ia = isWithinTenPercent(smallF.getIa_gain(), bigF.getIa_gain(), limit);
|
||||
boolean ib = isWithinTenPercent(smallF.getIb_gain(), bigF.getIb_gain(), limit);
|
||||
boolean ic = isWithinTenPercent(smallF.getIc_gain(), bigF.getIc_gain(), limit);
|
||||
boolean va = isWithinTenPercent(smallF.getUa_gain(), bigF.getUa_gain(), limit);
|
||||
boolean vb = isWithinTenPercent(smallF.getUb_gain(), bigF.getUb_gain(), limit);
|
||||
boolean vc = isWithinTenPercent(smallF.getUc_gain(), bigF.getUc_gain(), limit);
|
||||
if (ia && ib && ic && va && vb && vc) {
|
||||
|
||||
|
||||
} else {
|
||||
flag = false;
|
||||
//继续下发一轮
|
||||
if (!ia) {
|
||||
Integer newIa = (smallF.getIa_gain() + bigF.getIa_gain()) / 2;
|
||||
bigF.setIa_gain(newIa);
|
||||
}
|
||||
if (!ib) {
|
||||
Integer newIb = (smallF.getIb_gain() + bigF.getIb_gain()) / 2;
|
||||
bigF.setIb_gain(newIb);
|
||||
}
|
||||
if (!ic) {
|
||||
Integer newIc = (smallF.getIc_gain() + bigF.getIc_gain()) / 2;
|
||||
bigF.setIc_gain(newIc);
|
||||
}
|
||||
if (!va) {
|
||||
Integer newVa = (smallF.getUa_gain() + bigF.getUa_gain()) / 2;
|
||||
bigF.setUa_gain(newVa);
|
||||
}
|
||||
if (!vb) {
|
||||
Integer newUb = (smallF.getUb_gain() + bigF.getUb_gain()) / 2;
|
||||
bigF.setUb_gain(newUb);
|
||||
}
|
||||
if (!vc) {
|
||||
Integer newUc = (smallF.getUc_gain() + bigF.getUc_gain()) / 2;
|
||||
bigF.setUc_gain(newUc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
//如果系数没问题则不需要
|
||||
XiNumberManager.devXiList.removeIf(it -> it.equals(devIp));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//如果差距超过10%则再次下发系数
|
||||
if (CollUtil.isNotEmpty(XiNumberManager.devXiList)) {
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.devXiList.get(0))));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(xiSocket));
|
||||
} else {
|
||||
//存在小电压系数在误差范围内情况,直接结束。
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.big_comp_start.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
//小电流系数下发完毕;开始重新测试一次大电压
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 2;
|
||||
realDataXiList.clear();
|
||||
successComm.clear();
|
||||
}
|
||||
} else if (XiNumberManager.stepNumber == 2) {
|
||||
//大电压处理
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.big_comp_end.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_start.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(1)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 3;
|
||||
realDataXiList.clear();
|
||||
successComm.clear();
|
||||
} else if (XiNumberManager.stepNumber == 3) {
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
System.out.println("-------------------------已经全部结束----------------------");
|
||||
CnSocketUtil.quitSend(param);
|
||||
//修改设备表Factor_Check_Result字段
|
||||
XiNumberManager.devXiNumDataMap.forEach((key, val) -> {
|
||||
DevXiNumData small = XiNumberManager.smallDevXiNumDataMap.get(key);
|
||||
LambdaUpdateWrapper<PqDev> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(PqDev::getId, FormalTestManager.devIdMapComm.get(key));
|
||||
if (val.getResultFlag() == 0 || small.getResultFlag() == 0) {
|
||||
updateWrapper.set(PqDev::getFactorCheckResult, 0);
|
||||
} else {
|
||||
updateWrapper.set(PqDev::getFactorCheckResult, 1);
|
||||
}
|
||||
iPqDevService.update(updateWrapper);
|
||||
updateWrapper.clear();
|
||||
});
|
||||
}
|
||||
|
||||
processData(param, xiSocket);
|
||||
}
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case NORMAL_RESPONSE:
|
||||
realDataXiList.add(devData);
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
break;
|
||||
default:
|
||||
xiSocket.setRequestId(socketDataMsg.getRequestId());
|
||||
@@ -440,9 +296,223 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
private void processData(PreDetectionParam param, SocketMsg<String> xiSocket) {
|
||||
System.out.println(XiNumberManager.stepNumber + "从装置中已经完成获取测试数据,准备开始计算----------------------");
|
||||
Map<String, List<DevData>> realDataXiMap = FormalTestManager.realDataXiList.stream().collect(Collectors.groupingBy(it -> it.getId().split(splitTag)[0]));
|
||||
realDataXiMap.forEach((devIp, dataList) -> processDeviceData(devIp, dataList, param));
|
||||
|
||||
handleStep(XiNumberManager.stepNumber, param, xiSocket);
|
||||
}
|
||||
|
||||
|
||||
private void handleStep(int stepNumber, PreDetectionParam param, SocketMsg<String> xiSocket) {
|
||||
switch (stepNumber) {
|
||||
case 0:
|
||||
sendModifyCoefficientCommand(param, xiSocket);
|
||||
break;
|
||||
case 1:
|
||||
handleSmallVoltageStep(param, xiSocket);
|
||||
break;
|
||||
case 2:
|
||||
handleBigVoltageStep(param, xiSocket);
|
||||
break;
|
||||
case 3:
|
||||
handleFinalStep(param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 系数校验
|
||||
* 修改系数命令下发
|
||||
*/
|
||||
private void sendModifyCoefficientCommand(PreDetectionParam param, SocketMsg<String> xiSocket) {
|
||||
xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.devXiList.get(0))));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(xiSocket));
|
||||
}
|
||||
|
||||
private void handleSmallVoltageStep(PreDetectionParam param, SocketMsg<String> xiSocket) {
|
||||
System.out.println("进入小电压步骤》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
double limit = 0.1;
|
||||
XiNumberManager.smallDevXiNumDataMap.forEach((devIp, devXiNumDataSmall) -> {
|
||||
boolean flag = checkCoefficientDifference(devIp, devXiNumDataSmall, limit);
|
||||
if (flag) {
|
||||
XiNumberManager.devXiList.removeIf(it -> it.equals(devIp));
|
||||
}
|
||||
});
|
||||
|
||||
//如果差距超过10%则再次下发系数
|
||||
if (CollUtil.isNotEmpty(XiNumberManager.devXiList)) {
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.devXiList.get(0))));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(xiSocket));
|
||||
} else {
|
||||
//存在小电压系数在误差范围内情况,直接结束。
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.big_comp_start.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
//小电流系数下发完毕;开始重新测试一次大电压
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 2;
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
successComm.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handleBigVoltageStep(PreDetectionParam param, SocketMsg<String> xiSocket) {
|
||||
//大电压处理
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.big_comp_end.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_start.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(1)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 3;
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
successComm.clear();
|
||||
}
|
||||
|
||||
private void handleFinalStep(PreDetectionParam param) {
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||
System.out.println("-------------------------已经全部结束----------------------");
|
||||
CnSocketUtil.quitSend(param);
|
||||
//修改设备表Factor_Check_Result字段
|
||||
XiNumberManager.devXiNumDataMap.forEach((key, val) -> {
|
||||
DevXiNumData small = XiNumberManager.smallDevXiNumDataMap.get(key);
|
||||
LambdaUpdateWrapper<PqDev> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(PqDev::getId, FormalTestManager.devIdMapComm.get(key));
|
||||
if (val.getResultFlag() == 0 || small.getResultFlag() == 0) {
|
||||
updateWrapper.set(PqDev::getFactorCheckResult, 0);
|
||||
} else {
|
||||
updateWrapper.set(PqDev::getFactorCheckResult, 1);
|
||||
}
|
||||
iPqDevService.update(updateWrapper);
|
||||
updateWrapper.clear();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private boolean checkCoefficientDifference(String devIp, DevXiNumData devXiNumDataSmall, double limit) {
|
||||
boolean flag = true;
|
||||
DevXiNumData devXiNumDataBig = XiNumberManager.devXiNumDataMap.get(devIp);
|
||||
Map<Integer, DevXiNumData.GF> gfMapSmall = devXiNumDataSmall.getGf().stream().collect(Collectors.toMap(DevXiNumData.GF::getUMonitorPoint, Function.identity()));
|
||||
|
||||
for (DevXiNumData.GF bigGf : devXiNumDataBig.getGf()) {
|
||||
DevXiNumData.F smallF = gfMapSmall.get(bigGf.getUMonitorPoint()).getF();
|
||||
DevXiNumData.F bigF = bigGf.getF();
|
||||
|
||||
boolean ia = isWithinTenPercent(smallF.getIa_gain(), bigF.getIa_gain(), limit);
|
||||
boolean ib = isWithinTenPercent(smallF.getIb_gain(), bigF.getIb_gain(), limit);
|
||||
boolean ic = isWithinTenPercent(smallF.getIc_gain(), bigF.getIc_gain(), limit);
|
||||
boolean va = isWithinTenPercent(smallF.getUa_gain(), bigF.getUa_gain(), limit);
|
||||
boolean vb = isWithinTenPercent(smallF.getUb_gain(), bigF.getUb_gain(), limit);
|
||||
boolean vc = isWithinTenPercent(smallF.getUc_gain(), bigF.getUc_gain(), limit);
|
||||
if (!(ia && ib && ic && va && vb && vc)) {
|
||||
flag = false;
|
||||
adjustCoefficients(smallF, bigF);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当小电压系数和大电压系数的差距超过 10% 时,对大电压系数进行调整,调整的方式是取小电压系数和大电压系数的平均值。
|
||||
*/
|
||||
private void adjustCoefficients(DevXiNumData.F smallF, DevXiNumData.F bigF) {
|
||||
if (!isWithinTenPercent(smallF.getIa_gain(), bigF.getIa_gain(), 0.1)) {
|
||||
bigF.setIa_gain((smallF.getIa_gain() + bigF.getIa_gain()) / 2);
|
||||
}
|
||||
if (!isWithinTenPercent(smallF.getIb_gain(), bigF.getIb_gain(), 0.1)) {
|
||||
bigF.setIb_gain((smallF.getIb_gain() + bigF.getIb_gain()) / 2);
|
||||
}
|
||||
if (!isWithinTenPercent(smallF.getIc_gain(), bigF.getIc_gain(), 0.1)) {
|
||||
bigF.setIc_gain((smallF.getIc_gain() + bigF.getIc_gain()) / 2);
|
||||
}
|
||||
if (!isWithinTenPercent(smallF.getUa_gain(), bigF.getUa_gain(), 0.1)) {
|
||||
bigF.setUa_gain((smallF.getUa_gain() + bigF.getUa_gain()) / 2);
|
||||
}
|
||||
if (!isWithinTenPercent(smallF.getUb_gain(), bigF.getUb_gain(), 0.1)) {
|
||||
bigF.setUb_gain((smallF.getUb_gain() + bigF.getUb_gain()) / 2);
|
||||
}
|
||||
if (!isWithinTenPercent(smallF.getUc_gain(), bigF.getUc_gain(), 0.1)) {
|
||||
bigF.setUc_gain((smallF.getUc_gain() + bigF.getUc_gain()) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processDeviceData(String devIp, List<DevData> dataList, PreDetectionParam param) {
|
||||
AtomicBoolean xiFlag = new AtomicBoolean(true);
|
||||
XiNumberManager.devXiList.add(devIp);
|
||||
|
||||
DevXiNumData startXiData = XiNumberManager.devXiNumDataMap.get(devIp);
|
||||
Map<Integer, DevXiNumData.GF> gfMap = startXiData.getGf().stream().collect(Collectors.toMap(DevXiNumData.GF::getUMonitorPoint, Function.identity()));
|
||||
Map<String, List<DevData>> monitorMap = dataList.stream().collect(Collectors.groupingBy(DevData::getId));
|
||||
|
||||
List<DevXiNumData.GF> gf = new ArrayList<>();
|
||||
monitorMap.forEach((monitorId, list) -> {
|
||||
CoefficientVO coefficientVO = createCoefficientVO(monitorId);
|
||||
DevXiNumData.F F = new DevXiNumData.F();
|
||||
CoefficientVO.DevParameter devParameter = getDevParameter();
|
||||
|
||||
assemblyEntity(list, F, gfMap.get(Integer.parseInt(monitorId.split(splitTag)[1]) - 1), coefficientVO, devParameter);
|
||||
if (Objects.nonNull(coefficientVO.getResultFlag()) && coefficientVO.getResultFlag() == 0) {
|
||||
xiFlag.set(false);
|
||||
}
|
||||
|
||||
DevXiNumData.GF gfItem = createGFItem(monitorId, F);
|
||||
gf.add(gfItem);
|
||||
//表格数据
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue(), coefficientVO, null);
|
||||
});
|
||||
|
||||
DevXiNumData devXiNumData = createDevXiNumData(devIp, gf, xiFlag.get());
|
||||
saveDevXiNumData(devIp, devXiNumData);
|
||||
}
|
||||
|
||||
private CoefficientVO createCoefficientVO(String monitorId) {
|
||||
CoefficientVO coefficientVO = new CoefficientVO();
|
||||
String[] splitStr = monitorId.split(splitTag);
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 2) {
|
||||
coefficientVO.setType("big");
|
||||
} else {
|
||||
coefficientVO.setType("small");
|
||||
}
|
||||
coefficientVO.setMonitorNum(splitStr[1]);
|
||||
coefficientVO.setDevName(FormalTestManager.devNameMapComm.get(splitStr[0]));
|
||||
coefficientVO.setDesc((XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) ? "系数下装" : "系数校准");
|
||||
return coefficientVO;
|
||||
}
|
||||
|
||||
private CoefficientVO.DevParameter getDevParameter() {
|
||||
return (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 2) ? XiNumberManager.devParameterList.get(0) : XiNumberManager.devParameterList.get(1);
|
||||
}
|
||||
|
||||
private DevXiNumData.GF createGFItem(String monitorId, DevXiNumData.F F) {
|
||||
DevXiNumData.GF gfItem = new DevXiNumData.GF();
|
||||
gfItem.setUMonitorPoint(Integer.parseInt(monitorId.split(splitTag)[1]) - 1);
|
||||
gfItem.setF(F);
|
||||
return gfItem;
|
||||
}
|
||||
|
||||
private DevXiNumData createDevXiNumData(String devIp, List<DevXiNumData.GF> gf, boolean xiFlag) {
|
||||
DevXiNumData devXiNumData = new DevXiNumData();
|
||||
devXiNumData.setChnNum(0);
|
||||
devXiNumData.setDevIP(devIp);
|
||||
devXiNumData.setGf(gf);
|
||||
devXiNumData.setResultFlag(xiFlag ? 1 : 0);
|
||||
return devXiNumData;
|
||||
}
|
||||
|
||||
private void saveDevXiNumData(String devIp, DevXiNumData devXiNumData) {
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 2) {
|
||||
XiNumberManager.devXiNumDataMap.put(devIp, devXiNumData);
|
||||
} else if (XiNumberManager.stepNumber == 1 || XiNumberManager.stepNumber == 3) {
|
||||
XiNumberManager.smallDevXiNumDataMap.put(devIp, devXiNumData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -466,7 +536,7 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
private void assemblyEntity(List<DevData> deList, DevXiNumData.F F, CoefficientVO coefficientVO, CoefficientVO.DevParameter devParameter) {
|
||||
private void assemblyEntity(List<DevData> deList, DevXiNumData.F F, DevXiNumData.GF startF, CoefficientVO coefficientVO, CoefficientVO.DevParameter devParameter) {
|
||||
//表示接收完成,必须保证10个数
|
||||
if (deList.size() >= 10) {
|
||||
|
||||
@@ -494,12 +564,12 @@ public class SocketDevResponseService {
|
||||
coefficientVO.setCIeData(String.valueOf(optionalIC));
|
||||
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) {
|
||||
Integer aXi = (int) ((2 - (optionalA / devParameter.getDevVolt())) * 10000);
|
||||
Integer bXi = (int) ((2 - (optionalB / devParameter.getDevVolt())) * 10000);
|
||||
Integer cXi = (int) ((2 - (optionalC / devParameter.getDevVolt())) * 10000);
|
||||
Integer aIXi = (int) ((2 - (optionalIA / devParameter.getDevCurr())) * 10000);
|
||||
Integer bIXi = (int) ((2 - (optionalIB / devParameter.getDevCurr())) * 10000);
|
||||
Integer cIXi = (int) ((2 - (optionalIC / devParameter.getDevCurr())) * 10000);
|
||||
Integer aXi = (int) (devParameter.getDevVolt() * startF.getF().getUa_gain() / optionalA);
|
||||
Integer bXi = (int) (devParameter.getDevVolt() * startF.getF().getUb_gain() / optionalB);
|
||||
Integer cXi = (int) (devParameter.getDevVolt() * startF.getF().getUc_gain() / optionalC);
|
||||
Integer aIXi = (int) (devParameter.getDevCurr() * startF.getF().getIa_gain() / optionalIA);
|
||||
Integer bIXi = (int) (devParameter.getDevCurr() * startF.getF().getIb_gain() / optionalIB);
|
||||
Integer cIXi = (int) (devParameter.getDevCurr() * startF.getF().getIc_gain() / optionalIC);
|
||||
|
||||
coefficientVO.setAVuXi(aXi.toString());
|
||||
coefficientVO.setBVuXi(bXi.toString());
|
||||
@@ -515,7 +585,7 @@ public class SocketDevResponseService {
|
||||
F.setIb_gain(bIXi);
|
||||
F.setIc_gain(cIXi);
|
||||
} else {
|
||||
double vLimit = 0.1 * devParameter.getDevVolt() / 100;
|
||||
double vLimit = 0.1 / 100 * devParameter.getDevVolt();
|
||||
double iLimit = 0.005;
|
||||
coefficientVO.setAVuXi(isWithinTenPercent(optionalA, devParameter.getDevVolt(), vLimit) ? "合格" : "不合格");
|
||||
coefficientVO.setBVuXi(isWithinTenPercent(optionalB, devParameter.getDevVolt(), vLimit) ? "合格" : "不合格");
|
||||
@@ -710,9 +780,9 @@ public class SocketDevResponseService {
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(Integer.valueOf(param.getPlanCode()));
|
||||
storageParam.setCode(Integer.valueOf(param.getCode()));
|
||||
storageParam.setScriptId(param.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam);
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
issueParam.setIndexList(indexes);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
|
||||
} else {
|
||||
@@ -731,7 +801,7 @@ public class SocketDevResponseService {
|
||||
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO();
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + stepBegin);
|
||||
webSocketVO.setDesc(null);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
@@ -864,10 +934,16 @@ public class SocketDevResponseService {
|
||||
webSocketVO.setData(XiNumberManager.devParameterList.get(0));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
//下发命令获取所有装置通道系数,首先需要获取所有装置,通过所有装置下发获取系数命令,目前只支持单台装置获取系数
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
XiNumberManager.stepNumber = 0;
|
||||
XiNumberManager.devXiList.clear();
|
||||
@@ -919,7 +995,7 @@ public class SocketDevResponseService {
|
||||
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
realDataXiList.add(devData);
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
@@ -931,10 +1007,10 @@ public class SocketDevResponseService {
|
||||
//修改装置为监测中
|
||||
adPlanService.updateTestState(param.getPlanId(), param.getDevIds());
|
||||
//开启线程进行入库原始数据操作
|
||||
baseDataInsert(realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
baseDataInsert(FormalTestManager.realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
|
||||
//调用判断方法
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(realDataXiList, param, FormalTestManager.devIdMapComm, sourceIssue, dataRule);
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(FormalTestManager.realDataXiList, param, FormalTestManager.devIdMapComm, sourceIssue, dataRule);
|
||||
|
||||
//组装实体推送给前台
|
||||
assWebJson(param, textResult, socketDataMsg, sourceIssue);
|
||||
@@ -967,13 +1043,12 @@ public class SocketDevResponseService {
|
||||
allDevTestList.clear();
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), socketDataMsg.getRequestId().split(stepTag)[1] + stepEnd, null, resultList, null);
|
||||
}
|
||||
|
||||
//在这一步判断是否已经触发暂停按钮
|
||||
if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
FormalTestManager.stopTime = 0;
|
||||
FormalTestManager.hasStopFlag = true;
|
||||
successComm.clear();
|
||||
realDataXiList.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
||||
return;
|
||||
}
|
||||
@@ -1002,7 +1077,7 @@ public class SocketDevResponseService {
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
successComm.clear();
|
||||
realDataXiList.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -1011,7 +1086,7 @@ public class SocketDevResponseService {
|
||||
break;
|
||||
|
||||
case NORMAL_RESPONSE:
|
||||
realDataXiList.add(devData);
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
|
||||
break;
|
||||
case DEV_ERROR:
|
||||
@@ -1031,6 +1106,43 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
private void processData(List<DevData> FormalTestManager.realDataXiList, List<String> successComm, SourceIssue sourceIssue, PreDetectionParam param, SocketDataMsg socketDataMsg, Object dataRule, String handlerSourceStr) {
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println(sourceIssue.getType() + stepTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
handleSmallItemCompletion(FormalTestManager.realDataXiList, sourceIssue, param, socketDataMsg, dataRule);
|
||||
if (handlePauseCondition(param, successComm, FormalTestManager.realDataXiList)) {
|
||||
return;
|
||||
}
|
||||
startNextDetection(sourceIssue, param, socketDataMsg, handlerSourceStr);
|
||||
successComm.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleSmallItemCompletion(List<DevData> FormalTestManager.realDataXiList, SourceIssue sourceIssue, PreDetectionParam param, SocketDataMsg socketDataMsg, Object dataRule) {
|
||||
adPlanService.updateTestState(param.getPlanId(), param.getDevIds());
|
||||
baseDataInsertService.insert(FormalTestManager.realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(FormalTestManager.realDataXiList, param, FormalTestManager.devIdMapComm, sourceIssue, dataRule);
|
||||
assWebJson(param, textResult, socketDataMsg, sourceIssue);
|
||||
SocketManager.delSource(sourceIssue.getIndex());
|
||||
System.out.println("当前小项结束进行删除============" + sourceIssue.getType() + stepTag + sourceIssue.getIndex());
|
||||
long residueCount = SocketManager.getSourceTarget(sourceIssue.getType()) - 1;
|
||||
SocketManager.addTargetMap(sourceIssue.getType(), residueCount);
|
||||
System.out.println("该大项还有" + residueCount + "个小项没有进行检测!!!!!!!!");
|
||||
if (residueCount == 0) {
|
||||
handleLargeItemCompletion(sourceIssue, param, socketDataMsg);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 组装实体推送给前端
|
||||
*/
|
||||
@@ -1107,7 +1219,7 @@ public class SocketDevResponseService {
|
||||
case QUIT_INIT_01:
|
||||
//关闭所有
|
||||
SocketManager.removeUser(s);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
// CnSocketUtil.quitSendSource(param);
|
||||
break;
|
||||
case QUIT_INIT_02:
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
@@ -1274,7 +1386,7 @@ public class SocketDevResponseService {
|
||||
|
||||
/**
|
||||
* 判断相角(-180° ~ 180°)
|
||||
* (+360° ~ -360°)
|
||||
* (+360° ~ -360°)
|
||||
*
|
||||
* @param channelListDTO 源下发角度
|
||||
* @param devPhase 装置返回角度
|
||||
@@ -1288,10 +1400,18 @@ public class SocketDevResponseService {
|
||||
if (devPhase > 180) {
|
||||
phase = devPhase - 360;
|
||||
}
|
||||
|
||||
Double fPhase = channelListDTO.getFPhase();
|
||||
if (fPhase < -180) {
|
||||
fPhase = fPhase + 360;
|
||||
}
|
||||
if (fPhase > 180) {
|
||||
fPhase = fPhase - 360;
|
||||
}
|
||||
return
|
||||
NumberUtil.isIn(BigDecimal.valueOf(phase),
|
||||
BigDecimal.valueOf(channelListDTO.getFPhase() - 1),
|
||||
BigDecimal.valueOf(channelListDTO.getFPhase() + 1));
|
||||
BigDecimal.valueOf(fPhase - 1),
|
||||
BigDecimal.valueOf(fPhase + 1));
|
||||
|
||||
}
|
||||
|
||||
@@ -1301,7 +1421,7 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
public void initRestart() {
|
||||
this.successComm.clear();
|
||||
this.realDataXiList.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -1322,7 +1442,7 @@ public class SocketDevResponseService {
|
||||
//初始化相序集合
|
||||
this.devInfo.clear();
|
||||
this.devDataMap.clear();
|
||||
this.realDataXiList.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
this.targetTestMap.clear();
|
||||
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
@@ -1459,7 +1579,7 @@ public class SocketDevResponseService {
|
||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adHarmonicResult.setDataType("avg");
|
||||
|
||||
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
if (!DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
@@ -1484,22 +1604,39 @@ public class SocketDevResponseService {
|
||||
List<String> c = tem.getC();
|
||||
|
||||
Class<AdHarmonicResult> example = (Class<AdHarmonicResult>) adHarmonicResult.getClass();
|
||||
for (int i = 2; i <= 50; i++) {
|
||||
// 通过反射设置name字段的值
|
||||
try {
|
||||
// 假设这些字段已经以正确的方式定义在AdHarmonicResult类中
|
||||
Field aField = example.getDeclaredField("aValue" + i);
|
||||
Field bField = example.getDeclaredField("bValue" + i);
|
||||
Field cField = example.getDeclaredField("cValue" + i);
|
||||
if(DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) || DicDataEnum.HSI.getCode().equals(sourceIssue.getType())){
|
||||
for (int i = 1; i < a.size()+1; i++) {
|
||||
try {
|
||||
Field aField = example.getDeclaredField("aValue" + i);
|
||||
Field bField = example.getDeclaredField("bValue" + i);
|
||||
Field cField = example.getDeclaredField("cValue" + i);
|
||||
|
||||
aField.setAccessible(true);
|
||||
aField.set(adHarmonicResult, a.get(i - 2));
|
||||
bField.setAccessible(true);
|
||||
bField.set(adHarmonicResult, b.get(i - 2));
|
||||
cField.setAccessible(true);
|
||||
cField.set(adHarmonicResult, c.get(i - 2));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
aField.setAccessible(true);
|
||||
aField.set(adHarmonicResult, a.get(i - 1));
|
||||
bField.setAccessible(true);
|
||||
bField.set(adHarmonicResult, b.get(i - 1));
|
||||
cField.setAccessible(true);
|
||||
cField.set(adHarmonicResult, c.get(i - 1));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for (int i = 2; i <= a.size()+1; i++) {
|
||||
try {
|
||||
Field aField = example.getDeclaredField("aValue" + i);
|
||||
Field bField = example.getDeclaredField("bValue" + i);
|
||||
Field cField = example.getDeclaredField("cValue" + i);
|
||||
|
||||
aField.setAccessible(true);
|
||||
aField.set(adHarmonicResult, a.get(i - 2));
|
||||
bField.setAccessible(true);
|
||||
bField.set(adHarmonicResult, b.get(i - 2));
|
||||
cField.setAccessible(true);
|
||||
cField.set(adHarmonicResult, c.get(i - 2));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
adHarmonicResultList.add(adHarmonicResult);
|
||||
@@ -1544,9 +1681,7 @@ public class SocketDevResponseService {
|
||||
|
||||
private LocalDateTime timeFormat(String dateTimeStr, DateTimeFormatter formatter) {
|
||||
try {
|
||||
// 假设输入是UTC时间,将其解析为ZonedDateTime
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateTimeStr, formatter.withZone(ZoneId.of("UTC")));
|
||||
// 将ZonedDateTime转换为LocalDateTime(去除时区信息)
|
||||
LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();
|
||||
return localDateTime;
|
||||
} catch (DateTimeParseException e) {
|
||||
|
||||
@@ -10,10 +10,7 @@ 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.*;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
@@ -64,7 +61,11 @@ public class SocketSourceResponseService {
|
||||
switch (enumByCode) {
|
||||
//源初始化
|
||||
case YJC_YTXJY:
|
||||
detectionDev(param, socketDataMsg);
|
||||
if (ObjectUtil.isNotNull(param.getPlanId())) {
|
||||
detectionDev(param, socketDataMsg);
|
||||
} else {
|
||||
handleYtxjySimulate(param, socketDataMsg);
|
||||
}
|
||||
break;
|
||||
//相序检测
|
||||
case YJC_XUJY:
|
||||
@@ -72,7 +73,11 @@ public class SocketSourceResponseService {
|
||||
break;
|
||||
//正式检测
|
||||
case FORMAL_REAL:
|
||||
senParamToDev(param, socketDataMsg);
|
||||
if (ObjectUtil.isNotNull(param.getPlanId())) {
|
||||
senParamToDev(param, socketDataMsg);
|
||||
} else {
|
||||
handleSimulateTest(param, socketDataMsg);
|
||||
}
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
@@ -83,13 +88,92 @@ public class SocketSourceResponseService {
|
||||
break;
|
||||
case YXT:
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
System.out.println("fggggggggggggggggggggg" + enumByCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleYtxjySimulate(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
if (param.getSendWebMsg()) {
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
}
|
||||
System.out.println(param.getSendWebMsg() + "模拟检测-源初始化成功");
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case SOURCE_CONNECTION_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
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:
|
||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理模拟检测时,通信模块返回报文
|
||||
*
|
||||
* @param param
|
||||
* @param socketDataMsg
|
||||
*/
|
||||
private void handleSimulateTest(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
System.out.println("模拟检测-源成功执行脚本" + JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +200,6 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
@@ -166,6 +249,7 @@ public class SocketSourceResponseService {
|
||||
case SOURCE_CONNECTION_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case CONTROLLED_SOURCE_ERROR:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
@@ -337,6 +421,7 @@ public class SocketSourceResponseService {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
@@ -361,6 +446,7 @@ public class SocketSourceResponseService {
|
||||
this.monitorIdList = devList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
XiNumberManager.xiDevList = devList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.gather.detection.pojo.enums;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2025/2/12 10:15
|
||||
*/
|
||||
@Getter
|
||||
public enum DetectionCodeEnum {
|
||||
|
||||
FREQ("FREQ", "频率"),
|
||||
VRMS("VRMS", "相电压有效值"),
|
||||
DELTA_V("DELTA_V", "电压偏差"),
|
||||
VA("VA", "电压相角"),
|
||||
U1("U1", "基波电压"),
|
||||
V2_50("V2-50", "谐波电压"),
|
||||
I2_50("I2-50", "谐波电流"),
|
||||
P2_50("P2-50", "谐波有功功率"),
|
||||
SV_1_49("SV_1-49", "间谐波电压"),
|
||||
SI_1_49("SI_1-49", "间谐波电压"),
|
||||
MAG("MAG", "电压幅值"),
|
||||
DUR("DUR", "持续时间"),
|
||||
IRMS("IRMS", "电流有效值"),
|
||||
IA("IA", "电流相角"),
|
||||
V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
|
||||
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
|
||||
PST("PST", "短时间闪变"),
|
||||
|
||||
|
||||
I1("I1", "基波电流"),
|
||||
|
||||
|
||||
|
||||
|
||||
UNKNOWN_ERROR("-1", "未知异常"),
|
||||
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
DetectionCodeEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
public static DetectionCodeEnum getDetectionCodeByCode(String code) {
|
||||
for (DetectionCodeEnum detectionCodeEnum : DetectionCodeEnum.values()) {
|
||||
if (ObjectUtil.equals(code, detectionCodeEnum.getCode())) {
|
||||
return detectionCodeEnum;
|
||||
}
|
||||
}
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public enum DetectionResponseEnum {
|
||||
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
||||
ITEM_TEST_NOT("A020004", "检测项为空"),
|
||||
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复")
|
||||
;
|
||||
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复"),
|
||||
SOURCE_NOT_CONNECT("A020006", "源未连接");
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
@@ -47,6 +47,7 @@ public enum SourceOperateCodeEnum {
|
||||
YJC_XYJY("yjc_xyjy", "协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "相序校验"),
|
||||
FORMAL_REAL("formal_real","正式检测"),
|
||||
// SIMULATE_REAL("simulate_real","模拟检测"),
|
||||
Coefficient_Check("Coefficient_Check","系数校验"),
|
||||
QUITE("quit","关闭设备通讯初始化"),
|
||||
QUITE_SOURCE("close_source","关闭源通讯"),
|
||||
@@ -74,6 +75,7 @@ public enum SourceOperateCodeEnum {
|
||||
TEST_TEM_START("6","继续检测"),
|
||||
TEST_STOP("7","停止检测"),
|
||||
RE_ERROR_TEST("8","不合格项复检"),
|
||||
SIMULATE_TEST("9","模拟检测"),
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,10 +25,6 @@ public class PreDetectionParam {
|
||||
@NotBlank(message = "计划id不可为空")
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 检测计划code
|
||||
*/
|
||||
private String planCode;
|
||||
|
||||
/**
|
||||
* 数字、模拟、比对
|
||||
@@ -65,4 +61,6 @@ public class PreDetectionParam {
|
||||
* 自动生成,用于生成数据表后缀
|
||||
*/
|
||||
private String code;
|
||||
|
||||
private Boolean sendWebMsg;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.gather.detection.pojo.param;
|
||||
|
||||
import com.njcn.gather.script.pojo.constant.PqScriptValidMessage;
|
||||
import com.njcn.gather.source.pojo.constant.PqSourceValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-06
|
||||
*/
|
||||
@Data
|
||||
public class SimulateDetectionParam {
|
||||
|
||||
/**
|
||||
* 操作类型 9.模拟检测
|
||||
*/
|
||||
private String operateType = "9";
|
||||
|
||||
|
||||
/**
|
||||
* 用户功能组成唯一标识 zhangsan_test
|
||||
*/
|
||||
private String userPageId;
|
||||
|
||||
/**
|
||||
* 检测脚本Id
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
@NotNull(message = PqScriptValidMessage.INDEX_NOT_NULL)
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 源id
|
||||
*/
|
||||
@NotBlank(message = PqSourceValidMessage.ID_NOT_BLANK)
|
||||
private String sourceId;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.detection.service;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,8 @@ public interface PreDetectionService {
|
||||
|
||||
/**
|
||||
* 源通讯校验socket入参拼接
|
||||
* @param param
|
||||
*
|
||||
* @param param
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/11 13:26
|
||||
*/
|
||||
@@ -31,6 +32,24 @@ public interface PreDetectionService {
|
||||
|
||||
boolean restartTemTest(PreDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-源通讯校验
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void ytxCheckSimulate(SimulateDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-向源发送脚本
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void sendScript(SimulateDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-停止
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void closeTestSimulate(SimulateDetectionParam param);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
@@ -87,6 +88,8 @@ public class DetectionServiceImpl {
|
||||
param.setIndex(sourceIssue.getIndex());
|
||||
param.setScriptId(sourceIssue.getScriptId());
|
||||
param.setErrorSysId(errorSysId);
|
||||
param.setUn(sourceIssue.getFUn());
|
||||
param.setIn(sourceIssue.getFIn());
|
||||
List<ErrDtlsCheckDataVO> errDtlsCheckData = pqErrSysDtlsService.listByPqErrSysIdAndTypes(param);
|
||||
ResultUnitEnum resultUnitEnumByCode = ResultUnitEnum.getResultUnitEnumByCode(sourceIssue.getType());
|
||||
switch (resultUnitEnumByCode) {
|
||||
@@ -112,57 +115,81 @@ public class DetectionServiceImpl {
|
||||
*/
|
||||
case HV:
|
||||
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmV), code);
|
||||
return harmV.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(harmV)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmV), code);
|
||||
return harmV.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 谐波电流
|
||||
*/
|
||||
case HI:
|
||||
AdHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 2);
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmI), code);
|
||||
return harmI.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(harmI)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmI), code);
|
||||
return harmI.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 间谐波电压
|
||||
*/
|
||||
case HSV:
|
||||
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInV), code);
|
||||
return harmInV.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(harmInV)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInV), code);
|
||||
return harmInV.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 间谐波电流
|
||||
*/
|
||||
case HSI:
|
||||
AdHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 1);
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInI), code);
|
||||
return harmInI.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(harmInI)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInI), code);
|
||||
return harmInI.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
*/
|
||||
case IMBV:
|
||||
AdNonHarmonicResult vUnban = isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, "V_UNBAN");
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(vUnban), code);
|
||||
return vUnban.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(vUnban)) {
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(vUnban), code);
|
||||
return vUnban.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 三相电流不平衡度
|
||||
*/
|
||||
case IMBA:
|
||||
AdNonHarmonicResult iUnban = isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, "I_UNBAN");
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(iUnban), code);
|
||||
return iUnban.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(iUnban)) {
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(iUnban), code);
|
||||
return iUnban.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 谐波有功功率
|
||||
*/
|
||||
case HP:
|
||||
AdHarmonicResult harmP = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, P, sourceIssue, dataRule, 2);
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmP), code);
|
||||
return harmP.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(harmP)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmP), code);
|
||||
return harmP.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 闪变
|
||||
*/
|
||||
case F:
|
||||
AdNonHarmonicResult pst = isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, null, sourceIssue, dataRule, "PST");
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(pst), code);
|
||||
return pst.getResultFlag();
|
||||
if (ObjectUtil.isNotNull(pst)) {
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(pst), code);
|
||||
return pst.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 暂态
|
||||
*/
|
||||
@@ -170,8 +197,7 @@ public class DetectionServiceImpl {
|
||||
case VOLTAGE_DUR:
|
||||
return isVoltageQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code);
|
||||
default:
|
||||
// return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code);
|
||||
return 4;
|
||||
return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,49 +208,128 @@ public class DetectionServiceImpl {
|
||||
DictDataEnum dataRule,
|
||||
String code) {
|
||||
List<AdNonHarmonicResult> info = new ArrayList<>();
|
||||
List<AdHarmonicResult> harmonicResultList = new ArrayList<>();
|
||||
List<String> devValueTypeList = sourceIssue.getDevValueTypeList();
|
||||
//非谐波指标
|
||||
List<String> harmDesc = dev.stream().flatMap(x -> x.getSqlData().stream()).map(DevData.SqlDataDTO::getDesc).distinct().collect(Collectors.toList());
|
||||
//谐波类型
|
||||
List<String> inHarm = dev.stream().flatMap(x -> x.getSqlDataHarm().stream()).map(DevData.SqlDataHarmDTO::getDesc).distinct().collect(Collectors.toList());
|
||||
for (String s : devValueTypeList) {
|
||||
//基本数据
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule, s.split("\\$")[1]);
|
||||
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
|
||||
List<DetectionData> resultFlag = new ArrayList<>();
|
||||
map.forEach((key, value) -> {
|
||||
List<ErrDtlsCheckDataVO> checkData = dtlsCheckData.stream().filter(x -> key.equals(x.getPhase())).collect(Collectors.toList());
|
||||
DetectionData detectionData = rangeComparisonList(value, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule);
|
||||
if (key.equals(TYPE_T)) {
|
||||
result.setTValue(JSON.toJSONString(detectionData));
|
||||
String devIndex = s.split("\\$")[1];
|
||||
if (harmDesc.contains(devIndex)) {
|
||||
//基本数据(频率,电压,电流)
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule, devIndex);
|
||||
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData)) {
|
||||
result.setAdType(dtlsCheckData.get(0).getValueType());
|
||||
}
|
||||
if (key.equals(TYPE_A)) {
|
||||
result.setAValue(JSON.toJSONString(detectionData));
|
||||
List<DetectionData> resultFlag = new ArrayList<>();
|
||||
map.forEach((key, value) -> {
|
||||
List<ErrDtlsCheckDataVO> checkData = dtlsCheckData.stream().filter(x -> key.equals(x.getPhase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkData)) {
|
||||
DetectionData detectionData;
|
||||
if (DUR.equals(devIndex)) {
|
||||
detectionData = rangeDURComparisonList(value, new ArrayList<>(), sourceIssue.getFFreq(), checkData.get(0).getValue(), dataRule);
|
||||
} else {
|
||||
detectionData = rangeComparisonList(value, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule);
|
||||
}
|
||||
if (key.equals(TYPE_T)) {
|
||||
result.setTValue(JSON.toJSONString(detectionData));
|
||||
}
|
||||
if (key.equals(TYPE_A)) {
|
||||
result.setAValue(JSON.toJSONString(detectionData));
|
||||
}
|
||||
if (key.equals(TYPE_B)) {
|
||||
result.setBValue(JSON.toJSONString(detectionData));
|
||||
}
|
||||
if (key.equals(TYPE_C)) {
|
||||
result.setCValue(JSON.toJSONString(detectionData));
|
||||
}
|
||||
resultFlag.add(detectionData);
|
||||
}
|
||||
});
|
||||
result.setResultFlag(setResultFlag(resultFlag));
|
||||
info.add(result);
|
||||
}
|
||||
|
||||
if (inHarm.contains(devIndex)) {
|
||||
String fundCode = "";
|
||||
String harmCode = "";
|
||||
Integer num = 1;
|
||||
String type = "";
|
||||
Double fData = 1.0;
|
||||
if (devIndex.contains("V")) {
|
||||
fundCode = DetectionCodeEnum.U1.getCode();
|
||||
num = 2;
|
||||
type = U;
|
||||
fData = sourceIssue.getFUn();
|
||||
if (devIndex.contains("50")) {
|
||||
harmCode = DetectionCodeEnum.V2_50.getCode();
|
||||
}
|
||||
if (devIndex.contains("49")) {
|
||||
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
||||
}
|
||||
}
|
||||
if (key.equals(TYPE_B)) {
|
||||
result.setBValue(JSON.toJSONString(detectionData));
|
||||
if (devIndex.contains("I")) {
|
||||
fundCode = DetectionCodeEnum.I1.getCode();
|
||||
;
|
||||
type = I;
|
||||
fData = sourceIssue.getFIn();
|
||||
if (devIndex.contains("50")) {
|
||||
harmCode = DetectionCodeEnum.I2_50.getCode();
|
||||
}
|
||||
if (devIndex.contains("49")) {
|
||||
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
||||
}
|
||||
}
|
||||
if (key.equals(TYPE_C)) {
|
||||
result.setCValue(JSON.toJSONString(detectionData));
|
||||
if (devIndex.contains("P")) {
|
||||
type = P;
|
||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01;
|
||||
}
|
||||
resultFlag.add(detectionData);
|
||||
});
|
||||
result.setResultFlag(setResultFlag(resultFlag));
|
||||
info.add(result);
|
||||
//谐波
|
||||
Map<String, Map<Double, List<Double>>> devHarmMap = devHarmListMap(dev, sourceIssue, dataRule, 2);
|
||||
List<DetectionData> detectionData = harmRangeComparison(new ArrayList<>(), null, TYPE_T, sourceIssue, dataRule, devHarmMap.get(TYPE_T), sourceIssue.getFUn(), 2);
|
||||
//间谐波
|
||||
Map<String, Map<Double, List<Double>>> devInHarmMap = devHarmListMap(dev, sourceIssue, dataRule, 1);
|
||||
Map<String, Map<Double, List<Double>>> devHarmMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
|
||||
if (CollUtil.isNotEmpty(devHarmMap)) {
|
||||
AdHarmonicResult harmonicResult = new AdHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
harmonicResult.setMonitorId(devID + "_" + split[1]);
|
||||
harmonicResult.setScriptId(sourceIssue.getScriptId());
|
||||
harmonicResult.setSort(sourceIssue.getIndex());
|
||||
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData)) {
|
||||
harmonicResult.setAdType(dtlsCheckData.get(0).getValueType());
|
||||
}
|
||||
//电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType("avg");
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
|
||||
List<DetectionData> list = new ArrayList<>();
|
||||
list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList()));
|
||||
harmonicResult.setResultFlag(setResultFlag(list));
|
||||
harmonicResultList.add(harmonicResult);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
detectionDataDealService.acceptAdNonResult(info, code);
|
||||
List<Integer> resultFlag = info.stream().filter(x -> 4 != x.getResultFlag()).map(AdNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList());
|
||||
return getInteger(resultFlag);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harmonicResultList)) {
|
||||
detectionDataDealService.acceptAdResult(harmonicResultList, code);
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
@@ -336,45 +441,62 @@ public class DetectionServiceImpl {
|
||||
SourceIssue sourceIssue,
|
||||
DictDataEnum dataRule,
|
||||
Integer num) {
|
||||
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num);
|
||||
Double fData = 1.0;
|
||||
String fundCode = "";
|
||||
String harmCode = "";
|
||||
if (U.equals(type)) {
|
||||
fData = sourceIssue.getFUn();
|
||||
fundCode = DetectionCodeEnum.U1.getCode();
|
||||
if (num == 1) {
|
||||
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
||||
} else {
|
||||
harmCode = DetectionCodeEnum.V2_50.getCode();
|
||||
}
|
||||
}
|
||||
if (I.equals(type)) {
|
||||
fData = sourceIssue.getFIn();
|
||||
fundCode = DetectionCodeEnum.I1.getCode();
|
||||
;
|
||||
if (num == 1) {
|
||||
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
||||
} else {
|
||||
harmCode = DetectionCodeEnum.I2_50.getCode();
|
||||
}
|
||||
}
|
||||
if (P.equals(type)) {
|
||||
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01;
|
||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||
}
|
||||
|
||||
|
||||
AdHarmonicResult harmonicResult = new AdHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
harmonicResult.setMonitorId(devID + "_" + split[1]);
|
||||
harmonicResult.setScriptId(sourceIssue.getScriptId());
|
||||
harmonicResult.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
harmonicResult.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
|
||||
if (CollUtil.isNotEmpty(devMap)) {
|
||||
AdHarmonicResult harmonicResult = new AdHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
harmonicResult.setMonitorId(devID + "_" + split[1]);
|
||||
harmonicResult.setScriptId(sourceIssue.getScriptId());
|
||||
harmonicResult.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
harmonicResult.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
}
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType("avg");
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
|
||||
List<DetectionData> list = new ArrayList<>();
|
||||
list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList()));
|
||||
harmonicResult.setResultFlag(setResultFlag(list));
|
||||
return harmonicResult;
|
||||
}
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType("avg");
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
|
||||
List<DetectionData> list = new ArrayList<>();
|
||||
list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList()));
|
||||
harmonicResult.setResultFlag(setResultFlag(list));
|
||||
return harmonicResult;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,61 +518,64 @@ public class DetectionServiceImpl {
|
||||
DictDataEnum dataRule,
|
||||
String code) {
|
||||
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
);
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule, code);
|
||||
Double fData = 1.0;
|
||||
if (U.equals(type)) {
|
||||
fData = sourceIssue.getFUn();
|
||||
}
|
||||
if (I.equals(type)) {
|
||||
fData = sourceIssue.getFIn();
|
||||
}
|
||||
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
result.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
if (CollUtil.isNotEmpty(map)) {
|
||||
Double fData = 1.0;
|
||||
if (U.equals(type)) {
|
||||
fData = sourceIssue.getFUn();
|
||||
}
|
||||
if (I.equals(type)) {
|
||||
fData = sourceIssue.getFIn();
|
||||
}
|
||||
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split[0]);
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
result.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
}
|
||||
result.setDataType("avg");
|
||||
if (StrUtil.isBlank(type)) {
|
||||
//取出源所对应的相别信息
|
||||
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
||||
.filter(x -> TYPE_A.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_B.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setBValue(JSON.toJSONString(b));
|
||||
|
||||
List<PqScriptCheckData> channelTypeCList = checkData.stream()
|
||||
.filter(x -> TYPE_C.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
|
||||
result.setCValue(JSON.toJSONString(c));
|
||||
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
|
||||
} else {
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_T.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setTValue(JSON.toJSONString(t));
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(t)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result.setDataType("avg");
|
||||
if (StrUtil.isBlank(type)) {
|
||||
//取出源所对应的相别信息
|
||||
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
||||
.filter(x -> TYPE_A.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_B.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setBValue(JSON.toJSONString(b));
|
||||
|
||||
List<PqScriptCheckData> channelTypeCList = checkData.stream()
|
||||
.filter(x -> TYPE_C.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
|
||||
result.setCValue(JSON.toJSONString(c));
|
||||
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
|
||||
} else {
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_T.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setTValue(JSON.toJSONString(t));
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(t)));
|
||||
}
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -552,7 +677,11 @@ public class DetectionServiceImpl {
|
||||
if (DUR.equals(dur)) {
|
||||
c = rangeDURComparisonList(mag.get(typeC), magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule);
|
||||
} else {
|
||||
c = rangeComparisonList(mag.get(typeC), magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
|
||||
List<Double> ampData = mag.get(typeC).stream()
|
||||
.filter(x -> ObjectUtil.isNotNull(x))
|
||||
.map(x -> x * channelTypeCList.get(0).getFAmp() * 0.01)
|
||||
.collect(Collectors.toList());
|
||||
c = rangeComparisonList(ampData, magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -681,7 +810,7 @@ public class DetectionServiceImpl {
|
||||
Map<Double, Double> issueHarmMap;
|
||||
if (P.equals(type)) {
|
||||
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
.eq(PqScriptCheckData::getPhase, phase)
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
);
|
||||
@@ -689,8 +818,10 @@ public class DetectionServiceImpl {
|
||||
} else {
|
||||
Double percent;
|
||||
if (I.equals(type)) {
|
||||
//电流是百分比转换成赋值算的
|
||||
percent = fData * 0.01;
|
||||
} else {
|
||||
//电压是百分比算的
|
||||
percent = 1.0;
|
||||
}
|
||||
if (1 == num) {
|
||||
@@ -719,25 +850,27 @@ public class DetectionServiceImpl {
|
||||
errSysDtlMap.put(key, null);
|
||||
}
|
||||
});
|
||||
devMap.forEach((harm, harmDataList) -> {
|
||||
PqErrSysDtls errSysDtl = errSysDtlMap.get(harm);
|
||||
DetectionData data = new DetectionData();
|
||||
data.setIsData(4);
|
||||
data.setNum(harm);
|
||||
data.setData(harmDataList.get(0));
|
||||
Double v = issueHarmMap.get(harm);
|
||||
data.setResultData(v);
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType()));
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(6);
|
||||
nf.setGroupingUsed(false);
|
||||
data.setRadius(nf.format(-errSys.getMaxErrorValue()) + "~" + nf.format(errSys.getMaxErrorValue()));
|
||||
setDetection(dataRule, harmDataList, errSys, data, v);
|
||||
}
|
||||
info.add(data);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(devMap)) {
|
||||
devMap.forEach((harm, harmDataList) -> {
|
||||
PqErrSysDtls errSysDtl = errSysDtlMap.get(harm);
|
||||
DetectionData data = new DetectionData();
|
||||
data.setIsData(4);
|
||||
data.setNum(harm);
|
||||
data.setData(harmDataList.get(0));
|
||||
Double v = issueHarmMap.get(harm);
|
||||
data.setResultData(v);
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType()));
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(6);
|
||||
nf.setGroupingUsed(false);
|
||||
data.setRadius(nf.format(-errSys.getMaxErrorValue()) + "~" + nf.format(errSys.getMaxErrorValue()));
|
||||
setDetection(dataRule, harmDataList, errSys, data, v);
|
||||
}
|
||||
info.add(data);
|
||||
});
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -753,9 +886,12 @@ public class DetectionServiceImpl {
|
||||
*/
|
||||
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) {
|
||||
List<Double> qualifiedList = harmDataList.stream()
|
||||
.filter(x -> x > 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
|
||||
.filter(x -> v == 0 ? NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue())) :
|
||||
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
isData(dataRule, harmDataList, data, qualifiedList);
|
||||
}
|
||||
|
||||
@@ -788,31 +924,42 @@ public class DetectionServiceImpl {
|
||||
|
||||
/**
|
||||
* @param dev 原始数据
|
||||
* @param sourceIssue
|
||||
* @param dataRule
|
||||
* @param num
|
||||
* @param sourceIssue 源下发参数
|
||||
* @param dataRule 数据处理原则
|
||||
* @param fundCode 装置下发基波code
|
||||
* @param harmCode 装置下发谐波信息
|
||||
* @param num 区分谐波还是间谐波1:谐波,2:间谐波
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Map<Double, List<Double>>> devHarmListMap(List<DevData> dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
|
||||
public Map<String, Map<Double, List<Double>>> devHarmListMap(List<DevData> dev,
|
||||
SourceIssue sourceIssue,
|
||||
DictDataEnum dataRule,
|
||||
String fundCode,
|
||||
String harmCode,
|
||||
Integer num) {
|
||||
Map<String, Map<Double, List<Double>>> map = new HashMap<>(3);
|
||||
List<Double> harmNum = new ArrayList<>();
|
||||
harmNum.add(1.0);
|
||||
if (1 == num) {
|
||||
harmNum.addAll(sourceIssue.getChannelList().stream()
|
||||
.flatMap(x -> x.getInharmList().stream().map(f -> f.getInharm()))
|
||||
.sorted().distinct().collect(Collectors.toList()));
|
||||
} else {
|
||||
harmNum.add(1.0);
|
||||
harmNum.addAll(sourceIssue.getChannelList().stream()
|
||||
.flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm()))
|
||||
.sorted().distinct().collect(Collectors.toList()));
|
||||
}
|
||||
for (DevData devData : dev) {
|
||||
Optional<DevData.SqlDataDTO> first = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst();
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = devData.getSqlData();
|
||||
Optional<DevData.SqlDataDTO> first = Optional.empty();
|
||||
if (CollUtil.isNotEmpty(sqlDataDTOS)) {
|
||||
first = sqlDataDTOS.stream().filter(x -> x.getDesc().equals(fundCode)).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
DevData.SqlDataDTO fund = null;
|
||||
if (first.isPresent()) {
|
||||
fund = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||
fund = first.get();
|
||||
}
|
||||
List<DevData.SqlDataHarmDTO> harmList = devData.getSqlDataHarm().stream().collect(Collectors.toList());
|
||||
List<DevData.SqlDataHarmDTO> harmList = devData.getSqlDataHarm().stream().filter(x -> x.getDesc().equals(harmCode)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
DevData.SqlDataHarmDTO harm = harmList.get(0);
|
||||
if (ObjectUtil.isNotNull(fund)) {
|
||||
@@ -994,7 +1141,7 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
return BigDecimal.valueOf(devData - channelData);
|
||||
}
|
||||
return BigDecimal.valueOf(devData);
|
||||
return BigDecimal.valueOf(0);
|
||||
}
|
||||
|
||||
public BigDecimal divide(Double devData, Double channelData) {
|
||||
@@ -1076,17 +1223,25 @@ public class DetectionServiceImpl {
|
||||
Map<Double, List<Double>> integerListMap = map.get(type);
|
||||
for (Double i : harmNum) {
|
||||
if (integerListMap.containsKey(i)) {
|
||||
if (i.equals(1.0)) {
|
||||
if (i.equals(1.0) && num != 1) {
|
||||
integerListMap.get(1.0).add(multiply(fund, fund));
|
||||
} else {
|
||||
double v = (num == 1 ? i : (i - num));
|
||||
if (type.equals("A")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getA().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getA().size()) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getA().get((int) v), fund));
|
||||
}
|
||||
|
||||
}
|
||||
if (type.equals("B")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getB().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getB().size()) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getB().get((int) v), fund));
|
||||
}
|
||||
}
|
||||
if (type.equals("C")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getC().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getC().size()) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getC().get((int) v), fund));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1095,18 +1250,25 @@ public class DetectionServiceImpl {
|
||||
Map<Double, List<Double>> integerListMap = new LinkedHashMap<>(5);
|
||||
for (Double i : harmNum) {
|
||||
List<Double> integerList = new ArrayList<>();
|
||||
if (i.equals(1.0)) {
|
||||
if (i.equals(1.0) && num != 1) {
|
||||
integerList.add(multiply(fund, fund));
|
||||
integerListMap.put(1.0, integerList);
|
||||
} else {
|
||||
double v = (num == 1 ? i : (i - num));
|
||||
if (type.equals("A")) {
|
||||
integerList.add(multiply(harm.getList().getA().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getA().size()) {
|
||||
integerList.add(multiply(harm.getList().getA().get((int) v), fund));
|
||||
}
|
||||
}
|
||||
if (type.equals("B")) {
|
||||
integerList.add(multiply(harm.getList().getB().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getB().size()) {
|
||||
integerList.add(multiply(harm.getList().getB().get((int) v), fund));
|
||||
}
|
||||
}
|
||||
if (type.equals("C")) {
|
||||
integerList.add(multiply(harm.getList().getC().get((int) (i - num)), fund));
|
||||
if ((int) v < harm.getList().getC().size()) {
|
||||
integerList.add(multiply(harm.getList().getC().get((int) v), fund));
|
||||
}
|
||||
}
|
||||
integerListMap.put(i, integerList);
|
||||
}
|
||||
|
||||
@@ -11,34 +11,37 @@ 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.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
|
||||
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.WebServiceManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
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.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
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;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -46,10 +49,13 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
private final String source = "_Source";
|
||||
private final String dev = "_Dev";
|
||||
private final String stepTag = "&&";
|
||||
private final String handlerSourceStr = "_Source";
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
@@ -62,10 +68,10 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
private final SocketSourceResponseService socketSourceResponseService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
|
||||
@Value("${socket.source.ip:192.168.1.136}")
|
||||
@Value("${socket.source.ip:192.168.1.138}")
|
||||
private String ip;
|
||||
|
||||
@Value("${socket.source.port:10086}")
|
||||
@Value("${socket.source.port:61000}")
|
||||
private Integer port;
|
||||
|
||||
private final SocketSourceResponseService sourceResponseService;
|
||||
@@ -138,12 +144,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
//开始组装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));
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceParam));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -152,6 +157,24 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendYtxSocketSimulate(PreDetectionParam param) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
WebServiceManager.addPreDetectionParam(param);
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
//socketDevResponseService.initList(param);
|
||||
//socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceParam));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean startTest(PreDetectionParam param) {
|
||||
@@ -170,6 +193,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
@Override
|
||||
public boolean restartTemTest(PreDetectionParam param) {
|
||||
FormalTestManager.stopFlag = false;
|
||||
socketDevResponseService.initRestart();
|
||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
@@ -180,42 +204,148 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam=new PqScriptCheckDataParam();
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType,param.getCode());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setSourceId(param.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
preDetectionParam.setSendWebMsg(true);
|
||||
|
||||
specialDealSimulate(preDetectionParam);
|
||||
|
||||
// String code = dictDataService.getDictDataById(param.getPattern()).getCode();
|
||||
// DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||
// switch (dictDataEnumByCode) {
|
||||
// case DIGITAL:
|
||||
// case SIMULATE:
|
||||
// sendYtxSocketSimulate(preDetectionParam);
|
||||
// break;
|
||||
// case CONTRAST:
|
||||
// break;
|
||||
// default:
|
||||
// throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT);
|
||||
// }
|
||||
sendYtxSocketSimulate(preDetectionParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendScript(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
// 进行源通信连接
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setSourceId(param.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
preDetectionParam.setSendWebMsg(false);
|
||||
this.sendYtxSocketSimulate(preDetectionParam);
|
||||
}
|
||||
//组装源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
//issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
//issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setType(1);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
|
||||
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
sourceIssues = sourceIssues.stream()
|
||||
.filter(s -> s.getIndex().equals(param.getScriptIndex()))
|
||||
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
SourceIssue sourceIssue = sourceIssues.get(0);
|
||||
List<String> comm = sourceIssue.getDevValueTypeList();
|
||||
System.out.println("向装置下发的参数ddd>>>>>>>>" + comm);
|
||||
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTestSimulate(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
|
||||
}
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setSourceId(sourceParam.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
CnSocketUtil.quitSendSource(preDetectionParam);
|
||||
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void specialDeal(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
|
||||
System.out.println("发送关闭设备通讯指令。。。。。。。。");
|
||||
CnSocketUtil.quitSend(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(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
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) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作-模拟检测
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void specialDealSimulate(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,10 +353,10 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
/**
|
||||
* 校验
|
||||
*/
|
||||
private void commCheck(PreDetectionParam param){
|
||||
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()){
|
||||
if (ipList.size() != param.getDevIds().size()) {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,7 +34,8 @@ public class FormalTestManager {
|
||||
|
||||
|
||||
|
||||
|
||||
//用于存储所有测点的实时数据
|
||||
public static List<DevData> realDataXiList = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
@@ -19,9 +27,8 @@ import java.util.Map;
|
||||
public class MsgUtil {
|
||||
|
||||
|
||||
|
||||
public static SocketDataMsg socketDataMsg(String textMsg){
|
||||
return JSON.parseObject(textMsg,SocketDataMsg.class);
|
||||
public static SocketDataMsg socketDataMsg(String textMsg) {
|
||||
return JSON.parseObject(textMsg, SocketDataMsg.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,13 +53,12 @@ public class MsgUtil {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param socketDataMsg
|
||||
* @param devMap
|
||||
* @param type 0.装置 1.监测点
|
||||
* @param type 0.装置 1.监测点
|
||||
* @return
|
||||
*/
|
||||
public static String msgToWebData(SocketDataMsg socketDataMsg, Map<String,String> devMap,Integer type){
|
||||
public static String msgToWebData(SocketDataMsg socketDataMsg, Map<String, String> devMap, Integer type) {
|
||||
String data = socketDataMsg.getData();
|
||||
if (StrUtil.isNotBlank(data)) {
|
||||
String[] parts = data.split("_");
|
||||
@@ -60,10 +66,10 @@ public class MsgUtil {
|
||||
String key = parts[0];
|
||||
String newValue = devMap.get(key);
|
||||
if (newValue != null) {
|
||||
if(type == 0) {
|
||||
if (type == 0) {
|
||||
socketDataMsg.setData(newValue);
|
||||
}else {
|
||||
socketDataMsg.setData(newValue+"_"+parts[1]+"路");
|
||||
} else {
|
||||
socketDataMsg.setData(newValue + "_" + parts[1] + "路");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,6 +77,102 @@ public class MsgUtil {
|
||||
return JSON.toJSONString(socketDataMsg);
|
||||
}
|
||||
|
||||
public static List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
|
||||
List<DevData> info = new ArrayList<>();
|
||||
// if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
Map<String, List<AdNonHarmonicResult>> noHarmMap = nonHarm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort()));
|
||||
noHarmMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(result.getDataType());
|
||||
sqlDataDTO.setDesc(result.getAdType());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null);
|
||||
listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
info.add(data);
|
||||
});
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harm)) {
|
||||
Map<String, List<AdHarmonicResult>> harmMap = harm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN))));
|
||||
harmMap.forEach((key, value) -> {
|
||||
List<DevData> collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList());
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
|
||||
DevData.SqlDataHarmDTO dataHarmDTO;
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
if (containBaseHarm) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(harmonicResult.getDataType());
|
||||
sqlDataDTO.setDesc(harmonicResult.getAdType());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(harmonicResult.getBValue1()) ? Double.valueOf(harmonicResult.getBValue1()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(harmonicResult.getCValue1()) ? Double.valueOf(harmonicResult.getCValue1()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
|
||||
dataHarmDTO = new DevData.SqlDataHarmDTO();
|
||||
dataHarmDTO.setType(harmonicResult.getDataType());
|
||||
dataHarmDTO.setDesc(harmonicResult.getAdType());
|
||||
dataHarmDTO.setNum(containBaseHarm ? 49 : 50);
|
||||
DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO();
|
||||
listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setB(reflectHarmonicValue("b", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setC(reflectHarmonicValue("c", harmonicResult, containBaseHarm));
|
||||
dataHarmDTO.setList(listHarmDTO);
|
||||
sqlDataHarmDTOS.add(dataHarmDTO);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
collect.get(0).setSqlDataHarm(sqlDataHarmDTOS);
|
||||
} else {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
data.setSqlDataHarm(sqlDataHarmDTOS);
|
||||
info.add(data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// }
|
||||
return info;
|
||||
|
||||
}
|
||||
|
||||
private static List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
|
||||
List<String> info = new ArrayList<>();
|
||||
for (int i = notContainBaseHarm ? 2 : 1; i <= 50; i++) {
|
||||
String fieldName = phase + "Value" + i;
|
||||
try {
|
||||
Field idField = AdHarmonicResult.class.getDeclaredField(fieldName);
|
||||
idField.setAccessible(true);
|
||||
String value = idField.get(adHarmonicResult) + "";
|
||||
info.add(value);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
@@ -24,6 +25,8 @@ public class WebServiceManager {
|
||||
//key:页面 value:channel
|
||||
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
|
||||
|
||||
// 检测参数。key固定为preDetectionParam, value:检测参数
|
||||
private static final Map<String, PreDetectionParam> preDetectionParamMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addUser(String userId, Channel channel) {
|
||||
userSessions.put(userId, channel);
|
||||
@@ -35,7 +38,7 @@ public class WebServiceManager {
|
||||
Iterator<Map.Entry<String, Channel>> iterator = userSessions.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Channel> entry = iterator.next();
|
||||
if (entry.getValue().id().equals(channelId)) {
|
||||
if (entry.getValue().id().toString().equals(channelId)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -66,5 +69,15 @@ public class WebServiceManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addPreDetectionParam(PreDetectionParam preDetectionParam) {
|
||||
preDetectionParamMap.put("preDetectionParam", preDetectionParam);
|
||||
}
|
||||
public static PreDetectionParam getPreDetectionParam() {
|
||||
return preDetectionParamMap.get("preDetectionParam");
|
||||
}
|
||||
public static void removePreDetectionParam() {
|
||||
preDetectionParamMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -27,7 +28,7 @@ public class XiNumberManager {
|
||||
public static List<String> devXiList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 存储所有测点的大电压系数
|
||||
* 最开始存储装置通道原始系数,后续存储大电压计算出来的系数
|
||||
*/
|
||||
public static Map<String, DevXiNumData> devXiNumDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -47,5 +48,13 @@ public class XiNumberManager {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 因为只支持单台装置获取系数,用于记录未获取到系数的装置,获取到一个删除一个
|
||||
*/
|
||||
public static List<PreDetection> xiDevList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-02-11
|
||||
* @Description: 心跳处理类
|
||||
*/
|
||||
|
||||
|
||||
public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
private final ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
private final String dev = "_Dev";
|
||||
private final String sourceTag = "_Source";
|
||||
|
||||
private final PreDetectionParam param;
|
||||
private final String handlerType;
|
||||
|
||||
// 允许连续未收到心跳响应的最大次数
|
||||
private static final int MAX_HEARTBEAT_MISSES = 3;
|
||||
// 连续未收到心跳响应的次数
|
||||
private int consecutiveHeartbeatMisses = 0;
|
||||
|
||||
|
||||
public HeartbeatHandler(PreDetectionParam param,String type){
|
||||
this.param = param;
|
||||
this.handlerType = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
// 启动心跳定时任务
|
||||
scheduleHeartbeat(ctx);
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
heartbeatExecutor.shutdown();
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
// 每30秒发送一次心跳
|
||||
private void scheduleHeartbeat(ChannelHandlerContext ctx) {
|
||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||
if (ctx.channel().isActive()) {
|
||||
// 发送心跳包
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.channel().writeAndFlush(JSON.toJSONString(msg)+"\n");
|
||||
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send"+LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses++;
|
||||
if (consecutiveHeartbeatMisses >= MAX_HEARTBEAT_MISSES) {
|
||||
// 连续三次未收到心跳响应,断开连接
|
||||
System.out.println(handlerType+"连续三次未收到心跳响应,断开连接");
|
||||
if (dev.equals(handlerType)) {
|
||||
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
|
||||
CnSocketUtil.quitSend(param);
|
||||
} else {
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
System.err.println("线程中断异常: " + e.getMessage());
|
||||
}
|
||||
String key = dev.equals(handlerType) ? param.getUserPageId() + dev : param.getUserPageId() + sourceTag;
|
||||
SocketManager.removeUser(key);
|
||||
consecutiveHeartbeatMisses = 0; // 重置连续心跳丢失次数
|
||||
}
|
||||
}
|
||||
}, 3, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
// 过滤心跳包,避免进入业务逻辑
|
||||
if (isHeartbeatPacket(msg)) {
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response"+LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses = 0;
|
||||
return;
|
||||
}
|
||||
// 处理业务数据
|
||||
ctx.fireChannelRead(msg);
|
||||
|
||||
}
|
||||
|
||||
private boolean isHeartbeatPacket(String msg) {
|
||||
// 判断是否为心跳包
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
return socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,9 @@ import java.util.concurrent.TimeUnit;
|
||||
@Getter
|
||||
public class NettyClient {
|
||||
|
||||
private static final String dev = "_Dev";
|
||||
private static final String source = "_Source";
|
||||
|
||||
public static void socketClient(String ip, Integer port, PreDetectionParam param, String msg, SimpleChannelInboundHandler<String> handler) {
|
||||
NioEventLoopGroup group = new NioEventLoopGroup();
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
@@ -46,18 +49,21 @@ public class NettyClient {
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
|
||||
// .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new HeartbeatHandler(param,source))
|
||||
.addLast(handler);
|
||||
} else {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new HeartbeatHandler(param,dev))
|
||||
//空闲状态的handler
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(handler);
|
||||
}
|
||||
|
||||
@@ -69,7 +75,7 @@ public class NettyClient {
|
||||
System.out.println("链接服务端失败...");
|
||||
} else {
|
||||
System.out.println("链接服务端成功...");
|
||||
System.out.println("客户端向服务端发送消息:"+msg);
|
||||
System.out.println("客户端向服务端发送消息:"+port+msg);
|
||||
channelFuture.channel().writeAndFlush(msg+"\n");
|
||||
}
|
||||
});
|
||||
@@ -78,9 +84,9 @@ public class NettyClient {
|
||||
groupByUserId.shutdownGracefully();
|
||||
}else{
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
SocketManager.addGroup(param.getUserPageId()+"_Source",group);
|
||||
SocketManager.addGroup(param.getUserPageId()+source,group);
|
||||
}else{
|
||||
SocketManager.addGroup(param.getUserPageId()+"_Dev",group);
|
||||
SocketManager.addGroup(param.getUserPageId()+dev,group);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -6,6 +6,8 @@ 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.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.*;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
@@ -22,9 +24,12 @@ 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;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
@@ -102,7 +107,8 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
Boolean fly = false;
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
if(!FormalTestManager.hasStopFlag) {
|
||||
System.out.println(LocalDateTime.now() + "devHandler触发读超时函数**************************************");
|
||||
if (!FormalTestManager.hasStopFlag) {
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
@@ -114,7 +120,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
//闪变,正常抛一轮最大等待20分钟超时
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
|
||||
fly=true;
|
||||
fly = true;
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
CnSocketUtil.quitSend(param);
|
||||
timeoutSend(sourceIssue);
|
||||
@@ -122,37 +128,35 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
//统计数据项,正常抛一轮数据,超时
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
|
||||
fly=true;
|
||||
fly = true;
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
|
||||
} else {
|
||||
//实时数据
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
|
||||
fly=true;
|
||||
fly = true;
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fly=true;
|
||||
fly = true;
|
||||
//为空则认为是常规步骤,设定一分钟超时
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
if(fly){
|
||||
if (fly) {
|
||||
socketResponseService.backCheckState(param);
|
||||
}
|
||||
System.out.println("已经等了一分钟了。。。。。。。。。。。。");
|
||||
}else {
|
||||
} else {
|
||||
//如果是暂停操作后
|
||||
FormalTestManager.stopTime+=60;
|
||||
System.out.println("当前进入暂停操作超时函数-----------------"+FormalTestManager.stopTime);
|
||||
if(FormalTestManager.stopTime > 600){
|
||||
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);
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,8 +166,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有通道准备接入" + ctx.channel());
|
||||
@@ -183,7 +185,7 @@ 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 );
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
@@ -206,9 +208,26 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 发送业务消息时候开启计时器,
|
||||
* @param requestId
|
||||
*/
|
||||
private void timeoutSend(SourceIssue sourceIssue){
|
||||
/* private void scheduleTimeoutTask(String requestId) {
|
||||
ScheduledFuture<?> future = scheduler.schedule(() -> {
|
||||
if (requestTimeoutTasks.containsKey(requestId)) {
|
||||
// 处理超时逻辑
|
||||
System.out.println("Business request with ID " + requestId + " timed out.");
|
||||
requestTimeoutTasks.remove(requestId);
|
||||
ctx.close();
|
||||
}
|
||||
}, BUSINESS_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
requestTimeoutTasks.put(requestId, future);
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 超时后的处理
|
||||
*/
|
||||
private void timeoutSend(SourceIssue sourceIssue) {
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
FormalTestManager.devList.forEach(dev -> {
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
@@ -221,7 +240,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
devListRes.add(devLineTestResult);
|
||||
});
|
||||
WebSocketVO<List<DevLineTestResult>> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(sourceIssue.getType()+"_End");
|
||||
socketVO.setRequestId(sourceIssue.getType() + "_End");
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
|
||||
@@ -95,11 +95,11 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.WRITER_IDLE) {
|
||||
//发送ping 保持心跳链接
|
||||
SocketMsg msg = new SocketMsg();
|
||||
/* SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.writeAndFlush(JSON.toJSONString(msg)+"\n");
|
||||
ctx.writeAndFlush(JSON.toJSONString(msg)+"\n");*/
|
||||
}
|
||||
} else {
|
||||
//防止堆栈溢出
|
||||
@@ -126,6 +126,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
} else if (cause instanceof IOException) {
|
||||
// 处理I/O异常,例如读写错误
|
||||
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
// 处理超时异常
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.njcn.gather.detection.util.socket.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description: 客户端业务处理
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:18
|
||||
*/
|
||||
|
||||
public class DevNettyServerHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private final String DEV = "_Dev";
|
||||
private final String source = "_Source";
|
||||
|
||||
private final String stepTag = "&&";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
|
||||
|
||||
public static final DevNettyServerHandler INSTANCE = new DevNettyServerHandler();
|
||||
|
||||
/**
|
||||
* @Description: 当通道进行连接时推送消息
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:19
|
||||
*/
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("服务端监听到" + ctx.channel().id() + "连接");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理消息信息
|
||||
*/
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) {
|
||||
System.out.println(ctx.channel().id() + "NettyServer服务端接收到客户端消息:" + msg);
|
||||
Channel channel = ctx.channel();
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
|
||||
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||
//设备通讯校验
|
||||
case YJC_SBTXJY:
|
||||
String aa = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":null,\"code\":10201}";
|
||||
String bb = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":null,\"code\":10201}";
|
||||
String cc = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
|
||||
channel.writeAndFlush(aa+"\n");
|
||||
channel.writeAndFlush(bb+"\n");
|
||||
channel.writeAndFlush(cc+"\n");
|
||||
break;
|
||||
//协议校验
|
||||
case YJC_XYJY:
|
||||
String dd="{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$02\",\"data\":null,\"code\":10201}";
|
||||
String ee = "{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$02\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
|
||||
channel.writeAndFlush(dd+"\n");
|
||||
channel.writeAndFlush(ee+"\n");
|
||||
|
||||
String ff = "{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$03\",\"data\":null,\"code\":10201}";
|
||||
String gg ="{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$03\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
|
||||
channel.writeAndFlush(ff+"\n");
|
||||
channel.writeAndFlush(gg+"\n");
|
||||
break;
|
||||
//相序校验
|
||||
case YJC_XUJY:
|
||||
String hh = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"DATA_REQUEST$02\",\"data\":null,\"code\":10201}";
|
||||
String ii = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"DATA_REQUEST$02\",\"data\":\"{\\\"Time\\\":\\\"2025-02-14T15:09:06.004\\\",\\\"ID\\\":\\\"192.168.1.237_1\\\",\\\"result\\\":false,\\\"SqlData\\\":[{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"VRMS\\\",\\\"list\\\":{\\\"A\\\":\\\"59.969920\\\",\\\"B\\\":\\\"49.963360\\\",\\\"C\\\":\\\"39.971470\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"VA\\\",\\\"list\\\":{\\\"A\\\":\\\"0.000000\\\",\\\"B\\\":\\\"-119.864000\\\",\\\"C\\\":\\\"120.052000\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"IRMS\\\",\\\"list\\\":{\\\"A\\\":\\\"1.000979\\\",\\\"B\\\":\\\"1.998939\\\",\\\"C\\\":\\\"3.000807\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"IA\\\",\\\"list\\\":{\\\"A\\\":\\\"-0.038000\\\",\\\"B\\\":\\\"-120.052000\\\",\\\"C\\\":\\\"119.941000\\\",\\\"T\\\":null}}],\\\"SqlDataHarm\\\":[]}\",\"code\":10200}\n";
|
||||
channel.writeAndFlush(hh+"\n");
|
||||
channel.writeAndFlush(ii+"\n");
|
||||
break;
|
||||
//正式检测
|
||||
case FORMAL_REAL:
|
||||
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
String a = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"DATA_CHNFACTOR$01\",\"data\":null,\"code\":10201}";
|
||||
String b = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"DATA_CHNFACTOR$01\",\"data\":\"[{\\\"uMonitorPoint\\\":0,\\\"f\\\":{\\\"Ua_gain\\\":9999,\\\"Ub_gain\\\":10008,\\\"Uc_gain\\\":10000,\\\"U0_gain\\\":10000,\\\"Ia_gain\\\":9997,\\\"Ib_gain\\\":9997,\\\"Ic_gain\\\":10001,\\\"I0_gain\\\":10000,\\\"Uab_gain\\\":9999,\\\"Ubc_gain\\\":10008,\\\"Uca_gain\\\":10000}}]\",\"code\":10200}";
|
||||
channel.writeAndFlush(a+"\n");
|
||||
channel.writeAndFlush(b+"\n");
|
||||
|
||||
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||
case DATA_CHNFACTOR$01:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
//退出关闭
|
||||
case QUITE:
|
||||
// quitDeal(socketDataMsg, param, msg);
|
||||
break;
|
||||
case YXT:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有新连接加入了++++......" + ctx.channel());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Client disconnected, close the server-side channel too
|
||||
System.out.println("NettyServer服务端监听到" + ctx.channel().id() + "关闭连接");
|
||||
ctx.close(); // This will trigger the close event on the server side
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户事件的回调方法(自定义事件用于心跳机制)
|
||||
*/
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
//空闲状态的事件
|
||||
// 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()+" 断开连接");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,11 @@ import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.LineBasedFrameDecoder;
|
||||
import io.netty.handler.codec.string.StringDecoder;
|
||||
import io.netty.handler.codec.string.StringEncoder;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,11 +30,17 @@ public class NettyServer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
NettyServer nettyServer = new NettyServer();
|
||||
nettyServer.run();
|
||||
nettyServer.runSource();
|
||||
}
|
||||
|
||||
|
||||
private void run() {
|
||||
public static void sourceMain(String[] args) {
|
||||
NettyServer nettyServer = new NettyServer();
|
||||
nettyServer.runDev();
|
||||
}
|
||||
|
||||
|
||||
private void runSource() {
|
||||
NioEventLoopGroup boss = new NioEventLoopGroup(1);
|
||||
NioEventLoopGroup work = new NioEventLoopGroup();
|
||||
try {
|
||||
@@ -39,19 +50,30 @@ public class NettyServer {
|
||||
.handler(new ChannelInitializer<ServerSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(ServerSocketChannel ch) {
|
||||
System.out.println("服务正在启动中......");
|
||||
System.out.println("源通讯服务正在启动中......");
|
||||
}
|
||||
})
|
||||
//业务处理
|
||||
.childHandler(NettyServerChannelInitializer.INSTANCE);
|
||||
.childHandler(new ChannelInitializer<NioSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioSocketChannel ch) {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new DevNettyServerHandler());
|
||||
}
|
||||
});
|
||||
|
||||
ChannelFuture future = bootstrap.bind(port).sync();
|
||||
|
||||
future.addListener(f -> {
|
||||
if (future.isSuccess()) {
|
||||
System.out.println("服务启动成功");
|
||||
System.out.println("源通讯服务启动成功");
|
||||
} else {
|
||||
System.out.println("服务启动失败");
|
||||
System.out.println("源通讯服务启动失败");
|
||||
}
|
||||
});
|
||||
future.channel().closeFuture().sync();
|
||||
@@ -63,4 +85,52 @@ public class NettyServer {
|
||||
work.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void runDev() {
|
||||
NioEventLoopGroup boss = new NioEventLoopGroup(1);
|
||||
NioEventLoopGroup work = new NioEventLoopGroup();
|
||||
try {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap().group(boss, work);
|
||||
bootstrap.channel(NioServerSocketChannel.class)
|
||||
//这个处理器可以不写
|
||||
.handler(new ChannelInitializer<ServerSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(ServerSocketChannel ch) {
|
||||
System.out.println("设备通讯服务正在启动中......");
|
||||
}
|
||||
})
|
||||
//业务处理
|
||||
.childHandler(new ChannelInitializer<NioSocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioSocketChannel ch) {
|
||||
ch.pipeline()
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new SourceNettyServerHandler());
|
||||
}
|
||||
});
|
||||
|
||||
ChannelFuture future = bootstrap.bind(port).sync();
|
||||
|
||||
future.addListener(f -> {
|
||||
if (future.isSuccess()) {
|
||||
System.out.println("设备通讯服务启动成功");
|
||||
} else {
|
||||
System.out.println("设备通讯服务启动失败");
|
||||
}
|
||||
});
|
||||
future.channel().closeFuture().sync();
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
boss.shutdownGracefully();
|
||||
work.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class NettyServerChannelInitializer extends ChannelInitializer<NioSocketC
|
||||
// .addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new NettyServerHandler());
|
||||
.addLast(new DevNettyServerHandler());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.njcn.gather.detection.util.socket.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
/**
|
||||
* @Description: 客户端业务处理
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:18
|
||||
*/
|
||||
|
||||
public class NettyServerHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
public static final NettyServerHandler INSTANCE = new NettyServerHandler();
|
||||
|
||||
/**
|
||||
* @Description: 当通道进行连接时推送消息
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:19
|
||||
*/
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("服务端监听到"+ctx.channel().id()+"连接");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理消息信息
|
||||
*/
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) {
|
||||
System.out.println(ctx.channel().id()+"NettyServer服务端接收到客户端消息:"+msg);
|
||||
Channel channel = ctx.channel();
|
||||
/*
|
||||
if(msg.endsWith("结束")) {
|
||||
channel.writeAndFlush("socket指令结果:"+msg);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
channel.writeAndFlush("socket指令结果:"+msg);
|
||||
}
|
||||
}else{
|
||||
channel.writeAndFlush("socket指令结果:成功指令");
|
||||
}*/
|
||||
if(!msg.contains("HeartBeat")){
|
||||
if(msg.contains("start")){
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("requestId","yjc_ytxjy");
|
||||
jsonObject1.put("operateCode","INIT_GATHER");
|
||||
jsonObject1.put("code","10201");
|
||||
channel.writeAndFlush(jsonObject1.toJSONString()+'\n');
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("requestId","yjc_ytxjy");
|
||||
jsonObject.put("operateCode","INIT_GATHER");
|
||||
jsonObject.put("code","10200");
|
||||
channel.writeAndFlush(jsonObject.toJSONString()+'\n');
|
||||
}else if(msg.contains("YJC_xujy")){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("requestId","YJC_xujy");
|
||||
jsonObject.put("operateCode","OPER_GATHER");
|
||||
jsonObject.put("code","10201");
|
||||
channel.writeAndFlush(jsonObject.toJSONString()+'\n');
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("requestId","YJC_xujy");
|
||||
jsonObject1.put("operateCode","OPER_GATHER");
|
||||
jsonObject1.put("code","10200");
|
||||
channel.writeAndFlush(jsonObject1.toJSONString()+'\n');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有新连接加入了++++......" + ctx.channel());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Client disconnected, close the server-side channel too
|
||||
System.out.println("NettyServer服务端监听到"+ctx.channel().id()+"关闭连接");
|
||||
ctx.close(); // This will trigger the close event on the server side
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户事件的回调方法(自定义事件用于心跳机制)
|
||||
*/
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
//空闲状态的事件
|
||||
// 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()+" 断开连接");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.njcn.gather.detection.util.socket.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
/**
|
||||
* @Description: 客户端业务处理
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:18
|
||||
*/
|
||||
|
||||
public class SourceNettyServerHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private final String DEV = "_Dev";
|
||||
private final String source = "_Source";
|
||||
|
||||
private final String stepTag = "&&";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
|
||||
public static final SourceNettyServerHandler INSTANCE = new SourceNettyServerHandler();
|
||||
|
||||
/**
|
||||
* @Description: 当通道进行连接时推送消息
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:19
|
||||
*/
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("服务端监听到" + ctx.channel().id() + "连接");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理消息信息
|
||||
*/
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) {
|
||||
System.out.println(ctx.channel().id() + "NettyServer服务端接收到客户端消息:" + msg);
|
||||
Channel channel = ctx.channel();
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
if (ObjectUtil.isNotNull(enumByCode)) {
|
||||
switch (enumByCode) {
|
||||
//源初始化
|
||||
case YJC_YTXJY:
|
||||
String aa = "{\"requestId\":\"yjc_ytxjy\",\"operateCode\":\"INIT_GATHER\",\"data\":null,\"code\":10201}";
|
||||
String bb = "{\"requestId\":\"yjc_ytxjy\",\"operateCode\":\"INIT_GATHER\",\"data\":null,\"code\":10200}";
|
||||
channel.writeAndFlush(aa+"/n");
|
||||
channel.writeAndFlush(bb+"/n");
|
||||
break;
|
||||
//相序检测
|
||||
case YJC_XUJY:
|
||||
String hh = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10201}";
|
||||
String ii = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10200}";
|
||||
channel.writeAndFlush(hh+"\n");
|
||||
channel.writeAndFlush(ii+"\n");
|
||||
break;
|
||||
//正式检测
|
||||
case FORMAL_REAL:
|
||||
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
String a = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10201}";
|
||||
String b= "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10200}";
|
||||
|
||||
break;
|
||||
case QUITE_SOURCE:
|
||||
|
||||
break;
|
||||
case YXT:
|
||||
jsonObject1.put("requestId", "yjc_ytxjy");
|
||||
jsonObject1.put("operateCode", "INIT_GATHER");
|
||||
jsonObject1.put("code", "10201");
|
||||
channel.writeAndFlush(jsonObject1.toJSONString() + '\n');
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
System.out.println("未知异常" + enumByCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有新连接加入了++++......" + ctx.channel());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
// Client disconnected, close the server-side channel too
|
||||
System.out.println("NettyServer服务端监听到" + ctx.channel().id() + "关闭连接");
|
||||
ctx.close(); // This will trigger the close event on the server side
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户事件的回调方法(自定义事件用于心跳机制)
|
||||
*/
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
//空闲状态的事件
|
||||
// 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()+" 断开连接");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.njcn.gather.detection.util.socket.web;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,11 +53,13 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
} else if (msg instanceof TextWebSocketFrame) {
|
||||
//正常的TEXT消息类型
|
||||
TextWebSocketFrame frame = (TextWebSocketFrame) msg;
|
||||
log.info("webSocket服务器收到客户端心跳信息:{}", frame.text());
|
||||
/*if ("alive".equals(frame.text())) {
|
||||
//log.info("webSocket服务器收到客户端心跳信息:{}", frame.text());
|
||||
if ("alive".equals(frame.text())) {
|
||||
//System.out.println("webSocket心跳收到时间………………………………………………………………"+LocalDateTime.now());
|
||||
times = 0;
|
||||
TextWebSocketFrame wd = new TextWebSocketFrame("over");
|
||||
ctx.writeAndFlush(wd);
|
||||
}*/
|
||||
ctx.channel().writeAndFlush(wd);
|
||||
}
|
||||
}
|
||||
super.channelRead(ctx, msg);
|
||||
|
||||
@@ -69,6 +67,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
|
||||
/**
|
||||
* 根据用户地址获取用户名 ws://127.0.0.1:7777/hello?name=aa
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
@@ -108,7 +107,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx){
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) {
|
||||
// 假设用户 ID 是从某个地方获取的,这里简单示例为 "userId"
|
||||
System.out.println("weoSocket客户端退出: " + ctx.channel().id());
|
||||
WebServiceManager.removeChannel(ctx.channel().id().toString());
|
||||
@@ -120,9 +119,14 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
System.out.println("weoSocket断线" + ctx.channel().id());
|
||||
ctx.close();
|
||||
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setUserPageId("cdf");
|
||||
CnSocketUtil.quitSend(param);
|
||||
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
|
||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接?
|
||||
} else {
|
||||
preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId("cdf");
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,11 +137,12 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
eventDesc = "读空闲";
|
||||
System.out.println(ctx.channel().remoteAddress() + "发生超时事件--" + eventDesc);
|
||||
System.out.println("c端心跳检测发生超时事件--" + eventDesc);
|
||||
times++;
|
||||
if (times > 3) {
|
||||
System.out.println("空闲次数超过三次 关闭连接");
|
||||
System.out.println("c端心跳检测空闲次数超过三次 关闭连接");
|
||||
ctx.channel().close();
|
||||
WebServiceManager.removeChannel(ctx.channel().id().toString());
|
||||
}
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
@@ -153,12 +158,6 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送数据至前台
|
||||
*/
|
||||
public void sendMsgToUser(String userId, String msg) {
|
||||
WebServiceManager.sendMsg(userId, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -237,8 +238,11 @@ public class PqDevController extends BaseController {
|
||||
@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) {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file,@RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
@@ -269,7 +273,7 @@ public class PqDevController extends BaseController {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId);
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId, null);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface DevValidMessage {
|
||||
|
||||
String PATTERN_NOT_BLANK = "模式不能为空,请检查pattern参数";
|
||||
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空,请检查devType参数";
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空";
|
||||
|
||||
String DEV_CHNS_NOT_NULL = "设备通道系数不能为空,请检查devChns参数";
|
||||
|
||||
@@ -205,4 +205,7 @@ public interface DevValidMessage {
|
||||
String CONDITION_TYPE_FORMAT_ERROR = "判断条件类型格式错误,请检查conditionType参数";
|
||||
|
||||
String SORT_NOT_NULL = "排序不能为空";
|
||||
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
|
||||
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
|
||||
String CREATEID_NOT_BLANK = "设备序列号不能为空";
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import javax.validation.constraints.Pattern;
|
||||
public class CNDevExcel {
|
||||
|
||||
@Excel(name = "预投计划*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PreDetection {
|
||||
/**
|
||||
* 监测点线路号
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
@JSONField(name = "pt") //todo 是否改为ct
|
||||
private Integer ct;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,30 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*
|
||||
* @param cnDevExcelList 灿能二楼设备数据列表
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId);
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 根据计划id列表获取设备列表
|
||||
*
|
||||
* @param planIds
|
||||
* @return
|
||||
*/
|
||||
List<PqDev> listByPlanIds(List<String> planIds);
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
void visualizeCNDev(List<PqDev> pqDevs);
|
||||
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs 设备列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId);
|
||||
}
|
||||
|
||||
@@ -452,9 +452,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getName());
|
||||
pqDev.setDevType(devType.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
@@ -584,23 +584,26 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
for (PqDev pqDev : list) {
|
||||
if (result.containsKey(pqDev.getId())) {
|
||||
Integer checkState;
|
||||
int i;
|
||||
if (pqDev.getReCheckNum() >= config.getMaxTime()) {
|
||||
// 装置报告生成 todo...
|
||||
this.baseMapper.updateReportState(pqDev.getId());
|
||||
// 装置归档
|
||||
checkState = CheckStateEnum.DOCUMENTED.getValue();
|
||||
i = pqDev.getReCheckNum();
|
||||
} else {
|
||||
checkState = CheckStateEnum.CHECKED.getValue();
|
||||
i = pqDev.getReCheckNum() + 1;
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getReCheckNum, pqDev.getReCheckNum() + 1)
|
||||
.set(PqDev::getReCheckNum, i)
|
||||
.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())) {
|
||||
if (checkState.equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -670,35 +673,25 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, 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<>());
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId) {
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId,String planId) {
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeCNDev(oldDevList);
|
||||
this.reverseVisualizeCNDev(oldDevList, patternId);
|
||||
|
||||
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());
|
||||
|
||||
pqDev.setPlanId(planId);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
@@ -725,6 +718,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
dev.setPlanId(planId);
|
||||
|
||||
param.setName(dev.getName());
|
||||
param.setCreateId(dev.getName());
|
||||
@@ -757,6 +751,41 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.saveBatch(newDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listByPlanIds(List<String> planIds) {
|
||||
return this.lambdaQuery().in(PqDev::getPlanId, planIds).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
public 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());
|
||||
});
|
||||
}
|
||||
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
|
||||
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.setPattern(patternId);
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
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.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
@@ -891,35 +920,4 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,20 @@ package com.njcn.gather.err.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface PqErrSysMapper extends MPJBaseMapper<PqErrSys> {
|
||||
|
||||
/**
|
||||
* 根据ids获取绑定的计划数量
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Integer getCountBoundByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,16 @@
|
||||
<mapper namespace="com.njcn.gather.err.mapper.PqErrSysMapper">
|
||||
|
||||
|
||||
<select id="getCountBoundByIds" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM ad_plan
|
||||
<if test="ids!= null and ids.size() > 0">
|
||||
<where>
|
||||
AND Error_Sys_Id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.err.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-10
|
||||
*/
|
||||
@Getter
|
||||
public enum ErrResponseEnum {
|
||||
ERR_SYS_BOUND_NOT_DELETE("A100001","误差体系已被计划所绑定,无法删除!");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
ErrResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,14 @@ public class PqErrSysParam {
|
||||
|
||||
@ApiModelProperty("所属检测脚本")
|
||||
private String scriptId;
|
||||
|
||||
|
||||
@ApiModelProperty("电压")
|
||||
private Double un;
|
||||
|
||||
@ApiModelProperty("电流")
|
||||
private Double in;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ 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.detection.pojo.enums.DetectionCodeEnum;
|
||||
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.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
@@ -20,6 +22,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -33,7 +36,7 @@ import java.util.stream.Collectors;
|
||||
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
|
||||
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
|
||||
private final PqScriptMapper pqScriptMapper;
|
||||
|
||||
@Override
|
||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
|
||||
@@ -96,6 +99,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIndex(param.getIndex());
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
|
||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
|
||||
|
||||
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList());
|
||||
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
|
||||
@@ -117,6 +121,21 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
||||
dataVO.setValueType(script.getValueType());
|
||||
dataVO.setValue(script.getValue());
|
||||
dataVO.setPhase(script.getPhase());
|
||||
if(isValueType){
|
||||
if (DetectionCodeEnum.VRMS.getCode().equals(script.getValueTypeCode())) {
|
||||
BigDecimal volValue = new BigDecimal(script.getValue());
|
||||
BigDecimal result = volValue.multiply(new BigDecimal(param.getUn().toString()))
|
||||
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||
dataVO.setValue(result.doubleValue());
|
||||
}
|
||||
if (DetectionCodeEnum.IRMS.getCode().equals(script.getValueTypeCode())) {
|
||||
BigDecimal volValue = new BigDecimal(script.getValue());
|
||||
BigDecimal result = volValue.multiply(new BigDecimal(param.getIn().toString()))
|
||||
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||
dataVO.setValue(result.doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(errMap.containsKey(script.getValueType())){
|
||||
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.err.mapper.PqErrSysMapper;
|
||||
import com.njcn.gather.err.pojo.enums.ErrResponseEnum;
|
||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||
@@ -93,6 +94,10 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deletePqErrSys(List<String> ids) {
|
||||
Integer count = this.baseMapper.getCountBoundByIds(ids);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(ErrResponseEnum.ERR_SYS_BOUND_NOT_DELETE);
|
||||
}
|
||||
pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids);
|
||||
this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
return true;
|
||||
@@ -116,7 +121,6 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public List<Map<String, Object>> listAllPqErrSys() {
|
||||
List<PqErrSys> pqErrSysList = this.lambdaQuery().eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqErrSysList.stream().map(pqErrSys -> {
|
||||
|
||||
@@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,6 +46,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addIcd(PqIcdPathParam param) {
|
||||
this.checkRepeat(param, false);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
@@ -54,6 +56,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
@@ -62,6 +65,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deleteIcd(List<String> ids) {
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@@ -13,14 +13,15 @@ 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.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
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.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;
|
||||
@@ -29,6 +30,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -51,7 +53,7 @@ public class AdPlanController extends BaseController {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
|
||||
@OperateInfo
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测计划")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
@@ -62,7 +64,7 @@ public class AdPlanController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测计划")
|
||||
@ApiImplicitParam(name = "param", value = "检测计划", required = true)
|
||||
@@ -77,7 +79,7 @@ public class AdPlanController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改检测计划")
|
||||
@ApiImplicitParam(name = "updateParam", value = "检测计划", required = true)
|
||||
@@ -92,7 +94,7 @@ public class AdPlanController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.DELETE)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除检测计划")
|
||||
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
|
||||
@@ -108,7 +110,7 @@ public class AdPlanController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listByPattern")
|
||||
@ApiOperation("按照模式查询检测计划")
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
@@ -119,58 +121,119 @@ public class AdPlanController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载监测计划导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
adPlanService.downloadTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 二楼检测计划导出
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
@OperateInfo(operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出检测计划")
|
||||
@PostMapping("/exportCNPlan")
|
||||
@ApiOperation("二楼导出检测计划")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
public void exportCNPlan(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
List<AdPlanExcel.ExportData> data = adPlanService.getExportData(queryParam);
|
||||
ExcelUtil.exportExcel("检测计划导出数据.xlsx", AdPlanExcel.ExportData.class, data);
|
||||
|
||||
adPlanService.exportCNPlan(queryParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 二楼检测计划导出模板
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadCNPlanTemplate")
|
||||
@ApiOperation("下载二楼检测计划导出模板")
|
||||
public void downloadCNPlanTemplate() {
|
||||
adPlanService.downloadCNPlanTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 二楼检测计划导入
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入检测计划数据")
|
||||
@PostMapping(value = "/importCNPlan")
|
||||
@ApiOperation("二楼导入检测计划数据")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
})
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), patternId);
|
||||
public HttpResult<String> importCNPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNPlan");
|
||||
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.setHeadRows(2);
|
||||
params.setNeedVerify(true);
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setHeadRows(2);
|
||||
params.setNeedVerify(true);
|
||||
|
||||
List<AdPlanExcel> planExcelList;
|
||||
try {
|
||||
ExcelImportResult<AdPlanExcel.ImportData> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.ImportData.class, params);
|
||||
if (adPlanExcelResult.isVerifyFail()) {
|
||||
ExcelImportResult<AdPlanExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法检测计划数据.xlsx", response);
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
return null;
|
||||
} else {
|
||||
List<AdPlanExcel.ImportData> adPlanExcelList = adPlanExcelResult.getList();
|
||||
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
|
||||
adPlanService.importData(patternId, adPlanExcelList);
|
||||
}
|
||||
planExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage());
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(planExcelList)) {
|
||||
adPlanService.importCNPlan(planExcelList, patternId);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
// @PostMapping(value = "/import")
|
||||
// @ApiOperation("批量导入检测计划数据")
|
||||
// @ApiImplicitParams({
|
||||
// @ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
|
||||
// @ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
// })
|
||||
// public HttpResult<String> importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
// String methodDescribe = getMethodDescribe("importData");
|
||||
// LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), patternId);
|
||||
//
|
||||
// boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
// if (!fileType) {
|
||||
// throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
// }
|
||||
// ImportParams params = new ImportParams();
|
||||
// params.setHeadRows(2);
|
||||
// params.setNeedVerify(true);
|
||||
// params.setStartSheetIndex(0);
|
||||
// params.setSheetNum(1);
|
||||
//
|
||||
// List<AdPlanExcel.ImportData> adPlanExcelList = null;
|
||||
// try {
|
||||
// ExcelImportResult<AdPlanExcel.ImportData> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.ImportData.class, params);
|
||||
// if (adPlanExcelResult.isVerifyFail()) {
|
||||
// // 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
// PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
// return null;
|
||||
// } else {
|
||||
// adPlanExcelList = adPlanExcelResult.getList();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage());
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
|
||||
// adPlanService.importData(patternId, adPlanExcelList);
|
||||
// }
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// }
|
||||
|
||||
// @OperateInfo
|
||||
// @GetMapping("/getPieData")
|
||||
// @ApiOperation("获取饼状图数据")
|
||||
@@ -182,16 +245,25 @@ public class AdPlanController extends BaseController {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getBigTestItem")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getBigTestItem")
|
||||
@ApiOperation("获取检测大项数据")
|
||||
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
|
||||
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestParam("planId") String planId) {
|
||||
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
|
||||
String methodDescribe = getMethodDescribe("getBigTestItem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(planId);
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(),checkParam.getPlanId(),checkParam.getDevId());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/analyse")
|
||||
@ApiOperation("检测数据分析")
|
||||
@ApiImplicitParam(name = "planId", value = "检测计划id", required = true)
|
||||
public void analyse(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("analyse");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
adPlanService.analyse(ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ import lombok.Getter;
|
||||
public enum PlanResponseEnum {
|
||||
PLAN_REPEATED("A003014", "当前模式下,该计划已存在"),
|
||||
PLAN_NOT_EXIST("A003015", "该计划不存在"),
|
||||
SCRIPT_RELATE_DICT_NOT_EXIST("A003016","脚本关联的字典不存在");
|
||||
SCRIPT_RELATE_DICT_NOT_EXIST("A003016","脚本关联的字典不存在"),
|
||||
NOT_CHECKED_PLAN_CANNOT_ANALYSE("A003017","只有检测状态为检测完成的计划才能进行统计分析" ),
|
||||
CANNOT_CHANGE_SCRIPT_WHEN_CHECKING("A003018","只有检测状态为未检时,才能修改检测脚本" ),
|
||||
CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING("A003019","只有检测状态为未检时,才能修改误差体系" );
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
@@ -126,4 +127,11 @@ public class AdPlanParam {
|
||||
// private Integer result;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CheckParam{
|
||||
// 0:不合格项复检 1:全部复检
|
||||
private Integer reCheckType;
|
||||
private String planId;
|
||||
private String devId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.pojo.constant.DevValidMessage;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -21,164 +22,42 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class AdPlanExcel {
|
||||
@Excel(name = "名称", width = 40, needMerge = true, orderNum = "0")
|
||||
@Excel(name = "名称*", width = 40, needMerge = true, orderNum = "0")
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "检测源", width = 40, needMerge = true, orderNum = "1")
|
||||
@Excel(name = "检测源*", width = 40, needMerge = true, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.SOURC_NOT_BLANK)
|
||||
private String source;
|
||||
|
||||
@Excel(name = "数据源", width = 20, needMerge = true, orderNum = "2")
|
||||
@Excel(name = "数据源*", width = 20, needMerge = true, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.DATASOURCE_NOT_BLANK)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本", width = 50, needMerge = true, orderNum = "3")
|
||||
@Excel(name = "脚本*", width = 50, needMerge = true, orderNum = "3")
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_NOT_BLANK)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "4")
|
||||
@Excel(name = "误差体系*", width = 30, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DevValidMessage.ERRORSYS_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
@NotNull(message = DevValidMessage.TIMECHECK_NOT_NULL)
|
||||
private Integer timeCheck;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends AdPlanExcel {
|
||||
// @Excel(name = "模式", width = 20, needMerge = true, orderNum = "1")
|
||||
// @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
// private String pattern;
|
||||
@Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
@NotNull(message = DevValidMessage.TEST_STATE_NOT_NULL)
|
||||
private Integer testState;
|
||||
|
||||
// @Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3")
|
||||
// private String fatherPlanId;
|
||||
@Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DevValidMessage.REPORT_STATE_NOT_NULL)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
private Integer timeCheck;
|
||||
@Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
@NotNull(message = DevValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
private Integer result;
|
||||
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
private Integer testState;
|
||||
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
private Integer result;
|
||||
|
||||
// @Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11")
|
||||
// private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<BoundExportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends AdPlanExcel {
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DevValidMessage.TIMECHECK_NOT_BLANK)
|
||||
private String timeCheck;
|
||||
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.TEST_STATE_NOT_NULL)
|
||||
private String testState;
|
||||
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
@NotBlank(message = DevValidMessage.REPORT_STATE_NOT_NULL)
|
||||
private String reportState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
@NotBlank(message = DevValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
private String result;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<BoundImportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BoundData {
|
||||
@Excel(name = "名称", width = 20)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3")
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4")
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5")
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8")
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议", width = 15, orderNum = "11")
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址", width = 20, orderNum = "12")
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号", orderNum = "13")
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当为加密版本时必填)", width = 30, orderNum = "15")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当为加密版本时必填)", width = 30, orderNum = "16")
|
||||
private String devKey;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class BoundExportData extends BoundData {
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "是否支持系数校准(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "17", needMerge = true)
|
||||
private Integer factorFlag;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class BoundImportData extends BoundData {
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@Excel(name = "是否支持系数校准(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "17", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FACTOR_FLAG_NOT_BLANK)
|
||||
private String factorFlag;
|
||||
}
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<CNDevExcel> devices;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.njcn.gather.plan.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -57,26 +57,24 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
List<Map<String, Object>> listByPattern(String pattern);
|
||||
|
||||
/**
|
||||
* 下载检测计划模板
|
||||
* 二楼下载检测计划模板
|
||||
*/
|
||||
void downloadTemplate();
|
||||
void downloadCNPlanTemplate();
|
||||
|
||||
/**
|
||||
* 获取检测计划导出数据
|
||||
* 二楼导出检测计划数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 检测计划导出数据
|
||||
*/
|
||||
List<AdPlanExcel.ExportData> getExportData(AdPlanParam.QueryParam queryParam);
|
||||
void exportCNPlan(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 导入检测计划
|
||||
* @param patternId 模式Id
|
||||
* @param adPlanExcelList 检测计划Excel列表
|
||||
* @return 导入成功则返回true,否则返回false
|
||||
* 二楼导入检测计划
|
||||
*
|
||||
* @param planExcelList
|
||||
* @param patternId
|
||||
*/
|
||||
void importData(String patternId, List<AdPlanExcel.ImportData> adPlanExcelList);
|
||||
|
||||
void importCNPlan(List<AdPlanExcel> planExcelList, String patternId);
|
||||
|
||||
/**
|
||||
* 可视化
|
||||
@@ -88,26 +86,37 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
/**
|
||||
* 获取检测大项
|
||||
*
|
||||
* @param reCheckType 0:不合格项复检 1:全部复检
|
||||
* @param planId 检测计划Id
|
||||
* @param devId 设备Id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, String>> getBigTestItem(String planId);
|
||||
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId);
|
||||
|
||||
/**
|
||||
* 修改计划状态
|
||||
*
|
||||
* @param planId
|
||||
* @param devIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateTestState(String planId,List<String> devIds);
|
||||
boolean updateTestState(String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 数据状态回退
|
||||
*
|
||||
* @param planId
|
||||
* @param devIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateBackTestState(String planId,List<String> devIds);
|
||||
boolean updateBackTestState(String planId, List<String> devIds);
|
||||
|
||||
void finishPlan(String planId);
|
||||
|
||||
/**
|
||||
* 数据分析
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void analyse(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.gather.plan.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.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
@@ -12,11 +14,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.common.pojo.poi.PullDown;
|
||||
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.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
@@ -33,18 +37,40 @@ 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.mapper.DetectionDataDealMapper;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.storage.service.TableGenService;
|
||||
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.DictTree;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
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 com.njcn.web.utils.HttpServletUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xddf.usermodel.chart.*;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -66,6 +92,10 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final TableGenService tableGenService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final AdHarmonicService adHarmonicService;
|
||||
|
||||
@Override
|
||||
public Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
||||
@@ -135,17 +165,24 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
AdPlan plan1 = this.getById(param.getId());
|
||||
AdPlan plan2 = new AdPlan();
|
||||
if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
|
||||
if (!plan1.getScriptId().equals(param.getScriptId())) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_SCRIPT_WHEN_CHECKING);
|
||||
}
|
||||
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
|
||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
||||
}
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(param, plan2);
|
||||
plan2.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
plan2.setTestState(pqDevService.bind(param.getId(), param.getDevIds()));
|
||||
|
||||
adPlan.setTestState(pqDevService.bind(param.getId(), param.getDevIds()));
|
||||
|
||||
return this.updateById(adPlan);
|
||||
return this.updateById(plan2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,7 +199,7 @@ 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());
|
||||
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();
|
||||
@@ -204,15 +241,15 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("检测计划模板.xlsx", AdPlanExcel.ImportData.class, Collections.emptyList());
|
||||
public void downloadCNPlanTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(), AdPlanExcel.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdPlanExcel.ExportData> getExportData(AdPlanParam.QueryParam queryParam) {
|
||||
public void exportCNPlan(AdPlanParam.QueryParam queryParam) {
|
||||
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(planList);
|
||||
List<AdPlanExcel.ExportData> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.ExportData.class);
|
||||
List<AdPlanExcel> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.class);
|
||||
for (int i = 0; i < planList.size(); i++) {
|
||||
List<PqSource> pqSources = adPlanSourceService.listPqSourceByPlanId(planList.get(i).getId());
|
||||
planExcelList.get(i).setSource(pqSources.stream().map(PqSource::getName).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
@@ -220,25 +257,34 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
|
||||
queryParam1.setPlanId(planList.get(i).getId());
|
||||
List<PqDev> pqDevs = pqDevService.listByPlanId(queryParam1);
|
||||
pqDevService.visualize(pqDevs);
|
||||
planExcelList.get(i).setDevices(BeanUtil.copyToList(pqDevs, AdPlanExcel.BoundExportData.class));
|
||||
pqDevService.visualizeCNDev(pqDevs);
|
||||
List<CNDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
planExcelList.get(i).setDevices(deviceExportData);
|
||||
}
|
||||
return planExcelList;
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(), AdPlanExcel.class, planExcelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importData(String patternId, List<AdPlanExcel.ImportData> adPlanExcelList) {
|
||||
List<AdPlan> adPlans = BeanUtil.copyToList(adPlanExcelList, AdPlan.class);
|
||||
List<PqDev> devList = new ArrayList<>();
|
||||
public void importCNPlan(List<AdPlanExcel> planExcelList, String patternId) {
|
||||
List<AdPlan> adPlans = BeanUtil.copyToList(planExcelList, AdPlan.class);
|
||||
|
||||
String patternCode = dictDataService.getDictDataById(patternId).getCode();
|
||||
for (int i = 0; i < adPlans.size(); i++) {
|
||||
AdPlanExcel adPlanExcel = planExcelList.get(i);
|
||||
AdPlanParam adPlanParam = new AdPlanParam();
|
||||
adPlanParam.setName(adPlanExcel.getName());
|
||||
adPlanParam.setPattern(patternId);
|
||||
checkRepeat(adPlanParam, false);
|
||||
|
||||
AdPlanExcel.ImportData adPlanExcel = adPlanExcelList.get(i);
|
||||
String planId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
adPlans.get(i).setId(planId);
|
||||
adPlans.get(i).setPattern(patternId);
|
||||
Integer code = this.generateCode();
|
||||
adPlans.get(i).setCode(code);
|
||||
|
||||
tableGenService.deleteTable(Arrays.asList(code.toString()));
|
||||
tableGenService.genAdNonHarmonicTable(code.toString());
|
||||
|
||||
String source = adPlanExcel.getSource();
|
||||
String[] sourceNames = source.split(StrUtil.COMMA);
|
||||
@@ -257,22 +303,12 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
adPlanSourceService.addAdPlanSource(planId, sourceIds);
|
||||
|
||||
List<PqDev> pqDevs = adPlanExcel.getDevices().stream()
|
||||
.map(planExcel -> {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(planExcel, dev);
|
||||
dev.setPlanId(planId);
|
||||
dev.setPattern(patternId);
|
||||
return dev;
|
||||
}).collect(Collectors.toList());
|
||||
devList.addAll(pqDevs);
|
||||
List<CNDevExcel> cnDevExcelList = adPlanExcel.getDevices();
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId, planId);
|
||||
}
|
||||
// 逆向可视化
|
||||
this.reverseVisualize(adPlans);
|
||||
this.saveBatch(adPlans);
|
||||
|
||||
pqDevService.reverseVisualize(devList);
|
||||
pqDevService.saveBatch(devList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +356,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getBigTestItem(String planId) {
|
||||
public List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId) {
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
AdPlan adPlan = this.getById(planId);
|
||||
if (ObjectUtil.isNull(adPlan)) {
|
||||
@@ -330,8 +366,27 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
List<PqScriptDtls> scriptDtlsList = pqScriptDtlsService.listPqScriptDtlByScriptId(scriptId);
|
||||
|
||||
// 不合格项复检
|
||||
if (reCheckType == 0) {
|
||||
// List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
// allResultList.addAll(adHarmonicService.get(scriptId, null, devId, "-1", adPlan.getCode()));
|
||||
// allResultList.addAll(adNonHarmonicService.get(scriptId, null, devId, "-1", adPlan.getCode()));
|
||||
//
|
||||
// if (ObjectUtil.isNotEmpty(allResultList)) {
|
||||
// List<AdBaseResult> passList = allResultList.stream().filter(obj -> obj.getResultFlag() == 1).collect(Collectors.toList());
|
||||
// TreeSet<Integer> sortSet = passList.stream().map(AdBaseResult::getSort).collect(Collectors.toCollection(TreeSet::new));
|
||||
//
|
||||
// scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList());
|
||||
// }
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(Integer.valueOf(adPlan.getCode()));
|
||||
storageParam.setScriptId(adPlan.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
scriptDtlsList = scriptDtlsList.stream().filter(obj -> indexes.contains(obj.getScriptIndex())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Map<String, List<PqScriptDtls>> collect = scriptDtlsList.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptType, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
collect.forEach((key, value) -> {
|
||||
@@ -396,6 +451,142 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
.set(AdPlan::getTestState, CheckStateEnum.CHECKED.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse(List<String> ids) {
|
||||
SysTestConfig config = sysTestConfigService.getOneConfig();
|
||||
if (ObjectUtil.isNotNull(config)) {
|
||||
Integer maxTime = config.getMaxTime();
|
||||
List<AdPlan> planList = this.listByIds(ids);
|
||||
|
||||
planList.forEach(plan -> {
|
||||
if (!CheckStateEnum.CHECKED.getValue().equals(plan.getTestState())) {
|
||||
throw new BusinessException(PlanResponseEnum.NOT_CHECKED_PLAN_CANNOT_ANALYSE);
|
||||
}
|
||||
});
|
||||
|
||||
Map<String, List<String[]>> sheets = new TreeMap<>(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
if (o1.equals("概览")) {
|
||||
return -1;
|
||||
} else {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (planList.size() > 1) {
|
||||
StringBuffer allNote = new StringBuffer();
|
||||
List<PqDev> allDevList = new ArrayList<>();
|
||||
for (AdPlan plan : planList) {
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(plan.getId());
|
||||
List<PqDev> devList = pqDevService.listByPlanId(queryParam);
|
||||
devList = devList.stream().filter(x -> !x.getCheckResult().equals(CheckResultEnum.UNCHECKED.getValue())).collect(Collectors.toList());
|
||||
allDevList.addAll(devList);
|
||||
|
||||
allNote.append(plan.getName() + "计划" + devList.size() + "台,");
|
||||
if (plan.getName().equals("概览")) {
|
||||
sheets.put(plan.getName() + "检测计划", getRows(plan.getName(), devList, maxTime, getNote(plan, devList)));
|
||||
} else {
|
||||
sheets.put(plan.getName(), getRows(plan.getName(), devList, maxTime, getNote(plan, devList)));
|
||||
}
|
||||
}
|
||||
allNote.insert(0, "说明:总计" + allDevList.size() + "台设备,");
|
||||
allNote.replace(allNote.length() - 1, allNote.length(), "。");
|
||||
sheets.put("概览", getRows("数据分析结果-所有计划", allDevList, maxTime, allNote.toString()));
|
||||
} else {
|
||||
AdPlan plan = planList.get(0);
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(plan.getId());
|
||||
List<PqDev> devList = pqDevService.listByPlanId(queryParam);
|
||||
devList = devList.stream().filter(x -> !x.getCheckResult().equals(CheckResultEnum.UNCHECKED.getValue())).collect(Collectors.toList());
|
||||
|
||||
sheets.put(plan.getName(), getRows(plan.getName(), devList, maxTime, getNote(plan, devList)));
|
||||
}
|
||||
|
||||
exportPassRateExcel("数据分析结果.xlsx", maxTime, sheets);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取备注信息
|
||||
*
|
||||
* @param plan 检测计划
|
||||
* @param devList 设备列表
|
||||
* @return 备注信息
|
||||
*/
|
||||
private String getNote(AdPlan plan, List<PqDev> devList) {
|
||||
StringBuffer note = new StringBuffer();
|
||||
note.append("说明:本计划共有" + devList.size() + "台设备,");
|
||||
Map<String, List<PqDev>> devTypeMap = devList.stream().collect(Collectors.groupingBy(PqDev::getDevType, Collectors.toList()));
|
||||
devTypeMap.forEach((key, value) -> {
|
||||
DevType devType = devTypeService.getById(key);
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
note.append(devType.getName() + "型号" + value.size() + "台,");
|
||||
}
|
||||
});
|
||||
PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId());
|
||||
SysTestConfig config1 = sysTestConfigService.getConfig();
|
||||
if (ObjectUtil.isNotNull(config1)) {
|
||||
DictData dictData = dictDataService.getDictDataById(config1.getDataRule());
|
||||
if (ObjectUtil.isNotNull(errSys) && ObjectUtil.isNotNull(dictData)) {
|
||||
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData.getName() + "\"数据原则计算得出。");
|
||||
}
|
||||
}
|
||||
return note.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行数据
|
||||
*
|
||||
* @param header 表头
|
||||
* @param devList 设备列表
|
||||
* @param maxTime 最大复检次数
|
||||
* @param note 备注
|
||||
* @return
|
||||
*/
|
||||
private List<String[]> getRows(String header, List<PqDev> devList, Integer maxTime, String note) {
|
||||
List<String[]> rows = new ArrayList<>();
|
||||
String[] row1 = new String[]{header};
|
||||
|
||||
String[] row2 = new String[maxTime + 1];
|
||||
row2[0] = "\\";
|
||||
String[] row3 = new String[maxTime + 1];
|
||||
row3[0] = "合格数量";
|
||||
String[] row4 = new String[maxTime + 1];
|
||||
row4[0] = "总数量";
|
||||
String[] row5 = new String[maxTime + 1];
|
||||
row5[0] = "合格率";
|
||||
String[] row6 = new String[maxTime + 1];
|
||||
row6[0] = note;
|
||||
|
||||
long total = devList.size();
|
||||
|
||||
for (int i = 1; i <= maxTime; i++) {
|
||||
row2[i] = i + "次检测";
|
||||
int tempI = i;
|
||||
List<PqDev> tempDevList = devList.stream().filter(dev -> dev.getReCheckNum() <= tempI).collect(Collectors.toList());
|
||||
long passCount = tempDevList.stream().filter(dev -> dev.getCheckResult() == CheckResultEnum.ACCORD.getValue()).count();
|
||||
row3[i] = passCount + "";
|
||||
row4[i] = total + "";
|
||||
|
||||
if (total != 0) {
|
||||
row5[i] = String.format("%.2f%%", (float) passCount / total * 100);
|
||||
} else {
|
||||
row5[i] = "/";
|
||||
}
|
||||
}
|
||||
rows.add(row1);
|
||||
rows.add(row2);
|
||||
rows.add(row3);
|
||||
rows.add(row4);
|
||||
rows.add(row5);
|
||||
rows.add(row6);
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向可视化
|
||||
@@ -455,4 +646,257 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
throw new BusinessException(PlanResponseEnum.PLAN_REPEATED);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportPassRateExcel(String fileName, Integer maxTime, Map<String, List<String[]>> sheets) {
|
||||
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
|
||||
sheets.forEach((sheetName, rows) -> {
|
||||
XSSFSheet sheet = wb.createSheet(sheetName);
|
||||
|
||||
// 数据行
|
||||
CellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
XSSFFont headerFont = wb.createFont();
|
||||
headerFont.setFontName("Microsoft YaHei");
|
||||
headerFont.setBold(true);
|
||||
headerFont.setFontHeightInPoints((short) 14);
|
||||
cellStyle.setFont(headerFont);
|
||||
Row row0 = sheet.createRow(0);
|
||||
Cell row0Cell0 = row0.createCell(0);
|
||||
row0Cell0.setCellStyle(cellStyle);
|
||||
row0Cell0.setCellValue(rows.get(0)[0]);
|
||||
CellRangeAddress mergedRegion = new CellRangeAddress(0, 0, 0, 2 * maxTime + 1);
|
||||
sheet.addMergedRegion(mergedRegion);
|
||||
|
||||
CellStyle commoncellStyle = wb.createCellStyle();
|
||||
commoncellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
commoncellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
for (int i = 1; i < rows.size() - 1; i++) {
|
||||
String[] row = rows.get(i);
|
||||
Row createRow = sheet.createRow(i);
|
||||
for (int j = 0; j < row.length; j++) {
|
||||
Cell createCell = createRow.createCell(j);
|
||||
if (j == 0 || i == 1) {
|
||||
headerFont.setFontHeightInPoints((short) 11);
|
||||
createCell.setCellStyle(cellStyle);
|
||||
} else {
|
||||
createCell.setCellStyle(commoncellStyle);
|
||||
}
|
||||
if ("\\".equals(row[j])) {
|
||||
CreationHelper helper = wb.getCreationHelper();
|
||||
XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
||||
ClientAnchor anchor = helper.createClientAnchor();
|
||||
// 设置斜线的开始位置
|
||||
anchor.setCol1(j);
|
||||
anchor.setRow1(i);
|
||||
// 设置斜线的结束位置
|
||||
anchor.setCol2(j + 1);
|
||||
anchor.setRow2(i + 1);
|
||||
XSSFSimpleShape shape = drawing.createSimpleShape((XSSFClientAnchor) anchor);
|
||||
|
||||
// 设置形状类型为线型
|
||||
shape.setShapeType(ShapeTypes.LINE);
|
||||
// 设置线宽
|
||||
shape.setLineWidth(0.5);
|
||||
// 设置线的风格
|
||||
shape.setLineStyle(0);
|
||||
// 设置线的颜色
|
||||
shape.setLineStyleColor(0, 0, 0);
|
||||
} else {
|
||||
createCell.setCellValue(row[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row note = sheet.createRow(rows.size() - 1);
|
||||
Cell noteCell0 = note.createCell(0);
|
||||
commoncellStyle.setWrapText(true);
|
||||
noteCell0.setCellStyle(commoncellStyle);
|
||||
noteCell0.setCellValue(rows.get(rows.size() - 1)[0]);
|
||||
|
||||
mergedRegion = new CellRangeAddress(rows.size() - 1, rows.size() + 2, 0, maxTime);
|
||||
sheet.addMergedRegion(mergedRegion);
|
||||
|
||||
// 条形图
|
||||
XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
||||
// 前四个默认0,[0,5]:从0列5行开始;[6,16]:到6列16行结束
|
||||
// 默认宽度(14-8)*12
|
||||
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, maxTime + 1, 1, 2 * maxTime + 2, 25);
|
||||
// 创建一个chart对象
|
||||
XSSFChart chart = drawing.createChart(anchor);
|
||||
// 标题
|
||||
chart.setTitleText("检测结果分析");
|
||||
// 标题覆盖
|
||||
chart.setTitleOverlay(false);
|
||||
// 图例位置
|
||||
XDDFChartLegend legend = chart.getOrAddLegend();
|
||||
legend.setPosition(LegendPosition.TOP);
|
||||
// 分类轴标(X轴),标题位置
|
||||
XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);
|
||||
bottomAxis.setTitle("检测次数");
|
||||
// 值(Y轴)轴,标题位置
|
||||
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
|
||||
leftAxis.setTitle("合格率(%)");
|
||||
|
||||
// CellRangeAddress(起始行号,终止行号, 起始列号,终止列号)
|
||||
// 分类轴标(X轴)数据,单元格范围位置[1, 1]到[1, maxTime]
|
||||
XDDFDataSource<String> checkTimes = XDDFDataSourcesFactory.fromStringCellRange(sheet, new CellRangeAddress(1, 1, 1, maxTime));
|
||||
// 数据
|
||||
String[] rateStrArr = rows.get(rows.size() - 2);
|
||||
Double[] rateArr = new Double[maxTime];
|
||||
for (int i = 1; i < rateStrArr.length; i++) {
|
||||
if ("/".equals(rateStrArr[i])) {
|
||||
rateArr[i - 1] = 0.00;
|
||||
} else {
|
||||
rateArr[i - 1] = Double.parseDouble(rateStrArr[i].replace("%", ""));
|
||||
}
|
||||
}
|
||||
XDDFNumericalDataSource<Double> rate = XDDFDataSourcesFactory.fromArray(rateArr);
|
||||
|
||||
// bar:条形图,
|
||||
XDDFBarChartData bar = (XDDFBarChartData) chart.createData(ChartTypes.BAR, bottomAxis, leftAxis);
|
||||
|
||||
leftAxis.setCrossBetween(AxisCrossBetween.BETWEEN);
|
||||
// 设置为可变颜色
|
||||
bar.setVaryColors(true);// 这里可变颜色要设置成true,如果需要设置成自己想要的颜色,则置为false,然后在下面设置颜色
|
||||
// 条形图方向,纵向/横向:纵向
|
||||
bar.setBarDirection(BarDirection.COL);
|
||||
|
||||
// 图表加载数据,条形图1
|
||||
bar.addSeries(checkTimes, rate);
|
||||
|
||||
CTPlotArea plotArea = chart.getCTChart().getPlotArea();
|
||||
|
||||
CTBarSer serArray = plotArea.getBarChartArray(0).getSerArray(0);
|
||||
serArray.addNewDLbls();
|
||||
serArray.getDLbls().addNewShowVal().setVal(true);
|
||||
serArray.getDLbls().addNewShowLegendKey().setVal(false);
|
||||
serArray.getDLbls().addNewShowCatName().setVal(false);
|
||||
serArray.getDLbls().addNewShowSerName().setVal(false);
|
||||
|
||||
// 打印图表的xml
|
||||
//System.out.println(chart.getCTChart());
|
||||
|
||||
// 绘制
|
||||
chart.plot(bar);
|
||||
});
|
||||
|
||||
wb.write(outputStream);
|
||||
wb.close();
|
||||
} catch (IOException e) {
|
||||
log.error(">>> 导出数据异常:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<PullDown> getPullDownList() {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
|
||||
PullDown pullDown = null;
|
||||
// 检测脚本
|
||||
List<Map<String, Object>> maps1 = pqScriptService.listAllPqScript(null);
|
||||
List<String> scriptNameList = maps1.stream().map(m -> (String) m.get("name")).collect(Collectors.toList());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(3);
|
||||
pullDown.setLastCol(3);
|
||||
pullDown.setStrings(scriptNameList);
|
||||
pullDowns.add(pullDown);
|
||||
// 误差体系
|
||||
List<Map<String, Object>> maps2 = pqErrSysService.listAllPqErrSys();
|
||||
List<String> errSysNameList = maps2.stream().map(m -> (String) m.get("name")).collect(Collectors.toList());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(4);
|
||||
pullDown.setLastCol(4);
|
||||
pullDown.setStrings(errSysNameList);
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 是否做守时检测
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(5);
|
||||
pullDown.setLastCol(5);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 检测状态
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(6);
|
||||
pullDown.setLastCol(6);
|
||||
pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 报告生成状态
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
//检测结果
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(8);
|
||||
pullDown.setLastCol(8);
|
||||
pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 预投计划
|
||||
List<DictData> dictDataList = null;
|
||||
pullDown = new PullDown();
|
||||
|
||||
DictType dictType = dictTypeService.getByCode("Preinvestment_Plan");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(9);
|
||||
pullDown.setLastCol(9);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 设备类型
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(11);
|
||||
pullDown.setLastCol(11);
|
||||
pullDown.setStrings(devTypeService.listAll().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(12);
|
||||
pullDown.setLastCol(12);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 是否为加密版本
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(13);
|
||||
pullDown.setLastCol(13);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
|
||||
// 是否支持系数校准
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(16);
|
||||
pullDown.setLastCol(16);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.core.text.StrPool;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -27,9 +28,11 @@ 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.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.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
@@ -78,22 +81,27 @@ public class ReportServiceImpl implements IReportService {
|
||||
|
||||
@Override
|
||||
public void generateReport(DevReportParam devReportParam) {
|
||||
// 根据设备类型找到报告模板
|
||||
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("设备类型缺失,请联系管理员!");
|
||||
}
|
||||
DictData reportName = devTypeService.getReportName(pqDevVO.getDevType());
|
||||
if (Objects.isNull(reportName)) {
|
||||
throw new BusinessException("报告模板缺失,请联系管理员!");
|
||||
}
|
||||
// 读取模板文件
|
||||
ClassPathResource resource = new ClassPathResource("/model/BaseModel.docx");
|
||||
ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ".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);
|
||||
dealBaseModel(baseModelDocument, pqDevVO, devType);
|
||||
// 处理数据页中的信息
|
||||
dealDataModel(baseModelDocument, devReportParam, pqDevVO);
|
||||
// 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx
|
||||
@@ -124,7 +132,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
updateWrapper.set(AdPlan::getReportState, PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||
}
|
||||
adPlanService.update(updateWrapper);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
log.error("生成报告文件失败", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -179,14 +187,14 @@ public class ReportServiceImpl implements IReportService {
|
||||
*
|
||||
* @param baseModelDocument 模板文件
|
||||
*/
|
||||
private void dealBaseModel(XWPFDocument baseModelDocument, PqDevVO pqDevVO) {
|
||||
private void dealBaseModel(XWPFDocument baseModelDocument, PqDevVO pqDevVO, DevType devType) {
|
||||
// 首先获取非数据页中需要的信息
|
||||
Map<String, String> baseModelMap = new HashMap<>(16);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
baseModelMap.put("${devType}", devType.getName());
|
||||
// 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死
|
||||
baseModelMap.put("${userName}", "管理员");
|
||||
String userName = RequestUtil.getUserName();
|
||||
baseModelMap.put("${userName}", userName);
|
||||
// 调试日期
|
||||
if (pqDevVO.getCheckTime() != null) {
|
||||
baseModelMap.put("${testDate}", DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
|
||||
@@ -195,6 +203,8 @@ public class ReportServiceImpl implements IReportService {
|
||||
}
|
||||
// 装置编码
|
||||
baseModelMap.put("${CreateId}", pqDevVO.getCreateId());
|
||||
// 工作电源
|
||||
baseModelMap.put("${power}", devType.getPower());
|
||||
// 额定电流
|
||||
baseModelMap.put("${devCurr}", pqDevVO.getDevCurr().toString().concat("A"));
|
||||
// 额定电压
|
||||
@@ -226,7 +236,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
String scriptId = adPlan.getScriptId();
|
||||
Integer devChns = pqDevVO.getDevChns();
|
||||
for (int i = 1; i <= devChns; i++) {
|
||||
ClassPathResource resource = new ClassPathResource("/model/BaseDataModel.docx");
|
||||
ClassPathResource resource = new ClassPathResource("/model/report_table.docx");
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||
|
||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||
@@ -344,7 +354,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueT(singleNonHarmParam, dataModelMap, "FREQ55");
|
||||
|
||||
// 谐波电压,少了基波 todo...
|
||||
// 谐波电压
|
||||
testItemIndex = 10;
|
||||
pqScriptCheckDataService = "cce92410f1902897a61f644d875f2216";
|
||||
// 获取数据
|
||||
@@ -352,7 +362,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
singleNonHarmParam.setSort(testItemIndex);
|
||||
fillMapValueHarm(singleNonHarmParam, dataModelMap, "Uha", "Uhb", "Uhc", 57.74, 100);
|
||||
|
||||
// 谐波电电流,少了基波 todo...
|
||||
// 谐波电电流
|
||||
testItemIndex = 11;
|
||||
pqScriptCheckDataService = "3e5e384d38485ca4242152fba336de1d";
|
||||
// 获取数据
|
||||
@@ -399,38 +409,61 @@ public class ReportServiceImpl implements IReportService {
|
||||
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));
|
||||
// 基波
|
||||
String aBase = devValue(adHarmonicResult.getAValue1(), 1, 1);
|
||||
String bBase = devValue(adHarmonicResult.getBValue1(), 1, 1);
|
||||
String cBase = devValue(adHarmonicResult.getCValue1(), 1, 1);
|
||||
dataModelMap.put("${" + aSymbol + "1}", aBase);
|
||||
dataModelMap.put("${" + bSymbol + "1}", bBase);
|
||||
dataModelMap.put("${" + cSymbol + "1}", cBase);
|
||||
double aBaseValue = baseValue;
|
||||
double bBaseValue = baseValue;
|
||||
double cBaseValue = baseValue;
|
||||
|
||||
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));
|
||||
if (!aBase.equals(StrPool.SLASH)) {
|
||||
aBaseValue = Double.parseDouble(aBase);
|
||||
}
|
||||
if (!bBase.equals(StrPool.SLASH)) {
|
||||
bBaseValue = Double.parseDouble(bBase);
|
||||
}
|
||||
if (!cBase.equals(StrPool.SLASH)) {
|
||||
cBaseValue = Double.parseDouble(cBase);
|
||||
}
|
||||
|
||||
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 + "2}", devValue(adHarmonicResult.getAValue2(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "2}", devValue(adHarmonicResult.getBValue2(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "2}", devValue(adHarmonicResult.getCValue2(), cBaseValue, 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 + "5}", devValue(adHarmonicResult.getAValue5(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "5}", devValue(adHarmonicResult.getBValue5(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "5}", devValue(adHarmonicResult.getCValue5(), cBaseValue, 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 + "7}", devValue(adHarmonicResult.getAValue7(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "7}", devValue(adHarmonicResult.getBValue7(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "7}", devValue(adHarmonicResult.getCValue7(), cBaseValue, 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 + "11}", devValue(adHarmonicResult.getAValue11(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "11}", devValue(adHarmonicResult.getBValue11(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "11}", devValue(adHarmonicResult.getCValue11(), cBaseValue, 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));
|
||||
dataModelMap.put("${" + aSymbol + "23}", devValue(adHarmonicResult.getAValue23(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "23}", devValue(adHarmonicResult.getBValue23(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "23}", devValue(adHarmonicResult.getCValue23(), cBaseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "35}", devValue(adHarmonicResult.getAValue35(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "35}", devValue(adHarmonicResult.getBValue35(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "35}", devValue(adHarmonicResult.getCValue35(), cBaseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "43}", devValue(adHarmonicResult.getAValue43(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "43}", devValue(adHarmonicResult.getBValue43(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "43}", devValue(adHarmonicResult.getCValue43(), cBaseValue, percent));
|
||||
|
||||
dataModelMap.put("${" + aSymbol + "50}", devValue(adHarmonicResult.getAValue50(), aBaseValue, percent));
|
||||
dataModelMap.put("${" + bSymbol + "50}", devValue(adHarmonicResult.getBValue50(), bBaseValue, percent));
|
||||
dataModelMap.put("${" + cSymbol + "50}", devValue(adHarmonicResult.getCValue50(), cBaseValue, percent));
|
||||
|
||||
|
||||
}
|
||||
@@ -441,7 +474,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
if (Objects.nonNull(tempA) && Objects.nonNull(tempA.getData())) {
|
||||
return doubleRound(4, (tempA.getData() / percent) * baseValue);
|
||||
}
|
||||
return "/";
|
||||
return StrPool.SLASH;
|
||||
}
|
||||
|
||||
|
||||
@@ -474,7 +507,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
queryWrapper.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.in(PqScriptCheckData::getPhase, phase)
|
||||
.eq(PqScriptCheckData::getIndex, index);
|
||||
.eq(PqScriptCheckData::getScriptIndex, index);
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return list.get(0).getValueType();
|
||||
@@ -523,7 +556,7 @@ public class ReportServiceImpl implements IReportService {
|
||||
.eq(PqScriptDtls::getValue, value);
|
||||
List<PqScriptDtls> pqScriptDtls = pqScriptDtlsService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(pqScriptDtls)) {
|
||||
return pqScriptDtls.get(0).getIndex();
|
||||
return pqScriptDtls.get(0).getScriptIndex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -86,4 +86,16 @@ public class ResultController extends BaseController {
|
||||
|
||||
resultService.exportRawData(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/changeErrorSystem")
|
||||
@ApiOperation("更换误差体系")
|
||||
@ApiImplicitParam(name = "param", value = "修改参数", required = true)
|
||||
public HttpResult<Object> changeErrorSystem(@RequestBody ResultParam.ChangeErrorSystemParam param) {
|
||||
String methodDescribe = getMethodDescribe("changeErrorSystem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
resultService.changeErrorSystem(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,4 +64,28 @@ public class ResultParam {
|
||||
// 通道号,当为-1时,表示查询所有通道号,否则只查询指定通道号
|
||||
private String chnNum;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ChangeErrorSystemParam {
|
||||
@ApiModelProperty(value = "检测计划Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty(value = "脚本Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SCRIPT_ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty(value = "误差体系Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.ERROR_SYS_ID_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@ApiModelProperty(value = "设备Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.DEV_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_ID_FORMAT_ERROR)
|
||||
private String deviceId;
|
||||
|
||||
private Integer code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class FormContentVO {
|
||||
|
||||
private String scriptName;
|
||||
|
||||
private String errorSysName;
|
||||
private String errorSysId;
|
||||
|
||||
private String dataRule;
|
||||
|
||||
|
||||
@@ -17,6 +17,11 @@ public class TreeDataVO {
|
||||
*/
|
||||
private String scriptTypeName;
|
||||
|
||||
/**
|
||||
* code
|
||||
*/
|
||||
private String scriptTypeCode;
|
||||
|
||||
/**
|
||||
* 源下发的描述
|
||||
*/
|
||||
|
||||
@@ -45,4 +45,11 @@ public interface IResultService {
|
||||
* @param param
|
||||
*/
|
||||
void exportRawData(ResultParam param);
|
||||
|
||||
/**
|
||||
* 更换误差体系
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void changeErrorSystem(ResultParam.ChangeErrorSystemParam param);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -20,23 +26,31 @@ 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.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
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.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -60,6 +74,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
private final PqScriptMapper scriptMapper;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final TableGenMapper tableGenMapper;
|
||||
private final DetectionServiceImpl detectionServiceImpl;
|
||||
|
||||
/**
|
||||
* 谐波类code,取树形字典表中的code
|
||||
@@ -71,13 +87,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
public FormContentVO getFormContent(ResultParam.QueryParam queryParam) {
|
||||
FormContentVO formContentVO = new FormContentVO();
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
String scriptId = null;
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
scriptId = plan.getScriptId();
|
||||
adPlanService.visualize(Collections.singletonList(plan));
|
||||
}
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
formContentVO.setErrorSysName(plan.getErrorSysId());
|
||||
formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule());
|
||||
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
|
||||
|
||||
@@ -126,23 +142,25 @@ public class ResultServiceImpl implements IResultService {
|
||||
.selectAll(PqScriptDtls.class)
|
||||
.eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
.ne(PqScriptDtls::getIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(StrUtil.isNotBlank(param.getDevId()), PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
List<Integer> indexList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(param.getScriptType())) {
|
||||
indexList = pqScriptDtlsService.getIndexList(param.getScriptType(), param.getScriptId());
|
||||
}
|
||||
allResultList.addAll(adNonHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
allResultList.addAll(adHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
||||
if (CollUtil.isNotEmpty(allResultList)) {
|
||||
resultMap = allResultList.stream().collect(Collectors.groupingBy(AdBaseResult::getSort, Collectors.mapping(AdBaseResult::getResultFlag, Collectors.toSet())));
|
||||
if (StrUtil.isNotBlank(param.getDevId())) {
|
||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
List<Integer> indexList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(param.getScriptType())) {
|
||||
indexList = pqScriptDtlsService.getIndexList(param.getScriptType(), param.getScriptId());
|
||||
}
|
||||
allResultList.addAll(adNonHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
allResultList.addAll(adHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
if (CollUtil.isNotEmpty(allResultList)) {
|
||||
resultMap = allResultList.stream().collect(Collectors.groupingBy(AdBaseResult::getSort, Collectors.mapping(AdBaseResult::getResultFlag, Collectors.toSet())));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, List<PqScriptDtls>> dtlsSortMap = dtlsList.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptType, LinkedHashMap::new, Collectors.toList()));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(dtlsSortMap.keySet()));
|
||||
|
||||
@@ -165,29 +183,32 @@ public class ResultServiceImpl implements IResultService {
|
||||
//大相检测信息
|
||||
TreeDataVO infoVO = new TreeDataVO();
|
||||
infoVO.setScriptTypeName(dictTree.getName());
|
||||
infoVO.setScriptTypeCode(dictTree.getId());
|
||||
//额定条件下频率准确度测试
|
||||
LinkedHashMap<String, List<PqScriptDtls>> subTypeMap = value.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.filter(x -> "Base".equals(x.getScriptSubType()))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||
subTypeMap.forEach((subKey, subValue) -> {
|
||||
if (!"VOLTAGE".equals(dictTree.getCode())) {
|
||||
TreeDataVO subType = new TreeDataVO();
|
||||
subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeCode(subKey);
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||
indexMap.forEach((index, scriptDtlIndexList) -> {
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
dtlType.setIndex(index);
|
||||
dtlType.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dtlType.setScriptTypeCode(subKey);
|
||||
ratedScriptTypeName(scriptDtlIndexList, isValueType, dtlType, dictTree);
|
||||
dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString());
|
||||
if (finalResultMap.containsKey(index)) {
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
dtlType.setIndex(index);
|
||||
dtlType.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
ratedScriptTypeName(scriptDtlIndexList, isValueType, dtlType, dictTree);
|
||||
dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString());
|
||||
dtlType.setFly(conform(finalResultMap.get(index)));
|
||||
subTypeList.add(dtlType);
|
||||
}
|
||||
subTypeList.add(dtlType);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(subTypeList)) {
|
||||
subType.setChildren(subTypeList);
|
||||
@@ -195,7 +216,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
} else {
|
||||
dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂降测量准确度测试", 20, 85);
|
||||
dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂升测量准确度测试", 110, 180);
|
||||
dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂升测量准确度测试", 110, 200);
|
||||
dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压中断测量准确度测试", 0, 10);
|
||||
}
|
||||
|
||||
@@ -204,40 +225,43 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
//单影响量下频率准确度测试
|
||||
LinkedHashMap<String, List<PqScriptDtls>> subSingleTypeMap = value.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.filter(x -> !"Base".equals(x.getScriptSubType()))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||
if (CollUtil.isNotEmpty(subSingleTypeMap)) {
|
||||
TreeDataVO subType = new TreeDataVO();
|
||||
subType.setScriptTypeName(subName.get("Single").replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeName(!subName.containsKey("Single") ? "" : subName.get("Single").replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeCode(dictTree.getCode());
|
||||
//单影响量下频率准测量集合
|
||||
List<TreeDataVO> subSingleList = new ArrayList<>();
|
||||
subSingleTypeMap.forEach((subKey, subValue) -> {
|
||||
TreeDataVO treeDataVO = new TreeDataVO();
|
||||
treeDataVO.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
treeDataVO.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
treeDataVO.setScriptTypeCode(subKey);
|
||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
indexMap.forEach((index, scriptDtlIndexList) -> {
|
||||
if (finalResultMap.containsKey(index)) {
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
dtlType.setIndex(index);
|
||||
if ("Harm".equals(subKey)) {
|
||||
harmScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
if ("VOL".equals(subKey)) {
|
||||
volScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
if ("Freq".equals(subKey)) {
|
||||
freqScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString());
|
||||
dtlType.setFly(conform(finalResultMap.get(index)));
|
||||
subTypeList.add(dtlType);
|
||||
TreeDataVO dtlType = new TreeDataVO();
|
||||
dtlType.setIndex(index);
|
||||
dtlType.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dtlType.setScriptTypeCode(subKey);
|
||||
if ("Harm".equals(subKey)) {
|
||||
harmScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
|
||||
if ("VOL".equals(subKey)) {
|
||||
volScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
if ("Freq".equals(subKey)) {
|
||||
freqScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType);
|
||||
}
|
||||
dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString());
|
||||
if (finalResultMap.containsKey(index)) {
|
||||
dtlType.setFly(conform(finalResultMap.get(index)));
|
||||
}
|
||||
subTypeList.add(dtlType);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(subTypeList)) {
|
||||
treeDataVO.setChildren(subTypeList);
|
||||
@@ -263,23 +287,25 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<PqScriptDtls> dip = subValue.stream()
|
||||
.filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
||||
.filter(x -> x.getTransValue() >= start && x.getTransValue() <= end)
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.toList());
|
||||
TreeDataVO vo = new TreeDataVO();
|
||||
vo.setScriptTypeName(name);
|
||||
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
||||
TreeDataVO dlt;
|
||||
for (PqScriptDtls dtls : dip) {
|
||||
if (finalResultMap.containsKey(dtls.getIndex())) {
|
||||
dlt = new TreeDataVO();
|
||||
List<PqScriptDtls> scriptDtlIndexList = subValue.stream().filter(x -> dtls.getIndex().equals(x.getIndex())).collect(Collectors.toList());
|
||||
//特征幅值=20%Un,持续时间=1周波
|
||||
dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波");
|
||||
dlt.setIndex(dtls.getIndex());
|
||||
dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString());
|
||||
dlt.setFly(conform(finalResultMap.get(dtls.getIndex())));
|
||||
info.add(dlt);
|
||||
dlt = new TreeDataVO();
|
||||
List<PqScriptDtls> scriptDtlIndexList = subValue.stream().filter(x -> dtls.getScriptIndex().equals(x.getScriptIndex())).collect(Collectors.toList());
|
||||
//特征幅值=20%Un,持续时间=1周波
|
||||
dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波");
|
||||
dlt.setIndex(dtls.getScriptIndex());
|
||||
dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dlt.setScriptTypeCode("Base_" + start + "_" + end);
|
||||
dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString());
|
||||
if (finalResultMap.containsKey(dtls.getScriptIndex())) {
|
||||
dlt.setFly(conform(finalResultMap.get(dtls.getScriptIndex())));
|
||||
}
|
||||
info.add(dlt);
|
||||
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
@@ -393,7 +419,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
case IMBV:
|
||||
List<PqScriptCheckData> list = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, scriptDtlIndexList.get(0).getScriptIndex())
|
||||
);
|
||||
//三相负序电压不平衡度=0%
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + list.get(0).getValue() + ResultUnitEnum.IMBV.getUnit());
|
||||
@@ -404,7 +430,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
case IMBA:
|
||||
List<PqScriptCheckData> imba = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, scriptDtlIndexList.get(0).getScriptIndex())
|
||||
);
|
||||
//三相负序电流不平衡度=0%
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + imba.get(0).getValue() + ResultUnitEnum.IMBV.getUnit());
|
||||
@@ -762,7 +788,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
.select(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.isNotNull(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
harmNum = list.stream().sorted(Comparator.comparing(PqScriptCheckData::getHarmNum))
|
||||
.map(PqScriptCheckData::getHarmNum).distinct().collect(Collectors.toList());
|
||||
@@ -795,7 +821,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
.select(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.isNotNull(PqScriptCheckData::getHarmNum)
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
harmNum = list.stream().sorted(Comparator.comparing(PqScriptCheckData::getHarmNum))
|
||||
.map(PqScriptCheckData::getHarmNum).distinct().collect(Collectors.toList());
|
||||
@@ -833,6 +859,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeErrorSystem(ResultParam.ChangeErrorSystemParam param) {
|
||||
this.createTempResultTable(param.getCode() + "");
|
||||
this.insertTempResultTable(param.getPlanId(), param.getScriptId(), param.getCode() + "", param.getErrorSysId(), param.getDeviceId());
|
||||
}
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
if (numbers.size() > 1) {
|
||||
@@ -853,4 +886,162 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拷贝结果表
|
||||
*
|
||||
* @param code
|
||||
*/
|
||||
private void createTempResultTable(String code) {
|
||||
tableGenMapper.genAdHarmonicTable("drop table if exists AD_Non_Harmonic_Result_" + code + "_temp,AD_Harmonic_Result_" + code + "_temp");
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code + "_temp");
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
StringBuilder C = new StringBuilder();
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
if (i == 1) {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT 'C相基波',");
|
||||
} else {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
}
|
||||
}
|
||||
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "_temp (\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
|
||||
" Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" +
|
||||
" Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',\n" +
|
||||
A + B + C +
|
||||
" PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)\n" +
|
||||
") COMMENT='监测数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改拷贝后的结果表(根据误差体系修改)
|
||||
*
|
||||
* @param planId
|
||||
* @param code
|
||||
* @param errorSysId
|
||||
* @param devId
|
||||
*/
|
||||
private void insertTempResultTable(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setCode(code);
|
||||
param.setErrorSysId(errorSysId);
|
||||
param.setDevIds(Arrays.asList(devId));
|
||||
param.setCode(code + "_temp");
|
||||
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
// PqDev dev = pqDevService.getById(devId);
|
||||
devIdMapComm.put(devId, devId);
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
DictDataEnum dataRule;
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(code, devId);
|
||||
LinkedHashMap<Integer, List<AdNonHarmonicResult>> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<AdHarmonicResult> allHarmonicRawData = adHarmonicService.lisAll(code, devId);
|
||||
LinkedHashMap<Integer, List<AdHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(planId);
|
||||
// issueParam.setSourceId();
|
||||
// issueParam.setScriptType();
|
||||
// issueParam.setScriptSubType();
|
||||
|
||||
issueParam.setDevIds(Arrays.asList(devId));
|
||||
issueParam.setScriptId(scriptId);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
|
||||
sourceIssues.forEach(sourceIssue -> {
|
||||
List<AdNonHarmonicResult> nonHarmonicResults = nonHarmonicMap.get(sourceIssue.getIndex());
|
||||
List<AdHarmonicResult> harmonicResults = harmonicMap.get(sourceIssue.getIndex());
|
||||
List<DevData> realDataXiList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(nonHarmonicResults)) {
|
||||
realDataXiList.addAll(MsgUtil.toList(nonHarmonicResults, null, true));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harmonicResults)) {
|
||||
DictTree dictTree = dictTreeService.getById(harmonicResults.get(0).getAdType());
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) {
|
||||
realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, true));
|
||||
} else {
|
||||
realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < realDataXiList.size(); i++) {
|
||||
DevData devData = realDataXiList.get(i);
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarm = devData.getSqlDataHarm();
|
||||
if (CollUtil.isNotEmpty(sqlDataHarm)) {
|
||||
for (int j = 0; j < sqlDataHarm.size(); j++) {
|
||||
DevData.SqlDataHarmDTO sqlDataDTO = sqlDataHarm.get(j);
|
||||
String desc = sqlDataDTO.getDesc();
|
||||
if (StrUtil.isNotBlank(desc)) {
|
||||
DictTree dictTree = dictTreeService.getById(desc);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DevData.SqlDataDTO> sqlData = devData.getSqlData();
|
||||
if (CollUtil.isNotEmpty(sqlData)) {
|
||||
for (int j = 0; j < sqlData.size(); j++) {
|
||||
DevData.SqlDataDTO sqlDataDTO = sqlData.get(j);
|
||||
String desc = sqlDataDTO.getDesc();
|
||||
if (StrUtil.isNotBlank(desc)) {
|
||||
DictTree dictTree = dictTreeService.getById(desc);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
if (CollUtil.isNotEmpty(harmonicResults)) {
|
||||
// if (dictTree.getCode().contains("V")) {
|
||||
// sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
// }
|
||||
// if (dictTree.getCode().contains("I")) {
|
||||
// sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
// }
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
}
|
||||
if (DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
}
|
||||
// if (DetectionCodeEnum.SV_1_49.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
// if (DetectionCodeEnum.SI_1_49.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
// if (DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
} else {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.njcn.gather.script.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
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.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
@@ -59,12 +60,12 @@ public class PqScriptController extends BaseController {
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测脚本")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated PqScriptParam param) {
|
||||
public HttpResult<String> add(@RequestBody @Validated PqScriptParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqScriptService.addPqScript(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
String result = pqScriptService.addPqScript(param);
|
||||
if (StrUtil.isNotBlank(result)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
@@ -101,7 +102,7 @@ public class PqScriptController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("getScriptDtlsByScriptId")
|
||||
@GetMapping("/getScriptDtlsByScriptId")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<PqScriptDtls>> getScriptDtlsByScriptId(@RequestParam("id") String id) {
|
||||
@@ -139,19 +140,73 @@ public class PqScriptController extends BaseController {
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("dls")
|
||||
@PostMapping("/dlsDetails")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<SourceIssue>> dls(@RequestBody PqScriptIssueParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
@ApiImplicitParam(name = "param", value = "检测脚本", required = true)
|
||||
public HttpResult<List<SourceIssue>> dlsDetails(@RequestBody PqScriptIssueParam param) {
|
||||
String methodDescribe = getMethodDescribe("dlsDetails");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param);
|
||||
for (SourceIssue sourceIssue : sourceIssues) {
|
||||
String jsonString = JSON.toJSONString(sourceIssue,SerializerFeature.WriteNullStringAsEmpty);
|
||||
System.out.println();
|
||||
}
|
||||
String jsonString =sourceIssues.get(0).toString();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/addScriptDtls")
|
||||
@ApiOperation("添加检测脚本")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> addScriptDtls(@RequestBody PqScriptDtlsParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("addScriptDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.saveScriptDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/scriptDtlsCheckDataList")
|
||||
@ApiOperation("根据通讯参数生成装置下发原始数据公式")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<List<PqScriptDtlsParam.CheckData>> scriptDtlsCheckDataList(@RequestBody PqScriptDtlsParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("scriptDtlsCheckDataList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
List<PqScriptDtlsParam.CheckData> checkData = pqScriptDtlsService.scriptDtlsCheckDataList(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData , methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/deleteDtls")
|
||||
@ApiOperation("删除脚本")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> deleteDtls(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("deleteDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.deleteDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/updateDtls")
|
||||
@ApiOperation("启用关闭脚本")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> updateDtls(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("updateDtls");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
Boolean b = pqScriptDtlsService.updateDtls(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/checkDataList")
|
||||
@ApiOperation("通讯脚本回显")
|
||||
@ApiImplicitParam(name = "sourceIssue", value = "检测脚本", required = true)
|
||||
public HttpResult<List<PqScriptCheckData>> checkDataList(@RequestBody @Validated ScriptParam sourceIssue) {
|
||||
String methodDescribe = getMethodDescribe("checkDataList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue);
|
||||
List<PqScriptCheckData> checkData = pqScriptDtlsService.checkDataList(sourceIssue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -9,5 +10,11 @@ import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
*/
|
||||
public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> {
|
||||
|
||||
/**
|
||||
* 获取当前检测脚本最大index值
|
||||
* @param scriptId
|
||||
* @return
|
||||
*/
|
||||
Integer selectMaxIndex(@Param("scriptId") String scriptId);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
@@ -18,5 +20,13 @@ public interface PqScriptMapper extends MPJBaseMapper<PqScript> {
|
||||
* @Date: 2024/12/16 18:08
|
||||
*/
|
||||
Boolean selectScriptIsValueType(@Param("scriptId") String scriptId);
|
||||
|
||||
/**
|
||||
* 根据脚本id获取绑定的计划数量
|
||||
*
|
||||
* @param scriptIds
|
||||
* @return
|
||||
*/
|
||||
Integer getBoundCountByScriptIds(@Param("scriptIds") List<String> scriptIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,15 @@
|
||||
<mapper namespace="com.njcn.gather.script.mapper.PqScriptDtlsMapper">
|
||||
|
||||
|
||||
<select id="selectMaxIndex" resultType="java.lang.Integer">
|
||||
|
||||
SELECT
|
||||
IFNULL( max( t.Script_Index ), -1 ) AS num
|
||||
FROM
|
||||
pq_script_dtls t
|
||||
WHERE
|
||||
Script_Id = #{scriptId}
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -12,5 +12,16 @@
|
||||
State=1
|
||||
and Id = #{scriptId}
|
||||
</select>
|
||||
<select id="getBoundCountByScriptIds" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM ad_plan
|
||||
<if test="scriptIds !=null and scriptIds.size()!=0">
|
||||
<where>
|
||||
AND Script_Id in
|
||||
<foreach collection="scriptIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.njcn.gather.script.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-10
|
||||
*/
|
||||
public interface PqScriptValidMessage {
|
||||
String INDEX_NOT_NULL = "index不能为空";
|
||||
|
||||
String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.script.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-10
|
||||
*/
|
||||
@Getter
|
||||
public enum ScriptResponseEnum {
|
||||
SCRIPT_BOUND_NOT_DELETE("A020001", "脚本已被计划所绑定,无法删除!");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
ScriptResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,12 @@ public class PqScriptCheckDataParam {
|
||||
@ApiModelProperty("总检测脚本中的测试项序号")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty("检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)")
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("相别,字典表")
|
||||
private String phase;
|
||||
|
||||
@ApiModelProperty("检测指标类型(true:code(I$real) ,false展示id ,默认false)")
|
||||
private Boolean isValueTypeName=false;
|
||||
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
package com.njcn.gather.script.pojo.param;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
public class PqScriptDtlsParam {
|
||||
|
||||
/**
|
||||
* 检测脚本
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 检测脚本类型
|
||||
*/
|
||||
private String scriptType;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 多量响量
|
||||
*/
|
||||
@JSONField(name = "subType", ordinal = 3)
|
||||
private String subType;
|
||||
|
||||
/**
|
||||
* 检测序号
|
||||
*/
|
||||
private Integer index;
|
||||
|
||||
/**
|
||||
* 被检设备额定电压
|
||||
*/
|
||||
@JSONField(name = "fUn", ordinal = 4)
|
||||
private Double fUn;
|
||||
|
||||
/**
|
||||
* 被检设备额定电流
|
||||
*/
|
||||
@JSONField(name = "fIn", ordinal = 5)
|
||||
private Double fIn;
|
||||
|
||||
/**
|
||||
* 频率
|
||||
*/
|
||||
@JSONField(name = "fFreq", ordinal = 6)
|
||||
private Double fFreq;
|
||||
|
||||
@JSONField(name = "retryCompute", ordinal = 6)
|
||||
private Boolean retryCompute = false;
|
||||
/**
|
||||
* 装置下发参数
|
||||
*/
|
||||
@JSONField(name = "channelList", ordinal = 7)
|
||||
private List<CheckData> checkDataList;
|
||||
|
||||
/**
|
||||
* 通道信息
|
||||
*/
|
||||
@JSONField(name = "channelList", ordinal = 8)
|
||||
private List<ChannelListDTO> channelList;
|
||||
|
||||
@Data
|
||||
public static class CheckData {
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 检测指标类型父id
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Double value;
|
||||
|
||||
/**
|
||||
* (间)谐波次数
|
||||
*/
|
||||
private Double harmNum;
|
||||
|
||||
/**
|
||||
* 状态:0-不启用 1-启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 是否参与误差比较:0-不参与 1-参与
|
||||
*/
|
||||
private Integer errorFlag;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ChannelListDTO {
|
||||
|
||||
/**
|
||||
* 通道使能标志
|
||||
*/
|
||||
@JSONField(name = "channelFlag", ordinal = 1)
|
||||
private Boolean channelFlag;
|
||||
|
||||
/**
|
||||
* 谐波使能标志
|
||||
*/
|
||||
@JSONField(name = "harmFlag", ordinal = 2)
|
||||
private Boolean harmFlag;
|
||||
|
||||
/**
|
||||
* 间谐波使能标志
|
||||
*/
|
||||
@JSONField(name = "inHarmFlag", ordinal = 3)
|
||||
private Boolean inHarmFlag;
|
||||
|
||||
/**
|
||||
* 暂态使能标志
|
||||
*/
|
||||
@JSONField(name = "dipFlag", ordinal = 4)
|
||||
private Boolean dipFlag;
|
||||
|
||||
/**
|
||||
* 闪变使能标志
|
||||
*/
|
||||
@JSONField(name = "flickerFlag", ordinal = 5)
|
||||
private Boolean flickerFlag;
|
||||
|
||||
/**
|
||||
* 通道信息 枚举类型,包括{Ua, Ub, Uc, Ux, Ia, Ib, Ic, Ix ,NULL}
|
||||
*/
|
||||
@JSONField(name = "channelType", ordinal = 6)
|
||||
private String channelType;
|
||||
|
||||
/**
|
||||
* 幅值
|
||||
*/
|
||||
@JSONField(name = "fAmp", ordinal = 7)
|
||||
private Double fAmp;
|
||||
|
||||
/**
|
||||
* 相角
|
||||
*/
|
||||
@JSONField(name = "fPhase", ordinal = 8)
|
||||
private Double fPhase;
|
||||
|
||||
/**
|
||||
* 谐波叠加列表
|
||||
*/
|
||||
@JSONField(name = "harmList", ordinal = 9)
|
||||
private List<HarmModel> harmList;
|
||||
|
||||
/**
|
||||
* 间谐波叠加列表
|
||||
*/
|
||||
@JSONField(name = "inharmList", ordinal = 10)
|
||||
private List<InharmModel> inharmList;
|
||||
|
||||
/**
|
||||
* 暂态数据
|
||||
*/
|
||||
@JSONField(name = "dipData", ordinal = 11)
|
||||
private DipDataDTO dipData;
|
||||
|
||||
/**
|
||||
* 闪变数据
|
||||
*/
|
||||
@JSONField(name = "flickerData", ordinal = 12)
|
||||
private FlickerDataDTO flickerData;
|
||||
|
||||
|
||||
/**
|
||||
* 谐波叠加列表
|
||||
*/
|
||||
@Data
|
||||
public static class HarmModel {
|
||||
|
||||
/**
|
||||
* 谐波次数
|
||||
*/
|
||||
@JSONField(name = "harm", ordinal = 1)
|
||||
private Double harm;
|
||||
|
||||
/**
|
||||
* 谐波含有率
|
||||
*/
|
||||
@JSONField(name = "fAmp", ordinal = 2)
|
||||
private Double fAmp;
|
||||
|
||||
/**
|
||||
* 谐波相角
|
||||
*/
|
||||
@JSONField(name = "fPhase", ordinal = 3)
|
||||
private Double fPhase;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 间谐波叠加列表
|
||||
*/
|
||||
@Data
|
||||
public static class InharmModel {
|
||||
|
||||
/**
|
||||
* 间谐波次数
|
||||
*/
|
||||
@JSONField(name = "inharm", ordinal = 1)
|
||||
private Double inharm;
|
||||
|
||||
/**
|
||||
* 间谐波含有率
|
||||
*/
|
||||
@JSONField(name = "fAmp", ordinal = 2)
|
||||
private Double fAmp;
|
||||
|
||||
/**
|
||||
* 间谐波相角
|
||||
*/
|
||||
@JSONField(name = "fPhase", ordinal = 3)
|
||||
private Double fPhase;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂态数据
|
||||
*/
|
||||
@Data
|
||||
public static class DipDataDTO {
|
||||
|
||||
/**
|
||||
* 暂态幅值(%)
|
||||
*/
|
||||
@JSONField(name = "fTransValue", ordinal = 1)
|
||||
private Double fTransValue;
|
||||
|
||||
/**
|
||||
* 暂态前时间(s)
|
||||
*/
|
||||
@JSONField(name = "fPreTime", ordinal = 2)
|
||||
private Double fPreTime;
|
||||
|
||||
/**
|
||||
* 写入时间(s)
|
||||
*/
|
||||
@JSONField(name = "fRampIn", ordinal = 3)
|
||||
private Double fRampIn;
|
||||
|
||||
/**
|
||||
* 暂态持续时间(s)
|
||||
*/
|
||||
@JSONField(name = "fRetainTime", ordinal = 4)
|
||||
private Double fRetainTime;
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private Double retainTime;
|
||||
|
||||
/**
|
||||
* 写出时间(s)
|
||||
*/
|
||||
@JSONField(name = "fRampOut", ordinal = 5)
|
||||
private Double fRampOut;
|
||||
|
||||
/**
|
||||
* 暂态后时间(s)
|
||||
*/
|
||||
@JSONField(name = "fAfterTime", ordinal = 6)
|
||||
private Double fAfterTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 闪变数据
|
||||
*/
|
||||
@Data
|
||||
public static class FlickerDataDTO {
|
||||
|
||||
/**
|
||||
* 波动类型
|
||||
*/
|
||||
@JSONField(name = "waveFluType", ordinal = 1)
|
||||
private String waveFluType;
|
||||
|
||||
/**
|
||||
* 闪变调制波形类型
|
||||
*/
|
||||
@JSONField(name = "waveType", ordinal = 2)
|
||||
private String waveType;
|
||||
|
||||
/**
|
||||
* 闪变标准值
|
||||
*/
|
||||
@JSONField(name = "waveType", ordinal = 2)
|
||||
private Double flickerValue;
|
||||
|
||||
|
||||
/**
|
||||
* 占空比
|
||||
*/
|
||||
@JSONField(name = "fDutyCycle", ordinal = 3)
|
||||
private Double fDutyCycle;
|
||||
|
||||
/**
|
||||
* 变动次数
|
||||
*/
|
||||
@JSONField(name = "fChagFre", ordinal = 4)
|
||||
private Double fChagFre;
|
||||
|
||||
/**
|
||||
* 变动量
|
||||
*/
|
||||
@JSONField(name = "fChagValue", ordinal = 5)
|
||||
private Double fChagValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,13 @@ public class PqScriptIssueParam {
|
||||
private String sourceId;
|
||||
|
||||
private List<Integer> indexList;
|
||||
|
||||
@ApiModelProperty("检测脚本类型")
|
||||
private String scriptType;
|
||||
|
||||
@ApiModelProperty("表明指标类型(例如:Freq频率下的影响、Base额定下的影响、VOL电压下的影响)")
|
||||
private String scriptSubType;
|
||||
|
||||
@ApiModelProperty("脚本下发类型")
|
||||
private int type;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.gather.script.pojo.param;
|
||||
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/18
|
||||
*/
|
||||
@Data
|
||||
public class ScriptParam {
|
||||
|
||||
@ApiModelProperty("检测脚本id")
|
||||
@NotBlank(message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty("检测脚本类型")
|
||||
private String scriptType;
|
||||
|
||||
@ApiModelProperty("检测脚本序号")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty("是否启用脚本(状态:0-不启用 1-启用)")
|
||||
private Integer enable;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -16,7 +17,7 @@ public class PqScriptCheckData implements Serializable {
|
||||
/**
|
||||
* 检测脚本参考设定值ID
|
||||
*/
|
||||
@TableId
|
||||
@TableId(value = "Id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,8 @@ public class PqScriptCheckData implements Serializable {
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
private Integer index;
|
||||
@TableField("Script_Index")
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.gather.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -18,6 +20,7 @@ public class PqScriptDtls implements Serializable {
|
||||
/**
|
||||
* 检测脚本子表ID
|
||||
*/
|
||||
@TableId(value = "Id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
@@ -29,8 +32,8 @@ public class PqScriptDtls implements Serializable {
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
@TableField("Index")
|
||||
private Integer index;
|
||||
@TableField("Script_Index")
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 检测脚本类型
|
||||
|
||||
@@ -18,8 +18,14 @@ public class SourceIssue {
|
||||
/**
|
||||
* 检测小项dtls Id
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private Integer enable;
|
||||
/**
|
||||
* 源ID
|
||||
*/
|
||||
@@ -275,13 +281,19 @@ public class SourceIssue {
|
||||
* 波动类型
|
||||
*/
|
||||
@JSONField(name = "waveFluType", ordinal = 1)
|
||||
private Object waveFluType;
|
||||
private String waveFluType;
|
||||
|
||||
/**
|
||||
* 闪变调制波形类型
|
||||
*/
|
||||
@JSONField(name = "waveType", ordinal = 2)
|
||||
private Object waveType;
|
||||
private String waveType;
|
||||
|
||||
/**
|
||||
* 闪变标准值
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private Double flickerValue;
|
||||
|
||||
/**
|
||||
* 占空比
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.njcn.gather.script.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PqScriptCheckDataVO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
private String valueTypeId;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
*/
|
||||
private String valueTypeCode;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.gather.script.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PqScriptDtlDataVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 这条检测脚本的序号
|
||||
*/
|
||||
private String index;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -34,4 +34,5 @@ public interface IPqScriptCheckDataService extends IService<PqScriptCheckData> {
|
||||
*/
|
||||
List<PqScriptCheckData> listCheckDataCode(PqScriptCheckDataParam param);
|
||||
|
||||
Double getCheckDataValue(PqScriptCheckDataParam param);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.njcn.gather.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
|
||||
@@ -61,6 +64,7 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
*/
|
||||
List<SourceIssue> listSourceIssue(PqScriptIssueParam param);
|
||||
|
||||
|
||||
/**
|
||||
* 根据脚本类型、脚本id获取index列表
|
||||
*
|
||||
@@ -69,4 +73,39 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
* @return index列表
|
||||
*/
|
||||
List<Integer> getIndexList(String scriptType, String scriptId);
|
||||
|
||||
/**
|
||||
* 检测脚本单次小项数据新增
|
||||
* @param sourceIssue
|
||||
* @return
|
||||
*/
|
||||
Boolean saveScriptDtls(PqScriptDtlsParam sourceIssue);
|
||||
|
||||
/**
|
||||
* 根据通讯参数生成装置下发原始数据公式
|
||||
* @return
|
||||
*/
|
||||
List<PqScriptDtlsParam.CheckData> scriptDtlsCheckDataList(PqScriptDtlsParam sourceIssue);
|
||||
|
||||
/**
|
||||
* 删除脚本
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteDtls(ScriptParam param);
|
||||
|
||||
/**
|
||||
* 启用关闭脚本
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Boolean updateDtls(ScriptParam param);
|
||||
|
||||
/**
|
||||
* 通讯脚本回显
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<PqScriptCheckData> checkDataList(ScriptParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* @param param 检测脚本
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean addPqScript(PqScriptParam param);
|
||||
String addPqScript(PqScriptParam param);
|
||||
|
||||
/**
|
||||
* 删除检测脚本
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
@@ -16,9 +19,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -32,10 +33,7 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
|
||||
|
||||
private final String V="real$V2-50";
|
||||
private final String SV="real$SV_1-49";
|
||||
private final String I="real$I2-50";
|
||||
private final String IV="real$SI_1-49";
|
||||
private final String REAL="real$";
|
||||
|
||||
private final DictTreeMapper dictTreeMapper;
|
||||
|
||||
@@ -45,7 +43,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
queryWrapper.selectAll(PqScriptCheckData.class)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
if (param.getIsValueTypeName()) {
|
||||
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
|
||||
@@ -54,17 +52,19 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
if(CollUtil.isNotEmpty(pqScriptCheckData)){
|
||||
if (param.getIsValueTypeName()) {
|
||||
List<String> checkData = pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).distinct().collect(Collectors.toList());
|
||||
if(!checkData.contains("real$U1")){
|
||||
if(checkData.contains(V)||checkData.contains(SV)){
|
||||
checkData.add("real$U1");
|
||||
String U = REAL + DetectionCodeEnum.U1.getCode();
|
||||
if(!checkData.contains(U)){
|
||||
if(checkData.contains(REAL+DetectionCodeEnum.V2_50.getCode())){
|
||||
checkData.add(U);
|
||||
}
|
||||
}
|
||||
if(!checkData.contains("real$I1")){
|
||||
if(checkData.contains(I)||checkData.contains(IV)){
|
||||
checkData.add("real$I1");
|
||||
String I = REAL + DetectionCodeEnum.I1.getCode();
|
||||
if(!checkData.contains(I)){
|
||||
if(checkData.contains(REAL+DetectionCodeEnum.I2_50.getCode())){
|
||||
checkData.add(I);
|
||||
}
|
||||
}
|
||||
return checkData;
|
||||
return checkData.stream().distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
}
|
||||
@@ -79,6 +79,9 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
List<PqScriptCheckData> pqScriptCheckData = this.baseMapper.selectList(queryWrapper);
|
||||
if(CollUtil.isEmpty(pqScriptCheckData)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"测试脚本项暂无配置");
|
||||
}
|
||||
List<String> valueTypeList = pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
LambdaQueryWrapper<DictTree> dictTreeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictTreeLambdaQueryWrapper.in(DictTree::getId,valueTypeList).eq(DictTree::getState,DataStateEnum.DELETED.getCode());
|
||||
@@ -94,10 +97,27 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.selectAs(DictTree::getCode, PqScriptCheckData::getValueTypeCode)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptCheckData::getIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
return this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getCheckDataValue(PqScriptCheckDataParam param) {
|
||||
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getValueType, param.getValueType())
|
||||
.eq(PqScriptCheckData::getPhase, param.getPhase())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
|
||||
PqScriptCheckData data = this.getBaseMapper().selectOne(queryWrapper);
|
||||
if(ObjectUtil.isNotNull(data)){
|
||||
return data.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,18 +2,24 @@ package com.njcn.gather.script.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
||||
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
@@ -21,7 +27,9 @@ 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.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -71,7 +80,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final IPqDevService pqDevService;
|
||||
private final PqScriptMapper pqScriptMapper;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final PqScriptCheckDataMapper pqScriptCheckDataMapper;
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -107,31 +118,47 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.leftJoin(PqScript.class, PqScript::getId, PqScriptDtls::getScriptId)
|
||||
.eq(PqScript::getState, DataStateEnum.ENABLE.getCode())
|
||||
.eq(StrUtil.isNotBlank(scriptId), PqScriptDtls::getScriptId, scriptId);
|
||||
.eq(StrUtil.isNotBlank(scriptId), PqScriptDtls::getScriptId, scriptId)
|
||||
.eq(PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceIssue> listSourceIssue(PqScriptIssueParam param) {
|
||||
List<SourceIssue> sourceIssues = new ArrayList<>();
|
||||
//校验终端额定电压电流是否相同
|
||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
||||
.eq(PqDev::getPlanId, param.getPlanId())
|
||||
.in(PqDev::getId, param.getDevIds())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet());
|
||||
List<DevType> devTypes = devTypeService.listByIds(devTypeSet);
|
||||
Set<Double> voltSet = new HashSet<>(1);
|
||||
Set<Double> currSet = new HashSet<>(1);
|
||||
boolean devFly = CollUtil.isNotEmpty(param.getDevIds());
|
||||
if (devFly) {
|
||||
//校验终端额定电压电流是否相同
|
||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
||||
.eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId())
|
||||
.in(PqDev::getId, param.getDevIds())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet());
|
||||
List<DevType> devTypes = devTypeService.listByIds(devTypeSet);
|
||||
//额定电压信息
|
||||
voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
|
||||
//额定电流信息
|
||||
currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
|
||||
} else {
|
||||
if (param.getType() == 0) {
|
||||
voltSet.add(1.0);
|
||||
currSet.add(1.0);
|
||||
param.setIsPhaseSequence("-1");
|
||||
} else if (param.getType() == 1) {
|
||||
voltSet.add(57.74);
|
||||
currSet.add(5.0);
|
||||
param.setIsPhaseSequence("-1");
|
||||
}
|
||||
}
|
||||
|
||||
//额定电压信息
|
||||
Set<Double> voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
|
||||
//额定电流信息
|
||||
Set<Double> currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
|
||||
|
||||
if (voltSet.size() == 1 && currSet.size() == 1) {
|
||||
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr, param.getIndexList());
|
||||
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param, volt, curr);
|
||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
|
||||
if (CollUtil.isNotEmpty(pqScriptDtls)) {
|
||||
/**
|
||||
@@ -141,8 +168,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
* 3.组装所有检测格式
|
||||
*/
|
||||
Map<Integer, List<PqScriptDtls>> scriptDtlsMap = pqScriptDtls.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptIndex, LinkedHashMap::new, Collectors.toList()));
|
||||
scriptDtlsMap.forEach((key, value) -> {
|
||||
/**
|
||||
* 分组获取有多少小类
|
||||
@@ -155,17 +182,18 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
PqScriptDtls freqDtls = freq.get(0);
|
||||
SourceIssue issue = new SourceIssue();
|
||||
issue.setId(freqDtls.getId());
|
||||
issue.setEnable(freqDtls.getEnable());
|
||||
issue.setSourceId(param.getSourceId());
|
||||
issue.setType(freqDtls.getScriptCode());
|
||||
issue.setIndex(freqDtls.getIndex());
|
||||
issue.setIndex(freqDtls.getScriptIndex());
|
||||
String scriptSubType = freqDtls.getScriptSubType();
|
||||
issue.setSubType(StrUtil.isBlank(scriptSubType) ? scriptSubType : scriptSubType.replace("Base", "NULL"));
|
||||
issue.setSubType(CollUtil.isEmpty(param.getDevIds()) || StrUtil.isBlank(scriptSubType) ? scriptSubType : scriptSubType.replace("Base", "NULL"));
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||
checkDataParam.setIndex(freqDtls.getIndex());
|
||||
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
||||
checkDataParam.setIsValueTypeName(true);
|
||||
issue.setDevValueTypeList(pqScriptCheckDataService.getValueType(checkDataParam));
|
||||
issue.setDesc(ScriptDtlsDesc.getStringBuffer(value, isValueType).toString());
|
||||
issue.setDesc(ScriptDtlsDesc.getStringBuffer(value,true, isValueType).toString());
|
||||
issue.setScriptId(freqDtls.getScriptId());
|
||||
issue.setFUn(volt);
|
||||
issue.setFIn(curr);
|
||||
@@ -184,7 +212,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
)
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||
.collect(Collectors.toList());
|
||||
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, freqDtls.getValue(), "U", channelListDTOS);
|
||||
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, freqDtls.getValue(), "U", channelListDTOS, checkDataParam, devFly, isValueType);
|
||||
|
||||
//2.通道电流(ABC)
|
||||
List<PqScriptDtls> curList = value.stream().filter(x -> CUR.equals(x.getValueType()))
|
||||
@@ -196,7 +224,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
)
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||
.collect(Collectors.toList());
|
||||
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS);
|
||||
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
|
||||
|
||||
issue.setChannelList(channelListDTOS);
|
||||
sourceIssues.add(issue);
|
||||
@@ -213,52 +241,610 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
@Override
|
||||
public List<Integer> getIndexList(String scriptType, String scriptId) {
|
||||
MPJLambdaWrapper<PqScriptDtls> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.select(PqScriptDtls::getIndex)
|
||||
wrapper.select(PqScriptDtls::getScriptIndex)
|
||||
.distinct()
|
||||
.eq(PqScriptDtls::getScriptType, scriptType)
|
||||
.eq(PqScriptDtls::getScriptId, scriptId);
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getIndex).collect(Collectors.toList());
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getScriptIndex).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<PqScriptDtls> pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr, List<Integer> indexList) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean saveScriptDtls(PqScriptDtlsParam sourceIssue) {
|
||||
List<PqScriptDtls> info = new ArrayList<>();
|
||||
List<PqScriptCheckData> checkList = new ArrayList<>();
|
||||
Integer i = sourceIssue.getIndex();
|
||||
if (ObjectUtil.isNotNull(sourceIssue.getIndex())) {
|
||||
this.remove(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, sourceIssue.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, sourceIssue.getIndex())
|
||||
);
|
||||
pqScriptCheckDataService.remove(new LambdaQueryWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
.eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
);
|
||||
} else {
|
||||
i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()) + 1;
|
||||
}
|
||||
List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList();
|
||||
PqScriptCheckData data;
|
||||
if (CollUtil.isNotEmpty(checkDataList)) {
|
||||
checkDataList = checkDataList.stream().filter(x -> ObjectUtil.isNotNull(x.getValue())).collect(Collectors.toList());
|
||||
for (PqScriptDtlsParam.CheckData checkData : checkDataList) {
|
||||
data = new PqScriptCheckData();
|
||||
data.setScriptId(sourceIssue.getScriptId());
|
||||
data.setScriptIndex(i);
|
||||
data.setValueType(checkData.getValueType());
|
||||
data.setDataType(checkData.getDataType());
|
||||
data.setPhase(checkData.getPhase());
|
||||
data.setValue(checkData.getValue());
|
||||
data.setHarmNum(checkData.getHarmNum());
|
||||
data.setEnable(checkData.getEnable());
|
||||
data.setErrorFlag(checkData.getErrorFlag());
|
||||
checkList.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
//频率赋值
|
||||
PqScriptDtls dtls = setScriptDtls(sourceIssue, i);
|
||||
dtls.setValueType(FREQ);
|
||||
dtls.setPhase("T");
|
||||
dtls.setValue(sourceIssue.getFFreq());
|
||||
dtls.setAngle(0.0);
|
||||
info.add(dtls);
|
||||
if (CollUtil.isNotEmpty(sourceIssue.getChannelList())) {
|
||||
//开始遍历通道信息
|
||||
for (PqScriptDtlsParam.ChannelListDTO channelListDTO : sourceIssue.getChannelList()) {
|
||||
String phase = channelListDTO.getChannelType().substring(1, 2).toUpperCase();
|
||||
//电压或者电流
|
||||
if (channelListDTO.getChannelFlag()) {
|
||||
PqScriptDtls uOri = setScriptDtls(sourceIssue, i);
|
||||
uOri.setPhase(phase);
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
uOri.setValueType(VOL);
|
||||
}
|
||||
if (channelListDTO.getChannelType().contains("I")) {
|
||||
uOri.setValueType(CUR);
|
||||
}
|
||||
uOri.setValue(channelListDTO.getFAmp());
|
||||
uOri.setAngle(channelListDTO.getFPhase());
|
||||
info.add(uOri);
|
||||
}
|
||||
//谐波值
|
||||
if (channelListDTO.getHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = channelListDTO.getHarmList();
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
|
||||
PqScriptDtls harm = setScriptDtls(sourceIssue, i);
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
harm.setValueType(HARM_V);
|
||||
}
|
||||
if (channelListDTO.getChannelType().contains("I")) {
|
||||
harm.setValueType(HARM_I);
|
||||
}
|
||||
harm.setPhase(phase);
|
||||
harm.setHarmNum(harmModel.getHarm());
|
||||
harm.setValue(harmModel.getFAmp());
|
||||
harm.setAngle(harmModel.getFPhase());
|
||||
info.add(harm);
|
||||
}
|
||||
}
|
||||
}
|
||||
//间谐波
|
||||
if (channelListDTO.getInHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.InharmModel> inharmList = channelListDTO.getInharmList();
|
||||
if (CollUtil.isNotEmpty(inharmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) {
|
||||
PqScriptDtls inHarm = setScriptDtls(sourceIssue, i);
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
inHarm.setValueType(INHARM_V);
|
||||
}
|
||||
if (channelListDTO.getChannelType().contains("I")) {
|
||||
inHarm.setValueType(INHARM_I);
|
||||
}
|
||||
inHarm.setPhase(phase);
|
||||
inHarm.setHarmNum(inharmModel.getInharm());
|
||||
inHarm.setValue(inharmModel.getFAmp());
|
||||
inHarm.setAngle(inharmModel.getFPhase());
|
||||
info.add(inHarm);
|
||||
}
|
||||
}
|
||||
}
|
||||
//暂态
|
||||
if (channelListDTO.getDipFlag()) {
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
PqScriptDtlsParam.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData();
|
||||
if (ObjectUtil.isNotNull(dipData)) {
|
||||
PqScriptDtls dip = setScriptDtls(sourceIssue, i);
|
||||
dip.setValueType(DIP);
|
||||
dip.setPhase(phase);
|
||||
dip.setTransValue(dipData.getFTransValue());
|
||||
dip.setRetainTime(dipData.getRetainTime());
|
||||
info.add(dip);
|
||||
}
|
||||
}
|
||||
}
|
||||
//闪变
|
||||
if (channelListDTO.getFlickerFlag()) {
|
||||
if (channelListDTO.getChannelType().contains("U")) {
|
||||
PqScriptDtlsParam.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData();
|
||||
if (ObjectUtil.isNotNull(flickerData)) {
|
||||
PqScriptDtls dip = setScriptDtls(sourceIssue, i);
|
||||
dip.setValueType(FLICKER);
|
||||
dip.setPhase(phase);
|
||||
if (!"CPM".equals(flickerData.getWaveType())) {
|
||||
dip.setChagFre(NumberUtil.round(flickerData.getFChagFre() * 120, -1).doubleValue());
|
||||
} else {
|
||||
dip.setChagFre(flickerData.getFChagFre());
|
||||
}
|
||||
dip.setChagValue(flickerData.getFChagValue());
|
||||
info.add(dip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
this.saveBatch(info);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(checkList)) {
|
||||
pqScriptCheckDataService.saveBatch(checkList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptDtlsParam.CheckData> scriptDtlsCheckDataList(PqScriptDtlsParam sourceIssue) {
|
||||
List<PqScriptDtlsParam.CheckData> info = new ArrayList<>();
|
||||
//获取所有下拉值情况
|
||||
List<PqScriptDtlsParam.CheckData> checkDataList = sourceIssue.getCheckDataList();
|
||||
if (CollUtil.isNotEmpty(checkDataList)) {
|
||||
Map<String, List<PqScriptCheckData>> checkDataOldMap = new HashMap<>();
|
||||
if (sourceIssue.getRetryCompute()) {
|
||||
PqScriptCheckDataParam param = new PqScriptCheckDataParam();
|
||||
param.setScriptId(sourceIssue.getScriptId());
|
||||
param.setIndex(sourceIssue.getIndex());
|
||||
List<PqScriptCheckData> checkDataOld = pqScriptCheckDataService.listCheckDataCode(param);
|
||||
checkDataOldMap = checkDataOld.stream().collect(Collectors.groupingBy(PqScriptCheckData::getValueTypeCode));
|
||||
}
|
||||
|
||||
List<String> ids = checkDataList.stream().map(PqScriptDtlsParam.CheckData::getValueType).collect(Collectors.toList());
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(ids);
|
||||
Map<String, DictTree> dicTreeMap = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||
PqScriptDtlsParam.CheckData checkData;
|
||||
for (PqScriptDtlsParam.CheckData channelListDTO : checkDataList) {
|
||||
if (dicTreeMap.containsKey(channelListDTO.getValueType())) {
|
||||
DictTree dictTree = dicTreeMap.get(channelListDTO.getValueType());
|
||||
channelListDTO.setPid(dictTree.getPid());
|
||||
DetectionCodeEnum codeEnum = DetectionCodeEnum.getDetectionCodeByCode(dictTree.getCode());
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelList = sourceIssue.getChannelList();
|
||||
List<PqScriptDtlsParam.ChannelListDTO> list;
|
||||
List<PqScriptCheckData> checkArchive;
|
||||
if (checkDataOldMap.containsKey(codeEnum.getCode())) {
|
||||
checkArchive = checkDataOldMap.get(codeEnum.getCode());
|
||||
} else {
|
||||
checkArchive = new ArrayList<>();
|
||||
}
|
||||
switch (codeEnum) {
|
||||
case FREQ:
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase("T");
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
if (CollUtil.isNotEmpty(checkArchive)) {
|
||||
checkData.setValue(checkArchive.get(0).getValue());
|
||||
checkData.setDataType(checkArchive.get(0).getDataType());
|
||||
} else {
|
||||
checkData.setValue(sourceIssue.getFFreq());
|
||||
}
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
info.add(checkData);
|
||||
break;
|
||||
case U1:
|
||||
case VRMS:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
rmsCheck(info, channelListDTO, list, checkArchive, false);
|
||||
}
|
||||
break;
|
||||
case DELTA_V:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
rmsCheck(info, channelListDTO, list, checkArchive, true);
|
||||
}
|
||||
break;
|
||||
case VA:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
|
||||
if (listDTO.getChannelFlag()) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(listDTO.getFPhase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
info.add(checkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case V2_50:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
harmCheck(info, channelListDTO, list, checkArchive);
|
||||
}
|
||||
break;
|
||||
case I2_50:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
|
||||
harmCheck(info, channelListDTO, list, checkArchive);
|
||||
}
|
||||
break;
|
||||
case P2_50:
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelU = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(channelU)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) {
|
||||
if (listDTO.getHarmFlag()) {
|
||||
//获取电流通道
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelI = channelList.stream()
|
||||
.filter(PqScriptDtlsParam.ChannelListDTO::getHarmFlag)
|
||||
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(channelI)) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmI = channelI.stream()
|
||||
.flatMap(x -> x.getHarmList().stream()).collect(Collectors.toList());
|
||||
Map<Double, PqScriptDtlsParam.ChannelListDTO.HarmModel> harmIMap = harmI.stream()
|
||||
.collect(Collectors.toMap(PqScriptDtlsParam.ChannelListDTO.HarmModel::getHarm, Function.identity()));
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = listDTO.getHarmList();
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setHarmNum(harmModel.getHarm());
|
||||
if (harmIMap.containsKey(harmModel.getHarm())) {
|
||||
PqScriptDtlsParam.ChannelListDTO.HarmModel i = harmIMap.get(harmModel.getHarm());
|
||||
//电压*电流*cos(电压角度-电流角度)
|
||||
checkData.setValue(i.getFAmp() * harmModel.getFAmp() / 100 * Math.cos(harmModel.getFPhase() - i.getFPhase()));
|
||||
}
|
||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SV_1_49:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
inHarmCheck(info, channelListDTO, list, checkArchive);
|
||||
}
|
||||
break;
|
||||
case SI_1_49:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
|
||||
inHarmCheck(info, channelListDTO, list, checkArchive);
|
||||
}
|
||||
break;
|
||||
case MAG:
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
|
||||
if (listDTO.getDipFlag()) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(listDTO.getDipData().getFTransValue());
|
||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DUR:
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
|
||||
if (listDTO.getDipFlag()) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(listDTO.getDipData().getRetainTime());
|
||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IRMS:
|
||||
case IA:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
|
||||
rmsCheck(info, channelListDTO, list, checkArchive, false);
|
||||
}
|
||||
break;
|
||||
case V_UNBAN:
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
unbanCheck(info, channelListDTO, list, checkArchive);
|
||||
break;
|
||||
case I_UNBAN:
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList());
|
||||
unbanCheck(info, channelListDTO, list, checkArchive);
|
||||
break;
|
||||
case PST:
|
||||
if (CollUtil.isNotEmpty(channelList)) {
|
||||
list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
|
||||
if (listDTO.getFlickerFlag()) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
if (ObjectUtil.isNotNull(listDTO.getFlickerData())) {
|
||||
checkData.setValue(listDTO.getFlickerData().getFlickerValue());
|
||||
}
|
||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case I1:
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private void setCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData checkData, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptCheckData> checkArchive, PqScriptDtlsParam.ChannelListDTO listDTO) {
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
info.add(checkData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteDtls(ScriptParam param) {
|
||||
this.remove(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
);
|
||||
return pqScriptCheckDataService.remove(new LambdaQueryWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateDtls(ScriptParam param) {
|
||||
return this.update(new LambdaUpdateWrapper<PqScriptDtls>()
|
||||
.set(PqScriptDtls::getEnable, param.getEnable())
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptCheckData> checkDataList(ScriptParam param) {
|
||||
List<PqScriptDtls> list = this.list(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptType, param.getScriptType())
|
||||
);
|
||||
List<Integer> indexList = list.stream().map(PqScriptDtls::getScriptIndex).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(indexList)) {
|
||||
return pqScriptCheckDataMapper.selectJoinList(PqScriptCheckData.class, new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
.select(PqScriptCheckData::getValueType, PqScriptCheckData::getEnable, PqScriptCheckData::getErrorFlag)
|
||||
.distinct()
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.in(PqScriptCheckData::getScriptIndex, indexList)
|
||||
);
|
||||
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private void unbanCheck(List<PqScriptDtlsParam.CheckData> info,
|
||||
PqScriptDtlsParam.CheckData channelListDTO,
|
||||
List<PqScriptDtlsParam.ChannelListDTO> list,
|
||||
List<PqScriptCheckData> checkArchive
|
||||
) {
|
||||
PqScriptDtlsParam.CheckData checkData;
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase("T");
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelA = list.stream().filter(x -> x.getChannelType().contains("a")).collect(Collectors.toList());
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelB = list.stream().filter(x -> x.getChannelType().contains("b")).collect(Collectors.toList());
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelC = list.stream().filter(x -> x.getChannelType().contains("c")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(channelA) && CollUtil.isNotEmpty(channelB) && CollUtil.isNotEmpty(channelC)) {
|
||||
PqScriptDtlsParam.ChannelListDTO a = channelA.get(0);
|
||||
PqScriptDtlsParam.ChannelListDTO b = channelB.get(0);
|
||||
PqScriptDtlsParam.ChannelListDTO c = channelC.get(0);
|
||||
checkData.setValue(ThreePhaseUnbalance.calculateUnbalance(a.getFAmp(), a.getFPhase(), b.getFAmp(), b.getFPhase(), c.getFAmp(), c.getFPhase()));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(checkArchive)) {
|
||||
checkData.setValue(checkArchive.get(0).getValue());
|
||||
checkData.setDataType(checkArchive.get(0).getDataType());
|
||||
}
|
||||
info.add(checkData);
|
||||
}
|
||||
}
|
||||
|
||||
private void rmsCheck(List<PqScriptDtlsParam.CheckData> info,
|
||||
PqScriptDtlsParam.CheckData channelListDTO,
|
||||
List<PqScriptDtlsParam.ChannelListDTO> list,
|
||||
List<PqScriptCheckData> checkArchive,
|
||||
Boolean flyDeltaV
|
||||
) {
|
||||
PqScriptDtlsParam.CheckData checkData;
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : list) {
|
||||
if (listDTO.getChannelFlag()) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
checkData.setValue(collect.get(0).getValue());
|
||||
checkData.setDataType(collect.get(0).getDataType());
|
||||
} else {
|
||||
if (flyDeltaV) {
|
||||
checkData.setValue(0.0);
|
||||
} else {
|
||||
checkData.setValue(listDTO.getFAmp());
|
||||
}
|
||||
}
|
||||
info.add(checkData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void inHarmCheck(List<PqScriptDtlsParam.CheckData> info,
|
||||
PqScriptDtlsParam.CheckData channelListDTO,
|
||||
List<PqScriptDtlsParam.ChannelListDTO> uList,
|
||||
List<PqScriptCheckData> checkArchive
|
||||
) {
|
||||
PqScriptDtlsParam.CheckData checkData;
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) {
|
||||
if (listDTO.getInHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.InharmModel> inharmList = listDTO.getInharmList();
|
||||
if (CollUtil.isNotEmpty(inharmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(inharmModel.getFAmp());
|
||||
checkData.setHarmNum(inharmModel.getInharm());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
info.add(checkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setCheckValue(List<PqScriptCheckData> checkArchive, PqScriptDtlsParam.CheckData checkData, PqScriptDtlsParam.ChannelListDTO listDTO) {
|
||||
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
checkData.setValue(collect.get(0).getValue());
|
||||
checkData.setDataType(collect.get(0).getDataType());
|
||||
}
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
}
|
||||
|
||||
private void harmCheck(List<PqScriptDtlsParam.CheckData> info,
|
||||
PqScriptDtlsParam.CheckData channelListDTO,
|
||||
List<PqScriptDtlsParam.ChannelListDTO> uList,
|
||||
List<PqScriptCheckData> checkArchive
|
||||
) {
|
||||
PqScriptDtlsParam.CheckData checkData;
|
||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) {
|
||||
if (listDTO.getHarmFlag()) {
|
||||
List<PqScriptDtlsParam.ChannelListDTO.HarmModel> harmList = listDTO.getHarmList();
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) {
|
||||
checkData = new PqScriptDtlsParam.CheckData();
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(harmModel.getFAmp());
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setHarmNum(harmModel.getHarm());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
info.add(checkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private PqScriptDtls setScriptDtls(PqScriptDtlsParam sourceIssue, Integer i) {
|
||||
PqScriptDtls dtls = new PqScriptDtls();
|
||||
dtls.setScriptId(sourceIssue.getScriptId());
|
||||
dtls.setScriptIndex(i);
|
||||
dtls.setScriptType(sourceIssue.getScriptType());
|
||||
dtls.setScriptSubType(sourceIssue.getSubType());
|
||||
dtls.setEnable(DataStateEnum.ENABLE.getCode());
|
||||
return dtls;
|
||||
}
|
||||
|
||||
public List<PqScriptDtls> pqScriptDtls(PqScriptIssueParam param, Double volt, Double curr) {
|
||||
List<PqScriptDtls> pqScriptDtls;
|
||||
MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>();
|
||||
List<Integer> index = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(param.getScriptSubType())) {
|
||||
String[] split = param.getScriptSubType().split("_");
|
||||
if (split.length > 1) {
|
||||
param.setScriptSubType(split[0]);
|
||||
List<PqScriptDtls> pqScriptDtls1 = this.getBaseMapper().selectList(new LambdaQueryWrapper<PqScriptDtls>()
|
||||
.select(PqScriptDtls::getScriptIndex)
|
||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
.eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType())
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.ge(PqScriptDtls::getTransValue, split[1])
|
||||
.le(PqScriptDtls::getTransValue, split[2]));
|
||||
index = pqScriptDtls1.stream().map(PqScriptDtls::getScriptIndex).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
|
||||
// .eq(PqScriptDtls::getIndex, 1)
|
||||
// .le(PqScriptDtls::getIndex, 30)
|
||||
// .in(PqScriptDtls::getIndex, Arrays.asList(1,7))
|
||||
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) {
|
||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
.eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType())
|
||||
.in(CollUtil.isNotEmpty(index), PqScriptDtls::getScriptIndex, index)
|
||||
.eq(CollUtil.isNotEmpty(param.getDevIds()), PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqScriptCheckData::getScriptIndex)
|
||||
;
|
||||
if (param.getIsPhaseSequence().equals(CommonEnum.PHASE_TEST.getValue())) {
|
||||
//相序
|
||||
queryWrapper.eq(PqScriptDtls::getIndex, -1)
|
||||
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
} else if (isPhaseSequence.equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
|
||||
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
|
||||
//系数
|
||||
queryWrapper.in(PqScriptDtls::getIndex, indexList)
|
||||
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
} else {
|
||||
//先获取检测脚本类型是否相对值 true相对值 false绝对值(相对值要乘额定值,绝对值不需要处理)
|
||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(scriptId);
|
||||
queryWrapper.eq(PqScriptDtls::getScriptId, scriptId);
|
||||
queryWrapper.eq(PqScriptDtls::getScriptId, param.getScriptId());
|
||||
pqScriptDtls = this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
|
||||
if (isValueType) {
|
||||
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
|
||||
if (VOL.equals(pqScriptDtl.getValueType())) {
|
||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||
BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)
|
||||
.multiply(new BigDecimal(volt.toString()));
|
||||
pqScriptDtl.setValue(result.doubleValue());
|
||||
}
|
||||
if (CUR.equals(pqScriptDtl.getValueType())) {
|
||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||
BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)
|
||||
.multiply(new BigDecimal(curr.toString()));
|
||||
pqScriptDtl.setValue(result.doubleValue());
|
||||
if (CollUtil.isNotEmpty(param.getDevIds()) || (ObjectUtil.isNotNull(param.getType()) && param.getType() == 1)) {
|
||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
|
||||
if (isValueType) {
|
||||
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
|
||||
if (VOL.equals(pqScriptDtl.getValueType())) {
|
||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||
BigDecimal result = volValue.multiply(new BigDecimal(volt.toString()))
|
||||
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||
pqScriptDtl.setValue(result.doubleValue());
|
||||
}
|
||||
if (CUR.equals(pqScriptDtl.getValueType())) {
|
||||
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
|
||||
BigDecimal result = volValue.multiply(new BigDecimal(curr.toString()))
|
||||
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||
pqScriptDtl.setValue(result.doubleValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,17 +873,23 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
String inHarm,
|
||||
Double fFreq,
|
||||
String code,
|
||||
List<SourceIssue.ChannelListDTO> channelListDTOS) {
|
||||
for (PqScriptDtls dtls : dtlsList) {
|
||||
List<SourceIssue.ChannelListDTO> channelListDTOS,
|
||||
PqScriptCheckDataParam checkDataParam,
|
||||
Boolean devFly,
|
||||
Boolean isValueType) {
|
||||
List<String> info = new ArrayList<>();
|
||||
info.add("A");
|
||||
info.add("B");
|
||||
info.add("C");
|
||||
for (String phase : info) {
|
||||
List<PqScriptDtls> collect = dtlsList.stream().filter(x -> x.getPhase().equals(phase)).collect(Collectors.toList());
|
||||
SourceIssue.ChannelListDTO channelListDTO = new SourceIssue.ChannelListDTO();
|
||||
channelListDTO.setChannelFlag(true);
|
||||
channelListDTO.setChannelFlag(false);
|
||||
channelListDTO.setHarmFlag(false);
|
||||
channelListDTO.setInHarmFlag(false);
|
||||
channelListDTO.setDipFlag(false);
|
||||
channelListDTO.setFlickerFlag(false);
|
||||
channelListDTO.setChannelType(code + dtls.getPhase().toLowerCase());
|
||||
channelListDTO.setFAmp(dtls.getValue());
|
||||
channelListDTO.setFPhase(dtls.getAngle());
|
||||
channelListDTO.setChannelType(code + phase.toLowerCase());
|
||||
channelListDTO.setHarmList(new ArrayList<>());
|
||||
channelListDTO.setInharmList(new ArrayList<>());
|
||||
//暂态数据
|
||||
@@ -322,51 +914,72 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
flickerDataDTO.setFChagValue(0.0);
|
||||
channelListDTO.setFlickerData(flickerDataDTO);
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(dtlsOtherList)) {
|
||||
List<PqScriptDtls> phaseList = dtlsOtherList.stream().filter(x -> dtls.getPhase().equals(x.getPhase()))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getHarmNum))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(phaseList)) {
|
||||
//处理谐波类型
|
||||
List<PqScriptDtls> harmList = phaseList.stream().filter(x -> harm.equals(x.getValueType()))
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
PqScriptDtls dtls = collect.get(0);
|
||||
channelListDTO.setChannelFlag(true);
|
||||
channelListDTO.setFAmp(dtls.getValue());
|
||||
channelListDTO.setFPhase(dtls.getAngle());
|
||||
if (CollUtil.isNotEmpty(dtlsOtherList)) {
|
||||
List<PqScriptDtls> phaseList = dtlsOtherList.stream().filter(x -> dtls.getPhase().equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
channelListDTO.setHarmList(getHarmModels(harmList));
|
||||
channelListDTO.setHarmFlag(true);
|
||||
}
|
||||
//处理间谐波类型
|
||||
List<PqScriptDtls> inHarmList = phaseList.stream().filter(x -> inHarm.equals(x.getValueType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(inHarmList)) {
|
||||
channelListDTO.setInharmList(getInHarmModels(inHarmList));
|
||||
channelListDTO.setInHarmFlag(true);
|
||||
}
|
||||
//处理暂态数据
|
||||
List<PqScriptDtls> dipList = phaseList.stream().filter(x -> DIP.equals(x.getValueType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dipList)) {
|
||||
PqScriptDtls dip = dipList.get(0);
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
// 1.0/频率*持续时间(周波)= 暂态持续时间(s)
|
||||
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).doubleValue());
|
||||
dipDataDTO.setRetainTime(dip.getRetainTime());
|
||||
channelListDTO.setDipFlag(true);
|
||||
channelListDTO.setDipData(dipDataDTO);
|
||||
}
|
||||
//处理闪变数据
|
||||
List<PqScriptDtls> flickeRList = phaseList.stream().filter(x -> FLICKER.equals(x.getValueType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(flickeRList)) {
|
||||
PqScriptDtls flicker = flickeRList.get(0);
|
||||
if (CollUtil.isNotEmpty(phaseList)) {
|
||||
//处理谐波类型
|
||||
List<PqScriptDtls> harmList = phaseList.stream().filter(x -> harm.equals(x.getValueType()))
|
||||
.filter(x -> ObjectUtil.isNotNull(x.getHarmNum()))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getHarmNum))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(harmList)) {
|
||||
channelListDTO.setHarmList(getHarmModels(harmList));
|
||||
channelListDTO.setHarmFlag(true);
|
||||
}
|
||||
//处理间谐波类型
|
||||
List<PqScriptDtls> inHarmList = phaseList.stream().filter(x -> inHarm.equals(x.getValueType()))
|
||||
.filter(x -> ObjectUtil.isNotNull(x.getHarmNum()))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getHarmNum))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(inHarmList)) {
|
||||
channelListDTO.setInharmList(getInHarmModels(inHarmList));
|
||||
channelListDTO.setInHarmFlag(true);
|
||||
}
|
||||
//处理暂态数据
|
||||
List<PqScriptDtls> dipList = phaseList.stream().filter(x -> DIP.equals(x.getValueType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dipList)) {
|
||||
PqScriptDtls dip = dipList.get(0);
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
if (devFly) {
|
||||
if (isValueType) {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue() * dtls.getValue() * 0.01);
|
||||
} else {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
}
|
||||
}
|
||||
// 1.0/频率*持续时间(周波)= 暂态持续时间(s)
|
||||
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).doubleValue());
|
||||
dipDataDTO.setRetainTime(dip.getRetainTime());
|
||||
channelListDTO.setDipFlag(true);
|
||||
channelListDTO.setDipData(dipDataDTO);
|
||||
}
|
||||
//处理闪变数据
|
||||
List<PqScriptDtls> flickeRList = phaseList.stream().filter(x -> FLICKER.equals(x.getValueType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(flickeRList)) {
|
||||
PqScriptDtls flicker = flickeRList.get(0);
|
||||
|
||||
flickerDataDTO.setFChagFre(flicker.getChagFre());
|
||||
flickerDataDTO.setFChagValue(flicker.getChagValue());
|
||||
flickerDataDTO.setFChagFre(flicker.getChagFre());
|
||||
flickerDataDTO.setFChagValue(flicker.getChagValue());
|
||||
|
||||
DictTree dictTreeByCode = dictTreeService.getDictTreeByCode(DetectionCodeEnum.PST.getCode());
|
||||
if (ObjectUtil.isNotNull(dictTreeByCode)) {
|
||||
checkDataParam.setValueType(dictTreeByCode.getId());
|
||||
checkDataParam.setPhase(dtls.getPhase());
|
||||
flickerDataDTO.setFlickerValue(pqScriptCheckDataService.getCheckDataValue(checkDataParam));
|
||||
}
|
||||
channelListDTO.setFlickerFlag(true);
|
||||
channelListDTO.setFlickerData(flickerDataDTO);
|
||||
}
|
||||
|
||||
channelListDTO.setFlickerFlag(true);
|
||||
channelListDTO.setFlickerData(flickerDataDTO);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
channelListDTOS.add(channelListDTO);
|
||||
|
||||
@@ -7,7 +7,11 @@ 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.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.enums.ScriptResponseEnum;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
@@ -56,12 +60,13 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addPqScript(PqScriptParam param) {
|
||||
public String addPqScript(PqScriptParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqScript);
|
||||
this.save(pqScript);
|
||||
return pqScript.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +81,10 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deletePqScript(List<String> ids) {
|
||||
Integer count = this.baseMapper.getBoundCountByScriptIds(ids);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(ScriptResponseEnum.SCRIPT_BOUND_NOT_DELETE);
|
||||
}
|
||||
//删除对应的脚本详情
|
||||
pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids);
|
||||
LambdaUpdateWrapper<PqScript> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
@@ -97,7 +106,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqScript(String patternId) {
|
||||
List<PqScript> pqScriptList = this.lambdaQuery().eq(PqScript::getPattern, patternId).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<PqScript> pqScriptList = this.lambdaQuery().eq(StrUtil.isNotBlank(patternId), PqScript::getPattern, patternId).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqScript.getId());
|
||||
|
||||
@@ -16,8 +16,11 @@ import java.util.stream.Collectors;
|
||||
* @date 2025/1/13 22:05
|
||||
*/
|
||||
public class ScriptDtlsDesc {
|
||||
public static StringBuffer getStringBuffer(List<PqScriptDtls> scriptDtlIndex, Boolean isValueType) {
|
||||
public static StringBuffer getStringBuffer(List<PqScriptDtls> scriptDtlIndex,Boolean isScript, Boolean isValueType) {
|
||||
if (ObjectUtil.isNull(isValueType)) {
|
||||
isValueType = true;
|
||||
}
|
||||
if (isScript) {
|
||||
isValueType = false;
|
||||
}
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
@@ -79,7 +82,7 @@ public class ScriptDtlsDesc {
|
||||
buffer.append(name + " ");
|
||||
for (PqScriptDtls dtls : list) {
|
||||
buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit()
|
||||
+ ",暂态持续时间=" + dtls.getRetainTime().intValue() + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
|
||||
+ ",暂态持续时间=" + (ObjectUtil.isNull(dtls.getRetainTime()) ? dtls.getRetainTime() : dtls.getRetainTime().intValue()) + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.njcn.gather.script.util;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/2/25 13:24
|
||||
*/
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public class ThreePhaseUnbalance {
|
||||
|
||||
// 定义复数类
|
||||
static class Complex {
|
||||
BigDecimal real; // 复数的实部
|
||||
BigDecimal imag; // 复数的虚部
|
||||
|
||||
// 构造函数,初始化复数的实部和虚部
|
||||
public Complex(BigDecimal real, BigDecimal imag) {
|
||||
this.real = real;
|
||||
this.imag = imag;
|
||||
}
|
||||
|
||||
// 复数加法
|
||||
public Complex add(Complex other) {
|
||||
return new Complex(this.real.add(other.real), this.imag.add(other.imag));
|
||||
}
|
||||
|
||||
// 复数乘法
|
||||
public Complex multiply(Complex other) {
|
||||
BigDecimal real = this.real.multiply(other.real).subtract(this.imag.multiply(other.imag));
|
||||
BigDecimal imag = this.real.multiply(other.imag).add(this.imag.multiply(other.real));
|
||||
return new Complex(real, imag);
|
||||
}
|
||||
|
||||
// 复数除以一个实数
|
||||
public Complex divide(BigDecimal divisor) {
|
||||
return new Complex(this.real.divide(divisor, MathContext.DECIMAL128),
|
||||
this.imag.divide(divisor, MathContext.DECIMAL128));
|
||||
}
|
||||
|
||||
// 计算复数的模(幅值)
|
||||
public BigDecimal magnitude() {
|
||||
return BigDecimal.valueOf(Math.sqrt(real.multiply(real).add(imag.multiply(imag)).doubleValue()));
|
||||
}
|
||||
}
|
||||
|
||||
// 将幅值和角度(角度制)转换为复数
|
||||
public static Complex fromPolar(BigDecimal magnitude, BigDecimal angleDegrees) {
|
||||
double angleRadians = Math.toRadians(angleDegrees.doubleValue()); // 将角度转换为弧度
|
||||
BigDecimal real = magnitude.multiply(BigDecimal.valueOf(Math.cos(angleRadians))); // 计算实部
|
||||
BigDecimal imag = magnitude.multiply(BigDecimal.valueOf(Math.sin(angleRadians))); // 计算虚部
|
||||
return new Complex(real, imag);
|
||||
}
|
||||
|
||||
// 计算三相电压的对称分量(零序、正序、负序)
|
||||
public static Complex[] calculateSymmetricalComponents(Complex va, Complex vb, Complex vc) {
|
||||
// 120度相位因子 a = e^(j120°) = -0.5 + j * sqrt(3)/2
|
||||
Complex a = new Complex(BigDecimal.valueOf(-0.5), BigDecimal.valueOf(Math.sqrt(3) / 2));
|
||||
// 240度相位因子 a^2 = e^(j240°) = -0.5 - j * sqrt(3)/2
|
||||
Complex a2 = a.multiply(a);
|
||||
|
||||
// 零序分量 V0 = (Va + Vb + Vc) / 3
|
||||
Complex v0 = va.add(vb).add(vc).divide(BigDecimal.valueOf(3));
|
||||
|
||||
// 正序分量 V1 = (Va + a * Vb + a^2 * Vc) / 3
|
||||
Complex v1 = va.add(a.multiply(vb)).add(a2.multiply(vc)).divide(BigDecimal.valueOf(3));
|
||||
|
||||
// 负序分量 V2 = (Va + a^2 * Vb + a * Vc) / 3
|
||||
Complex v2 = va.add(a2.multiply(vb)).add(a.multiply(vc)).divide(BigDecimal.valueOf(3));
|
||||
|
||||
// 返回零序、正序、负序分量
|
||||
return new Complex[]{v0, v1, v2};
|
||||
}
|
||||
|
||||
// 计算三相电压的不平衡度
|
||||
public static void calculateUnbalance(Complex v0, Complex v1, Complex v2) {
|
||||
// 计算零序、正序、负序分量的幅值
|
||||
BigDecimal v0Mag = v0.magnitude(); // 零序分量幅值
|
||||
BigDecimal v1Mag = v1.magnitude(); // 正序分量幅值
|
||||
BigDecimal v2Mag = v2.magnitude(); // 负序分量幅值
|
||||
|
||||
// 计算不平衡度
|
||||
BigDecimal zeroSequenceUnbalance = v1Mag.compareTo(BigDecimal.ZERO) != 0 ?
|
||||
v0Mag.divide(v1Mag, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)) : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal negativeSequenceUnbalance = v1Mag.compareTo(BigDecimal.ZERO) != 0 ?
|
||||
v2Mag.divide(v1Mag, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)) : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal positiveSequenceUnbalance = BigDecimal.valueOf(100); // 正序电压不平衡度通常为100%
|
||||
|
||||
// 输出结果,保留2位小数
|
||||
System.out.printf("零序电压不平衡度: %.2f%%\n", zeroSequenceUnbalance.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
System.out.printf("负序电压不平衡度: %.2f%%\n", negativeSequenceUnbalance.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
System.out.printf("正序电压不平衡度: %.2f%%\n", positiveSequenceUnbalance.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 负序电压不平衡度
|
||||
*/
|
||||
public static double calculateUnbalance(double Ua0, double thetaA,
|
||||
double Ub0, double thetaB,
|
||||
double Uc0, double thetaC) {
|
||||
|
||||
// 输入三相电压的幅值和相位角(角度制)
|
||||
BigDecimal vaMagnitude = new BigDecimal(Ua0);
|
||||
BigDecimal vaAngle = new BigDecimal(thetaA);
|
||||
|
||||
BigDecimal vbMagnitude =new BigDecimal(Ub0);
|
||||
BigDecimal vbAngle = new BigDecimal(thetaB);
|
||||
|
||||
BigDecimal vcMagnitude =new BigDecimal(Uc0);
|
||||
BigDecimal vcAngle = new BigDecimal(thetaC);
|
||||
|
||||
// 将幅值和角度转换为复数
|
||||
Complex va = fromPolar(vaMagnitude, vaAngle);
|
||||
Complex vb = fromPolar(vbMagnitude, vbAngle);
|
||||
Complex vc = fromPolar(vcMagnitude, vcAngle);
|
||||
|
||||
// 计算对称分量
|
||||
Complex[] symmetricalComponents = calculateSymmetricalComponents(va, vb, vc);
|
||||
Complex v1 = symmetricalComponents[1]; // 正序分量
|
||||
Complex v2 = symmetricalComponents[2]; // 负序分量
|
||||
|
||||
// 计算零序、正序、负序分量的幅值
|
||||
BigDecimal v1Mag = v1.magnitude(); // 正序分量幅值
|
||||
BigDecimal v2Mag = v2.magnitude(); // 负序分量幅值
|
||||
|
||||
|
||||
BigDecimal negativeSequenceUnbalance = v1Mag.compareTo(BigDecimal.ZERO) != 0 ?
|
||||
v2Mag.divide(v1Mag, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)) : BigDecimal.ZERO;
|
||||
|
||||
// 输出结果,保留2位小数
|
||||
return negativeSequenceUnbalance.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// 输入三相电压的幅值和相位角(角度制)
|
||||
System.out.println("请输入A相电压的幅值(单位:V):");
|
||||
BigDecimal vaMagnitude = new BigDecimal(57.74);
|
||||
System.out.println("请输入A相电压的相位角(单位:度):");
|
||||
BigDecimal vaAngle = new BigDecimal(0);
|
||||
|
||||
System.out.println("请输入B相电压的幅值(单位:V):");
|
||||
BigDecimal vbMagnitude =new BigDecimal(57.74*0.9);
|
||||
System.out.println("请输入B相电压的相位角(单位:度):");
|
||||
BigDecimal vbAngle = new BigDecimal(-122);
|
||||
|
||||
System.out.println("请输入C相电压的幅值(单位:V):");
|
||||
BigDecimal vcMagnitude =new BigDecimal(57.74);
|
||||
System.out.println("请输入C相电压的相位角(单位:度):");
|
||||
BigDecimal vcAngle = new BigDecimal(118);
|
||||
|
||||
// 将幅值和角度转换为复数
|
||||
Complex va = fromPolar(vaMagnitude, vaAngle);
|
||||
Complex vb = fromPolar(vbMagnitude, vbAngle);
|
||||
Complex vc = fromPolar(vcMagnitude, vcAngle);
|
||||
|
||||
// 计算对称分量
|
||||
Complex[] symmetricalComponents = calculateSymmetricalComponents(va, vb, vc);
|
||||
Complex v0 = symmetricalComponents[0]; // 零序分量
|
||||
Complex v1 = symmetricalComponents[1]; // 正序分量
|
||||
Complex v2 = symmetricalComponents[2]; // 负序分量
|
||||
|
||||
// 输出对称分量
|
||||
System.out.printf("零序分量: %.2f + j%.2f\n", v0.real.setScale(2, RoundingMode.HALF_UP).doubleValue(),
|
||||
v0.imag.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
System.out.printf("正序分量: %.2f + j%.2f\n", v1.real.setScale(2, RoundingMode.HALF_UP).doubleValue(),
|
||||
v1.imag.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
System.out.printf("负序分量: %.2f + j%.2f\n", v2.real.setScale(2, RoundingMode.HALF_UP).doubleValue(),
|
||||
v2.imag.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
|
||||
// 计算并输出不平衡度
|
||||
calculateUnbalance(v0, v1, v2);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package com.njcn.gather.source.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -9,5 +12,12 @@ import com.njcn.gather.source.pojo.po.PqSource;
|
||||
*/
|
||||
public interface PqSourceMapper extends MPJBaseMapper<PqSource> {
|
||||
|
||||
/**
|
||||
* 根据ids获取绑定的计划数量
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Integer getCountBoundByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,16 @@
|
||||
<mapper namespace="com.njcn.gather.source.mapper.PqSourceMapper">
|
||||
|
||||
|
||||
<select id="getCountBoundByIds" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM ad_plan_source
|
||||
<if test="ids!= null and ids.size() > 0">
|
||||
<where>
|
||||
and Source_Id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.njcn.gather.source.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-07
|
||||
*/
|
||||
public interface PqSourceValidMessage {
|
||||
String ID_NOT_BLANK = "检测源id不能为空";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.source.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-10
|
||||
*/
|
||||
@Getter
|
||||
public enum SourceResponseEnum {
|
||||
SOURCE_BOUND_NOT_DELETE("A030001", "源已被计划所绑定,无法删除!");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
SourceResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.source.mapper.PqSourceMapper;
|
||||
import com.njcn.gather.source.pojo.enums.SourceResponseEnum;
|
||||
import com.njcn.gather.source.pojo.param.PqSourceParam;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
@@ -85,6 +86,10 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deletePqSource(List<String> ids) {
|
||||
Integer count = this.baseMapper.getCountBoundByIds(ids);
|
||||
if(count > 0){
|
||||
throw new BusinessException(SourceResponseEnum.SOURCE_BOUND_NOT_DELETE);
|
||||
}
|
||||
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.type.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
|
||||
@@ -79,4 +80,11 @@ public interface IDevTypeService extends IService<DevType> {
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deleteDevType(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据设备蕾西id获取报告名称
|
||||
* @param devType 设备类型Id
|
||||
* @return 报告字典
|
||||
*/
|
||||
DictData getReportName(String devType);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ 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.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.type.mapper.DevTypeMapper;
|
||||
import com.njcn.gather.type.pojo.enums.DevTypeResponseEnum;
|
||||
import com.njcn.gather.type.pojo.param.DevTypeParam;
|
||||
@@ -14,8 +16,11 @@ import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -28,6 +33,10 @@ import java.util.List;
|
||||
@Service
|
||||
public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> implements IDevTypeService {
|
||||
|
||||
@Resource
|
||||
private IDictDataService dictDataService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<DevType> listAll() {
|
||||
LambdaQueryWrapper<DevType> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -62,6 +71,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addDevType(DevTypeParam addParam) {
|
||||
this.checkRepeat(addParam, false);
|
||||
DevType devType = new DevType();
|
||||
@@ -71,6 +81,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateDevType(DevTypeParam.UpdateParam updateParam) {
|
||||
this.checkRepeat(updateParam, true);
|
||||
DevType devType = new DevType();
|
||||
@@ -79,10 +90,20 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deleteDevType(List<String> ids) {
|
||||
return this.lambdaUpdate().in(DevType::getId, ids).set(DevType::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictData getReportName(String devTypeId) {
|
||||
DevType devType = this.lambdaQuery().eq(DevType::getId, devTypeId).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.nonNull(devType)) {
|
||||
return dictDataService.getDictDataById(devType.getReportName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkRepeat(DevTypeParam param, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DevType::getName, param.getName())
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?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="generator.mapper.PqScriptCheckdataMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.njcn.gather.script.pojo.po.PqScriptCheckData">
|
||||
<id property="id" column="Id" jdbcType="CHAR"/>
|
||||
<result property="scriptId" column="Script_Id" jdbcType="CHAR"/>
|
||||
<result property="index" column="Index" jdbcType="INTEGER"/>
|
||||
<result property="valueType" column="Value_Type" jdbcType="CHAR"/>
|
||||
<result property="dataType" column="Data_Type" jdbcType="CHAR"/>
|
||||
<result property="phase" column="Phase" jdbcType="CHAR"/>
|
||||
<result property="value" column="Value" jdbcType="FLOAT"/>
|
||||
<result property="harmnum" column="HarmNum" jdbcType="FLOAT"/>
|
||||
<result property="enable" column="Enable" jdbcType="TINYINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
Id,Script_Id,Index,
|
||||
Value_Type,Data_Type,Phase,
|
||||
Value,HarmNum,Enable
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -4,11 +4,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
//@EnableAspectJAutoProxy
|
||||
public class EntranceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
username: root
|
||||
password: njcnpqs
|
||||
#初始化建立物理连接的个数、最小、最大连接数
|
||||
@@ -45,10 +45,10 @@ mybatis-plus:
|
||||
|
||||
socket:
|
||||
source:
|
||||
ip: 192.168.1.138
|
||||
ip: 192.168.1.24
|
||||
port: 62000
|
||||
device:
|
||||
ip: 192.168.1.138
|
||||
ip: 192.168.1.24
|
||||
port: 61000
|
||||
|
||||
webSocket:
|
||||
|
||||
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882A.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882A.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B1.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B1.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B2.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B2.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B3.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B3.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B4.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B4.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B5.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B5.docx
Normal file
Binary file not shown.
BIN
entrance/src/main/resources/model/njcn_882B6.docx
Normal file
BIN
entrance/src/main/resources/model/njcn_882B6.docx
Normal file
Binary file not shown.
@@ -3,9 +3,17 @@ package com.njcn.gather.storage.mapper;
|
||||
import com.njcn.db.mybatisplus.mapper.BatchBaseMapper;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DetectionDataDealMapper extends BatchBaseMapper<AdHarmonicResult> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID查询禁用的脚本详情索引
|
||||
*
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
List<Integer> listDisabledScriptDtlIndexs(String devId);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,4 @@ public interface TableGenMapper {
|
||||
|
||||
|
||||
void genAdNonHarmonicResultTable(@Param("code")String code);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
<mapper namespace="com.njcn.gather.storage.mapper.DetectionDataDealMapper">
|
||||
|
||||
|
||||
|
||||
<select id="listDisabledScriptDtlIndexs" resultType="java.lang.Integer">
|
||||
select distinct dtls.Script_Index
|
||||
from pq_script_dtls dtls
|
||||
inner join ad_plan plan on dtls.Script_Id = plan.Script_Id
|
||||
inner join pq_dev dev on dev.Plan_Id = plan.id
|
||||
where dev.id = #{devId}
|
||||
and dev.State = 1
|
||||
and dtls.Enable = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',
|
||||
Result_Flag int(1) NULL COMMENT '1不合格 2合格 4无法处理',
|
||||
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
|
||||
A_Value varchar(30) DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value varchar(30) DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value varchar(30) DEFAULT NULL COMMENT 'C相值',
|
||||
@@ -26,14 +26,14 @@
|
||||
|
||||
|
||||
<update id="genAdNonHarmonicResultTable" parameterType="string">
|
||||
CREATE TABLE ad_non_harmonic_result_${code} (
|
||||
CREATE TABLE if not exists ad_non_harmonic_result_${code} (
|
||||
Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',
|
||||
Time_Id DATETIME NULL COMMENT '时间',
|
||||
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',
|
||||
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',
|
||||
Result_Flag int(1) NOT NULL COMMENT '1不合格 2合格 4无法处理',
|
||||
Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',
|
||||
A_Value json NULL COMMENT 'A相值',
|
||||
B_Value json NULL COMMENT 'B相值',
|
||||
C_Value json NULL COMMENT 'C相值',
|
||||
@@ -41,10 +41,5 @@
|
||||
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type)
|
||||
) COMMENT='监测数据表';
|
||||
</update>
|
||||
|
||||
<update id="genAdHarmonicResultTable" parameterType="string">
|
||||
${tableSql}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AdHarmonicResult {
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 1.合格 2.合格 4.无法处理
|
||||
* 1.合格 2.不合格 4.无法处理
|
||||
*/
|
||||
private Integer resultFlag;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user