Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7a90ebeb4 | ||
|
|
67665d3762 | ||
|
|
41252af4e9 | ||
|
|
2869f66154 | ||
|
|
2bdaabac6e | ||
|
|
4b41e2edd1 | ||
|
|
5fa09bb41b | ||
|
|
c96cadc5d1 | ||
|
|
b471a05181 | ||
|
|
e42a2c8309 | ||
| ea585a65ff | |||
|
|
59ba5c0a0c | ||
|
|
99d43041cb | ||
|
|
aa5f57a856 | ||
|
|
9fc0fbcbcf | ||
|
|
434dc676ce | ||
| ea83963d33 | |||
|
|
257df0a511 | ||
| 496cff6c11 | |||
|
|
484f9c9f4c | ||
|
|
19b69eed0e | ||
|
|
b165365203 | ||
|
|
a42dcd1d4b | ||
|
|
be3df5c497 | ||
|
|
7b951fa4b6 | ||
|
|
89a7b5b8f6 | ||
|
|
102aa504e6 | ||
| d1cbfcedcc | |||
| 116563f13e | |||
|
|
55bf90d0af | ||
|
|
7ac01b0f5e | ||
| 1a28d25026 | |||
|
|
92b0640f9c | ||
|
|
4a2fb595d0 | ||
| 56dd19b32e | |||
|
|
8460574f10 | ||
| 6f890daad6 | |||
|
|
6727dee61e | ||
|
|
3fcad5ff76 | ||
| 1fe7866970 | |||
|
|
b96d0cdeb1 | ||
| 0c30603f31 | |||
|
|
64bdba9fa2 | ||
|
|
c7a45b5500 | ||
| 42701db2d5 |
@@ -74,6 +74,29 @@
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j -->
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j</artifactId>
|
||||
<version>3.3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.0</version> <!-- 您可以根据需要选择其他版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.12.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author chendaofei
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "预检测")
|
||||
@RestController
|
||||
@@ -30,15 +33,6 @@ public class PreDetectionController extends BaseController {
|
||||
|
||||
private final PreDetectionService preDetectionService;
|
||||
|
||||
private final DetectionServiceImpl detectionServiceImpl;
|
||||
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
|
||||
|
||||
/**
|
||||
* 开始检测
|
||||
*/
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.njcn.gather.detection.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2024/12/10 14:25
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "守时检测")
|
||||
@RestController
|
||||
@RequestMapping("/punctuality")
|
||||
@RequiredArgsConstructor
|
||||
public class PunctualityController extends BaseController {
|
||||
|
||||
// private final PunctualityService punctualityService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/deliveryTime")
|
||||
@ApiOperation("下发守时检测")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<?> list(@RequestBody Object param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
// punctualityService.triggerTimeMark();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,13 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.po.IcdCheckData;
|
||||
import com.njcn.gather.detection.pojo.po.SourceCompareDev;
|
||||
import com.njcn.gather.detection.pojo.vo.*;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
@@ -18,12 +21,12 @@ import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
@@ -52,6 +55,8 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.njcn.gather.detection.util.socket.FormalTestManager.harmonicRelationMap;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -67,6 +72,11 @@ public class SocketDevResponseService {
|
||||
// ISO 8601格式
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
private DevPhaseSequenceParam devPhaseSequenceParam;
|
||||
|
||||
private List<String> dataTypeList;
|
||||
|
||||
private List<String> icdTypeList;
|
||||
|
||||
private final List<String> nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(), DicDataEnum.VOLTAGE.getCode(), DicDataEnum.F.getCode()).collect(Collectors.toList());
|
||||
private final List<String> harmonicList = Stream.of(DicDataEnum.HV.getCode(), DicDataEnum.HI.getCode(), DicDataEnum.HP.getCode(), DicDataEnum.HSV.getCode(), DicDataEnum.HSI.getCode()).collect(Collectors.toList());
|
||||
@@ -105,6 +115,11 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
Set<String> failComm = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 存放从装置收到的icd校验数据。key为icdType,value为IcdCheckData
|
||||
*/
|
||||
Map<String, IcdCheckData> icdCheckDataMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 保存成功的协议
|
||||
*/
|
||||
@@ -761,83 +776,150 @@ public class SocketDevResponseService {
|
||||
System.out.println(successComm.size() + "=====" + FormalTestManager.monitorIdListComm.size());
|
||||
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
|
||||
//开始下源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
List<SourceIssue> sourceIssues;
|
||||
if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getOperateType())) {
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(param.getCode());
|
||||
storageParam.setScriptId(param.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
issueParam.setIndexList(indexes);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||
} else {
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
}
|
||||
//正式检测
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||
// 存放所有检测小项
|
||||
SocketManager.addSourceList(sourceIssues);
|
||||
// 按照大项分组。key为大项code,value为小项个数
|
||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||
SocketManager.initMap(sourceIssueMap);
|
||||
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.get(0).getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + stepBegin);
|
||||
webSocketVO.setDesc(null);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
|
||||
} else if (SourceOperateCodeEnum.PRE_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.COEFFICIENT_TEST.getValue().equals(param.getOperateType())) {
|
||||
//预检测的相序检测 以及系数校验都需要进行相序检测
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
} else if (SourceOperateCodeEnum.TEST_TEM_START.getValue().equals(param.getOperateType())) {
|
||||
//暂停检测后的继续检测
|
||||
System.out.println("进入暂停后的继续检测》》》》》》》》》》》》》》》》》》》》》》》》》》》" + "剩余检测小项" + SocketManager.getSourceList().size());
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssue));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
successComm.clear();
|
||||
failComm.clear();
|
||||
icdCheckDataMap.clear();
|
||||
|
||||
dataTypeList = pqScriptDtlsService.getScriptToIcdCheckInfo(param);
|
||||
icdTypeList = FormalTestManager.devList.stream().map(PreDetection::getIcdType).distinct().collect(Collectors.toList());
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue());
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("dataType", dataTypeList);
|
||||
map.put("icdType", icdTypeList.get(0));
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
System.out.println("开始脚本与icd校验:++++++++++");
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
completeJudgment(param);
|
||||
} else if (socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue())) {
|
||||
String data = socketDataMsg.getData();
|
||||
IcdCheckData icdCheckData = JSON.parseObject(data, IcdCheckData.class);
|
||||
|
||||
boolean isContinue = true;
|
||||
for (int i = 0; i < icdCheckData.getResultData().size(); i++) {
|
||||
IcdCheckData.ResultData item = icdCheckData.getResultData().get(i);
|
||||
Integer errorType = getErrorType(item.getDesc(), item.getPhaseResult());
|
||||
// 校验脚本与icd校验失败
|
||||
if (errorType.equals(0)) {
|
||||
isContinue = false;
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("icdType", icdCheckData.getIcdType());
|
||||
DetectionCodeEnum anEnum = DetectionCodeEnum.getDetectionCodeByCode(item.getDesc());
|
||||
map.put("dataType", anEnum.getMessage());
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setData(JSON.toJSONString(map));
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue());
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.SUCCESS.getCode());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
CnSocketUtil.quitSend(param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
icdCheckDataMap.put(icdCheckData.getIcdType(), icdCheckData);
|
||||
|
||||
if (isContinue) {
|
||||
//System.out.println("icdCheckDataMap.size()="+icdCheckDataMap.size()+",icdTypeList.size()="+icdTypeList.size());
|
||||
if (icdCheckDataMap.size() == icdTypeList.size()) {
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
|
||||
//开始下源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
List<SourceIssue> sourceIssues;
|
||||
if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getOperateType())) {
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(param.getCode());
|
||||
storageParam.setScriptId(param.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
issueParam.setIndexList(indexes);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||
} else {
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
}
|
||||
//正式检测
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||
// 使用 LinkedHashMap 保持分组顺序
|
||||
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
SourceIssue::getType,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
||||
sourceIssues = groupedIssues.values().stream()
|
||||
.flatMap(List::stream)
|
||||
.collect(Collectors.toList());
|
||||
// 存放所有检测小项
|
||||
SocketManager.addSourceList(sourceIssues);
|
||||
// 按照大项分组。key为大项code,value为小项个数
|
||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||
SocketManager.initMap(sourceIssueMap);
|
||||
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.get(0).getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + stepBegin);
|
||||
webSocketVO.setDesc(null);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
|
||||
} else if (SourceOperateCodeEnum.PRE_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.COEFFICIENT_TEST.getValue().equals(param.getOperateType())) {
|
||||
//预检测的相序检测 以及系数校验都需要进行相序检测
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
} else if (SourceOperateCodeEnum.TEST_TEM_START.getValue().equals(param.getOperateType())) {
|
||||
//暂停检测后的继续检测
|
||||
System.out.println("进入暂停后的继续检测》》》》》》》》》》》》》》》》》》》》》》》》》》》" + "剩余检测小项" + SocketManager.getSourceList().size());
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssue));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
// 发送下一个脚本与icd校验
|
||||
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
||||
if(ObjectUtil.isNotNull(icdType)){
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("dataType", dataTypeList);
|
||||
map.put("icdType", icdType);
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
System.out.println("开始脚本与icd校验:++++++++++");
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
@@ -864,6 +946,34 @@ public class SocketDevResponseService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误类型
|
||||
*
|
||||
* @param desc
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private Integer getErrorType(String desc, DevData.SqlDataDTO.ListDTO list) {
|
||||
if (ObjectUtil.isNotNull(list)) {
|
||||
if (DetectionCodeEnum.MAG.getCode().equals(desc) || DetectionCodeEnum.DUR.getCode().equals(desc)) {
|
||||
if (ObjectUtil.isNull(list.getA()) && ObjectUtil.isNull(list.getB()) && ObjectUtil.isNull(list.getC()) && ObjectUtil.isNull(list.getT())) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else if (DetectionCodeEnum.I_UNBAN.getCode().equals(desc) || DetectionCodeEnum.V_UNBAN.getCode().equals(desc)) {
|
||||
if (ObjectUtil.isNotNull(list.getA()) && list.getA().equals(0.0) && ObjectUtil.isNotNull(list.getB()) && list.getB().equals(1.0) && ObjectUtil.isNotNull(list.getC()) && list.getC().equals(1.0) || ObjectUtil.isNotNull(list.getT()) && list.getT().equals(1.0)) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtil.isNotNull(list.getA()) && list.getA().equals(1.0) && ObjectUtil.isNotNull(list.getB()) && list.getB().equals(1.0) && ObjectUtil.isNotNull(list.getC()) && list.getC().equals(1.0) || ObjectUtil.isNotNull(list.getT()) && list.getT().equals(1.0)) {
|
||||
return 1; // 装置上送错误
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; // icd文件与脚本不匹配
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 相序校验
|
||||
@@ -1080,7 +1190,7 @@ public class SocketDevResponseService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(),param.getUserId());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
successComm.clear();
|
||||
@@ -1093,6 +1203,9 @@ public class SocketDevResponseService {
|
||||
break;
|
||||
|
||||
case NORMAL_RESPONSE:
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
|
||||
break;
|
||||
@@ -1270,7 +1383,6 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param issue
|
||||
* @return key为V或I,value为对应的源下发信息
|
||||
*/
|
||||
@@ -1298,8 +1410,8 @@ public class SocketDevResponseService {
|
||||
List<DevData.SqlDataDTO> data,
|
||||
List<DevData.SqlDataDTO> dataPhase) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
if(isPhaseAngle){
|
||||
if(CollUtil.isNotEmpty(data)&&CollUtil.isNotEmpty(dataPhase)){
|
||||
if (isPhaseAngle) {
|
||||
if (CollUtil.isNotEmpty(data) && CollUtil.isNotEmpty(dataPhase)) {
|
||||
if (data.size() == dataPhase.size()) {
|
||||
DevData.SqlDataDTO.ListDTO dto = data.get(0).getList();
|
||||
DevData.SqlDataDTO.ListDTO phase = dataPhase.get(0).getList();
|
||||
@@ -1309,11 +1421,11 @@ public class SocketDevResponseService {
|
||||
str.append(")");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
DevData.SqlDataDTO.ListDTO dto = data.get(0).getList();
|
||||
str.append("装置(" + type + "a=" + String.format("%.4f", dto.getA()) +
|
||||
type + "b=" + String.format("%.4f", dto.getB()) +
|
||||
type + "c=" + String.format("%.4f", dto.getC()) );
|
||||
type + "b=" + String.format("%.4f", dto.getB()) +
|
||||
type + "c=" + String.format("%.4f", dto.getC()));
|
||||
str.append(")");
|
||||
}
|
||||
return str.toString();
|
||||
@@ -1389,11 +1501,11 @@ public class SocketDevResponseService {
|
||||
Map<String, SourceIssue.ChannelListDTO> sourceMap = channelList.stream()
|
||||
.collect(Collectors.toMap(x -> x.getChannelType(), Function.identity()));
|
||||
Boolean a = getaBoolean(sourceMap.get(type + "a"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getA() : null,
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getA(): null);
|
||||
Boolean b = getaBoolean(sourceMap.get(type + "b"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getB(): null,
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getB(): null);
|
||||
Boolean c = getaBoolean(sourceMap.get(type + "c"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getC(): null,
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getC(): null);
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getA() : null);
|
||||
Boolean b = getaBoolean(sourceMap.get(type + "b"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getB() : null,
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getB() : null);
|
||||
Boolean c = getaBoolean(sourceMap.get(type + "c"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getC() : null,
|
||||
CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getC() : null);
|
||||
compareDev.setIsQualified(a && b && c);
|
||||
compareDev.setDesc(name + (compareDev.getIsQualified() ? "合格->" : "不合格->") + stepTag + desc + stepTag + devMessage(type, data, dataPhase));
|
||||
return compareDev;
|
||||
@@ -1401,25 +1513,26 @@ public class SocketDevResponseService {
|
||||
|
||||
/**
|
||||
* 相须校验-从幅值、相角两个维度判断是否合格
|
||||
*
|
||||
* @param channelListDTO
|
||||
* @param devData
|
||||
* @param devPhase
|
||||
* @return
|
||||
*/
|
||||
private Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) {
|
||||
private Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) {
|
||||
Boolean isDev = false;
|
||||
Boolean isPhase = false;
|
||||
if(ObjectUtil.isNotNull(devData)){
|
||||
isDev= NumberUtil.isIn(BigDecimal.valueOf(devData),
|
||||
if (ObjectUtil.isNotNull(devData)) {
|
||||
isDev = NumberUtil.isIn(BigDecimal.valueOf(devData),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05));
|
||||
}
|
||||
if(isPhaseAngle){
|
||||
if(ObjectUtil.isNotNull(devPhase)){
|
||||
if (isPhaseAngle) {
|
||||
if (ObjectUtil.isNotNull(devPhase)) {
|
||||
isPhase = phaseBoolean(channelListDTO, devPhase);
|
||||
}
|
||||
}else{
|
||||
isPhase=true;
|
||||
} else {
|
||||
isPhase = true;
|
||||
}
|
||||
return isDev && isPhase;
|
||||
|
||||
@@ -1433,7 +1546,7 @@ public class SocketDevResponseService {
|
||||
* @param devPhase 装置返回角度
|
||||
* @return
|
||||
*/
|
||||
private Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) {
|
||||
private Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) {
|
||||
Double phase = devPhase;
|
||||
if (devPhase < -180) {
|
||||
phase = devPhase + 360;
|
||||
@@ -1509,6 +1622,9 @@ public class SocketDevResponseService {
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())) {
|
||||
initXiManager(param);
|
||||
}
|
||||
|
||||
harmonicRelationMap.put(DetectionCodeEnum.V2_50.getCode(),DetectionCodeEnum.U1.getCode());
|
||||
harmonicRelationMap.put(DetectionCodeEnum.I2_50.getCode(),DetectionCodeEnum.I1.getCode());
|
||||
}
|
||||
|
||||
//初始化系数校验参数
|
||||
@@ -1588,8 +1704,9 @@ public class SocketDevResponseService {
|
||||
adNonHarmonicResult.setMonitorId(temId);
|
||||
adNonHarmonicResult.setScriptId(param.getScriptId());
|
||||
adNonHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
|
||||
adNonHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adNonHarmonicResult.setDataType("avg");
|
||||
adNonHarmonicResult.setDataType(sourceIssue.getDataType());
|
||||
|
||||
Double a = listDTO.getA();
|
||||
Double b = listDTO.getB();
|
||||
@@ -1610,7 +1727,10 @@ public class SocketDevResponseService {
|
||||
adNonHarmonicResultList.add(adNonHarmonicResult);
|
||||
}
|
||||
} else {
|
||||
for (DevData.SqlDataHarmDTO sqlDataDTO : data.getSqlDataHarm()) {
|
||||
|
||||
for(int j=0;j<data.getSqlDataHarm().size();j++){
|
||||
DevData.SqlDataHarmDTO sqlDataDTO = data.getSqlDataHarm().get(j);
|
||||
String dui = harmonicRelationMap.get(sqlDataDTO.getDesc());
|
||||
AdHarmonicResult adHarmonicResult = new AdHarmonicResult();
|
||||
adHarmonicResult.setTimeId(localDateTime);
|
||||
|
||||
@@ -1618,11 +1738,11 @@ public class SocketDevResponseService {
|
||||
adHarmonicResult.setScriptId(param.getScriptId());
|
||||
adHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adHarmonicResult.setDataType("avg");
|
||||
adHarmonicResult.setDataType(sourceIssue.getDataType());
|
||||
|
||||
if (!DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().stream().filter(it->it.getDesc().equals(dui)).collect(Collectors.toList()).get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
Double cV = vvv.getC();
|
||||
@@ -1682,10 +1802,7 @@ public class SocketDevResponseService {
|
||||
}
|
||||
adHarmonicResultList.add(adHarmonicResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1754,4 +1871,47 @@ public class SocketDevResponseService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 脚本与设备校验
|
||||
*
|
||||
* @param param
|
||||
* @param socketDataMsg
|
||||
*/
|
||||
public void scriptToDeviceCheck(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
String data = socketDataMsg.getData();
|
||||
DevData devData = JSON.parseObject(data, DevData.class);
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
//SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
List<String> dataTypeList = new ArrayList<>();
|
||||
devData.getSqlData().forEach(obj -> {
|
||||
dataTypeList.add(obj.getDesc());
|
||||
});
|
||||
devData.getSqlDataHarm().forEach(obj -> {
|
||||
dataTypeList.add(obj.getDesc());
|
||||
});
|
||||
List<String> dataTypeCopy = new ArrayList<>(devPhaseSequenceParam.getDataType());
|
||||
dataTypeCopy.removeAll(dataTypeList);
|
||||
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case NORMAL_RESPONSE:
|
||||
break;
|
||||
case DEV_ERROR:
|
||||
break;
|
||||
case DEV_TARGET:
|
||||
break;
|
||||
case RE_OPERATE:
|
||||
break;
|
||||
case MESSAGE_PARSING_ERROR:
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,14 +357,10 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
int ignoreCount;
|
||||
int readData;
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
|
||||
ignoreCount = 1;
|
||||
readData = 2;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
ignoreCount = 2;
|
||||
readData = 5;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
} else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) {
|
||||
ignoreCount = 5;
|
||||
readData = 1;
|
||||
@@ -372,9 +368,13 @@ public class SocketSourceResponseService {
|
||||
} else {
|
||||
ignoreCount = 5;
|
||||
readData = 5;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
//区分实时数据还是分钟数据
|
||||
if ("real".equals(sourceIssue.getDataType())) {
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
} else {
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.detection.pojo.constant;
|
||||
|
||||
/**
|
||||
* 通信相关的常量
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/4/15 14:11
|
||||
*/
|
||||
public interface DetectionCommunicateConstant {
|
||||
|
||||
String SOURCE_CHANNEL_NAME = "AUTO_DETECTION_SOURCE";
|
||||
|
||||
String DEVICE_CHANNEL_NAME = "AUTO_DETECTION_DEV";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -38,6 +38,8 @@ public enum SourceOperateCodeEnum {
|
||||
DATA_CHNFACTOR$01("DATA_CHNFACTOR$01","校验系数获取"),
|
||||
DATA_CHNFACTOR$02("DATA_CHNFACTOR$02","校验系数下发"),
|
||||
|
||||
VERIFY_MAPPING$01("VERIFY_MAPPING$01","脚本与icd校验"),
|
||||
|
||||
|
||||
/**
|
||||
* 请求操作类型对应实体中 requestId
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.gather.detection.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-04-10
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class IcdCheckData {
|
||||
|
||||
private String icdType;
|
||||
|
||||
private List<ResultData> resultData;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResultData {
|
||||
private String type;
|
||||
|
||||
private String desc;
|
||||
|
||||
private DevData.SqlDataDTO.ListDTO phaseResult;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class DetectionData {
|
||||
private Double num;
|
||||
|
||||
/**
|
||||
* 是否是符合数据
|
||||
* 1.合格 2.不合格 3.网络超时 4.无法处理 5.不参与误差比较
|
||||
*/
|
||||
private Integer isData;
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.njcn.gather.detection.service;
|
||||
|
||||
/**
|
||||
* @Description: 守时检测流程
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/10 14:23
|
||||
*/
|
||||
public interface PunctualityService {
|
||||
|
||||
/**
|
||||
* 触发时间标识
|
||||
*/
|
||||
void triggerTimeMark();
|
||||
}
|
||||
@@ -32,11 +32,10 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.gather.detection.util.socket.UnitUtil.unit;
|
||||
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
@@ -115,45 +114,21 @@ public class DetectionServiceImpl {
|
||||
case I_ABSOLUTELY:
|
||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, code);
|
||||
/**
|
||||
* 谐波电压
|
||||
* 谐波
|
||||
*/
|
||||
case HV:
|
||||
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
|
||||
if (ObjectUtil.isNotNull(harmV)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmV), code);
|
||||
return harmV.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 谐波电流
|
||||
*/
|
||||
case HI:
|
||||
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
|
||||
AdHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 2);
|
||||
if (ObjectUtil.isNotNull(harmI)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmI), code);
|
||||
return harmI.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
return resultFlag(harmV, harmI, code);
|
||||
/**
|
||||
* 间谐波电压
|
||||
* 间谐波
|
||||
*/
|
||||
case HSV:
|
||||
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
|
||||
if (ObjectUtil.isNotNull(harmInV)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInV), code);
|
||||
return harmInV.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
/**
|
||||
* 间谐波电流
|
||||
*/
|
||||
case HSI:
|
||||
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
|
||||
AdHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 1);
|
||||
if (ObjectUtil.isNotNull(harmInI)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmInI), code);
|
||||
return harmInI.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
return resultFlag(harmInV, harmInI, code);
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
*/
|
||||
@@ -205,6 +180,21 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public Integer resultFlag(AdHarmonicResult v, AdHarmonicResult i, String code) {
|
||||
List<AdHarmonicResult> info = new ArrayList<>();
|
||||
if (ObjectUtil.isNotNull(v)) {
|
||||
info.add(v);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(i)) {
|
||||
info.add(i);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
detectionDataDealService.acceptAdResult(info, code);
|
||||
return getInteger(info.stream().map(x -> x.getResultFlag()).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
public Integer isUnknownQualified(List<DevData> dev,
|
||||
Map<String, String> devIdMapComm,
|
||||
List<ErrDtlsCheckDataVO> errDtlsCheckData,
|
||||
@@ -229,17 +219,14 @@ public class DetectionServiceImpl {
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
result.setDataType(sourceIssue.getDataType());
|
||||
Integer isQualified;
|
||||
String valueTypeCode;
|
||||
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData)) {
|
||||
result.setAdType(dtlsCheckData.get(0).getValueType());
|
||||
isQualified = dtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = dtlsCheckData.get(0).getValueTypeCode();
|
||||
} else {
|
||||
isQualified = 4;
|
||||
valueTypeCode = "";
|
||||
}
|
||||
List<DetectionData> resultFlag = new ArrayList<>();
|
||||
map.forEach((key, value) -> {
|
||||
@@ -247,9 +234,9 @@ public class DetectionServiceImpl {
|
||||
if (CollUtil.isNotEmpty(checkData)) {
|
||||
DetectionData detectionData;
|
||||
if (DUR.equals(devIndex)) {
|
||||
detectionData = rangeDURComparisonList(value, isQualified, valueTypeCode, new ArrayList<>(), sourceIssue.getFFreq(), checkData.get(0).getValue(), dataRule);
|
||||
detectionData = rangeDURComparisonList(value, isQualified, new ArrayList<>(), sourceIssue.getFFreq(), checkData.get(0).getValue(), dataRule);
|
||||
} else {
|
||||
detectionData = rangeComparisonList(value, isQualified, valueTypeCode, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule);
|
||||
detectionData = rangeComparisonList(value, isQualified, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule);
|
||||
}
|
||||
if (key.equals(TYPE_T)) {
|
||||
result.setTValue(JSON.toJSONString(detectionData));
|
||||
@@ -290,7 +277,6 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
if (devIndex.contains("I")) {
|
||||
fundCode = DetectionCodeEnum.I1.getCode();
|
||||
;
|
||||
type = I;
|
||||
fData = sourceIssue.getFIn();
|
||||
if (devIndex.contains("50")) {
|
||||
@@ -303,7 +289,7 @@ public class DetectionServiceImpl {
|
||||
if (devIndex.contains("P")) {
|
||||
type = P;
|
||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01;
|
||||
fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||
}
|
||||
Map<String, Map<Double, List<Double>>> devHarmMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
|
||||
if (CollUtil.isNotEmpty(devHarmMap)) {
|
||||
@@ -319,16 +305,14 @@ public class DetectionServiceImpl {
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData)) {
|
||||
harmonicResult.setAdType(dtlsCheckData.get(0).getValueType());
|
||||
isQualified = dtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = dtlsCheckData.get(0).getValueTypeCode();
|
||||
} else {
|
||||
isQualified = 4;
|
||||
valueTypeCode = "";
|
||||
}
|
||||
//电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, valueTypeCode, new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, valueTypeCode, new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, valueTypeCode, new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType("avg");
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType(sourceIssue.getDataType());
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
|
||||
@@ -391,16 +375,14 @@ public class DetectionServiceImpl {
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
result.setDataType(sourceIssue.getDataType());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
Integer isQualified = 4;
|
||||
String valueTypeCode = "";
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData)) {
|
||||
result.setAdType(dtlsCheckData.get(0).getValueType());
|
||||
isQualified = dtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = dtlsCheckData.get(0).getValueTypeCode();
|
||||
if (CollUtil.isNotEmpty(dtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = dtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
@@ -408,30 +390,35 @@ public class DetectionServiceImpl {
|
||||
if (map.containsKey(TYPE_T)) {
|
||||
List<ErrDtlsCheckDataVO> checkDataT = dtlsCheckData.stream().filter(x -> TYPE_T.equals(x.getPhase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkDataT)) {
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_T), isQualified, valueTypeCode, pqErrSysDtls, fData, checkDataT.get(0).getValue(), dataRule);
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_T), isQualified, pqErrSysDtls, fData, checkDataT.get(0).getValue(), dataRule);
|
||||
result.setTValue(JSON.toJSONString(t));
|
||||
result.setResultFlag(t.getIsData());
|
||||
}
|
||||
} else {
|
||||
List<DetectionData> resultFlag = new ArrayList<>();
|
||||
//取出源所对应的相别信息
|
||||
List<ErrDtlsCheckDataVO> checkDataA = dtlsCheckData.stream().filter(x -> TYPE_A.equals(x.getPhase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkDataA)) {
|
||||
DetectionData a = rangeComparisonList(map.get(TYPE_A), isQualified, valueTypeCode, pqErrSysDtls, fData, checkDataA.get(0).getValue(), dataRule);
|
||||
resultFlag.add(a);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
}
|
||||
List<ErrDtlsCheckDataVO> checkDataB = dtlsCheckData.stream().filter(x -> TYPE_B.equals(x.getPhase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkDataB)) {
|
||||
DetectionData b = rangeComparisonList(map.get(TYPE_B), isQualified, valueTypeCode, pqErrSysDtls, fData, checkDataB.get(0).getValue(), dataRule);
|
||||
resultFlag.add(b);
|
||||
result.setBValue(JSON.toJSONString(b));
|
||||
}
|
||||
List<ErrDtlsCheckDataVO> checkDataC = dtlsCheckData.stream().filter(x -> TYPE_C.equals(x.getPhase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkDataC)) {
|
||||
DetectionData c = rangeComparisonList(map.get(TYPE_C), isQualified, valueTypeCode, pqErrSysDtls, fData, checkDataC.get(0).getValue(), dataRule);
|
||||
resultFlag.add(c);
|
||||
result.setCValue(JSON.toJSONString(c));
|
||||
Map<String, BiConsumer<AdNonHarmonicResult, DetectionData>> setters = new HashMap<>();
|
||||
setters.put(TYPE_A, (r, d) -> r.setAValue(JSON.toJSONString(d)));
|
||||
setters.put(TYPE_B, (r, d) -> r.setBValue(JSON.toJSONString(d)));
|
||||
setters.put(TYPE_C, (r, d) -> r.setCValue(JSON.toJSONString(d)));
|
||||
|
||||
List<String> phases = Arrays.asList(TYPE_A, TYPE_B, TYPE_C);
|
||||
for (String phase : phases) {
|
||||
List<ErrDtlsCheckDataVO> checkData = dtlsCheckData.stream()
|
||||
.filter(x -> phase.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(checkData)) {
|
||||
List<Double> phaseValue = map.get(phase);
|
||||
// 注意:如果map中不存在该phase的键,phaseValue可能为null,需确保map包含该键
|
||||
DetectionData detectionData = rangeComparisonList(phaseValue, isQualified, pqErrSysDtls, fData, checkData.get(0).getValue(), dataRule);
|
||||
resultFlag.add(detectionData);
|
||||
BiConsumer<AdNonHarmonicResult, DetectionData> setter = setters.get(phase);
|
||||
if (setter != null) {
|
||||
setter.accept(result, detectionData);
|
||||
} else {
|
||||
// 处理未定义的setter的情况
|
||||
throw new IllegalArgumentException("Setter not defined for phase: " + phase);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.setResultFlag(setResultFlag(resultFlag));
|
||||
}
|
||||
@@ -479,7 +466,6 @@ public class DetectionServiceImpl {
|
||||
if (I.equals(type)) {
|
||||
fData = sourceIssue.getFIn();
|
||||
fundCode = DetectionCodeEnum.I1.getCode();
|
||||
;
|
||||
if (num == 1) {
|
||||
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
||||
} else {
|
||||
@@ -487,7 +473,7 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
}
|
||||
if (P.equals(type)) {
|
||||
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01;
|
||||
fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||
}
|
||||
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
|
||||
@@ -500,19 +486,19 @@ public class DetectionServiceImpl {
|
||||
harmonicResult.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
Integer isQualified = 4;
|
||||
String valueTypeCode = "";
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
harmonicResult.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
isQualified = errDtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = errDtlsCheckData.get(0).getValueTypeCode();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
String finalHarmCode = harmCode;
|
||||
List<ErrDtlsCheckDataVO> adDtlsCheckData = errDtlsCheckData.stream().filter(x -> finalHarmCode.equals(x.getValueTypeCode())).collect(Collectors.toList());
|
||||
harmonicResult.setAdType(adDtlsCheckData.get(0).getValueType());
|
||||
isQualified = adDtlsCheckData.get(0).getIsQualified();
|
||||
if (CollUtil.isNotEmpty(adDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
}
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, valueTypeCode, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, valueTypeCode, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, valueTypeCode, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType("avg");
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
||||
harmonicResult.setDataType(sourceIssue.getDataType());
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
|
||||
@@ -565,34 +551,32 @@ public class DetectionServiceImpl {
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
Integer isQualified = 4;
|
||||
String valueTypeCode = "";
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
result.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
isQualified = errDtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = errDtlsCheckData.get(0).getValueTypeCode();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
}
|
||||
result.setDataType("avg");
|
||||
result.setDataType(sourceIssue.getDataType());
|
||||
if (StrUtil.isBlank(type)) {
|
||||
//取出源所对应的相别信息
|
||||
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
||||
.filter(x -> TYPE_A.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = rangeComparisonList(map.get(TYPE_A), isQualified, valueTypeCode, pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
|
||||
DetectionData a = rangeComparisonList(map.get(TYPE_A), isQualified, pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_B.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData b = rangeComparisonList(map.get(TYPE_B), isQualified, valueTypeCode, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
DetectionData b = rangeComparisonList(map.get(TYPE_B), isQualified, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setBValue(JSON.toJSONString(b));
|
||||
|
||||
List<PqScriptCheckData> channelTypeCList = checkData.stream()
|
||||
.filter(x -> TYPE_C.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData c = rangeComparisonList(map.get(TYPE_C), isQualified, valueTypeCode, pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
|
||||
DetectionData c = rangeComparisonList(map.get(TYPE_C), isQualified, pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
|
||||
result.setCValue(JSON.toJSONString(c));
|
||||
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
|
||||
@@ -600,7 +584,7 @@ public class DetectionServiceImpl {
|
||||
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
||||
.filter(x -> TYPE_T.equals(x.getPhase()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_B), isQualified, valueTypeCode, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
DetectionData t = rangeComparisonList(map.get(TYPE_B), isQualified, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
||||
result.setTValue(JSON.toJSONString(t));
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(t)));
|
||||
}
|
||||
@@ -612,6 +596,14 @@ public class DetectionServiceImpl {
|
||||
|
||||
/**
|
||||
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态)
|
||||
* <p>
|
||||
* (假如都符合,则选取最开始合格的,都不合格,取最开始不合格的)
|
||||
* 方案一 分项问题
|
||||
* 分别计算各个相别是否合格
|
||||
* 不合格电压幅值的层级最高
|
||||
* <p>
|
||||
* 方案二 不分项问题
|
||||
* 以电压幅值最低的作为比较相别
|
||||
*
|
||||
* @param dev 处理过后的数据
|
||||
* @param errDtlsCheckData 误差体系
|
||||
@@ -635,14 +627,80 @@ public class DetectionServiceImpl {
|
||||
//暂态电压下多少就是多少
|
||||
List<ErrDtlsCheckDataVO> magErrList = errDtlsCheckData.stream().filter(x -> MAG.equals(x.getValueTypeCode())).collect(Collectors.toList());
|
||||
List<ErrDtlsCheckDataVO> durErrList = errDtlsCheckData.stream().filter(x -> DUR.equals(x.getValueTypeCode())).collect(Collectors.toList());
|
||||
|
||||
AdNonHarmonicResult magResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, mag, magErrList, sourceIssue.getFUn(), MAG);
|
||||
AdNonHarmonicResult durResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, dur, durErrList, sourceIssue.getFFreq(), DUR);
|
||||
if (CollUtil.isNotEmpty(mag.get(TYPE_B)) && CollUtil.isNotEmpty(mag.get(TYPE_C))) {
|
||||
conclusion(magResult, durResult);
|
||||
}
|
||||
detectionDataDealService.acceptAdNonResult(Arrays.asList(magResult, durResult), code);
|
||||
List<Integer> numbers = Arrays.asList(magResult.getResultFlag(), durResult.getResultFlag()).stream().distinct().collect(Collectors.toList());
|
||||
return getInteger(numbers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magResult 电压幅值结果
|
||||
* @param durResult 持续时间结果
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2025/4/9 18:54
|
||||
*/
|
||||
private void conclusion(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
|
||||
if (magResult.getResultFlag() == 1) {
|
||||
if (durResult.getResultFlag() != 2) {
|
||||
setTValueBasedOnAValue(magResult, durResult);
|
||||
} else {
|
||||
setTValueBasedOnAValue(magResult, durResult, false);
|
||||
}
|
||||
} else if (magResult.getResultFlag() == 2) {
|
||||
setTValueBasedOnAValue(magResult, durResult, true);
|
||||
} else {
|
||||
setTValueBasedOnAValue(magResult, durResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTValueBasedOnAValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult, Boolean isMag) {
|
||||
DetectionData a;
|
||||
DetectionData b;
|
||||
DetectionData c;
|
||||
if (isMag) {
|
||||
a = JSON.parseObject(magResult.getAValue(), DetectionData.class);
|
||||
b = JSON.parseObject(magResult.getBValue(), DetectionData.class);
|
||||
c = JSON.parseObject(magResult.getCValue(), DetectionData.class);
|
||||
} else {
|
||||
a = JSON.parseObject(durResult.getAValue(), DetectionData.class);
|
||||
b = JSON.parseObject(durResult.getBValue(), DetectionData.class);
|
||||
c = JSON.parseObject(durResult.getCValue(), DetectionData.class);
|
||||
}
|
||||
if (a.getIsData() == 2) {
|
||||
setTValueBasedOnAValue(magResult, durResult);
|
||||
} else if (b.getIsData() == 2) {
|
||||
setTValueBasedOnBValue(magResult, durResult);
|
||||
} else if (c.getIsData() == 2) {
|
||||
setTValueBasedOnCValue(magResult, durResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magResult 电压幅值结果
|
||||
* @param durResult 持续时间结果
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
*/
|
||||
private void setTValueBasedOnAValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
|
||||
magResult.setTValue(magResult.getAValue());
|
||||
durResult.setTValue(durResult.getAValue());
|
||||
}
|
||||
|
||||
private void setTValueBasedOnBValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
|
||||
magResult.setTValue(magResult.getBValue());
|
||||
durResult.setTValue(durResult.getBValue());
|
||||
}
|
||||
|
||||
private void setTValueBasedOnCValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
|
||||
magResult.setTValue(magResult.getCValue());
|
||||
durResult.setTValue(durResult.getCValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param devId 装置监测点id(ip_通道)
|
||||
* @param devIdMapComm ip_通道,装置名称
|
||||
@@ -671,54 +729,69 @@ public class DetectionServiceImpl {
|
||||
result.setMonitorId(devID + "_" + split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setSort(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
result.setDataType(sourceIssue.getDataType());
|
||||
List<PqErrSysDtls> magErrList = new ArrayList<>();
|
||||
Integer isQualified = 4;
|
||||
String valueTypeCode = "";
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
result.setAdType(errDtlsCheckData.get(0).getValueType());
|
||||
isQualified = errDtlsCheckData.get(0).getIsQualified();
|
||||
valueTypeCode = errDtlsCheckData.get(0).getValueTypeCode();
|
||||
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
magErrList = errDtlsCheckData.get(0).getErrSysDtls();
|
||||
}
|
||||
}
|
||||
//取出源所对应的相别信息
|
||||
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> ("Ua").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = setDetectionData(isQualified, valueTypeCode, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
|
||||
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> ("Ub").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
DetectionData b = setDetectionData(isQualified, valueTypeCode, dataRule, mag, fData, dur, magErrList, channelTypeBList, TYPE_B);
|
||||
DetectionData b = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeBList, TYPE_B);
|
||||
result.setBValue(JSON.toJSONString(b));
|
||||
|
||||
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> ("Uc").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData c = setDetectionData(isQualified, valueTypeCode, dataRule, mag, fData, dur, magErrList, channelTypeCList, TYPE_C);
|
||||
DetectionData c = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeCList, TYPE_C);
|
||||
result.setCValue(JSON.toJSONString(c));
|
||||
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
|
||||
if (CollUtil.isNotEmpty(mag.get(TYPE_B)) && CollUtil.isNotEmpty(mag.get(TYPE_C))) {
|
||||
//取出源所对应的相别信息
|
||||
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> ("Ua").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
|
||||
} else {
|
||||
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> x.getChannelType().contains("U"))
|
||||
.sorted(Comparator.comparing(
|
||||
x -> Optional.ofNullable(x.getDipData())
|
||||
.map(SourceIssue.ChannelListDTO.DipDataDTO::getFTransValue)
|
||||
.orElse(Double.NaN)
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
|
||||
result.setAValue(JSON.toJSONString(a));
|
||||
result.setTValue(JSON.toJSONString(a));
|
||||
result.setResultFlag(a.getIsData());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private DetectionData setDetectionData(Integer isQualified, String valueTypeCode, DictDataEnum dataRule, Map<String, List<Double>> mag, Double fData, String dur, List<PqErrSysDtls> magErrList, List<SourceIssue.ChannelListDTO> channelTypeCList, String typeC) {
|
||||
DetectionData c;
|
||||
private DetectionData setDetectionData(Integer isQualified,
|
||||
DictDataEnum dataRule,
|
||||
Map<String, List<Double>> mag,
|
||||
Double fData,
|
||||
String dur,
|
||||
List<PqErrSysDtls> magErrList,
|
||||
List<SourceIssue.ChannelListDTO> channelTypeCList,
|
||||
String type) {
|
||||
DetectionData data;
|
||||
if (DUR.equals(dur)) {
|
||||
c = rangeDURComparisonList(mag.get(typeC), isQualified, valueTypeCode, magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule);
|
||||
data = rangeDURComparisonList(mag.get(type), isQualified, magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule);
|
||||
} else {
|
||||
List<Double> ampData = mag.get(typeC).stream()
|
||||
.filter(x -> ObjectUtil.isNotNull(x))
|
||||
.map(x -> x * channelTypeCList.get(0).getFAmp() * 0.01)
|
||||
.collect(Collectors.toList());
|
||||
c = rangeComparisonList(ampData, isQualified, valueTypeCode, magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
|
||||
data = rangeComparisonList(mag.get(type), isQualified, magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
|
||||
}
|
||||
return c;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -839,11 +912,10 @@ public class DetectionServiceImpl {
|
||||
* @param sourceIssue 源下发的值(谐波)
|
||||
* @param dataRule 数据处理原则
|
||||
* @param devMap
|
||||
* @param fData
|
||||
* @param fData 额定值
|
||||
* @return
|
||||
*/
|
||||
public List<DetectionData> harmRangeComparison(Integer isQualified,
|
||||
String valueTypeCode,
|
||||
List<PqErrSysDtls> pqErrSysDtls,
|
||||
String type,
|
||||
String phase,
|
||||
@@ -874,12 +946,12 @@ public class DetectionServiceImpl {
|
||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
.flatMap(x -> x.getInharmList().stream())
|
||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> x.getFAmp() * percent));
|
||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
|
||||
} else {
|
||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
.flatMap(x -> x.getHarmList().stream())
|
||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFAmp() * percent));
|
||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
|
||||
}
|
||||
}
|
||||
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
|
||||
@@ -905,17 +977,14 @@ public class DetectionServiceImpl {
|
||||
if (CollUtil.isNotEmpty(harmDataList)) {
|
||||
data.setData(harmDataList.get(0));
|
||||
}
|
||||
Double v = issueHarmMap.get(harm);
|
||||
data.setResultData(v);
|
||||
Double channelData = issueHarmMap.get(harm);
|
||||
data.setResultData(channelData);
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType()));
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(6);
|
||||
nf.setGroupingUsed(false);
|
||||
data.setUnit(unit(valueTypeCode, errSysDtl.getErrorValueType()));
|
||||
data.setRadius(nf.format(-errSys.getMaxErrorValue()) + "~" + nf.format(errSys.getMaxErrorValue()));
|
||||
setDetection(dataRule, harmDataList, errSys, data, v);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm)));
|
||||
data.setUnit(errSysDtl.getErrorUnit());
|
||||
data.setRadius(-errSys.getMaxErrorValue() + "~" + errSys.getMaxErrorValue());
|
||||
setDetection(dataRule, harmDataList, errSys, data, channelData, fData);
|
||||
}
|
||||
info.add(data);
|
||||
});
|
||||
@@ -928,26 +997,27 @@ public class DetectionServiceImpl {
|
||||
* @param harmDataList 原始数据集合
|
||||
* @param errSysDtl 误差体系
|
||||
* @param data 初始化原始数据
|
||||
* @param v 源下发的数据
|
||||
* @param channelData 源下发的数据
|
||||
* @param ratedValue 额定值
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/29 18:10
|
||||
*/
|
||||
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) {
|
||||
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double channelData, Double ratedValue) {
|
||||
if (CollUtil.isNotEmpty(harmDataList)) {
|
||||
// 存放合格的数据
|
||||
List<Double> qualifiedList = harmDataList.stream()
|
||||
.filter(x -> v == 0 ? NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
|
||||
.filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))
|
||||
:
|
||||
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
|
||||
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qualifiedList)) {
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), v, errSysDtl.getErrorValueType()));
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl));
|
||||
} else {
|
||||
data.setErrorData(devSubtractChannelData(harmDataList.get(0), v, errSysDtl.getErrorValueType()));
|
||||
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl));
|
||||
}
|
||||
isData(dataRule, harmDataList, data, qualifiedList);
|
||||
}
|
||||
@@ -1078,7 +1148,7 @@ public class DetectionServiceImpl {
|
||||
* @param dataRule 数据处理原则
|
||||
* @returnd
|
||||
*/
|
||||
public DetectionData rangeComparisonList(List<Double> list, Integer isQualified, String valueTypeCode, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
||||
public DetectionData rangeComparisonList(List<Double> list, Integer isQualified, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
||||
DetectionData detectionData = new DetectionData();
|
||||
detectionData.setIsData(isQualified);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
@@ -1093,19 +1163,16 @@ public class DetectionServiceImpl {
|
||||
channelData)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(6);
|
||||
nf.setGroupingUsed(false);
|
||||
detectionData.setUnit(unit(valueTypeCode, errSysDtl.getErrorValueType()));
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
|
||||
detectionData.setRadius(nf.format(-errSysDtl.getMaxErrorValue()) + "~" + nf.format(errSysDtl.getMaxErrorValue()));
|
||||
setDetection(dataRule, list, errSysDtl, detectionData, channelData);
|
||||
detectionData.setUnit(errSysDtl.getErrorUnit());
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl, data, channelData));
|
||||
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||
setDetection(dataRule, list, errSysDtl, detectionData, channelData, data);
|
||||
}
|
||||
}
|
||||
return detectionData;
|
||||
}
|
||||
|
||||
public DetectionData rangeDURComparisonList(List<Double> list, Integer isQualified, String valueTypeCode, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
||||
public DetectionData rangeDURComparisonList(List<Double> list, Integer isQualified, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
||||
DetectionData detectionData = new DetectionData();
|
||||
detectionData.setIsData(isQualified);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
@@ -1124,9 +1191,9 @@ public class DetectionServiceImpl {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(6);
|
||||
nf.setGroupingUsed(false);
|
||||
detectionData.setUnit(unit(valueTypeCode, errSysDtl.getErrorValueType()));
|
||||
detectionData.setRadius(nf.format(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())))
|
||||
+ "~" + nf.format(BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue()))));
|
||||
detectionData.setUnit(errSysDtl.getErrorUnit());
|
||||
detectionData.setRadius(nf.format(BigDecimal.valueOf(-1.0 / data))
|
||||
+ "~" + nf.format(BigDecimal.valueOf(1.0 / data)));
|
||||
List<Double> qualifiedList = list.stream()
|
||||
.filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()),
|
||||
BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())),
|
||||
@@ -1134,14 +1201,14 @@ public class DetectionServiceImpl {
|
||||
).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qualifiedList)) {
|
||||
BigDecimal subtract = BigDecimal.valueOf(qualifiedList.get(0))
|
||||
.subtract(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())));
|
||||
.subtract(BigDecimal.valueOf(1.0 / data * (channelData)));
|
||||
detectionData.setErrorData(subtract);
|
||||
} else {
|
||||
BigDecimal subtract = BigDecimal.valueOf(list.get(0))
|
||||
.subtract(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())));
|
||||
.subtract(BigDecimal.valueOf(1.0 / data * (channelData)));
|
||||
detectionData.setErrorData(subtract);
|
||||
}
|
||||
isData(dataRule, qualifiedList, detectionData, qualifiedList);
|
||||
isData(dataRule, list, detectionData, qualifiedList);
|
||||
}
|
||||
}
|
||||
return detectionData;
|
||||
@@ -1157,7 +1224,8 @@ public class DetectionServiceImpl {
|
||||
* @param devData 装置上送值
|
||||
* @return
|
||||
*/
|
||||
public Boolean rangeComparison(Double startValue, Integer startFlag, Double endValue, Integer endFlag, Double devData) {
|
||||
public Boolean rangeComparison(Double startValue, Integer startFlag, Double endValue, Integer endFlag, Double
|
||||
devData) {
|
||||
Boolean minBool = null;
|
||||
Boolean maxBool = null;
|
||||
if (ObjectUtil.isNotNull(startValue)) {
|
||||
@@ -1189,39 +1257,36 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
|
||||
/**
|
||||
* 技术数据误差值(装置返回的值 - 源通道下发的值)
|
||||
* 计算数据误差值(装置返回的值 - 源通道下发的值)
|
||||
*
|
||||
* @param devData
|
||||
* @param channelData
|
||||
* @param errorValueType
|
||||
* @param devData 装置返回值
|
||||
* @param channelData 通道值
|
||||
* @param ratedValue 额定值
|
||||
* @param error
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Integer errorValueType) {
|
||||
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Double ratedValue, PqErrSysDtls error) {
|
||||
//计算装置值返回值 - 源下发值的数据 = 差值
|
||||
BigDecimal subtract = BigDecimal.valueOf(devData).subtract(BigDecimal.valueOf(channelData));
|
||||
if (subtract.doubleValue() != 0) {
|
||||
switch (errorValueType) {
|
||||
case 2:
|
||||
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/下发的幅值
|
||||
//只有相对值需要%比较,绝对值直接相减就行
|
||||
if (2 == error.getValueType()) {
|
||||
switch (error.getErrorValueType()) {
|
||||
case 0:
|
||||
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 额定值
|
||||
return subtract.multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(ratedValue), 4, RoundingMode.HALF_UP);
|
||||
case 1:
|
||||
//todo 当谐波电压和间谐波电压默认都是按照相对值误差进行计算(用户关心的是含有率)
|
||||
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 下发的幅值
|
||||
return subtract.multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
|
||||
case 3:
|
||||
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/装置返回值
|
||||
return subtract.multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(devData), 4, RoundingMode.HALF_UP);
|
||||
}
|
||||
return subtract;
|
||||
}
|
||||
return BigDecimal.valueOf(0);
|
||||
}
|
||||
|
||||
public BigDecimal divide(Double devData, Double channelData) {
|
||||
return BigDecimal.valueOf(devData)
|
||||
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
|
||||
|
||||
return subtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于计算误差体系的范围的
|
||||
* 用于计算误差体系的范围的(0:标称值 1:谐波值 2:值类型)
|
||||
*
|
||||
* @param value 误差值
|
||||
* @param ratedData 额定值
|
||||
@@ -1248,27 +1313,37 @@ public class DetectionServiceImpl {
|
||||
|
||||
/**
|
||||
* 用于计算最大误差值的范围的
|
||||
* (2绝对值-值比较(默认) 0绝对值-标称值(额定电压) 1绝对值-标准值(源下发直谐波如:H2) 0相对值-标称值 1相对值-标准值)
|
||||
*
|
||||
* @param errorValue 误差值
|
||||
* @param ratedData 额定值
|
||||
* @param harmData 谐波下发值(百分数->含油率)
|
||||
* @param type 误差值类型
|
||||
* @param error 最大误差值对象
|
||||
* @param ratedData 额定值
|
||||
* @param harmData 谐波下发值(百分数->含油率)
|
||||
* @return
|
||||
*/
|
||||
public Double maxErrorMultiply(Double errorValue, Double ratedData, Double harmData, Integer type) {
|
||||
if (ObjectUtil.isNotNull(errorValue)) {
|
||||
switch (type) {
|
||||
public Double maxErrorMultiply(PqErrSysDtls error, Double ratedData, Double harmData) {
|
||||
Double errorValue = error.getMaxErrorValue();
|
||||
//1绝对值
|
||||
if (1 == error.getValueType()) {
|
||||
switch (error.getErrorValueType()) {
|
||||
//绝对值-标称值= 最大误差值 * 额定电压
|
||||
case 0:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData))
|
||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
case 2:
|
||||
case 3:
|
||||
//绝对值-标准值 = 最大误差值 * 谐波下发值
|
||||
case 1:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData))
|
||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
//2相对值
|
||||
if (2 == error.getValueType()) {
|
||||
switch (error.getErrorValueType()) {
|
||||
//相对值-标称值 | 相对值-标准值 = 最大误差值 * 100
|
||||
case 0:
|
||||
case 1:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(100))
|
||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
default:
|
||||
return errorValue;
|
||||
}
|
||||
|
||||
}
|
||||
return errorValue;
|
||||
}
|
||||
@@ -1288,7 +1363,9 @@ public class DetectionServiceImpl {
|
||||
* @param harm 基波信息
|
||||
* @param fund 2-50次谐波信息
|
||||
*/
|
||||
public void harmPut(String type, Map<String, Map<Double, List<Double>>> map, List<Double> harmNum, DevData.SqlDataHarmDTO harm, String fund, Integer num) {
|
||||
public void harmPut(String
|
||||
type, Map<String, Map<Double, List<Double>>> map, List<Double> harmNum, DevData.SqlDataHarmDTO
|
||||
harm, String fund, Integer num) {
|
||||
if (map.containsKey(type)) {
|
||||
Map<Double, List<Double>> integerListMap = map.get(type);
|
||||
for (Double i : harmNum) {
|
||||
|
||||
@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
@@ -41,7 +43,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -52,8 +53,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
private final String source = "_Source";
|
||||
private final String dev = "_Dev";
|
||||
private final String stepTag = "&&";
|
||||
private final String handlerSourceStr = "_Source";
|
||||
|
||||
@@ -79,8 +78,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||
commCheck(param);
|
||||
specialDeal(param);
|
||||
// 参数校验,目前仅检查IP是否重复
|
||||
checkDevIp(param);
|
||||
DetectionCommunicateUtil.checkCommunicateChannel(param);
|
||||
/*
|
||||
先组装源通讯协议
|
||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||
@@ -106,7 +106,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void coefficientCheck(PreDetectionParam param) {
|
||||
specialDeal(param);
|
||||
// 检测是否存在连接的通道,后期需要做成动态,如果组合中不是第一位,则不需要关闭,也不用初始化 todo....
|
||||
DetectionCommunicateUtil.checkCommunicateChannel(param);
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||
.eq(AdPlanSource::getPlanId, param.getPlanId())
|
||||
);
|
||||
@@ -189,7 +190,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg));
|
||||
SocketManager.sendMsg(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
@@ -211,13 +212,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
preDetectionParam.setSendWebMsg(true);
|
||||
|
||||
specialDealSimulate(preDetectionParam);
|
||||
DetectionCommunicateUtil.checkCommunicateChannel(preDetectionParam);
|
||||
sendYtxSocketSimulate(preDetectionParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendScript(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
// 进行源通信连接
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
@@ -251,7 +252,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void closeTestSimulate(SimulateDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
|
||||
}
|
||||
@@ -260,72 +261,14 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
preDetectionParam.setSourceId(sourceParam.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
CnSocketUtil.quitSendSource(preDetectionParam);
|
||||
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void specialDeal(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
|
||||
System.out.println("发送关闭设备通讯指令。。。。。。。。");
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作-模拟检测
|
||||
*
|
||||
* @param param
|
||||
* 校验被检设备中是否存在IP重复的
|
||||
*/
|
||||
private void specialDealSimulate(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验
|
||||
*/
|
||||
private void commCheck(PreDetectionParam param) {
|
||||
private void checkDevIp(PreDetectionParam param) {
|
||||
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
|
||||
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
|
||||
if (ipList.size() != param.getDevIds().size()) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.gather.detection.util.business;
|
||||
|
||||
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* 检测通讯工具类
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/4/15 15:24
|
||||
*/
|
||||
@Slf4j
|
||||
public class DetectionCommunicateUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 检测是否存在连接的源、设备通讯的模块通道
|
||||
* 有则强行关闭
|
||||
*/
|
||||
public static void checkCommunicateChannel(PreDetectionParam param) {
|
||||
Channel channelSource = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
Channel channelDev = SocketManager.getChannelByUserId(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
|
||||
if (Objects.nonNull(channelSource) && channelSource.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
|
||||
System.out.println("发送关闭设备通讯指令。。。。。。。。");
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
|
||||
SocketManager.removeUser(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -66,4 +66,10 @@ public class FormalTestManager {
|
||||
public static Integer stopTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* 强行赋值关系
|
||||
*/
|
||||
public static Map<String,String> harmonicRelationMap = new HashMap<>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
@@ -19,10 +18,14 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
*/
|
||||
public class SocketManager {
|
||||
|
||||
// key为userId(xxx_Source、xxx_Dev),value为channel
|
||||
/**
|
||||
* key为userId(xxx_Source、xxx_Dev),value为channel
|
||||
*/
|
||||
private static final Map<String, Channel> socketSessions = new ConcurrentHashMap<>();
|
||||
|
||||
// key为userId(xxx_Source、xxx_Dev),value为group
|
||||
/**
|
||||
* key为userId(xxx_Source、xxx_Dev),value为group
|
||||
*/
|
||||
private static final Map<String, NioEventLoopGroup> socketGroup = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addUser(String userId, Channel channel) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class UnitUtil {
|
||||
unit = "P";
|
||||
}
|
||||
if (DetectionCodeEnum.MAG.getCode().equals(code)) {
|
||||
unit = "%";
|
||||
unit = "V";
|
||||
}
|
||||
if (DetectionCodeEnum.DUR.getCode().equals(code)) {
|
||||
unit = "s";
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
public class PqDevParam {
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
|
||||
@@ -40,8 +41,9 @@ public class PqDevParam {
|
||||
@ApiModelProperty(value = "出厂日期", required = true)
|
||||
private String createDate;
|
||||
|
||||
@ApiModelProperty(value = "设备序列号", required = true)
|
||||
@ApiModelProperty(value = "装置编号", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_CREATE_ID_REGEX, message = DetectionValidMessage.DEV_CREATE_ID_FORMAT_ERROR)
|
||||
private String createId;
|
||||
|
||||
@ApiModelProperty(value = "固件版本", required = true)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CNDevExcel {
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, orderNum = "3")
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.poi.PullDown;
|
||||
@@ -31,11 +32,7 @@ import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
import com.njcn.gather.report.service.IPqReportService;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
@@ -46,10 +43,10 @@ import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.gather.user.user.service.ISysUserService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@@ -61,6 +58,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -78,6 +76,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
private final IDevTypeService devTypeService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final ISysUserService userService;
|
||||
|
||||
@Override
|
||||
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
@@ -113,15 +112,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevParam, pqDev);
|
||||
if (pqDevParam.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
if ("1".equals(sysTestConfigService.getCurrrentScene())) {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
this.checkParams(pqDev, currrentScene);
|
||||
|
||||
if (SceneEnum.LEAVE_FACTORY_TEST.getValue().equals(currrentScene)) {
|
||||
pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
|
||||
}
|
||||
// 新增时默认设置
|
||||
@@ -143,13 +137,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.save(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
|
||||
this.checkRepeat(updateParam, true);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(updateParam, pqDev);
|
||||
/**
|
||||
* 校验参数
|
||||
*
|
||||
* @param pqDev
|
||||
* @param currrentScene
|
||||
*/
|
||||
private void checkParams(PqDev pqDev, String currrentScene) {
|
||||
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
@@ -158,6 +153,34 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
switch (sceneEnum) {
|
||||
case PROVINCE_PLATFORM:
|
||||
if (!Pattern.matches(PatternRegex.PROVINCE_DEV_NAME_REGEX, pqDev.getName())) {
|
||||
throw new BusinessException(DetectionResponseEnum.PROVINCE_DEV_NAME_FORMAT_ERROR);
|
||||
}
|
||||
break;
|
||||
case LEAVE_FACTORY_TEST:
|
||||
if (!Pattern.matches(PatternRegex.CN_DEV_NAME_REGEX, pqDev.getName())) {
|
||||
throw new BusinessException(DetectionResponseEnum.CN_DEV_NAME_FORMAT_ERROR);
|
||||
}
|
||||
break;
|
||||
case SELF_TEST:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
|
||||
this.checkRepeat(updateParam, true);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(updateParam, pqDev);
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
this.checkParams(pqDev, currrentScene);
|
||||
|
||||
// 比对式设备修改监测点
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
|
||||
if (ObjectUtil.isNotEmpty(updateParam.getMonitorList())) {
|
||||
@@ -344,23 +367,22 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, devIds).update();
|
||||
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, devIds));
|
||||
//判断是否有处了未检的其他设备
|
||||
List<Integer> notUnchecked = list.stream().map(PqDev::getCheckState).filter(x -> !x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
|
||||
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(notUnchecked)) {
|
||||
List<Integer> unchecked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.UNCHECKED.getValue())).distinct().collect(Collectors.toList());
|
||||
List<String> unchecked = list.stream().filter(x -> CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
//计划未检测
|
||||
if (CollUtil.isNotEmpty(unchecked)) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
}
|
||||
//计划检测中
|
||||
List<String> checking = list.stream().filter(x -> CheckStateEnum.CHECKING.getValue().equals(x.getCheckState()) ||
|
||||
CheckStateEnum.CHECKED.getValue().equals(x.getCheckState()) ||
|
||||
!DevDocumentStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
|
||||
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
|
||||
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
|
||||
).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
if (checking.size() == notUnchecked.size()) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
}
|
||||
//检测完成
|
||||
List<Integer> checked = list.stream().map(PqDev::getCheckState).filter(x -> x.equals(CheckStateEnum.DOCUMENTED.getValue())).distinct().collect(Collectors.toList());
|
||||
List<String> checked = list.stream().filter(x -> CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
if (checked.size() == notUnchecked.size()) {
|
||||
return CheckStateEnum.CHECKED.getValue();
|
||||
}
|
||||
@@ -370,6 +392,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return CheckStateEnum.UNCHECKED.getValue();
|
||||
}
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public List getPieData(String planId) {
|
||||
// List<PqDev> pqDevList = this.lambdaQuery().eq(PqDev::getPlanId, planId).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
@@ -391,6 +414,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
@Override
|
||||
public PqDevVO getPqDevById(String id) {
|
||||
PqDev pqDev = this.getById(id);
|
||||
if (StrUtil.isNotBlank(pqDev.getCheckBy())) {
|
||||
pqDev.setCheckBy(userService.getById(pqDev.getCheckBy()).getName());
|
||||
}
|
||||
PqDevVO pqDevVO = new PqDevVO();
|
||||
BeanUtil.copyProperties(pqDev, pqDevVO);
|
||||
|
||||
@@ -467,12 +493,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// 只有检测完成的设备才可以进行归档
|
||||
PqDev pqDev = this.getById(id);
|
||||
if (ObjectUtil.isNotNull(pqDev)) {
|
||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||
// 只有检测完成、且已生成报告的设备才可以进行归档
|
||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) || !pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_REPORT);
|
||||
}
|
||||
boolean update = this.lambdaUpdate()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
|
||||
.eq(PqDev::getId, id)
|
||||
@@ -490,8 +514,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,7 +521,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateResult(List<String> ids, List<String> valueType, String code,String userId) {
|
||||
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
SysTestConfig config = sysTestConfigService.getOneConfig();
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
|
||||
@@ -509,43 +531,31 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (result.containsKey(pqDev.getId())) {
|
||||
Integer checkState;
|
||||
int i;
|
||||
LambdaUpdateWrapper<PqDev> wrapper = new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
|
||||
.set(PqDev::getCheckBy, userId)
|
||||
.set(PqDev::getCheckTime, LocalDateTime.now())
|
||||
.eq(PqDev::getId, pqDev.getId());
|
||||
if (pqDev.getReCheckNum() >= config.getMaxTime()) {
|
||||
// 装置报告生成 todo...
|
||||
this.baseMapper.updateReportState(pqDev.getId());
|
||||
//this.baseMapper.updateReportState(pqDev.getId());
|
||||
wrapper.set(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
|
||||
// 装置归档
|
||||
checkState = CheckStateEnum.DOCUMENTED.getValue();
|
||||
i = pqDev.getReCheckNum();
|
||||
} else {
|
||||
checkState = CheckStateEnum.CHECKED.getValue();
|
||||
i = pqDev.getReCheckNum() + 1;
|
||||
wrapper.set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getReCheckNum, i)
|
||||
.set(PqDev::getCheckState, checkState)
|
||||
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
|
||||
.set(PqDev::getCheckBy, userId)
|
||||
.set(PqDev::getCheckTime, LocalDateTime.now())
|
||||
.set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue())
|
||||
.eq(PqDev::getId, pqDev.getId()));
|
||||
|
||||
if (checkState.equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
wrapper.set(PqDev::getReCheckNum, i)
|
||||
.set(PqDev::getCheckState, checkState);
|
||||
this.update(wrapper);
|
||||
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode());
|
||||
|
||||
List<PqDev> pqDevList = this.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(pqDevList)) {
|
||||
Set<Integer> set = pqDevList.stream().map(PqDev::getCheckResult).collect(Collectors.toSet());
|
||||
@@ -557,15 +567,23 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.baseMapper.updatePlanCheckResult(pqDev.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
||||
}
|
||||
|
||||
// set = pqDevList.stream().map(PqDev::getCheckState).collect(Collectors.toSet());
|
||||
// if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||
// this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.UNCHECKED.getValue());
|
||||
// } else {
|
||||
// this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.CHECKED.getValue());
|
||||
// }
|
||||
set = pqDevList.stream().map(PqDev::getCheckState).collect(Collectors.toSet());
|
||||
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||
this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
||||
} else {
|
||||
if (checkState.equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
||||
queryWrapper.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
} else {
|
||||
this.baseMapper.updatePlanTestState(pqDev.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -903,8 +921,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
// 是否支持系数校准
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 8);
|
||||
pullDown.setLastCol(startCol + 8);
|
||||
pullDown.setFirstCol(startCol + 7);
|
||||
pullDown.setLastCol(startCol + 7);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
|
||||
@@ -38,11 +38,6 @@ public class PqErrSysDtlsParam {
|
||||
@ApiModelProperty(value = "是否包含结束值", required = true)
|
||||
private Integer endFlag;
|
||||
|
||||
// @ApiModelProperty(value = "单位", required = true)
|
||||
// @NotBlank(message = DeviceValidMessage.UNIT_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.UNIT_FORMAT_ERROR)
|
||||
// private String unit;
|
||||
|
||||
@ApiModelProperty(value = "判断条件值类型", required = true)
|
||||
private Integer conditionType;
|
||||
|
||||
@@ -58,4 +53,10 @@ public class PqErrSysDtlsParam {
|
||||
@NotNull(message = DetectionValidMessage.SORT_NOT_NULL)
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("1绝对值、2相对值")
|
||||
private Integer valueType;
|
||||
|
||||
@ApiModelProperty("误差单位")
|
||||
private String errorUnit;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PqErrSysParam {
|
||||
|
||||
@ApiModelProperty(value = "参照标准名称", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME_REGEX, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
private String standardName;
|
||||
|
||||
@ApiModelProperty(value = "标准实施年份", required = true)
|
||||
@@ -41,7 +41,6 @@ public class PqErrSysParam {
|
||||
private Integer enable;
|
||||
|
||||
@ApiModelProperty(value = "误差详情列表", required = true)
|
||||
@Valid
|
||||
private List<PqErrSysDtlsParam> pqErrSysDtlsList;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -60,10 +60,6 @@ public class PqErrSysDtls implements Serializable {
|
||||
*/
|
||||
private Integer endFlag;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
// private String unit;
|
||||
|
||||
/**
|
||||
* 判断条件值类型(包括值类型,绝对值、相对值)
|
||||
@@ -77,7 +73,7 @@ public class PqErrSysDtls implements Serializable {
|
||||
private Double maxErrorValue;
|
||||
|
||||
/**
|
||||
* 误差值类型
|
||||
* 误差值类型(绝对值:0:标称值 1:标准值 2:值比较 相对值:0标称值 1:标准值)
|
||||
*/
|
||||
private Integer errorValueType;
|
||||
|
||||
@@ -86,5 +82,14 @@ public class PqErrSysDtls implements Serializable {
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 1绝对值、2相对值
|
||||
*/
|
||||
private Integer valueType;
|
||||
|
||||
/**
|
||||
* 误差单位
|
||||
*/
|
||||
private String errorUnit;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.icd.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -9,5 +10,12 @@ import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
*/
|
||||
public interface PqIcdPathMapper extends MPJBaseMapper<PqIcdPath> {
|
||||
|
||||
/**
|
||||
* 根据设备类型id获取Icd
|
||||
*
|
||||
* @param devTypeId
|
||||
* @return
|
||||
*/
|
||||
PqIcdPath selectIcdByDevType(@Param("devTypeId") String devTypeId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,11 @@
|
||||
<mapper namespace="com.njcn.gather.icd.mapper.PqIcdPathMapper">
|
||||
|
||||
|
||||
<select id="selectIcdByDevType" resultType="com.njcn.gather.icd.pojo.po.PqIcdPath">
|
||||
select *
|
||||
from pq_icd_path path
|
||||
inner join pq_dev_type type on path.id = type.icd
|
||||
where type.id = #{devTypeId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -51,4 +51,12 @@ public interface IPqIcdPathService extends IService<PqIcdPath> {
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deleteIcd(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据设备类型id获取Icd
|
||||
*
|
||||
* @param devTypeId
|
||||
* @return
|
||||
*/
|
||||
PqIcdPath getIcdByDevType(String devTypeId);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqIcdPath getIcdByDevType(String devTypeId) {
|
||||
return this.baseMapper.selectIcdByDevType(devTypeId);
|
||||
}
|
||||
|
||||
private void checkRepeat(PqIcdPathParam param, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PqIcdPath::getName, param.getName())
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.monitor.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
|
||||
@@ -125,8 +125,8 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载检测计划导出模板")
|
||||
public void downloadTemplate() {
|
||||
adPlanService.downloadTemplate();
|
||||
public void downloadTemplate(@RequestBody String patternId) {
|
||||
adPlanService.downloadTemplate(patternId);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
|
||||
@@ -78,7 +78,7 @@ public class AdPlanParam {
|
||||
@ApiModelProperty(value = "模式,字典表(数字、模拟、比对)")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
private String patternId;
|
||||
|
||||
@ApiModelProperty(value = "检测状态")
|
||||
@Min(value = 0, message = DetectionValidMessage.TEST_STATE_FORMAT_ERROR)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.njcn.gather.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -86,6 +87,7 @@ public class AdPlan extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 报告模板ID,关联PQ_Report表
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String reportTemplateId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,8 +111,10 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
|
||||
/**
|
||||
* 下载检测计划模板
|
||||
*
|
||||
* @param patternId
|
||||
*/
|
||||
void downloadTemplate();
|
||||
void downloadTemplate(String patternId);
|
||||
|
||||
/**
|
||||
* 导入检测计划数据
|
||||
|
||||
@@ -188,17 +188,21 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
AdPlan plan1 = this.getById(param.getId());
|
||||
AdPlan plan2 = new AdPlan();
|
||||
|
||||
if (param.getAssociateReport() != null && param.getAssociateReport() == 1) {
|
||||
String reportTemplateName = param.getReportTemplateName();
|
||||
String[] split = reportTemplateName.split("_");
|
||||
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
|
||||
if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
|
||||
if (!reportId.equals(plan1.getReportTemplateId())) {
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
if (param.getAssociateReport() != null) {
|
||||
if (param.getAssociateReport() == 1) {
|
||||
String reportTemplateName = param.getReportTemplateName();
|
||||
String[] split = reportTemplateName.split("_");
|
||||
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
|
||||
// if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
|
||||
// if (!reportId.equals(plan1.getReportTemplateId())) {
|
||||
// throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.isNotBlank(reportId)) {
|
||||
plan2.setReportTemplateId(reportId);
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(reportId)) {
|
||||
plan2.setReportTemplateId(reportId);
|
||||
} else {
|
||||
plan2.setReportTemplateId(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,9 +213,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
||||
}
|
||||
if (param.getAssociateReport() != null && param.getAssociateReport() != plan1.getAssociateReport()) {
|
||||
throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
}
|
||||
// if (param.getAssociateReport() != null && param.getAssociateReport() != plan1.getAssociateReport()) {
|
||||
// throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||
// }
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(param, plan2);
|
||||
@@ -476,15 +480,15 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
public void downloadTemplate(String patternId) {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
|
||||
switch (sceneEnum) {
|
||||
case PROVINCE_PLATFORM:
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM), ProvincePlanExcel.class, Collections.emptyList());
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM, patternId), ProvincePlanExcel.class, Collections.emptyList());
|
||||
break;
|
||||
case LEAVE_FACTORY_TEST:
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST), CNPlanExcel.class, Collections.emptyList());
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST, patternId), CNPlanExcel.class, Collections.emptyList());
|
||||
break;
|
||||
case SELF_TEST:
|
||||
break;
|
||||
@@ -531,7 +535,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<ProvinceDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, ProvinceDevExcel.class);
|
||||
planExcelList.get(i).setDevices(deviceExportData);
|
||||
}
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM), ProvincePlanExcel.class, planExcelList);
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM, queryParam.getPatternId()), ProvincePlanExcel.class, planExcelList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,7 +558,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<CNDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
planExcelList.get(i).setDevices(deviceExportData);
|
||||
}
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST), CNPlanExcel.class, planExcelList);
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST, queryParam.getPatternId()), CNPlanExcel.class, planExcelList);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -607,9 +611,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
Integer code = this.generateCode();
|
||||
adPlans.get(i).setCode(code);
|
||||
|
||||
tableGenService.deleteTable(Arrays.asList(code.toString()));
|
||||
tableGenService.genAdNonHarmonicTable(code.toString());
|
||||
|
||||
String source = planExcel.getSource();
|
||||
String[] sourceNames = source.split(StrUtil.COMMA);
|
||||
// 若非比对模式,检测源、数据源有2个以上时,不导入
|
||||
@@ -629,6 +630,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
List<CNDevExcel> cnDevExcelList = planExcel.getDevices();
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId, planId);
|
||||
|
||||
tableGenService.deleteTable(Arrays.asList(code.toString()));
|
||||
tableGenService.genAdNonHarmonicTable(code.toString());
|
||||
}
|
||||
// 逆向可视化
|
||||
this.reverseVisualize(adPlans);
|
||||
@@ -721,7 +725,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
|
||||
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern())
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPatternId()), "ad_plan.pattern", queryParam.getPatternId())
|
||||
.like(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName())
|
||||
.eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState())
|
||||
.eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState())
|
||||
@@ -1019,10 +1023,19 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
}
|
||||
|
||||
private List<PullDown> getPullDownList(SceneEnum scene) {
|
||||
private List<PullDown> getPullDownList(SceneEnum scene, String patternId) {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
|
||||
PullDown pullDown = null;
|
||||
// List<Map<String, Object>> maps = pqSourceService.listAllPqSource(patternId);
|
||||
// if (ObjectUtil.isNotEmpty(maps)) {
|
||||
// pullDown = new PullDown();
|
||||
// pullDown.setFirstCol(1);
|
||||
// pullDown.setLastCol(1);
|
||||
// pullDown.setStrings(maps.stream().map(m -> (String) m.get("name")).collect(Collectors.toList()));
|
||||
// pullDowns.add(pullDown);
|
||||
// }
|
||||
|
||||
// 数据源
|
||||
DictType dictType = dictTypeService.getByCode("Datasource");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
|
||||
@@ -10,9 +10,9 @@ public interface DetectionValidMessage {
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||
String NAME_NOT_BLANK = "名称不能为空";
|
||||
String ICD_NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号,长度为1-50个字符";
|
||||
String ICD_NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格、英文括号,长度为1-32个字符";
|
||||
String ICD_PATH_NOT_BLANK = "icd存储路径不能为空";
|
||||
String ICD_PATH_FORMAT_ERROR = "ICD路径格式错误";
|
||||
String ICD_PATH_FORMAT_ERROR = "ICD路径格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-50个字符";
|
||||
String ICD_NOT_BLANK = "ICD不能为空";
|
||||
String POWER_NOT_BLANK = "工作电源不能为空";
|
||||
String VOLT_NOT_BLANK = "额定电压不能为空";
|
||||
@@ -21,14 +21,14 @@ public interface DetectionValidMessage {
|
||||
String DEV_CHNS_RANGE_ERROR = "通道数格式错误";
|
||||
String INDEX_NOT_NULL = "index不能为空";
|
||||
String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空";
|
||||
String SCRIPT_NAME_FORMAT_ERROR = "脚本名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号,长度为1-50个字符";
|
||||
String SCRIPT_NAME_FORMAT_ERROR = "脚本名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符";
|
||||
String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误,请检查ratedVolt参数";
|
||||
String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误,请检查ratedCurr参数";
|
||||
String PORT_RANGE_ERROR = "端口号范围错误,请检查port参数";
|
||||
|
||||
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
|
||||
String NAME_FORMAT_ERROR = "名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符";
|
||||
|
||||
String PATTERN_NOT_BLANK = "模式不能为空,请检查pattern参数";
|
||||
String PATTERN_NOT_BLANK = "模式不能为空,请检查patternId参数";
|
||||
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空";
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface DetectionValidMessage {
|
||||
|
||||
String RECHECK_NUM_FORMAT_ERROR = "检测次数格式错误,请检查recheckNum参数";
|
||||
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误,请检查pattern参数";
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误,请检查patternId参数";
|
||||
|
||||
String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空,请检查sourceIds参数";
|
||||
|
||||
@@ -76,15 +76,15 @@ public interface DetectionValidMessage {
|
||||
|
||||
String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误,请检查planId参数";
|
||||
|
||||
String STANDARD_TIME_FORMAT_ERROR = "标准推行时间格式错误,请检查standardTime参数";
|
||||
String STANDARD_TIME_FORMAT_ERROR = "标准推行年份格式错误,请检查standardTime参数";
|
||||
|
||||
String SCRIPT_TYPE_NOT_BLANK = "检测脚本类型不能为空,请检查scriptType参数";
|
||||
|
||||
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空,请检查standardName参数";
|
||||
String STANDARD_NAME_NOT_BLANK = "标准号不能为空,请检查standardName参数";
|
||||
|
||||
String STANDARD_NAME_FORMAT_ERROR = "参照标准名称格式错误,请检查standardName参数";
|
||||
String STANDARD_NAME_FORMAT_ERROR = "标准号格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格、斜杠、反斜杠,长度为1-32个字符";
|
||||
|
||||
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空,请检查standardTime参数";
|
||||
String STANDARD_TIME_NOT_BLANK = "标准推行年份不能为空,请检查standardTime参数";
|
||||
|
||||
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误,请检查scriptType参数";
|
||||
|
||||
@@ -174,4 +174,9 @@ public interface DetectionValidMessage {
|
||||
String SORT_NOT_NULL = "排序不能为空";
|
||||
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
|
||||
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
|
||||
String CN_DEV_NAME_FORMAT_ERROR = "设备名称格式错误,只能包含数字、中划线,长度为1-32个字符";
|
||||
String DEV_CREATE_ID_FORMAT_ERROR = "装置编号格式错误,只能包含字母、数字、中文、下划线、中划线、空格,长度为1-32位";
|
||||
|
||||
String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符";
|
||||
String REPORT_NAME_NOT_BLANK = "报告模板不能为空";
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public enum DetectionResponseEnum {
|
||||
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
|
||||
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
|
||||
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
|
||||
SCRIPT_NAME_REPEAT("A02015","脚本名称重复"),
|
||||
|
||||
|
||||
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
|
||||
@@ -46,7 +47,9 @@ public enum DetectionResponseEnum {
|
||||
DEVICE_DIS_ERROR("A02055", "装置配置异常"),
|
||||
DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"),
|
||||
CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"),
|
||||
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败");
|
||||
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"),
|
||||
CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误,只能包含数字,长度为1-32位"),
|
||||
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位" );
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.report.pojo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -34,4 +35,5 @@ public class DevReportParam implements Serializable {
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
private List<String> devIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.njcn.gather.report.pojo.constant;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电能质量指标常用的一些常量池
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/27 11:11
|
||||
*/
|
||||
public interface PowerConstant {
|
||||
|
||||
/**
|
||||
* 有三相的指标
|
||||
*/
|
||||
List<String> THREE_PHASE = Arrays.asList("V", "HV", "HI", "HP", "HSV", "HSI", "I", "P", "F");
|
||||
|
||||
/**
|
||||
* T相指标
|
||||
*/
|
||||
List<String> T_PHASE = Arrays.asList("VOLTAGE", "IMBV", "IMBA", "FREQ");
|
||||
|
||||
|
||||
/**
|
||||
* 有次数的指标
|
||||
*/
|
||||
List<String> TIME = Arrays.asList("HV", "HI", "HP", "HSV", "HSI");
|
||||
|
||||
/**
|
||||
* 没有次数的指标
|
||||
*/
|
||||
List<String> NO_TIME = Arrays.asList("V", "I", "P", "VOLTAGE", "IMBV", "IMBA", "F", "FREQ");
|
||||
|
||||
/**
|
||||
* 有数据范围
|
||||
*/
|
||||
List<Integer> DATA_RANGE = Arrays.asList(1, 2);
|
||||
|
||||
/**
|
||||
* 暂态符号
|
||||
*/
|
||||
String VOLTAGE = "VOLTAGE";
|
||||
|
||||
/**
|
||||
* A相
|
||||
*/
|
||||
String PHASE_A = "A";
|
||||
|
||||
/**
|
||||
* B相
|
||||
*/
|
||||
String PHASE_B = "B";
|
||||
|
||||
/**
|
||||
* C相
|
||||
*/
|
||||
String PHASE_C = "C";
|
||||
|
||||
/**
|
||||
* T相
|
||||
*/
|
||||
String PHASE_T = "T";
|
||||
|
||||
/**
|
||||
* 电流单位
|
||||
*/
|
||||
String CURRENT_UNIT = "A";
|
||||
|
||||
/**
|
||||
* 电压单位
|
||||
*/
|
||||
String VOLTAGE_UNIT = "V";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.gather.report.pojo.constant;
|
||||
|
||||
/**
|
||||
*
|
||||
* 报告相关的一些常量
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/4/3 13:44
|
||||
*/
|
||||
public interface ReportConstant {
|
||||
|
||||
/**
|
||||
* docx文档后缀
|
||||
*/
|
||||
String DOCX = ".docx";
|
||||
|
||||
/**
|
||||
* 报告模板中书签的起始标识
|
||||
*/
|
||||
String BOOKMARK_START = "#{";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 影响量枚举
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/27 21:07
|
||||
*/
|
||||
@Getter
|
||||
public enum AffectEnum {
|
||||
|
||||
|
||||
BASE("base", "额定工作条件下的检测"),
|
||||
VOL("vol", "电压对XX测量的影响"),
|
||||
FREQ("freq", "频率对XX测量的影响"),
|
||||
HARM("harm", "谐波对XX测量的影响");
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
AffectEnum(String key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static AffectEnum getByKey(String key) {
|
||||
for (AffectEnum affectEnum : AffectEnum.values()) {
|
||||
if (affectEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return affectEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
* 本枚举用于记录模板中关键字的含义
|
||||
* 比如 ${manufacturer} 对应的设备厂家
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/24 14:34
|
||||
*
|
||||
* */
|
||||
@Getter
|
||||
public enum BaseReportKeyEnum {
|
||||
|
||||
DEV_TYPE("devType","设备型号、规格"),
|
||||
DEV_CODE("createId","装置编号"),
|
||||
POWER("power","工作电源"),
|
||||
DEV_CURR("devCurr","额定电流"),
|
||||
DEV_VOLT("devVolt","额定电压"),
|
||||
COUNT("count","通道数"),
|
||||
MANUFACTURER("manufacturer","设备厂家、制造厂商"),
|
||||
SAMPLE_ID("sampleId","样品编号"),
|
||||
ARRIVED_DATE("arrivedDate","收样日期"),
|
||||
TEST_DATE("testDate","检测日期"),
|
||||
INSPECTOR("inspector","检测员"),
|
||||
YEAR("year","年份"),
|
||||
MONTH("month","月份"),
|
||||
DAY("day","日"),
|
||||
YEAR_MONTH_DAY("year-month-day","年-月-日");
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
BaseReportKeyEnum(String key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 统计文档锚点类型
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/24 18:42
|
||||
*/
|
||||
@Getter
|
||||
public enum DocAnchorEnum {
|
||||
|
||||
|
||||
DATA_LINE("#{data:line}", "准确度数据展示区域,以测试回路维度展示", 1),
|
||||
DATA_SCRIPT("#{data:script}", "准确度数据展示区域,以检测项维度展示", 1),
|
||||
TEST_RESULT_DEV("#{testResult:dev}", "检测结论,仅有设备结论", 2),
|
||||
TEST_RESULT_LINE("#{testResult:line}", "检测结论,仅有回路结论", 2),
|
||||
TEST_RESULT_DETAIL("#{testResult:detail}", "检测结论,包含回路、设备结论", 2),
|
||||
CATALOG("#{catalog}", "目录信息", 3);
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
DocAnchorEnum(String key, String desc, Integer sort) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static DocAnchorEnum getByKey(String key) {
|
||||
for (DocAnchorEnum docAnchorEnum : DocAnchorEnum.values()) {
|
||||
if (docAnchorEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return docAnchorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 检测项模版枚举
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/27 10:24
|
||||
*/
|
||||
@Getter
|
||||
public enum ItemReportKeyEnum {
|
||||
|
||||
NAME("name", "检测项,比如:频率"),
|
||||
NAME_DETAIL("nameDetail", "检测项详细,比如:频率测量准确度"),
|
||||
ERROR_SCOPE("errorScope", "误差范围,注:在段落中时需加上(),表格中无需添加"),
|
||||
ERROR_SCOPE_MAG("errorScopeMag", "特征幅值:误差范围"),
|
||||
ERROR_SCOPE_DUR("errorScopeDur", "持续时间:误差范围"),
|
||||
SCRIPT_DETAIL("scriptDetail", "脚本输出明细。比如:基波电压UN=57.74V,f=50Hz,谐波含有率Uh=10%UN=5.774V"),
|
||||
TIME("time", "次数"),
|
||||
STANDARD("standard", "标准值"),
|
||||
STANDARD_A("standardA", "A相标准值"),
|
||||
STANDARD_B("standardB", "B相标准值"),
|
||||
STANDARD_C("standardC", "C相标准值"),
|
||||
STANDARD_MAG("standardMag", "特征幅值的标准值"),
|
||||
STANDARD_DUR("standardDur_ms", "持续时间的标准值"),
|
||||
TEST("test", "测试值"),
|
||||
TEST_MAG("testMag", "特征幅值测试值"),
|
||||
TEST_DUR("testDur_ms", "持续时间测试值"),
|
||||
TEST_A("testA", "A相测试值"),
|
||||
TEST_B("testB", "B相测试值"),
|
||||
TEST_C("testC", "C相测试值"),
|
||||
ERROR("error", "误差"),
|
||||
ERROR_MAG("errorMag", "特征幅值误差"),
|
||||
ERROR_DUR("errorDur_ms", "持续时间误差"),
|
||||
ERROR_A("errorA", "A相误差"),
|
||||
ERROR_B("errorB", "B相误差"),
|
||||
ERROR_C("errorC", "C相误差"),
|
||||
RESULT("result", "结论 比如:合格/不合格"),
|
||||
RESULT_A("resultA", "结论 比如:合格/不合格"),
|
||||
RESULT_B("resultB", "结论 比如:合格/不合格"),
|
||||
RESULT_C("resultC", "结论 比如:合格/不合格"),
|
||||
RESULT_MAG("resultMag", "特征幅值结论 比如:合格/不合格"),
|
||||
RESULT_DUR("resultDur", "持续时间结论 比如:合格/不合格");
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
ItemReportKeyEnum(String key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static ItemReportKeyEnum getByKey(String key) {
|
||||
for (ItemReportKeyEnum itemReportKetEnum : ItemReportKeyEnum.values()) {
|
||||
if (itemReportKetEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return itemReportKetEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 电能质量测试大项枚举
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/27 18:29
|
||||
*/
|
||||
@Getter
|
||||
public enum PowerIndexEnum {
|
||||
|
||||
|
||||
UNKNOWN("UNKNOWN", "未知指标"),
|
||||
FREQ("FREQ", "频率"),
|
||||
V("V", "电压"),
|
||||
I("I", "电流"),
|
||||
IMBV("IMBV", "三相电压不平衡度"),
|
||||
IMBA("IMBA", "三相电流不平衡度"),
|
||||
F("F", "闪变"),
|
||||
HP("HP", "谐波有功功率"),
|
||||
HV("HV", "谐波电压"),
|
||||
HI("HI", "谐波电流"),
|
||||
HSV("HSV", "间谐波电压"),
|
||||
HSI("HSI", "间谐波电流"),
|
||||
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断");
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
PowerIndexEnum(String key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static PowerIndexEnum getByKey(String key) {
|
||||
for (PowerIndexEnum powerIndexEnum : PowerIndexEnum.values()) {
|
||||
if (powerIndexEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return powerIndexEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,11 @@ public enum ReportResponseEnum {
|
||||
REPORT_TEMPLATE_NOT_EXIST("A012009", "报告模板缺失,请联系管理员!"),
|
||||
NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"),
|
||||
FILE_RENAME_FAILED("A012011", "文件重命名失败"),
|
||||
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线,长度不能超过50个字符"),
|
||||
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线,点号,长度不能超过50个字符"),
|
||||
FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" );
|
||||
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误,可包含中文、字母、数字、中划线、点号、空格,长度不能超过32个字符"),
|
||||
FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" ),
|
||||
GENERATE_REPORT_ERROR("A012015","生成报告失败"),
|
||||
;
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.gather.report.pojo.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* 测试大项的检测结果
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/4/7 20:17
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SingleTestResult implements Serializable {
|
||||
|
||||
/**
|
||||
* 大项名称
|
||||
*/
|
||||
private String scriptCode;
|
||||
|
||||
/**
|
||||
* 是否合格
|
||||
*/
|
||||
private boolean qualified;
|
||||
|
||||
|
||||
/**
|
||||
* 细节集合
|
||||
*/
|
||||
private Map<String, List<Map<String, List<Map<String, String>>>>> detail;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.gather.report.pojo.vo;
|
||||
|
||||
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/4/7 15:36
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Bookmark implements Serializable,Comparable<Bookmark>{
|
||||
|
||||
/**
|
||||
* 在文档中段落的索引
|
||||
*/
|
||||
private Integer index;
|
||||
|
||||
/**
|
||||
* 对应枚举
|
||||
*/
|
||||
private DocAnchorEnum docAnchorEnum;
|
||||
|
||||
|
||||
/**
|
||||
* 根据书签的排序字段进行排序
|
||||
* @param bookmark the object to be compared.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Bookmark bookmark) {
|
||||
return Integer.compare(this.docAnchorEnum.getSort(), bookmark.docAnchorEnum.getSort());
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,6 @@ public interface IPqReportService extends IService<PqReport> {
|
||||
void generateReport(DevReportParam devReportParam);
|
||||
|
||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||
|
||||
//Map<String, Object> getMap(DevReportParam devReportParam);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/25 19:37
|
||||
*/
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
public class Docx4jInsertParagraph {
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 加载现有的 Word 文档
|
||||
WordprocessingMLPackage wordPackage = WordprocessingMLPackage.load(new File("C:\\Users\\hongawen\\Desktop\\base_template.docx"));
|
||||
MainDocumentPart documentPart = wordPackage.getMainDocumentPart();
|
||||
|
||||
// 获取文档中的所有段落
|
||||
List<Object> paragraphs = documentPart.getContent();
|
||||
|
||||
// 在中间插入一个新段落
|
||||
int insertIndex = paragraphs.size() / 2;
|
||||
P newParagraph = createParagraph("This is a new paragraph inserted in the middle.");
|
||||
paragraphs.add(insertIndex, newParagraph);
|
||||
|
||||
// 保存修改后的文档
|
||||
wordPackage.save(new File("example_modified.docx"));
|
||||
}
|
||||
|
||||
private static P createParagraph(String text) {
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
Text t = factory.createText();
|
||||
t.setValue(text);
|
||||
run.getContent().add(t);
|
||||
paragraph.getContent().add(run);
|
||||
return paragraph;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,537 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.gather.report.pojo.constant.ReportConstant;
|
||||
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
|
||||
import com.njcn.gather.report.pojo.vo.Bookmark;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/26 13:47
|
||||
*/
|
||||
public class Docx4jUtil {
|
||||
|
||||
/**
|
||||
* 创建标题
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param paragraph 段落容器
|
||||
* @param content 标题内容
|
||||
* @param fontSize 字体大小
|
||||
* @param isBold 是否加粗
|
||||
*/
|
||||
public static void createTitle(ObjectFactory factory, P paragraph, String content, int fontSize, boolean isBold) {
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(content);
|
||||
// 创建运行属性
|
||||
RPr rPr = factory.createRPr();
|
||||
// 设置字体
|
||||
RFonts fonts = factory.createRFonts();
|
||||
fonts.setAscii("Arial");
|
||||
// 宋体
|
||||
fonts.setEastAsia("SimSun");
|
||||
rPr.setRFonts(fonts);
|
||||
|
||||
// 设置字号
|
||||
HpsMeasure size = new HpsMeasure();
|
||||
// 12号字=24
|
||||
size.setVal(new BigInteger("" + fontSize));
|
||||
rPr.setSz(size);
|
||||
rPr.setSzCs(size);
|
||||
|
||||
// 设置粗体
|
||||
if (isBold) {
|
||||
BooleanDefaultTrue b = new BooleanDefaultTrue();
|
||||
rPr.setB(b);
|
||||
}
|
||||
run.setRPr(rPr);
|
||||
run.getContent().add(text);
|
||||
// 换行
|
||||
// Br br = factory.createBr();
|
||||
// run.getContent().add(br);
|
||||
paragraph.getContent().add(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取Heading 5及其子内容
|
||||
*
|
||||
* @param allContent 文档内所有内容
|
||||
*/
|
||||
public static List<HeadingContent> extractHeading5Contents(List<Object> allContent) {
|
||||
List<HeadingContent> result = new ArrayList<>();
|
||||
boolean inHeading5Section = false;
|
||||
HeadingContent currentHeading = null;
|
||||
|
||||
for (Object obj : allContent) {
|
||||
|
||||
if (obj instanceof P) {
|
||||
P paragraph = (P) obj;
|
||||
if (isHeading5(paragraph)) {
|
||||
// 发现新的Heading 5,保存前一个并创建新的
|
||||
if (currentHeading != null) {
|
||||
result.add(currentHeading);
|
||||
}
|
||||
currentHeading = new HeadingContent();
|
||||
currentHeading.setHeadingText(getTextFromP(paragraph));
|
||||
inHeading5Section = true;
|
||||
} else if (inHeading5Section) {
|
||||
// 当前内容属于Heading 5的子内容
|
||||
currentHeading.addSubContent(paragraph);
|
||||
}
|
||||
} else if (obj instanceof JAXBElement && inHeading5Section) {
|
||||
// 表格属于当前Heading 5的子内容
|
||||
JAXBElement<?> jaxbElement = (JAXBElement<?>) obj;
|
||||
if (jaxbElement.getValue() instanceof Tbl) {
|
||||
currentHeading.addSubContent(obj);
|
||||
}
|
||||
} else if (isHigherLevelHeading(obj)) {
|
||||
// 遇到更高级别的标题,结束当前Heading 5的收集
|
||||
if (currentHeading != null) {
|
||||
result.add(currentHeading);
|
||||
currentHeading = null;
|
||||
}
|
||||
inHeading5Section = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 添加最后一个Heading 5
|
||||
if (currentHeading != null) {
|
||||
result.add(currentHeading);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断段落是否为Heading 5
|
||||
private static boolean isHeading5(P paragraph) {
|
||||
PPr ppr = paragraph.getPPr();
|
||||
if (ppr != null) {
|
||||
PPrBase.PStyle pStyle = ppr.getPStyle();
|
||||
if (pStyle != null && "5".equals(pStyle.getVal())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 判断是否为更高级别的标题(1-4)
|
||||
private static boolean isHigherLevelHeading(Object obj) {
|
||||
if (obj instanceof P) {
|
||||
PPr ppr = ((P) obj).getPPr();
|
||||
if (ppr != null) {
|
||||
PPrBase.PStyle pStyle = ppr.getPStyle();
|
||||
if (pStyle != null) {
|
||||
String style = pStyle.getVal();
|
||||
return style != null && style.matches("[1-4]");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断表格是否横向
|
||||
*
|
||||
* @param obj row
|
||||
*/
|
||||
public static boolean judgeTableCross(Object obj) {
|
||||
Tr row = (Tr) obj;
|
||||
List<Object> content = row.getContent();
|
||||
// 取最后一个单元格,判断是否包含汉字,有汉字就是横向的
|
||||
Object cellObject = content.get(content.size() - 1);
|
||||
JAXBElement<Tc> cellElement = (JAXBElement<Tc>) cellObject;
|
||||
Tc cell = cellElement.getValue();
|
||||
String text = getTextFromCell(cell);
|
||||
if (StrUtil.isBlank(text)) {
|
||||
return true;
|
||||
}
|
||||
// 遍历字符串中的每个字符,存在中文就认为是横向的,理论上设置的key全是英文
|
||||
for (char c : text.toCharArray()) {
|
||||
// 检查字符是否在中文Unicode范围内
|
||||
if (c >= '\u4E00' && c <= '\u9FFF') {
|
||||
// 发现中文字符,返回 false
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取cell内的文本内容
|
||||
*/
|
||||
public static String getTextFromCell(Tc cell) {
|
||||
List<Object> cellContent = cell.getContent();
|
||||
StringBuilder cellText = new StringBuilder();
|
||||
for (Object content : cellContent) {
|
||||
if (content instanceof P) {
|
||||
P paragraph = (P) content;
|
||||
cellText.append(getTextFromP(paragraph));
|
||||
}
|
||||
}
|
||||
return cellText.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从段落中提取纯文本
|
||||
*
|
||||
* @param paragraph 段落
|
||||
* @return 段落内容
|
||||
*/
|
||||
public static String getTextFromP(P paragraph) {
|
||||
StringBuilder textContent = new StringBuilder();
|
||||
for (Object runObj : paragraph.getContent()) {
|
||||
if (runObj instanceof R) {
|
||||
R run = (R) runObj;
|
||||
for (Object textObj : run.getContent()) {
|
||||
if (textObj instanceof Text) {
|
||||
textContent.append(((Text) textObj).getValue());
|
||||
} else if (textObj instanceof JAXBElement) {
|
||||
JAXBElement<?> jaxbElement = (JAXBElement<?>) textObj;
|
||||
if (jaxbElement.getValue() instanceof Text) {
|
||||
Text temp = (Text) jaxbElement.getValue();
|
||||
textContent.append(temp.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return textContent.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取段落的样式
|
||||
*
|
||||
* @param paragraph 段落
|
||||
*/
|
||||
public static RPr getTcPrFromParagraph(P paragraph) {
|
||||
// 1. 获取段落中的所有内容
|
||||
List<Object> content = paragraph.getContent();
|
||||
// 2. 清空原有内容但保留第一个Run的样式
|
||||
RPr preservedRPr = null;
|
||||
if (!content.isEmpty()) {
|
||||
Object firstObj = content.get(0);
|
||||
if (firstObj instanceof R) {
|
||||
// 保存第一个Run的样式
|
||||
preservedRPr = ((R) firstObj).getRPr();
|
||||
}
|
||||
}
|
||||
return preservedRPr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 段落中添加内容
|
||||
*/
|
||||
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr) {
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(content);
|
||||
run.setRPr(rPr);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建N个换行符
|
||||
*/
|
||||
public static void addBr(ObjectFactory factory, P paragraph, int n) {
|
||||
R run = factory.createR();
|
||||
for (int i = 0; i < n; i++) {
|
||||
// 换行
|
||||
Br br = factory.createBr();
|
||||
run.getContent().add(br);
|
||||
}
|
||||
paragraph.getContent().add(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表格行获取需要填的值的key
|
||||
*/
|
||||
public static List<String> getTableKey(Tr row) {
|
||||
List<String> keys = new ArrayList<>();
|
||||
// 横向的,最后一行为需要填充的数据后,前面的均是表头
|
||||
// 遍历获取出该row的所有key
|
||||
List<Object> content = row.getContent();
|
||||
for (Object cellObject : content) {
|
||||
if (cellObject instanceof JAXBElement) {
|
||||
JAXBElement<Tc> cellElement = (JAXBElement<Tc>) cellObject;
|
||||
Tc cell = cellElement.getValue();
|
||||
keys.add(Docx4jUtil.getTextFromCell(cell));
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容中需要填充的keys
|
||||
*
|
||||
* @param tempContent 标题下配置的内容
|
||||
*/
|
||||
public static List<List<String>> getFillKeys(List<HeadingContent> tempContent) {
|
||||
List<List<String>> keys = new ArrayList<>();
|
||||
List<String> pKeys = new ArrayList<>();
|
||||
List<String> tableKeys = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(tempContent)) {
|
||||
// 读取该表下模板里面的内容,这整个内容需要跟随误差范围循环的,确保内容的数据比较用的一个误差范围
|
||||
Docx4jUtil.HeadingContent headingContent = tempContent.get(0);
|
||||
for (Object object : headingContent.getSubContent()) {
|
||||
if (object instanceof P) {
|
||||
// 如果是段落,渲染段落内容
|
||||
P paragraph = (P) object;
|
||||
String textFromP = getTextFromP(paragraph);
|
||||
String[] splitKeys = textFromP.split(StrPool.DASHED);
|
||||
pKeys.addAll(Arrays.asList(splitKeys));
|
||||
} else if (object instanceof JAXBElement) {
|
||||
// 复制表格元素
|
||||
JAXBElement<Tbl> copiedTableElement = (JAXBElement<Tbl>) object;
|
||||
// 解析表格并插入对应数据,最关键的是得知道表格是横向还是纵向以及表头占了几行
|
||||
Tbl tbl = copiedTableElement.getValue();
|
||||
// 获取表格的行
|
||||
List<Object> rows = tbl.getContent();
|
||||
boolean isRow = Docx4jUtil.judgeTableCross(rows.get(0));
|
||||
if (isRow) {
|
||||
// 获取需要填的值的key
|
||||
List<String> cellKeys = Docx4jUtil.getTableKey((Tr) rows.get(rows.size() - 1));
|
||||
tableKeys.addAll(cellKeys);
|
||||
} else {
|
||||
// 纵向表格暂不考虑
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
keys.add(pKeys);
|
||||
keys.add(tableKeys);
|
||||
return keys;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新航
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param valueMap 数据
|
||||
* @param tableKeys keys
|
||||
* @param trPr 行样式
|
||||
* @param tcPr 单元格样式
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, TcPr tcPr, boolean centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (String tableKey : tableKeys) {
|
||||
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);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
pPr.setJc(jc);
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
if (value.equals("不合格")) {
|
||||
RPr rPr = factory.createRPr();
|
||||
Color color = factory.createColor();
|
||||
// 红色
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
run.setRPr(rPr);
|
||||
}
|
||||
cell.getContent().add(paragraph);
|
||||
cell.setTcPr(tcPr);
|
||||
row.getContent().add(cell);
|
||||
row.setTrPr(trPr);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param cellValues 数据
|
||||
* @param ascFontStyle 西文字体
|
||||
* @param eastFontStyle 中文字体
|
||||
* @param size 字体大小
|
||||
* @param boldFlag 是否加粗
|
||||
* @param centerFlag 是否居中
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle,String eastFontStyle, Integer size, boolean boldFlag, boolean centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (String value : cellValues) {
|
||||
Tc cell = factory.createTc();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(value);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
pPr.setJc(jc);
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
RPr rPr = factory.createRPr();
|
||||
if (value.equals("不合格")) {
|
||||
Color color = factory.createColor();
|
||||
// 红色
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
}
|
||||
if(boldFlag){
|
||||
BooleanDefaultTrue bold = factory.createBooleanDefaultTrue();
|
||||
rPr.setB(bold);
|
||||
}
|
||||
RFonts fonts = factory.createRFonts();
|
||||
// 西文字体
|
||||
fonts.setAscii(ascFontStyle);
|
||||
// 中文字体
|
||||
fonts.setEastAsia(eastFontStyle);
|
||||
rPr.setRFonts(fonts);
|
||||
|
||||
HpsMeasure fontSize = factory.createHpsMeasure();
|
||||
fontSize.setVal(BigInteger.valueOf(size));
|
||||
// 西文字号
|
||||
rPr.setSz(fontSize);
|
||||
// 中文字号
|
||||
rPr.setSzCs(fontSize);
|
||||
|
||||
run.setRPr(rPr);
|
||||
cell.getContent().add(paragraph);
|
||||
row.getContent().add(cell);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
public static JAXBElement<Tbl> deepCopyTbl(JAXBElement<Tbl> original) throws Exception {
|
||||
// 使用 docx4j 的 XmlUtils 进行深拷贝
|
||||
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
|
||||
Tbl clonedTbl = (Tbl) XmlUtils.deepCopy(original.getValue());
|
||||
|
||||
// 重新包装为 JAXBElement
|
||||
return new JAXBElement<Tbl>(
|
||||
original.getName(),
|
||||
original.getDeclaredType(),
|
||||
original.getScope(),
|
||||
clonedTbl
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 存储Heading 5及其子内容的辅助类
|
||||
public static class HeadingContent {
|
||||
private String headingText;
|
||||
private List<Object> subContent = new ArrayList<>();
|
||||
|
||||
public void setHeadingText(String text) {
|
||||
this.headingText = text;
|
||||
}
|
||||
|
||||
public String getHeadingText() {
|
||||
return headingText;
|
||||
}
|
||||
|
||||
public void addSubContent(Object obj) {
|
||||
subContent.add(obj);
|
||||
}
|
||||
|
||||
public List<Object> getSubContent() {
|
||||
return subContent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取段落在文档中的位置
|
||||
*/
|
||||
public static int getParagraphPosition(MainDocumentPart baseDocumentPart, DocAnchorEnum docAnchorEnum) {
|
||||
List<Object> baseContent = baseDocumentPart.getContent();
|
||||
for (int i = 0; i < baseContent.size(); i++) {
|
||||
Object obj = baseContent.get(i);
|
||||
if (obj instanceof P) {
|
||||
P p = (P) obj;
|
||||
String text = getTextFromP(p).trim();
|
||||
if (text.startsWith(ReportConstant.BOOKMARK_START)) {
|
||||
DocAnchorEnum anchorEnum = DocAnchorEnum.getByKey(text);
|
||||
if (anchorEnum != null && anchorEnum.getKey().equalsIgnoreCase(docAnchorEnum.getKey())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表格样式
|
||||
*/
|
||||
public static TblPr getTblPr(ObjectFactory factory) {
|
||||
// **关键步骤:设置黑色实线边框**
|
||||
TblPr tblPr = factory.createTblPr();
|
||||
TblBorders borders = factory.createTblBorders();
|
||||
|
||||
// 定义边框样式(1磅黑色单实线)
|
||||
CTBorder border = new CTBorder();
|
||||
// 实线类型
|
||||
border.setVal(STBorder.SINGLE);
|
||||
// 1磅=4单位(1/8磅)
|
||||
border.setSz(BigInteger.valueOf(4));
|
||||
// 黑色
|
||||
border.setColor("000000");
|
||||
|
||||
// 应用边框到所有边
|
||||
borders.setTop(border);
|
||||
borders.setBottom(border);
|
||||
borders.setLeft(border);
|
||||
borders.setRight(border);
|
||||
// 内部水平线
|
||||
borders.setInsideH(border);
|
||||
// 内部垂直线
|
||||
borders.setInsideV(border);
|
||||
|
||||
tblPr.setTblBorders(borders);
|
||||
|
||||
|
||||
// 设置表格宽度为96%
|
||||
TblWidth tblWidth = factory.createTblWidth();
|
||||
// 百分比类型
|
||||
tblWidth.setType("pct");
|
||||
// 96% = 4800/5000 (ISO标准)
|
||||
tblWidth.setW(BigInteger.valueOf(5000));
|
||||
tblPr.setTblW(tblWidth);
|
||||
|
||||
return tblPr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -45,54 +51,6 @@ public class WordUtil {
|
||||
});
|
||||
}
|
||||
|
||||
private static void insertPageBreak(XWPFDocument target) {
|
||||
if(!isDocumentEmpty(target)){
|
||||
// 获取最后一个页面的段落
|
||||
XWPFParagraph pageBreakParagraph = getLastPageParagraph(target);
|
||||
// 设置分页符
|
||||
pageBreakParagraph.setPageBreak(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDocumentEmpty(XWPFDocument document) {
|
||||
// 检查段落
|
||||
List<XWPFParagraph> paragraphs = document.getParagraphs();
|
||||
if (paragraphs != null && !paragraphs.isEmpty()) {
|
||||
for (XWPFParagraph paragraph : paragraphs) {
|
||||
if (paragraph.getText() != null && !paragraph.getText().trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查表格
|
||||
List<XWPFTable> tables = document.getTables();
|
||||
if (tables != null && !tables.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static XWPFParagraph getLastPageParagraph(XWPFDocument document) {
|
||||
XWPFParagraph lastPageParagraph = null;
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
lastPageParagraph = paragraph;
|
||||
}
|
||||
|
||||
return lastPageParagraph;
|
||||
}
|
||||
|
||||
private static boolean containsPageBreak(XWPFParagraph paragraph) {
|
||||
for (XWPFRun run : paragraph.getRuns()) {
|
||||
if (run.getText(0) != null && run.getText(0).contains("\f")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 替换表格中的占位符
|
||||
@@ -145,6 +103,42 @@ public class WordUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换文档中的占位符
|
||||
* @param document 文档
|
||||
* @param placeholders 待替换的占位符
|
||||
*/
|
||||
public static void replacePlaceholders(XWPFDocument document, Map<String, String> placeholders) {
|
||||
replacePlaceholdersInParagraphs(document,placeholders);
|
||||
replacePlaceholdersInTables(document,placeholders);
|
||||
}
|
||||
|
||||
|
||||
public static List<XWPFParagraph> findHeadingLevel5Paragraphs(XWPFDocument document) {
|
||||
List<XWPFParagraph> headingLevel5Paragraphs = new ArrayList<>();
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
String style = paragraph.getStyle();
|
||||
if ("5".equals(style)) {
|
||||
headingLevel5Paragraphs.add(paragraph);
|
||||
}
|
||||
}
|
||||
return headingLevel5Paragraphs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取段落的位置(通过遍历bodyElements)
|
||||
*/
|
||||
public static int getBodyElementPosition(XWPFDocument document, XWPFParagraph paragraph) {
|
||||
List<IBodyElement> bodyElements = document.getBodyElements();
|
||||
for (int i = 0; i < bodyElements.size(); i++) {
|
||||
if (bodyElements.get(i) instanceof XWPFParagraph && bodyElements.get(i).equals(paragraph)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,7 +17,7 @@ public class ResultVO {
|
||||
/**
|
||||
* 结果数据
|
||||
*/
|
||||
private Map<String, RawResultDataVO> resultData;
|
||||
private Map<String, List<RawResultDataVO>> resultData;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.njcn.gather.result.service;
|
||||
|
||||
import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -75,4 +78,22 @@ public interface IResultService {
|
||||
* @param param
|
||||
*/
|
||||
void reCalculate(ResultParam.ChangeErrorSystemParam param);
|
||||
|
||||
/**
|
||||
* 获取某测试大项的检测项内容
|
||||
*
|
||||
* @param checkDataVOList 检测项脚本
|
||||
* @param planCode 计划编号
|
||||
* @param devId 被检设备id
|
||||
* @param lineNo 回路号
|
||||
* @param tableKeys 表格key
|
||||
*/
|
||||
SingleTestResult getFinalContent(List<PqScriptDtlDataVO> checkDataVOList, String planCode, String devId, Integer lineNo, List<String> tableKeys);
|
||||
|
||||
/**
|
||||
* 获取段落中指定的key对应的值
|
||||
* @param itemCode 测试大项code
|
||||
* @param pKeys 待填充的值
|
||||
*/
|
||||
Map<String, String> getParagraphKeysValue(String itemCode, List<String> pKeys);
|
||||
}
|
||||
|
||||
@@ -4,20 +4,30 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.constant.PowerConstant;
|
||||
import com.njcn.gather.report.pojo.enums.AffectEnum;
|
||||
import com.njcn.gather.report.pojo.enums.ItemReportKeyEnum;
|
||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||
import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
@@ -30,10 +40,12 @@ import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
@@ -299,7 +311,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
dlt = new TreeDataVO();
|
||||
List<PqScriptDtls> scriptDtlIndexList = subValue.stream().filter(x -> dtls.getScriptIndex().equals(x.getScriptIndex())).collect(Collectors.toList());
|
||||
//特征幅值=20%Un,持续时间=1周波
|
||||
dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波");
|
||||
dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime() + "周波");
|
||||
dlt.setIndex(dtls.getScriptIndex());
|
||||
dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType());
|
||||
dlt.setScriptTypeCode("Base_" + start + "_" + end);
|
||||
@@ -374,7 +386,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
//叠加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()
|
||||
+ "次" + dictTree.getName() + "(含有率为GB/T)");
|
||||
+ "次" + dictTree.getName()); // + "(含有率为GB/T)"
|
||||
} else {
|
||||
//叠加5%的2次谐波电压
|
||||
dtlType.setScriptTypeName("叠加" + hv.get(0).getValue().intValue() + ResultUnitEnum.HV.getUnit() + "的" + hv.get(0).getHarmNum().intValue() + "次" + dictTree.getName());
|
||||
@@ -505,6 +517,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
case VOLTAGE_MAG:
|
||||
case VOLTAGE_DUR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +598,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
case VOLTAGE_MAG:
|
||||
case VOLTAGE_DUR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,6 +691,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
case VOLTAGE_MAG:
|
||||
case VOLTAGE_DUR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,6 +788,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<PqScriptDtls> dip = dtls.stream().filter(x -> "Dip".equals(x.getValueType())).collect(Collectors.toList());
|
||||
dtlType.setScriptTypeName("频率=" + dipf.get(0).getValue() + ResultUnitEnum.FREQ.getUnit() + ",特征幅值=" + dip.get(0).getTransValue().intValue() + "%Un,持续时间=" + dip.get(0).getRetainTime().intValue() + "周波");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,6 +930,496 @@ public class ResultServiceImpl implements IResultService {
|
||||
this.calculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某测试大项的检测项内容,主要针对表格需要填充的值
|
||||
* 注:虽然测试项区是三相,他们的标准值可能不同,但是误差范围是一致的
|
||||
* 1、区分额定条件、单影响量条件、单影响量条件
|
||||
* 2、区分scriptIndex
|
||||
* 3、区分谐波次数(有必要的情况下)
|
||||
*
|
||||
* @param dtlDataVOList 检测项脚本
|
||||
* @param planCode 计划编号
|
||||
* @param devId 被检设备id
|
||||
* @param lineNo 回路号
|
||||
* @param tableKeys 表格key
|
||||
*/
|
||||
@Override
|
||||
public SingleTestResult getFinalContent(List<PqScriptDtlDataVO> dtlDataVOList, String planCode, String devId, Integer lineNo, List<String> tableKeys) {
|
||||
SingleTestResult singleTestResult = new SingleTestResult();
|
||||
Map<String/*subType影响量,额定或某单影响量*/, List<Map<String/*误差范围*/, List<Map<String/*填充key*/, String/*实际值*/>>>>> finalContent = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(dtlDataVOList)) {
|
||||
// 首先区分测试条件
|
||||
Map<String, List<PqScriptDtlDataVO>> subTypeMap = dtlDataVOList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptSubType));
|
||||
subTypeMap.forEach((subType, scriptDtlDataVOList) -> {
|
||||
AffectEnum affectEnum = AffectEnum.getByKey(subType);
|
||||
if (Objects.nonNull(affectEnum)) {
|
||||
String scriptCode = scriptDtlDataVOList.get(0).getScriptCode();
|
||||
String scriptId = scriptDtlDataVOList.get(0).getScriptId();
|
||||
PowerIndexEnum indexEnum = PowerIndexEnum.getByKey(scriptCode);
|
||||
if (Objects.nonNull(indexEnum)) {
|
||||
String affectName = affectEnum.getDesc().replaceAll("XX", indexEnum.getDesc());
|
||||
// 同一个影响量下,获取出子脚本信息
|
||||
List<Integer> indexList = scriptDtlDataVOList.stream().map(PqScriptDtlDataVO::getScriptIndex).distinct().collect(Collectors.toList());
|
||||
List<PqScriptCheckData> scriptCheckDataList = pqScriptCheckDataService.listCheckData(scriptId, indexList);
|
||||
List<String> valueTypeList = scriptCheckDataList.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
// 稍作区分,暂态的脚本同一个scriptIndex可以有两个指标,其余脚本每个checkData的valueType对应一个指标结果
|
||||
if (PowerConstant.VOLTAGE.equalsIgnoreCase(scriptCode)) {
|
||||
// 暂态的valueType通常只有2个,一个特征幅值,一个持续时间
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (Integer sort : indexList) {
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillVoltagePhaseData(nonHarmList, keyFillMap, tableKeys);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
// 需要对所有填充进行按误差范围分组
|
||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||
// 分组后,还需要针对特征幅值标准值进行一个升序
|
||||
errorScoperMap.forEach((errorScope, maps) -> {
|
||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD_MAG.getKey());
|
||||
});
|
||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||
errorList.add(errorScoperMap);
|
||||
// 最后赋值返回
|
||||
finalContent.put(affectName, errorList);
|
||||
} else {
|
||||
for (String valueType : valueTypeList) {
|
||||
if (PowerConstant.TIME.contains(scriptCode)) {
|
||||
// 查询结果数据,经过上层处理谐波类此处的scriptIndex确保只有一个
|
||||
if (indexList.size() == 1) {
|
||||
// 获取谐波数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueType, indexList.get(0));
|
||||
AdHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
||||
// 注:如果ABC的标准值一致,则同步到standard中
|
||||
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
checkDataHarmNumMap.forEach((harmNum, dtlsList) -> {
|
||||
Map<String, String> keyFillMap = new HashMap<>();
|
||||
// 次数需要区分谐波&间谐波
|
||||
String time;
|
||||
if (harmNum % 1 == 0) {
|
||||
// 谐波,需要转为正数字符串
|
||||
time = String.valueOf(harmNum.intValue());
|
||||
} else {
|
||||
// 间谐波,保留小数位转为字符串
|
||||
time = String.format("%.1f", harmNum);
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.TIME.getKey(), time);
|
||||
// 将间谐波次数取整1.5取2,2.5取3
|
||||
double timeDouble = Math.round(harmNum);
|
||||
int timeInt = (int) timeDouble;
|
||||
// 填充结果数据
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
});
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 按次数排序
|
||||
PubUtils.sortByDoubleValue(keyFillMapList, ItemReportKeyEnum.TIME.getKey());
|
||||
// 取出任意一次谐波数据的误差范围作为key
|
||||
String titleScope = keyFillMapList.get(0).get(ItemReportKeyEnum.ERROR_SCOPE.getKey());
|
||||
Map<String, List<Map<String, String>>> errorScoperMap = new HashMap<>();
|
||||
errorScoperMap.put(titleScope, keyFillMapList);
|
||||
List<Map<String, List<Map<String, String>>>> errorScoperMapList = new ArrayList<>();
|
||||
errorScoperMapList.add(errorScoperMap);
|
||||
finalContent.put(affectName, errorScoperMapList);
|
||||
}
|
||||
} else {
|
||||
log.error("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
||||
throw new BusinessException("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
||||
}
|
||||
} else {
|
||||
// 非谐波的需要区分是否为ABC相还是T相
|
||||
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
||||
// 获取该三相的数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 需要对所有的填充进行按误差范围分组
|
||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||
// 分组后,还需要针对标准值进行一个升序
|
||||
errorScoperMap.forEach((errorScope, maps) -> {
|
||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
||||
});
|
||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||
errorList.add(errorScoperMap);
|
||||
// 最后赋值返回
|
||||
finalContent.put(affectName, errorList);
|
||||
}
|
||||
} else {
|
||||
log.error("生成三相类表格数据失败,结果表数据丢失,请核实。");
|
||||
}
|
||||
} else {
|
||||
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(8);
|
||||
fillTPhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 需要对所有填充进行按误差范围分组
|
||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||
// 分组后,还需要针对特征幅值标准值进行一个升序
|
||||
errorScoperMap.forEach((errorScope, maps) -> {
|
||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
||||
});
|
||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||
errorList.add(errorScoperMap);
|
||||
// 最后赋值返回
|
||||
finalContent.put(affectName, errorList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error("未找到合适的脚本信息");
|
||||
}
|
||||
} else {
|
||||
log.error("未找到合适的测量条件");
|
||||
}
|
||||
});
|
||||
}
|
||||
// 返回之前做下总结性判断
|
||||
singleTestResult.setQualified(judgeQualified(finalContent));
|
||||
singleTestResult.setDetail(finalContent);
|
||||
return singleTestResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 三相的相关数据处理
|
||||
* 包含:谐波、间谐波、电压、电流、功率、闪变
|
||||
*
|
||||
* @param singleResult 可能是谐波类,也有可能是电压电流,需要区分下结果
|
||||
* @param timeInt 谐波类需要传指定次数
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
*/
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
||||
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
||||
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
||||
// 待填充Key
|
||||
String standard = "/", standardA = "/", standardB = "/", standardC = "/",
|
||||
testA = "/", testB = "/", testC = "/",
|
||||
errorA = "/", errorB = "/", errorC = "/",
|
||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
||||
errorScope = "/", unit = "";
|
||||
|
||||
if (Objects.nonNull(tempA) && (PowerConstant.DATA_RANGE.contains(tempA.getIsData()))) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : "不合格";
|
||||
errorScope = tempA.getRadius();
|
||||
unit = tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempB) && (PowerConstant.DATA_RANGE.contains(tempB.getIsData()))) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempB.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempB.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(tempC) && (PowerConstant.DATA_RANGE.contains(tempC.getIsData()))) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempC.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempC.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
}
|
||||
}
|
||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
||||
standard = standardA;
|
||||
}
|
||||
// 标准值
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_B.getKey(), standardB);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_C.getKey(), standardC);
|
||||
// 测试值
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST_A.getKey(), testA);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST_B.getKey(), testB);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST_C.getKey(), testC);
|
||||
// 误差值
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_A.getKey(), errorA);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_B.getKey(), errorB);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_C.getKey(), errorC);
|
||||
// 结果
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT_A.getKey(), resultA);
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT_B.getKey(), resultB);
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT_C.getKey(), resultC);
|
||||
if (resultA.equals("不合格") || resultB.equals("不合格") || resultC.equals("不合格")) {
|
||||
result = "不合格";
|
||||
} else if (!resultA.equals("/") || !resultB.equals("/") || !resultC.equals("/")) {
|
||||
result = "合格";
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||
errorScope = dealErrorScope(errorScope).concat(unit);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* T相的相关数据处理,非暂态数据
|
||||
* 包含:三相电压/电流不平衡度、频率,其中三相电压/电流实际ABC中存了正序/负序/零序电压
|
||||
*
|
||||
* @param singleResult 可能是谐波类,也有可能是电压电流,需要区分下结果
|
||||
* @param timeInt 谐波类需要传指定次数
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
*/
|
||||
private void fillTPhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/", unit = "";
|
||||
DetectionData tempT = getResultData(singleResult, timeInt, PowerConstant.PHASE_T);
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
result = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unit = tempT.getUnit();
|
||||
errorScope = tempT.getRadius();
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR.getKey(), error);
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||
errorScope = dealErrorScope(errorScope).concat(unit);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对暂态的数据填充
|
||||
*
|
||||
* @param nonHarmList 暂态的结果集
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
* @param tableKeys 模板表格中的key
|
||||
*/
|
||||
private void fillVoltagePhaseData(List<AdNonHarmonicResult> nonHarmList, Map<String, String> keyFillMap, List<String> tableKeys) {
|
||||
String standardMag = "/", standardDur = "/",
|
||||
testMag = "/", testDur = "/",
|
||||
errorMag = "/", errorDur = "/",
|
||||
resultMag = "/", resultDur = "/", result,
|
||||
errorScope, errorScopeMag = "/", errorScopeDur = "/",
|
||||
unitMag = "", unitDur = "";
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
DetectionData tempT = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_T);
|
||||
// 需要判断adNonHarmonicResult是特征幅值还是持续时间
|
||||
String adType = adNonHarmonicResult.getAdType();
|
||||
DictTree temp = dictTreeService.getById(adType);
|
||||
if (temp.getCode().equalsIgnoreCase("MAG")) {
|
||||
// 特征幅值
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unitMag = tempT.getUnit();
|
||||
errorScopeMag = tempT.getRadius();
|
||||
}
|
||||
} else if (temp.getCode().equalsIgnoreCase("DUR")) {
|
||||
// 持续时间,需要注意时间单位处理,默认是秒
|
||||
String timeUnit = "s";
|
||||
for (String tableKey : tableKeys) {
|
||||
if (tableKey.contains(ItemReportKeyEnum.STANDARD_DUR.getKey())) {
|
||||
//截取单位
|
||||
String[] tempStr = tableKey.split(StrPool.UNDERLINE);
|
||||
if (tempStr.length > 1) {
|
||||
if (tempStr[1].equalsIgnoreCase("ms")) {
|
||||
timeUnit = "ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unitDur = tempT.getUnit();
|
||||
errorScopeDur = tempT.getRadius();
|
||||
if (timeUnit.equalsIgnoreCase("ms")) {
|
||||
// 如果是ms,上述的一些数据需要重新处理
|
||||
if (!standardDur.equalsIgnoreCase("/")) {
|
||||
standardDur = PubUtils.doubleRoundStr(4, Double.parseDouble(standardDur) * 1000);
|
||||
}
|
||||
if (!testDur.equalsIgnoreCase("/")) {
|
||||
testDur = PubUtils.doubleRoundStr(4, Double.parseDouble(testDur) * 1000);
|
||||
}
|
||||
if (!errorDur.equalsIgnoreCase("/")) {
|
||||
errorDur = PubUtils.doubleRoundStr(4, Double.parseDouble(errorDur) * 1000);
|
||||
}
|
||||
if (!errorScopeDur.equalsIgnoreCase("/")) {
|
||||
if (errorScopeDur.contains("~")) {
|
||||
String[] tempStr = errorScopeDur.split("~");
|
||||
errorScopeDur = PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[0]) * 1000).concat("~").concat(PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[1]) * 1000));
|
||||
}
|
||||
}
|
||||
unitDur = "ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
errorScopeMag = dealErrorScope(errorScopeMag).concat(unitMag);
|
||||
errorScopeDur = dealErrorScope(errorScopeDur).concat(unitDur);
|
||||
|
||||
errorScope = "特征幅值:".concat(errorScopeMag).concat(StrPool.COMMA).concat("持续时间:").concat(errorScopeDur);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
// 标准值
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_MAG.getKey(), standardMag);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_DUR.getKey(), standardDur);
|
||||
// 测试值
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST_MAG.getKey(), testMag);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST_DUR.getKey(), testDur);
|
||||
// 误差
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_MAG.getKey(), errorMag);
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_DUR.getKey(), errorDur);
|
||||
// 结果
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT_MAG.getKey(), resultMag);
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT_DUR.getKey(), resultDur);
|
||||
// 综合结果
|
||||
result = resultMag;
|
||||
if (!resultDur.equals("/") && result.equals("合格")) {
|
||||
if (resultDur.equals("不合格")) {
|
||||
result = "不合格";
|
||||
}
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理下误差范围,如果正负数一致时调整为±的形式
|
||||
* 数据库中一般形式为:-0.1155~0.1155
|
||||
*
|
||||
* @param errorScope 误差范围
|
||||
*/
|
||||
private String dealErrorScope(String errorScope) {
|
||||
if (errorScope.contains("~")) {
|
||||
String[] split = errorScope.split("~");
|
||||
String begin = split[0];
|
||||
if (begin.contains(StrPool.DASHED)) {
|
||||
begin = begin.substring(1);
|
||||
}
|
||||
String end = split[1];
|
||||
if (end.equalsIgnoreCase(begin)) {
|
||||
return "±" + begin;
|
||||
}
|
||||
}
|
||||
return errorScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历所有的结果,是否存在不合格,但凡有一个不合格就返回false
|
||||
*
|
||||
* @param finalContent 最终结果
|
||||
*/
|
||||
private boolean judgeQualified(Map<String, List<Map<String, List<Map<String, String>>>>> finalContent) {
|
||||
List<String> results = finalContent.values().parallelStream()
|
||||
.flatMap(List::stream)
|
||||
.flatMap(m -> m.values().stream())
|
||||
.flatMap(List::stream)
|
||||
.filter(map -> map.containsKey(ItemReportKeyEnum.RESULT.getKey()))
|
||||
.map(map -> map.get(ItemReportKeyEnum.RESULT.getKey()))
|
||||
.collect(Collectors.toList());
|
||||
List<String> qualifiedList = results.stream().filter("不合格"::equals).collect(Collectors.toList());
|
||||
return CollUtil.isEmpty(qualifiedList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据谐波结果数据获取局的测试数据
|
||||
*
|
||||
* @param singleResult 谐波数据
|
||||
* @param timeInt 次数
|
||||
* @param phaseA 相别
|
||||
*/
|
||||
private DetectionData getResultData(Object singleResult, Integer timeInt, String phaseA) {
|
||||
String fieldName = phaseA.toLowerCase().concat("Value");
|
||||
if (Objects.nonNull(timeInt)) {
|
||||
fieldName = fieldName.concat(String.valueOf(timeInt));
|
||||
}
|
||||
String filedValue;
|
||||
try {
|
||||
filedValue = (String) ReflectUtil.getFieldValue(singleResult, fieldName);
|
||||
} catch (Exception exception) {
|
||||
throw new BusinessException("获取对象字段属性失败");
|
||||
}
|
||||
return JSONUtil.toBean(filedValue, DetectionData.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取段落中指定的key对应的值,目前主要为测试大项名称服务,通过code匹配
|
||||
*
|
||||
* @param itemCode 测试大项code
|
||||
* @param pKeys 待填充的值
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getParagraphKeysValue(String itemCode, List<String> pKeys) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(pKeys)) {
|
||||
for (String pKey : pKeys) {
|
||||
ItemReportKeyEnum reportKeyEnum = ItemReportKeyEnum.getByKey(pKey);
|
||||
if (Objects.nonNull(reportKeyEnum)) {
|
||||
if (reportKeyEnum.getKey().equals(ItemReportKeyEnum.NAME.getKey())) {
|
||||
PowerIndexEnum indexEnum = PowerIndexEnum.getByKey(itemCode);
|
||||
if (Objects.nonNull(indexEnum)) {
|
||||
map.put(reportKeyEnum.getKey(), indexEnum.getDesc());
|
||||
} else {
|
||||
log.error("电能指标枚举未找到测试项");
|
||||
}
|
||||
} else if (reportKeyEnum.getKey().equals(ItemReportKeyEnum.NAME_DETAIL.getKey())) {
|
||||
PowerIndexEnum indexEnum = PowerIndexEnum.getByKey(itemCode);
|
||||
if (Objects.nonNull(indexEnum)) {
|
||||
map.put(reportKeyEnum.getKey(), indexEnum.getDesc().concat("测量准确度"));
|
||||
} else {
|
||||
log.error("电能指标枚举未找到测试项");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error("段落枚举未找到占用符");
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
if (numbers.size() > 1) {
|
||||
@@ -1008,10 +1518,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(scriptId, oldCode, devId);
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<AdNonHarmonicResult>> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<AdHarmonicResult> allHarmonicRawData = adHarmonicService.listAll(scriptId, oldCode, devId);
|
||||
List<AdHarmonicResult> allHarmonicRawData = adHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<AdHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
@@ -1034,13 +1544,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
realDataXiList.addAll(this.toList(nonHarmonicResults, null, true));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harmonicResults)) {
|
||||
DictTree dictTree = dictTreeService.getById(harmonicResults.get(0).getAdType());
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) {
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, true));
|
||||
} else {
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, false));
|
||||
}
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(harmonicResults.get(0).getAdType()) || DetectionCodeEnum.I2_50.getCode().equals(harmonicResults.get(0).getAdType()) || DetectionCodeEnum.P2_50.getCode().equals(harmonicResults.get(0).getAdType())) {
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, true));
|
||||
} else {
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1064,8 +1571,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(result.getDataType());
|
||||
DictTree dictTree = dictTreeService.getById(result.getAdType());
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
sqlDataDTO.setDesc(result.getAdType());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null);
|
||||
@@ -1088,16 +1594,15 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
|
||||
DevData.SqlDataHarmDTO dataHarmDTO;
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
DictTree dictTree = dictTreeService.getById(harmonicResult.getAdType());
|
||||
if (containBaseHarm) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(harmonicResult.getDataType());
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode())) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(harmonicResult.getAdType())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
} else if (DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode())) {
|
||||
} else if (DetectionCodeEnum.I2_50.getCode().equals(harmonicResult.getAdType())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
} else {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
sqlDataDTO.setDesc(harmonicResult.getAdType());
|
||||
}
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null);
|
||||
@@ -1109,7 +1614,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
dataHarmDTO = new DevData.SqlDataHarmDTO();
|
||||
dataHarmDTO.setType(harmonicResult.getDataType());
|
||||
dataHarmDTO.setDesc(dictTree.getCode());
|
||||
dataHarmDTO.setDesc(harmonicResult.getAdType());
|
||||
dataHarmDTO.setNum(containBaseHarm ? 49 : 50);
|
||||
DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO();
|
||||
listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm));
|
||||
@@ -1132,9 +1637,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
});
|
||||
|
||||
}
|
||||
// }
|
||||
return info;
|
||||
|
||||
}
|
||||
|
||||
private List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
|
||||
|
||||
@@ -59,15 +59,11 @@ public class PqScriptController extends BaseController {
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测脚本")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated PqScriptParam param) {
|
||||
public HttpResult<String> add(@RequestBody @Validated PqScriptParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
Boolean result = pqScriptService.addPqScript(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
String id = pqScriptService.addPqScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, id, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@@ -216,6 +212,5 @@ public class PqScriptController extends BaseController {
|
||||
String checkData = pqScriptDtlsService.getScriptDtlsDesc(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, checkData, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.njcn.gather.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptCheckDataVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.njcn.gather.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptCheckDataVO;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
@@ -17,5 +21,7 @@ public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> {
|
||||
* @return
|
||||
*/
|
||||
Integer selectMaxIndex(@Param("scriptId") String scriptId);
|
||||
|
||||
List<PqScriptDtlDataVO> getScriptDtlsDataList(@Param("scriptId")String scriptId);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.script.mapper.PqScriptCheckDataMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -10,5 +10,21 @@
|
||||
WHERE Script_Id = #{scriptId}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getScriptDtlsDataList" resultType="com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO" >
|
||||
SELECT
|
||||
t2.CODE scriptCode,
|
||||
t2.NAME scriptName,
|
||||
t1.*
|
||||
FROM
|
||||
pq_script_dtls t1,
|
||||
sys_dict_tree t2
|
||||
WHERE
|
||||
t1.Script_Type = t2.Id
|
||||
AND t1.Script_Id = #{scriptId}
|
||||
AND t1.ENABLE = 1
|
||||
ORDER BY
|
||||
t1.Script_Index ASC,t1.HarmNum ASC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
AND State=1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ public class PqScriptCheckDataParam {
|
||||
@ApiModelProperty("相别,字典表")
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* pq_script_checkdata 里dataType 删除,由根据计划中的数据源,来进行配置脚本增加扩展性
|
||||
*/
|
||||
@ApiModelProperty("数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("检测指标类型(true:code(I$real) ,false展示id ,默认false)")
|
||||
private Boolean isValueTypeName=false;
|
||||
|
||||
|
||||
@@ -84,11 +84,6 @@ public class PqScriptDtlsParam {
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PqScriptIssueParam {
|
||||
@ApiModelProperty("终端id集合")
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty()
|
||||
@ApiModelProperty("校验步骤")
|
||||
private String isPhaseSequence;
|
||||
|
||||
@ApiModelProperty("源id")
|
||||
|
||||
@@ -39,10 +39,6 @@ public class PqScriptCheckData implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String valueTypeCode;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
|
||||
@@ -50,6 +50,9 @@ public class SourceIssue {
|
||||
@JSONField(serialize = false)
|
||||
private List<String> devValueTypeList;
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private String dataType;
|
||||
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private String desc;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.gather.script.pojo.vo;
|
||||
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/26 14:45
|
||||
*/
|
||||
@Data
|
||||
public class PqScriptCheckDataVO extends PqScriptCheckData {
|
||||
|
||||
/**
|
||||
* 脚本项名称
|
||||
*/
|
||||
private String scriptName;
|
||||
|
||||
/**
|
||||
* 脚本项Code
|
||||
*/
|
||||
private String scriptCode;
|
||||
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package com.njcn.gather.script.pojo.vo;
|
||||
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PqScriptDtlDataVO implements Serializable {
|
||||
public class PqScriptDtlDataVO extends PqScriptDtls implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 这条检测脚本的序号
|
||||
* 脚本项名称
|
||||
*/
|
||||
private String index;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String scriptName;
|
||||
|
||||
/**
|
||||
* 脚本项Code
|
||||
*/
|
||||
private String scriptCode;
|
||||
|
||||
}
|
||||
@@ -36,4 +36,19 @@ public interface IPqScriptCheckDataService extends IService<PqScriptCheckData> {
|
||||
List<PqScriptCheckData> listCheckDataCode(PqScriptCheckDataParam param);
|
||||
|
||||
Double getCheckDataValue(PqScriptCheckDataParam param);
|
||||
|
||||
/**
|
||||
* 查询条件范围内的参与比较的脚本详情
|
||||
* @param scriptId 脚本id
|
||||
* @param indexList 脚本下标集合
|
||||
*/
|
||||
List<PqScriptCheckData> listCheckData(String scriptId, List<Integer> indexList);
|
||||
|
||||
/**
|
||||
* 根据脚本id删除数据
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean deleteByScriptIds(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.njcn.gather.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.param.ScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -114,11 +116,24 @@ public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
List<PqScriptCheckData> checkDataList(ScriptParam param);
|
||||
|
||||
/**
|
||||
* @Description: 获取脚本详情描述
|
||||
* @param param
|
||||
* @Description: 获取脚本详情描述
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2025/3/31 9:40
|
||||
*/
|
||||
String getScriptDtlsDesc(ScriptParam.Desc param);
|
||||
|
||||
/**
|
||||
* 获取脚本与icd校验所需要的信息
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<String> getScriptToIcdCheckInfo(PreDetectionParam param);
|
||||
/**
|
||||
* 根据脚本id获取脚本详情数据
|
||||
* @param scriptId 脚本id
|
||||
*/
|
||||
List<PqScriptDtlDataVO> getScriptDtlsDataList(String scriptId);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* 新增检测脚本
|
||||
*
|
||||
* @param param 检测脚本
|
||||
* @return 成功返回true, 失败返回false
|
||||
* @return 成功返回ScriptId, 失败返回null
|
||||
*/
|
||||
Boolean addPqScript(PqScriptParam param);
|
||||
String addPqScript(PqScriptParam param);
|
||||
|
||||
/**
|
||||
* 删除检测脚本
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.njcn.gather.script.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
@@ -34,61 +34,68 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
|
||||
|
||||
private final String REAL="real$";
|
||||
private final String SYMBOL="$";
|
||||
|
||||
private final DictTreeMapper dictTreeMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getValueType(PqScriptCheckDataParam param) {
|
||||
MPJLambdaWrapper<PqScriptCheckData> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(PqScriptCheckData.class)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
if (param.getIsValueTypeName()) {
|
||||
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
|
||||
}
|
||||
List<PqScriptCheckData> pqScriptCheckData = this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
|
||||
if(CollUtil.isNotEmpty(pqScriptCheckData)){
|
||||
String dataType = param.getDataType();
|
||||
if(StrUtil.isNotBlank(dataType)){
|
||||
String[] split = dataType.split(",");
|
||||
if (split.length > 1) {
|
||||
dataType = split[0];
|
||||
}
|
||||
MPJLambdaWrapper<PqScriptCheckData> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(PqScriptCheckData.class)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
if (param.getIsValueTypeName()) {
|
||||
List<String> checkData = pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).distinct().collect(Collectors.toList());
|
||||
String U = REAL + DetectionCodeEnum.U1.getCode();
|
||||
if(!checkData.contains(U)){
|
||||
if(checkData.contains(REAL+DetectionCodeEnum.V2_50.getCode())){
|
||||
checkData.add(U);
|
||||
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
|
||||
}
|
||||
List<PqScriptCheckData> pqScriptCheckData = this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
|
||||
if (CollUtil.isNotEmpty(pqScriptCheckData)) {
|
||||
if (param.getIsValueTypeName()) {
|
||||
final String finalDataType = dataType;
|
||||
List<String> checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList());
|
||||
String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode();
|
||||
if (!checkData.contains(U)) {
|
||||
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) {
|
||||
checkData.add(U);
|
||||
}
|
||||
}
|
||||
}
|
||||
String I = REAL + DetectionCodeEnum.I1.getCode();
|
||||
if(!checkData.contains(I)){
|
||||
if(checkData.contains(REAL+DetectionCodeEnum.I2_50.getCode())){
|
||||
checkData.add(I);
|
||||
String I = finalDataType + SYMBOL + DetectionCodeEnum.I1.getCode();
|
||||
if (!checkData.contains(I)) {
|
||||
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.I2_50.getCode())) {
|
||||
checkData.add(I);
|
||||
}
|
||||
}
|
||||
return checkData.stream().distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
}
|
||||
return checkData.stream().distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> getValueTypeMap(String scriptId) {
|
||||
public Map<String, String> getValueTypeMap(String scriptId) {
|
||||
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(PqScriptCheckData::getValueType)
|
||||
.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
List<PqScriptCheckData> pqScriptCheckData = this.baseMapper.selectList(queryWrapper);
|
||||
if(CollUtil.isEmpty(pqScriptCheckData)){
|
||||
// throw new BusinessException(CommonResponseEnum.FAIL,"测试脚本项暂无配置");
|
||||
if (CollUtil.isEmpty(pqScriptCheckData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.SCRIPT_CHECK_DATA_NOT_EXIST);
|
||||
}
|
||||
List<String> valueTypeList = pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||
LambdaQueryWrapper<DictTree> dictTreeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictTreeLambdaQueryWrapper.in(DictTree::getId,valueTypeList).eq(DictTree::getState,DataStateEnum.DELETED.getCode());
|
||||
dictTreeLambdaQueryWrapper.in(DictTree::getId, valueTypeList).eq(DictTree::getState, DataStateEnum.DELETED.getCode());
|
||||
List<DictTree> dictTreeList = dictTreeMapper.selectList(dictTreeLambdaQueryWrapper);
|
||||
Map<String,String> map = dictTreeList.stream().collect(Collectors.toMap(DictTree::getCode,DictTree::getId));
|
||||
Map<String, String> map = dictTreeList.stream().collect(Collectors.toMap(DictTree::getCode, DictTree::getId));
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -109,17 +116,31 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptCheckData::getScriptIndex, param.getIndex())
|
||||
.eq(PqScriptCheckData::getValueType, param.getValueType())
|
||||
.eq(PqScriptCheckData::getPhase, param.getPhase())
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
|
||||
PqScriptCheckData data = this.getBaseMapper().selectOne(queryWrapper);
|
||||
if(ObjectUtil.isNotNull(data)){
|
||||
if (ObjectUtil.isNotNull(data)) {
|
||||
return data.getValue();
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptCheckData> listCheckData(String scriptId, List<Integer> indexList) {
|
||||
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<PqScriptCheckData>()
|
||||
.eq(PqScriptCheckData::getScriptId, scriptId)
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.eq(PqScriptCheckData::getErrorFlag, 1)
|
||||
.in(PqScriptCheckData::getScriptIndex, indexList)
|
||||
.orderByAsc(PqScriptCheckData::getHarmNum);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteByScriptIds(List<String> ids) {
|
||||
return this.remove(new LambdaQueryWrapper<PqScriptCheckData>().in(PqScriptCheckData::getScriptId, ids));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
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.service.IPqDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
||||
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
@@ -24,12 +28,14 @@ import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -83,6 +89,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final PqScriptCheckDataMapper pqScriptCheckDataMapper;
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final AdPlanMapper adPlanMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -125,6 +132,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
|
||||
@Override
|
||||
public List<SourceIssue> listSourceIssue(PqScriptIssueParam param) {
|
||||
String dataType;
|
||||
if (StrUtil.isNotBlank(param.getPlanId())) {
|
||||
AdPlan plan = adPlanMapper.selectById(param.getPlanId());
|
||||
dataType = plan.getDatasourceId();
|
||||
} else {
|
||||
dataType = "real";
|
||||
}
|
||||
List<SourceIssue> sourceIssues = new ArrayList<>();
|
||||
Set<Double> voltSet = new HashSet<>(1);
|
||||
Set<Double> currSet = new HashSet<>(1);
|
||||
@@ -191,6 +205,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
||||
checkDataParam.setIsValueTypeName(true);
|
||||
if(DicDataEnum.F.getCode().equals(issue.getType())||DicDataEnum.VOLTAGE.getCode().equals(issue.getType())){
|
||||
checkDataParam.setDataType("avg");
|
||||
issue.setDataType("avg");
|
||||
}else {
|
||||
checkDataParam.setDataType(dataType);
|
||||
issue.setDataType(dataType);
|
||||
}
|
||||
issue.setDevValueTypeList(pqScriptCheckDataService.getValueType(checkDataParam));
|
||||
issue.setDesc(ScriptDtlsDesc.getStringBuffer(value, true, isValueType).toString());
|
||||
issue.setScriptId(freqDtls.getScriptId());
|
||||
@@ -274,7 +295,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
data.setScriptId(sourceIssue.getScriptId());
|
||||
data.setScriptIndex(i);
|
||||
data.setValueType(checkData.getValueType());
|
||||
data.setDataType(checkData.getDataType());
|
||||
data.setPhase(checkData.getPhase());
|
||||
data.setValue(checkData.getValue());
|
||||
data.setHarmNum(checkData.getHarmNum());
|
||||
@@ -430,10 +450,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase("T");
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
if (CollUtil.isNotEmpty(checkArchive)) {
|
||||
checkData.setValue(checkArchive.get(0).getValue());
|
||||
checkData.setDataType(checkArchive.get(0).getDataType());
|
||||
} else {
|
||||
checkData.setValue(sourceIssue.getFFreq());
|
||||
}
|
||||
@@ -463,7 +481,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(listDTO.getFPhase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
@@ -601,7 +618,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
|
||||
private void setCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData checkData, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptCheckData> checkArchive, PqScriptDtlsParam.ChannelListDTO listDTO) {
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
@@ -681,6 +697,30 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
return ScriptDtlsDesc.getStringBuffer(pqScriptDtls, true, isValueType).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getScriptToIcdCheckInfo(PreDetectionParam param) {
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
// issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = this.listSourceIssue(issueParam);
|
||||
|
||||
Set<String> dataTypeSet = new HashSet<>();
|
||||
sourceIssues.forEach(x -> {
|
||||
dataTypeSet.addAll(x.getDevValueTypeList());
|
||||
});
|
||||
|
||||
return dataTypeSet.stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptDtlDataVO> getScriptDtlsDataList(String scriptId) {
|
||||
return this.baseMapper.getScriptDtlsDataList(scriptId);
|
||||
}
|
||||
|
||||
private void unbanCheck(List<PqScriptDtlsParam.CheckData> info,
|
||||
PqScriptDtlsParam.CheckData channelListDTO,
|
||||
List<PqScriptDtlsParam.ChannelListDTO> list,
|
||||
@@ -692,7 +732,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase("T");
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
List<PqScriptDtlsParam.ChannelListDTO> channelA = list.stream().filter(x -> x.getChannelType().contains("a")).collect(Collectors.toList());
|
||||
@@ -706,7 +745,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
}
|
||||
if (CollUtil.isNotEmpty(checkArchive)) {
|
||||
checkData.setValue(checkArchive.get(0).getValue());
|
||||
checkData.setDataType(checkArchive.get(0).getDataType());
|
||||
}
|
||||
info.add(checkData);
|
||||
}
|
||||
@@ -725,13 +763,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setErrorFlag(channelListDTO.getErrorFlag());
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
checkData.setValue(collect.get(0).getValue());
|
||||
checkData.setDataType(collect.get(0).getDataType());
|
||||
} else {
|
||||
if (flyDeltaV) {
|
||||
checkData.setValue(0.0);
|
||||
@@ -761,7 +797,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setEnable(channelListDTO.getEnable());
|
||||
checkData.setValue(inharmModel.getFAmp());
|
||||
checkData.setHarmNum(inharmModel.getInharm());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
@@ -776,7 +811,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
checkData.setValue(collect.get(0).getValue());
|
||||
checkData.setDataType(collect.get(0).getDataType());
|
||||
}
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
}
|
||||
@@ -798,7 +832,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setValue(harmModel.getFAmp());
|
||||
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
|
||||
checkData.setHarmNum(harmModel.getHarm());
|
||||
checkData.setDataType(channelListDTO.getDataType());
|
||||
checkData.setValueType(channelListDTO.getValueType());
|
||||
checkData.setPid(channelListDTO.getPid());
|
||||
setCheckValue(checkArchive, checkData, listDTO);
|
||||
@@ -859,7 +892,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
} else {
|
||||
//先获取检测脚本类型是否相对值 true相对值 false绝对值(相对值要乘额定值,绝对值不需要处理)
|
||||
queryWrapper.eq(PqScriptDtls::getScriptId, param.getScriptId());
|
||||
queryWrapper.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.in(CollUtil.isNotEmpty(param.getIndexList()), PqScriptDtls::getScriptIndex, param.getIndexList());
|
||||
pqScriptDtls = this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
|
||||
if (CollUtil.isNotEmpty(param.getDevIds()) || (ObjectUtil.isNotNull(param.getType()) && param.getType() == 1)) {
|
||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
|
||||
@@ -981,9 +1015,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
if (devFly) {
|
||||
if (isValueType) {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue() * dtls.getValue() * 0.01);
|
||||
} else {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
} else {
|
||||
dipDataDTO.setFTransValue(NumberUtil.round(dip.getTransValue() / dtls.getValue(), 4).doubleValue());
|
||||
}
|
||||
}
|
||||
// 1.0/频率*持续时间(周波)= 暂态持续时间(s)
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.service.IPqScriptService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
|
||||
public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> implements IPqScriptService {
|
||||
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
|
||||
@Override
|
||||
public Page<PqScript> listPqScript(PqScriptParam.QueryParam param) {
|
||||
@@ -58,17 +60,20 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean addPqScript(PqScriptParam param) {
|
||||
public String addPqScript(PqScriptParam param) {
|
||||
this.checkRepeat(param, false);
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqScript);
|
||||
this.save(pqScript);
|
||||
return pqScript.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
|
||||
this.checkRepeat(param, true);
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
@@ -85,6 +90,8 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
}
|
||||
//删除对应的脚本详情
|
||||
pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids);
|
||||
//删除对应的checkdata
|
||||
pqScriptCheckDataService.deleteByScriptIds(ids);
|
||||
LambdaUpdateWrapper<PqScript> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(PqScript::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(PqScript::getId, ids);
|
||||
@@ -118,4 +125,25 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
public PqScript getPqScriptByName(String name) {
|
||||
return this.lambdaQuery().eq(PqScript::getName, name).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查脚本是否重复
|
||||
*
|
||||
* @param param 计划参数
|
||||
* @param isExcludeSelf 是否排除自己
|
||||
*/
|
||||
private void checkRepeat(PqScriptParam param, boolean isExcludeSelf) {
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
wrapper.eq("name", param.getName());
|
||||
if (isExcludeSelf) {
|
||||
if(param instanceof PqScriptParam.UpdateParam){
|
||||
wrapper.ne("id", ((PqScriptParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(DetectionResponseEnum.SCRIPT_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.validation.constraints.Pattern;
|
||||
public class DevTypeParam {
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_TYPE_NAME_REGEX, message = DetectionValidMessage.DEV_TYPE_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备关联的ICD", required = true)
|
||||
@@ -44,7 +45,6 @@ public class DevTypeParam {
|
||||
private Integer devChns;
|
||||
|
||||
@ApiModelProperty(value = "报告模板")
|
||||
// @NotBlank(message = "报告模板不能为空")
|
||||
private String reportName;
|
||||
|
||||
/**
|
||||
|
||||
105
entrance/src/main/java/com/njcn/gather/advice/LogAdvice.java
Normal file
105
entrance/src/main/java/com/njcn/gather/advice/LogAdvice.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.njcn.gather.advice;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import com.njcn.web.utils.ReflectCommonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-2
|
||||
*/
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class LogAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
@Autowired
|
||||
private ISysLogAuditService logService;
|
||||
|
||||
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||
4, 8, 30, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(100),
|
||||
// 队列满时由主线程执行
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 无需审计记录的操作,比如根据客户端获取客户端信息
|
||||
*/
|
||||
|
||||
private final static List<String> UN_LOG_INFO = Collections.singletonList("未知业务");
|
||||
|
||||
|
||||
/**
|
||||
* controller返回的响应体包含的状态码,而非全局异常捕获器处抛出来的状态码
|
||||
*/
|
||||
private final static List<String> FILTER_CODE = Arrays.asList(CommonResponseEnum.SUCCESS.getCode(), CommonResponseEnum.FAIL.getCode(), CommonResponseEnum.NO_DATA.getCode());
|
||||
|
||||
|
||||
/**
|
||||
* 判断下结果,是不是成功
|
||||
*
|
||||
* @param returnType 返回类型,包含大量信息,controller、method、result等等
|
||||
* @param converterType 消息转换器类型,目前配置的是Jackson
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class converterType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截所有请求成功的操作进行日志入库处理
|
||||
* 需要 用户标识、事件描述、事件结果、操作IP、事件类型、事件严重度、操作时间、操作类型
|
||||
*
|
||||
* @param body .
|
||||
* @param returnType .
|
||||
* @param selectedContentType .
|
||||
* @param selectedConverterType .
|
||||
* @param request .
|
||||
* @param response .
|
||||
* @return .
|
||||
*/
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, @Nonnull MethodParameter returnType, @Nonnull MediaType selectedContentType, @Nonnull Class selectedConverterType, @Nonnull ServerHttpRequest request, @Nonnull ServerHttpResponse response) {
|
||||
if (body instanceof HttpResult) {
|
||||
HttpResult<?> httpResult = (HttpResult<?>) body;
|
||||
if (FILTER_CODE.contains(httpResult.getCode())) {
|
||||
// 传递上下文
|
||||
HttpServletRequest httpServletRequest = HttpServletUtil.getRequest();
|
||||
String methodDescribe = ReflectCommonUtil.getMethodDescribeByMethod(returnType.getMethod());
|
||||
if (!UN_LOG_INFO.contains(methodDescribe)) {
|
||||
Future<?> future = executor.submit(() -> {
|
||||
HttpServletUtil.setRequest(httpServletRequest);
|
||||
logService.recodeAdviceLog(returnType, httpResult, methodDescribe);
|
||||
});
|
||||
try {
|
||||
// 抛出 ExecutionException
|
||||
future.get();
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.error("保存审计日志异常,异常为:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,14 @@ 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.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import com.njcn.web.utils.ReflectCommonUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.util.NestedServletException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
@@ -25,6 +29,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -40,7 +45,16 @@ import java.util.stream.Stream;
|
||||
@RestControllerAdvice
|
||||
public class GlobalBusinessExceptionHandler {
|
||||
|
||||
// private final ILogService logService;
|
||||
@Resource
|
||||
private final ISysLogAuditService sysLogAuditService;
|
||||
|
||||
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||
4, 8, 30, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(100),
|
||||
// 队列满时由主线程执行
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 捕获业务功能异常,通常为业务数据抛出的异常
|
||||
@@ -48,16 +62,9 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param businessException 业务异常
|
||||
*/
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public HttpResult<String> handleBusinessException(HttpServletRequest httpServletRequest, BusinessException businessException) {
|
||||
public HttpResult<String> handleBusinessException(BusinessException businessException) {
|
||||
String operate = ReflectCommonUtil.getMethodDescribeByException(businessException);
|
||||
// logService.recodeBusinessExceptionLog(businessException, httpServletRequest, businessException.getMessage());
|
||||
//判断方法上是否有自定义注解,做特殊处理
|
||||
Method method = ReflectCommonUtil.getMethod(businessException);
|
||||
// if (!Objects.isNull(method)){
|
||||
// if(method.isAnnotationPresent(ReturnMsg.class)){
|
||||
// return HttpResultUtil.assembleResult(businessException.getCode(), null, StrFormatter.format("{}",businessException.getMessage()));
|
||||
// }
|
||||
// }
|
||||
recodeBusinessExceptionLog(businessException, businessException.getMessage());
|
||||
return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate);
|
||||
}
|
||||
|
||||
@@ -68,9 +75,9 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param nullPointerException 空指针异常
|
||||
*/
|
||||
@ExceptionHandler(NullPointerException.class)
|
||||
public HttpResult<String> handleNullPointerException(HttpServletRequest httpServletRequest, NullPointerException nullPointerException) {
|
||||
public HttpResult<String> handleNullPointerException(NullPointerException nullPointerException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage(), nullPointerException);
|
||||
// logService.recodeBusinessExceptionLog(nullPointerException, httpServletRequest, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(nullPointerException, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NULL_POINTER_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(nullPointerException));
|
||||
}
|
||||
|
||||
@@ -80,9 +87,9 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param arithmeticException 算数运算异常,由于除数为0引起的异常
|
||||
*/
|
||||
@ExceptionHandler(ArithmeticException.class)
|
||||
public HttpResult<String> handleArithmeticException(HttpServletRequest httpServletRequest, ArithmeticException arithmeticException) {
|
||||
public HttpResult<String> handleArithmeticException(ArithmeticException arithmeticException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage(), arithmeticException);
|
||||
// logService.recodeBusinessExceptionLog(arithmeticException, httpServletRequest, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(arithmeticException, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ARITHMETIC_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(arithmeticException));
|
||||
}
|
||||
|
||||
@@ -92,9 +99,9 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param classCastException 类型转换异常
|
||||
*/
|
||||
@ExceptionHandler(ClassCastException.class)
|
||||
public HttpResult<String> handleClassCastException(HttpServletRequest httpServletRequest, ClassCastException classCastException) {
|
||||
public HttpResult<String> handleClassCastException(ClassCastException classCastException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage(), classCastException);
|
||||
// logService.recodeBusinessExceptionLog(classCastException, httpServletRequest, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(classCastException, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.CLASS_CAST_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(classCastException));
|
||||
}
|
||||
|
||||
@@ -105,9 +112,9 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param indexOutOfBoundsException 索引下标越界异常
|
||||
*/
|
||||
@ExceptionHandler(IndexOutOfBoundsException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(HttpServletRequest httpServletRequest, IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage(), indexOutOfBoundsException);
|
||||
// logService.recodeBusinessExceptionLog(indexOutOfBoundsException, httpServletRequest, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(indexOutOfBoundsException, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException));
|
||||
}
|
||||
|
||||
@@ -117,10 +124,10 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param httpMediaTypeNotSupportedException 请求中参数的媒体方式不支持异常
|
||||
*/
|
||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||
public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpServletRequest httpServletRequest, HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) {
|
||||
public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage(), httpMediaTypeNotSupportedException);
|
||||
// 然后提取错误提示信息进行返回
|
||||
// logService.recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, httpServletRequest, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(httpMediaTypeNotSupportedException));
|
||||
}
|
||||
|
||||
@@ -131,13 +138,13 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param methodArgumentNotValidException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public HttpResult<String> methodArgumentNotValidExceptionHandler(HttpServletRequest httpServletRequest, MethodArgumentNotValidException methodArgumentNotValidException) {
|
||||
public HttpResult<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException methodArgumentNotValidException) {
|
||||
// 从异常对象中拿到allErrors数据
|
||||
String messages = methodArgumentNotValidException.getBindingResult().getAllErrors()
|
||||
.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(";"));
|
||||
// 然后提取错误提示信息进行返回
|
||||
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
|
||||
// logService.recodeBusinessExceptionLog(methodArgumentNotValidException, httpServletRequest, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(methodArgumentNotValidException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages, ControllerUtil.getMethodArgumentNotValidException(methodArgumentNotValidException));
|
||||
}
|
||||
|
||||
@@ -148,7 +155,7 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param constraintViolationException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public HttpResult<String> constraintViolationExceptionExceptionHandler(HttpServletRequest httpServletRequest, ConstraintViolationException constraintViolationException) {
|
||||
public HttpResult<String> constraintViolationExceptionExceptionHandler(ConstraintViolationException constraintViolationException) {
|
||||
String exceptionMessage = constraintViolationException.getMessage();
|
||||
StringBuilder messages = new StringBuilder();
|
||||
if (exceptionMessage.indexOf(StrUtil.COMMA) > 0) {
|
||||
@@ -161,7 +168,7 @@ public class GlobalBusinessExceptionHandler {
|
||||
}
|
||||
// 然后提取错误提示信息进行返回
|
||||
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
|
||||
// logService.recodeBusinessExceptionLog(constraintViolationException, httpServletRequest, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(constraintViolationException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
List<ConstraintViolation<?>> constraintViolationList = new ArrayList<>(constraintViolationException.getConstraintViolations());
|
||||
ConstraintViolation<?> constraintViolation = constraintViolationList.get(0);
|
||||
Class<?> rootBeanClass = constraintViolation.getRootBeanClass();
|
||||
@@ -182,24 +189,12 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param illegalArgumentException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(HttpServletRequest httpServletRequest, IllegalArgumentException illegalArgumentException) {
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(IllegalArgumentException illegalArgumentException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), illegalArgumentException);
|
||||
// logService.recodeBusinessExceptionLog(illegalArgumentException, httpServletRequest, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(illegalArgumentException, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, illegalArgumentException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(illegalArgumentException));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 表格校验异常
|
||||
// *
|
||||
// * @param excelAnalysisException 表格校验异常
|
||||
// */
|
||||
// @ExceptionHandler(ExcelAnalysisException.class)
|
||||
// public HttpResult<String> handleExcelAnalysisException(HttpServletRequest httpServletRequest, ExcelAnalysisException excelAnalysisException) {
|
||||
// LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), excelAnalysisException);
|
||||
// // logService.recodeBusinessExceptionLog(excelAnalysisException, httpServletRequest,CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, excelAnalysisException.getCause().getMessage(), ReflectCommonUtil.getMethodDescribeByException(excelAnalysisException));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 未声明异常捕捉
|
||||
@@ -207,7 +202,7 @@ public class GlobalBusinessExceptionHandler {
|
||||
* @param exception 未声明异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public HttpResult<String> handleException(HttpServletRequest httpServletRequest, Exception exception) {
|
||||
public HttpResult<String> handleException(Exception exception) {
|
||||
//针对fallbackFactory降级异常特殊处理
|
||||
Exception tempException = exception;
|
||||
String exceptionCause = CommonResponseEnum.UN_DECLARE.getMessage();
|
||||
@@ -224,7 +219,7 @@ public class GlobalBusinessExceptionHandler {
|
||||
}
|
||||
}
|
||||
LogUtil.logExceptionStackInfo(exceptionCause, tempException);
|
||||
// logService.recodeBusinessExceptionLog(tempException, httpServletRequest, exceptionCause);
|
||||
recodeBusinessExceptionLog(exception, exceptionCause);
|
||||
//判断方法上是否有自定义注解,做特殊处理
|
||||
// Method method = ReflectCommonUtil.getMethod(exception);
|
||||
// if (!Objects.isNull(method)){
|
||||
@@ -236,18 +231,30 @@ public class GlobalBusinessExceptionHandler {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* json解析异常
|
||||
*
|
||||
* @param jsonException json参数
|
||||
*/
|
||||
@ExceptionHandler(JSONException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(HttpServletRequest httpServletRequest, JSONException jsonException) {
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(JSONException jsonException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage(), jsonException);
|
||||
// logService.recodeBusinessExceptionLog(jsonException, httpServletRequest, CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage());
|
||||
recodeBusinessExceptionLog(jsonException, CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.JSON_CONVERT_EXCEPTION, jsonException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(jsonException));
|
||||
}
|
||||
|
||||
private void recodeBusinessExceptionLog(Exception businessException, String methodDescribe) {
|
||||
HttpServletRequest httpServletRequest = HttpServletUtil.getRequest();
|
||||
Future<?> future = executor.submit(() -> {
|
||||
HttpServletUtil.setRequest(httpServletRequest);
|
||||
sysLogAuditService.recodeBusinessExceptionLog(businessException, methodDescribe);
|
||||
});
|
||||
try {
|
||||
// 抛出 ExecutionException
|
||||
future.get();
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.error("保存审计日志异常,异常为:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.
37
entrance/src/test/java/com/njcn/BaseJunitTest.java
Normal file
37
entrance/src/test/java/com/njcn/BaseJunitTest.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.gather.EntranceApplication;
|
||||
import com.njcn.gather.report.pojo.DevReportParam;
|
||||
import com.njcn.gather.report.service.IPqReportService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月10日 15:05
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = EntranceApplication.class)
|
||||
public class BaseJunitTest {
|
||||
|
||||
@Autowired
|
||||
private IPqReportService pqReportService;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
DevReportParam devReportParam = new DevReportParam();
|
||||
devReportParam.setPlanId("ad3df9e4a90b4c3c8ce7d21a84ce6f59");
|
||||
devReportParam.setPlanCode("31");
|
||||
devReportParam.setScriptId("810e4050e1d445e3542c998a077a263a");
|
||||
devReportParam.setDevId("a46349a3b3cf4789a6b82690a6076afd");
|
||||
pqReportService.generateReport(devReportParam);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,11 +10,11 @@
|
||||
Sort int(4) 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相值(没有相别的则存这里)',
|
||||
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
|
||||
A_Value varchar(30) DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value varchar(30) DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value varchar(30) DEFAULT NULL COMMENT 'C相值',
|
||||
T_Value varchar(30) DEFAULT NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
PRIMARY KEY (Monitor_Id, Time_Id, Script_Id, Sort, AD_Type)
|
||||
) COMMENT='监测数据表';
|
||||
</update>
|
||||
@@ -28,7 +28,7 @@
|
||||
<update id="genAdNonHarmonicResultTable" parameterType="string">
|
||||
CREATE TABLE if not exists ad_non_harmonic_result_${code} (
|
||||
Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',
|
||||
Time_Id DATETIME NULL COMMENT '时间',
|
||||
Time_Id DATETIME NULL COMMENT '时间',
|
||||
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',
|
||||
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.gather.storage.pojo.param;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -12,6 +14,8 @@ import java.util.List;
|
||||
* @data 2025/1/10 16:06
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SingleNonHarmParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -19,7 +23,7 @@ public class SingleNonHarmParam implements Serializable {
|
||||
/**
|
||||
* 检测计划编码
|
||||
*/
|
||||
private Integer planCode;
|
||||
private String planCode;
|
||||
|
||||
/**
|
||||
* 被检设备ID
|
||||
@@ -36,6 +40,11 @@ public class SingleNonHarmParam implements Serializable {
|
||||
*/
|
||||
private String adType;
|
||||
|
||||
/**
|
||||
* 测试项类型,暂态的存在多个
|
||||
*/
|
||||
private List<String> valueTypeList;
|
||||
|
||||
/**
|
||||
* 测试项所在脚本的位置
|
||||
*/
|
||||
@@ -43,4 +52,35 @@ public class SingleNonHarmParam implements Serializable {
|
||||
|
||||
private List<Integer> sortList;
|
||||
|
||||
public SingleNonHarmParam(Integer planCode, String devId, Integer channelNo, String adType, Integer sort) {
|
||||
this.planCode = String.valueOf(planCode);
|
||||
this.devId = devId;
|
||||
this.channelNo = channelNo;
|
||||
this.adType = adType;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public SingleNonHarmParam(Integer planCode, String devId, Integer channelNo, String adType, List<Integer> sortList) {
|
||||
this.planCode = String.valueOf(planCode);
|
||||
this.devId = devId;
|
||||
this.channelNo = channelNo;
|
||||
this.adType = adType;
|
||||
this.sortList = sortList;
|
||||
}
|
||||
|
||||
public SingleNonHarmParam(Integer planCode, String devId, Integer channelNo, List<String> valueTypeList, Integer sort) {
|
||||
this.planCode = String.valueOf(planCode);
|
||||
this.devId = devId;
|
||||
this.channelNo = channelNo;
|
||||
this.valueTypeList = valueTypeList;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public SingleNonHarmParam(Integer planCode, String devId, Integer channelNo, List<String> valueTypeList, List<Integer> sortList) {
|
||||
this.planCode = String.valueOf(planCode);
|
||||
this.devId = devId;
|
||||
this.channelNo = channelNo;
|
||||
this.valueTypeList = valueTypeList;
|
||||
this.sortList = sortList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, RawResultDataVO> listHarmResultData(StorageParam param);
|
||||
Map<String, List<RawResultDataVO>> listHarmResultData(StorageParam param);
|
||||
|
||||
/**
|
||||
* 获取索引
|
||||
@@ -56,12 +56,22 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
||||
AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||
|
||||
/**
|
||||
* 获取所有谐波原始数据
|
||||
* 获取所有谐波结果数据
|
||||
*
|
||||
* @param scriptId
|
||||
* @param code
|
||||
* @param devId 设备ID
|
||||
* @return
|
||||
*/
|
||||
List<AdHarmonicResult> listAll(String scriptId, String code, String devId);
|
||||
List<AdHarmonicResult> listAllResultData(String scriptId, String code, String devId);
|
||||
|
||||
/**
|
||||
* 获取所有原始数据
|
||||
*
|
||||
* @param scriptId
|
||||
* @param code
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
List<AdHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param);
|
||||
Map<String, List<RawResultDataVO>> listNonHarmResultData(StorageParam param);
|
||||
|
||||
/**
|
||||
* 根据参数查询指定非谐波结果
|
||||
@@ -48,11 +48,29 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
|
||||
AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||
|
||||
/**
|
||||
* 获取所有原始数据
|
||||
* 获取所有结果数据
|
||||
* @param scriptId
|
||||
* @param code
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
List<AdNonHarmonicResult> listAll(String scriptId,String code,String devId);
|
||||
List<AdNonHarmonicResult> listAllResultData(String scriptId,String code,String devId);
|
||||
|
||||
/**
|
||||
* 根据查询条件查找结果
|
||||
* @param param 查询条件
|
||||
*/
|
||||
List<AdNonHarmonicResult> queryByCondition(SingleNonHarmParam param);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取所有原始数据
|
||||
*
|
||||
* @param scriptId
|
||||
* @param code
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
List<AdNonHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -23,7 +24,7 @@ import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.system.dictionary.mapper.DictTreeMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -32,6 +33,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -43,8 +45,8 @@ import java.util.stream.Collectors;
|
||||
public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarmonicResult> implements AdHarmonicService {
|
||||
|
||||
private final AdNonHarmonicMapper adNonHarmonicMapper;
|
||||
private final IDictDataService dictDataService;
|
||||
private final DictTreeMapper dictTreeMapper;
|
||||
private final IDictTreeService dictTreeService;
|
||||
|
||||
@Override
|
||||
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, String code) {
|
||||
@@ -74,65 +76,64 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
.orderByAsc(AdHarmonicResult::getTimeId)
|
||||
;
|
||||
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
LinkedHashMap<String, List<AdHarmonicResult>> adMap =
|
||||
adHarmonicResults.stream().collect(Collectors.groupingBy(AdHarmonicResult::getAdType, LinkedHashMap::new, Collectors.toList()));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet()));
|
||||
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||
Map<String, List<RawDataVO>> info = new LinkedHashMap<>(3);
|
||||
if (CollectionUtil.isNotEmpty(adHarmonicResults)) {
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
RawDataVO dataVO;
|
||||
List<RawDataVO> rawDataVOS;
|
||||
DictTree dictData = dictTreeMapper.selectById(adHarmonicResults.get(0).getAdType());
|
||||
String unit;
|
||||
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
||||
unit = "A";
|
||||
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
||||
unit = "W";
|
||||
} else {
|
||||
unit = "%";
|
||||
}
|
||||
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field timeId = harmonicResult.getClass().getDeclaredField("timeId");
|
||||
timeId.setAccessible(true);
|
||||
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
|
||||
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
dataVO.setDataA(ObjectUtil.isNotNull(fieldA.get(harmonicResult)) ? new BigDecimal(fieldA.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
dataVO.setDataB(ObjectUtil.isNotNull(fieldB.get(harmonicResult)) ? new BigDecimal(fieldB.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
dataVO.setDataC(ObjectUtil.isNotNull(fieldC.get(harmonicResult)) ? new BigDecimal(fieldC.get(harmonicResult) + "").toPlainString() : null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (info.containsKey(String.valueOf(i))) {
|
||||
info.get(String.valueOf(i)).add(dataVO);
|
||||
} else {
|
||||
rawDataVOS = new ArrayList<>();
|
||||
rawDataVOS.add(dataVO);
|
||||
info.put(String.valueOf(i), rawDataVOS);
|
||||
}
|
||||
|
||||
adMap.forEach((ad,value)->{
|
||||
if (dictTreeByName.containsKey(ad)) {
|
||||
DictTree dictData = dictTreeByName.get(ad);
|
||||
List<RawDataVO> rawDataVOS = new ArrayList<>();
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
RawDataVO dataVO;
|
||||
String unit;
|
||||
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
||||
unit = "A";
|
||||
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
||||
unit = "W";
|
||||
} else {
|
||||
unit = "%";
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field timeId = harmonicResult.getClass().getDeclaredField("timeId");
|
||||
timeId.setAccessible(true);
|
||||
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
|
||||
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
dataVO.setDataA(StrUtil.isNotBlank(fieldA.get(harmonicResult) + "") ? new BigDecimal(fieldA.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
dataVO.setDataB(StrUtil.isNotBlank(fieldB.get(harmonicResult) + "") ? new BigDecimal(fieldB.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
dataVO.setDataC(StrUtil.isNotBlank(fieldC.get(harmonicResult) + "") ? new BigDecimal(fieldC.get(harmonicResult) + "").toPlainString() : null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
rawDataVOS.add(dataVO);
|
||||
}
|
||||
}
|
||||
info.put(dictData.getName(), rawDataVOS);
|
||||
}
|
||||
});
|
||||
DynamicTableNameHandler.remove();
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, RawResultDataVO> listHarmResultData(StorageParam param) {
|
||||
public Map<String, List<RawResultDataVO>> listHarmResultData(StorageParam param) {
|
||||
String prefix = "ad_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
@@ -140,55 +141,61 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
.eq(ObjectUtil.isNotNull(param.getScriptId()), AdHarmonicResult::getScriptId, param.getScriptId())
|
||||
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdHarmonicResult::getSort, param.getIndex())
|
||||
.orderByAsc(AdHarmonicResult::getTimeId);
|
||||
|
||||
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
Map<String, RawResultDataVO> info = new LinkedHashMap<>(3);
|
||||
if (CollUtil.isNotEmpty(adHarmonicResults)) {
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
RawResultDataVO dataVO;
|
||||
DictTree dictData = dictTreeMapper.selectById(adHarmonicResults.get(0).getAdType());
|
||||
String unit;
|
||||
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
||||
unit = "A";
|
||||
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
||||
unit = "W";
|
||||
} else {
|
||||
unit = "%";
|
||||
}
|
||||
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataB(b);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataC(c);
|
||||
if (ObjectUtil.isNotNull(a)) {
|
||||
dataVO.setRadius(a.getRadius());
|
||||
}
|
||||
dataVO.setIsData(setResultFlag(Arrays.asList(a, b, c)));
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
info.put(String.valueOf(i), dataVO);
|
||||
LinkedHashMap<String, List<AdHarmonicResult>> adMap =
|
||||
adHarmonicResults.stream().collect(Collectors.groupingBy(AdHarmonicResult::getAdType, LinkedHashMap::new, Collectors.toList()));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet()));
|
||||
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||
Map<String, List<RawResultDataVO>> info = new LinkedHashMap<>(3);
|
||||
adMap.forEach((ad,value)->{
|
||||
if (dictTreeByName.containsKey(ad)) {
|
||||
DictTree dictData = dictTreeByName.get(ad);
|
||||
List<RawResultDataVO> rawDataVOS = new ArrayList<>();
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
RawResultDataVO dataVO;
|
||||
String unit;
|
||||
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
||||
unit = "A";
|
||||
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
||||
unit = "W";
|
||||
} else {
|
||||
unit = "%";
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataB(b);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataC(c);
|
||||
if (ObjectUtil.isNotNull(a)) {
|
||||
dataVO.setRadius(a.getRadius());
|
||||
}
|
||||
dataVO.setIsData(setResultFlag(Arrays.asList(a, b, c)));
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
rawDataVOS.add(dataVO);
|
||||
}
|
||||
}
|
||||
info.put(dictData.getName(), rawDataVOS);
|
||||
}
|
||||
});
|
||||
DynamicTableNameHandler.remove();
|
||||
return info;
|
||||
}
|
||||
@@ -231,6 +238,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
.eq(AdHarmonicResult::getSort, singleNonHarmParam.getSort())
|
||||
.eq(AdHarmonicResult::getAdType, singleNonHarmParam.getAdType());
|
||||
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
if (CollectionUtil.isNotEmpty(adHarmonicResults)) {
|
||||
return adHarmonicResults.get(0);
|
||||
}
|
||||
@@ -239,11 +247,28 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdHarmonicResult> listAll(String scriptId, String code, String devId) {
|
||||
public List<AdHarmonicResult> listAllResultData(String scriptId, String code, String devId) {
|
||||
String prefix = "ad_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(AdHarmonicResult.class)
|
||||
.selectAs(DictTree::getCode, AdHarmonicResult::getAdType)
|
||||
.leftJoin(DictTree.class, DictTree::getId, AdHarmonicResult::getAdType).eq(AdHarmonicResult::getScriptId, scriptId)
|
||||
.likeRight(AdHarmonicResult::getMonitorId, devId);
|
||||
List<AdHarmonicResult> results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdHarmonicResult> listAllRawData(String scriptId, String code, String devId) {
|
||||
String prefix = "ad_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.eq(AdHarmonicResult::getScriptId, scriptId).likeRight(AdHarmonicResult::getMonitorId, devId);
|
||||
wrapper.selectAll(AdHarmonicResult.class)
|
||||
.selectAs(DictTree::getCode, AdHarmonicResult::getAdType)
|
||||
.leftJoin(DictTree.class, DictTree::getId, AdHarmonicResult::getAdType).eq(AdHarmonicResult::getScriptId, scriptId)
|
||||
.likeRight(AdHarmonicResult::getMonitorId, devId);
|
||||
List<AdHarmonicResult> results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return results;
|
||||
@@ -251,10 +276,10 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
|
||||
private Integer setResultFlag(List<RawResultDataVO.DetectionData> numbers) {
|
||||
List<Integer> isData = numbers.stream().filter(Objects::nonNull)
|
||||
.filter(x -> ObjectUtil.isNotNull(x.getData()))
|
||||
.map(RawResultDataVO.DetectionData::getIsData)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
.filter(x -> ObjectUtil.isNotNull(x.getData()))
|
||||
.map(RawResultDataVO.DetectionData::getIsData)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
return getInteger(isData);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -24,10 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -77,12 +75,12 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
List<RawDataVO> rawDataVOS = new ArrayList<>();
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
RawDataVO dataVO = new RawDataVO();
|
||||
dataVO.setUnit(unit(dictTree.getCode()));
|
||||
dataVO.setUnit(dictTree.getCode().equals("MAG")?"%":unit(dictTree.getCode()));
|
||||
dataVO.setTime(result.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
dataVO.setDataA(ObjectUtil.isNotNull(result.getAValue()) ? new BigDecimal(result.getAValue()).toPlainString() : null);
|
||||
dataVO.setDataB(ObjectUtil.isNotNull(result.getBValue()) ? new BigDecimal(result.getBValue()).toPlainString() : null);
|
||||
dataVO.setDataC(ObjectUtil.isNotNull(result.getCValue()) ? new BigDecimal(result.getCValue()).toPlainString() : null);
|
||||
dataVO.setDataT(ObjectUtil.isNotNull(result.getTValue()) ? new BigDecimal(result.getTValue()).toPlainString() : null);
|
||||
dataVO.setDataA(StrUtil.isNotBlank(result.getAValue()) ? new BigDecimal(result.getAValue()).toPlainString() : null);
|
||||
dataVO.setDataB(StrUtil.isNotBlank(result.getBValue()) ? new BigDecimal(result.getBValue()).toPlainString() : null);
|
||||
dataVO.setDataC(StrUtil.isNotBlank(result.getCValue()) ? new BigDecimal(result.getCValue()).toPlainString() : null);
|
||||
dataVO.setDataT(StrUtil.isNotBlank(result.getTValue()) ? new BigDecimal(result.getTValue()).toPlainString() : null);
|
||||
rawDataVOS.add(dataVO);
|
||||
}
|
||||
info.put(dictTree.getName(), rawDataVOS);
|
||||
@@ -93,7 +91,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param) {
|
||||
public Map<String, List<RawResultDataVO>> listNonHarmResultData(StorageParam param) {
|
||||
String prefix = "ad_non_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
@@ -103,12 +101,12 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
|
||||
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||
|
||||
Map<String, RawResultDataVO> info = new LinkedHashMap<>(2);
|
||||
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity()));
|
||||
Map<String, List<RawResultDataVO>> info = new LinkedHashMap<>(2);
|
||||
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream()
|
||||
.sorted(Comparator.comparing(AdNonHarmonicResult::getResultFlag))
|
||||
.collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity(), (a, b) -> a, LinkedHashMap::new));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
||||
|
||||
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||
|
||||
adTypeMap.forEach((key, result) -> {
|
||||
if (dictTreeByName.containsKey(key)) {
|
||||
DictTree treeName = dictTreeByName.get(key);
|
||||
@@ -130,7 +128,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
dataVO.setRadius(b.getRadius());
|
||||
}
|
||||
}
|
||||
info.put(treeName.getName(), dataVO);
|
||||
info.put(treeName.getName(), Arrays.asList(dataVO));
|
||||
}
|
||||
});
|
||||
DynamicTableNameHandler.remove();
|
||||
@@ -155,11 +153,43 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdNonHarmonicResult> listAll(String scriptId, String code, String devId) {
|
||||
public List<AdNonHarmonicResult> listAllResultData(String scriptId, String code, String devId) {
|
||||
String prefix = "ad_non_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(AdNonHarmonicResult.class)
|
||||
.selectAs(DictTree::getCode, AdNonHarmonicResult::getAdType)
|
||||
.leftJoin(DictTree.class, DictTree::getId, AdNonHarmonicResult::getAdType)
|
||||
.eq(AdNonHarmonicResult::getScriptId, scriptId)
|
||||
.likeRight(AdNonHarmonicResult::getMonitorId, devId);
|
||||
List<AdNonHarmonicResult> results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdNonHarmonicResult> queryByCondition(SingleNonHarmParam param) {
|
||||
String prefix = "ad_non_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getPlanCode());
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.like(AdNonHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getChannelNo())
|
||||
.in(AdNonHarmonicResult::getSort, param.getSortList())
|
||||
.in(AdNonHarmonicResult::getAdType, param.getValueTypeList());
|
||||
List<AdNonHarmonicResult> adNonHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return adNonHarmonicResults;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdNonHarmonicResult> listAllRawData(String scriptId, String code, String devId) {
|
||||
String prefix = "ad_non_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.eq(AdNonHarmonicResult::getScriptId, scriptId)
|
||||
wrapper.selectAll(AdNonHarmonicResult.class)
|
||||
.selectAs(DictTree::getCode, AdNonHarmonicResult::getAdType)
|
||||
.leftJoin(DictTree.class, DictTree::getId, AdNonHarmonicResult::getAdType)
|
||||
.eq(AdNonHarmonicResult::getScriptId, scriptId)
|
||||
.likeRight(AdNonHarmonicResult::getMonitorId, devId);
|
||||
List<AdNonHarmonicResult> results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
@@ -234,7 +264,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
* 暂态-电压幅值
|
||||
*/
|
||||
case "MAG":
|
||||
unit = "%";
|
||||
unit = "V";
|
||||
break;
|
||||
/**
|
||||
* 暂态-持续时间
|
||||
|
||||
@@ -16,50 +16,50 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
|
||||
@Override
|
||||
public void genAdNonHarmonicTable(String code) {
|
||||
//TODO 判断是否存在该表
|
||||
tableGenMapper.genAdNonHarmonicTable(code);
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code);
|
||||
|
||||
//TODO 判断是否存在该表
|
||||
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
StringBuilder C = new StringBuilder();
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
if (i == 1) {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT 'C相基波',");
|
||||
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相基波',");
|
||||
} else {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
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相谐波',");
|
||||
}
|
||||
}
|
||||
|
||||
String sql = "CREATE TABLE AD_Harmonic_" + code + " (\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NOT NULL COMMENT '时间',\n" +
|
||||
" Time_Id DATETIME NOT NULL COMMENT '时间',\n" +
|
||||
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||
" Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
|
||||
" Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" +
|
||||
" Result_Flag int(1) NULL COMMENT '0.不合格 1.合格',\n" +
|
||||
" Result_Flag int(1) NULL COMMENT '0不合格 1合格 4无法处理',\n" +
|
||||
A + B + C +
|
||||
" PRIMARY KEY (Monitor_Id,Time_Id, Script_Id, Sort, AD_Type)\n" +
|
||||
" PRIMARY KEY (Monitor_Id,Time_Id,Script_Id, Sort, AD_Type)\n" +
|
||||
") COMMENT='监测数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql);
|
||||
|
||||
String a = A.toString().replaceAll("float", "json");
|
||||
String b = B.toString().replaceAll("float", "json");
|
||||
String c = C.toString().replaceAll("float", "json");
|
||||
String sql2 = "CREATE TABLE AD_Harmonic_Result_" + code + " (\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
|
||||
" Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" +
|
||||
" Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',\n" +
|
||||
A + B + C +
|
||||
" PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)\n" +
|
||||
a + b + c +
|
||||
" PRIMARY KEY (Monitor_Id,Script_Id, Sort, AD_Type)\n" +
|
||||
") COMMENT='监测数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql2);
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ public class DictDataParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_DATA_NAME_REGEX, message = SystemValidMessage.DICT_DATA_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_DATA_CODE_REGEX, message = SystemValidMessage.DICT_DATA_CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DictPqParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("相别")
|
||||
@@ -27,9 +27,11 @@ public class DictPqParam {
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("别名,默认与名称相同")
|
||||
@Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_OTHER_NAME_FORMAT_ERROR)
|
||||
private String otherName;
|
||||
|
||||
@ApiModelProperty("显示名称")
|
||||
@Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_SHOW_NAME_FORMAT_ERROR)
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
|
||||
@@ -28,6 +28,7 @@ public class DictTreeParam {
|
||||
*/
|
||||
@ApiModelProperty(value = "名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ public class DictTreeParam {
|
||||
*/
|
||||
@TableField(value = "编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.DICT_TYPE_CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,12 +19,12 @@ public class DictTypeParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.CODE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DICT_CODE_REGEX, message = SystemValidMessage.DICT_TYPE_CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
|
||||
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.njcn.gather.system.log.aop;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.db.mybatisplus.constant.UserConstant;
|
||||
import com.njcn.gather.system.log.pojo.enums.LogLevelEnum;
|
||||
import com.njcn.gather.system.log.pojo.enums.LogOperationTypeEnum;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
import com.njcn.gather.user.user.service.ISysUserService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-2
|
||||
*/
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LogAdvice implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private final ISysLogAuditService sysLogAuditService;
|
||||
private final ISysUserService sysUserService;
|
||||
private final List<String> IGNORE_METHOD = new ArrayList<>(Arrays.asList("login"));
|
||||
|
||||
private BlockingQueue<SysLogAudit> logQueue = new LinkedBlockingDeque<>();
|
||||
|
||||
// @Pointcut(value = "execution(* com.njcn.gather..controller.*.*(..)) && !execution(* com.njcn.gather..controller.AuthController.*(..))")
|
||||
@Pointcut(value = "execution(* com.njcn.gather..controller.*.*(..))")
|
||||
public void logPointcut() {
|
||||
}
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
String name = joinPoint.getSignature().getName();
|
||||
String username = "";
|
||||
// 因为刚开始登录时无法获取到token,针对login方法单独处理
|
||||
if (IGNORE_METHOD.contains(name)) {
|
||||
Object[] args = joinPoint.getArgs();
|
||||
Object arg = args[0];
|
||||
if (arg instanceof SysUserParam.LoginParam) {
|
||||
username = ((SysUserParam.LoginParam) arg).getUsername();
|
||||
}
|
||||
} else {
|
||||
String userId = RequestUtil.getUserId();
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
SysUser user = sysUserService.getById(RequestUtil.getUserId());
|
||||
if (ObjectUtil.isNotNull(user)) {
|
||||
username = user.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
sysLogAuditService.scheduleRemoveLog();
|
||||
result = joinPoint.proceed();
|
||||
if (result instanceof HttpResult) {
|
||||
HttpResult result1 = (HttpResult) result;
|
||||
if (CommonResponseEnum.SUCCESS.getCode().equals(result1.getCode())) {
|
||||
addLogToQueue(joinPoint, "".equals(username) ? UserConstant.UNKNOWN_USER_ID : username, LogOperationTypeEnum.OPERATE.getMsg(), 1, LogLevelEnum.INFO.getCode(), 0);
|
||||
} else {
|
||||
addLogToQueue(joinPoint, "".equals(username) ? UserConstant.UNKNOWN_USER_ID : username, LogOperationTypeEnum.OPERATE.getMsg(), 0, LogLevelEnum.INFO.getCode(), 0);
|
||||
}
|
||||
} else {
|
||||
addLogToQueue(joinPoint, "".equals(username) ? UserConstant.UNKNOWN_USER_ID : username, LogOperationTypeEnum.OPERATE.getMsg(), 1, LogLevelEnum.INFO.getCode(), 0);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
addLogToQueue(joinPoint, "".equals(username) ? UserConstant.UNKNOWN_USER_ID : username, LogOperationTypeEnum.OPERATE.getMsg(), 0, LogLevelEnum.ERROR.getCode(), 1);
|
||||
throw e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addLogToQueue(ProceedingJoinPoint joinPoint, String username, String operationType, Integer result, Integer level, Integer warn) {
|
||||
SysLogAudit sysLogAudit = new SysLogAudit();
|
||||
sysLogAudit.setOperateType(operationType);
|
||||
sysLogAudit.setLevel(level);
|
||||
sysLogAudit.setWarn(warn); //0-未告警,1-告警
|
||||
sysLogAudit.setCreateBy(username);
|
||||
|
||||
sysLogAudit.setIp(RequestUtil.getUserIp());
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
OperateInfo operateInfo = method.getAnnotation(OperateInfo.class);
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
String resultStr = (result == 1 ? "成功" : "失败");
|
||||
if (operateInfo != null) {
|
||||
//注解上的操作类型
|
||||
sysLogAudit.setResult(operateInfo.operateType() + resultStr);
|
||||
}
|
||||
if (apiOperation != null) {
|
||||
//注解上的描述
|
||||
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
sysLogAudit.setRemark(username + ":" + now + " " + apiOperation.value() + " " + resultStr);
|
||||
}
|
||||
//Object[] args = joinPoint.getArgs();
|
||||
logQueue.add(sysLogAudit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
List<SysLogAudit> logList = new ArrayList<>();
|
||||
SysLogAudit log;
|
||||
while ((log = logQueue.poll(5, TimeUnit.MILLISECONDS)) != null) {
|
||||
log.setSort(sysLogAuditService.getMaxSort() + 1);
|
||||
logList.add(log);
|
||||
}
|
||||
if (!logList.isEmpty()) {
|
||||
sysLogAuditService.saveBatch(logList); // 假设有一个批量保存的方法
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(SystemResponseEnum.LOG_RECORD_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,8 @@ public class SysLogParam {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("日志类型")
|
||||
private String operateType;
|
||||
|
||||
@ApiModelProperty("操作用户")
|
||||
private String createBy;
|
||||
private String userName;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user