Compare commits
159 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a27eb7e462 | ||
|
|
f68d5da31e | ||
|
|
2d889b07f7 | ||
|
|
417a53a835 | ||
|
|
04a667531b | ||
| 9ecfe4f59b | |||
|
|
0d80e33d13 | ||
|
|
a2f7b1b9de | ||
| ee96b8e56b | |||
|
|
a0f6846f53 | ||
|
|
6c88c54982 | ||
|
|
a177d7991c | ||
| b2ff27b15c | |||
|
|
f8fb45cf6f | ||
| 35a47b2fa3 | |||
|
|
4c0816a829 | ||
|
|
1eb64fadae | ||
|
|
3ceb73d601 | ||
|
|
9d701ad55e | ||
| 8453b1da95 | |||
|
|
ba2fec5ac0 | ||
| 46a2e2068b | |||
| 7336a0aaa8 | |||
|
|
910069a463 | ||
| 56477157aa | |||
|
|
a67c5de69d | ||
|
|
95d5396759 | ||
| 858fc9aa05 | |||
| a6b0509179 | |||
|
|
55793dcecd | ||
| c9ac33864a | |||
| 6e4bbfc383 | |||
|
|
cb4d8d502a | ||
| 067f2235a7 | |||
| b42ede2853 | |||
| 9a4ef6abb5 | |||
|
|
af2b080ff5 | ||
|
|
0e056a7de1 | ||
|
|
b5e5286411 | ||
|
|
d01c0e14c0 | ||
|
|
0cf8bbc3d5 | ||
|
|
3a239b5123 | ||
|
|
0eabe977cb | ||
|
|
f1f86ea854 | ||
|
|
e048c92ad1 | ||
|
|
65f46a22f5 | ||
| 5d4cce365e | |||
|
|
b4c9bd12c9 | ||
|
|
8a11a9e5b1 | ||
|
|
b2738e1726 | ||
|
|
5d16d6c494 | ||
|
|
2693015dab | ||
|
|
3ecffc99b8 | ||
| 9c02a7cb8e | |||
|
|
a4edf8b3f6 | ||
| 8328d6c06e | |||
|
|
2ac33e8cec | ||
|
|
bbb911c917 | ||
|
|
bef9723255 | ||
|
|
47e3e5218d | ||
|
|
72800e1e44 | ||
| f6547b02a4 | |||
|
|
8fb22017d3 | ||
|
|
6f8070c85f | ||
| c09a0f4b85 | |||
| ba22f2b796 | |||
|
|
f62aa1f7f7 | ||
|
|
f19a467300 | ||
|
|
f4550b9c76 | ||
|
|
a5791ef76b | ||
|
|
dff4b556eb | ||
|
|
c013cd2eac | ||
| dc366ae1c3 | |||
| a9d2ba8dde | |||
|
|
de138328e9 | ||
|
|
757501efa8 | ||
|
|
73028c70d2 | ||
|
|
bdb3efd81d | ||
| 20423028f7 | |||
|
|
6442219087 | ||
|
|
a0148badaf | ||
| 8745f8bbbe | |||
|
|
277b1710fa | ||
| 1115520106 | |||
|
|
c8b63a7a7a | ||
|
|
1ed27ed29f | ||
|
|
072a2b6bfc | ||
|
|
b2bb7c3901 | ||
|
|
ad2752197a | ||
| 424a81ac53 | |||
|
|
38332616fa | ||
| 118068bafe | |||
| 8103b45a61 | |||
|
|
ef4c4a0a17 | ||
|
|
31a2311698 | ||
|
|
9937c3cb5f | ||
| 482d7f6ce5 | |||
|
|
5905c0b438 | ||
| 594ac7d4d4 | |||
| 9d2aad81e4 | |||
| 6b1303d250 | |||
| c45800f6d5 | |||
|
|
74cdfaf882 | ||
|
|
34ff162db1 | ||
|
|
bd6af21b99 | ||
| f0566a5969 | |||
| 76a571921a | |||
| 512ed2a542 | |||
|
|
c2c5c9668e | ||
|
|
a0b0023def | ||
| a11189d85c | |||
| ed54f79983 | |||
|
|
f03622ac5b | ||
|
|
bf3fe9450f | ||
| b4e2727c58 | |||
| 977ab4bf1b | |||
| d26504c841 | |||
| 418e17a427 | |||
| 4e0e50a4f8 | |||
| e05403bfa7 | |||
| b1a2ccd018 | |||
| 10f39b44a2 | |||
| 9eca074ffb | |||
| 9820d0a915 | |||
|
|
525de0c24c | ||
|
|
744c72dea2 | ||
|
|
b4114f19de | ||
|
|
b0dde94314 | ||
|
|
da7015fd89 | ||
|
|
9058c9081b | ||
|
|
34f317780e | ||
|
|
708b40880e | ||
|
|
bf661b5c1c | ||
|
|
57b08a99c6 | ||
| 8bc8a97e83 | |||
|
|
53548aec32 | ||
|
|
1380af6d50 | ||
|
|
21dcd87be2 | ||
|
|
fb97e421bb | ||
|
|
4f2ae176fa | ||
|
|
06e21711f2 | ||
|
|
95c564595f | ||
|
|
e725cd8a60 | ||
|
|
8507ad8378 | ||
|
|
cb8495fb0d | ||
|
|
8f8d3d38cc | ||
|
|
7eb80121a1 | ||
|
|
3736082096 | ||
|
|
2f303e63a3 | ||
|
|
ab2e5c346e | ||
|
|
ebb45238b0 | ||
|
|
6763721043 | ||
|
|
e235c3ef66 | ||
|
|
40b0e535cb | ||
|
|
9438301ebd | ||
|
|
bfed1b3e93 | ||
|
|
a9515f42b3 | ||
|
|
bbb62586f9 | ||
|
|
6aef21797d |
@@ -76,10 +76,25 @@
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.docx4j</groupId>-->
|
||||
<!-- <artifactId>docx4j-core</artifactId>-->
|
||||
<!-- <version>8.3.8</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j</artifactId>
|
||||
<version>3.3.4</version>
|
||||
<version>6.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
@@ -97,6 +112,18 @@
|
||||
<version>2.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>RestTemplate-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.10.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -3,13 +3,10 @@ package com.njcn.gather.detection.controller;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -34,7 +31,9 @@ public class PreDetectionController extends BaseController {
|
||||
private final PreDetectionService preDetectionService;
|
||||
|
||||
/**
|
||||
* 开始检测
|
||||
* 开始检测通用入口
|
||||
*
|
||||
* @param param 实体参数
|
||||
*/
|
||||
@PostMapping("/startPreTest")
|
||||
@OperateInfo
|
||||
@@ -46,6 +45,7 @@ public class PreDetectionController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 程控源-源通讯校验
|
||||
*
|
||||
@@ -128,4 +128,18 @@ public class PreDetectionController extends BaseController {
|
||||
preDetectionService.restartTemTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始比对检测(包括预检测、正式检测)通用入口
|
||||
*/
|
||||
@PostMapping("/startContrastTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("开始比对检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startContrastTest(@RequestBody @Validated ContrastDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startContrastTest");
|
||||
preDetectionService.startContrastTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
@@ -18,6 +19,7 @@ import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -31,18 +33,9 @@ public class SocketSourceResponseService {
|
||||
/**
|
||||
* 向webSocket客户端发送消息
|
||||
*/
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
private final String DEV = "_Dev";
|
||||
private final String source = "_Source";
|
||||
|
||||
private final String stepTag = "&&";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
|
||||
|
||||
@Value("${socket.device.ip}")
|
||||
private String ip;
|
||||
|
||||
@@ -55,7 +48,7 @@ public class SocketSourceResponseService {
|
||||
|
||||
public void deal(PreDetectionParam param, String msg) throws Exception {
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
String[] tem = socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG);
|
||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
if (ObjectUtil.isNotNull(enumByCode)) {
|
||||
switch (enumByCode) {
|
||||
@@ -190,14 +183,14 @@ public class SocketSourceResponseService {
|
||||
//向前端推送信息
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(monitorIdList);
|
||||
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
|
||||
phaseSequenceParam.setReadCount(10);
|
||||
phaseSequenceParam.setIgnoreCount(7);
|
||||
phaseSequenceParam.setReadCount(3);
|
||||
phaseSequenceParam.setIgnoreCount(4);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
@@ -219,8 +212,8 @@ public class SocketSourceResponseService {
|
||||
/**
|
||||
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
|
||||
*
|
||||
* @param param
|
||||
* @param socketDataMsg
|
||||
* @param param 参数
|
||||
* @param socketDataMsg 消息
|
||||
*/
|
||||
private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
@@ -231,11 +224,11 @@ public class SocketSourceResponseService {
|
||||
case SUCCESS:
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
String s = param.getUserPageId() + DEV;
|
||||
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
//List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", devList);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
@@ -301,7 +294,7 @@ public class SocketSourceResponseService {
|
||||
//向前端推送信息
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
@@ -350,11 +343,11 @@ public class SocketSourceResponseService {
|
||||
//向前端推送信息
|
||||
// webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
|
||||
String s = param.getUserPageId() + DEV;
|
||||
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
List<String> comm = sourceIssue.getDevValueTypeList(); //形如:类型&小项code这种形式。例如:real$VRMS、real$IRMS
|
||||
System.out.println("向装置下发的参数>>>>>>>>" + comm);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + sourceIssue.getType());
|
||||
int ignoreCount;
|
||||
int readData;
|
||||
if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
|
||||
@@ -375,9 +368,11 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
}
|
||||
}
|
||||
List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
System.out.println("devList is empty:" + CollectionUtils.isEmpty(devList));
|
||||
|
||||
//List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
phaseSequenceParam.setMoniterIdList(monitorIdList);
|
||||
phaseSequenceParam.setDataType(comm);
|
||||
phaseSequenceParam.setReadCount(readData);
|
||||
phaseSequenceParam.setIgnoreCount(ignoreCount);
|
||||
@@ -393,7 +388,7 @@ public class SocketSourceResponseService {
|
||||
});
|
||||
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1] + stepBegin);
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.START_TAG);
|
||||
webSocketVO.setDesc(SocketManager.getSourceList().get(0).getDesc());
|
||||
webSocketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
@@ -421,16 +416,16 @@ public class SocketSourceResponseService {
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case MESSAGE_PARSING_ERROR:
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
break;
|
||||
case UNABLE_TO_RESPOND:
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
|
||||
@@ -13,6 +13,9 @@ public interface DetectionCommunicateConstant {
|
||||
|
||||
String DEVICE_CHANNEL_NAME = "AUTO_DETECTION_DEV";
|
||||
|
||||
String DEV = "_Dev";
|
||||
|
||||
String SOURCE = "_Source";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,17 +28,13 @@ public enum DetectionCodeEnum {
|
||||
V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
|
||||
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
|
||||
PST("PST", "短时间闪变"),
|
||||
P("P", "功率"),
|
||||
|
||||
|
||||
P_FUND("P_FUND", "功率"),
|
||||
I1("I1", "基波电流"),
|
||||
|
||||
|
||||
|
||||
|
||||
UNKNOWN_ERROR("-1", "未知异常"),
|
||||
|
||||
;
|
||||
|
||||
STAR("Star","星型接线"),
|
||||
DELTA("Delta","角型接线");
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
@@ -48,6 +48,8 @@ public enum SourceOperateCodeEnum {
|
||||
YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"),
|
||||
YJC_XYJY("yjc_xyjy", "协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "相序校验"),
|
||||
YJC_ALIGN("YJC_align","实时数据对齐校验"),
|
||||
YJC_MXYZXJY("YJC_mxyzxjy", "模型一致性校验"),
|
||||
FORMAL_REAL("formal_real","正式检测"),
|
||||
// SIMULATE_REAL("simulate_real","模拟检测"),
|
||||
Coefficient_Check("Coefficient_Check","系数校验"),
|
||||
@@ -55,11 +57,13 @@ public enum SourceOperateCodeEnum {
|
||||
QUITE_SOURCE("close_source","关闭源通讯"),
|
||||
ERROR_FLOW_END("error_flow_end","当前流程存在异常结束"),
|
||||
YXT("yxt","心跳"),
|
||||
REPORT_CAT("FTP_SEND$01","处理报告"),
|
||||
|
||||
UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"),
|
||||
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
|
||||
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
|
||||
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),
|
||||
DEVICE_ERROR("device_error","设备主动关闭连接,请稍后再试"),
|
||||
|
||||
|
||||
|
||||
@@ -68,17 +72,17 @@ public enum SourceOperateCodeEnum {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
COEFFICIENT_TEST("0","系数校验"),
|
||||
PRE_TEST("1","预检测"),
|
||||
FORMAL_TEST("2","正式检测"),
|
||||
TIME_TEST("3","守时检测"),
|
||||
PHASE_TEST("4","相序检测"),
|
||||
TEST_TEM_STOP("5","临时停止"),
|
||||
TEST_TEM_START("6","继续检测"),
|
||||
TEST_STOP("7","停止检测"),
|
||||
RE_ERROR_TEST("8","不合格项复检"),
|
||||
SIMULATE_TEST("9","模拟检测"),
|
||||
|
||||
// COEFFICIENT_TEST("0","系数校验"),
|
||||
// PRE_TEST("1","预检测"),
|
||||
// FORMAL_TEST("2","正式检测"),
|
||||
// TIME_TEST("3","守时检测"),
|
||||
// PHASE_TEST("4","相序检测"),
|
||||
// TEST_TEM_STOP("5","临时停止"),
|
||||
ALL_TEST("1","全部检测"),
|
||||
RE_ERROR_TEST("2","不合格项复检"),
|
||||
SIMULATE_TEST("4","模拟检测"),
|
||||
//TEST_STOP("7","停止检测"),
|
||||
//FAST_TEST("10","一键检测"),
|
||||
|
||||
/**
|
||||
* 系数校验步骤
|
||||
@@ -93,8 +97,10 @@ public enum SourceOperateCodeEnum {
|
||||
small_comp_end("small_comp_end","小电压校准结束"),
|
||||
|
||||
|
||||
|
||||
;
|
||||
/**
|
||||
* ftp文件传送指令
|
||||
*/
|
||||
FTP_SEND_01("FTP_SEND$01", "发送文件"),;
|
||||
|
||||
private final String value;
|
||||
private final String msg;
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum SourceResponseCodeEnum {
|
||||
SUCCESS(10200, "请求成功"),
|
||||
UNPROCESSED_BUSINESS(10201, "立即响应,业务还未处理,类似肯定应答"),
|
||||
NORMAL_RESPONSE(10202, "正常响应中间状态码"),
|
||||
ICD_NOT_FOUND(10500, "未找到对应ICD"),
|
||||
MESSAGE_PARSING_ERROR(10520, "报文解析有误"),
|
||||
CONTROLLED_SOURCE_ERROR(10521, "程控源参数有误"),
|
||||
TEST_ITEM_PARSING_ERROR(10522, "测试项解析有误"),
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.gather.detection.pojo.param;
|
||||
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-18
|
||||
*/
|
||||
@Data
|
||||
public class ContrastDetectionParam {
|
||||
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("用户ID,唯一标识")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotEmpty(message = DetectionValidMessage.DEV_IDS_NOT_EMPTY)
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty("标准设备ID列表")
|
||||
@NotEmpty(message = DetectionValidMessage.STANDARD_DEV_IDS_NOT_EMPTY)
|
||||
private List<String> standardDevIds;
|
||||
|
||||
/**
|
||||
* key为 标准设备ID_检测点序号、value为 被检设备ID_检测点序号
|
||||
*/
|
||||
@ApiModelProperty("配对关系")
|
||||
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
||||
private Map<String,String> pairs;
|
||||
/**
|
||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
||||
*/
|
||||
private List<Boolean> testItemList;
|
||||
}
|
||||
@@ -14,10 +14,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class PreDetectionParam {
|
||||
|
||||
/**
|
||||
* 操作类型 0.预检测 1.正式检测 2.系数校验
|
||||
*/
|
||||
private String operateType = "0";
|
||||
private String operateType;
|
||||
|
||||
/**
|
||||
* 检测计划id
|
||||
@@ -65,4 +62,19 @@ public class PreDetectionParam {
|
||||
private Boolean sendWebMsg;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private Float temperature;
|
||||
|
||||
/**
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
|
||||
/**
|
||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
||||
*/
|
||||
private List<Boolean> testItemList;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ public class DevData {
|
||||
@JSONField(name = "Time", ordinal = 1)
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 设备ip_通道号 这种形式
|
||||
*/
|
||||
@JSONField(name = "ID", ordinal = 2)
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.service;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
|
||||
@@ -49,4 +50,10 @@ public interface PreDetectionService {
|
||||
* @param param
|
||||
*/
|
||||
void closeTestSimulate(SimulateDetectionParam param);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void startContrastTest(ContrastDetectionParam param);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,19 @@
|
||||
package com.njcn.gather.detection.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
@@ -21,8 +24,10 @@ 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.NettyContrastClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
@@ -43,7 +48,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -65,6 +73,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
private final SocketSourceResponseService socketSourceResponseService;
|
||||
private final SocketContrastResponseService socketContrastResponseService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
|
||||
@Value("${socket.source.ip:192.168.1.138}")
|
||||
@@ -73,19 +82,23 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
@Value("${socket.source.port:61000}")
|
||||
private Integer port;
|
||||
|
||||
private final SocketSourceResponseService sourceResponseService;
|
||||
//private final SocketSourceResponseService sourceResponseService;
|
||||
|
||||
|
||||
@Override
|
||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||
// 参数校验,目前仅检查IP是否重复
|
||||
checkDevIp(param);
|
||||
// 参数校验,目前仅检查IP是否重复,后续可在里面扩展
|
||||
checkDevIp(param.getDevIds());
|
||||
//用于处理异常导致的socket通道未关闭,socket交互异常
|
||||
DetectionCommunicateUtil.checkCommunicateChannel(param);
|
||||
/*
|
||||
先组装源通讯协议
|
||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||
*/
|
||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
param.setScriptId(plan.getScriptId());
|
||||
param.setErrorSysId(plan.getErrorSysId());
|
||||
param.setCode(String.valueOf(plan.getCode()));
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||
@@ -122,7 +135,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
// NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, socketSourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -133,13 +147,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
WebServiceManager.addPreDetectionParam(param);
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
param.setSourceId(planSource.getSourceId());
|
||||
param.setScriptId(plan.getScriptId());
|
||||
param.setErrorSysId(plan.getErrorSysId());
|
||||
param.setCode(String.valueOf(plan.getCode()));
|
||||
if (ObjectUtil.isNotNull(planSource)) {
|
||||
//获取源初始化参数
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
@@ -149,7 +161,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
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));
|
||||
//建立与源控程序的socket连接,
|
||||
// NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -167,7 +181,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
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));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -190,7 +204,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
||||
SocketManager.sendMsg(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME, JSON.toJSONString(xuMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
@@ -198,7 +212,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(),param.getUserId());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
@@ -218,7 +232,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void sendScript(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
// 进行源通信连接
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
@@ -252,7 +266,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void closeTestSimulate(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
|
||||
}
|
||||
@@ -264,14 +278,64 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startContrastTest(ContrastDetectionParam param) {
|
||||
// 参数校验,目前仅检查IP是否重复,后续可在里面扩展
|
||||
checkDevIp(param.getDevIds());
|
||||
//用于处理异常导致的socket通道未关闭,socket交互异常
|
||||
DetectionCommunicateUtil.checkContrastCommunicateChannel(param.getUserId());
|
||||
socketContrastResponseService.init(param);
|
||||
|
||||
// 和通信模块进行连接
|
||||
this.sendContrastSocket(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 比对式-与通信模块进行连接
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void sendContrastSocket(ContrastDetectionParam param) {
|
||||
String s = param.getUserId() + CnSocketUtil.DEV_TAG;
|
||||
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
List<PreDetection> preDetections = BeanUtil.copyToList(FormalTestManager.devList, PreDetection.class);
|
||||
preDetections.addAll(BeanUtil.copyToList(FormalTestManager.standardDevList, PreDetection.class));
|
||||
preDetections.forEach(x -> {
|
||||
x.setDevType(x.getIcdType());
|
||||
x.getMonitorList().forEach(y -> {
|
||||
|
||||
String pt = y.getPt();
|
||||
int i = pt.indexOf(":");
|
||||
y.setPt(BigDecimal.valueOf(Double.parseDouble(pt.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(pt.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
|
||||
|
||||
String ct = y.getCt();
|
||||
i = ct.indexOf(":");
|
||||
y.setCt(BigDecimal.valueOf(Double.parseDouble(ct.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(ct.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
|
||||
});
|
||||
});
|
||||
map.put("deviceList", preDetections);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
SocketManager.sendMsg(s, json);
|
||||
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId(param.getUserId());
|
||||
NettyClient.socketClient(ip, port, preDetectionParam, json, new NettyContrastClientHandler(preDetectionParam, socketContrastResponseService));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验被检设备中是否存在IP重复的
|
||||
*/
|
||||
private void checkDevIp(PreDetectionParam param) {
|
||||
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
|
||||
private void checkDevIp(List<String> devIds) {
|
||||
List<PqDev> pqDevList = iPqDevService.listByIds(devIds);
|
||||
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
|
||||
if (ipList.size() != param.getDevIds().size()) {
|
||||
if (ipList.size() != devIds.size()) {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.njcn.gather.detection.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-28
|
||||
*/
|
||||
public class DetectionUtil {
|
||||
/**
|
||||
* 相角矫正到统一个区间
|
||||
*
|
||||
* @param phase
|
||||
* @return
|
||||
*/
|
||||
public static Double adjustPhase(Double phase) {
|
||||
if (phase < -180) {
|
||||
return phase + 360;
|
||||
}
|
||||
if (phase > 180) {
|
||||
return phase - 360;
|
||||
}
|
||||
return phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据是否对齐
|
||||
*
|
||||
* @param devData 被检设备数据
|
||||
* @param standardDevData 标准设备数据
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAlignData(DevData devData, DevData standardDevData) {
|
||||
if (ObjectUtil.isNotNull(devData) && ObjectUtil.isNotNull(standardDevData)) {
|
||||
|
||||
long devMillis = getMillis(devData.getTime());
|
||||
long standardMillis = getMillis(standardDevData.getTime());
|
||||
if (BigDecimal.valueOf(devMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.valueOf(standardMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP)) == 0) {
|
||||
return true;
|
||||
} else if (Math.abs(devMillis - standardMillis) < 100) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串日期时间转换为指定格式的LocalDateTime
|
||||
*
|
||||
* @param dateTimeStr
|
||||
* @param formatter
|
||||
* @return
|
||||
*/
|
||||
public static LocalDateTime timeFormat(String dateTimeStr, DateTimeFormatter formatter) {
|
||||
try {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateTimeStr, formatter.withZone(ZoneId.of("UTC")));
|
||||
LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();
|
||||
return localDateTime;
|
||||
} catch (DateTimeParseException e) {
|
||||
System.err.println("日期时间字符串格式错误: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串日期时间对应的毫秒数
|
||||
*
|
||||
* @param dateTimeStr
|
||||
* @return
|
||||
*/
|
||||
public static long getMillis(String dateTimeStr) {
|
||||
LocalDateTime localDateTime = timeFormat(dateTimeStr, DateTimeFormatter.ISO_DATE_TIME);
|
||||
return getMillis(localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取LocalDateTime的所对应的毫秒数
|
||||
*
|
||||
* @param localDateTime
|
||||
* @return
|
||||
*/
|
||||
public static long getMillis(LocalDateTime localDateTime) {
|
||||
return localDateTime.atZone(ZoneId.of("UTC")).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断value是否为0
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static boolean isZero(Double value) {
|
||||
BigDecimal bd = BigDecimal.valueOf(value);
|
||||
if(bd.subtract(BigDecimal.ZERO).abs().compareTo(BigDecimal.valueOf(0.001)) < 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CP95值
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public static List<Double> getCP95Doubles(List<Double> t) {
|
||||
if (CollUtil.isNotEmpty(t)) {
|
||||
if (t.size() < 21) {
|
||||
if (t.size() == 1) {
|
||||
return t;
|
||||
}
|
||||
if (t.size() > 1) {
|
||||
return t.subList(1, 2);
|
||||
}
|
||||
} else {
|
||||
int v = (int) (t.size() * 0.5);
|
||||
return t.subList(v, v + 1);
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CP95值所在索引
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public static int getCP95Idx(List<Double> t) {
|
||||
if (CollUtil.isNotEmpty(t)) {
|
||||
if (t.size() < 21) {
|
||||
if (t.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
if (t.size() > 1) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
int v = (int) (t.size() * 0.5);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部分值
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public static List<Double> getSectionValueDoubles(List<Double> t) {
|
||||
if (CollUtil.isNotEmpty(t)) {
|
||||
if (t.size() > 2) {
|
||||
Double max = Collections.max(t);
|
||||
Double min = Collections.min(t);
|
||||
t.remove(max);
|
||||
t.remove(min);
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平均值
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public static List<Double> getAvgDoubles(List<Double> t) {
|
||||
if (CollUtil.isNotEmpty(t)) {
|
||||
t = Arrays.asList(t.stream().mapToDouble(Double::doubleValue).average().orElse(0.0));
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list进行从大到小排序,并返回排序后的索引序列
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> sort(List<Double> list) {
|
||||
List<Integer> indexList = Stream.iterate(0, i -> i + 1).limit(list.size()).collect(Collectors.toList());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
int maxIdx = i;
|
||||
for (int j = i + 1; j < list.size(); j++) {
|
||||
if (list.get(j) > list.get(maxIdx)) {
|
||||
maxIdx = j;
|
||||
}
|
||||
}
|
||||
if (maxIdx != i) {
|
||||
double temp = list.get(i);
|
||||
list.set(i, list.get(maxIdx));
|
||||
list.set(maxIdx, temp);
|
||||
|
||||
int tempIdx = indexList.get(i);
|
||||
indexList.set(i, indexList.get(maxIdx));
|
||||
indexList.set(maxIdx, tempIdx);
|
||||
}
|
||||
}
|
||||
return indexList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* 检测通讯工具类
|
||||
*
|
||||
* @author hongawen
|
||||
@@ -26,8 +25,9 @@ public class DetectionCommunicateUtil {
|
||||
* 有则强行关闭
|
||||
*/
|
||||
public static void checkCommunicateChannel(PreDetectionParam param) {
|
||||
Channel channelSource = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
Channel channelDev = SocketManager.getChannelByUserId(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
|
||||
Channel channelSource = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.DEV);
|
||||
|
||||
if (Objects.nonNull(channelSource) && channelSource.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
@@ -43,8 +43,8 @@ public class DetectionCommunicateUtil {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
SocketManager.removeUser(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
|
||||
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
|
||||
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
@@ -54,5 +54,30 @@ public class DetectionCommunicateUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 比对式-检测是否存在已有的Socket通道,有则强行关闭
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
public static void checkContrastCommunicateChannel(String userId) {
|
||||
Channel channel = SocketManager.getChannelByUserId(userId);
|
||||
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("存在已有的Socket通道,强行关闭。。。。。。。。");
|
||||
CnSocketUtil.contrastSendquit(userId);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(userId);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,17 @@ import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
*/
|
||||
public class CnSocketUtil {
|
||||
|
||||
private final static String devTag = "_Dev";
|
||||
private final static String sourceTag = "_Source";
|
||||
public final static String DEV_TAG = "_Dev";
|
||||
|
||||
public final static String SOURCE_TAG = "_Source";
|
||||
|
||||
public final static String START_TAG = "_Start";
|
||||
|
||||
public final static String END_TAG = "_End";
|
||||
|
||||
public final static String STEP_TAG = "&&";
|
||||
|
||||
public final static String SPLIT_TAG = "_";
|
||||
|
||||
/**
|
||||
* 退出检测
|
||||
@@ -24,7 +33,8 @@ public class CnSocketUtil {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,30 +47,44 @@ public class CnSocketUtil {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("sourceId", param.getSourceId());
|
||||
socketMsg.setData(jsonObject.toJSONString());
|
||||
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送webSocket数据
|
||||
*/
|
||||
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc){
|
||||
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc) {
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(requestId);
|
||||
webSocketVO.setOperateCode(operatorType);
|
||||
webSocketVO.setData(data);
|
||||
webSocketVO.setDesc(desc);
|
||||
WebServiceManager.sendMessage(userId,webSocketVO);
|
||||
WebServiceManager.sendMessage(userId, webSocketVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送未知异常的webSocket数据
|
||||
*/
|
||||
public static void sendUnSocket(String userId){
|
||||
public static void sendUnSocket(String userId) {
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
WebServiceManager.sendMessage(userId,webSocketVO);
|
||||
WebServiceManager.sendMessage(userId, webSocketVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 比对式-退出检测
|
||||
*/
|
||||
public static void contrastSendquit(String userId) {
|
||||
System.out.println("比对式-发送关闭备通讯模块指令。。。。。。。。");
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(userId + DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -12,64 +16,98 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-08
|
||||
* @Description: 正式检测对象管理
|
||||
* @Description: 正式(预)检测对象管理
|
||||
*/
|
||||
public class FormalTestManager {
|
||||
|
||||
|
||||
/**
|
||||
* key:设备ip,value:当前设备下面的通道序号
|
||||
* key:设备ip,value:当前设备下面的通道号
|
||||
*/
|
||||
public static Map<String,List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
|
||||
public static Map<String, List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的装置
|
||||
* 所有参与检测的被检设备
|
||||
*/
|
||||
public static List<PreDetection> devList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的标准设备
|
||||
*/
|
||||
public static List<PreDetection> standardDevList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的监测点
|
||||
*/
|
||||
public static List<String> monitorIdListComm = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 所有参与检测的监测点。key:监测点id(ip_通道号),value:检测点实体
|
||||
*/
|
||||
public static Map<String, PreDetection.MonitorListDTO> monitorMap = new HashMap<>();
|
||||
|
||||
|
||||
//用于存储所有测点的实时数据
|
||||
/**
|
||||
* 用于存储所有测点的实时数据
|
||||
*/
|
||||
public static List<DevData> realDataXiList = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* key:设备ip,value:装置名称
|
||||
*/
|
||||
public static Map<String, String> devNameMapComm = new HashMap<>();
|
||||
|
||||
/**
|
||||
* key:设备ip,value:装置id
|
||||
*/
|
||||
public static Map<String, String> devIdMapComm = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 停止触发标识
|
||||
*/
|
||||
public static Boolean stopFlag = false;
|
||||
|
||||
|
||||
/**
|
||||
* 已经暂停后的标识
|
||||
*/
|
||||
public static Boolean hasStopFlag = false;
|
||||
|
||||
|
||||
/**
|
||||
* 暂停后的超时计时时间
|
||||
*/
|
||||
public static Integer stopTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* 强行赋值关系
|
||||
*/
|
||||
public static Map<String,String> harmonicRelationMap = new HashMap<>();
|
||||
public static Map<String, String> harmonicRelationMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 当前正在检测的计划
|
||||
*/
|
||||
public static AdPlan currentTestPlan;
|
||||
|
||||
/**
|
||||
* 比对式检测-检测项。
|
||||
*/
|
||||
public static List<String> testItemCodeList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 数据处理原则
|
||||
*/
|
||||
public static DictDataEnum dataRule;
|
||||
|
||||
/**
|
||||
* 所有参与比对式检测的被检设备、标准设备配对关系。key:标准设备id_通道号,value:被检设备id_通道号
|
||||
*/
|
||||
public static Map<String, String> pairsMap = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* 被检设备的数据。key:设备ip_通道号,value:DevData数据集合
|
||||
*/
|
||||
public static Map<String, List<DevData>> devDataMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 标准设备的数据。key:设备ip_通道号,value:DevData数据集合
|
||||
*/
|
||||
public static Map<String, List<DevData>> standardDevDataMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
@@ -94,6 +95,10 @@ public class SocketManager {
|
||||
*/
|
||||
public static volatile Map<Integer,Long> clockMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 用于存储比对式测试时间。
|
||||
*/
|
||||
public static volatile Map<DataSourceEnum, Long> contrastClockMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,54 +10,54 @@ import java.util.Arrays;
|
||||
* @date 2025/3/27 14:58
|
||||
*/
|
||||
public class UnitUtil {
|
||||
public static String unit(String code, Integer fly) {
|
||||
String unit = "";
|
||||
if (Arrays.asList(0, 1).contains(fly)) {
|
||||
if (DetectionCodeEnum.FREQ.getCode().equals(code)) {
|
||||
unit = "Hz";
|
||||
}
|
||||
if (DetectionCodeEnum.VRMS.getCode().equals(code)) {
|
||||
unit = "V";
|
||||
}
|
||||
if (DetectionCodeEnum.IRMS.getCode().equals(code)) {
|
||||
unit = "A";
|
||||
}
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(code) ||
|
||||
DetectionCodeEnum.SV_1_49.getCode().equals(code)||
|
||||
DetectionCodeEnum.V_UNBAN.getCode().equals(code) ||
|
||||
DetectionCodeEnum.I_UNBAN.getCode().equals(code)
|
||||
) {
|
||||
unit = "%";
|
||||
}
|
||||
if (DetectionCodeEnum.I2_50.getCode().equals(code) ||
|
||||
DetectionCodeEnum.SI_1_49.getCode().equals(code)
|
||||
) {
|
||||
unit = "A";
|
||||
}
|
||||
if (DetectionCodeEnum.P2_50.getCode().equals(code)) {
|
||||
unit = "W";
|
||||
}
|
||||
if (DetectionCodeEnum.P.getCode().equals(code)) {
|
||||
unit = "P";
|
||||
}
|
||||
if (DetectionCodeEnum.MAG.getCode().equals(code)) {
|
||||
unit = "V";
|
||||
}
|
||||
if (DetectionCodeEnum.DUR.getCode().equals(code)) {
|
||||
unit = "s";
|
||||
}
|
||||
if (DetectionCodeEnum.VA.getCode().equals(code) ||
|
||||
DetectionCodeEnum.IA.getCode().equals(code)
|
||||
) {
|
||||
unit = "°";
|
||||
}
|
||||
if (DetectionCodeEnum.DELTA_V.getCode().equals(code)
|
||||
) {
|
||||
unit = "%";
|
||||
}
|
||||
}else{
|
||||
unit = "%";
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
// public static String unit(String code, Integer fly) {
|
||||
// String unit = "";
|
||||
// if (Arrays.asList(0, 1).contains(fly)) {
|
||||
// if (DetectionCodeEnum.FREQ.getCode().equals(code)) {
|
||||
// unit = "Hz";
|
||||
// }
|
||||
// if (DetectionCodeEnum.VRMS.getCode().equals(code)) {
|
||||
// unit = "V";
|
||||
// }
|
||||
// if (DetectionCodeEnum.IRMS.getCode().equals(code)) {
|
||||
// unit = "A";
|
||||
// }
|
||||
// if (DetectionCodeEnum.V2_50.getCode().equals(code) ||
|
||||
// DetectionCodeEnum.SV_1_49.getCode().equals(code)||
|
||||
// DetectionCodeEnum.V_UNBAN.getCode().equals(code) ||
|
||||
// DetectionCodeEnum.I_UNBAN.getCode().equals(code)
|
||||
// ) {
|
||||
// unit = "%";
|
||||
// }
|
||||
// if (DetectionCodeEnum.I2_50.getCode().equals(code) ||
|
||||
// DetectionCodeEnum.SI_1_49.getCode().equals(code)
|
||||
// ) {
|
||||
// unit = "A";
|
||||
// }
|
||||
// if (DetectionCodeEnum.P2_50.getCode().equals(code)) {
|
||||
// unit = "W";
|
||||
// }
|
||||
// if (DetectionCodeEnum.P.getCode().equals(code)) {
|
||||
// unit = "P";
|
||||
// }
|
||||
// if (DetectionCodeEnum.MAG.getCode().equals(code)) {
|
||||
// unit = "V";
|
||||
// }
|
||||
// if (DetectionCodeEnum.DUR.getCode().equals(code)) {
|
||||
// unit = "s";
|
||||
// }
|
||||
// if (DetectionCodeEnum.VA.getCode().equals(code) ||
|
||||
// DetectionCodeEnum.IA.getCode().equals(code)
|
||||
// ) {
|
||||
// unit = "°";
|
||||
// }
|
||||
// if (DetectionCodeEnum.DELTA_V.getCode().equals(code)
|
||||
// ) {
|
||||
// unit = "%";
|
||||
// }
|
||||
// }else{
|
||||
// unit = "%";
|
||||
// }
|
||||
// return unit;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ public class WebServiceManager {
|
||||
channel.writeAndFlush(wd);
|
||||
}else {
|
||||
log.error("{}-websocket推送消息失败;当前用户-{}-客户端已经断开连接", LocalDateTime.now(),userId);
|
||||
// PreDetectionParam param = preDetectionParamMap.get("preDetectionParam");
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,14 +8,11 @@ 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.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -26,13 +23,8 @@ import java.util.concurrent.TimeUnit;
|
||||
* @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;
|
||||
|
||||
@@ -42,7 +34,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
private int consecutiveHeartbeatMisses = 0;
|
||||
|
||||
|
||||
public HeartbeatHandler(PreDetectionParam param,String type){
|
||||
public HeartbeatHandler(PreDetectionParam param, String type) {
|
||||
this.param = param;
|
||||
this.handlerType = type;
|
||||
}
|
||||
@@ -61,7 +53,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
// 每30秒发送一次心跳
|
||||
// 每10秒发送一次心跳
|
||||
private void scheduleHeartbeat(ChannelHandlerContext ctx) {
|
||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||
if (ctx.channel().isActive()) {
|
||||
@@ -70,14 +62,14 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.channel().writeAndFlush(JSON.toJSONString(msg)+"\n");
|
||||
ctx.channel().writeAndFlush(JSON.toJSONString(msg) + "\n");
|
||||
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send"+LocalDateTime.now());
|
||||
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send" + LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses++;
|
||||
if (consecutiveHeartbeatMisses >= MAX_HEARTBEAT_MISSES) {
|
||||
// 连续三次未收到心跳响应,断开连接
|
||||
System.out.println(handlerType+"连续三次未收到心跳响应,断开连接");
|
||||
if (dev.equals(handlerType)) {
|
||||
System.out.println(handlerType + "连续三次未收到心跳响应,断开连接");
|
||||
if (CnSocketUtil.DEV_TAG.equals(handlerType)) {
|
||||
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
|
||||
CnSocketUtil.quitSend(param);
|
||||
} else {
|
||||
@@ -89,7 +81,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
Thread.currentThread().interrupt();
|
||||
System.err.println("线程中断异常: " + e.getMessage());
|
||||
}
|
||||
String key = dev.equals(handlerType) ? param.getUserPageId() + dev : param.getUserPageId() + sourceTag;
|
||||
String key = CnSocketUtil.DEV_TAG.equals(handlerType) ? param.getUserPageId() + CnSocketUtil.DEV_TAG : param.getUserPageId() + CnSocketUtil.SOURCE_TAG;
|
||||
SocketManager.removeUser(key);
|
||||
consecutiveHeartbeatMisses = 0; // 重置连续心跳丢失次数
|
||||
}
|
||||
@@ -98,12 +90,11 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
// 过滤心跳包,避免进入业务逻辑
|
||||
if (isHeartbeatPacket(msg)) {
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response"+LocalDateTime.now());
|
||||
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response" + LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses = 0;
|
||||
return;
|
||||
}
|
||||
@@ -115,6 +106,6 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
private boolean isHeartbeatPacket(String msg) {
|
||||
// 判断是否为心跳包
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
return socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
return !Objects.isNull(socketDataMsg.getOperateCode()) && socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ 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();
|
||||
@@ -49,10 +46,10 @@ 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(new HeartbeatHandler(param, CnSocketUtil.SOURCE_TAG))
|
||||
.addLast(handler);
|
||||
} else {
|
||||
ch.pipeline()
|
||||
@@ -61,8 +58,11 @@ public class NettyClient {
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new HeartbeatHandler(param,dev))
|
||||
.addLast(new HeartbeatHandler(param, CnSocketUtil.DEV_TAG))
|
||||
//空闲状态的handler
|
||||
//readerIdleTimeSeconds:在指定的秒数内如果没有读取到任何数据,则触发IdleState.READER_IDLE事件。
|
||||
//writerIdleTimeSeconds:在指定的秒数内如果没有写入任何数据,则触发IdleState.WRITER_IDLE事件。
|
||||
//allIdleTimeSeconds:在指定的秒数内如果没有发生任何读取或写入操作,则触发IdleState.ALL_IDLE事件。
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(handler);
|
||||
}
|
||||
@@ -73,22 +73,28 @@ public class NettyClient {
|
||||
channelFuture.addListener((ChannelFutureListener) ch -> {
|
||||
if (!ch.isSuccess()) {
|
||||
System.out.println("链接服务端失败...");
|
||||
// 连接失败时关闭 group
|
||||
group.shutdownGracefully();
|
||||
} else {
|
||||
System.out.println("链接服务端成功...");
|
||||
System.out.println("客户端向服务端发送消息:"+port+msg);
|
||||
channelFuture.channel().writeAndFlush(msg+"\n");
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
if (ObjectUtil.isNotNull(groupByUserId)) {
|
||||
groupByUserId.shutdownGracefully().sync();
|
||||
}
|
||||
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, group);
|
||||
} else {
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
if (ObjectUtil.isNotNull(groupByUserId)) {
|
||||
groupByUserId.shutdownGracefully().sync();
|
||||
}
|
||||
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.DEV_TAG, group);
|
||||
}
|
||||
|
||||
System.out.println("客户端向服务端发送消息:" + port + msg);
|
||||
channelFuture.channel().writeAndFlush(msg + "\n");
|
||||
}
|
||||
});
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + "_Dev");
|
||||
if(ObjectUtil.isNotNull(groupByUserId)){
|
||||
groupByUserId.shutdownGracefully();
|
||||
}else{
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
SocketManager.addGroup(param.getUserPageId()+source,group);
|
||||
}else{
|
||||
SocketManager.addGroup(param.getUserPageId()+dev,group);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("连接socket服务端发送异常............" + e.getMessage());
|
||||
group.shutdownGracefully();
|
||||
@@ -100,9 +106,12 @@ public class NettyClient {
|
||||
socketDataMsg.setRequestId("connect");
|
||||
if (handler instanceof NettySourceClientHandler) {
|
||||
socketDataMsg.setOperateCode("Source");
|
||||
}else{
|
||||
} else if (handler instanceof NettyDevClientHandler) {
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketDataMsg.setOperateCode("Dev");
|
||||
} else {
|
||||
socketDataMsg.setOperateCode("Dev");
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.handler.timeout.TimeoutException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-25
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class NettyContrastClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
|
||||
private final PreDetectionParam param;
|
||||
private final SocketContrastResponseService socketContrastResponseService;
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.DEV_TAG, ctx.channel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
||||
System.out.println("contrastClientHandler接收server端数据>>>>>>" + msg);
|
||||
try {
|
||||
socketContrastResponseService.deal(param, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("与通信模块端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户事件的回调方法(自定义事件用于心跳机制)
|
||||
*
|
||||
* @param ctx
|
||||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
if (evt instanceof IdleStateEvent) { //IdleState.在一段时间内没有收到任何消息时,会触发该事件
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
System.out.println(LocalDateTime.now() + "contrastClientHandler触发读超时函数**************************************");
|
||||
SocketManager.contrastClockMap.put(DataSourceEnum.REAL_DATA, SocketManager.contrastClockMap.get(DataSourceEnum.REAL_DATA) + 60L);
|
||||
|
||||
//实时数据
|
||||
if (SocketManager.contrastClockMap.get(DataSourceEnum.REAL_DATA) >= 60) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》" + "实时数据已超时----------------关闭");
|
||||
timeoutSend();
|
||||
}
|
||||
// if (!FormalTestManager.hasStopFlag) {
|
||||
// if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
// SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
// if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
// SocketManager.clockMap.put(sourceIssue.getIndex(), SocketManager.clockMap.get(sourceIssue.getIndex()) + 60L);
|
||||
// } else {
|
||||
// SocketManager.clockMap.put(sourceIssue.getIndex(), 60L);
|
||||
// }
|
||||
//
|
||||
// if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
// //闪变,正常抛一轮最大等待20分钟超时
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
|
||||
// fly = true;
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// } else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
// //统计数据项,正常抛一轮数据,超时
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
|
||||
// fly = true;
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// } else {
|
||||
// //实时数据
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
|
||||
// fly = true;
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// fly = true;
|
||||
// //为空则认为是常规步骤,设定一分钟超时
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
|
||||
// }
|
||||
// if (fly) {
|
||||
// socketContrastResponseService.backCheckState(param);
|
||||
// }
|
||||
// } else {
|
||||
// //如果是暂停操作后
|
||||
// FormalTestManager.stopTime += 60;
|
||||
// System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
|
||||
// if (FormalTestManager.stopTime > 600) {
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有通道准备接入" + ctx.channel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
System.out.println("捕获到通信模块服务异常。。。。。。。");
|
||||
// 处理异常,例如记录日志、关闭连接等
|
||||
cause.printStackTrace();
|
||||
// 根据异常类型进行不同的处理
|
||||
if (cause instanceof ConnectException) {
|
||||
System.out.println("连接socket服务端异常");
|
||||
} else if (cause instanceof IOException) {
|
||||
System.out.println("IOException caught: There was an I/O error.");
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
System.out.println("TimeoutException caught: Operation timed out.");
|
||||
} else if (cause instanceof ProtocolException) {
|
||||
System.out.println("ProtocolException caught: Invalid protocol message.");
|
||||
} else {
|
||||
// 处理其他类型的异常
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
}
|
||||
CnSocketUtil.quitSend(param);
|
||||
// socketContrastResponseService.backCheckState(param);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收数据超时处理
|
||||
*/
|
||||
private void timeoutSend() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,11 @@ 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.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.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
@@ -25,11 +26,9 @@ import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,8 +40,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequiredArgsConstructor
|
||||
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private final String dev = "_Dev";
|
||||
|
||||
private final PreDetectionParam param;
|
||||
|
||||
private final SocketDevResponseService socketResponseService;
|
||||
@@ -56,7 +53,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
@@ -64,7 +61,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId() + dev, ctx.channel());
|
||||
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.DEV_TAG, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +76,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
e.printStackTrace();
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +87,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("设备通讯客户端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
|
||||
@@ -105,7 +100,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
Boolean fly = false;
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (evt instanceof IdleStateEvent) { //IdleState.在一段时间内没有收到任何消息时,会触发该事件
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
System.out.println(LocalDateTime.now() + "devHandler触发读超时函数**************************************");
|
||||
if (!FormalTestManager.hasStopFlag) {
|
||||
@@ -146,6 +141,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
fly = true;
|
||||
//为空则认为是常规步骤,设定一分钟超时
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
|
||||
}
|
||||
if (fly) {
|
||||
socketResponseService.backCheckState(param);
|
||||
@@ -185,7 +181,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.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
@@ -199,9 +195,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else {
|
||||
// 处理其他类型的异常
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
// 可以记录未知异常信息
|
||||
}
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketResponseService.backCheckState(param);
|
||||
ctx.close();
|
||||
}
|
||||
@@ -240,7 +238,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() + CnSocketUtil.END_TAG);
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
@@ -21,7 +15,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,10 +64,10 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception{
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("源通讯客户端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(webUser.getUserPageId()+sourceTag);
|
||||
SocketManager.removeUser(webUser.getUserPageId() + sourceTag);
|
||||
// System.out.println("断线了......" + ctx.channel());
|
||||
// ctx.channel().eventLoop().schedule(() -> {
|
||||
// System.out.println("断线重连......");
|
||||
@@ -125,7 +118,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 );
|
||||
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
|
||||
@@ -122,6 +122,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
|
||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接?
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
} else {
|
||||
preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId("cdf");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.gather.device.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -11,10 +10,11 @@ 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.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -129,8 +129,8 @@ public class PqDevController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
pqDevService.downloadTemplate();
|
||||
public void downloadTemplate(@RequestBody PqDevParam pqDevParam) {
|
||||
pqDevService.downloadTemplate(pqDevParam.getPattern());
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@@ -140,15 +140,22 @@ public class PqDevController extends BaseController {
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<Object> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
public HttpResult<Boolean> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, @RequestParam("planId") String planId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
pqDevService.importDev(file, patternId, null, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
if("null".equals(planId)){
|
||||
planId = null;
|
||||
}
|
||||
Boolean result = pqDevService.importDev(file, patternId, planId, response);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -162,39 +169,12 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<PqDev> pqDevList = pqDevService.listByPlanId(param);
|
||||
|
||||
List<PqDevVO> result = BeanUtil.copyToList(pqDevList, PqDevVO.class);
|
||||
result.forEach(pqDevVO -> {
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
pqDevVO.setDevVolt(devType.getDevVolt());
|
||||
pqDevVO.setDevCurr(devType.getDevCurr());
|
||||
}
|
||||
});
|
||||
@OperateInfo
|
||||
@GetMapping("/getSelectOptions")
|
||||
@ApiOperation("根据历史记录信息来获取下拉框内容")
|
||||
public HttpResult<Map<String, List<String>>> getSelectOptions(@RequestParam("pattern") String pattern) {
|
||||
String methodDescribe = getMethodDescribe("getSelectOptions");
|
||||
Map<String, List<String>> result = pqDevService.listSelectOptions(pattern);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqDevService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.njcn.gather.device.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
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.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "标准设备管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqStandardDev")
|
||||
@RequiredArgsConstructor
|
||||
public class PqStandardDevController extends BaseController {
|
||||
private final IPqStandardDevService pqStandardDevService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询标准设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqStandardDev>> list(@RequestBody PqStandardDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<PqStandardDev> result = pqStandardDevService.listPqStandardDevs(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询标准设备")
|
||||
@ApiImplicitParam(name = "id", value = "标准设备id", required = true)
|
||||
public HttpResult<PqStandardDev> getById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
||||
PqStandardDev result = pqStandardDevService.getPqStandardDevById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增标准设备")
|
||||
@ApiImplicitParam(name = "param", value = "标准设备", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated PqStandardDevParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqStandardDevService.addPqStandardDev(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改标准设备")
|
||||
@ApiImplicitParam(name = "param", value = "标准设备", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated PqStandardDevParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
boolean result = pqStandardDevService.updatePqStandardDev(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除标准设备")
|
||||
@ApiImplicitParam(name = "ids", value = "标准设备id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
boolean result = pqStandardDevService.deletePqStandardDevs(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("批量导出标准设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody PqStandardDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
pqStandardDevService.export(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载标准设备导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
pqStandardDevService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping("/import")
|
||||
@ApiOperation("导入标准设备")
|
||||
@ApiImplicitParam(name = "file", value = "导入文件", required = true)
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},导入文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
pqStandardDevService.importData(file, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取所有标准设备")
|
||||
public HttpResult<List<PqStandardDev>> getAll() {
|
||||
String methodDescribe = getMethodDescribe("getAll");
|
||||
LogUtil.njcnDebug(log, "{},查询所有数据", methodDescribe);
|
||||
List<PqStandardDev> result = pqStandardDevService.lambdaQuery().eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出指定计划已关联的标准设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqStandardDev>> listByPlanId(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<PqStandardDev> pqDevVOList = pqStandardDevService.listByPlanId(planId);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
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.PreDetection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -47,6 +49,12 @@ public interface PqDevMapper extends MPJBaseMapper<PqDev> {
|
||||
*
|
||||
* @param planId
|
||||
*/
|
||||
String getScriptIdByPlanId(String planId);
|
||||
String getScriptIdByPlanId(@Param("planId")String planId);
|
||||
|
||||
List<PqDevVO> selectByQueryParam(PqDevParam.QueryParam param);
|
||||
|
||||
PqDevVO selectByDevId(@Param("devId") String devId);
|
||||
|
||||
List<PqDevVO> listByDevIds(@Param("devIds") List<String> devIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-02
|
||||
*/
|
||||
public interface PqDevSubMapper extends MPJBaseMapper<PqDevSub> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @date 2025-05-09
|
||||
*/
|
||||
public interface PqStandardDevMapper extends MPJBaseMapper<PqStandardDev> {
|
||||
|
||||
List<PreDetection> listStandardDevPreDetection(@Param("devIds") List<String> ids);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="DevResultMap" type="com.njcn.gather.device.pojo.vo.PreDetection">
|
||||
<id column="Id" property="devId" />
|
||||
<id column="Name" property="devName" />
|
||||
<id column="IP" property="devIP" />
|
||||
<result column="Port" property="port" />
|
||||
<result column="Dev_Type" property="devType" />
|
||||
<result column="Series" property="devCode" />
|
||||
<result column="Dev_Key" property="devKey" />
|
||||
<result column="icdType" property="icdType" />
|
||||
<result column="Dev_Chns" property="devChns" />
|
||||
<result column="Dev_Volt" property="devVolt" />
|
||||
<result column="Dev_Curr" property="devCurr" />
|
||||
<id column="Id" property="devId"/>
|
||||
<id column="Name" property="devName"/>
|
||||
<id column="IP" property="devIP"/>
|
||||
<result column="Port" property="port"/>
|
||||
<result column="Dev_Type" property="devType"/>
|
||||
<result column="Series" property="devCode"/>
|
||||
<result column="Dev_Key" property="devKey"/>
|
||||
<result column="icdType" property="icdType"/>
|
||||
<result column="Dev_Chns" property="devChns"/>
|
||||
<result column="Dev_Volt" property="devVolt"/>
|
||||
<result column="Dev_Curr" property="devCurr"/>
|
||||
|
||||
<collection
|
||||
property="monitorList"
|
||||
@@ -50,24 +50,84 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="finishPlan" >
|
||||
update ad_plan set Test_State = 2 where id = #{planId}
|
||||
<update id="finishPlan">
|
||||
update ad_plan
|
||||
set Test_State = 2
|
||||
where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updateReportState" >
|
||||
update pq_dev set Report_State = 1 where id = #{id}
|
||||
<update id="updateReportState">
|
||||
update pq_dev
|
||||
set Report_State = 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanCheckResult">
|
||||
update ad_plan set Result = #{checkResult} where id = #{planId}
|
||||
update ad_plan
|
||||
set Result = #{checkResult}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanTestState">
|
||||
update ad_plan set Test_State = #{testState} where id = #{planId}
|
||||
update ad_plan
|
||||
set Test_State = #{testState}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
|
||||
<select id="getScriptIdByPlanId" resultType="java.lang.String">
|
||||
SELECT Script_Id FROM ad_plan WHERE id = #{planId}
|
||||
SELECT Script_Id
|
||||
FROM ad_plan
|
||||
WHERE id = #{planId}
|
||||
</select>
|
||||
|
||||
<select id="selectByQueryParam" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
|
||||
SELECT dev.*,dev_sub.* FROM pq_dev dev
|
||||
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
|
||||
<where>
|
||||
dev.state = 1
|
||||
<if test="planIdList!= null and planIdList.size!=0">
|
||||
AND dev.Plan_Id in
|
||||
<foreach collection="planIdList" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="name!= null and name!= ''">
|
||||
AND dev.Name LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
<if test="checkStateList!= null and checkStateList.size()!= 0 ">
|
||||
AND dev_sub.Check_State in
|
||||
<foreach collection="checkStateList" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="checkResult!= null">
|
||||
AND dev_sub.Check_Result = #{checkResult}
|
||||
</if>
|
||||
<if test="reportState!= null">
|
||||
AND dev_sub.Report_State = #{reportState}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY dev.Create_Time DESC,dev.Name
|
||||
</select>
|
||||
|
||||
<select id="selectByDevId" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
|
||||
SELECT dev.*, dev_sub.*
|
||||
FROM pq_dev dev
|
||||
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
|
||||
WHERE dev.Id = #{devId}
|
||||
</select>
|
||||
|
||||
<select id="listByDevIds" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
|
||||
SELECT dev.*, dev_sub.*
|
||||
FROM pq_dev dev
|
||||
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
|
||||
WHERE dev.state = 1
|
||||
<if test="devIds!= null and devIds.size() != 0">
|
||||
AND dev.Id in
|
||||
<foreach collection="devIds" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.storage.mapper.AdNonHarmonicMapper">
|
||||
|
||||
<mapper namespace="com.njcn.gather.device.mapper.PqDevSubMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.mapper.PqStandardDevMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="standardDevResultMap" type="com.njcn.gather.device.pojo.vo.PreDetection">
|
||||
<id column="Id" property="devId"/>
|
||||
<id column="Name" property="devName"/>
|
||||
<id column="IP" property="devIP"/>
|
||||
<result column="Port" property="port"/>
|
||||
<result column="Dev_Type" property="devType"/>
|
||||
<result column="Series" property="devCode"/>
|
||||
<result column="Dev_Key" property="devKey"/>
|
||||
<result column="icdType" property="icdType"/>
|
||||
<result column="Dev_Chns" property="devChns"/>
|
||||
<result column="Dev_Volt" property="devVolt"/>
|
||||
<result column="Dev_Curr" property="devCurr"/>
|
||||
|
||||
<!-- <collection-->
|
||||
<!-- property="monitorList"-->
|
||||
<!-- column="{ devId = Id}"-->
|
||||
<!-- select="com.njcn.gather.monitor.mapper.PqMonitorMapper.selectMonitorInfo"-->
|
||||
<!-- >-->
|
||||
<!-- </collection>-->
|
||||
</resultMap>
|
||||
|
||||
<select id="listStandardDevPreDetection" resultMap="standardDevResultMap">
|
||||
select
|
||||
standard_dev.Id,
|
||||
standard_dev.Name,
|
||||
standard_dev.IP,
|
||||
standard_dev.Port,
|
||||
standard_dev.Dev_Type,
|
||||
standard_dev.Series,
|
||||
standard_dev.Dev_Key,
|
||||
dev_type.icdType,
|
||||
dev_type.Dev_Chns,
|
||||
dev_type.Dev_Volt,
|
||||
dev_type.Dev_Curr
|
||||
from pq_standard_dev standard_dev
|
||||
inner join pq_dev_type dev_type on standard_dev.Dev_Type = dev_type.id
|
||||
where standard_dev.Id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.Getter;
|
||||
public enum DevReportStateEnum {
|
||||
NOT_GENERATED("未生成", 0),
|
||||
GENERATED("已生成", 1),
|
||||
GENERATED_UPLOADED("已生成且已上传", 3),
|
||||
UNCHECKED("未检", 2);
|
||||
|
||||
private final Integer value;
|
||||
|
||||
@@ -6,12 +6,14 @@ import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ public class PqDevParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty(value = "设备类型,字典表", required = true)
|
||||
@ApiModelProperty(value = "设备类型", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
@@ -98,18 +100,16 @@ public class PqDevParam {
|
||||
@ApiModelProperty("报告路径")
|
||||
private String reportPath;
|
||||
|
||||
@ApiModelProperty("设备关键信息二维码")
|
||||
private String qrCode;
|
||||
// @ApiModelProperty("设备关键信息二维码")
|
||||
// private String qrCode;
|
||||
|
||||
@ApiModelProperty(value = "检测次数,默认为0", required = true)
|
||||
@NotNull(message = DetectionValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
@Min(value = 0, message = DetectionValidMessage.RECHECK_NUM_FORMAT_ERROR)
|
||||
private Integer reCheckNum;
|
||||
// @ApiModelProperty(value = "检测次数,默认为0", required = true)
|
||||
// @NotNull(message = DetectionValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
// @Min(value = 0, message = DetectionValidMessage.RECHECK_NUM_FORMAT_ERROR)
|
||||
// private Integer reCheckNum;
|
||||
|
||||
@ApiModelProperty("是否支持系数校准")
|
||||
@Min(value = 0, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
|
||||
private String factorFlag;
|
||||
private Integer factorFlag;
|
||||
|
||||
@ApiModelProperty("监测点台账列表")
|
||||
@Valid
|
||||
@@ -121,6 +121,22 @@ public class PqDevParam {
|
||||
@ApiModelProperty("预投计划")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@ApiModelProperty("委托方")
|
||||
private String delegate;
|
||||
|
||||
@ApiModelProperty("被检通道")
|
||||
private String inspectChannel;
|
||||
|
||||
@ApiModelProperty("投运日期")
|
||||
@DateTimeStrValid(message = DetectionValidMessage.OPERATION_DATE_FORMAT_ERROR)
|
||||
private String operationDate;
|
||||
|
||||
@ApiModelProperty("定验日期")
|
||||
@DateTimeStrValid(message = DetectionValidMessage.INSPECT_DATE_FORMAT_ERROR)
|
||||
private String inspectDate;
|
||||
|
||||
@ApiModelProperty("是否为导入设备")
|
||||
private Integer importFlag;
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@@ -150,7 +166,7 @@ public class PqDevParam {
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("检测计划ID")
|
||||
private String planId;
|
||||
private List<String> planIdList;
|
||||
|
||||
@ApiModelProperty("检测状态列表")
|
||||
private List<
|
||||
@@ -167,6 +183,20 @@ public class PqDevParam {
|
||||
@Max(value = 2, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
private Integer reportState;
|
||||
|
||||
@ApiModelProperty("所属地市名称")
|
||||
private String cityName;
|
||||
|
||||
@ApiModelProperty("所属供电公司名称")
|
||||
private String gdName;
|
||||
|
||||
@ApiModelProperty("所属电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("地市")
|
||||
private String region;
|
||||
|
||||
@ApiModelProperty("是否分配")
|
||||
private Integer assign;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -183,12 +213,15 @@ public class PqDevParam {
|
||||
@Data
|
||||
public static class BindPlanParam {
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@NotNull(message = DetectionValidMessage.PLAN_ID_NOT_NULL)
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty("0-解绑、1-绑定")
|
||||
private Integer bindFlag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.njcn.gather.device.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-05-09
|
||||
*/
|
||||
@Data
|
||||
public class PqStandardDevParam {
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备类型", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "设备厂家", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.MANUFACTURER_FORMAT_ERROR)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "通信协议", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PROTOCOL_FORMAT_ERROR)
|
||||
private String protocol;
|
||||
|
||||
@ApiModelProperty(value = "ip地址", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "端口", required = true)
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@ApiModelProperty(value = "装置是否为加密版本", required = true)
|
||||
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
|
||||
@Min(value = 0, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@ApiModelProperty("识别码(3ds加密)")
|
||||
private String series;
|
||||
|
||||
@ApiModelProperty("秘钥(3ds加密)")
|
||||
private String devKey;
|
||||
|
||||
@ApiModelProperty(value = "可检通道", required = true)
|
||||
private String inspectChannel;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备厂家", required = true)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "设备类型", required = true)
|
||||
private String devType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqStandardDevParam {
|
||||
@ApiModelProperty(value = "标准设备id", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -15,7 +14,6 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -115,7 +113,6 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 送样日期
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@@ -136,70 +133,58 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String subName;
|
||||
|
||||
/**
|
||||
* 检测状态
|
||||
*/
|
||||
private Integer checkState;
|
||||
|
||||
/**
|
||||
* 检测结果
|
||||
*/
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 报告状态
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 报告路径
|
||||
*/
|
||||
private String reportPath;
|
||||
|
||||
/**
|
||||
* 设备关键信息二维码
|
||||
*/
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* 检测次数,默认为0
|
||||
*/
|
||||
@TableField(value = "ReCheck_Num")
|
||||
private Integer reCheckNum;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 检测计划id
|
||||
*/
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 守时检测结果(0:不合格, 1:合格)
|
||||
*/
|
||||
private Integer timeCheckResult;
|
||||
|
||||
/**
|
||||
* 是否支持系数校准(0:不支持,1:支持)
|
||||
*/
|
||||
private Integer factorFlag;
|
||||
|
||||
/**
|
||||
* 系数校准结果(0:不合格,1:合格)
|
||||
* 预投计划
|
||||
*/
|
||||
private Integer factorCheckResult;
|
||||
|
||||
@TableField("Check_Time")
|
||||
private LocalDateTime checkTime;
|
||||
|
||||
@TableField("Check_By")
|
||||
private String checkBy;
|
||||
|
||||
@TableField("Preinvestment_Plan")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
/**
|
||||
* 委托方
|
||||
*/
|
||||
private String delegate;
|
||||
|
||||
/**
|
||||
* 可检通道
|
||||
*/
|
||||
private String inspectChannel;
|
||||
|
||||
/**
|
||||
* 定检日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate inspectDate;
|
||||
|
||||
/**
|
||||
* 谐波系统设备id
|
||||
*/
|
||||
private String harmSysId;
|
||||
|
||||
/**
|
||||
* 是否为导入设备(比对式使用) 0-否 1-是
|
||||
*/
|
||||
private Integer importFlag;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_dev_sub")
|
||||
public class PqDevSub {
|
||||
private static final long serialVersionUID = -93146063424890267L;
|
||||
/**
|
||||
* 关联pq_dev表的id字段
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
/**
|
||||
* 检测状态 0-未检、1检测中、2检测完成、3归档
|
||||
*/
|
||||
private Integer checkState;
|
||||
|
||||
/**
|
||||
* 检测结果 0不符合、1符合、2未检
|
||||
*/
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 报告生成状态 0未生成、1已生成、2未检
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 检测次数
|
||||
*/
|
||||
@TableField(value = "ReCheck_Num")
|
||||
private Integer recheckNum;
|
||||
|
||||
/**
|
||||
* 守时检测结果 0:不合格, 1:合格,2:/表示没有做守时检测
|
||||
*/
|
||||
private Integer timeCheckResult;
|
||||
|
||||
/**
|
||||
* 系数校准结果 0:不合格,1:合格,2:/表示没有做系数校准
|
||||
*/
|
||||
private Integer factorCheckResult;
|
||||
|
||||
/**
|
||||
* 实时数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer realtimeResult;
|
||||
|
||||
/**
|
||||
* 统计数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer statisticsResult;
|
||||
|
||||
/**
|
||||
* 录波数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer recordedResult;
|
||||
|
||||
/**
|
||||
* 检测人
|
||||
*/
|
||||
private String checkBy;
|
||||
|
||||
/**
|
||||
* 检测时间
|
||||
*/
|
||||
@TableField("Check_Time")
|
||||
private LocalDateTime checkTime;
|
||||
|
||||
/**
|
||||
* 预检测耗时
|
||||
*/
|
||||
private Integer preDetectTime;
|
||||
|
||||
/**
|
||||
* 系数校准耗时
|
||||
*/
|
||||
private Integer coefficientTime;
|
||||
|
||||
/**
|
||||
* 正式检测耗时
|
||||
*/
|
||||
private Integer formalCheckTime;
|
||||
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private Float temperature;
|
||||
|
||||
/**
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @date 2025-05-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_standard_dev")
|
||||
public class PqStandardDev extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 932459726326242984L;
|
||||
/**
|
||||
* 标准设备id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 标准设备-名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 标准设备-设备类型
|
||||
*/
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 标准设备-设备厂家
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 可检通道(可多选,中间使用英文逗号隔开)
|
||||
*/
|
||||
private String inspectChannel;
|
||||
|
||||
/**
|
||||
* 通信协议
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 是否加密(0否、1是)
|
||||
*/
|
||||
private Integer encryptionFlag;
|
||||
|
||||
/**
|
||||
* 识别码
|
||||
*/
|
||||
private String series;
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
private String devKey;
|
||||
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CNDevExcel {
|
||||
@NotBlank(message = DetectionValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@Excel(name = "装置编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-05-07
|
||||
*/
|
||||
@Data
|
||||
public class ContrastDevExcel implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
@Excel(name = "所属地市*", width = 30, needMerge = true, orderNum = "1")
|
||||
private String cityName;
|
||||
|
||||
@Excel(name = "所属供电公司*", width = 30, needMerge = true, orderNum = "2")
|
||||
private String gdName;
|
||||
|
||||
@Excel(name = "所属电站*", width = 30, needMerge = true, orderNum = "3")
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "设备名称*", width = 20, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备序列号*", width = 20, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, needMerge = true, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备厂家*", width = 20, needMerge = true, orderNum = "7")
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
// @Excel(name = "被检通道", width = 20, needMerge = true, orderNum = "8")
|
||||
// private String inspectChannel;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, needMerge = true, orderNum = "8")
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, needMerge = true, orderNum = "9")
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议*", width = 15, needMerge = true, orderNum = "10")
|
||||
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "是否加密*", width = 20, needMerge = true, replace = {"否_0", "是_1"}, orderNum = "11")
|
||||
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, needMerge = true, orderNum = "12")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, needMerge = true, orderNum = "13")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, needMerge = true, orderNum = "14")
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, needMerge = true, orderNum = "15")
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "投运日期(yyyy-MM-dd)*", width = 30, needMerge = true, orderNum = "16", format = "yyyy-MM-dd")
|
||||
@NotNull(message = DetectionValidMessage.CREATE_DATE_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "定检日期(yyyy-MM-dd)*", width = 30, needMerge = true, orderNum = "17", format = "yyyy-MM-dd")
|
||||
@NotNull(message = DetectionValidMessage.INSPECT_DATE_NOT_NULL)
|
||||
private LocalDate inspectDate;
|
||||
|
||||
@Excel(name = "谐波系统设备id*", width = 30, needMerge = true, orderNum = "18")
|
||||
@NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@ExcelCollection(name = "监测点信息", orderNum = "19")
|
||||
private List<PqMonitorExcel> pqMonitorExcelList;
|
||||
}
|
||||
@@ -1,15 +1,9 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,4 +21,94 @@ public class PqDevVO extends PqDev {
|
||||
private Double devCurr;
|
||||
|
||||
private List<PqMonitor> monitorList;
|
||||
|
||||
/**
|
||||
* 检测状态 0-未检、1检测中、2检测完成、3归档
|
||||
*/
|
||||
private Integer checkState;
|
||||
|
||||
/**
|
||||
* 检测结果 0不符合、1符合、2未检
|
||||
*/
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 报告生成状态 0未生成、1已生成、2未检
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 检测次数
|
||||
*/
|
||||
private Integer recheckNum;
|
||||
|
||||
/**
|
||||
* 守时检测结果 0:不合格, 1:合格,2:/表示没有做守时检测
|
||||
*/
|
||||
private Integer timeCheckResult;
|
||||
|
||||
/**
|
||||
* 系数校准结果 0:不合格,1:合格,2:/表示没有做系数校准
|
||||
*/
|
||||
private Integer factorCheckResult;
|
||||
|
||||
/**
|
||||
* 实时数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer realtimeResult;
|
||||
|
||||
/**
|
||||
* 统计数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer statisticsResult;
|
||||
|
||||
/**
|
||||
* 录波数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
private Integer recordedResult;
|
||||
|
||||
/**
|
||||
* 检测人
|
||||
*/
|
||||
private String checkBy;
|
||||
|
||||
/**
|
||||
* 检测时间
|
||||
*/
|
||||
private LocalDateTime checkTime;
|
||||
|
||||
/**
|
||||
* 预检测耗时
|
||||
*/
|
||||
private Integer preDetectTime;
|
||||
|
||||
/**
|
||||
* 系数校准耗时
|
||||
*/
|
||||
private Integer coefficientTime;
|
||||
|
||||
/**
|
||||
* 正式检测耗时
|
||||
*/
|
||||
private Integer formalCheckTime;
|
||||
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private Float temperature;
|
||||
|
||||
/**
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
|
||||
/**
|
||||
* 绑定的计划名称
|
||||
*/
|
||||
private String boundPlanName;
|
||||
|
||||
/**
|
||||
* 是否已经分配。0-未分配、1-已分配、2-所有
|
||||
*/
|
||||
private Integer assign;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-01
|
||||
*/
|
||||
@Data
|
||||
public class PqStandardDevExcel {
|
||||
|
||||
@Excel(name = "名称*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型*", width = 25, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备厂家*", width = 25, orderNum = "3")
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "可检通道*", width = 25, orderNum = "4")
|
||||
@NotBlank(message = DetectionValidMessage.INSPECT_CHANNEL_NOT_BLANK)
|
||||
private String inspectChannel;
|
||||
|
||||
@Excel(name = "通信协议*", width = 25, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址*", width = 25, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "7")
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "9")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "10")
|
||||
private String devKey;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
public class PreDetection {
|
||||
|
||||
/**
|
||||
* 装置ip
|
||||
* 装置id
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private String devId;
|
||||
@@ -95,16 +95,28 @@ public class PreDetection {
|
||||
private Integer line;
|
||||
|
||||
/**
|
||||
* 监测点线路号
|
||||
* pt
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
private Integer pt;
|
||||
private String pt;
|
||||
|
||||
/**
|
||||
* 监测点线路号
|
||||
* ct
|
||||
*/
|
||||
@JSONField(name = "pt") //todo 是否改为ct
|
||||
private Integer ct;
|
||||
@JSONField(name = "ct") //todo 是否改为ct
|
||||
private String ct;
|
||||
|
||||
/**
|
||||
* 统计间隔
|
||||
*/
|
||||
@JSONField(name = "statInterval")
|
||||
private Integer statInterval;
|
||||
|
||||
/**
|
||||
* 接线方式
|
||||
*/
|
||||
@JSONField(name = "connection")
|
||||
private String connection;
|
||||
}
|
||||
|
||||
public String getDevKey() {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ProvinceDevExcel implements Serializable {
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "出厂日期*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@@ -63,16 +63,25 @@ public class ProvinceDevExcel implements Serializable {
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "14")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
|
||||
private Integer factorFlag;
|
||||
// @Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
|
||||
// private Integer factorFlag;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "16")
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "15")
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "17")
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "16")
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "样品编号", width = 20, orderNum = "17")
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
private LocalDate arrivedDate;
|
||||
|
||||
@Excel(name="委托方", width = 40, orderNum = "19")
|
||||
private String delegate;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,7 @@ import com.njcn.common.pojo.poi.PullDown;
|
||||
import com.njcn.gather.device.pojo.enums.TimeCheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -64,36 +61,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result);
|
||||
|
||||
/**
|
||||
* 获取模拟式||数字式设备导出时所需的数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return
|
||||
*/
|
||||
//List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出时所需的数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 比对式设备导出时所需的数据
|
||||
*/
|
||||
//List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
//void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
//void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 获取所有未绑定的设备
|
||||
*
|
||||
@@ -108,7 +75,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param param 计划id
|
||||
* @return 绑定的设备列表
|
||||
*/
|
||||
List<PqDev> listByPlanId(PqDevParam.QueryParam param);
|
||||
List<PqDevVO> listByPlanId(PqDevParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 绑定计划
|
||||
@@ -137,13 +104,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(List<String> id);
|
||||
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
@@ -152,13 +112,15 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param valueType
|
||||
* @param code
|
||||
* @param userId
|
||||
* @param temperature
|
||||
* @param humidity
|
||||
* @return
|
||||
*/
|
||||
boolean updateResult(List<String> ids, List<String> valueType, String code,String userId);
|
||||
boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity);
|
||||
|
||||
void updatePqDevReportState(String devId, int i);
|
||||
|
||||
int countUnReportDev(String planId);
|
||||
long countUnReportDev(String planId);
|
||||
|
||||
/**
|
||||
* 根据计划id列表获取设备列表
|
||||
@@ -177,8 +139,10 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void downloadTemplate();
|
||||
void downloadTemplate(String patternId);
|
||||
|
||||
/**
|
||||
* 导入设备数据
|
||||
@@ -188,7 +152,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
boolean importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
@@ -198,7 +162,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
boolean importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
@@ -207,14 +171,14 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param patternId
|
||||
* @param planId
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
boolean importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
void visualizeCNDev(List<PqDev> pqDevs);
|
||||
void visualizeCNDev(List<PqDevVO> pqDevs);
|
||||
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
@@ -232,7 +196,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
boolean importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入省级平台设备数据
|
||||
@@ -241,14 +205,14 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param patternId
|
||||
* @param planId
|
||||
*/
|
||||
void importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId);
|
||||
boolean importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 可视化-省级平台设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
void visualizeProvinceDev(List<PqDev> pqDevs);
|
||||
void visualizeProvinceDev(List<PqDevVO> pqDevs);
|
||||
|
||||
/**
|
||||
* 逆向可视化-省级平台设备
|
||||
@@ -261,6 +225,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
/**
|
||||
* 获取省级平台设备导出、导出文件模板的下拉列表
|
||||
*
|
||||
* @param startCol 开始列
|
||||
* @return
|
||||
*/
|
||||
List<PullDown> getProvinceDevPullDownList(int startCol);
|
||||
@@ -272,4 +237,46 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @return
|
||||
*/
|
||||
List<PullDown> getCNDevPullDownList(int startCol);
|
||||
|
||||
/**
|
||||
* 导入比对式设备数据
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
boolean importContrastDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入比对式设备数据
|
||||
*
|
||||
* @param contrastDevExcelList
|
||||
* @param patternId
|
||||
*/
|
||||
boolean importContrastDev(List<ContrastDevExcel> contrastDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出、导出文件模板的下拉列表
|
||||
*
|
||||
* @param startCol
|
||||
* @return
|
||||
*/
|
||||
List<PullDown> getContrastDevPullDownList(int startCol);
|
||||
|
||||
/**
|
||||
* 根据历史记录来获取下拉框内容
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<String>> listSelectOptions(String pattern);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出数据
|
||||
*
|
||||
* @param pqDevVOList 设备id列表
|
||||
* @return
|
||||
*/
|
||||
List<ContrastDevExcel> getExportContrastDevData(List<PqDevVO> pqDevVOList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
public interface IPqDevSubService extends IService<PqDevSub> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-02
|
||||
*/
|
||||
public interface IPqStandardDevService extends IService<PqStandardDev> {
|
||||
|
||||
/**
|
||||
* 分页查询标准设备列表
|
||||
*
|
||||
* @param queryParam 分页查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 根据id查询标准设备
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 设备对象
|
||||
*/
|
||||
PqStandardDev getPqStandardDevById(String id);
|
||||
|
||||
/**
|
||||
* 新增标准设备
|
||||
*
|
||||
* @param param 新增参数
|
||||
* @return 新增成功返回true,失败返回false
|
||||
*/
|
||||
boolean addPqStandardDev(PqStandardDevParam param);
|
||||
|
||||
/**
|
||||
* 修改标准设备
|
||||
*
|
||||
* @param param 修改参数
|
||||
* @return 修改成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqStandardDev(PqStandardDevParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 批量删除标准设备
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean deletePqStandardDevs(List<String> ids);
|
||||
|
||||
/**
|
||||
* 导出标准设备
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
void export(PqStandardDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下装标准设备导入模板
|
||||
*/
|
||||
void downloadTemplate();
|
||||
|
||||
/**
|
||||
* 导入标准设备数据
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
void importData(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 查询出指定计划以关联的标准设备列表
|
||||
*
|
||||
* @param planId
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> listByPlanId(String planId);
|
||||
|
||||
/**
|
||||
* 查询出标准设备所需的检测信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<PreDetection> listStandardDevPreDetection(List<String> ids);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
import com.njcn.gather.device.mapper.PqDevSubMapper;
|
||||
import com.njcn.gather.device.service.IPqDevSubService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqDevSubServiceImpl extends ServiceImpl<PqDevSubMapper, PqDevSub> implements IPqDevSubService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.poi.PullDown;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.gather.device.mapper.PqStandardDevMapper;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 曹泽辉
|
||||
* @date 2025-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, PqStandardDev> implements IPqStandardDevService {
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
|
||||
|
||||
@Override
|
||||
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
||||
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "manufacturer", queryParam.getManufacturer())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getDevType()), "dev_type", queryParam.getDevType())
|
||||
.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
return this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqStandardDev getPqStandardDevById(String id) {
|
||||
PqStandardDev standardDev = this.getById(id);
|
||||
if (standardDev.getEncryptionFlag() == 1) {
|
||||
standardDev.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
|
||||
standardDev.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
|
||||
}
|
||||
return standardDev;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addPqStandardDev(PqStandardDevParam param) {
|
||||
this.checkRepeat(param, false);
|
||||
PqStandardDev pqStandardDev = BeanUtil.copyProperties(param, PqStandardDev.class);
|
||||
pqStandardDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.checkEncryption(pqStandardDev);
|
||||
return this.save(pqStandardDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updatePqStandardDev(PqStandardDevParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
PqStandardDev pqStandardDev = BeanUtil.copyProperties(param, PqStandardDev.class);
|
||||
this.checkEncryption(pqStandardDev);
|
||||
return this.updateById(pqStandardDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deletePqStandardDevs(List<String> ids) {
|
||||
LambdaUpdateWrapper<PqStandardDev> wrapper = new LambdaUpdateWrapper();
|
||||
wrapper.set(PqStandardDev::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(PqStandardDev::getId, ids);
|
||||
return this.update(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(PqStandardDevParam.QueryParam queryParam) {
|
||||
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "manufacturer", queryParam.getManufacturer())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getDevType()), "dev_type", queryParam.getDevType())
|
||||
.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
List<PqStandardDev> pqStandardDevs = this.list(wrapper);
|
||||
this.visualizeStandardDev(pqStandardDevs);
|
||||
List<PqStandardDevExcel> pqStandardDevExcels = BeanUtil.copyToList(pqStandardDevs, PqStandardDevExcel.class);
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "标准设备导出数据.xlsx", 1, this.getStandardDevPullDownList(), PqStandardDevExcel.class, pqStandardDevExcels);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "标准设备导入模板.xlsx", 1, this.getStandardDevPullDownList(), PqStandardDevExcel.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importData(MultipartFile file, HttpServletResponse response) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setNeedVerify(true);
|
||||
params.setHeadRows(1);
|
||||
|
||||
List<PqStandardDevExcel> contrastDevExcelList = null;
|
||||
try {
|
||||
ExcelImportResult<PqStandardDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqStandardDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
} else {
|
||||
contrastDevExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
this.importData(contrastDevExcelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqStandardDev> listByPlanId(String planId) {
|
||||
return adPlanStandardDevMapper.listByPlanId(Collections.singletonList(planId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PreDetection> listStandardDevPreDetection(List<String> ids) {
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
return this.baseMapper.listStandardDevPreDetection(ids);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param contrastDevExcelList
|
||||
* @return
|
||||
*/
|
||||
private void importData(List<PqStandardDevExcel> contrastDevExcelList) {
|
||||
if (CollectionUtil.isNotEmpty(contrastDevExcelList)) {
|
||||
List<PqStandardDev> contrastDevs = BeanUtil.copyToList(contrastDevExcelList, PqStandardDev.class);
|
||||
this.reverseVisualizeStandardDev(contrastDevs);
|
||||
this.saveBatch(contrastDevs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标准设备导出文件下拉列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<PullDown> getStandardDevPullDownList() {
|
||||
List<PullDown> pullDownList = new ArrayList<>();
|
||||
|
||||
PullDown pullDown = new PullDown();
|
||||
|
||||
// 设备类型
|
||||
pullDown.setFirstCol(1);
|
||||
pullDown.setLastCol(1);
|
||||
pullDown.setStrings(devTypeService.listAll().stream().map(devType -> devType.getName()).collect(Collectors.toList()));
|
||||
pullDownList.add(pullDown);
|
||||
|
||||
|
||||
List<DictData> dictDataList = null;
|
||||
// 设备厂家
|
||||
DictType dictType = dictTypeService.getByCode("Dev_Manufacturers");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(2);
|
||||
pullDown.setLastCol(2);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDownList.add(pullDown);
|
||||
}
|
||||
|
||||
// 通讯协议
|
||||
dictType = dictTypeService.getByCode("Protocol");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(4);
|
||||
pullDown.setLastCol(4);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDownList.add(pullDown);
|
||||
}
|
||||
|
||||
// 是否加密
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(Arrays.asList("否", "是"));
|
||||
pullDownList.add(pullDown);
|
||||
|
||||
return pullDownList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可视化标准设备
|
||||
*
|
||||
* @param pqStandardDevs
|
||||
*/
|
||||
private void visualizeStandardDev(List<PqStandardDev> pqStandardDevs) {
|
||||
pqStandardDevs.forEach(pqStandardDev -> {
|
||||
pqStandardDev.setDevType(devTypeService.getById(pqStandardDev.getDevType()).getName());
|
||||
pqStandardDev.setManufacturer(dictDataService.getDictDataById(pqStandardDev.getManufacturer()).getName());
|
||||
pqStandardDev.setProtocol(dictDataService.getDictDataById(pqStandardDev.getProtocol()).getName());
|
||||
if (pqStandardDev.getEncryptionFlag() == 1) {
|
||||
pqStandardDev.setSeries(EncryptionUtil.decoderString(1, pqStandardDev.getSeries()));
|
||||
pqStandardDev.setDevKey(EncryptionUtil.decoderString(1, pqStandardDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向可视化标准设备
|
||||
*
|
||||
* @param pqStandardDevs
|
||||
*/
|
||||
private void reverseVisualizeStandardDev(List<PqStandardDev> pqStandardDevs) {
|
||||
pqStandardDevs.forEach(pqStandardDev -> {
|
||||
PqStandardDevParam pqStandardDevParam = BeanUtil.copyProperties(pqStandardDev, PqStandardDevParam.class);
|
||||
this.checkRepeat(pqStandardDevParam, false);
|
||||
this.checkEncryption(pqStandardDev);
|
||||
pqStandardDev.setDevType(devTypeService.getByName(pqStandardDev.getDevType()).getId());
|
||||
pqStandardDev.setManufacturer(dictDataService.getDictDataByName(pqStandardDev.getManufacturer()).getId());
|
||||
pqStandardDev.setProtocol(dictDataService.getDictDataByName(pqStandardDev.getProtocol()).getId());
|
||||
pqStandardDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否重复
|
||||
*
|
||||
* @param pqStandardDevParam
|
||||
* @param isExcludeSelf
|
||||
*/
|
||||
private void checkRepeat(PqStandardDevParam pqStandardDevParam, boolean isExcludeSelf) {
|
||||
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_standard_dev.Name", pqStandardDevParam.getName())
|
||||
.eq("pq_standard_dev.State", DataStateEnum.ENABLE.getCode());
|
||||
if (isExcludeSelf) {
|
||||
if (pqStandardDevParam instanceof PqStandardDevParam.UpdateParam) {
|
||||
wrapper.ne("pq_standard_dev.Id", ((PqStandardDevParam.UpdateParam) pqStandardDevParam).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(DetectionResponseEnum.PQ_STANDARD_DEV_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查加密情况
|
||||
*
|
||||
* @param pqStandardDev
|
||||
*/
|
||||
private void checkEncryption(PqStandardDev pqStandardDev) {
|
||||
if (pqStandardDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqStandardDev.getSeries()) && StrUtil.isNotBlank(pqStandardDev.getDevKey())) {
|
||||
pqStandardDev.setSeries(EncryptionUtil.encodeString(1, pqStandardDev.getSeries()));
|
||||
pqStandardDev.setDevKey(EncryptionUtil.encodeString(1, pqStandardDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,5 +139,16 @@ public class PqErrSysController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getTestItems")
|
||||
@ApiOperation("根据误差体系id获取测试项")
|
||||
@ApiImplicitParam(name = "id", value = "误差体系id", required = true)
|
||||
public HttpResult<List<Map<String, String>>> getTestItems(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getTestItems");
|
||||
LogUtil.njcnDebug(log, "{},获取测试项ID为:{}", methodDescribe, id);
|
||||
List<Map<String, String>> result = pqErrSysService.getTestItems(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,4 +57,10 @@ public interface IPqErrSysDtlsService extends IService<PqErrSysDtls> {
|
||||
* @return
|
||||
*/
|
||||
List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param);
|
||||
|
||||
/**
|
||||
* 根据误差体系id和脚本类型查询脚本类型
|
||||
* @return
|
||||
*/
|
||||
List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndScriptType(String errSysId, String scriptType);
|
||||
}
|
||||
|
||||
@@ -79,4 +79,12 @@ public interface IPqErrSysService extends IService<PqErrSys> {
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean copyPqErrSys(String id);
|
||||
|
||||
/**
|
||||
* 根据id获取测试项列表
|
||||
*
|
||||
* @param id 误差体系id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, String>> getTestItems(String id);
|
||||
}
|
||||
|
||||
@@ -155,4 +155,14 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndScriptType(String errSysId, String scriptType) {
|
||||
MPJLambdaWrapper<PqErrSysDtls> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(PqErrSysDtls.class)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType)
|
||||
.eq(PqErrSysDtls::getErrorSysId, errSysId)
|
||||
.eq(DictTree::getId, scriptType);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addPqErrSys(PqErrSysParam param) {
|
||||
param.setStandardName(param.getStandardName().trim());
|
||||
this.checkRepeat(param, false);
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
@@ -84,6 +85,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
|
||||
param.setStandardName(param.getStandardName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
@@ -206,6 +208,11 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
return this.save(pqErrSys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getTestItems(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查重复
|
||||
*
|
||||
|
||||
@@ -47,6 +47,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addIcd(PqIcdPathParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, false);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
@@ -57,6 +58,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
package com.njcn.gather.monitor.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -21,5 +34,15 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class PqMonitorController extends BaseController {
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询监测点")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<List<PqMonitor>> list(@RequestBody PqMonitorParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
List<PqMonitor> result = pqMonitorService.listPqMonitorByDevId(queryParam.getDevId());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
|
||||
<select id="selectMonitorInfo"
|
||||
resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
SELECT
|
||||
Id as lineId,
|
||||
Num as line,
|
||||
pt as pt,
|
||||
ct as ct
|
||||
FROM
|
||||
pq_monitor
|
||||
WHERE
|
||||
dev_id = #{devId}
|
||||
SELECT CONCAT(pq_dev.IP, '_', Num) as lineId,
|
||||
Num as line,
|
||||
pt as pt,
|
||||
ct as ct,
|
||||
Stat_Interval,
|
||||
sys_dict_data.Code as `Connection`
|
||||
FROM pq_monitor
|
||||
inner join sys_dict_data on pq_monitor.Connection = sys_dict_data.id
|
||||
inner join pq_dev on pq_monitor.Dev_Id = pq_dev.Id
|
||||
WHERE Dev_Id = #{devId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -16,28 +17,63 @@ import javax.validation.constraints.Pattern;
|
||||
@Data
|
||||
public class PqMonitorParam {
|
||||
|
||||
@ApiModelProperty(value = "谐波系统监测点ID")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "所属设备id")
|
||||
@NotBlank(message = DetectionValidMessage.DEVICE_ID_NOT_BLANK)
|
||||
private String devId;
|
||||
|
||||
@ApiModelProperty(value = "所属母线")
|
||||
@NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String busbar;
|
||||
|
||||
@ApiModelProperty(value = "监测点名称")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "监测点序号")
|
||||
@ApiModelProperty(value = "线路号(监测点序号)")
|
||||
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "PT变比")
|
||||
@NotNull(message = DetectionValidMessage.PT_NOT_NULL)
|
||||
private Float pt;
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt;
|
||||
|
||||
@ApiModelProperty(value = "CT变比")
|
||||
@NotNull(message = DetectionValidMessage.CT_NOT_NULL)
|
||||
private Float ct;
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct;
|
||||
|
||||
@ApiModelProperty(value = "接线方式")
|
||||
@NotBlank(message = DetectionValidMessage.WIRING_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.WIRING_TYPE_FORMAT_ERROR)
|
||||
private String ptType;
|
||||
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.CONNECTION_FORMAT_ERROR)
|
||||
private String connection;
|
||||
|
||||
@ApiModelProperty(value = "统计间隔")
|
||||
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
|
||||
private Integer statInterval;
|
||||
|
||||
@ApiModelProperty(value = "谐波系统监测点id")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
public static class QueryParam {
|
||||
@ApiModelProperty(value = "所属设备id")
|
||||
@NotBlank(message = DetectionValidMessage.DEVICE_ID_NOT_BLANK)
|
||||
private String devId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改实体
|
||||
*/
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class UpdateParam extends PqMonitorParam {
|
||||
// @ApiModelProperty(value = "监测点id", required = true)
|
||||
// @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
|
||||
// private String id;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.njcn.gather.monitor.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -20,40 +18,49 @@ public class PqMonitor implements Serializable {
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 默认与谐波系统监测点ID相同
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 所属设备ID
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
/**
|
||||
* 所属母线
|
||||
* 监测点名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 监测点序号
|
||||
* 所属母线
|
||||
*/
|
||||
private String busbar;
|
||||
|
||||
/**
|
||||
* 线路号(监测点序号)
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* PT变比
|
||||
*/
|
||||
private Float pt;
|
||||
private String pt;
|
||||
|
||||
/**
|
||||
* CT变比
|
||||
*/
|
||||
private Float ct;
|
||||
private String ct;
|
||||
|
||||
/**
|
||||
* 统计间隔
|
||||
*/
|
||||
private Integer statInterval;
|
||||
|
||||
/**
|
||||
* 接线方式,字典表
|
||||
*/
|
||||
private String ptType;
|
||||
private String connection;
|
||||
|
||||
/**
|
||||
* 谐波系统监测点id
|
||||
*/
|
||||
private String harmSysId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.njcn.gather.monitor.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -17,36 +14,35 @@ import javax.validation.constraints.Pattern;
|
||||
@Data
|
||||
public class PqMonitorExcel {
|
||||
|
||||
@Excel(name = "监测点序号", width = 20, orderNum = "1")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.MONITOR_NUM_FORMAT_ERROR)
|
||||
private Integer num;
|
||||
@Excel(name = "谐波系统监测点ID*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@Excel(name = "所属母线", width = 20, orderNum = "2")
|
||||
@Excel(name = "所属母线*", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String busbar;
|
||||
|
||||
@Excel(name = "监测点名称*", width = 20, orderNum = "3")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "PT变比", width = 20, orderNum = "3")
|
||||
@NotNull(message = DetectionValidMessage.PT_NOT_NULL)
|
||||
private Float pt;
|
||||
@Excel(name = "线路号(监测点序号)*", width = 20, orderNum = "4")
|
||||
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
|
||||
private Integer num;
|
||||
|
||||
@Excel(name = "CT变比", width = 20, orderNum = "4")
|
||||
@NotNull(message = DetectionValidMessage.CT_NOT_NULL)
|
||||
private Float ct;
|
||||
@Excel(name = "PT变比(pt1:pt2)*", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt;
|
||||
|
||||
@Excel(name = "接线方式", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.WIRING_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.WIRING_TYPE_FORMAT_ERROR)
|
||||
private String ptType;
|
||||
@Excel(name = "CT变比(ct1:ct2)*", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends PqMonitorExcel {
|
||||
@Excel(name = "接线方式*", width = 20, orderNum = "7")
|
||||
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
|
||||
private String connection;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends PqMonitorExcel {
|
||||
|
||||
}
|
||||
@Excel(name = "统计间隔*", width = 10, orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
|
||||
private Integer statInterval;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.monitor.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备id获取所有监测点信息
|
||||
*
|
||||
@@ -22,28 +24,42 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
List<PqMonitor> listPqMonitorByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 批量新增监测点信息
|
||||
* 根据设备id批量新增监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @param pqMonitorParamList 监测点信息列表
|
||||
* @return 新增成功返回true,否则返回false
|
||||
* @param devId
|
||||
* @param monitorList
|
||||
* @return
|
||||
*/
|
||||
boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList);
|
||||
boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> monitorList);
|
||||
|
||||
/**
|
||||
* 批量删除监测点信息
|
||||
* 根据设备id批量修改监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @return 删除成功返回true,否则返回false
|
||||
* @param devId
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList);
|
||||
|
||||
/**
|
||||
* 根据设备id删除监测点信息
|
||||
*
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
boolean deletePqMonitorByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 修改监测点信息
|
||||
* 可视化监测点
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @param paramList 监测点信息
|
||||
* @return 修改成功返回true,否则返回false
|
||||
* @param monitorList
|
||||
*/
|
||||
boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList);
|
||||
void visualizeMonitor(List<PqMonitor> monitorList);
|
||||
|
||||
/**
|
||||
* 逆向可视化监测点
|
||||
*
|
||||
* @param monitorList
|
||||
*/
|
||||
void reverseVisualizeMonitor(List<PqMonitor> monitorList);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.njcn.gather.monitor.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,21 +36,12 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList) {
|
||||
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class);
|
||||
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> monitorList) {
|
||||
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(monitorList, PqMonitor.class);
|
||||
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
|
||||
return this.saveBatch(pqMonitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deletePqMonitorByDevId(String devId) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
return this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList) {
|
||||
@@ -58,4 +53,35 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
return this.saveBatch(pqMonitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deletePqMonitorByDevId(String devId) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
return this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visualizeMonitor(List<PqMonitor> monitorList) {
|
||||
monitorList.forEach(monitor -> {
|
||||
DictData dictData = dictDataService.getDictDataById(monitor.getConnection());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
monitor.setConnection(dictData.getName());
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.CONNECTION_NOT_EXIST);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reverseVisualizeMonitor(List<PqMonitor> monitorList) {
|
||||
monitorList.forEach(monitor -> {
|
||||
DictData dictData = dictDataService.getDictDataByName(monitor.getConnection());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
monitor.setConnection(dictData.getId());
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.CONNECTION_NOT_EXIST);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
package com.njcn.gather.plan.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
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.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -28,7 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -42,15 +52,17 @@ import java.util.Map;
|
||||
public class AdPlanController extends BaseController {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final IDevTypeService devTypeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测计划")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<AdPlanVO>> list(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
public HttpResult<List<AdPlanVO>> list(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<AdPlanVO> result = adPlanService.listAdPlan(queryParam);
|
||||
List<AdPlanVO> result = adPlanService.listAdPlan(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -77,6 +89,7 @@ public class AdPlanController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = adPlanService.updateAdPlan(updateParam);
|
||||
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
@@ -87,11 +100,11 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除检测计划")
|
||||
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
|
||||
@ApiImplicitParam(name = "ids", value = "计划id列表", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestBody List<String> ids, @RequestParam("pattern") String pattern) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
boolean result = adPlanService.deleteAdPlan(ids);
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids), pattern);
|
||||
boolean result = adPlanService.deleteAdPlan(ids, pattern);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
@@ -99,7 +112,6 @@ public class AdPlanController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listByPattern")
|
||||
@ApiOperation("按照模式查询检测计划")
|
||||
@@ -125,8 +137,8 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载检测计划导出模板")
|
||||
public void downloadTemplate(@RequestBody String patternId) {
|
||||
adPlanService.downloadTemplate(patternId);
|
||||
public void downloadTemplate(@RequestBody AdPlanParam param) {
|
||||
adPlanService.downloadTemplate(param.getPattern());
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@@ -136,7 +148,7 @@ public class AdPlanController extends BaseController {
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
})
|
||||
public HttpResult<Object> importPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
public HttpResult<Boolean> importPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNPlan");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
@@ -144,8 +156,12 @@ public class AdPlanController extends BaseController {
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
adPlanService.importPlan(file, patternId, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
boolean result = adPlanService.importPlan(file, patternId, response);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -155,7 +171,7 @@ public class AdPlanController extends BaseController {
|
||||
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
|
||||
String methodDescribe = getMethodDescribe("getBigTestItem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevId());
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -168,5 +184,176 @@ public class AdPlanController extends BaseController {
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
adPlanService.analyse(ids);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
AdPlan plan = adPlanService.getById(param.getPlanIdList().get(0));
|
||||
if (CommonEnum.FATHER_ID.getValue().equals(plan.getFatherPlanId())) {
|
||||
List<AdPlan> planList = adPlanService.lambdaQuery().eq(AdPlan::getFatherPlanId, param.getPlanIdList().get(0)).list();
|
||||
List<String> planIdList = planList.stream().map(AdPlan::getId).collect(Collectors.toList());
|
||||
param.getPlanIdList().addAll(planIdList);
|
||||
}
|
||||
List<PqDevVO> pqDevVOList = pqDevService.listByPlanId(param);
|
||||
List<AdPlan> planList = adPlanService.listByIds(param.getPlanIdList());
|
||||
|
||||
pqDevVOList.forEach(pqDevVO -> {
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevType(devType.getName());
|
||||
pqDevVO.setDevVolt(devType.getDevVolt());
|
||||
pqDevVO.setDevCurr(devType.getDevCurr());
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDevVO.getPlanId())) {
|
||||
AdPlan plan1 = planList.stream().filter(p -> p.getId().equals(pqDevVO.getPlanId())).findFirst().get();
|
||||
if (ObjectUtil.isNotNull(plan1) && plan.getId().equals(plan1.getFatherPlanId())) {
|
||||
pqDevVO.setBoundPlanName(plan1.getName());
|
||||
pqDevVO.setAssign(DataStateEnum.ENABLE.getCode());
|
||||
} else {
|
||||
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
} else {
|
||||
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
});
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listDevByPlanId")
|
||||
@ApiOperation("根据计划id分页查询被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqDevVO>> listDevByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listDevByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
AdPlan plan = adPlanService.getById(param.getPlanIdList().get(0));
|
||||
if (CommonEnum.FATHER_ID.getValue().equals(plan.getFatherPlanId())) {
|
||||
List<AdPlan> planList = adPlanService.lambdaQuery().eq(AdPlan::getFatherPlanId, param.getPlanIdList().get(0)).list();
|
||||
List<String> planIdList = planList.stream().map(AdPlan::getId).collect(Collectors.toList());
|
||||
param.getPlanIdList().addAll(planIdList);
|
||||
}
|
||||
Page<PqDevVO> pqDevVOPage = pqDevService.listPqDevs(param);
|
||||
|
||||
List<AdPlan> planList = adPlanService.listByIds(param.getPlanIdList());
|
||||
for (PqDevVO pqDevVO : pqDevVOPage.getRecords()) {
|
||||
if (StrUtil.isNotBlank(pqDevVO.getPlanId())) {
|
||||
AdPlan plan1 = planList.stream().filter(p -> p.getId().equals(pqDevVO.getPlanId())).findFirst().get();
|
||||
if (ObjectUtil.isNotNull(plan1) && plan.getId().equals(plan1.getFatherPlanId())) {
|
||||
pqDevVO.setBoundPlanName(plan1.getName());
|
||||
pqDevVO.setAssign(DataStateEnum.ENABLE.getCode());
|
||||
} else {
|
||||
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
} else {
|
||||
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOPage, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@GetMapping("/updateSubPlanName")
|
||||
@ApiOperation("修改子计划名称")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true),
|
||||
@ApiImplicitParam(name = "name", value = "计划名称", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> updateSubPlanName(@RequestParam("planId") String planId, @RequestParam("name") String name) {
|
||||
String methodDescribe = getMethodDescribe("updateSubPlanName");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, planId, name);
|
||||
boolean result = adPlanService.updateSubPlanName(planId, name);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getUnBoundStandardDev")
|
||||
@ApiOperation("根据父计划ID获取未被子计划绑定的标准设备")
|
||||
@ApiImplicitParam(name = "fatherPlanId", value = "父计划ID", required = true)
|
||||
public HttpResult<List<PqStandardDev>> getUnBoundStandardDev(@RequestParam("fatherPlanId") String fatherPlanId) {
|
||||
String methodDescribe = getMethodDescribe("getUnBoundStandardDev");
|
||||
LogUtil.njcnDebug(log, "{},父计划ID为:{}", methodDescribe, fatherPlanId);
|
||||
List<PqStandardDev> result = adPlanService.getUnBoundStandardDev(fatherPlanId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getBoundStandardDev")
|
||||
@ApiOperation("根据计划ID获取已绑定的标准设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划ID", required = true)
|
||||
public HttpResult<List<PqStandardDev>> getBoundStandardDev(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("getUnBoundStandardDev");
|
||||
LogUtil.njcnDebug(log, "{},计划ID为:{}", methodDescribe, planId);
|
||||
List<PqStandardDev> result = adPlanService.getBoundStandardDev(planId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateBindStandardDev")
|
||||
@ApiOperation("子计划绑定/解绑标准设备")
|
||||
@ApiImplicitParam(name = "param", value = "绑定/解绑参数", required = true)
|
||||
public HttpResult<Boolean> updateBindStandardDev(@RequestBody @Validated PqDevParam.BindPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateBindStandardDev");
|
||||
LogUtil.njcnDebug(log, "{},绑定/解绑参数为:{}", methodDescribe, param);
|
||||
|
||||
boolean result = adPlanService.updateBindStandardDev(param.getPlanId(), param.getDevIds());
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateBindDev")
|
||||
@ApiOperation("子计划绑定/解绑被检设备")
|
||||
@ApiImplicitParam(name = "param", value = "绑定/解绑参数", required = true)
|
||||
public HttpResult<Boolean> updateBindDev(@RequestBody @Validated PqDevParam.BindPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateBindDev");
|
||||
LogUtil.njcnDebug(log, "{},绑定/解绑参数为:{}", methodDescribe, param);
|
||||
|
||||
boolean result = adPlanService.updateBindDev(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
// @PostMapping("/deleteSubPlan")
|
||||
// @ApiOperation("删除子计划")
|
||||
// @ApiImplicitParam(name = "ids", value = "子计划id列表", required = true)
|
||||
// public HttpResult<Boolean> deleteSubPlan(@RequestBody List<String> ids) {
|
||||
// String methodDescribe = getMethodDescribe("deleteSubPlan");
|
||||
// LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
// boolean result = adPlanService.deleteAdPlan(ids);
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
|
||||
@OperateInfo(operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/exportSubPlan")
|
||||
@ApiOperation("导出子计划")
|
||||
@ApiImplicitParam(name = "planId", value = "子计划id", required = true)
|
||||
public void exportSubPlan(@RequestParam("planId") String planId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("exportSubPlan");
|
||||
LogUtil.njcnDebug(log, "{},导出ID数据为:{}", methodDescribe, planId);
|
||||
adPlanService.exportSubPlan(planId, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.report.pojo.po.PqReport;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
@@ -27,5 +29,13 @@ public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
|
||||
* @return
|
||||
*/
|
||||
PqReport getPqReportById(String id);
|
||||
|
||||
/**
|
||||
* 获取所有报告模板名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<String> listAllReportTemplateName();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.gather.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanStandardDev;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
public interface AdPlanStandardDevMapper extends MPJBaseMapper<AdPlanStandardDev> {
|
||||
|
||||
/**
|
||||
* 根据计划id查询标准设备列表
|
||||
*
|
||||
* @param planIdList
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> listByPlanId(@Param("planIdList") List<String> planIdList);
|
||||
}
|
||||
|
||||
@@ -17,5 +17,10 @@
|
||||
WHERE id = #{id}
|
||||
and state = 1
|
||||
</select>
|
||||
<select id="listAllReportTemplateName" resultType="java.lang.String">
|
||||
SELECT concat(name, '_', version) as name
|
||||
FROM pq_report
|
||||
WHERE state = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanStandardDevMapper">
|
||||
|
||||
|
||||
<select id="listByPlanId" resultType="com.njcn.gather.device.pojo.po.PqStandardDev">
|
||||
select standard_dev.*
|
||||
from ad_plan_standard_dev plan_std_dev left join pq_standard_dev standard_dev on plan_std_dev.Standard_Dev_Id = standard_dev.Id
|
||||
<if test="planIdList!= null and planIdList.size() != 0">
|
||||
where plan_std_dev.Plan_Id in
|
||||
<foreach collection="planIdList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -8,13 +8,13 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum DataSourceEnum {
|
||||
THREE_SENSE_ACTUAL_TIME_DATA("0", "3s实时数据"),
|
||||
REAL_DATA("real", "3s实时数据"),
|
||||
|
||||
MINUTE_STATISTICS_MAX("1", "分钟统计数据-最大"),
|
||||
MINUTE_STATISTICS_MIN("2", "分钟统计数据-最小"),
|
||||
MINUTE_STATISTICS_AVG("3", "分钟统计数据-平均"),
|
||||
MINUTE_STATISTICS_CP95("4", "分钟统计数据-CP95"),
|
||||
RECORDED_DATA("5", "录播数据");
|
||||
MINUTE_STATISTICS_MAX("max", "分钟统计数据-最大"),
|
||||
MINUTE_STATISTICS_MIN("min", "分钟统计数据-最小"),
|
||||
MINUTE_STATISTICS_AVG("avg", "分钟统计数据-平均"),
|
||||
MINUTE_STATISTICS_CP95("cp95", "分钟统计数据-CP95"),
|
||||
RECORDED_DATA("Recorded_data", "录播数据");
|
||||
|
||||
private String value;
|
||||
private String msg;
|
||||
|
||||
@@ -27,12 +27,7 @@ public class AdPlanParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
// @ApiModelProperty(value = "父计划ID")
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
// private String fatherPlanId;
|
||||
|
||||
@ApiModelProperty(value = "检测源ID列表", required = true)
|
||||
@NotEmpty(message = DetectionValidMessage.SOURCE_IDS_NOT_EMPTY)
|
||||
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.SOURCE_ID_FORMAT_ERROR) String> sourceIds;
|
||||
|
||||
@ApiModelProperty(value = "数据源ID列表", required = true)
|
||||
@@ -40,8 +35,6 @@ public class AdPlanParam {
|
||||
private List<String> datasourceIds;
|
||||
|
||||
@ApiModelProperty(value = "检测脚本ID", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.SCRIPT_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.SCRIPT_ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty(value = "误差体系ID", required = true)
|
||||
@@ -56,15 +49,29 @@ public class AdPlanParam {
|
||||
private Integer timeCheck;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty(value = "是否关联报告")
|
||||
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
|
||||
private Integer associateReport;
|
||||
|
||||
@ApiModelProperty(value = "报告模板名称")
|
||||
private String reportTemplateName;
|
||||
|
||||
@ApiModelProperty(value = "数据处理原则")
|
||||
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
|
||||
private String dataRule;
|
||||
|
||||
@ApiModelProperty(value = "父计划ID")
|
||||
private String fatherPlanId;
|
||||
|
||||
@ApiModelProperty(value = "标准设备ID列表")
|
||||
private List<String> standardDevIds;
|
||||
|
||||
@ApiModelProperty(value = "测试项ID列表")
|
||||
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.SOURCE_ID_FORMAT_ERROR)String> testItems;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@@ -110,6 +117,6 @@ public class AdPlanParam {
|
||||
// 0:不合格项复检 1:全部复检
|
||||
private Integer reCheckType;
|
||||
private String planId;
|
||||
private String devId;
|
||||
private List<String> devIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,25 @@ public class AdPlan extends BaseEntity implements Serializable {
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String reportTemplateId;
|
||||
|
||||
/**
|
||||
* 数据处理原则。任意值、部分值、所有值、cp95值、平均值
|
||||
*/
|
||||
private String dataRule;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
/**
|
||||
* 检测项ID,中间使用英文逗号分割
|
||||
*/
|
||||
private String testItem;
|
||||
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private String origin;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.gather.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Data
|
||||
@TableName("ad_plan_standard_dev")
|
||||
public class AdPlanStandardDev implements Serializable {
|
||||
private static final long serialVersionUID = 153286652772158825L;
|
||||
/**
|
||||
* 检测计划id
|
||||
*/
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 标准设备id
|
||||
*/
|
||||
private String standardDevId;
|
||||
|
||||
}
|
||||
|
||||
@@ -25,27 +25,38 @@ public class AdPlanExcel {
|
||||
@NotBlank(message = DetectionValidMessage.DATASOURCE_NOT_BLANK)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本*", width = 100, needMerge = true, orderNum = "3")
|
||||
@Excel(name = "脚本*", width = 40, needMerge = true, orderNum = "3")
|
||||
@NotBlank(message = DetectionValidMessage.SCRIPT_NOT_BLANK)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系*", width = 30, needMerge = true, orderNum = "4")
|
||||
@Excel(name = "误差体系*", width = 40, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DetectionValidMessage.ERRORSYS_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
@Excel(name = "数据处理原则*", width = 20, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
|
||||
private String dataRule;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "6")
|
||||
@NotNull(message = DetectionValidMessage.TIMECHECK_NOT_NULL)
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
@NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
|
||||
private Integer testState;
|
||||
@Excel(name = "关联报告模板*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
|
||||
private Integer associateReport;
|
||||
|
||||
@Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
|
||||
private Integer reportState;
|
||||
@Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, needMerge = true, orderNum = "8")
|
||||
private String reportTemplateId;
|
||||
|
||||
@Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
private Integer result;
|
||||
// @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "9")
|
||||
// @NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
|
||||
// private Integer testState;
|
||||
//
|
||||
// @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "10")
|
||||
// @NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
|
||||
// private Integer reportState;
|
||||
//
|
||||
// @Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "11")
|
||||
// @NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
// private Integer result;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -108,4 +109,44 @@ public class AdPlanVO {
|
||||
* 报告模板名称
|
||||
*/
|
||||
private String reportTemplateName;
|
||||
|
||||
/**
|
||||
* 数据处理原则
|
||||
*/
|
||||
private String dataRule;
|
||||
|
||||
/**
|
||||
* 检测进度
|
||||
*/
|
||||
private Float progress;
|
||||
|
||||
/**
|
||||
* 标准设备ID列表
|
||||
*/
|
||||
private Map<String, Integer> standardDevMap;
|
||||
|
||||
/**
|
||||
* 标准设备名称
|
||||
*/
|
||||
private String standardDevNameStr;
|
||||
|
||||
/**
|
||||
* 测试项id列表
|
||||
*/
|
||||
private List<String> testItems;
|
||||
|
||||
/**
|
||||
* 测试项name列表
|
||||
*/
|
||||
private String testItemNameStr;
|
||||
|
||||
/**
|
||||
* 计划绑定的被检设备列表
|
||||
*/
|
||||
private List<PqDevVO> pqDevVOList;
|
||||
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private String origin;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-16
|
||||
*/
|
||||
@Data
|
||||
public class ContrastPlanExcel {
|
||||
|
||||
private String id;
|
||||
|
||||
@Excel(name = "名称*", width = 30, orderNum = "1")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "标准设备*", width = 50, orderNum = "2")
|
||||
private String standardDev;
|
||||
|
||||
@Excel(name = "数据源*", width = 50, orderNum = "3")
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "检测项*", width = 50, orderNum = "4")
|
||||
private String testItem;
|
||||
|
||||
@Excel(name = "误差体系*", width = 50, orderNum = "5")
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "数据处理原则*", width = 20, orderNum = "6")
|
||||
private String dataRule;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 30, orderNum = "7")
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "关联报告模板*", width = 30, orderNum = "8", replace = {"否_0", "是_1"})
|
||||
private Integer associateReport;
|
||||
|
||||
@Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, orderNum = "9")
|
||||
private String reportTemplateId;
|
||||
}
|
||||
@@ -2,6 +2,8 @@ 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.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
@@ -24,7 +26,7 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @param queryParam 分页查询参数
|
||||
* @return 分页查询结果
|
||||
*/
|
||||
Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam);
|
||||
List<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增检测计划
|
||||
@@ -46,9 +48,11 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* 删除检测计划
|
||||
*
|
||||
* @param ids 检测计划id列表
|
||||
* @param pattern 模式Id
|
||||
*
|
||||
* @return 删除成功则返回true,否则返回false
|
||||
*/
|
||||
boolean deleteAdPlan(List<String> ids);
|
||||
boolean deleteAdPlan(List<String> ids,String pattern);
|
||||
|
||||
/**
|
||||
* 根据模式查询检测计划
|
||||
@@ -70,10 +74,10 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
*
|
||||
* @param reCheckType 0:不合格项复检 1:全部复检
|
||||
* @param planId 检测计划Id
|
||||
* @param devId 设备Id
|
||||
* @param devIds 设备Id列表
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId);
|
||||
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 修改计划状态
|
||||
@@ -82,7 +86,7 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @param devIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateTestState(String planId, List<String> devIds);
|
||||
//boolean updateTestState(String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 数据状态回退
|
||||
@@ -123,5 +127,58 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @param patternId
|
||||
* @param response
|
||||
*/
|
||||
void importPlan(MultipartFile file, String patternId, HttpServletResponse response);
|
||||
boolean importPlan(MultipartFile file, String patternId, HttpServletResponse response);
|
||||
|
||||
|
||||
/**
|
||||
* 根据父计划Id获取未被子计划绑定的标准设备
|
||||
*
|
||||
* @param fatherPlanId
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> getUnBoundStandardDev(String fatherPlanId);
|
||||
|
||||
/**
|
||||
* 根据计划Id获取已绑定标准设备
|
||||
*
|
||||
* @param planId
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> getBoundStandardDev(String planId);
|
||||
|
||||
/**
|
||||
* 修改子计划名称
|
||||
*
|
||||
* @param planId
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean updateSubPlanName(String planId, String name);
|
||||
|
||||
/**
|
||||
* 子计划绑定/解绑被检设备
|
||||
*
|
||||
* @param planId
|
||||
* @param pqDevIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateBindDev(PqDevParam.BindPlanParam param);
|
||||
|
||||
/**
|
||||
* 子计划绑定/解绑标准设备
|
||||
*
|
||||
* @param planId
|
||||
* @param standardDevIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateBindStandardDev(String planId, List<String> standardDevIds);
|
||||
|
||||
/**
|
||||
* 根据计划Id导出子计划数据
|
||||
*
|
||||
* @param planId
|
||||
* @param response
|
||||
*/
|
||||
void exportSubPlan(String planId, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.gather.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanStandardDev;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
public interface IAdPlanStandardDevService extends IService<AdPlanStandardDev> {
|
||||
|
||||
|
||||
/**
|
||||
* 添加检测计划-标准设备关联关系
|
||||
*
|
||||
* @param planId
|
||||
* @param standardDevIds
|
||||
* @return
|
||||
*/
|
||||
boolean addAdPlanStandardDev(String planId, List<String> standardDevIds);
|
||||
|
||||
/**
|
||||
* 修改检测计划-标准设备关联关系
|
||||
*
|
||||
* @param planId
|
||||
* @param standardDevIds
|
||||
* @return
|
||||
*/
|
||||
boolean updateAdPlanStandardDev(String planId, List<String> standardDevIds);
|
||||
|
||||
/**
|
||||
* 删除检测计划-标准设备关联关系
|
||||
*
|
||||
* @param planIds
|
||||
* @return
|
||||
*/
|
||||
boolean deleteAdPlanStandardDev(List<String> planIds);
|
||||
|
||||
/**
|
||||
* 删除检测计划-标准设备关联关系
|
||||
*
|
||||
* @param planId
|
||||
* @param standardDevIds
|
||||
* @return
|
||||
*/
|
||||
boolean deleteAdPlanStandardDev(String planId, List<String> standardDevIds);
|
||||
|
||||
/**
|
||||
* 根据检测计划id获取标准设备名称字符串
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String getStandardDevNameStrByPlanId(String id);
|
||||
|
||||
/**
|
||||
* 根据检测计划id获取关联关系
|
||||
*
|
||||
* @param planIds
|
||||
* @return
|
||||
*/
|
||||
List<AdPlanStandardDev> listByPlanId(List<String> planIds);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.plan.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.plan.mapper.AdPlanSourceMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
@@ -44,9 +45,12 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteAdPlanSourceByPlanIds(List<String> planIds) {
|
||||
QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("ad_plan_source.Plan_Id", planIds);
|
||||
return this.remove(queryWrapper);
|
||||
if(CollectionUtils.isNotEmpty(planIds)){
|
||||
QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("ad_plan_source.Plan_Id", planIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.gather.plan.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanStandardDev;
|
||||
import com.njcn.gather.plan.service.IAdPlanStandardDevService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdPlanStandardDevServiceImpl extends ServiceImpl<AdPlanStandardDevMapper, AdPlanStandardDev> implements IAdPlanStandardDevService {
|
||||
|
||||
@Override
|
||||
public boolean addAdPlanStandardDev(String planId, List<String> standardDevIds) {
|
||||
List<AdPlanStandardDev> adPlanStandardDevList = new ArrayList<>();
|
||||
for (String standardDevId : standardDevIds) {
|
||||
AdPlanStandardDev adPlanStandardDev = new AdPlanStandardDev();
|
||||
adPlanStandardDev.setPlanId(planId);
|
||||
adPlanStandardDev.setStandardDevId(standardDevId);
|
||||
adPlanStandardDevList.add(adPlanStandardDev);
|
||||
}
|
||||
return this.saveBatch(adPlanStandardDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAdPlanStandardDev(String planId, List<String> standardDevIds) {
|
||||
this.deleteAdPlanStandardDev(Collections.singletonList(planId));
|
||||
return this.addAdPlanStandardDev(planId, standardDevIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAdPlanStandardDev(List<String> planIds) {
|
||||
if (CollectionUtil.isNotEmpty(planIds)) {
|
||||
QueryWrapper<AdPlanStandardDev> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("Plan_Id", planIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAdPlanStandardDev(String planId, List<String> standardDevIds) {
|
||||
if (CollectionUtil.isNotEmpty(standardDevIds)) {
|
||||
QueryWrapper<AdPlanStandardDev> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("Plan_Id", planId).in("Standard_Dev_Id", standardDevIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStandardDevNameStrByPlanId(String id) {
|
||||
List<PqStandardDev> pqStandardDevs = this.baseMapper.listByPlanId(Collections.singletonList(id));
|
||||
return pqStandardDevs.stream().map(PqStandardDev::getName).reduce((a, b) -> a + "," + b).orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdPlanStandardDev> listByPlanId(List<String> planIds) {
|
||||
return this.lambdaQuery().in(AdPlanStandardDev::getPlanId, planIds).list();
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public interface DetectionValidMessage {
|
||||
|
||||
String RECHECK_NUM_NOT_NULL = "检测次数不能为空,请检查reCheckNum参数";
|
||||
|
||||
String PLAN_ID_NOT_NULL = "检测计划ID不能为空,请检查planId参数";
|
||||
String PLAN_ID_NOT_BLANK = "检测计划ID不能为空,请检查planId参数";
|
||||
|
||||
String PQ_DEV_IDS_NOT_NULL = "设备ID集合不能为null,请检查pqDevIds参数";
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface DetectionValidMessage {
|
||||
|
||||
String RECHECK_NUM_FORMAT_ERROR = "检测次数格式错误,请检查recheckNum参数";
|
||||
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误,请检查patternId参数";
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误";
|
||||
|
||||
String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空,请检查sourceIds参数";
|
||||
|
||||
@@ -120,13 +120,13 @@ public interface DetectionValidMessage {
|
||||
|
||||
String BELONG_LINE_NOT_BLANK = "所属母线不能为空";
|
||||
|
||||
String PT_NOT_NULL = "PT变比不能为空";
|
||||
String PT_NOT_BLANK = "PT变比不能为空";
|
||||
|
||||
String CT_NOT_NULL = "CT变比不能为空";
|
||||
String CT_NOT_BLANK = "CT变比不能为空";
|
||||
|
||||
String WIRING_TYPE_NOT_BLANK = "接线方式不能为空";
|
||||
String CONNECTION_NOT_BLANK = "接线方式不能为空";
|
||||
|
||||
String WIRING_TYPE_FORMAT_ERROR = "接线方式格式错误";
|
||||
String CONNECTION_FORMAT_ERROR = "接线方式格式错误";
|
||||
|
||||
String DATASOURCE_ID_NOT_EMPTY = "数据源ID不能为空";
|
||||
|
||||
@@ -158,7 +158,7 @@ public interface DetectionValidMessage {
|
||||
|
||||
String CHECK_RESULT_FORMAT_ERROR = "检测结果格式错误";
|
||||
|
||||
String MONITOR_NUM_NOT_NULL = "监测点序号不能为空";
|
||||
String MONITOR_NUM_NOT_NULL = "线路号不能为空";
|
||||
|
||||
String FACTOR_FLAG_FORMAT_ERROR = "是否支持系数校准格式错误";
|
||||
|
||||
@@ -179,4 +179,24 @@ public interface DetectionValidMessage {
|
||||
|
||||
String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符";
|
||||
String REPORT_NAME_NOT_BLANK = "报告模板不能为空";
|
||||
String OPERATION_DATE_FORMAT_ERROR = "投运日期格式错误,请检查operationDate参数";
|
||||
|
||||
String INSPECT_DATE_FORMAT_ERROR = "定检日期格式错误,请检查inspectDate参数";
|
||||
String MONITOR_NAME_NOT_BLANK = "监测点名称不能为空";
|
||||
String MONITOR_ID_NOT_BLANK = "谐波系统监测点ID不能为空";
|
||||
String DEVICE_ID_NOT_BLANK = "所属设备ID不能为空";
|
||||
String STAT_INTERVAL_NOT_NULL = "统计间隔不能为空";
|
||||
String MONITOR_ID_PATTERN = "谐波系统监测点ID格式错误";
|
||||
String DATA_RULE_NOT_BLANK = "数据处理原则不能为空";
|
||||
String ASSOCIATE_REPORT_NOT_NULL = "是否关联报告模板不能为空";
|
||||
String PID_FORMAT_ERROR = "PID格式错误";
|
||||
String INSPECT_CHANNEL_NOT_BLANK = "可检通道不能为空";
|
||||
String INSPECT_CHANNEL_FORMAT_ERROR = "可检通道格式错误";
|
||||
String CREATE_DATE_NOT_NULL = "投运日期不能为空";
|
||||
String INSPECT_DATE_NOT_NULL = "定检日期不能为空";
|
||||
String HARM_SYS_ID_NOT_BLANK = "谐波系统设备id不能为空";
|
||||
String FATHER_PLAN_ID_FORMAT_ERROR = "父计划ID格式错误";
|
||||
String DEV_IDS_NOT_EMPTY = "被检设备不能为空";
|
||||
String STANDARD_DEV_IDS_NOT_EMPTY = "标准设备不能为空";
|
||||
String PAIRS_NOT_EMPTY = "配对关系不能为空";
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum DetectionResponseEnum {
|
||||
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
|
||||
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
|
||||
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
|
||||
SCRIPT_NAME_REPEAT("A02015","脚本名称重复"),
|
||||
SCRIPT_NAME_REPEAT("A02015", "脚本名称重复"),
|
||||
|
||||
|
||||
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
|
||||
@@ -48,8 +48,31 @@ public enum DetectionResponseEnum {
|
||||
DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"),
|
||||
CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"),
|
||||
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"),
|
||||
CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误,只能包含数字,长度为1-32位"),
|
||||
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位" );
|
||||
CN_DEV_NAME_FORMAT_ERROR("A02059", "设备名称格式错误,只能包含数字,长度为1-32位"),
|
||||
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060", "设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位"),
|
||||
IMPORT_REPORT_TEMPLATE_ERROR("A02061", "当关联报告模板为是时,报告模板不能为空"),
|
||||
DEV_TYPE_NOT_EXIST("A02062", "设备类型不存在,请先添加设备类型"),
|
||||
MANUFACTURER_NOT_EXIST("A02063", "该设备厂家不存在,请先在\"设备厂家\"字典中添加"),
|
||||
PROTOCOL_NOT_EXIST("A02064", "该协议不存在,请先在\"通讯协议\"字典中添加"),
|
||||
DELEGATE_NOT_EXIST("A02065", "该委托方不存在,请先在\"委托方\"字典中添加"),
|
||||
PREINVESTMENT_PLAN_NOT_EXIST("A02066", "该预投计划不存在,请先在\"预投计划\"字典中添加"),
|
||||
DATA_SOURCE_NOT_EXIST("A02067", "该数据源不存在,请先在\"数据源\"字典中添加"),
|
||||
SCRIPT_NOT_EXIST("A02068", "该脚本不存在,请先添加该脚本"),
|
||||
ERROR_SYSTEM_NOT_EXIST("A02069", "该误差体系不存在,请先添加该误差体系"),
|
||||
DATA_RULE_NOT_EXIST("A02070", "该数据处理原则不存在,请先在\"数据处理原则\"字典中添加"),
|
||||
REPORT_TEMPLATE_NOT_EXIST("A02071", "该报告模板不存在,请先添加该报告模板"),
|
||||
LACK_REPORT_TEMPLATE_ID("A02072", "当关联报告模板为\"是\"时,报告模板不能为空"),
|
||||
NAME_OR_CREATEID_REPEAT("A02073", "名称或装置编号重复"),
|
||||
MONITOR_REPEAT("A02080", "当前设备下已存在相同的监测点"),
|
||||
PQ_STANDARD_DEV_REPEAT("A02090", "已存在同名的标准设备"),
|
||||
IMPORT_FLAG_NOT_UPDATE("A02091", "从谐波系统导入的设备不支持修改"),
|
||||
CONNECTION_NOT_EXIST("A02092", "该连接不存在,请先在\"接线方式\"字典中添加"),
|
||||
MONITOR_NUM_OUT_OF_RANGE("A02093", "检测点线路号超出范围,请检查线路号"),
|
||||
MONITOR_NUM_REPEAT("A02094", "该被检设备下存在相同线路号的监测点"),
|
||||
PLAN_HAS_CHILDREN("A02095", "该计划下存在子计划,请先删除子计划"),
|
||||
PLAN_REPEATED_IN_SAME_LEVEL("A02096", "该父计划下存在同名的子计划"),
|
||||
PLEASE_UNASSIGN_STANDARD_DEV("A02097","存在已分配给子计划的标准设备,请先解除分配" ),
|
||||
PLEASE_UNASSIGN_DEVICE("A02098", "存在已分配给计划的被检设备,请先解除分配");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.report.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
@@ -140,4 +141,30 @@ public class ReportController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("listAllName");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqReportService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/uploadReportToCloud")
|
||||
@ApiOperation("批量上传检测报告到云端")
|
||||
@ApiImplicitParam(name = "deviceIds", value = "被检设备ID列表,为空时上传所有已生成报告的设备", required = false)
|
||||
public HttpResult<Object> uploadReportToCloud(@RequestBody(required = false) List<String> deviceIds) {
|
||||
String methodDescribe = getMethodDescribe("uploadReportToCloud");
|
||||
LogUtil.njcnDebug(log, "{},设备ID列表为:{}", methodDescribe, deviceIds);
|
||||
pqReportService.uploadReportToCloud(deviceIds);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ public enum BaseReportKeyEnum {
|
||||
YEAR("year","年份"),
|
||||
MONTH("month","月份"),
|
||||
DAY("day","日"),
|
||||
YEAR_MONTH_DAY("year-month-day","年-月-日");
|
||||
YEAR_MONTH_DAY("year-month-day","年-月-日"),
|
||||
TEMPERATURE("temp","温度"),
|
||||
HUMIDITY("hum","相对湿度"),
|
||||
DELEGATE("delegate","委托方");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/5/22 9:46
|
||||
*/
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 统计文档锚点类型
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/24 18:42
|
||||
*/
|
||||
@Getter
|
||||
public enum BookmarkEnum {
|
||||
|
||||
|
||||
DATA_LINE("data_line", "准确度数据展示区域,以测试回路维度展示", 1),
|
||||
DATA_SCRIPT("data_script", "准确度数据展示区域,以检测项维度展示", 1),
|
||||
TEST_RESULT_DEV("testResult_dev", "检测结论,仅有设备结论", 2),
|
||||
TEST_RESULT_LINE("testResult_line", "检测结论,仅有回路结论", 2),
|
||||
TEST_RESULT_DETAIL("testResult_detail", "检测结论,包含回路、设备结论", 2),
|
||||
CATALOG("catalog", "目录信息", 3);
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
BookmarkEnum(String key, String desc, Integer sort) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static BookmarkEnum getByKey(String key) {
|
||||
for (BookmarkEnum bookmarkEnum : BookmarkEnum.values()) {
|
||||
if (bookmarkEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return bookmarkEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public enum ItemReportKeyEnum {
|
||||
|
||||
NAME("name", "检测项,比如:频率"),
|
||||
NAME_DETAIL("nameDetail", "检测项详细,比如:频率测量准确度"),
|
||||
INFLUENCE("influence", "影响量的描述,比如额定工作条件、谐波对电压的影响等等"),
|
||||
ERROR_SCOPE("errorScope", "误差范围,注:在段落中时需加上(),表格中无需添加"),
|
||||
ERROR_SCOPE_MAG("errorScopeMag", "特征幅值:误差范围"),
|
||||
ERROR_SCOPE_DUR("errorScopeDur", "持续时间:误差范围"),
|
||||
|
||||
@@ -16,9 +16,9 @@ public enum PowerIndexEnum {
|
||||
FREQ("FREQ", "频率"),
|
||||
V("V", "电压"),
|
||||
I("I", "电流"),
|
||||
IMBV("IMBV", "三相电压不平衡度"),
|
||||
IMBA("IMBA", "三相电流不平衡度"),
|
||||
F("F", "闪变"),
|
||||
IMBV("IMBV", "负序电压不平衡度"),
|
||||
IMBA("IMBA", "负序电流不平衡度"),
|
||||
F("F", "短时电压闪变"),
|
||||
HP("HP", "谐波有功功率"),
|
||||
HV("HV", "谐波电压"),
|
||||
HI("HI", "谐波电流"),
|
||||
|
||||
@@ -20,11 +20,11 @@ public enum ReportResponseEnum {
|
||||
REPORT_TEMPLATE_NOT_EXIST("A012009", "报告模板缺失,请联系管理员!"),
|
||||
NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"),
|
||||
FILE_RENAME_FAILED("A012011", "文件重命名失败"),
|
||||
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" ),
|
||||
GENERATE_REPORT_ERROR("A012015","生成报告失败"),
|
||||
;
|
||||
REPORT_NAME_PATTERN_ERROR("A012012", "报告名称格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
REPORT_VERSION_PATTERN_ERROR("A012013", "报告版本号格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
FILE_SIZE_ERROR("A012014", "文件大小不能超过5MB"),
|
||||
GENERATE_REPORT_ERROR("A012015", "生成报告失败"),
|
||||
FTP_CONNECTION_FAILED("A012016", "FTP连接失败,无法将二维码文件上传至装置");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.njcn.gather.report.pojo.vo.PqReportVO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
@@ -65,7 +64,23 @@ public interface IPqReportService extends IService<PqReport> {
|
||||
|
||||
void generateReport(DevReportParam devReportParam);
|
||||
|
||||
|
||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||
|
||||
//Map<String, Object> getMap(DevReportParam devReportParam);
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(List<String> id);
|
||||
|
||||
/**
|
||||
* 批量上传检测报告到云端
|
||||
*
|
||||
* @param deviceIds 被检设备ID列表,为空时上传所有已生成报告的设备
|
||||
*/
|
||||
void uploadReportToCloud(List<String> deviceIds);
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,295 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
|
||||
import com.njcn.gather.report.pojo.enums.BookmarkEnum;
|
||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 递归查找所有书签,并在书签处插入内容
|
||||
*/
|
||||
public class BookmarkUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 书签信息
|
||||
*/
|
||||
public static class BookmarkInfo {
|
||||
public CTBookmark bookmark;
|
||||
public P parentParagraph;
|
||||
public ContentAccessor parentContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查找所有书签
|
||||
*/
|
||||
public static List<BookmarkInfo> findAllBookmarks(ContentAccessor contentAccessor) {
|
||||
List<BookmarkInfo> result = new ArrayList<>();
|
||||
for (Object obj : contentAccessor.getContent()) {
|
||||
Object realObj = (obj instanceof JAXBElement) ? ((JAXBElement<?>) obj).getValue() : obj;
|
||||
if (realObj instanceof P) {
|
||||
P p = (P) realObj;
|
||||
for (Object o2 : p.getContent()) {
|
||||
Object realO2 = (o2 instanceof JAXBElement) ? ((JAXBElement<?>) o2).getValue() : o2;
|
||||
if (realO2 instanceof CTBookmark) {
|
||||
BookmarkInfo info = new BookmarkInfo();
|
||||
info.bookmark = (CTBookmark) realO2;
|
||||
info.parentParagraph = p;
|
||||
info.parentContainer = contentAccessor;
|
||||
result.add(info);
|
||||
}
|
||||
}
|
||||
} else if (realObj instanceof ContentAccessor) {
|
||||
result.addAll(findAllBookmarks((ContentAccessor) realObj));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在书签后插入段落
|
||||
*/
|
||||
public static void insertParagraphsAfter(BookmarkInfo info, P paragraph) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
parentContent.add(idx + 1, paragraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在书签后插入表格
|
||||
*/
|
||||
public static void insertTableAfter(BookmarkInfo info, Tbl table) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
parentContent.add(idx + 1, table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在书签后插入元素,可能是段落、表格、图片、书签等
|
||||
*/
|
||||
public static void insertElement(BookmarkInfo info, List<Object> elements) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
// 遍历元素,如果是通道回路这种大标题需要新起一个空的文档页
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
Object element = elements.get(i);
|
||||
if (element instanceof P) {
|
||||
P p = (P) element;
|
||||
String textFromP = Docx4jUtil.getTextFromP(p);
|
||||
if (textFromP.contains("测量回路")) {
|
||||
if (!textFromP.contains("1")) {
|
||||
// 另起一页
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
}
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, p);
|
||||
}
|
||||
else if (textFromP.startsWith(PowerIndexEnum.IMBV.getDesc())
|
||||
|| textFromP.startsWith(PowerIndexEnum.HV.getDesc())
|
||||
|| textFromP.startsWith(PowerIndexEnum.HI.getDesc())
|
||||
|
||||
) {
|
||||
// 另起一页
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}else if(textFromP.startsWith("注:基波电流幅值5.000A,基波频率50.0Hz,各次间谐波电流含有率均为3.0%。")){
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
}
|
||||
else {
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}
|
||||
} else {
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档中的空白页
|
||||
* @param docx 要处理的Word文档
|
||||
*/
|
||||
public static void removeBlankPages(MainDocumentPart mainDocumentPart) {
|
||||
// 获取文档主体
|
||||
Document document = mainDocumentPart.getJaxbElement();
|
||||
Body body = document.getBody();
|
||||
|
||||
// 获取所有段落
|
||||
List<Object> paragraphs = body.getContent();
|
||||
|
||||
// 用于标记是否在空白页中
|
||||
boolean inBlankPage = false;
|
||||
// 用于存储要删除的段落
|
||||
List<P> paragraphsToRemove = new ArrayList<>();
|
||||
|
||||
for (Object paragraph : paragraphs) {
|
||||
if (paragraph instanceof P){
|
||||
P paragraphtemp = (P) paragraph;
|
||||
// 检查段落是否为空
|
||||
boolean isEmpty = isParagraphEmpty(paragraphtemp);
|
||||
|
||||
if (isEmpty) {
|
||||
if (!inBlankPage) {
|
||||
inBlankPage = true;
|
||||
}
|
||||
paragraphsToRemove.add(paragraphtemp);
|
||||
} else {
|
||||
inBlankPage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除空白段落
|
||||
for (P paragraph : paragraphsToRemove) {
|
||||
body.getContent().remove(paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查段落是否为空
|
||||
* @param paragraph 要检查的段落
|
||||
* @return 如果段落为空返回true,否则返回false
|
||||
*/
|
||||
private static boolean isParagraphEmpty(P paragraph) {
|
||||
// 检查段落是否包含分节符
|
||||
if (paragraph.getPPr() != null && paragraph.getPPr().getSectPr() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查段落中的文本内容
|
||||
for (Object obj : paragraph.getContent()) {
|
||||
if (obj instanceof R) {
|
||||
R run = (R) obj;
|
||||
// 在3.3.4版本中,使用getContent()获取文本内容
|
||||
for (Object runContent : run.getContent()) {
|
||||
if (runContent instanceof Text) {
|
||||
Text text = (Text) runContent;
|
||||
if (text.getValue() != null && !text.getValue().trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在插入前检查目标位置是否有分页符
|
||||
*
|
||||
* @param position 目标位置
|
||||
* @return 是否包含分页符
|
||||
*/
|
||||
private static boolean hasPageBreak(Object position) {
|
||||
if (position instanceof P) {
|
||||
P paragraph = (P) position;
|
||||
for (Object run : paragraph.getContent()) {
|
||||
if (run instanceof R) {
|
||||
R r = (R) run;
|
||||
for (Object element : r.getContent()) {
|
||||
if (element instanceof Br && ((Br) element).getType() != null
|
||||
&& ((Br) element).getType().equals("page")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除书签
|
||||
*
|
||||
* @param bookmarkInfo 书签信息
|
||||
*/
|
||||
public static void removeBookmark(BookmarkUtil.BookmarkInfo bookmarkInfo) {
|
||||
try {
|
||||
// 获取书签所在的段落
|
||||
P paragraph = bookmarkInfo.parentParagraph;
|
||||
|
||||
// 遍历段落内容,找到并删除书签开始和结束标记
|
||||
List<Object> paragraphContent = new ArrayList<>(paragraph.getContent());
|
||||
for (Object obj : paragraphContent) {
|
||||
if (obj instanceof JAXBElement) {
|
||||
JAXBElement<?> element = (JAXBElement<?>) obj;
|
||||
Object value = element.getValue();
|
||||
|
||||
// 删除书签开始标记
|
||||
if (value instanceof CTBookmark) {
|
||||
paragraph.getContent().remove(obj);
|
||||
}
|
||||
// 删除书签结束标记
|
||||
else if (value instanceof CTMarkupRange) {
|
||||
paragraph.getContent().remove(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 ObjectFactory 创建表格
|
||||
*
|
||||
* @param factory ObjectFactory 实例
|
||||
* @param data 二维数组,表格内容
|
||||
* @return Tbl 表格对象
|
||||
*/
|
||||
public static Tbl createTable(ObjectFactory factory, String[][] data) {
|
||||
Tbl table = factory.createTbl();
|
||||
for (String[] rowData : data) {
|
||||
Tr row = factory.createTr();
|
||||
for (String cellData : rowData) {
|
||||
Tc cell = factory.createTc();
|
||||
P para = factory.createP();
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(cellData);
|
||||
run.getContent().add(text);
|
||||
para.getContent().add(run);
|
||||
cell.getContent().add(para);
|
||||
row.getContent().add(cell);
|
||||
}
|
||||
table.getContent().add(row);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定标签的标签信息
|
||||
*
|
||||
* @param key 标签名
|
||||
* @param bookmarks 所有标签信息
|
||||
*/
|
||||
public static BookmarkInfo getBookmarkInfo(String key, List<BookmarkInfo> bookmarks) {
|
||||
BookmarkUtil.BookmarkInfo bookmarkInfo = null;
|
||||
for (BookmarkUtil.BookmarkInfo info : bookmarks) {
|
||||
String name = info.bookmark.getName();
|
||||
if (key.equalsIgnoreCase(name)) {
|
||||
bookmarkInfo = info;
|
||||
}
|
||||
}
|
||||
return bookmarkInfo;
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,12 @@ import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.gather.report.pojo.constant.ReportConstant;
|
||||
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
|
||||
import com.njcn.gather.report.pojo.vo.Bookmark;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -244,13 +237,14 @@ public class Docx4jUtil {
|
||||
/**
|
||||
* 段落中添加内容
|
||||
*/
|
||||
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr) {
|
||||
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr,PPr ppr) {
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(content);
|
||||
run.setRPr(rPr);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
paragraph.setPPr(ppr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,6 +341,20 @@ public class Docx4jUtil {
|
||||
text.setValue(value);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
// 字体
|
||||
// 设置字体
|
||||
RPr rPr = factory.createRPr();
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
if (containsChinese(value)) {
|
||||
rFonts.setEastAsia("宋体");
|
||||
rFonts.setAscii("宋体");
|
||||
rFonts.setHAnsi("宋体");
|
||||
} else {
|
||||
rFonts.setEastAsia("Arial");
|
||||
rFonts.setAscii("Arial");
|
||||
rFonts.setHAnsi("Arial");
|
||||
}
|
||||
rPr.setRFonts(rFonts);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
@@ -356,13 +364,17 @@ public class Docx4jUtil {
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
if (value.equals("不合格")) {
|
||||
RPr rPr = factory.createRPr();
|
||||
Color color = factory.createColor();
|
||||
// 红色
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
run.setRPr(rPr);
|
||||
}
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
// 10号字体 = 20 half-points
|
||||
sz.setVal(new BigInteger("20"));
|
||||
rPr.setSz(sz);
|
||||
|
||||
cell.getContent().add(paragraph);
|
||||
cell.setTcPr(tcPr);
|
||||
row.getContent().add(cell);
|
||||
@@ -372,20 +384,39 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断字符串是否包含中文
|
||||
* @param str 需要判断的字符串
|
||||
* @return 是否包含中文
|
||||
*/
|
||||
private static boolean containsChinese(String str) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
for (char c : str.toCharArray()) {
|
||||
if (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param cellValues 数据
|
||||
* @param factory 工厂
|
||||
* @param cellValues 数据
|
||||
* @param ascFontStyle 西文字体
|
||||
* @param eastFontStyle 中文字体
|
||||
* @param size 字体大小
|
||||
* @param boldFlag 是否加粗
|
||||
* @param centerFlag 是否居中
|
||||
* @param eastFontStyle 中文字体
|
||||
* @param size 字体大小
|
||||
* @param boldFlag 是否加粗
|
||||
* @param centerFlag 是否居中
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle,String eastFontStyle, Integer size, boolean boldFlag, boolean centerFlag) {
|
||||
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle, String eastFontStyle, Integer size, boolean boldFlag, List<Integer> centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (String value : cellValues) {
|
||||
for (int i = 0; i < cellValues.size(); i++) {
|
||||
String value = cellValues.get(i);
|
||||
Tc cell = factory.createTc();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
@@ -394,7 +425,7 @@ public class Docx4jUtil {
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
if (!centerFlag.contains(i)) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
@@ -408,7 +439,7 @@ public class Docx4jUtil {
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
}
|
||||
if(boldFlag){
|
||||
if (boldFlag) {
|
||||
BooleanDefaultTrue bold = factory.createBooleanDefaultTrue();
|
||||
rPr.setB(bold);
|
||||
}
|
||||
@@ -425,9 +456,20 @@ public class Docx4jUtil {
|
||||
rPr.setSz(fontSize);
|
||||
// 中文字号
|
||||
rPr.setSzCs(fontSize);
|
||||
|
||||
run.setRPr(rPr);
|
||||
cell.getContent().add(paragraph);
|
||||
// 设置单元格边距
|
||||
TcPr cellProperties = factory.createTcPr();
|
||||
cell.setTcPr(cellProperties);
|
||||
// 设置单元格上下边距(单位:缇)
|
||||
TcMar mar = factory.createTcMar();
|
||||
TblWidth top = factory.createTblWidth();
|
||||
top.setW(BigInteger.valueOf(100));
|
||||
mar.setTop(top);
|
||||
TblWidth bottom = factory.createTblWidth();
|
||||
bottom.setW(BigInteger.valueOf(100));
|
||||
mar.setBottom(bottom);
|
||||
cellProperties.setTcMar(mar);
|
||||
row.getContent().add(cell);
|
||||
}
|
||||
return row;
|
||||
@@ -448,7 +490,6 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 存储Heading 5及其子内容的辅助类
|
||||
public static class HeadingContent {
|
||||
private String headingText;
|
||||
@@ -471,6 +512,38 @@ public class Docx4jUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定书签在文档段落中的位置索引
|
||||
*
|
||||
* @param documentPart 主文档部分
|
||||
* @param bookmarkName 书签名称
|
||||
* @return 段落索引,找不到返回 -1
|
||||
*/
|
||||
public static int getParagraphPosition(MainDocumentPart documentPart, String bookmarkName) {
|
||||
List<Object> content = documentPart.getContent();
|
||||
for (int i = 0; i < content.size(); i++) {
|
||||
Object obj = content.get(i);
|
||||
// 只处理段落
|
||||
if (obj instanceof P) {
|
||||
P paragraph = (P) obj;
|
||||
// 提取段落纯文本
|
||||
String text = getTextFromP(paragraph).trim();
|
||||
if (text.startsWith("#{") && text.endsWith("}")) {
|
||||
// 提取书签名
|
||||
String name = text.substring(2, text.length() - 1);
|
||||
if (name.equals(bookmarkName)) {
|
||||
// 返回段落索引
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 找不到返回 -1
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取段落在文档中的位置
|
||||
*/
|
||||
@@ -534,4 +607,27 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分页符
|
||||
*/
|
||||
public static P getPageBreak() {
|
||||
try {
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
// 创建分页符
|
||||
R run = factory.createR();
|
||||
Br br = factory.createBr();
|
||||
br.setType(STBrType.PAGE);
|
||||
// 直接添加 br 对象
|
||||
run.getContent().add(br);
|
||||
// 创建包含分页符的段落
|
||||
P pageBreakParagraph = factory.createP();
|
||||
pageBreakParagraph.getContent().add(run);
|
||||
return pageBreakParagraph;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public enum ResultUnitEnum {
|
||||
IMBV("%", "电压不平衡度","IMBV"),
|
||||
IMBA("%", "电流不平衡度","IMBA"),
|
||||
F("","闪变","F"),
|
||||
P("W", "功率","P"),
|
||||
|
||||
UNKNOWN("","未知","UNKNOWN"),
|
||||
;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ResultParam {
|
||||
public static class QueryParam {
|
||||
|
||||
@ApiModelProperty(value = "检测计划Id", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_NULL)
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ResultParam {
|
||||
@Data
|
||||
public static class ChangeErrorSystemParam {
|
||||
@ApiModelProperty(value = "检测计划Id", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_NULL)
|
||||
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
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.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -36,6 +36,7 @@ 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.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
@@ -47,16 +48,16 @@ import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
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.po.SimAndDigBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
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.cfg.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -80,16 +81,18 @@ import java.util.stream.Collectors;
|
||||
public class ResultServiceImpl implements IResultService {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final AdNonHarmonicService adNonHarmonicService;
|
||||
private final AdHarmonicService adHarmonicService;
|
||||
private final SimAndDigNonHarmonicService adNonHarmonicService;
|
||||
private final SimAndDigHarmonicService adHarmonicService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final PqScriptMapper scriptMapper;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final TableGenMapper tableGenMapper;
|
||||
private final DetectionServiceImpl detectionServiceImpl;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
/**
|
||||
* 谐波类code,取树形字典表中的code
|
||||
@@ -108,12 +111,12 @@ public class ResultServiceImpl implements IResultService {
|
||||
adPlanService.visualize(Collections.singletonList(plan));
|
||||
}
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
|
||||
|
||||
List<Map<String, String>> chnList = new ArrayList<>();
|
||||
|
||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
List<SimAndDigBaseResult> allResultList = new ArrayList<>();
|
||||
//只查询指定的脚本类型
|
||||
if (ObjectUtil.isNotNull(queryParam.getScriptType())) {
|
||||
List<Integer> indexList = pqScriptDtlsService.getIndexList(queryParam.getScriptType(), scriptId);
|
||||
@@ -122,22 +125,22 @@ public class ResultServiceImpl implements IResultService {
|
||||
if (HARMONIC_TYPE_CODE.contains(dictTree.getCode())) {
|
||||
allResultList.addAll(adHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
} else {
|
||||
allResultList.addAll(adNonHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(adNonHarmonicService.listSimAndDigBaseResult(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
}
|
||||
} else { //查询所有的脚本类型
|
||||
allResultList.addAll(adHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(adNonHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(adNonHarmonicService.listSimAndDigBaseResult(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(allResultList)) {
|
||||
Map<String, List<AdBaseResult>> chnMap = allResultList.stream().collect(
|
||||
Map<String, List<SimAndDigBaseResult>> chnMap = allResultList.stream().collect(
|
||||
Collectors.groupingBy(obj -> obj.getMonitorId().substring(obj.getMonitorId().lastIndexOf("_") + 1))
|
||||
);
|
||||
chnMap.forEach((chn, list) -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("value", chn);
|
||||
Set<Integer> collect = list.stream().filter(obj -> obj.getResultFlag() != 4).map(AdBaseResult::getResultFlag).collect(Collectors.toSet());
|
||||
Set<Integer> collect = list.stream().filter(obj -> obj.getResultFlag() != 4).map(SimAndDigBaseResult::getResultFlag).collect(Collectors.toSet());
|
||||
map.put("label", conform(collect) + "");
|
||||
|
||||
chnList.add(map);
|
||||
@@ -161,15 +164,15 @@ public class ResultServiceImpl implements IResultService {
|
||||
);
|
||||
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
||||
if (StrUtil.isNotBlank(param.getDevId())) {
|
||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
List<SimAndDigBaseResult> 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(adNonHarmonicService.listSimAndDigBaseResult(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())));
|
||||
resultMap = allResultList.stream().collect(Collectors.groupingBy(SimAndDigBaseResult::getSort, Collectors.mapping(SimAndDigBaseResult::getResultFlag, Collectors.toSet())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,8 +970,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 暂态的valueType通常只有2个,一个特征幅值,一个持续时间
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (Integer sort : indexList) {
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillVoltagePhaseData(nonHarmList, keyFillMap, tableKeys);
|
||||
@@ -992,8 +995,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 查询结果数据,经过上层处理谐波类此处的scriptIndex确保只有一个
|
||||
if (indexList.size() == 1) {
|
||||
// 获取谐波数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueType, indexList.get(0));
|
||||
AdHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueType, indexList.get(0));
|
||||
SimAndDigHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
||||
// 注:如果ABC的标准值一致,则同步到standard中
|
||||
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
@@ -1013,10 +1016,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
double timeDouble = Math.round(harmNum);
|
||||
int timeInt = (int) timeDouble;
|
||||
// 填充结果数据
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 按次数排序
|
||||
@@ -1037,16 +1038,14 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 非谐波的需要区分是否为ABC相还是T相
|
||||
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
||||
// 获取该三相的数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
for (SimAndDigNonHarmonicResult SimAndDigNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillThreePhaseData(SimAndDigNonHarmonicResult, null, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 需要对所有的填充进行按误差范围分组
|
||||
@@ -1067,15 +1066,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
} else {
|
||||
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
for (SimAndDigNonHarmonicResult simAndDigNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(8);
|
||||
fillTPhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillTPhaseData(simAndDigNonHarmonicResult, null, keyFillMap);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
@@ -1118,7 +1115,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param timeInt 谐波类需要传指定次数
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
*/
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap, String scriptCode) {
|
||||
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
||||
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
||||
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
||||
@@ -1127,50 +1124,65 @@ public class ResultServiceImpl implements IResultService {
|
||||
testA = "/", testB = "/", testC = "/",
|
||||
errorA = "/", errorB = "/", errorC = "/",
|
||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
||||
errorScope = "/", unit = "";
|
||||
errorScope = "/", unit = "", scriptDetail = "/";
|
||||
|
||||
if (Objects.nonNull(tempA) && (PowerConstant.DATA_RANGE.contains(tempA.getIsData()))) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : "不合格";
|
||||
errorScope = tempA.getRadius();
|
||||
unit = tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
if (Objects.nonNull(tempA)) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
if (Objects.nonNull(tempA.getErrorData())) {
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
}
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : tempA.getIsData() == 2 ? "不合格" : "/";
|
||||
errorScope = tempA.getRadius() == null ? "/" : tempA.getRadius();
|
||||
unit = tempA.getUnit() == null ? "" : tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempB) && (PowerConstant.DATA_RANGE.contains(tempB.getIsData()))) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempB)) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
if (Objects.nonNull(tempB.getErrorData())) {
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
}
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : tempB.getIsData() == 2 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempB.getRadius();
|
||||
errorScope = tempB.getRadius() == null ? "/" : tempB.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempB.getUnit();
|
||||
unit = tempB.getUnit() == null ? "" : tempB.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(tempC) && (PowerConstant.DATA_RANGE.contains(tempC.getIsData()))) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempC)) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
if (Objects.nonNull(tempC.getErrorData())) {
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
}
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : tempC.getIsData() == 2 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempC.getRadius();
|
||||
errorScope = tempC.getRadius() == null ? "/" : tempC.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempC.getUnit();
|
||||
unit = tempC.getUnit() == null ? "" : tempC.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
}
|
||||
}
|
||||
// 浙江脚本特殊处理
|
||||
if (scriptCode.equalsIgnoreCase("I")) {
|
||||
resultA = "/";
|
||||
resultB = "/";
|
||||
resultC = "/";
|
||||
}
|
||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
||||
standard = standardA;
|
||||
}
|
||||
// 处理脚本输出
|
||||
scriptDetail = dealScriptDetail(scriptCode, standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.SCRIPT_DETAIL.getKey(), scriptDetail);
|
||||
// 标准值
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
||||
@@ -1198,6 +1210,45 @@ public class ResultServiceImpl implements IResultService {
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对浙江杭州处理脚本输出细节,todo... 需要更改更合理的方式,现在算是写死的了部分
|
||||
* 目前浙江这边就是(间)谐波电压/电流
|
||||
*/
|
||||
private String dealScriptDetail(String scriptCode, String standard) {
|
||||
String scriptDetail = "";
|
||||
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(scriptCode);
|
||||
if (powerIndexEnum != null) {
|
||||
switch (powerIndexEnum) {
|
||||
case HV:
|
||||
case HSV:
|
||||
// 注:基波电压幅值57.74V,基波频率50.0Hz。
|
||||
scriptDetail = "注:基波电压幅值57.74V,基波频率50.0Hz。";
|
||||
break;
|
||||
case HI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
case HSI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次间谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return scriptDetail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* T相的相关数据处理,非暂态数据
|
||||
@@ -1210,13 +1261,15 @@ public class ResultServiceImpl implements IResultService {
|
||||
private void fillTPhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/", unit = "";
|
||||
DetectionData tempT = getResultData(singleResult, timeInt, PowerConstant.PHASE_T);
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
result = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unit = tempT.getUnit();
|
||||
errorScope = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
result = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 2 ? "不合格" : "/";
|
||||
unit = tempT.getUnit() == null ? "" : tempT.getUnit();
|
||||
errorScope = tempT.getRadius() == null ? "/" : tempT.getRadius();
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
||||
@@ -1233,25 +1286,27 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
* @param tableKeys 模板表格中的key
|
||||
*/
|
||||
private void fillVoltagePhaseData(List<AdNonHarmonicResult> nonHarmList, Map<String, String> keyFillMap, List<String> tableKeys) {
|
||||
private void fillVoltagePhaseData(List<SimAndDigNonHarmonicResult> nonHarmList, Map<String, String> keyFillMap, List<String> tableKeys) {
|
||||
String standardMag = "/", standardDur = "/",
|
||||
testMag = "/", testDur = "/",
|
||||
errorMag = "/", errorDur = "/",
|
||||
resultMag = "/", resultDur = "/", result,
|
||||
errorScope, errorScopeMag = "/", errorScopeDur = "/",
|
||||
unitMag = "", unitDur = "";
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
for (SimAndDigNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
DetectionData tempT = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_T);
|
||||
// 需要判断adNonHarmonicResult是特征幅值还是持续时间
|
||||
String adType = adNonHarmonicResult.getAdType();
|
||||
DictTree temp = dictTreeService.getById(adType);
|
||||
if (temp.getCode().equalsIgnoreCase("MAG")) {
|
||||
// 特征幅值
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 2 ? "不合格" : "/";
|
||||
unitMag = tempT.getUnit();
|
||||
errorScopeMag = tempT.getRadius();
|
||||
}
|
||||
@@ -1259,7 +1314,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 持续时间,需要注意时间单位处理,默认是秒
|
||||
String timeUnit = "s";
|
||||
for (String tableKey : tableKeys) {
|
||||
if (tableKey.contains(ItemReportKeyEnum.STANDARD_DUR.getKey())) {
|
||||
if (tableKey.contains("standardDur")) {
|
||||
//截取单位
|
||||
String[] tempStr = tableKey.split(StrPool.UNDERLINE);
|
||||
if (tempStr.length > 1) {
|
||||
@@ -1267,14 +1322,27 @@ public class ResultServiceImpl implements IResultService {
|
||||
timeUnit = "ms";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unitDur = tempT.getUnit();
|
||||
errorScopeDur = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT.getResultData())) {
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getData())) {
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getIsData())) {
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getUnit())) {
|
||||
unitDur = tempT.getUnit();
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getRadius())) {
|
||||
errorScopeDur = tempT.getRadius();
|
||||
}
|
||||
if (timeUnit.equalsIgnoreCase("ms")) {
|
||||
// 如果是ms,上述的一些数据需要重新处理
|
||||
if (!standardDur.equalsIgnoreCase("/")) {
|
||||
@@ -1296,8 +1364,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
}
|
||||
errorScopeMag = dealErrorScope(errorScopeMag).concat(unitMag);
|
||||
errorScopeDur = dealErrorScope(errorScopeDur).concat(unitDur);
|
||||
errorScopeMag = dealErrorScope(errorScopeMag).concat(StrUtil.isBlank(unitMag) ? "" : unitMag);
|
||||
errorScopeDur = dealErrorScope(errorScopeDur).concat(StrUtil.isBlank(unitDur) ? "" : unitDur);
|
||||
|
||||
errorScope = "特征幅值:".concat(errorScopeMag).concat(StrPool.COMMA).concat("持续时间:").concat(errorScopeDur);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
@@ -1331,6 +1399,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param errorScope 误差范围
|
||||
*/
|
||||
private String dealErrorScope(String errorScope) {
|
||||
if (StrUtil.isBlank(errorScope)) {
|
||||
return "/";
|
||||
}
|
||||
if (errorScope.contains("~")) {
|
||||
String[] split = errorScope.split("~");
|
||||
String begin = split[0];
|
||||
@@ -1449,7 +1520,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
private void createTempResultTable(String code) {
|
||||
this.dropTempResultTable(code);
|
||||
String oldCode = code.replace("_temp", "");
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code);
|
||||
tableGenMapper.genNonHarmonicResultTable(code, false);
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
StringBuilder C = new StringBuilder();
|
||||
@@ -1466,7 +1537,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "(\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Time_Id DATETIME(3) 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" +
|
||||
@@ -1510,20 +1581,27 @@ public class ResultServiceImpl implements IResultService {
|
||||
// PqDev dev = pqDevService.getById(devId);
|
||||
devIdMapComm.put(devId, devId);
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
DictDataEnum dataRule;
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
// SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
// if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
// dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
// } else {
|
||||
// dataRule = DictDataEnum.SECTION_VALUE;
|
||||
// }
|
||||
AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllRawData(scriptId, oldCode, 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.listAllRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<AdHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<SimAndDigNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllSimAndDigRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<SimAndDigNonHarmonicResult>> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(SimAndDigNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(SimAndDigNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<SimAndDigHarmonicResult> allHarmonicRawData = adHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<SimAndDigHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(SimAndDigHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(SimAndDigHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(planId);
|
||||
@@ -1533,12 +1611,12 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
issueParam.setDevIds(Arrays.asList(devId));
|
||||
issueParam.setScriptId(scriptId);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
issueParam.setIsPhaseSequence(CommonEnum.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<SimAndDigNonHarmonicResult> nonHarmonicResults = nonHarmonicMap.get(sourceIssue.getIndex());
|
||||
List<SimAndDigHarmonicResult> harmonicResults = harmonicMap.get(sourceIssue.getIndex());
|
||||
List<DevData> realDataXiList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(nonHarmonicResults)) {
|
||||
realDataXiList.addAll(this.toList(nonHarmonicResults, null, true));
|
||||
@@ -1553,13 +1631,20 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
});
|
||||
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(scriptId);
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), null, param.getTemperature(), param.getHumidity());
|
||||
}
|
||||
|
||||
private List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
|
||||
private List<DevData> toList(List<SimAndDigNonHarmonicResult> nonHarm, List<SimAndDigHarmonicResult> harm, boolean containBaseHarm) {
|
||||
List<DevData> info = new ArrayList<>();
|
||||
// if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
Map<String, List<AdNonHarmonicResult>> noHarmMap = nonHarm.stream()
|
||||
Map<String, List<SimAndDigNonHarmonicResult>> 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("_");
|
||||
@@ -1568,7 +1653,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
for (SimAndDigNonHarmonicResult result : value) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(result.getDataType());
|
||||
sqlDataDTO.setDesc(result.getAdType());
|
||||
@@ -1585,7 +1670,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
});
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harm)) {
|
||||
Map<String, List<AdHarmonicResult>> harmMap = harm.stream()
|
||||
Map<String, List<SimAndDigHarmonicResult>> 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());
|
||||
@@ -1593,7 +1678,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
|
||||
DevData.SqlDataHarmDTO dataHarmDTO;
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
for (SimAndDigHarmonicResult harmonicResult : value) {
|
||||
if (containBaseHarm) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(harmonicResult.getDataType());
|
||||
@@ -1640,12 +1725,12 @@ public class ResultServiceImpl implements IResultService {
|
||||
return info;
|
||||
}
|
||||
|
||||
private List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
|
||||
private List<String> reflectHarmonicValue(String phase, SimAndDigHarmonicResult 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);
|
||||
Field idField = SimAndDigHarmonicResult.class.getDeclaredField(fieldName);
|
||||
idField.setAccessible(true);
|
||||
String value = idField.get(adHarmonicResult) + "";
|
||||
info.add(value);
|
||||
|
||||
@@ -20,7 +20,9 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -34,14 +36,14 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
|
||||
|
||||
private final String SYMBOL="$";
|
||||
private final String SYMBOL = "$";
|
||||
|
||||
private final DictTreeMapper dictTreeMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getValueType(PqScriptCheckDataParam param) {
|
||||
String dataType = param.getDataType();
|
||||
if(StrUtil.isNotBlank(dataType)){
|
||||
if (StrUtil.isNotBlank(dataType)) {
|
||||
String[] split = dataType.split(",");
|
||||
if (split.length > 1) {
|
||||
dataType = split[0];
|
||||
@@ -60,7 +62,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
if (param.getIsValueTypeName()) {
|
||||
final String finalDataType = dataType;
|
||||
List<String> checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList());
|
||||
String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode();
|
||||
String U = finalDataType + SYMBOL + DetectionCodeEnum.U1.getCode();
|
||||
if (!checkData.contains(U)) {
|
||||
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) {
|
||||
checkData.add(U);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user