Compare commits
65 Commits
ac1d98efdc
...
2025-12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fa7ec91c4 | ||
|
|
fdb4b7060a | ||
| 3f47b0f008 | |||
|
|
cb431b5af1 | ||
|
|
153428b24f | ||
|
|
d92544f7c4 | ||
|
|
3f1ae1886a | ||
|
|
af4863af65 | ||
|
|
4b7c1259a7 | ||
|
|
de1496389e | ||
| 79003cd0f4 | |||
|
|
c3443fcc91 | ||
|
|
5105e77823 | ||
|
|
eb068b76a4 | ||
| 9f11f7ec11 | |||
| 2012221b73 | |||
|
|
9ab5d42439 | ||
| 7abcaefeb1 | |||
|
|
f4df52dd1c | ||
| db115bb27d | |||
|
|
68d96e67aa | ||
| 3f94012faa | |||
| 41c557118c | |||
| 6596a572d6 | |||
| 139c7b0651 | |||
|
|
ab236cd34f | ||
|
|
786bd5d660 | ||
|
|
21d2c2b7a7 | ||
|
|
48fa4c2390 | ||
|
|
033330b005 | ||
|
|
f81123c3f7 | ||
|
|
5539cb2887 | ||
|
|
1df9c8d703 | ||
|
|
1cbed2a620 | ||
| 89667367ea | |||
| 92b95dd86d | |||
|
|
6b7e38fef6 | ||
|
|
f10debe2f2 | ||
|
|
9d15351fba | ||
|
|
2339a006ec | ||
|
|
7fd904ab79 | ||
|
|
61f149b562 | ||
|
|
57ee3a4d43 | ||
| 563eb80b65 | |||
|
|
dae10378dd | ||
|
|
40cb153656 | ||
|
|
af4f000b13 | ||
|
|
f922ee97aa | ||
|
|
321ec97130 | ||
|
|
0dd3502942 | ||
|
|
26c5e933f5 | ||
|
|
00ba09faae | ||
|
|
40e39d651b | ||
|
|
02c8164b7e | ||
|
|
8c598aec1e | ||
|
|
2c59defdc2 | ||
|
|
5642bf2b31 | ||
|
|
ba76df66b0 | ||
|
|
57c419eb70 | ||
|
|
98f4ecef6c | ||
|
|
20e07712cb | ||
|
|
c7d8fc3168 | ||
|
|
bb22857fc9 | ||
|
|
6ef908ff60 | ||
|
|
7461801657 |
@@ -120,7 +120,7 @@ public class SocketContrastResponseService {
|
||||
// private SysRegRes contrastRegRes = null;
|
||||
|
||||
|
||||
@Value("${log.homeDir}")
|
||||
@Value("${report.reportDir}")
|
||||
private String alignDataFilePath;
|
||||
|
||||
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
||||
@@ -182,6 +182,8 @@ public class SocketContrastResponseService {
|
||||
FormalTestManager.pstDataType = null;
|
||||
FormalTestManager.isPstData = false;
|
||||
FormalTestManager.isWaveCheck = false;
|
||||
FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false;
|
||||
// FormalTestManager.isXu = true;
|
||||
FormalTestManager.nonWaveDataSourceEnum = null;
|
||||
|
||||
String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(",");
|
||||
@@ -219,7 +221,13 @@ public class SocketContrastResponseService {
|
||||
FormalTestManager.isRemoveSocket = false;
|
||||
FormalTestManager.waveCheckFlag = false;
|
||||
FormalTestManager.scheduler = null;
|
||||
FormalTestManager.scheduledFuture = null;
|
||||
if (FormalTestManager.scheduledFuture != null) {
|
||||
FormalTestManager.scheduledFuture.cancel(true);
|
||||
if (FormalTestManager.scheduler != null) {
|
||||
FormalTestManager.scheduler.shutdown();
|
||||
}
|
||||
FormalTestManager.scheduledFuture = null;
|
||||
}
|
||||
|
||||
HashBiMap<String, String> hashBiMap = HashBiMap.create(param.getPairs());
|
||||
FormalTestManager.pairsIdMap.clear();
|
||||
@@ -716,9 +724,14 @@ public class SocketContrastResponseService {
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
System.out.println("(仅有录波)模型一致性校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
|
||||
this.sendXu(s);
|
||||
this.resetTimer();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
if (FormalTestManager.isXu) {
|
||||
this.sendXu(s);
|
||||
this.resetTimer();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
} else {
|
||||
System.out.println("跳过相序校验!");
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -909,9 +922,14 @@ public class SocketContrastResponseService {
|
||||
|
||||
this.clearData();
|
||||
|
||||
System.out.println("数据对齐校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》");
|
||||
this.sendXu(s);
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
if (FormalTestManager.isXu) {
|
||||
System.out.println("数据对齐校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》");
|
||||
this.sendXu(s);
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
} else {
|
||||
System.out.println("跳过相序校验!");
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
this.resetTimer();
|
||||
}
|
||||
}
|
||||
@@ -1035,60 +1053,7 @@ public class SocketContrastResponseService {
|
||||
webSend.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());//最终成功推送
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
|
||||
// 后续做正式检测
|
||||
if (param.getTestItemList().get(2)) {
|
||||
System.out.println("相序校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始正式检测》》》》》》》》》》》》》》》》");
|
||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||
socketMsg.setOperateCode(requestOperateCode.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(Arrays.asList(FormalTestManager.monitorMap.keySet().toArray(new String[FormalTestManager.monitorMap.size()])));
|
||||
List<String> allDataType = this.getAllDataType();
|
||||
FormalTestManager.pstDataType = new ArrayList<>();
|
||||
if (allDataType.contains(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode())) {
|
||||
FormalTestManager.pstDataType.add(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
allDataType.remove(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(allDataType)) {
|
||||
phaseSequenceParam.setDataType(allDataType);
|
||||
} else {
|
||||
if (CollUtil.isNotEmpty(FormalTestManager.pstDataType)) {
|
||||
FormalTestManager.isPstData = true;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
phaseSequenceParam.setDataType(FormalTestManager.pstDataType);
|
||||
}
|
||||
}
|
||||
phaseSequenceParam.setReadCount(this.getReadCount(this.getTargetCount()));
|
||||
phaseSequenceParam.setIgnoreCount(0);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
this.resetTimer();
|
||||
checkResult = false;
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
// 录波数据
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
successComm.clear();
|
||||
failComm.clear();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.RECORD_WAVE_STEP1;
|
||||
// 发送录波指令
|
||||
this.sendRecordWave(s);
|
||||
}
|
||||
} else {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
if (FormalTestManager.voltageProtocol) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
}
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
FormalTestManager.isTesting = false;
|
||||
}
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
} else if (successComm.size() == FormalTestManager.monitorMap.size()) {
|
||||
this.clearData();
|
||||
@@ -1174,6 +1139,63 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
||||
// 后续做正式检测
|
||||
if (param.getTestItemList().get(2)) {
|
||||
System.out.println("开始正式检测!");
|
||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||
socketMsg.setOperateCode(requestOperateCode.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(Arrays.asList(FormalTestManager.monitorMap.keySet().toArray(new String[FormalTestManager.monitorMap.size()])));
|
||||
List<String> allDataType = this.getAllDataType();
|
||||
FormalTestManager.pstDataType = new ArrayList<>();
|
||||
if (allDataType.contains(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode())) {
|
||||
FormalTestManager.pstDataType.add(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
allDataType.remove(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(allDataType)) {
|
||||
phaseSequenceParam.setDataType(allDataType);
|
||||
} else {
|
||||
if (CollUtil.isNotEmpty(FormalTestManager.pstDataType)) {
|
||||
FormalTestManager.isPstData = true;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
phaseSequenceParam.setDataType(FormalTestManager.pstDataType);
|
||||
}
|
||||
}
|
||||
phaseSequenceParam.setReadCount(this.getReadCount(this.getTargetCount()));
|
||||
phaseSequenceParam.setIgnoreCount(0);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
this.resetTimer();
|
||||
checkResult = false;
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
// 录波数据
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
successComm.clear();
|
||||
failComm.clear();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.RECORD_WAVE_STEP1;
|
||||
// 发送录波指令
|
||||
this.sendRecordWave(s);
|
||||
}
|
||||
} else {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
if (FormalTestManager.voltageProtocol) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
}
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
FormalTestManager.isTesting = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正式检测
|
||||
*
|
||||
@@ -1208,39 +1230,6 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
}
|
||||
this.setScheduler(targetCount, param.getUserPageId(), requestOperateCode, quitOperateCode);
|
||||
// if (Objects.isNull(FormalTestManager.scheduler)) {
|
||||
// FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
||||
// long delay = this.getDelay(targetCount);
|
||||
// FormalTestManager.scheduledFuture = FormalTestManager.scheduler.schedule(() -> {
|
||||
// if (!checkResult) {
|
||||
// System.out.println("正式检测-" + delay + "s内收集数据不完整!");
|
||||
// // 断开与设备的连接,但是不要将Socket移除
|
||||
// if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
// }
|
||||
// if (FormalTestManager.voltageProtocol) {
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
// }
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
// FormalTestManager.isTesting = false;
|
||||
//
|
||||
// this.clearData();
|
||||
//
|
||||
// Collection<String> disjunction = CollectionUtil.disjunction(FormalTestManager.pairsIpMap.keySet(), successPair.keySet());
|
||||
// // 向前端推送收集数据不完整的配对项
|
||||
// for (String key : disjunction) {
|
||||
// webSend.setCode(SourceResponseCodeEnum.FAIL.getCode());
|
||||
// webSend.setData(MsgUtil.getPairStr(key, FormalTestManager.pairsIpMap.inverse().get(key), FormalTestManager.devNameMapComm) + " 数据收集不完整!");
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
// }
|
||||
// // 推送最终失败结果
|
||||
// webSend.setCode(SourceResponseCodeEnum.ALL_FAIL.getCode());//最终错误推送
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
// }
|
||||
// FormalTestManager.scheduler.shutdown();
|
||||
// FormalTestManager.scheduler = null;
|
||||
// }, delay, TimeUnit.SECONDS);
|
||||
// }
|
||||
|
||||
String monitorId1 = devData.getId();
|
||||
String devMonitorId = monitorId1;
|
||||
@@ -1953,6 +1942,17 @@ public class SocketContrastResponseService {
|
||||
boolean isStar = DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection());
|
||||
boolean isDelta = DetectionCodeEnum.DELTA.getCode().equals(monitorListDTO.getConnection());
|
||||
|
||||
PreDetection preDetection = FormalTestManager.devList.stream().filter(obj -> obj.getDevIP().equals(split[0])).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(preDetection)) {
|
||||
if (preDetection.getUsePhaseIndex() == 1) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<AlignDataVO.RawData> dataList = new ArrayList<>();
|
||||
for (int i = 0; i < channelDevDataList.size(); i++) {
|
||||
DevData.SqlDataDTO.ListDTO list1 = null;
|
||||
@@ -2032,6 +2032,7 @@ public class SocketContrastResponseService {
|
||||
channelDataMap.forEach((channel, channelDevDataList) -> {
|
||||
String standardDevMonitorId = ip + CnSocketUtil.SPLIT_TAG + channel;
|
||||
String devMonitorId = FormalTestManager.pairsIpMap.inverse().get(standardDevMonitorId);
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
PreDetection.MonitorListDTO monitorListDTO = FormalTestManager.monitorMap.get(devMonitorId);
|
||||
List<DevData> devDataList = BeanUtil.copyToList(FormalTestManager.devDataMap.get(devMonitorId), DevData.class);
|
||||
channelDevDataList.sort(Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
@@ -2042,9 +2043,21 @@ public class SocketContrastResponseService {
|
||||
exportParams.setSheetName(standardDevName + "通道" + channel);
|
||||
sheet.put("title", exportParams);
|
||||
|
||||
List<AlignDataExcel> dataList = new ArrayList<>();
|
||||
boolean isStar = DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection());
|
||||
boolean isDelta = DetectionCodeEnum.DELTA.getCode().equals(monitorListDTO.getConnection());
|
||||
|
||||
PreDetection preDetection = FormalTestManager.devList.stream().filter(obj -> obj.getDevIP().equals(split[0])).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(preDetection)) {
|
||||
if (preDetection.getUsePhaseIndex() == 1) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<AlignDataExcel> dataList = new ArrayList<>();
|
||||
for (int i = 0; i < channelDevDataList.size(); i++) {
|
||||
DevData.SqlDataDTO.ListDTO list1 = null;
|
||||
DevData.SqlDataDTO sqlDataDTO1 = null;
|
||||
@@ -2103,7 +2116,7 @@ public class SocketContrastResponseService {
|
||||
});
|
||||
});
|
||||
|
||||
ExcelUtil.saveExcel(alignDataFilePath, "实时数据.xlsx", sheetsList);
|
||||
ExcelUtil.saveExcel(alignDataFilePath, "对齐数据.xlsx", sheetsList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2252,6 +2265,19 @@ public class SocketContrastResponseService {
|
||||
boolean isStar = DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection());
|
||||
boolean isDelta = DetectionCodeEnum.DELTA.getCode().equals(monitorListDTO.getConnection());
|
||||
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
PreDetection preDetection = FormalTestManager.devList.stream().filter(obj -> obj.getDevIP().equals(split[0])).findFirst().orElse(null);
|
||||
|
||||
if (ObjectUtil.isNotNull(preDetection)) {
|
||||
if (preDetection.getUsePhaseIndex() == 1) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 电压校验
|
||||
List<DevData.SqlDataDTO> uDev = null;
|
||||
List<DevData.SqlDataDTO> uStd = null;
|
||||
@@ -2374,7 +2400,6 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
|
||||
boolean isPhaseAngle = false;
|
||||
PreDetection preDetection = FormalTestManager.devList.stream().filter(dev -> dev.getDevId().equals(devMonitorId.split(CnSocketUtil.SPLIT_TAG)[0])).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(preDetection)) {
|
||||
isPhaseAngle = preDetection.getAngle() == 1 ? true : false;
|
||||
}
|
||||
|
||||
@@ -439,6 +439,7 @@ public class SocketDevResponseService {
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
String type = sourceIssues.get(0).getType();
|
||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||
@@ -612,7 +613,7 @@ public class SocketDevResponseService {
|
||||
|
||||
private void assemblyEntity(List<DevData> deList, DevXiNumData.F F, DevXiNumData.GF startF, CoefficientVO coefficientVO, CoefficientVO.DevParameter devParameter) {
|
||||
//表示接收完成,必须保证3个数
|
||||
if (deList.size() >= 3) {
|
||||
if (deList.size() >= 7) {
|
||||
List<Double> aList = deList.stream().map(it -> it.getSqlData().get(0).getList().getA()).collect(Collectors.toList());
|
||||
List<Double> bList = deList.stream().map(it -> it.getSqlData().get(0).getList().getB()).collect(Collectors.toList());
|
||||
List<Double> cList = deList.stream().map(it -> it.getSqlData().get(0).getList().getC()).collect(Collectors.toList());
|
||||
@@ -687,7 +688,7 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
private Double reduceList(List<Double> valList) {
|
||||
// valList.subList(0, 5).clear();
|
||||
// valList.subList(valList.size() - 3, valList.size() - 1).clear();
|
||||
valList.subList(valList.size() - 2, valList.size()).clear();
|
||||
return valList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
|
||||
}
|
||||
|
||||
@@ -953,6 +954,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||
}
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
@@ -1210,6 +1212,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||
}
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
@@ -1782,6 +1785,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
FormalTestManager.currentTestPlan = plan;
|
||||
|
||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||
FormalTestManager.patternEnum = PatternEnum.getEnum(code);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||
@@ -14,7 +15,12 @@ import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -56,6 +62,8 @@ public class SocketSourceResponseService {
|
||||
* 设备信息服务,提供设备基础信息查询功能
|
||||
*/
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IAdPlanSourceService adPlanSourceService;
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
/**
|
||||
* Socket连接管理器,负责管理设备和源的Socket连接
|
||||
@@ -334,9 +342,9 @@ public class SocketSourceResponseService {
|
||||
// 系数校验固定检测项:实时电压有效值和实时电流有效值
|
||||
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
|
||||
// 读取3次数据用于系数计算
|
||||
phaseSequenceParam.setReadCount(3);
|
||||
phaseSequenceParam.setReadCount(7); //3
|
||||
// 忽略前4次数据,等待测量稳定
|
||||
phaseSequenceParam.setIgnoreCount(4);
|
||||
phaseSequenceParam.setIgnoreCount(3); //4
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
@@ -363,18 +371,32 @@ public class SocketSourceResponseService {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
// 使用智能发送工具类,自动管理设备连接
|
||||
socketManager.smartSendToDevice(param, json);
|
||||
if (FormalTestManager.unknownError) {
|
||||
FormalTestManager.unknownError = false;
|
||||
|
||||
//重新下发脚本
|
||||
String type = FormalTestManager.currentIssue.getType();
|
||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||
FormalTestManager.currentIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||
}
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||
} else {
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
// 使用智能发送工具类,自动管理设备连接
|
||||
socketManager.smartSendToDevice(param, json);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
@@ -570,6 +592,10 @@ public class SocketSourceResponseService {
|
||||
case UNPROCESSED_BUSINESS:
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
break;
|
||||
case UNKNOWN_ERROR: //-1源未知异常
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
FormalTestManager.unknownError = true;
|
||||
break;
|
||||
default:
|
||||
sendErrorAndQuit(param, socketDataMsg, dictDataEnumByCode);
|
||||
break;
|
||||
@@ -601,9 +627,23 @@ public class SocketSourceResponseService {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
if (FormalTestManager.unknownError) {
|
||||
//获取源初始化参数
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
SocketMsg<String> socketMsg1 = new SocketMsg<>();
|
||||
socketMsg1.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketMsg1.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketMsg1.setData(JSON.toJSONString(sourceParam));
|
||||
//使用智能发送工具类,自动管理与源控程序的socket连接
|
||||
socketManager.smartSendToSource(param, JSON.toJSONString(socketMsg1));
|
||||
}
|
||||
} else {
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
@@ -653,6 +693,8 @@ public class SocketSourceResponseService {
|
||||
|
||||
// 同步更新系数管理器中的设备列表
|
||||
XiNumberManager.xiDevList = devList;
|
||||
FormalTestManager.unknownError = false;
|
||||
FormalTestManager.currentIssue = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,9 @@ public class ContrastDetectionParam {
|
||||
private List<Boolean> testItemList;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 是否进行相许校验
|
||||
*/
|
||||
private Integer phaseCheck;
|
||||
}
|
||||
|
||||
@@ -53,4 +53,9 @@ public class DetectionData {
|
||||
* 误差体系详情ID(比对式使用)
|
||||
*/
|
||||
private String errorDtlId;
|
||||
|
||||
/**
|
||||
* 有效组数
|
||||
*/
|
||||
private Integer validGroupNum;
|
||||
}
|
||||
|
||||
@@ -809,6 +809,9 @@ public class DetectionServiceImpl {
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A, scale);
|
||||
if (CollUtil.isEmpty(mag.get(TYPE_A))) {
|
||||
a.setIsData(2);
|
||||
}
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
result.setTValue(JSON.toJSONString(a));
|
||||
result.setResultFlag(a.getIsData());
|
||||
@@ -1567,6 +1570,9 @@ public class DetectionServiceImpl {
|
||||
private Map<String, Integer> singleMonitorProcessing(List<DevData> devDataList, List<DevData> standardDevDataList, Map<String, String> devIdMapComm, List<String> testItemCodeList, String errorSysId, DictDataEnum dataRule, Integer num, String code, Integer waveNum, DataSourceEnum dataSourceEnum) {
|
||||
Map<String, Integer> resultMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(testItemCodeList)) {
|
||||
devDataList = devDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
||||
standardDevDataList = standardDevDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
||||
// 处理谐波数据
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
String[] split1 = devDataList.get(0).getId().split("_");
|
||||
String devMonitorId = devIdMapComm.get(split1[0]) + "_" + split1[1];
|
||||
@@ -1654,7 +1660,7 @@ public class DetectionServiceImpl {
|
||||
resultMap.put(PowerIndexEnum.HSI.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, I, fIn, INHARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
||||
break;
|
||||
case PST:
|
||||
resultMap.put(PowerIndexEnum.F.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn , DetectionCodeEnum.PST.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, DataSourceEnum.MINUTE_STATISTICS_AVG));
|
||||
resultMap.put(PowerIndexEnum.F.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, DetectionCodeEnum.PST.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, DataSourceEnum.MINUTE_STATISTICS_AVG));
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
break;
|
||||
@@ -1750,8 +1756,16 @@ public class DetectionServiceImpl {
|
||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||
}
|
||||
|
||||
Map<String, List<Double>> validData = this.getValidData(standardDevDataList, desc);
|
||||
|
||||
Integer validGroupNum = 0;
|
||||
if (map.containsKey(TYPE_T)) {
|
||||
if (ObjectUtil.isNotNull(validData)) {
|
||||
List<Double> tValidDataList = validData.get(TYPE_T);
|
||||
validGroupNum = this.getValidGroupNum(tValidDataList, null, errSysDtls, fData, scale, dataRule);
|
||||
}
|
||||
List<DetectionData> tList = rangeComparisonList(map.get(TYPE_T).get(0), map.get(TYPE_T).get(1), errSysDtls, fData, scale, dataRule);
|
||||
this.setValidGroupNum(tList, validGroupNum);
|
||||
result.setTValue(JSON.toJSONString(tList));
|
||||
result.setResultFlag(setResultFlag(tList));
|
||||
} else {
|
||||
@@ -1768,7 +1782,13 @@ public class DetectionServiceImpl {
|
||||
phases.add(TYPE_B);
|
||||
|
||||
for (String phase : phases) {
|
||||
if (ObjectUtil.isNotNull(validData)) {
|
||||
List<Double> validDataList = validData.get(phase);
|
||||
validGroupNum = this.getValidGroupNum(validDataList, null, errSysDtls, fData, scale, dataRule);
|
||||
}
|
||||
|
||||
List<DetectionData> phaseList = rangeComparisonList(map.get(phase).get(0), map.get(phase).get(1), errSysDtls, fData, scale, dataRule);
|
||||
this.setValidGroupNum(phaseList, validGroupNum);
|
||||
resultFlag.addAll(phaseList);
|
||||
BiConsumer<ContrastNonHarmonicResult, List<DetectionData>> setter = setters.get(phase);
|
||||
setter.accept(result, phaseList);
|
||||
@@ -1783,6 +1803,169 @@ public class DetectionServiceImpl {
|
||||
return StorageUtil.getInteger(resultFlag);
|
||||
}
|
||||
|
||||
private Map<String, List<Double>> getValidData(List<DevData> dev, String desc) {
|
||||
List<Double> aDev = new ArrayList<>();
|
||||
List<Double> bDev = new ArrayList<>();
|
||||
List<Double> cDev = new ArrayList<>();
|
||||
List<Double> tDev = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < dev.size(); i++) {
|
||||
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||
|
||||
String finalDesc = desc;
|
||||
List<DevData.SqlDataDTO.ListDTO> devList = devSqlData.stream().filter(j -> finalDesc.equals(j.getDesc()))
|
||||
.map(DevData.SqlDataDTO::getList).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isEmpty(devList)) {
|
||||
return null;
|
||||
}
|
||||
aDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getA()))
|
||||
.map(x -> x.getA().doubleValue())
|
||||
.collect(Collectors.toList()));
|
||||
bDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getB()))
|
||||
.map(x -> x.getB().doubleValue())
|
||||
.collect(Collectors.toList()));
|
||||
cDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getC()))
|
||||
.map(x -> x.getC().doubleValue())
|
||||
.collect(Collectors.toList()));
|
||||
tDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getT()))
|
||||
.map(x -> x.getT().doubleValue())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return new HashMap() {
|
||||
{
|
||||
put(TYPE_A, aDev);
|
||||
put(TYPE_B, bDev);
|
||||
put(TYPE_C, cDev);
|
||||
put(TYPE_T, tDev);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Map<String, Map<Double, List<Double>>> getHarmValidData(List<DevData> dev, String fundCode, String harmCode, Integer harmonicFlag) {
|
||||
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
||||
Map<String, Map<Double, List<Double>>> devMap = new HashMap<>(3);
|
||||
|
||||
List<Double> harmNum = new ArrayList<>();
|
||||
if (1 == harmonicFlag) {
|
||||
harmNum.addAll(Stream.iterate(0.5, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||
} else {
|
||||
harmNum.addAll(Stream.iterate(1.0, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < dev.size(); i++) {
|
||||
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||
|
||||
Optional<DevData.SqlDataDTO> first1 = Optional.empty();
|
||||
|
||||
if (CollUtil.isNotEmpty(devSqlData)) {
|
||||
first1 = devSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
|
||||
DevData.SqlDataDTO fund1 = null;
|
||||
if (first1.isPresent()) {
|
||||
fund1 = first1.get();
|
||||
}
|
||||
|
||||
List<DevData.SqlDataHarmDTO> devHarmList = dev.get(i).getSqlDataHarm().stream().filter(x -> harmCode.equals(x.getDesc())).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isEmpty(devHarmList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(devHarmList)) {
|
||||
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
||||
if (ObjectUtil.isNotNull(fund1)) {
|
||||
harmPut(TYPE_A, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getA()), harmonicFlag);
|
||||
harmPut(TYPE_B, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getB()), harmonicFlag);
|
||||
harmPut(TYPE_C, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getC()), harmonicFlag);
|
||||
} else {
|
||||
harmPut(TYPE_A, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
harmPut(TYPE_B, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
harmPut(TYPE_C, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return devMap;
|
||||
}
|
||||
|
||||
private Integer getValidGroupNum(List<Double> devDataList, List<Double> U1List, List<PqErrSysDtls> errSysDtls, Double fData, Integer scale, DictDataEnum dataRule) {
|
||||
int result = 0;
|
||||
if (dataRule.getCode().equals(DictDataEnum.Own_value.getCode()) || dataRule.getCode().equals(DictDataEnum.SECTION_VALUE.getCode())) {
|
||||
return 1;
|
||||
} else {
|
||||
for (int i = 0; i < devDataList.size(); i++) {
|
||||
Double U1 = CollUtil.isNotEmpty(U1List) ? U1List.get(i) : null;
|
||||
Double stdDevData = BigDecimal.valueOf(devDataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
Double devData = BigDecimal.valueOf(devDataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
DetectionData detectionData = new DetectionData();
|
||||
detectionData.setIsData(ResultEnum.NO_ERROR_SYS.getValue());
|
||||
|
||||
//获得误差体系
|
||||
List<PqErrSysDtls> errSysDtls1 = errSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||
x.getStartFlag(),
|
||||
startRadiusEnd(x.getEndValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||
x.getEndFlag(),
|
||||
ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData)).collect(Collectors.toList());
|
||||
detectionData.setData(devData);
|
||||
detectionData.setResultData(stdDevData);
|
||||
if (CollUtil.isNotEmpty(errSysDtls1)) {
|
||||
result++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Double, Integer> getHarmValidGroupNum(Map<Double, List<Double>> devDataMap, List<Double> U1List, List<PqErrSysDtls> errSysDtls, Double fData, Integer scale, DictDataEnum dataRule) {
|
||||
Map<Double, Integer> resultMap = new HashMap<>();
|
||||
devDataMap.forEach((harmNum, dataList) -> {
|
||||
if (dataRule.getCode().equals(DictDataEnum.Own_value.getCode()) || dataRule.getCode().equals(DictDataEnum.SECTION_VALUE.getCode())) {
|
||||
resultMap.put(harmNum, 1);
|
||||
} else {
|
||||
Integer validGroupNum = 0;
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
Double U1 = CollUtil.isNotEmpty(U1List) ? U1List.get(i) : null;
|
||||
Double stdDevData = BigDecimal.valueOf(dataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
Double devData = BigDecimal.valueOf(dataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
DetectionData detectionData = new DetectionData();
|
||||
detectionData.setIsData(ResultEnum.NO_ERROR_SYS.getValue());
|
||||
|
||||
//获得误差体系
|
||||
List<PqErrSysDtls> errSysDtls1 = errSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||
x.getStartFlag(),
|
||||
startRadiusEnd(x.getEndValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||
x.getEndFlag(),
|
||||
ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData)).collect(Collectors.toList());
|
||||
detectionData.setData(devData);
|
||||
detectionData.setResultData(stdDevData);
|
||||
if (CollUtil.isNotEmpty(errSysDtls1)) {
|
||||
validGroupNum++;
|
||||
}
|
||||
}
|
||||
resultMap.put(harmNum, validGroupNum);
|
||||
}
|
||||
});
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private void setValidGroupNum(List<DetectionData> tList, Integer validGroupNum) {
|
||||
tList.forEach(detectionData -> {
|
||||
detectionData.setValidGroupNum(validGroupNum);
|
||||
});
|
||||
}
|
||||
|
||||
private void setHarmValidGroupNum(List<DetectionData> integerBooleanA, Map<Double, Integer> harmValidGroupNumA) {
|
||||
integerBooleanA.forEach(detectionData -> {
|
||||
Double harmNum = detectionData.getNum();
|
||||
Integer validGroupNum = harmValidGroupNumA.get(harmNum);
|
||||
detectionData.setValidGroupNum(validGroupNum);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理谐波数据
|
||||
@@ -1869,9 +2052,22 @@ public class DetectionServiceImpl {
|
||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||
}
|
||||
|
||||
Map<String, Map<Double, List<Double>>> harmValidData = this.getHarmValidData(standardDevDataList, fundCode, harmCode, harmonicFlag);
|
||||
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(devMap.get(TYPE_A).get(0), devMap.get(TYPE_A).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(devMap.get(TYPE_B).get(0), devMap.get(TYPE_B).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(devMap.get(TYPE_C).get(0), devMap.get(TYPE_C).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||
|
||||
Map<String, Map<Double, List<Double>>> U1ListMap = this.getU1ListMap(standardDevDataList, fundCode, harmCode, harmonicFlag);
|
||||
Map<Double, Integer> harmValidGroupNumA = this.getHarmValidGroupNum(harmValidData.get(TYPE_A), U1ListMap.get(TYPE_A).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||
this.setHarmValidGroupNum(integerBooleanA, harmValidGroupNumA);
|
||||
|
||||
Map<Double, Integer> harmValidGroupNumB = this.getHarmValidGroupNum(harmValidData.get(TYPE_B), U1ListMap.get(TYPE_B).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||
this.setHarmValidGroupNum(integerBooleanB, harmValidGroupNumB);
|
||||
|
||||
Map<Double, Integer> harmValidGroupNumC = this.getHarmValidGroupNum(harmValidData.get(TYPE_C), U1ListMap.get(TYPE_C).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||
this.setHarmValidGroupNum(integerBooleanC, harmValidGroupNumC);
|
||||
|
||||
reflectHarmonic(true, "a", integerBooleanA, result, harmonicFlag);
|
||||
reflectHarmonic(true, "b", integerBooleanB, result, harmonicFlag);
|
||||
reflectHarmonic(true, "c", integerBooleanC, result, harmonicFlag);
|
||||
@@ -1888,6 +2084,59 @@ public class DetectionServiceImpl {
|
||||
return StorageUtil.getInteger(resultFlag);
|
||||
}
|
||||
|
||||
private Map<String, Map<Double, List<Double>>> getU1ListMap(List<DevData> devDataList, String fundCode, String harmCode, Integer harmonicFlag) {
|
||||
Map<String, Map<Double, List<Double>>> resultMap = new HashMap<>(3);
|
||||
|
||||
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
||||
Map<String, Map<Double, List<Double>>> devMap = new HashMap<>(3);
|
||||
|
||||
List<Double> harmNum = new ArrayList<>();
|
||||
if (1 == harmonicFlag) {
|
||||
harmNum.addAll(Stream.iterate(0.5, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||
} else {
|
||||
harmNum.addAll(Stream.iterate(1.0, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < devDataList.size(); i++) {
|
||||
List<DevData.SqlDataDTO> standardDevSqlData = devDataList.get(i).getSqlData();
|
||||
|
||||
Optional<DevData.SqlDataDTO> first1 = Optional.empty();
|
||||
|
||||
if (CollUtil.isNotEmpty(standardDevSqlData)) {
|
||||
first1 = standardDevSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
|
||||
DevData.SqlDataDTO fund1 = null;
|
||||
if (first1.isPresent()) {
|
||||
fund1 = first1.get();
|
||||
}
|
||||
|
||||
List<DevData.SqlDataHarmDTO> devHarmList = devDataList.get(i).getSqlDataHarm().stream().filter(x -> harmCode.equals(x.getDesc())).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isEmpty(devHarmList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(devHarmList)) {
|
||||
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
||||
if (ObjectUtil.isNotNull(fund1)) {
|
||||
harmPut(TYPE_A, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getA()), harmonicFlag);
|
||||
harmPut(TYPE_B, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getB()), harmonicFlag);
|
||||
harmPut(TYPE_C, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getC()), harmonicFlag);
|
||||
} else {
|
||||
harmPut(TYPE_A, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
harmPut(TYPE_B, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
harmPut(TYPE_C, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultMap.put(TYPE_A, devMap.get(TYPE_A));
|
||||
resultMap.put(TYPE_B, devMap.get(TYPE_C));
|
||||
resultMap.put(TYPE_C, devMap.get(TYPE_C));
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理非谐波类取值
|
||||
@@ -1908,6 +2157,7 @@ public class DetectionServiceImpl {
|
||||
List<Double> cStandardDev = new ArrayList<>();
|
||||
List<Double> tDev = new ArrayList<>();
|
||||
List<Double> tStandardDev = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < dev.size(); i++) {
|
||||
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||
List<DevData.SqlDataDTO> standardDevSqlData = standardDev.get(i).getSqlData();
|
||||
@@ -1952,66 +2202,66 @@ public class DetectionServiceImpl {
|
||||
.map(x -> x.getT().doubleValue())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
List<Integer> aIdxs = DetectionUtil.sort(aDev, false);
|
||||
List<Integer> bIdxs = DetectionUtil.sort(bDev, false);
|
||||
List<Integer> cIdxs = DetectionUtil.sort(cDev, false);
|
||||
List<Integer> tIdxs = DetectionUtil.sort(tDev, false);
|
||||
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||
switch (dataRule) {
|
||||
case SECTION_VALUE:
|
||||
if (aDev.size() > 2) {
|
||||
aDev.remove(aIdxs.get(0));
|
||||
aDev.remove(aIdxs.get(aIdxs.size() - 1));
|
||||
List<Double> newArray = DetectionUtil.getNewArray(aStandardDev, aIdxs.subList(1, aIdxs.size() - 1));
|
||||
aStandardDev.clear();
|
||||
aStandardDev.addAll(newArray);
|
||||
if (aStandardDev.size() > 2) {
|
||||
aStandardDev.remove(0);
|
||||
aStandardDev.remove(aStandardDev.size() - 1);
|
||||
List<Double> newArray = DetectionUtil.getNewArray(aDev, aIdxs.subList(1, aIdxs.size() - 1));
|
||||
aDev.clear();
|
||||
aDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (bDev.size() > 2) {
|
||||
bDev.remove(bIdxs.get(0));
|
||||
bDev.remove(bIdxs.get(bIdxs.size() - 1));
|
||||
List<Double> newArray = DetectionUtil.getNewArray(bStandardDev, bIdxs.subList(1, bIdxs.size() - 1));
|
||||
bStandardDev.clear();
|
||||
bStandardDev.addAll(newArray);
|
||||
if (bStandardDev.size() > 2) {
|
||||
bStandardDev.remove(0);
|
||||
bStandardDev.remove(bStandardDev.size() - 1);
|
||||
List<Double> newArray = DetectionUtil.getNewArray(bDev, bIdxs.subList(1, bIdxs.size() - 1));
|
||||
bDev.clear();
|
||||
bDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (cDev.size() > 2) {
|
||||
cDev.remove(cIdxs.get(0));
|
||||
cDev.remove(cIdxs.get(cIdxs.size() - 1));
|
||||
List<Double> newArray = DetectionUtil.getNewArray(cStandardDev, cIdxs.subList(1, cIdxs.size() - 1));
|
||||
cStandardDev.clear();
|
||||
cStandardDev.addAll(newArray);
|
||||
if (cStandardDev.size() > 2) {
|
||||
cStandardDev.remove(0);
|
||||
cStandardDev.remove(cStandardDev.size() - 1);
|
||||
List<Double> newArray = DetectionUtil.getNewArray(cDev, cIdxs.subList(1, cIdxs.size() - 1));
|
||||
cDev.clear();
|
||||
cDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (tDev.size() > 2) {
|
||||
tDev.remove(tIdxs.get(0));
|
||||
tDev.remove(tIdxs.get(tIdxs.size() - 1));
|
||||
List<Double> newArray = DetectionUtil.getNewArray(tStandardDev, tIdxs.subList(1, tIdxs.size() - 1));
|
||||
tStandardDev.clear();
|
||||
tStandardDev.addAll(newArray);
|
||||
if (tStandardDev.size() > 2) {
|
||||
tStandardDev.remove(0);
|
||||
tStandardDev.remove(tStandardDev.size() - 1);
|
||||
List<Double> newArray = DetectionUtil.getNewArray(tDev, tIdxs.subList(1, tIdxs.size() - 1));
|
||||
tDev.clear();
|
||||
tDev.addAll(newArray);
|
||||
}
|
||||
break;
|
||||
case CP95_VALUE:
|
||||
if (CollUtil.isNotEmpty(aDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(aDev);
|
||||
aDev = Collections.singletonList(aDev.get(cp95Idx));
|
||||
if (CollUtil.isNotEmpty(aStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(aStandardDev);
|
||||
aStandardDev = Collections.singletonList(aStandardDev.get(cp95Idx));
|
||||
aDev = Collections.singletonList(aDev.get(aIdxs.get(cp95Idx)));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(bDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(bDev);
|
||||
bDev = Collections.singletonList(bDev.get(cp95Idx));
|
||||
if (CollUtil.isNotEmpty(bStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(bStandardDev);
|
||||
bStandardDev = Collections.singletonList(bStandardDev.get(cp95Idx));
|
||||
bDev = Collections.singletonList(bDev.get(bIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(cDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(cDev);
|
||||
cDev = Collections.singletonList(cDev.get(cp95Idx));
|
||||
if (CollUtil.isNotEmpty(cStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(cStandardDev);
|
||||
cStandardDev = Collections.singletonList(cStandardDev.get(cp95Idx));
|
||||
cDev = Collections.singletonList(cDev.get(cIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(tDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(tDev);
|
||||
tDev = Collections.singletonList(tDev.get(cp95Idx));
|
||||
if (CollUtil.isNotEmpty(tStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(tStandardDev);
|
||||
tStandardDev = Collections.singletonList(tStandardDev.get(cp95Idx));
|
||||
tDev = Collections.singletonList(tDev.get(tIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -2153,18 +2403,18 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
devMap.forEach((typeKey, typeValue) -> {
|
||||
standardDevMap.forEach((typeKey, typeValue) -> {
|
||||
typeValue.forEach((key, value) -> {
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||
switch (dataRule) {
|
||||
case SECTION_VALUE:
|
||||
if (value.size() > 2) {
|
||||
value.remove(idx.get(0));
|
||||
value.remove(idx.get(idx.size() - 1));
|
||||
List<Double> newArray = DetectionUtil.getNewArray(standardDevMap.get(typeKey).get(key), idx.subList(1, idx.size() - 1));
|
||||
standardDevMap.get(typeKey).get(key).clear();
|
||||
standardDevMap.get(typeKey).get(key).addAll(newArray);
|
||||
value.remove(0);
|
||||
value.remove(value.size() - 1);
|
||||
List<Double> newArray = DetectionUtil.getNewArray(devMap.get(typeKey).get(key), idx.subList(1, idx.size() - 1));
|
||||
devMap.get(typeKey).get(key).clear();
|
||||
devMap.get(typeKey).get(key).addAll(newArray);
|
||||
}
|
||||
break;
|
||||
case CP95_VALUE:
|
||||
@@ -2173,18 +2423,18 @@ public class DetectionServiceImpl {
|
||||
List<Double> newValue = Collections.singletonList(value.get(cp95Idx));
|
||||
value.clear();
|
||||
value.addAll(newValue);
|
||||
Double standardCP95Data = standardDevMap.get(typeKey).get(key).get(cp95Idx);
|
||||
standardDevMap.get(typeKey).get(key).clear();
|
||||
standardDevMap.get(typeKey).get(key).add(standardCP95Data);
|
||||
Double devCP95Data = devMap.get(typeKey).get(key).get(idx.get(cp95Idx));
|
||||
devMap.get(typeKey).get(key).clear();
|
||||
devMap.get(typeKey).get(key).add(devCP95Data);
|
||||
}
|
||||
break;
|
||||
case AVG_VALUE:
|
||||
List<Double> avgDoubles = DetectionUtil.getAvgDoubles(value);
|
||||
value.clear();
|
||||
value.addAll(avgDoubles);
|
||||
List<Double> standardAvgData = DetectionUtil.getAvgDoubles(standardDevMap.get(typeKey).get(key));
|
||||
standardDevMap.get(typeKey).get(key).clear();
|
||||
standardDevMap.get(typeKey).get(key).addAll(standardAvgData);
|
||||
List<Double> devAvgData = DetectionUtil.getAvgDoubles(devMap.get(typeKey).get(key));
|
||||
devMap.get(typeKey).get(key).clear();
|
||||
devMap.get(typeKey).get(key).addAll(devAvgData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
private final SocketManager socketManager;
|
||||
|
||||
@Value("${log.homeDir}")
|
||||
@Value("${report.reportDir}")
|
||||
private String alignDataFilePath;
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void exportAlignData() {
|
||||
String fileName = "实时数据.xlsx";
|
||||
String fileName = "对齐数据.xlsx";
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanTestConfig;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -195,4 +196,16 @@ public class FormalTestManager {
|
||||
public static boolean statisticsProtocol;
|
||||
|
||||
public static boolean voltageProtocol;
|
||||
|
||||
public static boolean unknownError;
|
||||
|
||||
/**
|
||||
* 当前下发的脚本
|
||||
*/
|
||||
public static SourceIssue currentIssue;
|
||||
|
||||
/**
|
||||
* 是否进行相序校验
|
||||
*/
|
||||
public static boolean isXu;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
devLineTestResult.setDeviceName(dev.getDevName());
|
||||
|
||||
Integer[] resultFlags = dev.getMonitorList().stream()
|
||||
.map(monitor -> ResultEnum.NETWORK_TIMEOUT)
|
||||
.map(monitor -> ResultEnum.NETWORK_TIMEOUT.getValue())
|
||||
.toArray(Integer[]::new);
|
||||
devLineTestResult.setChnResult(resultFlags);
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PqDevController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除被检设备")
|
||||
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "删除参数", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestBody @Validated PqDevParam.DeleteParam param) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, param.getIds()));
|
||||
@@ -162,10 +162,31 @@ public class PqDevController extends BaseController {
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getSelectOptions")
|
||||
@ApiOperation("根据历史记录信息来获取下拉框内容")
|
||||
@ApiOperation("从历史数据中查询下拉框选项")
|
||||
@ApiImplicitParam(name = "pattern", value = "模式id", required = true)
|
||||
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.UPLOAD)
|
||||
@PostMapping(value = "/ttt")
|
||||
@ApiOperation("批量导入被检设备")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult ttt(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, @RequestParam("planId") String planId, @RequestParam(value = "cover", defaultValue = "0") Integer cover, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("ttt");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
if ("null".equals(planId)) {
|
||||
planId = null;
|
||||
}
|
||||
return pqDevService.importDev(file, patternId, planId, response, cover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,17 +149,17 @@ public class PqStandardDevController 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<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);
|
||||
}
|
||||
// @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);
|
||||
// }
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
|
||||
@@ -38,8 +38,8 @@ public class ContrastDevExcel implements Serializable {
|
||||
@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)
|
||||
@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")
|
||||
@@ -91,8 +91,8 @@ public class ContrastDevExcel implements Serializable {
|
||||
@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)
|
||||
@Excel(name = "谐波系统设备id", width = 30, needMerge = true, orderNum = "18")
|
||||
// @NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@ExcelCollection(name = "监测点信息", orderNum = "19")
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface IPqStandardDevService extends IService<PqStandardDev> {
|
||||
* @param planId
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> listByPlanId(String planId);
|
||||
// List<PqStandardDev> listByPlanId(String planId);
|
||||
|
||||
/**
|
||||
* 查询出标准设备所需的检测信息
|
||||
|
||||
@@ -68,6 +68,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -562,6 +563,13 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
PqDev dev = this.getById(devId);
|
||||
Integer checkState = pqMonitorService.getDevCheckState(devId);
|
||||
Integer checkResult = pqMonitorService.getDevCheckResult(devId);
|
||||
if (checkResult == 1) {
|
||||
checkResult = CheckResultEnum.ACCORD.getValue();
|
||||
}
|
||||
if (checkResult == 2) {
|
||||
checkResult = CheckResultEnum.NOT_ACCORD.getValue();
|
||||
}
|
||||
|
||||
|
||||
SysUser user = userService.getById(userId);
|
||||
|
||||
@@ -1265,6 +1273,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
.map(ContrastDevExcel::getPqMonitorExcelList)
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(List::stream)
|
||||
// 过滤掉没有线路号的数据
|
||||
.filter(item -> ObjectUtil.isNotNull(item.getNum()))
|
||||
.collect(Collectors.toList());
|
||||
// 取第一条为设备基本信息
|
||||
ContrastDevExcel devExcel = devExcelList.get(0);
|
||||
@@ -1290,7 +1300,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// 判断是否有重复的num
|
||||
Set<Integer> uniqueNumSet = new HashSet<>(numList);
|
||||
if (uniqueNumSet.size() != numList.size()) {
|
||||
throw new BusinessException(DetectionResponseEnum.MONITOR_NUM_REPEAT);
|
||||
throw new BusinessException(DetectionResponseEnum.MONITOR_NUM_REPEAT, "【" + name + "】该被检设备下存在相同线路号的监测点!");
|
||||
}
|
||||
Integer max = CollectionUtil.max(numList);
|
||||
Integer min = CollectionUtil.min(numList);
|
||||
@@ -1309,10 +1319,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// 根据num排序
|
||||
pqMonitorExcelList.sort(Comparator.comparingInt(PqMonitorExcel::getNum));
|
||||
StringBuilder inspectChannelBuilder = new StringBuilder();
|
||||
for (int i = 1; i <= devChns; i++) {
|
||||
inspectChannelBuilder.append(i);
|
||||
if (i < devChns) {
|
||||
inspectChannelBuilder.append(",");
|
||||
for (int i = 0; i < numList.size(); i++) {
|
||||
inspectChannelBuilder.append(numList.get(i));
|
||||
if (i < numList.size() - 1) {
|
||||
inspectChannelBuilder.append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
importPqDev.setInspectChannel(inspectChannelBuilder.toString());
|
||||
@@ -1331,9 +1341,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (CollUtil.isNotEmpty(hasList)) {
|
||||
importPqDev.setId(hasList.get(0).getId());
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor pqMonitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
pqMonitor.setDevId(importPqDev.getId());
|
||||
monitorList.add(pqMonitor);
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
finalUpdateDevList.add(importPqDev);
|
||||
@@ -1357,6 +1369,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
@@ -1366,6 +1380,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
@@ -1487,13 +1503,19 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 24);
|
||||
pullDown.setLastCol(startCol + 24);
|
||||
pullDown.setFirstCol(startCol + 26);
|
||||
pullDown.setLastCol(startCol + 26);
|
||||
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 27);
|
||||
pullDown.setLastCol(startCol + 27);
|
||||
pullDown.setStrings(Stream.iterate(1, x -> x + 1).limit(10).map(String::valueOf).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
@@ -1555,7 +1577,22 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
contrastDevExcels.forEach(contrastDevExcel -> {
|
||||
List<PqMonitor> monitorList = pqMonitorService.listPqMonitorByDevIds(Collections.singletonList(contrastDevExcel.getId()));
|
||||
pqMonitorService.visualizeMonitor(monitorList);
|
||||
List<PqMonitorExcel> pqMonitorExcelList = BeanUtil.copyToList(monitorList, PqMonitorExcel.class);
|
||||
List<PqMonitorExcel> pqMonitorExcelList = new ArrayList<>();
|
||||
for (int i = 0; i < monitorList.size(); i++) {
|
||||
PqMonitor pqMonitor = monitorList.get(i);
|
||||
PqMonitorExcel pqMonitorExcel = BeanUtil.copyProperties(pqMonitor, PqMonitorExcel.class);
|
||||
String pt = pqMonitor.getPt();
|
||||
String[] split1 = pt.split(String.valueOf(StrUtil.C_COLON));
|
||||
pqMonitorExcel.setPt1(split1[0]);
|
||||
pqMonitorExcel.setPt2(split1[1]);
|
||||
|
||||
String ct = pqMonitor.getCt();
|
||||
String[] split2 = ct.split(String.valueOf(StrUtil.C_COLON));
|
||||
pqMonitorExcel.setCt1(split2[0]);
|
||||
pqMonitorExcel.setCt2(split2[1]);
|
||||
|
||||
pqMonitorExcelList.add(pqMonitorExcel);
|
||||
}
|
||||
contrastDevExcel.setPqMonitorExcelList(pqMonitorExcelList);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,10 +154,10 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
this.importData(contrastDevExcelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqStandardDev> listByPlanId(String planId) {
|
||||
return adPlanStandardDevMapper.listByPlanId(Collections.singletonList(planId));
|
||||
}
|
||||
// @Override
|
||||
// public List<PqStandardDev> listByPlanId(String planId) {
|
||||
// return adPlanStandardDevMapper.listByPlanId(Collections.singletonList(planId));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<PreDetection> listStandardDevPreDetection(List<String> ids) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PqIcdPathController extends BaseController {
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated PqIcdPathParam param) {
|
||||
public HttpResult<Boolean> add(PqIcdPathParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PqIcdPathController extends BaseController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
|
||||
public HttpResult<Boolean> update(PqIcdPathParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.icd.pojo.enums;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-11-11
|
||||
*/
|
||||
public enum IcdResponseEnum {
|
||||
FILE_NOT_NULL("A018001", "映射文件不能为空"),
|
||||
FILE_TYPE_ERROR("A018002", "映射文件类型错误"),
|
||||
FILE_SIZE_ERROR("A018003", "映射文件大小超出限制");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
IcdResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
@@ -32,6 +33,9 @@ public class PqIcdPathParam {
|
||||
@ApiModelProperty(value = "角型接线时是否使用相别的指标来进行检测,0表示否,1表示是", required = true)
|
||||
private Integer usePhaseIndex;
|
||||
|
||||
@ApiModelProperty(value = "映射文件", required = true)
|
||||
private MultipartFile mappingFile;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.icd.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
@@ -46,5 +47,18 @@ public class PqIcdPath extends BaseEntity implements Serializable {
|
||||
* 角型接线时是否使用相别的指标来进行检测,0表示否,1表示是
|
||||
*/
|
||||
private Integer usePhaseIndex;
|
||||
|
||||
/**
|
||||
* 映射文件路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private FileVO mappingFile;
|
||||
|
||||
@Data
|
||||
public static class FileVO{
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.icd.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -7,17 +8,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||
import com.njcn.gather.icd.pojo.enums.IcdResponseEnum;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -41,6 +51,13 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
||||
.orderByDesc(PqIcdPath::getCreateTime);
|
||||
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
page.getRecords().forEach(pqIcdPath -> {
|
||||
PqIcdPath.FileVO fileVO = new PqIcdPath.FileVO();
|
||||
fileVO.setUrl(commInstallPath + "\\DeviceControl\\Config\\" + pqIcdPath.getName() + ".txt");
|
||||
fileVO.setName(pqIcdPath.getName() + ".txt");
|
||||
pqIcdPath.setMappingFile(fileVO);
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -52,9 +69,81 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
System.out.println("commInstallPath = " + commInstallPath);
|
||||
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||
MultipartFile mappingFile = param.getMappingFile();
|
||||
|
||||
System.out.println("mappingFile = " + ObjectUtil.isNotNull(mappingFile) + " " + !mappingFile.isEmpty());
|
||||
if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||
String mappingFilename = mappingFile.getOriginalFilename();
|
||||
|
||||
if (!mappingFilename.endsWith(".txt")) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||
}
|
||||
if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果文件存在,则先删除
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + mappingFilename;
|
||||
System.out.println("mappingFilePath = " + mappingFilePath);
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
byte[] bytes = mappingFile.getBytes();
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||
bufferedOutputStream.write(bytes);
|
||||
bufferedOutputStream.flush();
|
||||
|
||||
bufferedOutputStream.close();
|
||||
System.out.println("File saved successfully");
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||
}
|
||||
} else {
|
||||
System.out.println("mappingFile is null or empty");
|
||||
throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL);
|
||||
}
|
||||
|
||||
this.executeRestartCmd(commInstallPath);
|
||||
|
||||
return this.save(pqIcdPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行重启通讯服务脚本
|
||||
*
|
||||
* @param commInstallPath
|
||||
*/
|
||||
private void executeRestartCmd(String commInstallPath) {
|
||||
// 以管理员身份运行bat脚本
|
||||
String batFilePath = commInstallPath + "\\重启所有服务.bat";
|
||||
try {
|
||||
Runtime.getRuntime().exec(batFilePath);
|
||||
} catch (IOException e) {
|
||||
log.error("重启通讯服务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCommInstallPath() {
|
||||
String workDir = System.getProperty("user.dir");
|
||||
// String workDir = "D:\\program\\CN_Gather";
|
||||
// 获取映射文件存放文件夹
|
||||
String dirPath = workDir + "\\9100";
|
||||
int index = workDir.indexOf("\\resources\\extraResources\\java");
|
||||
if (index != -1) {
|
||||
dirPath = workDir.substring(0, workDir.indexOf("\\resources\\extraResources\\java")) + "\\9100";
|
||||
}
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
@@ -62,12 +151,60 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||
MultipartFile mappingFile = param.getMappingFile();
|
||||
if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||
String mappingFilename = mappingFile.getOriginalFilename();
|
||||
|
||||
if (!mappingFilename.endsWith(".txt")) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||
}
|
||||
if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果文件存在,则先删除
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + mappingFilename;
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
byte[] bytes = mappingFile.getBytes();
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||
bufferedOutputStream.write(bytes);
|
||||
bufferedOutputStream.flush();
|
||||
|
||||
bufferedOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
this.executeRestartCmd(commInstallPath);
|
||||
|
||||
return this.updateById(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteIcd(List<String> ids) {
|
||||
List<PqIcdPath> pqIcdPaths = this.listByIds(ids);
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
pqIcdPaths.forEach(pqIcdPath -> {
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + pqIcdPath.getName() + ".txt";
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
});
|
||||
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.njcn.gather.monitor.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,5 +35,21 @@ public interface PqMonitorMapper extends MPJBaseMapper<PqMonitor> {
|
||||
PqMonitor getByDevIdAndNum(@Param("devId") String devId, @Param("num") Integer num);
|
||||
|
||||
List<PqMonitor> listByDevIds(@Param("devIds") List<String> devIds);
|
||||
|
||||
void updateDeviceCheckState(@Param("devId")String devId, @Param("value") Integer value);
|
||||
|
||||
void updateDeviceCheckResult(@Param("devId")String devId, @Param("value") Integer value);
|
||||
|
||||
void updateDeviceReportRState(@Param("devId")String devId, @Param("value") Integer value);
|
||||
|
||||
AdPlan getPlanByDevId(@Param("devId") String devId);
|
||||
|
||||
List<PqDevSub> listDevSubByPlanId(@Param("planId") String planId);
|
||||
|
||||
void updatePlanCheckState(@Param("planId") String planId, @Param("value") Integer value);
|
||||
|
||||
void updatePlanCheckResult(@Param("planId") String planId, @Param("value") Integer value);
|
||||
|
||||
void updatePlanReportRState(@Param("planId") String planId, @Param("value") Integer value);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.monitor.mapper.PqMonitorMapper">
|
||||
|
||||
|
||||
<select id="selectMonitorInfo"
|
||||
resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
SELECT CONCAT(pq_dev.IP, '_', Num) as lineId,
|
||||
@@ -41,5 +42,55 @@
|
||||
</foreach>
|
||||
order by Num
|
||||
</select>
|
||||
|
||||
<update id="updateDeviceCheckState">
|
||||
update pq_dev_sub
|
||||
set Check_State = #{value}
|
||||
where dev_Id = #{devId}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceCheckResult">
|
||||
update pq_dev_sub
|
||||
set Check_Result = #{value}
|
||||
where dev_Id = #{devId}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceReportRState">
|
||||
update pq_dev_sub
|
||||
set Report_State = #{value}
|
||||
where dev_Id = #{devId}
|
||||
</update>
|
||||
|
||||
<select id="getPlanByDevId" resultType="com.njcn.gather.plan.pojo.po.AdPlan">
|
||||
select *
|
||||
from ad_plan
|
||||
inner join pq_dev on ad_plan.id = pq_dev.Plan_Id
|
||||
where pq_dev.Id = #{devId}
|
||||
</select>
|
||||
|
||||
<select id="listDevSubByPlanId" resultType="com.njcn.gather.device.pojo.po.PqDevSub">
|
||||
select *
|
||||
from pq_dev_sub
|
||||
inner join pq_dev on pq_dev_sub.dev_Id = pq_dev.Id
|
||||
where pq_dev.Plan_Id = #{planId}
|
||||
</select>
|
||||
|
||||
<update id="updatePlanCheckState">
|
||||
update ad_plan
|
||||
set Test_State = #{value}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanCheckResult">
|
||||
update ad_plan
|
||||
set Result = #{value}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanReportRState">
|
||||
update ad_plan
|
||||
set Report_State = #{value}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class PqMonitorExcel {
|
||||
|
||||
@Excel(name = "谐波系统监测点ID*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
|
||||
@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;
|
||||
|
||||
@@ -30,19 +30,27 @@ public class PqMonitorExcel {
|
||||
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
|
||||
private Integer num;
|
||||
|
||||
@Excel(name = "PT变比(pt1:pt2)*", width = 20, orderNum = "5")
|
||||
@Excel(name = "PT一次变比*", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt;
|
||||
private String pt1;
|
||||
|
||||
@Excel(name = "CT变比(ct1:ct2)*", width = 20, orderNum = "6")
|
||||
@Excel(name = "PT二次变比*", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt2;
|
||||
|
||||
@Excel(name = "CT一次变比*", width = 20, orderNum = "7")
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct;
|
||||
private String ct1;
|
||||
|
||||
@Excel(name = "接线方式*", width = 20, orderNum = "7")
|
||||
@Excel(name = "CT二次变比*", width = 20, orderNum = "8")
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct2;
|
||||
|
||||
@Excel(name = "接线方式*", width = 20, orderNum = "9")
|
||||
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
|
||||
private String connection;
|
||||
|
||||
@Excel(name = "统计间隔*", width = 10, orderNum = "8")
|
||||
@Excel(name = "统计间隔*", width = 20, orderNum = "10")
|
||||
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
|
||||
private Integer statInterval;
|
||||
}
|
||||
|
||||
@@ -118,4 +118,11 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
* @return
|
||||
*/
|
||||
boolean removeByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 根据被检设备id和监测点编号获取监测点信息
|
||||
* @param id 被检设备id
|
||||
* @param monitorNum 监测点编号
|
||||
*/
|
||||
PqMonitor getByDevAndNum(String id, int monitorNum);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,15 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
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.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.storage.service.impl.DetectionDataServiceImpl;
|
||||
@@ -26,6 +30,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -62,11 +67,108 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
@Transactional
|
||||
public boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList) {
|
||||
// 先删除原有数据
|
||||
this.deletePqMonitorByDevId(devId);
|
||||
// 再添加新数据
|
||||
// this.deletePqMonitorByDevId(devId);
|
||||
|
||||
// 添加新数据
|
||||
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(paramList, PqMonitor.class);
|
||||
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
|
||||
return this.saveBatch(pqMonitorList);
|
||||
|
||||
List<PqMonitor> existedMonitorList = this.listPqMonitorByDevIds(Collections.singletonList(devId));
|
||||
|
||||
Map<Integer, List<PqMonitor>> map = pqMonitorList.stream().collect(Collectors.groupingBy(PqMonitor::getNum));
|
||||
|
||||
List<PqMonitor> newMonitorList = new ArrayList<>();
|
||||
map.forEach((num, monitorList) -> {
|
||||
PqMonitor pqMonitor = existedMonitorList.stream().filter(monitor -> monitor.getNum() == num).findFirst().orElse(null);
|
||||
|
||||
if (ObjectUtil.isNotNull(pqMonitor)) {
|
||||
BeanUtil.copyProperties(monitorList.get(0), pqMonitor, "id", "realtimeResult", "statisticsResult", "recordedResult", "realtimeNum", "statisticsNum", "recordedNum", "resultType", "qualifiedNum");
|
||||
newMonitorList.add(pqMonitor);
|
||||
} else {
|
||||
newMonitorList.addAll(monitorList);
|
||||
}
|
||||
});
|
||||
|
||||
// 同步更新设备的状态
|
||||
List<PqMonitor> enableCheckMonitorList = newMonitorList.stream().filter(pqMonitor -> pqMonitor.getCheckFlag() == 1).collect(Collectors.toList());
|
||||
List<PqMonitor> checkedMonitorList = enableCheckMonitorList.stream().filter(pqMonitor -> ObjectUtil.isNotNull(pqMonitor.getResultType())).collect(Collectors.toList());
|
||||
|
||||
if (enableCheckMonitorList.size() == checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
||||
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.CHECKED.getValue());
|
||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||
}
|
||||
if (enableCheckMonitorList.size() > checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
||||
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.CHECKING.getValue());
|
||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||
}
|
||||
if (enableCheckMonitorList.size() > 0 && checkedMonitorList.size() == 0) {
|
||||
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<Integer> monitorResultList = checkedMonitorList.stream().map(pqMonitor -> {
|
||||
String resultType = pqMonitor.getResultType();
|
||||
DataSourceEnum dataSourceEnum = DataSourceEnum.ofByValue(resultType);
|
||||
switch (dataSourceEnum) {
|
||||
case REAL_DATA:
|
||||
return pqMonitor.getRealtimeResult();
|
||||
case WAVE_DATA:
|
||||
return pqMonitor.getRecordedResult();
|
||||
case MINUTE_STATISTICS_MAX:
|
||||
case MINUTE_STATISTICS_MIN:
|
||||
case MINUTE_STATISTICS_AVG:
|
||||
case MINUTE_STATISTICS_CP95:
|
||||
return pqMonitor.getStatisticsResult();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
long qualifiedCount = monitorResultList.stream().filter(result -> result != null && result == 1).count();
|
||||
if (qualifiedCount == monitorResultList.size() && monitorResultList.size() > 0) {
|
||||
this.baseMapper.updateDeviceCheckResult(devId, CheckResultEnum.ACCORD.getValue());
|
||||
} else if (monitorResultList.size() > 0) {
|
||||
this.baseMapper.updateDeviceCheckResult(devId, CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else {
|
||||
this.baseMapper.updateDeviceCheckResult(devId, CheckResultEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
// 同步更新计划的状态
|
||||
AdPlan plan = this.baseMapper.getPlanByDevId(devId);
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
|
||||
|
||||
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
||||
|
||||
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
||||
List<PqDevSub> checkingDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKING.getValue()).collect(Collectors.toList());
|
||||
if (checkedDevSubList.size() == devSubList.size() && devSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
||||
} else if (checkedDevSubList.size() > 0 || checkingDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
||||
if (accordDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.ACCORD.getValue());
|
||||
} else if (accordDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<PqDevSub> generatedDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getReportState() == DevReportStateEnum.GENERATED.getValue()).collect(Collectors.toList());
|
||||
if (generatedDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getValue());
|
||||
} else if (generatedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
}
|
||||
}
|
||||
return this.saveOrUpdateBatch(newMonitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,10 +265,19 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
} else {
|
||||
newWaveNum.set(waveNum);
|
||||
newMonitorResult = waveNumResultMap.get(waveNum);
|
||||
if (newMonitorResult == 2) {
|
||||
newMonitorResult = CheckResultEnum.NOT_ACCORD.getValue();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newMonitorResult = detectionDataDealService.getMonitorResult(monitorId, adTypes, dataSourceEnum.getValue(), num, null, code);
|
||||
if (newMonitorResult == 2) {
|
||||
newMonitorResult = CheckResultEnum.NOT_ACCORD.getValue();
|
||||
}
|
||||
if (newMonitorResult == 1) {
|
||||
newMonitorResult = CheckResultEnum.ACCORD.getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -188,7 +299,18 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(oldMonitorResult)) {
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(newMonitorResult)) {
|
||||
qualifiedNum += 1;
|
||||
String oldNum = "";
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(resultType)) {
|
||||
oldNum = monitor.getRealtimeNum();
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(resultType)) {
|
||||
oldNum = monitor.getRecordedNum();
|
||||
} else {
|
||||
oldNum = monitor.getStatisticsNum();
|
||||
}
|
||||
String[] split1 = oldNum.split(CnSocketUtil.SPLIT_TAG);
|
||||
if (!split1[0].equals(num.toString())) {
|
||||
qualifiedNum += 1;
|
||||
}
|
||||
updateFlag = true;
|
||||
}
|
||||
} else {
|
||||
@@ -269,11 +391,38 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
String resultType = monitor.getResultType();
|
||||
if (StrUtil.isNotBlank(resultType)) {
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(resultType)) {
|
||||
allResultFlags.add(monitor.getRealtimeResult());
|
||||
//allResultFlags.add(monitor.getRealtimeResult());
|
||||
if (monitor.getRealtimeResult() == 0) {
|
||||
allResultFlags.add(2);
|
||||
}
|
||||
if (monitor.getRealtimeResult() == 1) {
|
||||
allResultFlags.add(1);
|
||||
}
|
||||
if (monitor.getRealtimeResult() == 4) {
|
||||
allResultFlags.add(4);
|
||||
}
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(resultType)) {
|
||||
allResultFlags.add(monitor.getRecordedResult());
|
||||
//allResultFlags.add(monitor.getRecordedResult());
|
||||
if (monitor.getRecordedResult() == 0) {
|
||||
allResultFlags.add(2);
|
||||
}
|
||||
if (monitor.getRecordedResult() == 1) {
|
||||
allResultFlags.add(1);
|
||||
}
|
||||
if (monitor.getRecordedResult() == 4) {
|
||||
allResultFlags.add(4);
|
||||
}
|
||||
} else {
|
||||
allResultFlags.add(monitor.getStatisticsResult());
|
||||
//allResultFlags.add(monitor.getStatisticsResult());
|
||||
if (monitor.getStatisticsResult() == 0) {
|
||||
allResultFlags.add(2);
|
||||
}
|
||||
if (monitor.getStatisticsResult() == 1) {
|
||||
allResultFlags.add(1);
|
||||
}
|
||||
if (monitor.getStatisticsResult() == 4) {
|
||||
allResultFlags.add(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,4 +436,16 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
return this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqMonitor getByDevAndNum(String devId, int monitorNum) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId)
|
||||
.eq("pq_monitor.Num", monitorNum);
|
||||
List<PqMonitor> pqMonitors = this.list(wrapper);
|
||||
if (CollUtil.isNotEmpty(pqMonitors)) {
|
||||
return pqMonitors.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getBigTestItem")
|
||||
@ApiOperation("获取检测大项数据")
|
||||
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
|
||||
@ApiImplicitParam(name = "checkParam", value = "检测计划id", required = true)
|
||||
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
|
||||
String methodDescribe = getMethodDescribe("getBigTestItem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
|
||||
@@ -191,7 +191,7 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/analyse")
|
||||
@ApiOperation("检测数据分析")
|
||||
@ApiImplicitParam(name = "planId", value = "检测计划id", required = true)
|
||||
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
|
||||
public void analyse(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("analyse");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
@@ -201,7 +201,7 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
@@ -241,7 +241,7 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listDevByPlanId")
|
||||
@ApiOperation("根据计划id分页查询被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqDevVO>> listDevByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listDevByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
@@ -554,6 +554,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
child.put("pid", adPlan.getFatherPlanId());
|
||||
child.put("name", adPlan.getName());
|
||||
child.put("timeCheck", adPlan.getTimeCheck());
|
||||
child.put("dataRule", adPlan.getDataRule());
|
||||
|
||||
List<PqStandardDev> pqStandardDevs = adPlanStandardDevMapper.listByPlanId(Collections.singletonList(adPlan.getId()));
|
||||
List<String> devTypeIdList = pqStandardDevs.stream().map(PqStandardDev::getDevType).collect(Collectors.toList());
|
||||
@@ -1554,8 +1555,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
// 检测脚本
|
||||
List<Map<String, Object>> maps1 = pqScriptService.listAllPqScript(null);
|
||||
List<String> scriptNameList = maps1.stream().map(m -> (String) m.get("name")).collect(Collectors.toList());
|
||||
List<PqScript> pqScriptList = pqScriptService.listAllPqScript(null);
|
||||
List<String> scriptNameList = pqScriptList.stream().map(m -> m.getName()).collect(Collectors.toList());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(3);
|
||||
pullDown.setLastCol(3);
|
||||
@@ -1721,8 +1722,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
String zipFileName = URLEncoder.encode(subPlan.getName() + ".zip", "UTF-8");
|
||||
File zipFile = FileUtil.file(tempDir, zipFileName);
|
||||
|
||||
// 先将json文件添加到zip中
|
||||
ZipUtil.zip(jsonFile.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 先将json文件添加到zip中(使用UTF-8编码)
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, jsonFile);
|
||||
|
||||
|
||||
// 创建一个临时目录存放两个文件
|
||||
@@ -1744,8 +1745,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
|
||||
// 重新创建zip文件,包含所有文件
|
||||
ZipUtil.zip(tempZipDir.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 重新创建zip文件,包含所有文件,使用UTF-8编码
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, FileUtil.file(tempZipDir));
|
||||
|
||||
// 删除临时目录
|
||||
FileUtil.del(tempZipDir);
|
||||
@@ -1779,9 +1780,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
File zipFile = FileUtil.file(tempDir, file.getOriginalFilename());
|
||||
file.transferTo(zipFile);
|
||||
|
||||
// 解压zip文件
|
||||
// 解压zip文件,使用UTF-8编码
|
||||
File unzipDir = FileUtil.mkdir(FileUtil.file(tempDir, "unzip"));
|
||||
ZipUtil.unzip(zipFile.getAbsolutePath(), unzipDir.getAbsolutePath());
|
||||
ZipUtil.unzip(zipFile, unzipDir, CharsetUtil.CHARSET_UTF_8);
|
||||
|
||||
// 查找解压目录中的json文件
|
||||
File[] files = unzipDir.listFiles();
|
||||
@@ -2099,8 +2100,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
}
|
||||
|
||||
// 重新创建zip文件,包含所有文件
|
||||
ZipUtil.zip(tempZipDir.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 重新创建zip文件,包含所有文件,使用UTF-8编码
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, FileUtil.file(tempZipDir));
|
||||
|
||||
// 删除临时目录
|
||||
FileUtil.del(tempZipDir);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
* @data 2025/1/9 14:02
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "报表管理")
|
||||
@Api(tags = "报告管理")
|
||||
@RestController
|
||||
@RequestMapping("/report")
|
||||
@RequiredArgsConstructor
|
||||
@@ -46,7 +46,7 @@ public class ReportController extends BaseController {
|
||||
*/
|
||||
@OperateInfo
|
||||
@PostMapping("/generateReport")
|
||||
@ApiOperation("生成测试报告")
|
||||
@ApiOperation("生成报告")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Object> generateReport(@RequestBody DevReportParam devReportParam) {
|
||||
String methodDescribe = getMethodDescribe("generateReport");
|
||||
@@ -60,7 +60,7 @@ public class ReportController extends BaseController {
|
||||
*/
|
||||
@OperateInfo
|
||||
@PostMapping("/downloadReport")
|
||||
@ApiOperation("下载测试报告")
|
||||
@ApiOperation("下载报告")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public void downloadReport(@RequestBody DevReportParam devReportParam, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("downloadReport");
|
||||
@@ -91,7 +91,7 @@ public class ReportController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增报告模板")
|
||||
@ApiImplicitParam(name = "param", value = "报告模板参数", required = true)
|
||||
@ApiImplicitParam(name = "reportParam", value = "报告模板参数", required = true)
|
||||
public HttpResult<Boolean> add(ReportParam reportParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, reportParam);
|
||||
@@ -106,7 +106,7 @@ public class ReportController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新报告模板")
|
||||
@ApiImplicitParam(name = "param", value = "报告模板参数", required = true)
|
||||
@ApiImplicitParam(name = "reportParam", value = "报告模板参数", required = true)
|
||||
public HttpResult<Boolean> update(ReportParam.UpdateParam reportParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改参数为:{}", methodDescribe, reportParam);
|
||||
@@ -136,7 +136,6 @@ public class ReportController extends BaseController {
|
||||
@OperateInfo
|
||||
@GetMapping("/listAllName")
|
||||
@ApiOperation("查询所有报告模板名称")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<List<String>> listAllName() {
|
||||
String methodDescribe = getMethodDescribe("listAllName");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
||||
@@ -145,7 +144,7 @@ public class ReportController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
@ApiImplicitParam(name = "ids", value = "设备id", required = true)
|
||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
|
||||
@@ -39,7 +39,10 @@ public enum BaseReportKeyEnum {
|
||||
CREATE_DATE("createDate","生产日期"),
|
||||
TEMPERATURE("temp","温度"),
|
||||
HUMIDITY("hum","相对湿度"),
|
||||
DELEGATE("delegate","委托方");
|
||||
DELEGATE("delegate","委托方"),
|
||||
CREATEDATE("createDate","出厂日期"),
|
||||
HW_VERSION("hardwareVersion","硬件版本"),
|
||||
SW_VERSION("softwareVersion","软件版本");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.IPqDevSubService;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
@@ -59,6 +61,7 @@ import com.njcn.gather.report.service.IPqReportService;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||
@@ -86,6 +89,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
@@ -113,6 +117,7 @@ import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -162,6 +167,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
@Value("${qr.gcDev.path}")
|
||||
private String gcDevPath;
|
||||
|
||||
@Value("${report.dateFormat}")
|
||||
private String dateFormat;
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
private final PqDevMapper pqDevMapper;
|
||||
@@ -179,6 +186,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private final ISysUserService sysUserService;
|
||||
private final IPqErrSysService pqErrSysService;
|
||||
private final IAdPlanTestConfigService adPlanTestConfigService;
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
|
||||
@Resource
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
@@ -307,7 +315,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) {
|
||||
MultipartFile baseFile = reportParam.getBaseFile();
|
||||
MultipartFile detailFile = reportParam.getDetailFile();
|
||||
String newDir = templatePath + File.separator + reportParam.getName() + File.separator + reportParam.getVersion() + File.separator;
|
||||
String relativePath = reportParam.getName() + File.separator + reportParam.getVersion() + File.separator;
|
||||
String newDir = templatePath + File.separator + relativePath;
|
||||
|
||||
long FILE_SIZE_LIMIT = 5 * 1024 * 1024;
|
||||
if (isAdd) {
|
||||
@@ -326,13 +335,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
pqReport.setBasePath(newDir + baseOriginalFilename);
|
||||
pqReport.setDetailPath(newDir + detailOriginalFilename);
|
||||
pqReport.setBasePath(relativePath + baseOriginalFilename);
|
||||
pqReport.setDetailPath(relativePath + detailOriginalFilename);
|
||||
|
||||
this.createDirectory(newDir);
|
||||
this.clearDirectory(newDir);
|
||||
this.uploadFile(baseFile, pqReport.getBasePath());
|
||||
this.uploadFile(detailFile, pqReport.getDetailPath());
|
||||
this.uploadFile(baseFile, newDir + baseOriginalFilename);
|
||||
this.uploadFile(detailFile, newDir + detailOriginalFilename);
|
||||
} else {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL);
|
||||
}
|
||||
@@ -380,34 +389,34 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
//若修改了文件名称、版本号,则需要重命名文件
|
||||
this.createDirectory(newDir);
|
||||
if (!oldDir.equals(newDir)) {
|
||||
if (!oldDir.equals(relativePath)) {
|
||||
// 文件夹重命名
|
||||
String oldBasePathStr = oldPqReport.getBasePath();
|
||||
String baseName = oldBasePathStr.substring(oldBasePathStr.lastIndexOf(File.separator) + 1);
|
||||
Path oldBasePath = Paths.get(oldBasePathStr);
|
||||
Path oldBasePath = Paths.get(templatePath + File.separator + oldBasePathStr);
|
||||
Path newBasePath = Paths.get(newDir + baseName);
|
||||
pqReport.setBasePath(newDir + baseName);
|
||||
pqReport.setBasePath(relativePath + baseName);
|
||||
|
||||
String oldDetailPathStr = oldPqReport.getDetailPath();
|
||||
String detailName = oldDetailPathStr.substring(oldDetailPathStr.lastIndexOf(File.separator) + 1);
|
||||
Path oldDetailPath = Paths.get(oldDetailPathStr);
|
||||
Path oldDetailPath = Paths.get(templatePath + File.separator + oldDetailPathStr);
|
||||
Path newDetailPath = Paths.get(newDir + detailName);
|
||||
pqReport.setDetailPath(newDir + detailName);
|
||||
pqReport.setDetailPath(relativePath + detailName);
|
||||
|
||||
try {
|
||||
// windows下文件夹名称不区分大小写
|
||||
if (!oldDir.equalsIgnoreCase(newDir)) {
|
||||
if (!oldDir.equalsIgnoreCase(relativePath)) {
|
||||
this.clearDirectory(newDir);
|
||||
Files.move(oldBasePath, newBasePath);
|
||||
Files.move(oldDetailPath, newDetailPath);
|
||||
if (!oldPqReport.getName().equals(reportParam.getName()) && !this.existSameName(pqReport.getId(), oldPqReport.getName())) {
|
||||
this.recursionDeleteDirectory(templatePath + File.separator + oldPqReport.getName());
|
||||
} else {
|
||||
Paths.get(oldDir).toFile().delete();
|
||||
Paths.get(templatePath + oldDir).toFile().delete();
|
||||
}
|
||||
} else {
|
||||
// 文件夹重命名
|
||||
Paths.get(oldDir).toFile().renameTo(Paths.get(newDir).toFile());
|
||||
Paths.get(templatePath + oldDir).toFile().renameTo(Paths.get(newDir).toFile());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_RENAME_FAILED);
|
||||
@@ -415,16 +424,16 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
}
|
||||
|
||||
if (!baseFileOriginalFilename.isEmpty()) {
|
||||
pqReport.setBasePath(newDir + baseFileOriginalFilename);
|
||||
Paths.get(oldPqReport.getBasePath()).toFile().delete();
|
||||
pqReport.setBasePath(relativePath + baseFileOriginalFilename);
|
||||
Paths.get(templatePath + File.separator + oldPqReport.getBasePath()).toFile().delete();
|
||||
Paths.get(newDir + oldPqReport.getBasePath().substring(oldPqReport.getBasePath().lastIndexOf(File.separator) + 1)).toFile().delete();
|
||||
this.uploadFile(baseFile, pqReport.getBasePath());
|
||||
this.uploadFile(baseFile, newDir + baseFileOriginalFilename);
|
||||
}
|
||||
if (!detailFileOriginalFilename.isEmpty()) {
|
||||
pqReport.setDetailPath(newDir + detailFileOriginalFilename);
|
||||
Paths.get(oldPqReport.getDetailPath()).toFile().delete();
|
||||
pqReport.setDetailPath(relativePath + detailFileOriginalFilename);
|
||||
Paths.get(templatePath + File.separator + oldPqReport.getDetailPath()).toFile().delete();
|
||||
Paths.get(newDir + oldPqReport.getDetailPath().substring(oldPqReport.getDetailPath().lastIndexOf(File.separator) + 1)).toFile().delete();
|
||||
this.uploadFile(detailFile, pqReport.getDetailPath());
|
||||
this.uploadFile(detailFile, newDir + detailFileOriginalFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -786,53 +795,63 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
if (Objects.isNull(pqDevVO)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_NOT_EXIST);
|
||||
}
|
||||
devReportParam.setDevId(devId);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_TYPE_NOT_EXIST);
|
||||
}
|
||||
PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getReportTemplateId()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(report.getBasePath());
|
||||
Path detailPath = Paths.get(report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
// 获取文档基础部分,并替换占位符
|
||||
Map<String, String> baseModelDataMap = dealBaseModelContrastData(plan, pqDevVO, devType);
|
||||
InputStream wordFinishInputStream = wordReportService.replacePlaceholders(baseInputStream, baseModelDataMap);
|
||||
WordprocessingMLPackage baseModelDocument = WordprocessingMLPackage.load(wordFinishInputStream);
|
||||
MainDocumentPart baseDocumentPart = baseModelDocument.getMainDocumentPart();
|
||||
if (CheckStateEnum.CHECKED.getValue().compareTo(pqDevVO.getCheckState()) <= 0) {
|
||||
devReportParam.setDevId(devId);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_TYPE_NOT_EXIST);
|
||||
}
|
||||
PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getReportTemplateId()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(templatePath + File.separator + report.getBasePath());
|
||||
Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
// 获取文档基础部分,并替换占位符
|
||||
Map<String, String> baseModelDataMap = dealBaseModelContrastData(plan, pqDevVO, devType);
|
||||
InputStream wordFinishInputStream = wordReportService.replacePlaceholders(baseInputStream, baseModelDataMap);
|
||||
WordprocessingMLPackage baseModelDocument = WordprocessingMLPackage.load(wordFinishInputStream);
|
||||
MainDocumentPart baseDocumentPart = baseModelDocument.getMainDocumentPart();
|
||||
|
||||
// 获取数据模版页内容,根据脚本动态组装数据页内容
|
||||
MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart();
|
||||
dealDataModelScatteredByBookmarkByPlanContrast(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// 保存新的文档
|
||||
String dirPath = reportPath.concat(File.separator).concat(plan.getName());
|
||||
// 确保目录存在
|
||||
ensureDirectoryExists(dirPath);
|
||||
// 构建文件名:cityName_gdName_subName_name.docx
|
||||
String fileName = String.format("%s_%s_%s_%s.docx",
|
||||
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
|
||||
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
|
||||
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
|
||||
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
|
||||
Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument);
|
||||
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName)));
|
||||
this.updateDevAndPlanState(devId, devReportParam.getPlanId());
|
||||
} catch (NoSuchFileException e) {
|
||||
String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件";
|
||||
log.error("报告模板文件不存在 - 文件路径: {}", filePath, e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
log.error("报告文件读写异常", e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||
// 获取数据模版页内容,根据脚本动态组装数据页内容
|
||||
MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart();
|
||||
dealDataModelScatteredByBookmarkByPlanContrast(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// 保存新的文档
|
||||
String dirPath = reportPath.concat(File.separator).concat(plan.getName());
|
||||
// 确保目录存在
|
||||
ensureDirectoryExists(dirPath);
|
||||
// 构建文件名:cityName_gdName_subName_name.docx
|
||||
String fileName = String.format("%s_%s_%s_%s.docx",
|
||||
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
|
||||
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
|
||||
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
|
||||
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
|
||||
// 判断是否需要在报告上输出水印
|
||||
String leader = baseModelDataMap.get(BaseReportKeyEnum.AUDIT_BY.getKey());
|
||||
String loginName = RequestUtil.getLoginNameByToken();
|
||||
SysUser user = sysUserService.getUserByLoginName(loginName);
|
||||
if (!leader.equals(user.getName())) {
|
||||
log.info("当前用户不是审核人,添加非正式水印");
|
||||
Docx4jUtil.addWatermarkToDocument(baseModelDocument, "非正式");
|
||||
}
|
||||
Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument);
|
||||
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName)));
|
||||
this.updateDevAndPlanState(devId, devReportParam.getPlanId());
|
||||
} catch (NoSuchFileException e) {
|
||||
String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件";
|
||||
log.error("报告模板文件不存在 - 文件路径: {}", filePath, e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
log.error("报告文件读写异常", e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -864,8 +883,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(report.getBasePath());
|
||||
Path detailPath = Paths.get(report.getDetailPath());
|
||||
Path basePath = Paths.get(templatePath + File.separator + report.getBasePath());
|
||||
Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
@@ -1154,10 +1173,11 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
Integer monitorNum = next.getKey();
|
||||
// 线路下的指标数据
|
||||
List<ContrastTestResult> contrastTestResults = next.getValue();
|
||||
PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum);
|
||||
// 插入回路号前,先换个页
|
||||
todoInsertList.add(Docx4jUtil.createPageBreakParagraph());
|
||||
// 回路标题
|
||||
todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory));
|
||||
todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory, pqDevVO));
|
||||
int scriptIndex = 1;
|
||||
for (ContrastTestResult contrastTestResult : contrastTestResults) {
|
||||
// 比如电压 V
|
||||
@@ -1168,7 +1188,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 根据code获取对应需要填充的内容
|
||||
List<Docx4jUtil.HeadingContent> tempContent = contentMap.get(scriptCode);
|
||||
// 需要区分下谐波类和非谐波类
|
||||
List<Object> tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult);
|
||||
List<Object> tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult, pqMonitor);
|
||||
todoInsertList.addAll(tempList);
|
||||
scriptIndex++;
|
||||
}
|
||||
@@ -1586,18 +1606,37 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
// 获取现有行的样式
|
||||
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
|
||||
|
||||
// 获取现有样式
|
||||
TrPr trPr = existingRow.getTrPr();
|
||||
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
|
||||
TcPr tcPr = element.getValue().getTcPr();
|
||||
TblWidth cellWidth = factory.createTblWidth();
|
||||
cellWidth.setType("dxa");
|
||||
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
|
||||
tcPr.setTcW(cellWidth);
|
||||
// 获取每个单元格的TcPr(保留各单元格独立的边框设置)
|
||||
List<TcPr> tcPrList = new ArrayList<>();
|
||||
RPr templateRPr = null;
|
||||
for (Object cellObj : existingRow.getContent()) {
|
||||
if (cellObj instanceof JAXBElement) {
|
||||
JAXBElement<Tc> cellElement = (JAXBElement<Tc>) cellObj;
|
||||
Tc templateCell = cellElement.getValue();
|
||||
TcPr tcPr = templateCell.getTcPr();
|
||||
// 设置单元格宽度
|
||||
if (tcPr == null) {
|
||||
tcPr = factory.createTcPr();
|
||||
}
|
||||
TblWidth cellWidth = factory.createTblWidth();
|
||||
cellWidth.setType("dxa");
|
||||
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
|
||||
tcPr.setTcW(cellWidth);
|
||||
tcPrList.add(tcPr);
|
||||
// 从第一个单元格获取字体样式
|
||||
if (templateRPr == null && !templateCell.getContent().isEmpty() && templateCell.getContent().get(0) instanceof P) {
|
||||
P templateP = (P) templateCell.getContent().get(0);
|
||||
templateRPr = Docx4jUtil.getTcPrFromParagraph(templateP);
|
||||
}
|
||||
}
|
||||
}
|
||||
tbl.getContent().remove(existingRow);
|
||||
// 迭代增加行,需要填充的表格keys在tableKeys集合中
|
||||
for (Map<String, String> stringStringMap : dataList) {
|
||||
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPr, true);
|
||||
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPrList, templateRPr, true);
|
||||
tbl.getContent().add(newRow);
|
||||
}
|
||||
} else {
|
||||
@@ -1624,7 +1663,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<Object> fillContentInTemplateContrast(List<Docx4jUtil.HeadingContent> tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult) {
|
||||
private List<Object> fillContentInTemplateContrast(List<Docx4jUtil.HeadingContent> tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult, PqMonitor pqMonitor) {
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
Docx4jUtil.HeadingContent headingContent = tempContent.get(0);
|
||||
List<String> tableKeys = Docx4jUtil.getTableFillKeys(tempContent);
|
||||
@@ -1738,9 +1777,47 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 纵向表格暂不考虑
|
||||
}
|
||||
|
||||
// 如果存在特殊说明,在表格后添加一个段落
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) {
|
||||
P specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase());
|
||||
StringBuilder description = new StringBuilder();
|
||||
if (contrastTestResult.getScriptCode().equalsIgnoreCase("I")) {
|
||||
// 获取该通道的额定电流
|
||||
String ct = pqMonitor.getCt();
|
||||
// 理论上ct是 xxx:xxx的格式。比如10:1,100:5
|
||||
if (ct.indexOf(":") > 0) {
|
||||
String[] ctArray = ct.split(":");
|
||||
description.append("注:当前回路额定电流为:").append(ctArray[1]).append("A。");
|
||||
}
|
||||
} else if (contrastTestResult.getScriptCode().equalsIgnoreCase("V")) {
|
||||
// 获取该通道的额定电压
|
||||
String pt = pqMonitor.getPt();
|
||||
// 理论上pt是 xxx:xxx的格式。比如380:380,10000:100
|
||||
if (pt.indexOf(":") > 0) {
|
||||
String[] ptArray = pt.split(":");
|
||||
// 电压需要特殊处理下,处理为相电压值
|
||||
String voltage = ptArray[1];
|
||||
if (voltage.equalsIgnoreCase("100")) {
|
||||
voltage = "57.74";
|
||||
} else if (voltage.equalsIgnoreCase("380")) {
|
||||
voltage = "220";
|
||||
} else {
|
||||
// 其他场景下就除以根号3
|
||||
double result = Double.parseDouble(voltage) / Math.sqrt(3);
|
||||
voltage = doubleRound(2, result);
|
||||
}
|
||||
description.append("注:当前回路额定电流为:").append(voltage).append("V。");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果存在特殊说明,在表格后添加一个段落 如果有电压和电流需要把额定电压和电流标注进来 pqMonitor
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase()) || StrUtil.isNotBlank(description.toString())) {
|
||||
P specialCaseP;
|
||||
if (StrUtil.isNotBlank(description.toString())) {
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) {
|
||||
description.append(contrastTestResult.getSpecialCase().replace("注:", ""));
|
||||
}
|
||||
specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, description.toString());
|
||||
} else {
|
||||
specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase());
|
||||
}
|
||||
todoInsertList.add(specialCaseP);
|
||||
}
|
||||
}
|
||||
@@ -1948,6 +2025,18 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
baseModelMap.put(BaseReportKeyEnum.DEV_TYPE.getKey(), devType.getName());
|
||||
// 检测员
|
||||
baseModelMap.put(BaseReportKeyEnum.INSPECTOR.getKey(), pqDevVO.getCheckBy() + "");
|
||||
baseModelMap.put(BaseReportKeyEnum.INSPECTOR.getKey(), pqDevVO.getCheckBy() + "");
|
||||
String datePattern = DatePattern.NORM_DATE_PATTERN;
|
||||
if (DatePattern.CHINESE_DATE_PATTERN.equals(dateFormat)) {
|
||||
datePattern = DatePattern.CHINESE_DATE_PATTERN;
|
||||
}
|
||||
|
||||
// 出厂日期
|
||||
baseModelMap.put(BaseReportKeyEnum.CREATEDATE.getKey(), pqDevVO.getCreateDate().format(DateTimeFormatter.ofPattern(datePattern)));
|
||||
// 硬件版本
|
||||
baseModelMap.put(BaseReportKeyEnum.HW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getHardwareVersion()) ? pqDevVO.getHardwareVersion() : StrUtil.EMPTY);
|
||||
// 软件版本
|
||||
baseModelMap.put(BaseReportKeyEnum.SW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getSoftwareVersion()) ? pqDevVO.getSoftwareVersion() : StrUtil.EMPTY);
|
||||
// 调试日期
|
||||
if (pqDevVO.getCheckTime() != null) {
|
||||
baseModelMap.put(BaseReportKeyEnum.TEST_DATE.getKey(), DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
|
||||
@@ -2016,7 +2105,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 委托方
|
||||
String delegate = pqDevVO.getDelegate();
|
||||
if (StrUtil.isNotBlank(delegate)) {
|
||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer());
|
||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getDelegate());
|
||||
if (ObjectUtil.isNotNull(delegateDictData)) {
|
||||
baseModelMap.put(BaseReportKeyEnum.DELEGATE.getKey(), delegateDictData.getName());
|
||||
} else {
|
||||
@@ -2088,7 +2177,19 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private void dealDataModel(List<InputStream> wordFileInputStreams, DevReportParam devReportParam, PqDevVO pqDevVO) throws Exception {
|
||||
Integer devChns = pqDevVO.getDevChns();
|
||||
for (int i = 1; i <= devChns; i++) {
|
||||
ClassPathResource resource = new ClassPathResource("/model/report_table.docx");
|
||||
String path = "/model/report_table.docx";
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (devType.getName().equals("PQ-COM")) {
|
||||
path = "/model/report_table - PQ-COM.docx";
|
||||
}
|
||||
ClassPathResource resource = new ClassPathResource(path);
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||
|
||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||
singleNonHarmParam.setPlanCode(devReportParam.getPlanCode());
|
||||
singleNonHarmParam.setDevId(pqDevVO.getId());
|
||||
singleNonHarmParam.setChannelNo(i);
|
||||
|
||||
// 获取数据
|
||||
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||
// 读取模板文件中的占位符
|
||||
@@ -2106,11 +2207,20 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
List<SimAndDigHarmonicResult> adHarmonicResultList = adHarmonicService.listAllResultData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + i);
|
||||
|
||||
// 填充数据
|
||||
int finalI = i;
|
||||
indexKeysMap.forEach((index, keys) -> {
|
||||
String s1 = keys.stream().findFirst().get();
|
||||
// 谐波类
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(s1) || DetectionCodeEnum.I2_50.getCode().equals(s1) || DetectionCodeEnum.SV_1_49.getCode().equals(s1) || DetectionCodeEnum.SI_1_49.getCode().equals(s1)) {
|
||||
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index);
|
||||
// 查找一下U1
|
||||
double u1 = 57.74;
|
||||
List<SimAndDigHarmonicResult> rawData = adHarmonicService.listAllRawData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + finalI);
|
||||
SimAndDigHarmonicResult adHarmonicResult = rawData.stream().filter(obj -> obj.getAdType().equals(DetectionCodeEnum.V2_50.getCode())).sorted((obj1, obj2) -> obj2.getTimeId().compareTo(obj1.getTimeId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(adHarmonicResult)) {
|
||||
String aValue1 = adHarmonicResult.getAValue1();
|
||||
u1 = Double.parseDouble(aValue1);
|
||||
}
|
||||
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index, u1);
|
||||
} else {
|
||||
// 非谐波类
|
||||
if (DetectionCodeEnum.V_UNBAN.getCode().equals(s1) || DetectionCodeEnum.FREQ.getCode().equals(s1)) {
|
||||
@@ -2178,14 +2288,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
* @param keys key
|
||||
* @param index index
|
||||
*/
|
||||
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
|
||||
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index, double baseValue) {
|
||||
keys.forEach(key -> {
|
||||
List<SimAndDigHarmonicResult> resultList = allHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(resultList)) {
|
||||
SimAndDigHarmonicResult adHarmonicResult = resultList.get(0);
|
||||
if (Objects.nonNull(adHarmonicResult)) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(key) || DetectionCodeEnum.SV_1_49.getCode().equals(key)) {
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, 57.74, 100);
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, baseValue, 100);
|
||||
}
|
||||
if (DetectionCodeEnum.I2_50.getCode().equals(key) || DetectionCodeEnum.SI_1_49.getCode().equals(key)) {
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, 1, 1);
|
||||
@@ -2392,16 +2502,21 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
/**
|
||||
* 创建回路标题到报告中
|
||||
*/
|
||||
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory) {
|
||||
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) {
|
||||
PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum);
|
||||
String monitorInfoName = "";
|
||||
if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) {
|
||||
monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")";
|
||||
}
|
||||
List<Docx4jUtil.HeadingContent> headingContents = contentMap.get(PowerIndexEnum.LINE_TITLE.getKey());
|
||||
// 如果contentMap中有指定内容,创建大纲级别为2的标题
|
||||
if (CollUtil.isNotEmpty(headingContents)) {
|
||||
return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum,
|
||||
return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum + monitorInfoName,
|
||||
"SimSun", 30, true);
|
||||
}
|
||||
// 没有模板配置时,创建默认样式段落
|
||||
P titleParagraph = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum,
|
||||
Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum + monitorInfoName,
|
||||
28, true);
|
||||
return titleParagraph;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/reCalculate")
|
||||
@ApiOperation("重新计算检测结果")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "重新计算参数", required = true)
|
||||
public HttpResult<Object> reCalculate(@RequestBody @Validated ResultParam.ChangeErrorSystemParam param) {
|
||||
String methodDescribe = getMethodDescribe("reCalculate");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
@@ -115,7 +115,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
|
||||
@GetMapping("/deleteTempTable")
|
||||
@ApiOperation("删除临时表")
|
||||
@ApiImplicitParam(name = "param", value = "删除参数", required = true)
|
||||
@ApiImplicitParam(name = "code", value = "计划对应的表后缀code", required = true)
|
||||
public HttpResult<Object> deleteTempTable(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("deleteTempTable");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, code);
|
||||
@@ -127,7 +127,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getContrastFormContent")
|
||||
@ApiOperation("获取比对式检测结果-表单内容")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<FormContentVO> getContrastFormContent(@RequestBody @Validated ResultParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getContrastFormContent");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
@@ -139,7 +139,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getContrastResult")
|
||||
@ApiOperation("获取比对式检测结果")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<ContrastResultVO> getContrastResult(@RequestBody @Validated ResultParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getContrastResult");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
@@ -154,7 +154,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorResult")
|
||||
@ApiOperation("获取监测点的检测结果")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "devId", value = "设备id", required = true)
|
||||
public HttpResult<List<MonitorResultVO>> getMonitorResult(@RequestParam("devId") String devId) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorResult");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, devId);
|
||||
@@ -180,7 +180,7 @@ public class ResultController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateMonitorResult")
|
||||
@ApiOperation("更新监测点的检测结果")
|
||||
@ApiImplicitParam(name = "result", value = "更新内容", required = true)
|
||||
@ApiImplicitParam(name = "resultParams", value = "更新内容", required = true)
|
||||
public HttpResult<Boolean> updateMonitorResult(@RequestBody @Validated MonitorResultVO resultParams) {
|
||||
String methodDescribe = getMethodDescribe("updateMonitorResult");
|
||||
LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, resultParams);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.result.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -74,6 +75,8 @@ public class ResultParam {
|
||||
|
||||
// 模式id
|
||||
private String patternId;
|
||||
|
||||
private String code;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -83,7 +86,7 @@ public class ResultParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty(value = "脚本Id", required = false)
|
||||
@ApiModelProperty(value = "脚本Id")
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty(value = "误差体系Id", required = true)
|
||||
@@ -95,9 +98,16 @@ public class ResultParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_ID_FORMAT_ERROR)
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty(value = "计划对应表后缀", required = true)
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "模式Id", required = true)
|
||||
private String patternId;
|
||||
|
||||
@ApiModelProperty(value = "通道号", required = true)
|
||||
private String chnNum;
|
||||
|
||||
@ApiModelProperty(value = "数据处理原则", required = true)
|
||||
private String dataRuleId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,58 +14,38 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class MonitorResultVO implements Comparable<MonitorResultVO> {
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
@ApiModelProperty(value = "监测点id", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.DEV_MONITOR_ID_NOT_BLANK)
|
||||
private String monitorId;
|
||||
|
||||
/**
|
||||
* 监测点序号
|
||||
*/
|
||||
@ApiModelProperty(value = "监测点序号")
|
||||
private Integer monitorNum;
|
||||
|
||||
/**
|
||||
* 总检测次数
|
||||
*/
|
||||
@ApiModelProperty(value = "总检测次数")
|
||||
private Integer totalNum;
|
||||
|
||||
/**
|
||||
* 合格检测次数
|
||||
*/
|
||||
@ApiModelProperty(value = "合格检测次数")
|
||||
private Integer qualifiedNum;
|
||||
|
||||
/**
|
||||
* 不合格检测次数
|
||||
*/
|
||||
@ApiModelProperty(value = "不合格检测次数")
|
||||
private Integer unQualifiedNum;
|
||||
|
||||
/**
|
||||
* 误差体系名称
|
||||
*/
|
||||
@ApiModelProperty(value = "误差体系名称")
|
||||
private String errorSysName;
|
||||
|
||||
/**
|
||||
* 检测结果
|
||||
*/
|
||||
@ApiModelProperty(value = "检测结果", required = true)
|
||||
@NotNull(message = DetectionValidMessage.DEV_MONITOR_RESULT_NOT_NULL)
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 结论来源
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "结论来源")
|
||||
private String resultOrigin;
|
||||
/**
|
||||
* 哪次
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "使用哪次检测结果", required = true)
|
||||
@NotNull(message = DetectionValidMessage.DEV_MONITOR_RESULT_NUM_NOT_BLANK)
|
||||
private String whichTime;
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
|
||||
|
||||
@ApiModelProperty(value = "数据源类型", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.DEV_MONITOR_RESULT_TYPE_NOT_BLANK)
|
||||
private String resultType;
|
||||
|
||||
@@ -146,11 +146,11 @@ public class ResultServiceImpl implements IResultService {
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
String scriptId = null;
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
scriptId = plan.getScriptId();
|
||||
adPlanService.visualize(Collections.singletonList(plan));
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
}
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
|
||||
|
||||
List<Map<String, String>> chnList = new ArrayList<>();
|
||||
@@ -398,8 +398,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
double cosValue = Math.cos((aDtl1.get(0).getAngle() - aDtl2.get(0).getAngle()) / 180 * Math.PI);
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(cosValue).setScale(6, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
dtlType.setScriptTypeName(ResultUnitEnum.V_RELATIVE.getName() + "=" + v.get(0).getValue().intValue() + unitV
|
||||
+ " " + ResultUnitEnum.I_RELATIVE.getName() + "=" + i.get(0).getValue().intValue() + unitI
|
||||
dtlType.setScriptTypeName(ResultUnitEnum.V_RELATIVE.getName() + "=" + v.get(0).getValue() + unitV
|
||||
+ " " + ResultUnitEnum.I_RELATIVE.getName() + "=" + i.get(0).getValue() + unitI
|
||||
+ " cos(φ)=" + bigDecimal.doubleValue());
|
||||
}
|
||||
break;
|
||||
@@ -415,7 +415,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
unit = ResultUnitEnum.V_ABSOLUTELY.getUnit();
|
||||
}
|
||||
List<PqScriptDtls> v = scriptDtlIndexList.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList());
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + v.get(0).getValue().intValue() + unit);
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + v.get(0).getValue() + unit);
|
||||
break;
|
||||
/**
|
||||
* 电流
|
||||
@@ -429,7 +429,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
unitI = ResultUnitEnum.I_ABSOLUTELY.getUnit();
|
||||
}
|
||||
List<PqScriptDtls> I = scriptDtlIndexList.stream().filter(x -> "CUR".equals(x.getValueType())).collect(Collectors.toList());
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + I.get(0).getValue().intValue() + unitI);
|
||||
dtlType.setScriptTypeName(dictTree.getName() + "=" + I.get(0).getValue() + unitI);
|
||||
break;
|
||||
/**
|
||||
* 谐波电压
|
||||
@@ -449,12 +449,12 @@ public class ResultServiceImpl implements IResultService {
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getHarmNum, LinkedHashMap::new, Collectors.toList()));
|
||||
if (harmNumMap.size() > 1) {
|
||||
//叠加2~50次谐波电压(含有率为GB/T)
|
||||
dtlType.setScriptTypeName("叠加" + harmNumMap.entrySet().iterator().next().getValue().get(0).getHarmNum().intValue() + "~" +
|
||||
new ArrayList<>(harmNumMap.entrySet()).get(harmNumMap.size() - 1).getValue().get(0).getHarmNum().intValue()
|
||||
dtlType.setScriptTypeName("叠加" + harmNumMap.entrySet().iterator().next().getValue().get(0).getHarmNum() + "~" +
|
||||
new ArrayList<>(harmNumMap.entrySet()).get(harmNumMap.size() - 1).getValue().get(0).getHarmNum()
|
||||
+ "次" + dictTree.getName()); // + "(含有率为GB/T)"
|
||||
} else {
|
||||
//叠加5%的2次谐波电压
|
||||
dtlType.setScriptTypeName("叠加" + hv.get(0).getValue().intValue() + ResultUnitEnum.HV.getUnit() + "的" + hv.get(0).getHarmNum().intValue() + "次" + dictTree.getName());
|
||||
dtlType.setScriptTypeName("叠加" + hv.get(0).getValue() + ResultUnitEnum.HV.getUnit() + "的" + hv.get(0).getHarmNum() + "次" + dictTree.getName());
|
||||
}
|
||||
break;
|
||||
/**
|
||||
@@ -488,7 +488,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
dtlType.setScriptTypeName(a.toString());
|
||||
} else {
|
||||
//叠加5%的2次谐波电压
|
||||
dtlType.setScriptTypeName("叠加" + harmInNumList.get(0).getValue().intValue() + ResultUnitEnum.HV.getUnit() + "的" + harmInNumList.get(0).getHarmNum() + "次" + dictTree.getName());
|
||||
dtlType.setScriptTypeName("叠加" + harmInNumList.get(0).getValue() + ResultUnitEnum.HV.getUnit() + "的" + harmInNumList.get(0).getHarmNum() + "次" + dictTree.getName());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -983,10 +983,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
DictData dictData = dictDataService.getDictDataById(param.getPatternId());
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
this.createTempResultTable(param.getCode() + "_temp", true);
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId());
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId(), false, param.getDataRuleId());
|
||||
} else {
|
||||
this.createTempResultTable(param.getCode() + "_temp", false);
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId());
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId(), param.getDataRuleId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,9 +1000,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
public void reCalculate(ResultParam.ChangeErrorSystemParam param) {
|
||||
DictData dictData = dictDataService.getDictDataById(param.getPatternId());
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode(), param.getErrorSysId(), param.getDeviceId(), true, param.getDataRuleId());
|
||||
} else {
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId(), param.getDataRuleId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,8 +1533,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
PqDev dev = pqDevService.getById(queryParam.getDeviceId());
|
||||
DictData dictData = dictDataService.getById(plan.getDataRule());
|
||||
formContentVO.setDataRule(dictData.getName());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(dev.getName());
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
|
||||
@@ -1554,10 +1553,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
List<ContrastBaseResult> allResultList = new ArrayList<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, false, queryParam.getDeviceId(), adTypeList);
|
||||
contrastNonHarmonicResults.addAll(contrastNonHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, true, queryParam.getDeviceId(), adTypeList));
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, false, queryParam.getDeviceId(), adTypeList);
|
||||
contrastHarmonicResults.addAll(contrastHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, true, queryParam.getDeviceId(), adTypeList));
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, false, null, queryParam.getDeviceId(), adTypeList);
|
||||
contrastNonHarmonicResults.addAll(contrastNonHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, true, null, queryParam.getDeviceId(), adTypeList));
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, false, null, queryParam.getDeviceId(), adTypeList);
|
||||
contrastHarmonicResults.addAll(contrastHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, null, true, null, queryParam.getDeviceId(), adTypeList));
|
||||
allResultList.addAll(contrastHarmonicResults);
|
||||
allResultList.addAll(contrastNonHarmonicResults);
|
||||
|
||||
@@ -1581,8 +1580,6 @@ public class ResultServiceImpl implements IResultService {
|
||||
public ContrastResultVO getContrastResult(ResultParam.QueryParam queryParam) {
|
||||
ContrastResultVO contrastResultVO = new ContrastResultVO();
|
||||
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
|
||||
List<DictTree> dictTreeList = dictTreeService.getDictTreeById(Collections.singletonList(queryParam.getScriptType()));
|
||||
|
||||
List<String> fatherIdList = dictTreeList.stream().map(DictTree::getId).collect(Collectors.toList());
|
||||
@@ -1604,8 +1601,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
|
||||
contrastResultVO.setResultMap(this.getResultMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), String.valueOf(plan.getCode())));
|
||||
contrastResultVO.setRawDataMap(this.getRawDataMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), String.valueOf(plan.getCode()), contrastResultVO.getResultMap().keySet().stream().collect(Collectors.toList())));
|
||||
contrastResultVO.setResultMap(this.getResultMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), queryParam.getCode()));
|
||||
contrastResultVO.setRawDataMap(this.getRawDataMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), queryParam.getCode(), contrastResultVO.getResultMap().keySet().stream().collect(Collectors.toList())));
|
||||
return contrastResultVO;
|
||||
}
|
||||
|
||||
@@ -1658,6 +1655,26 @@ public class ResultServiceImpl implements IResultService {
|
||||
result.setResultType(resultType + CnSocketUtil.SPLIT_TAG + waveData.get(1));
|
||||
result.setResultOrigin(dataSourceEnum.getMsg() + waveData.get(1));
|
||||
break;
|
||||
case MINUTE_STATISTICS_AVG:
|
||||
result.setCheckResult(pqMonitor.getStatisticsResult());
|
||||
result.setWhichTime(pqMonitor.getStatisticsNum());
|
||||
result.setResultOrigin(dataSourceEnum.getMsg());
|
||||
break;
|
||||
case MINUTE_STATISTICS_MAX:
|
||||
result.setCheckResult(pqMonitor.getStatisticsResult());
|
||||
result.setWhichTime(pqMonitor.getStatisticsNum());
|
||||
result.setResultOrigin(dataSourceEnum.getMsg());
|
||||
break;
|
||||
case MINUTE_STATISTICS_MIN:
|
||||
result.setCheckResult(pqMonitor.getStatisticsResult());
|
||||
result.setWhichTime(pqMonitor.getStatisticsNum());
|
||||
result.setResultOrigin(dataSourceEnum.getMsg());
|
||||
break;
|
||||
case MINUTE_STATISTICS_CP95:
|
||||
result.setCheckResult(pqMonitor.getStatisticsResult());
|
||||
result.setWhichTime(pqMonitor.getStatisticsNum());
|
||||
result.setResultOrigin(dataSourceEnum.getMsg());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1683,27 +1700,27 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
AdPlan finalPlan = plan;
|
||||
// 实时数据结果
|
||||
List<ContrastNonHarmonicResult> realNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, monitorId, null);
|
||||
Map<Integer, List<ContrastNonHarmonicResult>> numNonHarmonicMap = realNonHarmonicResults.stream()
|
||||
List<ContrastNonHarmonicResult> realNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, DataSourceEnum.REAL_DATA.getValue(), monitorId, null);
|
||||
Map<Integer, List<ContrastNonHarmonicResult>> realNumNonHarmonicMap = realNonHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastNonHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastNonHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<ContrastHarmonicResult> realHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, monitorId, null);
|
||||
Map<Integer, List<ContrastHarmonicResult>> numHarmonicMap = realHarmonicResults.stream()
|
||||
List<ContrastHarmonicResult> realHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, DataSourceEnum.REAL_DATA.getValue(), monitorId, null);
|
||||
Map<Integer, List<ContrastHarmonicResult>> realNumHarmonicMap = realHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
Map<Integer, List<Integer>> numResutMap = new TreeMap<>();
|
||||
numNonHarmonicMap.forEach((num, resultList) -> {
|
||||
numResutMap.put(num, resultList.stream().map(ContrastNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()));
|
||||
Map<Integer, List<Integer>> realNumResutMap = new TreeMap<>();
|
||||
realNumNonHarmonicMap.forEach((num, resultList) -> {
|
||||
realNumResutMap.put(num, resultList.stream().map(ContrastNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()));
|
||||
});
|
||||
numHarmonicMap.forEach((num, resultList) -> {
|
||||
List<Integer> list = numResutMap.getOrDefault(num, new ArrayList<>());
|
||||
realNumHarmonicMap.forEach((num, resultList) -> {
|
||||
List<Integer> list = realNumResutMap.getOrDefault(num, new ArrayList<>());
|
||||
list.addAll(resultList.stream().map(ContrastHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()));
|
||||
numResutMap.put(num, list);
|
||||
realNumResutMap.put(num, list);
|
||||
});
|
||||
|
||||
numResutMap.forEach((num, resultList) -> {
|
||||
realNumResutMap.forEach((num, resultList) -> {
|
||||
List<DataSourceResultVO> dataSourceResultVOList = new ArrayList<>();
|
||||
DataSourceResultVO realDataSourceResultVO = new DataSourceResultVO();
|
||||
realDataSourceResultVO.setDataSourceCode(DataSourceEnum.REAL_DATA.getValue());
|
||||
@@ -1714,14 +1731,14 @@ public class ResultServiceImpl implements IResultService {
|
||||
result.put(num, dataSourceResultVOList);
|
||||
});
|
||||
|
||||
Map<Integer, Map<Integer, List<Integer>>> waveNumMap = new TreeMap<>();
|
||||
|
||||
// 录波数据结果
|
||||
List<ContrastNonHarmonicResult> waveNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, true, monitorId, null);
|
||||
Map<Integer, Map<Integer, List<Integer>>> waveNumMap = new TreeMap<>();
|
||||
List<ContrastNonHarmonicResult> waveNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, true, null, monitorId, null);
|
||||
Map<Integer, List<ContrastNonHarmonicResult>> waveNumNonHarmonicMap = waveNonHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastNonHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastNonHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
List<ContrastHarmonicResult> waveHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, true, monitorId, null);
|
||||
List<ContrastHarmonicResult> waveHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, true, null, monitorId, null);
|
||||
Map<Integer, List<ContrastHarmonicResult>> waveNumHarmonicMap = waveHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
@@ -1763,6 +1780,62 @@ public class ResultServiceImpl implements IResultService {
|
||||
result.put(num, orDefault);
|
||||
});
|
||||
|
||||
String dataRule = finalPlan.getDatasourceId();
|
||||
String[] split1 = dataRule.split(CnSocketUtil.SPLIT_TAG);
|
||||
DataSourceEnum dataType = null;
|
||||
for (String s : split1) {
|
||||
if (MINUTE_STATISTICS_AVG.getValue().equals(s)) {
|
||||
dataType = MINUTE_STATISTICS_AVG;
|
||||
break;
|
||||
}
|
||||
if (MINUTE_STATISTICS_CP95.getValue().equals(s)) {
|
||||
dataType = MINUTE_STATISTICS_CP95;
|
||||
break;
|
||||
}
|
||||
if (MINUTE_STATISTICS_MAX.getValue().equals(s)) {
|
||||
dataType = MINUTE_STATISTICS_MAX;
|
||||
break;
|
||||
}
|
||||
if (MINUTE_STATISTICS_MIN.getValue().equals(s)) {
|
||||
dataType = MINUTE_STATISTICS_MIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 统计数据
|
||||
if (ObjectUtil.isNotNull(dataType)) {
|
||||
List<ContrastNonHarmonicResult> statisticsNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, dataType.getValue(), monitorId, null);
|
||||
Map<Integer, List<ContrastNonHarmonicResult>> statisticsNumNonHarmonicMap = statisticsNonHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastNonHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastNonHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<ContrastHarmonicResult> statisticsHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(finalPlan.getCode()), null, null, false, dataType.getValue(), monitorId, null);
|
||||
Map<Integer, List<ContrastHarmonicResult>> statisticsNumHarmonicMap = statisticsHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(ContrastHarmonicResult::getNum))
|
||||
.collect(Collectors.groupingBy(ContrastHarmonicResult::getNum, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
Map<Integer, List<Integer>> statisticsNumResutMap = new TreeMap<>();
|
||||
statisticsNumNonHarmonicMap.forEach((num, resultList) -> {
|
||||
statisticsNumResutMap.put(num, resultList.stream().map(ContrastNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()));
|
||||
});
|
||||
statisticsNumHarmonicMap.forEach((num, resultList) -> {
|
||||
List<Integer> list = statisticsNumResutMap.getOrDefault(num, new ArrayList<>());
|
||||
list.addAll(resultList.stream().map(ContrastHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()));
|
||||
statisticsNumResutMap.put(num, list);
|
||||
});
|
||||
|
||||
DataSourceEnum finalDataType = dataType;
|
||||
statisticsNumResutMap.forEach((num, resultList) -> {
|
||||
List<DataSourceResultVO> dataSourceResultVOList = new ArrayList<>();
|
||||
DataSourceResultVO realDataSourceResultVO = new DataSourceResultVO();
|
||||
realDataSourceResultVO.setDataSourceCode(finalDataType.getValue());
|
||||
realDataSourceResultVO.setDataSourceName(finalDataType.getMsg());
|
||||
realDataSourceResultVO.setCheckResult(StorageUtil.getInteger(resultList));
|
||||
dataSourceResultVOList.add(realDataSourceResultVO);
|
||||
|
||||
result.put(num, dataSourceResultVOList);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1802,8 +1875,11 @@ public class ResultServiceImpl implements IResultService {
|
||||
monitor.setRecordedResult(null);
|
||||
monitor.setRecordedNum(null);
|
||||
}
|
||||
boolean flag = pqMonitorService.updateById(monitor);
|
||||
|
||||
return pqMonitorService.updateById(monitor);
|
||||
pqDevService.updateResult(split[0], null);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1814,8 +1890,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
String monitorId = devId + CnSocketUtil.SPLIT_TAG + chnNum;
|
||||
|
||||
List<ContrastNonHarmonicResult> realNoHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, null, false, monitorId, null);
|
||||
List<ContrastHarmonicResult> realHarmonicResults = contrastHarmonicService.listAllResultData(code, num, null, false, monitorId, null);
|
||||
List<ContrastNonHarmonicResult> realNoHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, null, false, null, monitorId, null);
|
||||
List<ContrastHarmonicResult> realHarmonicResults = contrastHarmonicService.listAllResultData(code, num, null, false, null, monitorId, null);
|
||||
|
||||
Map<String, List<Integer>> checkItemResultMap = realNoHarmonicResults.stream().collect(Collectors.groupingBy(ContrastNonHarmonicResult::getAdType, Collectors.mapping(ContrastNonHarmonicResult::getResultFlag, Collectors.toList())));
|
||||
checkItemResultMap.putAll(realHarmonicResults.stream().collect(Collectors.groupingBy(ContrastHarmonicResult::getAdType, Collectors.mapping(ContrastHarmonicResult::getResultFlag, Collectors.toList()))));
|
||||
@@ -1834,8 +1910,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
checkItemResultMap.clear();
|
||||
|
||||
List<ContrastNonHarmonicResult> waveNoHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, null, true, monitorId, null);
|
||||
List<ContrastHarmonicResult> waveHarmonicResults = contrastHarmonicService.listAllResultData(code, num, null, true, monitorId, null);
|
||||
List<ContrastNonHarmonicResult> waveNoHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, null, true, null, monitorId, null);
|
||||
List<ContrastHarmonicResult> waveHarmonicResults = contrastHarmonicService.listAllResultData(code, num, null, true, null, monitorId, null);
|
||||
if (CollUtil.isNotEmpty(waveNoHarmonicResults) && CollUtil.isNotEmpty(waveHarmonicResults)) {
|
||||
checkItemResultMap.putAll(waveNoHarmonicResults.stream().collect(Collectors.groupingBy(ContrastNonHarmonicResult::getAdType, Collectors.mapping(ContrastNonHarmonicResult::getResultFlag, Collectors.toList()))));
|
||||
checkItemResultMap.putAll(waveHarmonicResults.stream().collect(Collectors.groupingBy(ContrastHarmonicResult::getAdType, Collectors.mapping(ContrastHarmonicResult::getResultFlag, Collectors.toList()))));
|
||||
@@ -1955,8 +2031,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
int totalDataPoints = 0; // 统计总的数据点数
|
||||
int zeroFilteredPoints = 0; // 统计双零过滤的数据点数
|
||||
|
||||
// 遍历 2~50 次谐波
|
||||
for (int harmNum = 2; harmNum <= 50; harmNum++) {
|
||||
// 间谐波从1开始,普通谐波从2开始
|
||||
int startHarmNum = isInterHarmonic ? 1 : 2;
|
||||
// 遍历谐波次数
|
||||
for (int harmNum = startHarmNum; harmNum <= 50; harmNum++) {
|
||||
String harmKey = String.valueOf(harmNum);
|
||||
Map<String, Map<String, Map<String, String>>> checkResultHarmonic = new LinkedHashMap<>();
|
||||
List<String> zeroFilteredPhases = new ArrayList<>(); // 当前次数被过滤的相别
|
||||
@@ -2301,10 +2379,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
contrastTestResult.setHarmonic(false);
|
||||
List<String> allResult = new ArrayList<>();
|
||||
Map<String, Map<String, String>> checkResultNonHarmonic = new LinkedHashMap<>();
|
||||
|
||||
// 根据指标代码确定小数位数
|
||||
Integer decimalPlaces = getDecimalPlacesByScriptCode(dictTree.getCode());
|
||||
|
||||
try {
|
||||
// 非谐波的需要注意是否为T相还是ABC三相的
|
||||
if (PowerConstant.T_PHASE.contains(dictTree.getCode())) {
|
||||
@@ -2430,27 +2506,22 @@ public class ResultServiceImpl implements IResultService {
|
||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||
if (CollUtil.isNotEmpty(dataList)) {
|
||||
DetectionData detectionData = dataList.get(0);
|
||||
|
||||
// 相别
|
||||
dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase);
|
||||
// 有效组数 todo... 目前是对齐组数
|
||||
dataMap.put(ItemReportKeyEnum.NUM_OF_DATA.getKey(), String.valueOf(numOfData));
|
||||
|
||||
// 标准值 - 根据参数决定是否格式化
|
||||
String standardValue = String.valueOf(detectionData.getResultData());
|
||||
if (decimalPlaces != null && detectionData.getResultData() != null) {
|
||||
standardValue = formatSignificantDigits(detectionData.getResultData(), decimalPlaces);
|
||||
}
|
||||
dataMap.put(ItemReportKeyEnum.STANDARD.getKey(), standardValue);
|
||||
|
||||
// 被检值 - 根据参数决定是否格式化
|
||||
String testValue = String.valueOf(detectionData.getData());
|
||||
if (decimalPlaces != null && detectionData.getData() != null) {
|
||||
testValue = formatSignificantDigits(detectionData.getData(), decimalPlaces);
|
||||
}
|
||||
dataMap.put(ItemReportKeyEnum.TEST.getKey(), testValue);
|
||||
|
||||
|
||||
// 误差 - 根据参数决定是否格式化
|
||||
String errorValue = String.valueOf(detectionData.getErrorData());
|
||||
if (decimalPlaces != null && detectionData.getErrorData() != null) {
|
||||
@@ -2459,7 +2530,6 @@ public class ResultServiceImpl implements IResultService {
|
||||
errorValue = "/";
|
||||
}
|
||||
dataMap.put(ItemReportKeyEnum.ERROR.getKey(), errorValue);
|
||||
|
||||
// 误差范围 - 根据参数决定是否格式化
|
||||
String errorScope = String.valueOf(detectionData.getRadius());
|
||||
if (decimalPlaces != null && detectionData.getRadius() != null) {
|
||||
@@ -2468,7 +2538,6 @@ public class ResultServiceImpl implements IResultService {
|
||||
errorScope = "/";
|
||||
}
|
||||
dataMap.put(ItemReportKeyEnum.A_ERROR_SCOPE.getKey(), errorScope);
|
||||
|
||||
// 结论
|
||||
dataMap.put(ItemReportKeyEnum.RESULT.getKey(), getTestResult(detectionData.getIsData()));
|
||||
} else {
|
||||
@@ -2563,8 +2632,20 @@ public class ResultServiceImpl implements IResultService {
|
||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||
if (CollUtil.isNotEmpty(dataList)) {
|
||||
DetectionData detectionData = dataList.get(0);
|
||||
// 次数
|
||||
dataMap.put(ItemReportKeyEnum.TIME.getKey(), String.valueOf(harmNum));
|
||||
// 次数 - 从数据对象中获取实际次数(间谐波为1.5、2.5等)
|
||||
String timeValue;
|
||||
if (detectionData.getNum() != null) {
|
||||
double numValue = detectionData.getNum();
|
||||
// 如果是整数,则只显示整数部分(如2.0显示为2)
|
||||
if (numValue == Math.floor(numValue)) {
|
||||
timeValue = String.valueOf((int) numValue);
|
||||
} else {
|
||||
timeValue = String.valueOf(numValue);
|
||||
}
|
||||
} else {
|
||||
timeValue = String.valueOf(harmNum);
|
||||
}
|
||||
dataMap.put(ItemReportKeyEnum.TIME.getKey(), timeValue);
|
||||
// 相别
|
||||
dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase);
|
||||
// 有效组数 todo... 目前是对齐组数
|
||||
@@ -2605,7 +2686,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 结论
|
||||
dataMap.put(ItemReportKeyEnum.RESULT.getKey(), getTestResult(detectionData.getIsData()));
|
||||
} else {
|
||||
// 次数
|
||||
// 次数 - 数据为空时用循环变量作为兜底
|
||||
dataMap.put(ItemReportKeyEnum.TIME.getKey(), String.valueOf(harmNum));
|
||||
// 相别
|
||||
dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase);
|
||||
@@ -2680,8 +2761,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
private Map<String, List<RawResultDataVO>> getResultMap(DictTree dictTree, List<String> adTypeList, String monitorId, String unit, Integer num, Integer waveNum, Boolean isWave, String code) {
|
||||
Map<String, List<RawResultDataVO>> resultMap = new LinkedHashMap<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, waveNum, isWave, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(code, num, waveNum, isWave, monitorId, adTypeList);
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, waveNum, isWave, null, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(code, num, waveNum, isWave, null, monitorId, adTypeList);
|
||||
|
||||
if (CollUtil.isNotEmpty(contrastNonHarmonicResults)) {
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResult = contrastNonHarmonicResults.get(0);
|
||||
@@ -2778,33 +2859,33 @@ public class ResultServiceImpl implements IResultService {
|
||||
private Map<String, List<AlignDataVO.RawData>> getRawDataMap(DictTree dictTree, List<String> adTypeList, String monitorId, String unit, Integer num, Integer waveNum, Boolean isWave, String code, List<String> keys) {
|
||||
Map<String, List<AlignDataVO.RawData>> rawMap = new LinkedHashMap<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, waveNum, isWave, 0, monitorId, adTypeList);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, waveNum, isWave, 1, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, waveNum, isWave, 0, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, waveNum, isWave, 1, monitorId, adTypeList);
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, waveNum, isWave, null, 0, monitorId, adTypeList);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, waveNum, isWave, null, 1, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, waveNum, isWave, null, 0, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, waveNum, isWave, null, 1, monitorId, adTypeList);
|
||||
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
List<AlignDataVO.RawData> rawDataVOList = new ArrayList<>();
|
||||
for (int i = 0; i < devNonHarmonicRawDataList.size(); i++) {
|
||||
AlignDataVO.RawData rawDataVO = new AlignDataVO.RawData();
|
||||
rawDataVO.setUnit(unit);
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResult = devNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeDev(contrastNonHarmonicResult.getTimeId().format(dtf));
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResultDev = devNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeDev(contrastNonHarmonicResultDev.getTimeId().format(dtf));
|
||||
|
||||
rawDataVO.setUbDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUtDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
rawDataVO.setUbDev(getValue(contrastNonHarmonicResultDev.getBValue()));
|
||||
rawDataVO.setUtDev(getValue(contrastNonHarmonicResultDev.getTValue()));
|
||||
|
||||
contrastNonHarmonicResult = stdDevNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResult.getTimeId().format(dtf));
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
||||
if (!DicDataEnum.IMBV.getCode().equals(dictTree.getCode()) && !DicDataEnum.IMBA.getCode().equals(dictTree.getCode())) {
|
||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUcStdDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
||||
rawDataVO.setUcStdDev(getValue(contrastNonHarmonicResultStdDev.getCValue()));
|
||||
}
|
||||
|
||||
rawDataVO.setUbStdDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUtStdDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
rawDataVO.setUbStdDev(getValue(contrastNonHarmonicResultStdDev.getBValue()));
|
||||
rawDataVO.setUtStdDev(getValue(contrastNonHarmonicResultStdDev.getTValue()));
|
||||
|
||||
rawDataVOList.add(rawDataVO);
|
||||
}
|
||||
@@ -2983,7 +3064,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param errorSysId
|
||||
* @param devId
|
||||
*/
|
||||
private void simAndDigCalculateResult(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
private void simAndDigCalculateResult(String planId, String scriptId, String code, String errorSysId, String devId, String dataRuleId) {
|
||||
String oldCode = code.replace("_temp", "");
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setCode(code);
|
||||
@@ -3001,8 +3082,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
// } else {
|
||||
// dataRule = DictDataEnum.SECTION_VALUE;
|
||||
// }
|
||||
AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
// AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(dataRuleId);
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
@@ -3060,8 +3141,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param code
|
||||
* @param errorSysId
|
||||
* @param deviceId
|
||||
* @param updateResult
|
||||
*/
|
||||
private void contrastCalculateResult(String planId, String code, String errorSysId, String deviceId) {
|
||||
private void contrastCalculateResult(String planId, String code, String errorSysId, String deviceId, boolean updateResult, String dataRuleId) {
|
||||
String oldCode = code.replace("_temp", "");
|
||||
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
@@ -3104,33 +3186,38 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
|
||||
DictDataEnum dataRule;
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
DictData dictData = dictDataService.getDictDataById(dataRuleId);
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
pqMonitorService.lambdaUpdate().set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRealtimeNum, null)
|
||||
.set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRecordedNum, null)
|
||||
.set(PqMonitor::getStatisticsResult, null)
|
||||
.set(PqMonitor::getStatisticsNum, null)
|
||||
.set(PqMonitor::getResultType, null)
|
||||
.set(PqMonitor::getQualifiedNum, 0)
|
||||
.eq(PqMonitor::getDevId, deviceId)
|
||||
.eq(PqMonitor::getCheckFlag, 1)
|
||||
.update();
|
||||
if (updateResult) {
|
||||
pqMonitorService.lambdaUpdate().set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRealtimeNum, null)
|
||||
.set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRecordedNum, null)
|
||||
.set(PqMonitor::getStatisticsResult, null)
|
||||
.set(PqMonitor::getStatisticsNum, null)
|
||||
.set(PqMonitor::getResultType, null)
|
||||
.set(PqMonitor::getQualifiedNum, 0)
|
||||
.eq(PqMonitor::getDevId, deviceId)
|
||||
// .eq(PqMonitor::getNum, Integer.parseInt(chnNum))
|
||||
.eq(PqMonitor::getCheckFlag, 1)
|
||||
.update();
|
||||
}
|
||||
|
||||
// String monitorId = deviceId + CnSocketUtil.SPLIT_TAG + chnNum;
|
||||
List<AdPair> adPairList = adPairService.listByDevIds(Arrays.asList(deviceId));
|
||||
Map<Integer, List<AdPair>> numAdPairsMap = adPairList.stream().collect(Collectors.groupingBy(AdPair::getNum, Collectors.toList()));
|
||||
|
||||
numAdPairsMap.forEach((num, pairList) -> {
|
||||
BiMap<String, String> parsIp = HashBiMap.create();
|
||||
BiMap<String, String> parsId = HashBiMap.create();
|
||||
Map<String, Integer> numMap = new HashMap<>();
|
||||
Map<String, List<AdPair>> devMonitroIdMap = pairList.stream().collect(Collectors.groupingBy(AdPair::getDevMonitorId, Collectors.toList()));
|
||||
devMonitroIdMap.forEach((devMonitorId, pairList1) -> {
|
||||
BiMap<String, String> parsIp = HashBiMap.create();
|
||||
BiMap<String, String> parsId = HashBiMap.create();
|
||||
String[] split1 = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
AdPair adPair = pairList1.get(0);
|
||||
String[] split2 = adPair.getStdDevMonitorId().split(CnSocketUtil.SPLIT_TAG);
|
||||
@@ -3141,42 +3228,40 @@ public class ResultServiceImpl implements IResultService {
|
||||
numMap.put(devMonitorId, num);
|
||||
numMap.put(adPair.getStdDevMonitorId(), num);
|
||||
devIdMapComm.put(standardDev.getIp(), standardDev.getId());
|
||||
});
|
||||
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, 0, deviceId, null);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, 1, deviceId, null);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, 0, deviceId, null);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, 1, deviceId, null);
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, devMonitorId, null);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, devMonitorId, null);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, devMonitorId, null);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, devMonitorId, null);
|
||||
|
||||
List<DevData> devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
List<DevData> standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
List<DevData> devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
List<DevData> standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
|
||||
if (CollUtil.isNotEmpty(devData) && CollUtil.isNotEmpty(standardDevData)) {
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, code, null, finalNonWaveDataSourceEnum);
|
||||
if (CollUtil.isNotEmpty(devData) && CollUtil.isNotEmpty(standardDevData)) {
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, code, null, finalNonWaveDataSourceEnum);
|
||||
|
||||
parsId.forEach((devMonitorId, stdDevMonitorId) -> {
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, finalNonWaveDataSourceEnum, num, null, oldCode);
|
||||
pqDevService.updateResult(split[0], null);
|
||||
});
|
||||
}
|
||||
if (updateResult) {
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, finalNonWaveDataSourceEnum, num, null, oldCode);
|
||||
pqDevService.updateResult(split1[0], null);
|
||||
}
|
||||
}
|
||||
|
||||
AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(planId);
|
||||
for (int i = 1; i <= adPlanTestConfig.getWaveRecord(); i++) {
|
||||
devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, 0, deviceId, null);
|
||||
stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, 1, deviceId, null);
|
||||
devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, 0, deviceId, null);
|
||||
stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, 1, deviceId, null);
|
||||
AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(planId);
|
||||
for (int i = 1; i <= adPlanTestConfig.getWaveRecord(); i++) {
|
||||
devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, devMonitorId, null);
|
||||
stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, devMonitorId, null);
|
||||
devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, devMonitorId, null);
|
||||
stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, devMonitorId, null);
|
||||
|
||||
devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, oldCode, i, DataSourceEnum.WAVE_DATA);
|
||||
}
|
||||
devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, oldCode, i, DataSourceEnum.WAVE_DATA);
|
||||
}
|
||||
|
||||
parsId.forEach((devMonitorId, stdDevMonitorId) -> {
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, WAVE_DATA, num, adPlanTestConfig.getWaveRecord(), oldCode);
|
||||
pqDevService.updateResult(split[0], null);
|
||||
if (updateResult) {
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, WAVE_DATA, num, adPlanTestConfig.getWaveRecord(), oldCode);
|
||||
pqDevService.updateResult(split1[0], null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -3317,8 +3402,17 @@ public class ResultServiceImpl implements IResultService {
|
||||
devMonitorIdMap2.forEach((devMonitorId, value) -> {
|
||||
Map<LocalDateTime, List<ContrastHarmonicResult>> timeListMap = value.stream().collect(Collectors.groupingBy(ContrastHarmonicResult::getTimeId, Collectors.toList()));
|
||||
|
||||
String[] split1 = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
timeListMap.forEach((time, value1) -> {
|
||||
DevData devData = info.stream().filter(x -> x.getTime().equals(time.format(DateTimeFormatter.ofPattern(DatePattern.ISO8601_PATTERN)))).findFirst().orElse(null);
|
||||
// DevData devData = info.stream().filter(x -> x.getTime().equals(time.format(DateTimeFormatter.ofPattern(DatePattern.ISO8601_PATTERN)))).findFirst().orElse(null);
|
||||
DevData devData = null;
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
DevData devData1 = info.get(i);
|
||||
if (time.format(DateTimeFormatter.ofPattern(DatePattern.ISO8601_PATTERN)).equals(devData1.getTime()) && devData1.getId().split(CnSocketUtil.SPLIT_TAG)[1].equals(split1[1])) {
|
||||
devData = devData1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(devData)) {
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
if (flag == 0) {
|
||||
@@ -3508,10 +3602,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
switch (scriptCode) {
|
||||
// 保留2位小数
|
||||
case "FREQ": // 频率
|
||||
return 2;
|
||||
return 4;
|
||||
// 保留3位小数
|
||||
case "I": // 电流
|
||||
return 3;
|
||||
return 5;
|
||||
// 保留4位小数
|
||||
case "IMBV": // 电压不平衡度
|
||||
case "IMBA": // 电流不平衡度
|
||||
|
||||
@@ -58,7 +58,7 @@ public class PqScriptController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测脚本")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "检测脚本", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated PqScriptParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
@@ -69,7 +69,7 @@ public class PqScriptController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改检测脚本")
|
||||
@ApiImplicitParam(name = "updateParam", value = "检测脚本", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated PqScriptParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
@@ -126,10 +126,10 @@ public class PqScriptController extends BaseController {
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取指定模式下的所有检测脚本")
|
||||
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
public HttpResult<List<PqScript>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
String methodDescribe = getMethodDescribe("getAllPqScript");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
|
||||
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
|
||||
List<PqScript> result = pqScriptService.listAllPqScript(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class PqScriptParam {
|
||||
@Max(value = 20, message = DetectionValidMessage.SCRIPT_CURR_FORMAT_ERROR)
|
||||
private Double ratedCurr;
|
||||
|
||||
@ApiModelProperty("是否为Fluke专用脚本")
|
||||
private Integer fluke;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
@@ -73,6 +73,11 @@ public class PqScript extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Double ratedCurr;
|
||||
|
||||
/**
|
||||
* 是否为福禄克专用脚本。0-否 1-是
|
||||
*/
|
||||
private Integer fluke;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
|
||||
@@ -92,6 +92,18 @@ public class PqScriptDtls implements Serializable {
|
||||
@TableField("RetainTime")
|
||||
private Double retainTime;
|
||||
|
||||
/**
|
||||
* 暂态前延时间(S)
|
||||
*/
|
||||
@TableField("FPreTime")
|
||||
private Double fPreTime;
|
||||
|
||||
/**
|
||||
* 暂态后延时间(S)
|
||||
*/
|
||||
@TableField("FAfterTime")
|
||||
private Double fAfterTime;
|
||||
|
||||
/**
|
||||
* 变动频度(次/min)
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* @param patternId 模式id
|
||||
* @return 检测脚本列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqScript(String patternId);
|
||||
List<PqScript> listAllPqScript(String patternId);
|
||||
|
||||
/**
|
||||
* 根据脚本名称查询脚本
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
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.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
@@ -67,14 +68,14 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final static String INHARM_I = "InHarm_I";
|
||||
private final static String DIP = "Dip";
|
||||
private final static String FLICKER = "Flicker";
|
||||
@Value("${Dip.fPreTime}")
|
||||
private Double fPreTime;
|
||||
// @Value("${Dip.fPreTime}")
|
||||
// private Double fPreTime;
|
||||
@Value("${Dip.fRampIn}")
|
||||
private Double fRampIn;
|
||||
@Value("${Dip.fRampOut}")
|
||||
private Double fRampOut;
|
||||
@Value("${Dip.fAfterTime}")
|
||||
private Double fAfterTime;
|
||||
// @Value("${Dip.fAfterTime}")
|
||||
// private Double fAfterTime;
|
||||
@Value("${Flicker.waveFluType}")
|
||||
private String waveFluType;
|
||||
@Value("${Flicker.waveType}")
|
||||
@@ -384,6 +385,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
dip.setPhase(phase);
|
||||
dip.setTransValue(dipData.getFTransValue());
|
||||
dip.setRetainTime(dipData.getRetainTime());
|
||||
dip.setFPreTime(dipData.getFPreTime());
|
||||
dip.setFAfterTime(dipData.getFAfterTime());
|
||||
info.add(dip);
|
||||
}
|
||||
}
|
||||
@@ -959,6 +962,22 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
// 相序校验中电流需加量需要依据企标10650.2中章节5.5.3的描述过载能力:2 倍额定电流连续,10 倍额定电流持续 1 s。
|
||||
// 考虑到有可能存在1A的额定电流,本处做特殊处理,加量分别为额定电流的0.2/0.4/0.6的标幺乘积加量
|
||||
// 电压暂不做处理,原因:1、电压的企标描述过载能力为4倍,空间较大;2、额定电压比如57.74V为浮点数,存在不确定小数位,避免引起算术误差;
|
||||
// 1. 获取额定电流,前端已做限制,相同额定电流才能一起检测
|
||||
String deviceId = param.getDevIds().get(0);
|
||||
PqDevVO pqDev = pqDevService.getPqDevById(deviceId);
|
||||
String devTypeId = pqDev.getDevType();
|
||||
DevType devType = devTypeService.getById(devTypeId);
|
||||
Double devCurr = devType.getDevCurr();
|
||||
for (int i = 0; i < pqScriptDtls.size(); i++) {
|
||||
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
|
||||
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
|
||||
if(scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0){
|
||||
scriptDtls.setValue(devCurr * scriptDtls.getValue());
|
||||
}
|
||||
}
|
||||
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
|
||||
//系数
|
||||
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())
|
||||
@@ -1037,10 +1056,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
dipDataDTO.setFTransValue(0.0);
|
||||
dipDataDTO.setFRetainTime(0.0);
|
||||
|
||||
dipDataDTO.setFPreTime(fPreTime);
|
||||
// dipDataDTO.setFPreTime(fPreTime);
|
||||
dipDataDTO.setFRampIn(fRampIn);
|
||||
dipDataDTO.setFRampOut(fRampOut);
|
||||
dipDataDTO.setFAfterTime(fAfterTime);
|
||||
// dipDataDTO.setFAfterTime(fAfterTime);
|
||||
|
||||
|
||||
channelListDTO.setDipData(dipDataDTO);
|
||||
@@ -1087,6 +1106,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
if (CollUtil.isNotEmpty(dipList)) {
|
||||
PqScriptDtls dip = dipList.get(0);
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
dipDataDTO.setFPreTime(dip.getFPreTime());
|
||||
dipDataDTO.setFAfterTime(dip.getFAfterTime());
|
||||
if (devFly) {
|
||||
// if (isValueType) {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
|
||||
@@ -112,15 +112,15 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqScript(String patternId) {
|
||||
public List<PqScript> listAllPqScript(String patternId) {
|
||||
List<PqScript> pqScriptList = this.lambdaQuery().eq(StrUtil.isNotBlank(patternId), PqScript::getPattern, patternId).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqScript.getId());
|
||||
map.put("name", pqScript.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
// List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("id", pqScript.getId());
|
||||
// map.put("name", pqScript.getName());
|
||||
// return map;
|
||||
// }).collect(Collectors.toList());
|
||||
return pqScriptList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
wrapper.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
wrapper.eq("name", param.getName());
|
||||
if (isExcludeSelf) {
|
||||
if(param instanceof PqScriptParam.UpdateParam){
|
||||
if (param instanceof PqScriptParam.UpdateParam) {
|
||||
wrapper.ne("id", ((PqScriptParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,17 +127,5 @@ public class PqSourceController extends BaseController {
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(sourceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/aa")
|
||||
@ApiOperation("按照检测源ID获取源参数")
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true)
|
||||
public HttpResult<SourceInitialize> aa(@RequestParam("sourceId") String sourceId) {
|
||||
String methodDescribe = getMethodDescribe("getParam");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceId);
|
||||
SourceInitialize sourceInitializeParam = pqSourceService.getSourceInitializeParam(sourceId);
|
||||
String jsonString = JSON.toJSONString(sourceInitializeParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceInitializeParam, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DevTypeController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改设备类型")
|
||||
@ApiImplicitParam(name = "devTypeParam", value = "设备类型", required = true)
|
||||
@ApiImplicitParam(name = "updateParam", value = "设备类型参数", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated DevTypeParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
|
||||
|
||||
@@ -9,7 +9,7 @@ spring:
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://localhost:13306/pqs9100w?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100_nx?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: njcnpqs
|
||||
#初始化建立物理连接的个数、最小、最大连接数
|
||||
@@ -85,6 +85,7 @@ log:
|
||||
report:
|
||||
template: D:\template
|
||||
reportDir: D:\report
|
||||
dateFormat: yyyy年MM月dd日
|
||||
data:
|
||||
homeDir: D:\data
|
||||
qr:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- 直接使用固定配置,避免Spring配置解析时机问题 -->
|
||||
<property name="log.projectName" value="entrance"/>
|
||||
<property name="logCommonLevel" value="info"/>
|
||||
<property name="logHomeDir" value="D:\logs"/>
|
||||
<property name="logHomeDir" value="${logHomeDir:-D:\logs}"/>
|
||||
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
entrance/src/main/resources/model/report_table - PQ-COM.docx
Normal file
BIN
entrance/src/main/resources/model/report_table - PQ-COM.docx
Normal file
Binary file not shown.
@@ -25,10 +25,10 @@ public class AnalysisServiceStreamTest {
|
||||
private ICompareWaveService compareWaveServiceImpl;
|
||||
|
||||
// 测试文件路径 - 请根据实际情况修改
|
||||
private static final String SOURCE_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.200\\PQ_PQLD1_000020_20251017_140358_193.cfg";
|
||||
private static final String SOURCE_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.200\\PQ_PQLD1_000020_20251017_140358_193.dat";
|
||||
private static final String TARGET_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.168\\PQ_PQLD1_000018_20251017_140357_625.cfg";
|
||||
private static final String TARGET_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.168\\PQ_PQLD1_000018_20251017_140357_625.dat";
|
||||
private static final String SOURCE_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.241\\PQ_PQLD2_000177_20251028_112422_833.cfg";
|
||||
private static final String SOURCE_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.241\\PQ_PQLD2_000177_20251028_112422_833.dat";
|
||||
private static final String TARGET_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.242\\PQ_PQLD2_000238_20251028_112422_518.cfg";
|
||||
private static final String TARGET_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.242\\PQ_PQLD2_000238_20251028_112422_518.dat";
|
||||
|
||||
|
||||
// private static final String SOURCE_CFG_PATH = "F:\\hatch\\wavecompare\\数据比对\\统计数据1\\B码\\217\\PQMonitor_PQM1_000006_20200430_115517_889.cfg";
|
||||
|
||||
1
license.key
Normal file
1
license.key
Normal file
@@ -0,0 +1 @@
|
||||
AoNUHvLQag9nPPxWDsf5EwwBqifh5wnoFjrU01w+kIA7TPdRl0AQDBSA3IU7AY28Liubt6Rl8CsDtxEDrz8L5m0FqQrmZ1TmIJtZWbBR16NxXRgf8izM5JurYEY6ZbjU021yCu0fitxB0DJZ8LB8zfUDsV1MFGHl+yPjh4ZQrYDffID4rk/mRe/EE6F7bS19upStSOnQxVQVJSXwCVVHgsuFXqiuagM21OmxpYNjqaPnvAKoHRXTTxXn9BrSgZBocxuHB/IE+a0a+Q2eQo4RZa2IQpneEA/QIKEqezqsABxmM33duQ4eKt17hAttISV1J0R1cKpwZ4tYuSoHCuMONA==
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.njcn.gather.storage.controller;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "处理数据")
|
||||
@RestController
|
||||
@RequestMapping("/dataDeal")
|
||||
@RequiredArgsConstructor
|
||||
public class DataDealController extends BaseController {
|
||||
|
||||
private final DetectionDataDealService detectionDataDealService;
|
||||
|
||||
|
||||
@GetMapping("ttt")
|
||||
public HttpResult<Object> dataDealAndInsert(){
|
||||
String methodDescribe = getMethodDescribe("dataDealAndInsert");
|
||||
|
||||
List<SimAndDigHarmonicResult> list2 = new ArrayList<>();
|
||||
SimAndDigHarmonicResult SimAndDigHarmonicResult = new SimAndDigHarmonicResult();
|
||||
SimAndDigHarmonicResult.setDataType("aa");
|
||||
SimAndDigHarmonicResult.setAdType("aaaa");
|
||||
|
||||
SimAndDigHarmonicResult.setDevMonitorId("ss");
|
||||
SimAndDigHarmonicResult.setScriptId("ddd");
|
||||
SimAndDigHarmonicResult.setTimeId(LocalDateTime.now());
|
||||
|
||||
list2.add(SimAndDigHarmonicResult);
|
||||
SimAndDigHarmonicResult SimAndDigHarmonicResult2 = new SimAndDigHarmonicResult();
|
||||
SimAndDigHarmonicResult2.setDataType("aabb");
|
||||
SimAndDigHarmonicResult2.setAdType("aaaabb");
|
||||
|
||||
SimAndDigHarmonicResult2.setDevMonitorId("ssbb");
|
||||
SimAndDigHarmonicResult2.setScriptId("dddbb");
|
||||
SimAndDigHarmonicResult2.setTimeId(LocalDateTime.now());
|
||||
list2.add(SimAndDigHarmonicResult2);
|
||||
|
||||
detectionDataDealService.acceptHarmonic(list2,"1");
|
||||
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.njcn.gather.storage.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.storage.service.TableGenService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "生成表")
|
||||
@RestController
|
||||
@RequestMapping("/genTable")
|
||||
@RequiredArgsConstructor
|
||||
public class TableGenController extends BaseController {
|
||||
|
||||
private final TableGenService tableGenService;
|
||||
|
||||
|
||||
@GetMapping("genAdHarmonicTable")
|
||||
@ApiOperation("生成表")
|
||||
@OperateInfo
|
||||
public HttpResult<Object> genAdHarmonicTable(@RequestParam("code") String code, @RequestParam("isContrast") boolean isContrast) {
|
||||
String methodDescribe = getMethodDescribe("genAdHarmonicTable");
|
||||
tableGenService.genTable(code, isContrast);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@
|
||||
Time_Id DATETIME(3) NOT NULL COMMENT '时间',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',
|
||||
A_Value float DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value float DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value float DEFAULT NULL COMMENT 'C相值',
|
||||
T_Value float DEFAULT NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
A_Value float(14,7) DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value float(14,7) DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value float(14,7) DEFAULT NULL COMMENT 'C相值',
|
||||
T_Value float(14,7) DEFAULT NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
|
||||
<choose>
|
||||
<when test="isContrast">
|
||||
@@ -19,9 +19,9 @@
|
||||
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
|
||||
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
|
||||
Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',
|
||||
A_Value_0 float NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
A_Value_0 float(14,7) NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',
|
||||
Wave_Num tinyint(1) unsigned DEFAULT null COMMENT '录波数据第几组',
|
||||
PRIMARY KEY (Id)
|
||||
</when>
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,7 @@ public interface ContrastHarmonicService extends IService<ContrastHarmonicResult
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList);
|
||||
List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取所有谐波结果数据
|
||||
@@ -33,27 +32,29 @@ public interface ContrastHarmonicService extends IService<ContrastHarmonicResult
|
||||
* @param devId 设备ID
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList);
|
||||
|
||||
|
||||
/**
|
||||
* 获取谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
ContrastHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -19,12 +18,13 @@ public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonic
|
||||
* @param num
|
||||
* @param waveNum
|
||||
* @param isWave
|
||||
* @param dataType
|
||||
* @param flag
|
||||
* @param devId
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList);
|
||||
List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,31 +34,34 @@ public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonic
|
||||
* @param num
|
||||
* @param waveNum
|
||||
* @param isWave
|
||||
* @param dataType
|
||||
* @param devId
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取非谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
ContrastNonHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.njcn.gather.storage.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.storage.mapper.ContrastHarmonicMappper;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
@@ -13,7 +13,6 @@ import com.njcn.gather.storage.service.ContrastHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,12 +25,13 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList) {
|
||||
public List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.eq(ContrastHarmonicResult::getFlag, flag)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastHarmonicResult::getTimeId);
|
||||
if (isWave) {
|
||||
@@ -48,15 +48,14 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* todo... 缺少统计的数据获取逻辑
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList) {
|
||||
public List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList);
|
||||
if (isWave) {
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
@@ -73,12 +72,11 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
@Override
|
||||
@@ -93,7 +91,7 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
List<ContrastHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, null, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
@@ -102,11 +100,12 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
@Override
|
||||
@@ -128,10 +127,10 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
.in(ContrastHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
if (isWave) {
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
} else {
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.storage.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -12,7 +13,6 @@ import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -25,12 +25,13 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList) {
|
||||
public List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastNonHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, flag)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastNonHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastNonHarmonicResult::getTimeId);
|
||||
if (isWave) {
|
||||
@@ -48,11 +49,12 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList) {
|
||||
public List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastNonHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastNonHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList);
|
||||
if (isWave) {
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
@@ -80,7 +82,7 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastNonHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
List<ContrastNonHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, null, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
@@ -106,10 +108,10 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
.in(ContrastNonHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastNonHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
if (isWave) {
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastNonHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
} else {
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
|
||||
@@ -28,13 +28,13 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
StringBuilder C = new StringBuilder();
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
if (i == 1) {
|
||||
A.append("A_Value_").append(i).append(" float NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" float NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" float NULL COMMENT 'C相基波',");
|
||||
A.append("A_Value_").append(i).append(" float(14,7) NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" float(14,7) NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" float(14,7) NULL COMMENT 'C相基波',");
|
||||
} else {
|
||||
A.append("A_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
A.append("A_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
|
||||
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
|
||||
"Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',\n" +
|
||||
"A_Value_0 float NULL COMMENT 'A相基波有效值',\n" +
|
||||
"C_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
"B_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
"A_Value_0 float(14,7) NULL COMMENT 'A相基波有效值',\n" +
|
||||
"C_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',\n" +
|
||||
"B_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',\n" +
|
||||
"Wave_Num tinyint(1) unsigned DEFAULT null COMMENT '录波数据第几组',\n" +
|
||||
"PRIMARY KEY (Id)\n"
|
||||
:
|
||||
@@ -64,9 +64,9 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
// 添加索引
|
||||
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_harmonic_" + code + "_dev_monitor_id" + " ON ad_harmonic_" + code + " (Dev_Monitor_Id);");
|
||||
|
||||
String a = A.toString().replaceAll("float", "json");
|
||||
String b = B.toString().replaceAll("float", "json");
|
||||
String c = C.toString().replaceAll("float", "json");
|
||||
String a = A.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String b = B.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String c = C.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String sql2 = "CREATE TABLE AD_Harmonic_Result_" + code + " (\n" +
|
||||
" Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME(3) NULL COMMENT '时间',\n" +
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DictDataController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getDicDataById")
|
||||
@ApiOperation("根据字典id查询字典数据")
|
||||
@ApiImplicitParam(name = "dicIndex", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "dicIndex", value = "字典id", required = true)
|
||||
public HttpResult<DictData> getDicDataById(@RequestParam("dicIndex") String dicIndex) {
|
||||
String methodDescribe = getMethodDescribe("getDicDataById");
|
||||
DictData result = dictDataService.getDictDataById(dicIndex);
|
||||
@@ -109,7 +109,7 @@ public class DictDataController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getDicDataByCode")
|
||||
@ApiOperation("根据字典code查询字典数据")
|
||||
@ApiImplicitParam(name = "code", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "code", value = "字典code", required = true)
|
||||
public HttpResult<DictData> getDicDataByCode(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("getDicDataByCode");
|
||||
DictData result = dictDataService.getDictDataByCode(code);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DictTreeController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getTreeByCode")
|
||||
@ApiOperation("按照code查询字典树")
|
||||
@ApiImplicitParam(name = "keyword", value = "查询参数", required = true)
|
||||
@ApiImplicitParam(name = "code", value = "查询参数", required = true)
|
||||
public HttpResult<List<DictTree>> getTreeByCode(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("getTreeByCode");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, code);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DictTreeParam {
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@ApiModelProperty(value = "编码")
|
||||
@TableField(value = "编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.DICT_TYPE_CODE_FORMAT_ERROR)
|
||||
@@ -42,21 +43,25 @@ public class DictTreeParam {
|
||||
/**
|
||||
* 用于区分多种类型的字典树 0.台账对象类型 1.自定义报表指标类型
|
||||
*/
|
||||
@ApiModelProperty(value = "0.台账对象类型 1.自定义报表指标类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 根据type自定义内容,type:0用于区分对象类型是101电网侧 102用户侧
|
||||
*/
|
||||
@ApiModelProperty(value = "根据type自定义内容,type:0用于区分对象类型是101电网侧 102用户侧")
|
||||
private String extend;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
@@ -93,9 +93,9 @@ public class SysLogAudit implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 日志发生事件
|
||||
* 日志发生时间
|
||||
*/
|
||||
@Excel(name = "日志发生事件", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "日志发生时间", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.gather.system.log.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.csv.entity.CsvExportParams;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -56,7 +58,8 @@ public class SysLogAuditServiceImpl extends ServiceImpl<SysLogAuditMapper, SysLo
|
||||
QueryWrapper<SysLogAudit> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(param.getUserName()), "sys_log_audit.User_name", param.getUserName())
|
||||
.between(StrUtil.isAllNotBlank(param.getSearchBeginTime(), param.getSearchEndTime()), "sys_log_audit.Log_time", param.getSearchBeginTime(), param.getSearchEndTime());
|
||||
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), "sys_log_audit.Log_time", LocalDateTimeUtil.parse(param.getSearchBeginTime() + " 00:00:00", DatePattern.NORM_DATETIME_FORMATTER))
|
||||
.le(StrUtil.isNotBlank(param.getSearchEndTime()), "sys_log_audit.Log_time", LocalDateTimeUtil.parse(param.getSearchEndTime() + " 23:59:59", DatePattern.NORM_DATETIME_FORMATTER));
|
||||
}
|
||||
queryWrapper.orderByDesc("sys_log_audit.Log_time");
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
@@ -67,7 +70,8 @@ public class SysLogAuditServiceImpl extends ServiceImpl<SysLogAuditMapper, SysLo
|
||||
QueryWrapper<SysLogAudit> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(param.getUserName()), "sys_log_audit.User_name", param.getUserName())
|
||||
.between(StrUtil.isAllNotBlank(param.getSearchBeginTime(), param.getSearchEndTime()), "sys_log_audit.Log_time", param.getSearchBeginTime(), param.getSearchEndTime());
|
||||
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), "sys_log_audit.Log_time", LocalDateTimeUtil.parse(param.getSearchBeginTime() + " 00:00:00", DatePattern.NORM_DATETIME_FORMATTER))
|
||||
.le(StrUtil.isNotBlank(param.getSearchEndTime()), "sys_log_audit.Log_time", LocalDateTimeUtil.parse(param.getSearchEndTime() + " 23:59:59", DatePattern.NORM_DATETIME_FORMATTER));
|
||||
}
|
||||
queryWrapper.orderByDesc("sys_log_audit.Log_time");
|
||||
List<SysLogAudit> list = this.list(queryWrapper);
|
||||
|
||||
@@ -36,41 +36,41 @@ import java.util.Map;
|
||||
public class SysRegResController extends BaseController {
|
||||
private final ISysRegResService sysRegResService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询注册版本列表")
|
||||
public HttpResult<SysRegResVO> listRegRes() {
|
||||
String methodDescribe = getMethodDescribe("listRegRes");
|
||||
LogUtil.njcnDebug(log, "{},查询参数为空", methodDescribe);
|
||||
SysRegResVO result = sysRegResService.listRegRes();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @GetMapping("/list")
|
||||
// @ApiOperation("查询注册版本列表")
|
||||
// public HttpResult<SysRegResVO> listRegRes() {
|
||||
// String methodDescribe = getMethodDescribe("listRegRes");
|
||||
// LogUtil.njcnDebug(log, "{},查询参数为空", methodDescribe);
|
||||
// SysRegResVO result = sysRegResService.listRegRes();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getRegResByType")
|
||||
@ApiOperation("根据类型id查询配置")
|
||||
@ApiImplicitParam(name = "type", value = "类型id,字典值", required = true)
|
||||
public HttpResult<SysRegRes> getRegResByType(@RequestParam("id") String typeId) {
|
||||
@ApiImplicitParam(name = "typeId", value = "类型id,字典值", required = true)
|
||||
public HttpResult<SysRegRes> getRegResByType(@RequestParam("typeId") String typeId) {
|
||||
String methodDescribe = getMethodDescribe("listByTypeId");
|
||||
LogUtil.njcnDebug(log, "{},查询参数为:{}", methodDescribe, typeId);
|
||||
SysRegRes result = sysRegResService.getRegResByType(typeId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增注册版本")
|
||||
@ApiImplicitParam(name = "sysRegRes", value = "注册版本对象", required = true)
|
||||
public HttpResult<Boolean> addRegRes(@RequestBody @Validated SysRegResParam param) {
|
||||
String methodDescribe = getMethodDescribe("addRegRes");
|
||||
LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, param);
|
||||
boolean result = sysRegResService.addRegRes(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
// @PostMapping("/add")
|
||||
// @ApiOperation("新增注册版本")
|
||||
// @ApiImplicitParam(name = "sysRegRes", value = "注册版本对象", required = true)
|
||||
// public HttpResult<Boolean> addRegRes(@RequestBody @Validated SysRegResParam param) {
|
||||
// String methodDescribe = getMethodDescribe("addRegRes");
|
||||
// LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, param);
|
||||
// boolean result = sysRegResService.addRegRes(param);
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
|
||||
@@ -5,16 +5,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>CN_Gather</artifactId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>activate-tool</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -30,21 +27,4 @@
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.tool.active.service.ActivateService;
|
||||
@@ -57,7 +58,12 @@ public class ActivateController extends BaseController {
|
||||
public HttpResult getLicense() {
|
||||
String methodDescribe = getMethodDescribe("checkLicense");
|
||||
LogUtil.njcnDebug(log, "{},获取许可信息", methodDescribe);
|
||||
ActivationCodePlaintext activationCodePlaintext = activateService.readLicenseFile();
|
||||
ActivationCodePlaintext activationCodePlaintext = null;
|
||||
try {
|
||||
activationCodePlaintext = activateService.readLicenseFile();
|
||||
} catch (BusinessException e) {
|
||||
methodDescribe = "无效的许可信息";
|
||||
}
|
||||
String macAddress = NetUtil.getLocalMacAddress();
|
||||
if (activationCodePlaintext == null) {
|
||||
activationCodePlaintext = new ActivationCodePlaintext();
|
||||
@@ -81,7 +87,6 @@ public class ActivateController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, activationCodePlaintext, methodDescribe);
|
||||
}
|
||||
|
||||
@ApiModel("验证设备激活码参数")
|
||||
@Data
|
||||
public static class VerifyActivationCodeParams {
|
||||
@ApiModelProperty(value = "激活码")
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
@@ -27,6 +28,7 @@ import java.util.Map;
|
||||
* @version 1.0
|
||||
* @data 2025/3/26 13:47
|
||||
*/
|
||||
@Slf4j
|
||||
public class Docx4jUtil {
|
||||
|
||||
/**
|
||||
@@ -434,7 +436,93 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新航
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param valueMap 数据
|
||||
* @param tableKeys keys
|
||||
* @param trPr 行样式
|
||||
* @param tcPrList 每个单元格的样式列表(用于保留各单元格独立的边框设置)
|
||||
* @param templateRPr 模板中的字体样式(可为null,为null时使用默认宋体10号)
|
||||
* @param centerFlag 是否居中
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, List<TcPr> tcPrList, RPr templateRPr, boolean centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (int i = 0; i < tableKeys.size(); i++) {
|
||||
String tableKey = tableKeys.get(i);
|
||||
Tc cell = factory.createTc();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
String value = valueMap.get(tableKey);
|
||||
Text text = factory.createText();
|
||||
text.setValue(value);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
|
||||
// 从模板复制字体样式
|
||||
RPr rPr = factory.createRPr();
|
||||
if (templateRPr != null) {
|
||||
// 复制字体
|
||||
if (templateRPr.getRFonts() != null) {
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
rFonts.setEastAsia(templateRPr.getRFonts().getEastAsia());
|
||||
rFonts.setAscii(templateRPr.getRFonts().getAscii());
|
||||
rFonts.setHAnsi(templateRPr.getRFonts().getHAnsi());
|
||||
rPr.setRFonts(rFonts);
|
||||
}
|
||||
// 复制字号
|
||||
if (templateRPr.getSz() != null) {
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
sz.setVal(templateRPr.getSz().getVal());
|
||||
rPr.setSz(sz);
|
||||
}
|
||||
if (templateRPr.getSzCs() != null) {
|
||||
HpsMeasure szCs = factory.createHpsMeasure();
|
||||
szCs.setVal(templateRPr.getSzCs().getVal());
|
||||
rPr.setSzCs(szCs);
|
||||
}
|
||||
} else {
|
||||
// 默认使用宋体10号
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
rFonts.setEastAsia("宋体");
|
||||
rFonts.setAscii("宋体");
|
||||
rFonts.setHAnsi("宋体");
|
||||
rPr.setRFonts(rFonts);
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
sz.setVal(new BigInteger("20"));
|
||||
rPr.setSz(sz);
|
||||
}
|
||||
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
pPr.setJc(jc);
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
// 不合格标红
|
||||
if (value != null && value.equals("不合格")) {
|
||||
Color color = factory.createColor();
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
}
|
||||
run.setRPr(rPr);
|
||||
|
||||
cell.getContent().add(paragraph);
|
||||
// 使用对应位置的单元格样式(保留边框设置)
|
||||
if (tcPrList != null && i < tcPrList.size()) {
|
||||
cell.setTcPr(tcPrList.get(i));
|
||||
}
|
||||
row.getContent().add(cell);
|
||||
row.setTrPr(trPr);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param valueMap 数据
|
||||
@@ -2139,5 +2227,83 @@ public class Docx4jUtil {
|
||||
return specialCaseP;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为Word文档添加水印
|
||||
* 使用页眉方式,但设置页眉高度为0,确保不影响文档结构
|
||||
*
|
||||
* @param wordPackage Word文档包
|
||||
* @param watermarkText 水印文字(如:"非正式")
|
||||
* @throws Exception 添加水印失败时抛出异常
|
||||
*/
|
||||
public static void addWatermarkToDocument(WordprocessingMLPackage wordPackage, String watermarkText) throws Exception {
|
||||
try {
|
||||
MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
|
||||
// 创建页眉部分
|
||||
org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart headerPart =
|
||||
new org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart();
|
||||
|
||||
// 将页眉部分添加到文档并获取关系ID
|
||||
org.docx4j.relationships.Relationship relationship = mainDocumentPart.addTargetPart(headerPart);
|
||||
|
||||
// 创建页眉对象
|
||||
org.docx4j.wml.Hdr hdr = factory.createHdr();
|
||||
|
||||
// 创建段落
|
||||
P paragraph = factory.createP();
|
||||
|
||||
// 创建Run
|
||||
R run = factory.createR();
|
||||
|
||||
// 使用VML textbox方式创建水印文本(绝对定位,显示在页面中部)
|
||||
String vmlString = String.format(
|
||||
"<w:pict xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" " +
|
||||
"xmlns:v=\"urn:schemas-microsoft-com:vml\">" +
|
||||
"<v:shape style=\"position:absolute;left:0;text-align:center;margin-left:0;margin-top:0;" +
|
||||
"width:500pt;height:200pt;z-index:-251658240;" +
|
||||
"mso-position-horizontal:center;mso-position-horizontal-relative:page;" +
|
||||
"mso-position-vertical:center;mso-position-vertical-relative:page\" " +
|
||||
"fillcolor=\"none\" stroked=\"f\">" +
|
||||
"<v:textbox style=\"mso-fit-shape-to-text:t\">" +
|
||||
"<w:txbxContent>" +
|
||||
"<w:p><w:pPr><w:jc w:val=\"center\"/></w:pPr>" +
|
||||
"<w:r><w:rPr>" +
|
||||
"<w:color w:val=\"D8D8D8\"/>" +
|
||||
"<w:sz w:val=\"240\"/>" +
|
||||
"<w:szCs w:val=\"240\"/>" +
|
||||
"<w:rFonts w:ascii=\"微软雅黑\" w:eastAsia=\"微软雅黑\" w:hAnsi=\"微软雅黑\"/>" +
|
||||
"</w:rPr><w:t>%s</w:t></w:r></w:p>" +
|
||||
"</w:txbxContent></v:textbox>" +
|
||||
"</v:shape></w:pict>", watermarkText);
|
||||
|
||||
// 解析VML并添加到Run
|
||||
Object vmlObject = XmlUtils.unmarshalString(vmlString);
|
||||
run.getContent().add(vmlObject);
|
||||
|
||||
paragraph.getContent().add(run);
|
||||
hdr.getContent().add(paragraph);
|
||||
headerPart.setJaxbElement(hdr);
|
||||
|
||||
// 获取或创建节属性(SectPr)
|
||||
SectPr sectPr = mainDocumentPart.getJaxbElement().getBody().getSectPr();
|
||||
if (sectPr == null) {
|
||||
sectPr = factory.createSectPr();
|
||||
mainDocumentPart.getJaxbElement().getBody().setSectPr(sectPr);
|
||||
}
|
||||
|
||||
// 创建页眉引用并关联到节属性
|
||||
org.docx4j.wml.HeaderReference headerReference = factory.createHeaderReference();
|
||||
headerReference.setId(relationship.getId());
|
||||
headerReference.setType(org.docx4j.wml.HdrFtrRef.DEFAULT);
|
||||
sectPr.getEGHdrFtrReferences().add(headerReference);
|
||||
|
||||
log.info("成功添加水印:{}", watermarkText);
|
||||
} catch (Exception e) {
|
||||
log.error("添加水印失败:{}", e.getMessage(), e);
|
||||
throw new Exception("添加水印失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "登录/注销")
|
||||
@Api(tags = "登录-注销")
|
||||
@RequestMapping("/admin")
|
||||
@RequiredArgsConstructor
|
||||
public class AuthController extends BaseController {
|
||||
|
||||
@@ -153,7 +153,7 @@ public class SysFunctionController extends BaseController {
|
||||
@OperateInfo(operateType = OperateType.UPDATE, info = LogEnum.SYSTEM_MEDIUM)
|
||||
@PostMapping("/assignFunctionByRoleId")
|
||||
@ApiOperation("角色分配菜单")
|
||||
@ApiImplicitParam(name = "roleFunctionComponent", value = "角色信息", required = true)
|
||||
@ApiImplicitParam(name = "param", value = "角色信息", required = true)
|
||||
public HttpResult<Boolean> assignFunctionByRoleId(@RequestBody @Validated SysRoleParam.RoleBindFunction param) {
|
||||
String methodDescribe = getMethodDescribe("assignFunctionByRoleId");
|
||||
LogUtil.njcnDebug(log, "{},传入的角色id和资源id集合为:{}", methodDescribe, param);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SysRoleController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增角色信息")
|
||||
@ApiImplicitParam(name = "roleParam", value = "角色信息", required = true)
|
||||
@ApiImplicitParam(name = "sysRoleParam", value = "角色信息", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated SysRoleParam sysRoleParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},角色信息数据为:{}", methodDescribe, sysRoleParam);
|
||||
|
||||
@@ -102,11 +102,7 @@ public class SysUserController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/updatePassword")
|
||||
@ApiOperation("修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true),
|
||||
@ApiImplicitParam(name = "oldPassword", value = "旧密码", required = true),
|
||||
@ApiImplicitParam(name = "newPassword", value = "新密码", required = true)
|
||||
})
|
||||
@ApiImplicitParam(name = "param", value = "修改密码参数", required = true)
|
||||
public HttpResult<Boolean> updatePassword(@RequestBody @Validated SysUserParam.SysUserUpdatePasswordParam param) {
|
||||
String methodDescribe = getMethodDescribe("updatePassword");
|
||||
LogUtil.njcnDebug(log, "{},用户id:{},用户旧密码:{},新密码:{}", methodDescribe, param.getId(), param.getOldPassword(), param.getNewPassword());
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AuthGlobalFilter implements Filter, Ordered {
|
||||
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login","/admin/getPublicKey", "/report/generateReport");
|
||||
private final static List<String> IGNORE_URI = Arrays.asList("/doc.html","/v3/api-docs","/admin/login","/admin/getPublicKey", "/report/generateReport");
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
@@ -42,7 +42,7 @@ public class AuthGlobalFilter implements Filter, Ordered {
|
||||
res.setContentType("application/json; charset=utf-8");
|
||||
|
||||
String requestURI = req.getRequestURI();
|
||||
if (IGNORE_URI.contains(requestURI)) {
|
||||
if (IGNORE_URI.contains(requestURI) || requestURI.startsWith("/webjars") || requestURI.startsWith("/swagger-resources")) {
|
||||
filterChain.doFilter(req, res);
|
||||
} else {
|
||||
String accessTokenStr = req.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
|
||||
Reference in New Issue
Block a user