Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
744c72dea2 | ||
|
|
b4114f19de | ||
|
|
b0dde94314 | ||
|
|
da7015fd89 | ||
|
|
9058c9081b | ||
|
|
34f317780e | ||
|
|
708b40880e | ||
|
|
bf661b5c1c | ||
|
|
57b08a99c6 | ||
| 8bc8a97e83 | |||
|
|
53548aec32 | ||
|
|
1380af6d50 | ||
|
|
21dcd87be2 | ||
|
|
fb97e421bb | ||
|
|
4f2ae176fa | ||
|
|
06e21711f2 | ||
|
|
95c564595f | ||
|
|
e725cd8a60 | ||
|
|
8507ad8378 | ||
|
|
cb8495fb0d | ||
|
|
8f8d3d38cc | ||
|
|
7eb80121a1 | ||
|
|
3736082096 | ||
|
|
2f303e63a3 | ||
|
|
ab2e5c346e | ||
|
|
ebb45238b0 | ||
|
|
6763721043 | ||
|
|
e235c3ef66 | ||
|
|
40b0e535cb | ||
|
|
9438301ebd | ||
|
|
bfed1b3e93 | ||
|
|
a9515f42b3 | ||
|
|
bbb62586f9 | ||
|
|
6aef21797d |
@@ -76,6 +76,21 @@
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.docx4j</groupId>-->
|
||||
<!-- <artifactId>docx4j-core</artifactId>-->
|
||||
<!-- <version>8.3.8</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.docx4j</groupId>
|
||||
<artifactId>docx4j</artifactId>
|
||||
|
||||
@@ -10,7 +10,6 @@ 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;
|
||||
@@ -21,6 +20,7 @@ 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.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
@@ -32,9 +32,10 @@ import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import com.njcn.gather.system.reg.service.ISysRegResService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -72,8 +73,6 @@ public class SocketDevResponseService {
|
||||
// ISO 8601格式
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
private DevPhaseSequenceParam devPhaseSequenceParam;
|
||||
|
||||
private List<String> dataTypeList;
|
||||
|
||||
private List<String> icdTypeList;
|
||||
@@ -92,6 +91,8 @@ public class SocketDevResponseService {
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final AdHarmonicService adHarmonicService;
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final IDictDataService dictDataService;
|
||||
@Value("${phaseAngle.isEnable}")
|
||||
private Boolean isPhaseAngle;
|
||||
|
||||
@@ -844,11 +845,15 @@ public class SocketDevResponseService {
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
Set<Integer> indexes = new HashSet<>();
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(param.getCode());
|
||||
storageParam.setScriptId(param.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
issueParam.setIndexList(indexes);
|
||||
param.getDevIds().forEach(devId -> {
|
||||
storageParam.setDevId(devId);
|
||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||
});
|
||||
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||
} else {
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
@@ -909,11 +914,13 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
// 发送下一个脚本与icd校验
|
||||
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
||||
if(ObjectUtil.isNotNull(icdType)){
|
||||
if (ObjectUtil.isNotNull(icdType)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("dataType", dataTypeList);
|
||||
map.put("icdType", icdType);
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue());
|
||||
System.out.println("开始脚本与icd校验:++++++++++");
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
@@ -940,6 +947,10 @@ public class SocketDevResponseService {
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
CnSocketUtil.quitSend(param);
|
||||
break;
|
||||
case ICD_NOT_FOUND:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
CnSocketUtil.quitSend(param);
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.sendUnSocket(param.getUserPageId());
|
||||
break;
|
||||
@@ -986,86 +997,92 @@ public class SocketDevResponseService {
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
devInfo.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
if (devData.getResult()) {
|
||||
devInfo.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println("相序校验接受数据完成---------" + successComm.size() + "__" + FormalTestManager.monitorIdListComm.size());
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println("相序校验接受数据完成---------" + successComm.size() + "__" + FormalTestManager.monitorIdListComm.size());
|
||||
|
||||
PqScriptIssueParam sourceParam = new PqScriptIssueParam();
|
||||
sourceParam.setPlanId(param.getPlanId());
|
||||
sourceParam.setDevIds(param.getDevIds());
|
||||
sourceParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
sourceParam.setScriptId(param.getScriptId());
|
||||
sourceParam.setSourceId(param.getSourceId());
|
||||
List<SourceIssue> sourceIssues = scriptDtlsService.listSourceIssue(sourceParam);
|
||||
List<SourceCompareDev> info = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(sourceIssues)) {
|
||||
devInfo.stream().sorted(Comparator.comparing(DevData::getId));
|
||||
info.addAll(devIsSource(devInfo, sourceIssues.get(0)));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
SocketDataMsg dataMsg = new SocketDataMsg();
|
||||
dataMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
dataMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
dataMsg.setCode(SourceResponseCodeEnum.SUCCESS.getCode());
|
||||
PqScriptIssueParam sourceParam = new PqScriptIssueParam();
|
||||
sourceParam.setPlanId(param.getPlanId());
|
||||
sourceParam.setDevIds(param.getDevIds());
|
||||
sourceParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
sourceParam.setScriptId(param.getScriptId());
|
||||
sourceParam.setSourceId(param.getSourceId());
|
||||
List<SourceIssue> sourceIssues = scriptDtlsService.listSourceIssue(sourceParam);
|
||||
List<SourceCompareDev> info = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(sourceIssues)) {
|
||||
devInfo.stream().sorted(Comparator.comparing(DevData::getId));
|
||||
info.addAll(devIsSource(devInfo, sourceIssues.get(0)));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
SocketDataMsg dataMsg = new SocketDataMsg();
|
||||
dataMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
dataMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
dataMsg.setCode(SourceResponseCodeEnum.SUCCESS.getCode());
|
||||
|
||||
for (SourceCompareDev sourceCompareDev : info) {
|
||||
dataMsg.setData(sourceCompareDev.getDevName() + splitTag + sourceCompareDev.getLineNum() + "校验结果:" + sourceCompareDev.getDesc());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(dataMsg));
|
||||
for (SourceCompareDev sourceCompareDev : info) {
|
||||
dataMsg.setData(sourceCompareDev.getDevName() + splitTag + sourceCompareDev.getLineNum() + "校验结果:" + sourceCompareDev.getDesc());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(dataMsg));
|
||||
}
|
||||
|
||||
if (info.stream().anyMatch(it -> !it.getIsQualified())) {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getCode());
|
||||
webSocketVO.setData(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getMessage());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
CnSocketUtil.quitSend(param);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//向前端推送消息
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
successComm.clear();
|
||||
}
|
||||
|
||||
if (info.stream().anyMatch(it -> !it.getIsQualified())) {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getCode());
|
||||
webSocketVO.setData(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getMessage());
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.PRE_TEST.getValue())) {
|
||||
System.out.println("预检测流程结束-----------------关闭源");
|
||||
//同时关闭设备三个步骤
|
||||
CnSocketUtil.quitSend(param);
|
||||
} else if (param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())) {
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||
webSocketVO.setData(XiNumberManager.devParameterList.get(0));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
return;
|
||||
|
||||
//下发命令获取所有装置通道系数,首先需要获取所有装置,通过所有装置下发获取系数命令,目前只支持单台装置获取系数
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
XiNumberManager.stepNumber = 0;
|
||||
XiNumberManager.devXiList.clear();
|
||||
XiNumberManager.devXiNumDataMap.clear();
|
||||
XiNumberManager.smallDevXiNumDataMap.clear();
|
||||
|
||||
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
}
|
||||
|
||||
|
||||
//向前端推送消息
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
successComm.clear();
|
||||
}
|
||||
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.PRE_TEST.getValue())) {
|
||||
System.out.println("预检测流程结束-----------------关闭源");
|
||||
//同时关闭设备三个步骤
|
||||
CnSocketUtil.quitSend(param);
|
||||
} else if (param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())) {
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||
webSocketVO.setData(XiNumberManager.devParameterList.get(0));
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
//下发命令获取所有装置通道系数,首先需要获取所有装置,通过所有装置下发获取系数命令,目前只支持单台装置获取系数
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
XiNumberManager.stepNumber = 0;
|
||||
XiNumberManager.devXiList.clear();
|
||||
XiNumberManager.devXiNumDataMap.clear();
|
||||
XiNumberManager.smallDevXiNumDataMap.clear();
|
||||
|
||||
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("被抛除的数据:" + data);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
@@ -1109,105 +1126,111 @@ public class SocketDevResponseService {
|
||||
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
if (devData.getResult()) {
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
successComm.add(devData.getId());
|
||||
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
//修改装置为监测中
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
//修改装置为监测中
|
||||
// adPlanService.updateTestState(param.getPlanId(), param.getDevIds());
|
||||
//开启线程进行入库原始数据操作
|
||||
baseDataInsert(FormalTestManager.realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
//开启线程进行入库原始数据操作
|
||||
baseDataInsert(FormalTestManager.realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
|
||||
//调用判断方法
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(FormalTestManager.realDataXiList, param, FormalTestManager.devIdMapComm, sourceIssue, dataRule);
|
||||
//调用判断方法
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(FormalTestManager.realDataXiList, param, FormalTestManager.devIdMapComm, sourceIssue, dataRule);
|
||||
|
||||
System.out.println(textResult);
|
||||
//组装实体推送给前台
|
||||
assWebJson(param, textResult, socketDataMsg, sourceIssue);
|
||||
System.out.println(textResult);
|
||||
//组装实体推送给前台
|
||||
assWebJson(param, textResult, socketDataMsg, sourceIssue);
|
||||
|
||||
//当小项结束后需要删除集合中的小项
|
||||
SocketManager.delSource(sourceIssue.getIndex());
|
||||
System.out.println("当前小项结束进行删除============" + sourceIssue.getType() + splitTag + sourceIssue.getIndex());
|
||||
//当小项结束后需要删除集合中的小项
|
||||
SocketManager.delSource(sourceIssue.getIndex());
|
||||
System.out.println("当前小项结束进行删除============" + sourceIssue.getType() + splitTag + sourceIssue.getIndex());
|
||||
|
||||
long residueCount = SocketManager.getSourceTarget(sourceIssue.getType()) - 1;
|
||||
SocketManager.addTargetMap(sourceIssue.getType(), residueCount);
|
||||
System.out.println("该大项还有" + residueCount + "个小项没有进行检测!!!!!!!!");
|
||||
if (residueCount == 0) {
|
||||
System.out.println(sourceIssue.getType() + sourceIssue.getIndex() + "当前测试大项已经全部结束》》》》》》》》");
|
||||
//当residueCount为0则认为大项中的小项已经全部跑完,开始组装信息推送给前端
|
||||
List<DevLineTestResult> resultList = new ArrayList<>();
|
||||
// 获取当前检测大项的所有设备的检测结果
|
||||
List<DevLineTestResult> allDevTestList = targetTestMap.get(sourceIssue.getType());
|
||||
Map<String, List<DevLineTestResult>> map = allDevTestList.stream().collect(Collectors.groupingBy(DevLineTestResult::getDeviceId));
|
||||
map.forEach((dev, list) -> {
|
||||
DevLineTestResult devTem = new DevLineTestResult();
|
||||
devTem.setDeviceId(dev);
|
||||
devTem.setDeviceName(list.get(0).getDeviceName());
|
||||
Integer[] arr = list.get(0).getChnResult();
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
List<Integer[]> arrList = list.stream().map(DevLineTestResult::getChnResult).collect(Collectors.toList());
|
||||
Integer[] resultArr = getMaxIntArray(arrList);
|
||||
devTem.setChnResult(resultArr);
|
||||
}
|
||||
resultList.add(devTem);
|
||||
});
|
||||
allDevTestList.clear();
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), socketDataMsg.getRequestId().split(stepTag)[1] + stepEnd, null, resultList, null);
|
||||
}
|
||||
//在这一步判断是否已经触发暂停按钮
|
||||
if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
FormalTestManager.stopTime = 0;
|
||||
FormalTestManager.hasStopFlag = true;
|
||||
successComm.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
||||
return;
|
||||
}
|
||||
|
||||
//开始进行下一项检测
|
||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
||||
long residueCount = SocketManager.getSourceTarget(sourceIssue.getType()) - 1;
|
||||
SocketManager.addTargetMap(sourceIssue.getType(), residueCount);
|
||||
System.out.println("该大项还有" + residueCount + "个小项没有进行检测!!!!!!!!");
|
||||
if (residueCount == 0) {
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), sourceIssues.getType() + stepBegin, null, new ArrayList<>(), null);
|
||||
System.out.println(sourceIssue.getType() + sourceIssue.getIndex() + "当前测试大项已经全部结束》》》》》》》》");
|
||||
//当residueCount为0则认为大项中的小项已经全部跑完,开始组装信息推送给前端
|
||||
List<DevLineTestResult> resultList = new ArrayList<>();
|
||||
// 获取当前检测大项的所有设备的检测结果
|
||||
List<DevLineTestResult> allDevTestList = targetTestMap.get(sourceIssue.getType());
|
||||
Map<String, List<DevLineTestResult>> map = allDevTestList.stream().collect(Collectors.groupingBy(DevLineTestResult::getDeviceId));
|
||||
map.forEach((dev, list) -> {
|
||||
DevLineTestResult devTem = new DevLineTestResult();
|
||||
devTem.setDeviceId(dev);
|
||||
devTem.setDeviceName(list.get(0).getDeviceName());
|
||||
Integer[] arr = list.get(0).getChnResult();
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
List<Integer[]> arrList = list.stream().map(DevLineTestResult::getChnResult).collect(Collectors.toList());
|
||||
Integer[] resultArr = getMaxIntArray(arrList);
|
||||
devTem.setChnResult(resultArr);
|
||||
}
|
||||
resultList.add(devTem);
|
||||
});
|
||||
allDevTestList.clear();
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), socketDataMsg.getRequestId().split(stepTag)[1] + stepEnd, null, resultList, null);
|
||||
}
|
||||
//在这一步判断是否已经触发暂停按钮
|
||||
if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
FormalTestManager.stopTime = 0;
|
||||
FormalTestManager.hasStopFlag = true;
|
||||
successComm.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
||||
return;
|
||||
}
|
||||
|
||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
//开始进行下一项检测
|
||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
||||
if (residueCount == 0) {
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), sourceIssues.getType() + stepBegin, null, new ArrayList<>(), null);
|
||||
}
|
||||
|
||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
successComm.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
successComm.clear();
|
||||
FormalTestManager.realDataXiList.clear();
|
||||
|
||||
} else {
|
||||
System.out.println("被抛除的数据:" + data);
|
||||
}
|
||||
break;
|
||||
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
|
||||
case NORMAL_RESPONSE:
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
if (devData.getResult()) {
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
} else {
|
||||
System.out.println("被抛除的数据:" + data);
|
||||
}
|
||||
FormalTestManager.realDataXiList.add(devData);
|
||||
|
||||
break;
|
||||
case DEV_ERROR:
|
||||
|
||||
@@ -1285,6 +1308,11 @@ public class SocketDevResponseService {
|
||||
|
||||
if (targetTestMap.containsKey(sourceIssue.getType())) {
|
||||
List<DevLineTestResult> devLineTestResultList = targetTestMap.get(sourceIssue.getType());
|
||||
// devListRes.forEach(it1 -> {
|
||||
// devLineTestResultList.stream().filter(it2 -> it2.getDeviceId().equals(it1.getDeviceId())).findFirst().ifPresent(it2 -> {
|
||||
// setNewChnResult(it2.getChnResult(), it1.getChnResult());
|
||||
// });
|
||||
// });
|
||||
devLineTestResultList.addAll(devListRes);
|
||||
} else {
|
||||
targetTestMap.put(sourceIssue.getType(), devListRes);
|
||||
@@ -1297,6 +1325,26 @@ public class SocketDevResponseService {
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
}
|
||||
|
||||
// private void setNewChnResult(Integer[] oldChnResult, Integer[] newChnResult) {
|
||||
// for (int i = 0; i < oldChnResult.length; i++) {
|
||||
// if (newChnResult[i] == 2) {
|
||||
// oldChnResult[i] = 2;
|
||||
// continue;
|
||||
// }
|
||||
// if (newChnResult[i] == 3 && oldChnResult[i] != 2) {
|
||||
// oldChnResult[i] = 3;
|
||||
// continue;
|
||||
// }
|
||||
// if (newChnResult[i] == 4 && oldChnResult[i] != 2) {
|
||||
// oldChnResult[i] = 4;
|
||||
// continue;
|
||||
// }
|
||||
// if (newChnResult[i] == 5 && oldChnResult[i] != 2 && oldChnResult[i] != 3 && oldChnResult[i] != 4) {
|
||||
// oldChnResult[i] = 5;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 返回大项检测结果,默认遇到 4,5时认为不参与计算
|
||||
*/
|
||||
@@ -1610,11 +1658,13 @@ public class SocketDevResponseService {
|
||||
//初始化有效数据数
|
||||
//Map<String, SysRegResVO> sysRegResMap = iSysRegResService.listRegRes();
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
//SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
AdPlan plan = adPlanService.getById(param.getPlanId());
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
//字典树
|
||||
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
||||
@@ -1623,8 +1673,8 @@ public class SocketDevResponseService {
|
||||
initXiManager(param);
|
||||
}
|
||||
|
||||
harmonicRelationMap.put(DetectionCodeEnum.V2_50.getCode(),DetectionCodeEnum.U1.getCode());
|
||||
harmonicRelationMap.put(DetectionCodeEnum.I2_50.getCode(),DetectionCodeEnum.I1.getCode());
|
||||
harmonicRelationMap.put(DetectionCodeEnum.V2_50.getCode(), DetectionCodeEnum.U1.getCode());
|
||||
harmonicRelationMap.put(DetectionCodeEnum.I2_50.getCode(), DetectionCodeEnum.I1.getCode());
|
||||
}
|
||||
|
||||
//初始化系数校验参数
|
||||
@@ -1728,7 +1778,7 @@ public class SocketDevResponseService {
|
||||
}
|
||||
} else {
|
||||
|
||||
for(int j=0;j<data.getSqlDataHarm().size();j++){
|
||||
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();
|
||||
@@ -1742,7 +1792,7 @@ public class SocketDevResponseService {
|
||||
|
||||
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().stream().filter(it->it.getDesc().equals(dui)).collect(Collectors.toList()).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();
|
||||
@@ -1871,47 +1921,4 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ public enum SourceOperateCodeEnum {
|
||||
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
|
||||
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
|
||||
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),
|
||||
DEVICE_ERROR("device_error","设备主动关闭连接,请稍后再试"),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum SourceResponseCodeEnum {
|
||||
SUCCESS(10200, "请求成功"),
|
||||
UNPROCESSED_BUSINESS(10201, "立即响应,业务还未处理,类似肯定应答"),
|
||||
NORMAL_RESPONSE(10202, "正常响应中间状态码"),
|
||||
ICD_NOT_FOUND(10500, "未找到对应ICD"),
|
||||
MESSAGE_PARSING_ERROR(10520, "报文解析有误"),
|
||||
CONTROLLED_SOURCE_ERROR(10521, "程控源参数有误"),
|
||||
TEST_ITEM_PARSING_ERROR(10522, "测试项解析有误"),
|
||||
|
||||
@@ -65,4 +65,14 @@ public class PreDetectionParam {
|
||||
private Boolean sendWebMsg;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private Float temperature;
|
||||
|
||||
/**
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -1015,7 +1016,23 @@ public class DetectionServiceImpl {
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qualifiedList)) {
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl));
|
||||
switch (dataRule) {
|
||||
case AT_WILL_VALUE:
|
||||
case CP95_VALUE:
|
||||
case AVG_VALUE:
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl));
|
||||
break;
|
||||
case SECTION_VALUE:
|
||||
case Own_value:
|
||||
if (qualifiedList.size() == harmDataList.size()) {
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl));
|
||||
} else {
|
||||
List<Double> subtract = CollectionUtils.subtract(harmDataList, qualifiedList).stream().collect(Collectors.toList());
|
||||
data.setData(subtract.get(0));
|
||||
data.setErrorData(devSubtractChannelData(subtract.get(0), channelData, ratedValue, errSysDtl));
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl));
|
||||
}
|
||||
@@ -1041,6 +1058,8 @@ public class DetectionServiceImpl {
|
||||
if (qualifiedList.size() == harmDataList.size()) {
|
||||
data.setIsData(1);
|
||||
} else {
|
||||
List<Double> subtract = CollectionUtils.subtract(harmDataList, qualifiedList).stream().collect(Collectors.toList());
|
||||
data.setData(subtract.get(0));
|
||||
data.setIsData(2);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -133,6 +133,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
WebServiceManager.addPreDetectionParam(param);
|
||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
param.setSourceId(planSource.getSourceId());
|
||||
@@ -198,7 +199,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(),param.getUserId());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public class CnSocketUtil {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ public class CnSocketUtil {
|
||||
jsonObject.put("sourceId", param.getSourceId());
|
||||
socketMsg.setData(jsonObject.toJSONString());
|
||||
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,6 +55,9 @@ public class WebServiceManager {
|
||||
channel.writeAndFlush(wd);
|
||||
}else {
|
||||
log.error("{}-websocket推送消息失败;当前用户-{}-客户端已经断开连接", LocalDateTime.now(),userId);
|
||||
// PreDetectionParam param = preDetectionParamMap.get("preDetectionParam");
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,14 +8,11 @@ import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -42,7 +39,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
private int consecutiveHeartbeatMisses = 0;
|
||||
|
||||
|
||||
public HeartbeatHandler(PreDetectionParam param,String type){
|
||||
public HeartbeatHandler(PreDetectionParam param, String type) {
|
||||
this.param = param;
|
||||
this.handlerType = type;
|
||||
}
|
||||
@@ -70,13 +67,13 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.channel().writeAndFlush(JSON.toJSONString(msg)+"\n");
|
||||
ctx.channel().writeAndFlush(JSON.toJSONString(msg) + "\n");
|
||||
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send"+LocalDateTime.now());
|
||||
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send" + LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses++;
|
||||
if (consecutiveHeartbeatMisses >= MAX_HEARTBEAT_MISSES) {
|
||||
// 连续三次未收到心跳响应,断开连接
|
||||
System.out.println(handlerType+"连续三次未收到心跳响应,断开连接");
|
||||
System.out.println(handlerType + "连续三次未收到心跳响应,断开连接");
|
||||
if (dev.equals(handlerType)) {
|
||||
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
|
||||
CnSocketUtil.quitSend(param);
|
||||
@@ -98,12 +95,11 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
// 过滤心跳包,避免进入业务逻辑
|
||||
if (isHeartbeatPacket(msg)) {
|
||||
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response"+LocalDateTime.now());
|
||||
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response" + LocalDateTime.now());
|
||||
consecutiveHeartbeatMisses = 0;
|
||||
return;
|
||||
}
|
||||
@@ -115,6 +111,6 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
private boolean isHeartbeatPacket(String msg) {
|
||||
// 判断是否为心跳包
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
return socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
return !Objects.isNull(socketDataMsg.getOperateCode()) && socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
fly = true;
|
||||
//为空则认为是常规步骤,设定一分钟超时
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
|
||||
}
|
||||
if (fly) {
|
||||
socketResponseService.backCheckState(param);
|
||||
@@ -185,7 +186,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else if (cause instanceof IOException) {
|
||||
// 处理I/O异常,例如读写错误
|
||||
System.out.println("IOException caught: There was an I/O error.");
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
|
||||
// 例如,可以记录更详细的I/O错误信息
|
||||
} else if (cause instanceof TimeoutException) {
|
||||
@@ -199,9 +200,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else {
|
||||
// 处理其他类型的异常
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
|
||||
// 可以记录未知异常信息
|
||||
}
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketResponseService.backCheckState(param);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
|
||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接?
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
} else {
|
||||
preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId("cdf");
|
||||
|
||||
@@ -182,19 +182,4 @@ public class PqDevController extends BaseController {
|
||||
});
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqDevService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,7 @@ public class PqDevParam {
|
||||
private Integer reCheckNum;
|
||||
|
||||
@ApiModelProperty("是否支持系数校准")
|
||||
@Min(value = 0, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
|
||||
private String factorFlag;
|
||||
private Integer factorFlag;
|
||||
|
||||
@ApiModelProperty("监测点台账列表")
|
||||
@Valid
|
||||
@@ -121,6 +119,9 @@ public class PqDevParam {
|
||||
@ApiModelProperty("预投计划")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@ApiModelProperty("委托方")
|
||||
private String delegate;
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
|
||||
@@ -201,5 +201,19 @@ public class PqDev extends BaseEntity implements Serializable {
|
||||
@TableField("Preinvestment_Plan")
|
||||
private String preinvestmentPlan;
|
||||
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private Float temperature;
|
||||
|
||||
/**
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
|
||||
/**
|
||||
* 委托方
|
||||
*/
|
||||
private String delegate;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CNDevExcel {
|
||||
@NotBlank(message = DetectionValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@Excel(name = "装置编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ProvinceDevExcel implements Serializable {
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "出厂日期*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@@ -63,16 +63,25 @@ public class ProvinceDevExcel implements Serializable {
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "14")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
|
||||
private Integer factorFlag;
|
||||
// @Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
|
||||
// private Integer factorFlag;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "16")
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "15")
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "17")
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "16")
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "样品编号", width = 20, orderNum = "17")
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
private String arrivedDate;
|
||||
|
||||
@Excel(name="委托方", width = 40, orderNum = "19")
|
||||
private String delegate;
|
||||
}
|
||||
|
||||
@@ -137,13 +137,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(List<String> id);
|
||||
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
@@ -152,9 +145,11 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param valueType
|
||||
* @param code
|
||||
* @param userId
|
||||
* @param temperature
|
||||
* @param humidity
|
||||
* @return
|
||||
*/
|
||||
boolean updateResult(List<String> ids, List<String> valueType, String code,String userId);
|
||||
boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity);
|
||||
|
||||
void updatePqDevReportState(String devId, int i);
|
||||
|
||||
|
||||
@@ -82,10 +82,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
|
||||
page1.getRecords().forEach(p -> {
|
||||
if (ObjectUtil.isNotNull(p.getSeries())) {
|
||||
if (StrUtil.isNotBlank(p.getSeries())) {
|
||||
p.setSeries(EncryptionUtil.decoderString(1, p.getSeries()));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(p.getDevKey())) {
|
||||
if (StrUtil.isNotBlank(p.getDevKey())) {
|
||||
p.setDevKey(EncryptionUtil.decoderString(1, p.getDevKey()));
|
||||
}
|
||||
});
|
||||
@@ -108,6 +108,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||
pqDevParam.setName(pqDevParam.getName().trim());
|
||||
pqDevParam.setCreateId(pqDevParam.getCreateId().trim());
|
||||
this.checkRepeat(pqDevParam, false);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
@@ -174,6 +176,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
updateParam.setCreateId(updateParam.getCreateId().trim());
|
||||
this.checkRepeat(updateParam, true);
|
||||
|
||||
PqDev pqDev = new PqDev();
|
||||
@@ -376,7 +380,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
//计划检测中
|
||||
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
|
||||
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
|
||||
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())
|
||||
).map(PqDev::getId).distinct().collect(Collectors.toList());
|
||||
if (checking.size() == notUnchecked.size()) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
@@ -485,43 +489,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return preDetections;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean documented(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
for (String id : ids) {
|
||||
// 只有检测完成的设备才可以进行归档
|
||||
PqDev pqDev = this.getById(id);
|
||||
if (ObjectUtil.isNotNull(pqDev)) {
|
||||
// 只有检测完成、且已生成报告的设备才可以进行归档
|
||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) || !pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
boolean update = this.lambdaUpdate()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
|
||||
.eq(PqDev::getId, id)
|
||||
.update();
|
||||
if (update) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = this.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@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, Float temperature, Float humidity) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
SysTestConfig config = sysTestConfigService.getOneConfig();
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
|
||||
@@ -533,9 +503,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
int i;
|
||||
LambdaUpdateWrapper<PqDev> wrapper = new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
|
||||
.set(PqDev::getCheckBy, userId)
|
||||
.set(StrUtil.isNotBlank(userId), PqDev::getCheckBy, userId)
|
||||
.set(PqDev::getCheckTime, LocalDateTime.now())
|
||||
.eq(PqDev::getId, pqDev.getId());
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
if (SceneEnum.PROVINCE_PLATFORM.getValue().equals(currrentScene)) {
|
||||
wrapper.set(ObjectUtil.isNotNull(temperature), PqDev::getTemperature, temperature)
|
||||
.set(ObjectUtil.isNotNull(humidity), PqDev::getHumidity, humidity);
|
||||
}
|
||||
if (pqDev.getReCheckNum() >= config.getMaxTime()) {
|
||||
// 装置报告生成 todo...
|
||||
//this.baseMapper.updateReportState(pqDev.getId());
|
||||
@@ -713,6 +688,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
} else {
|
||||
pqDev.setSeries(null);
|
||||
pqDev.setDevKey(null);
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
@@ -755,9 +733,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.checkRepeat(param, false);
|
||||
pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) && dev.getCreateId().equals(pqDev.getCreateId())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.NAME_OR_CREATEID_REPEAT);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -862,12 +842,17 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 是否支持系数校准
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 11);
|
||||
pullDown.setLastCol(startCol + 11);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
// 委托方
|
||||
dictType = dictTypeService.getByCode("Delegate");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 15);
|
||||
pullDown.setLastCol(startCol + 15);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
@@ -950,11 +935,26 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
*/
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DictData preinvestmentPlanDictData = dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan());
|
||||
if (ObjectUtil.isNull(preinvestmentPlanDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.PREINVESTMENT_PLAN_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setPreinvestmentPlan(preinvestmentPlanDictData.getId());
|
||||
}
|
||||
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
if (ObjectUtil.isNull(devType)) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setDevType(devType.getId());
|
||||
}
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNull(protocolDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setProtocol(protocolDictData.getId());
|
||||
}
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
@@ -1035,6 +1035,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
} else {
|
||||
pqDev.setSeries(null);
|
||||
pqDev.setDevKey(null);
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
@@ -1076,9 +1079,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
param.setDevType(pqDev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) || dev.getCreateId().equals(pqDev.getCreateId())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.NAME_OR_CREATEID_REPEAT);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1091,8 +1096,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public void visualizeProvinceDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName());
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName());
|
||||
}
|
||||
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
if (StrUtil.isNotBlank(pqDev.getDelegate())) {
|
||||
pqDev.setDelegate(dictDataService.getDictDataById(pqDev.getDelegate()).getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1100,10 +1111,32 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
if (ObjectUtil.isNull(devType)) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setDevType(devType.getId());
|
||||
}
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setManufacturer(dictDataService.getDictDataByName(pqDev.getManufacturer()).getId());
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
DictData manufacturerDictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNull(manufacturerDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.MANUFACTURER_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setManufacturer(manufacturerDictData.getId());
|
||||
}
|
||||
DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNull(protocolDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setProtocol(protocolDictData.getId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDelegate())) {
|
||||
DictData delegateDictData = dictDataService.getDictDataByName(pqDev.getDelegate());
|
||||
if (ObjectUtil.isNull(delegateDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.DELEGATE_NOT_EXIST);
|
||||
} else {
|
||||
pqDev.setDelegate(delegateDictData.getId());
|
||||
}
|
||||
}
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
|
||||
@@ -67,6 +67,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addPqErrSys(PqErrSysParam param) {
|
||||
param.setStandardName(param.getStandardName().trim());
|
||||
this.checkRepeat(param, false);
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
@@ -84,6 +85,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
|
||||
param.setStandardName(param.getStandardName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
|
||||
@@ -47,6 +47,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addIcd(PqIcdPathParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, false);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
@@ -57,6 +58,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
|
||||
@@ -125,8 +125,8 @@ public class AdPlanController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载检测计划导出模板")
|
||||
public void downloadTemplate(@RequestBody String patternId) {
|
||||
adPlanService.downloadTemplate(patternId);
|
||||
public void downloadTemplate(@RequestBody AdPlanParam.QueryParam queryParam) {
|
||||
adPlanService.downloadTemplate(queryParam.getPatternId());
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@@ -155,7 +155,7 @@ public class AdPlanController extends BaseController {
|
||||
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
|
||||
String methodDescribe = getMethodDescribe("getBigTestItem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevId());
|
||||
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevIds());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.report.pojo.po.PqReport;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
@@ -27,5 +29,13 @@ public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
|
||||
* @return
|
||||
*/
|
||||
PqReport getPqReportById(String id);
|
||||
|
||||
/**
|
||||
* 获取所有报告模板名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<String> listAllReportTemplateName();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,5 +17,10 @@
|
||||
WHERE id = #{id}
|
||||
and state = 1
|
||||
</select>
|
||||
<select id="listAllReportTemplateName" resultType="java.lang.String">
|
||||
SELECT concat(name, '_', version) as name
|
||||
FROM pq_report
|
||||
WHERE state = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum DataSourceEnum {
|
||||
THREE_SENSE_ACTUAL_TIME_DATA("0", "3s实时数据"),
|
||||
THREE_SENSE_ACTUAL_TIME_DATA("real", "3s实时数据"),
|
||||
|
||||
MINUTE_STATISTICS_MAX("1", "分钟统计数据-最大"),
|
||||
MINUTE_STATISTICS_MIN("2", "分钟统计数据-最小"),
|
||||
MINUTE_STATISTICS_AVG("3", "分钟统计数据-平均"),
|
||||
MINUTE_STATISTICS_CP95("4", "分钟统计数据-CP95"),
|
||||
RECORDED_DATA("5", "录播数据");
|
||||
MINUTE_STATISTICS_MAX("max", "分钟统计数据-最大"),
|
||||
MINUTE_STATISTICS_MIN("min", "分钟统计数据-最小"),
|
||||
MINUTE_STATISTICS_AVG("avg", "分钟统计数据-平均"),
|
||||
MINUTE_STATISTICS_CP95("cp95", "分钟统计数据-CP95"),
|
||||
RECORDED_DATA("Recorded_data", "录播数据");
|
||||
|
||||
private String value;
|
||||
private String msg;
|
||||
|
||||
@@ -60,11 +60,16 @@ public class AdPlanParam {
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty(value = "是否关联报告")
|
||||
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
|
||||
private Integer associateReport;
|
||||
|
||||
@ApiModelProperty(value = "报告模板名称")
|
||||
private String reportTemplateName;
|
||||
|
||||
@ApiModelProperty(value = "数据处理原则")
|
||||
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
|
||||
private String dataRule;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@@ -110,6 +115,6 @@ public class AdPlanParam {
|
||||
// 0:不合格项复检 1:全部复检
|
||||
private Integer reCheckType;
|
||||
private String planId;
|
||||
private String devId;
|
||||
private List<String> devIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,5 +94,10 @@ public class AdPlan extends BaseEntity implements Serializable {
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 数据处理原则。任意值、部分值、所有值、cp95值、平均值
|
||||
*/
|
||||
private String dataRule;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,27 +25,38 @@ public class AdPlanExcel {
|
||||
@NotBlank(message = DetectionValidMessage.DATASOURCE_NOT_BLANK)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本*", width = 100, needMerge = true, orderNum = "3")
|
||||
@Excel(name = "脚本*", width = 40, needMerge = true, orderNum = "3")
|
||||
@NotBlank(message = DetectionValidMessage.SCRIPT_NOT_BLANK)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系*", width = 30, needMerge = true, orderNum = "4")
|
||||
@Excel(name = "误差体系*", width = 40, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DetectionValidMessage.ERRORSYS_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
@Excel(name = "数据处理原则*", width = 20, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
|
||||
private String dataRule;
|
||||
|
||||
@Excel(name = "是否做守时检测*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "6")
|
||||
@NotNull(message = DetectionValidMessage.TIMECHECK_NOT_NULL)
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
@NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
|
||||
private Integer testState;
|
||||
@Excel(name = "关联报告模版*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
|
||||
private Integer associateReport;
|
||||
|
||||
@Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
|
||||
private Integer reportState;
|
||||
@Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, needMerge = true, orderNum = "8")
|
||||
private String reportTemplateId;
|
||||
|
||||
@Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
@NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
private Integer result;
|
||||
// @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "9")
|
||||
// @NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
|
||||
// private Integer testState;
|
||||
//
|
||||
// @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "10")
|
||||
// @NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
|
||||
// private Integer reportState;
|
||||
//
|
||||
// @Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "11")
|
||||
// @NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
// private Integer result;
|
||||
}
|
||||
|
||||
@@ -108,4 +108,6 @@ public class AdPlanVO {
|
||||
* 报告模板名称
|
||||
*/
|
||||
private String reportTemplateName;
|
||||
|
||||
private String dataRule;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -70,10 +70,10 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
*
|
||||
* @param reCheckType 0:不合格项复检 1:全部复检
|
||||
* @param planId 检测计划Id
|
||||
* @param devId 设备Id
|
||||
* @param devIds 设备Id列表
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId);
|
||||
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 修改计划状态
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.po.PqReport;
|
||||
import com.njcn.gather.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.service.IPqScriptService;
|
||||
@@ -142,6 +143,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
this.checkRepeat(param, false);
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
adPlan.setName(param.getName().trim());
|
||||
|
||||
String planId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
adPlan.setId(planId);
|
||||
@@ -184,6 +186,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
AdPlan plan1 = this.getById(param.getId());
|
||||
AdPlan plan2 = new AdPlan();
|
||||
@@ -304,11 +307,19 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
|
||||
adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adPlan.getDataRule())) {
|
||||
String dataRule = adPlan.getDataRule();
|
||||
adPlan.setDataRule(dictDataService.getDictDataById(dataRule).getName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) {
|
||||
PqReport report = this.baseMapper.getPqReportById(adPlan.getReportTemplateId());
|
||||
adPlan.setReportTemplateId(report.getName() + "_" + report.getVersion());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId) {
|
||||
public List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds) {
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
AdPlan adPlan = this.getById(planId);
|
||||
if (ObjectUtil.isNull(adPlan)) {
|
||||
@@ -330,10 +341,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
//
|
||||
// scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList());
|
||||
// }
|
||||
Set<Integer> indexes = new HashSet<>();
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(adPlan.getCode() + "");
|
||||
storageParam.setScriptId(adPlan.getScriptId());
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
|
||||
devIds.forEach(devId -> {
|
||||
storageParam.setDevId(devId);
|
||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||
});
|
||||
scriptDtlsList = scriptDtlsList.stream().filter(obj -> indexes.contains(obj.getScriptIndex())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -624,6 +639,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
}
|
||||
planExcel.setAssociateReport(0);
|
||||
planExcel.setReportTemplateId(null);
|
||||
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
adPlanSourceService.addAdPlanSource(planId, sourceIds);
|
||||
@@ -704,11 +721,18 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
}
|
||||
if ((planExcel.getAssociateReport().equals(1) && "".equals(planExcel.getReportTemplateId()))) {
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_REPORT_TEMPLATE_ERROR);
|
||||
}
|
||||
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
adPlanSourceService.addAdPlanSource(planId, sourceIds);
|
||||
|
||||
List<ProvinceDevExcel> cnDevExcelList = planExcel.getDevices();
|
||||
ProvinceDevExcel provinceDevExcel = cnDevExcelList.get(0);
|
||||
if (ObjectUtil.isNull(provinceDevExcel.getName())) {
|
||||
cnDevExcelList.remove(0);
|
||||
}
|
||||
pqDevService.importProvinceDev(cnDevExcelList, patternId, planId);
|
||||
}
|
||||
// 逆向可视化
|
||||
@@ -753,12 +777,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
});
|
||||
PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId());
|
||||
SysTestConfig config1 = sysTestConfigService.getConfig();
|
||||
if (ObjectUtil.isNotNull(config1)) {
|
||||
DictData dictData = dictDataService.getDictDataById(config1.getDataRule());
|
||||
if (ObjectUtil.isNotNull(errSys) && ObjectUtil.isNotNull(dictData)) {
|
||||
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData.getName() + "\"数据原则计算得出。");
|
||||
}
|
||||
DictData dictData1 = dictDataService.getDictDataById(plan.getDataRule());
|
||||
if (ObjectUtil.isNotNull(dictData1) && ObjectUtil.isNotNull(errSys)) {
|
||||
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData1.getName() + "\"数据原则计算得出。");
|
||||
}
|
||||
return note.toString();
|
||||
}
|
||||
@@ -821,13 +842,49 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private void reverseVisualize(List<AdPlan> planList) {
|
||||
planList.forEach(adPlan -> {
|
||||
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getValueByMsg(id)).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> {
|
||||
String value = DataSourceEnum.getValueByMsg(id);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
throw new BusinessException(DetectionResponseEnum.DATA_SOURCE_NOT_EXIST);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
|
||||
adPlan.setScriptId(pqScriptService.getPqScriptByName(adPlan.getScriptId()).getId());
|
||||
PqScript pqScript = pqScriptService.getPqScriptByName(adPlan.getScriptId());
|
||||
if (ObjectUtil.isNull(pqScript)) {
|
||||
throw new BusinessException(DetectionResponseEnum.SCRIPT_NOT_EXIST);
|
||||
} else {
|
||||
adPlan.setScriptId(pqScript.getId());
|
||||
}
|
||||
|
||||
adPlan.setErrorSysId(pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId()).getId());
|
||||
PqErrSys pqErrSys = pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId());
|
||||
if (ObjectUtil.isNull(pqErrSys)) {
|
||||
throw new BusinessException(DetectionResponseEnum.ERROR_SYSTEM_NOT_EXIST);
|
||||
} else {
|
||||
adPlan.setErrorSysId(pqErrSys.getId());
|
||||
}
|
||||
|
||||
DictData dataRuleDictData = dictDataService.getDictDataByName(adPlan.getDataRule());
|
||||
if (ObjectUtil.isNull(dataRuleDictData)) {
|
||||
throw new BusinessException(DetectionResponseEnum.DATA_RULE_NOT_EXIST);
|
||||
} else {
|
||||
adPlan.setDataRule(dataRuleDictData.getId());
|
||||
}
|
||||
if (adPlan.getAssociateReport().equals(0)) {
|
||||
adPlan.setReportTemplateId(null);
|
||||
}else if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) {
|
||||
String[] split = adPlan.getReportTemplateId().split("_");
|
||||
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
|
||||
if (ObjectUtil.isNull(reportId)) {
|
||||
throw new BusinessException(DetectionResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
} else {
|
||||
adPlan.setReportTemplateId(reportId);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.LACK_REPORT_TEMPLATE_ID);
|
||||
}
|
||||
adPlan.setCode(this.generateCode());
|
||||
|
||||
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
||||
// 默认为顶级检测计划
|
||||
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
||||
@@ -1027,14 +1084,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
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);
|
||||
// }
|
||||
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");
|
||||
@@ -1065,34 +1122,61 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
pullDown.setStrings(errSysNameList);
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 是否做守时检测
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(5);
|
||||
pullDown.setLastCol(5);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
// 数据处理原则
|
||||
dictType = dictTypeService.getByCode("Data_Rule");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
List<DictData> dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
// 检测状态
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(5);
|
||||
pullDown.setLastCol(5);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 是否做守时检测
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(6);
|
||||
pullDown.setLastCol(6);
|
||||
pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg()));
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 报告生成状态
|
||||
// 是否关联报告模板
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg()));
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
//检测结果
|
||||
// 报告模板
|
||||
List<String> strings = this.baseMapper.listAllReportTemplateName();
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(8);
|
||||
pullDown.setLastCol(8);
|
||||
pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg()));
|
||||
pullDown.setStrings(strings);
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 检测状态
|
||||
// pullDown = new PullDown();
|
||||
// pullDown.setFirstCol(9);
|
||||
// pullDown.setLastCol(9);
|
||||
// pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg()));
|
||||
// pullDowns.add(pullDown);
|
||||
|
||||
// 报告生成状态
|
||||
// pullDown = new PullDown();
|
||||
// pullDown.setFirstCol(10);
|
||||
// pullDown.setLastCol(10);
|
||||
// pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg()));
|
||||
// pullDowns.add(pullDown);
|
||||
|
||||
//检测结果
|
||||
// pullDown = new PullDown();
|
||||
// pullDown.setFirstCol(11);
|
||||
// pullDown.setLastCol(11);
|
||||
// pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg()));
|
||||
// pullDowns.add(pullDown);
|
||||
|
||||
switch (scene) {
|
||||
case PROVINCE_PLATFORM:
|
||||
List<PullDown> provinceDevPullDownList = pqDevService.getProvinceDevPullDownList(9);
|
||||
|
||||
@@ -179,4 +179,6 @@ public interface DetectionValidMessage {
|
||||
|
||||
String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符";
|
||||
String REPORT_NAME_NOT_BLANK = "报告模板不能为空";
|
||||
String DATA_RULE_NOT_BLANK = "数据处理原则不能为空";
|
||||
String ASSOCIATE_REPORT_NOT_NULL = "是否关联报告模板不能为空";
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum DetectionResponseEnum {
|
||||
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
|
||||
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
|
||||
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
|
||||
SCRIPT_NAME_REPEAT("A02015","脚本名称重复"),
|
||||
SCRIPT_NAME_REPEAT("A02015", "脚本名称重复"),
|
||||
|
||||
|
||||
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
|
||||
@@ -48,8 +48,21 @@ public enum DetectionResponseEnum {
|
||||
DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"),
|
||||
CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"),
|
||||
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"),
|
||||
CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误,只能包含数字,长度为1-32位"),
|
||||
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位" );
|
||||
CN_DEV_NAME_FORMAT_ERROR("A02059", "设备名称格式错误,只能包含数字,长度为1-32位"),
|
||||
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060", "设备名称格式错误,只能包含字母、数字、下划线、中划线、空格,长度为1-32位"),
|
||||
IMPORT_REPORT_TEMPLATE_ERROR("A02061", "当关联报告模板为是时,报告模板不能为空"),
|
||||
DEV_TYPE_NOT_EXIST("A02062", "设备类型不存在,请先添加设备类型"),
|
||||
MANUFACTURER_NOT_EXIST("A02063", "该设备厂家不存在,请先在\"设备厂家\"字典中添加"),
|
||||
PROTOCOL_NOT_EXIST("A02064", "该协议不存在,请先在\"通讯协议\"字典中添加"),
|
||||
DELEGATE_NOT_EXIST("A02065", "该委托方不存在,请先在\"委托方\"字典中添加"),
|
||||
PREINVESTMENT_PLAN_NOT_EXIST("A02066", "该预投计划不存在,请先在\"预投计划\"字典中添加"),
|
||||
DATA_SOURCE_NOT_EXIST("A02067", "该数据源不存在,请先在\"数据源\"字典中添加"),
|
||||
SCRIPT_NOT_EXIST("A02068", "该脚本不存在,请先添加该脚本"),
|
||||
ERROR_SYSTEM_NOT_EXIST("A02069", "该误差体系不存在,请先添加该误差体系"),
|
||||
DATA_RULE_NOT_EXIST("A02070", "该数据处理原则不存在,请先在\"数据处理原则\"字典中添加"),
|
||||
REPORT_TEMPLATE_NOT_EXIST("A02071", "该报告模板不存在,请先添加该报告模板"),
|
||||
LACK_REPORT_TEMPLATE_ID("A02072","当关联报告模板为\"是\"时,报告模板不能为空" ),
|
||||
NAME_OR_CREATEID_REPEAT("A02073","名称或装置编号重复" );
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.report.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
@@ -140,4 +141,19 @@ public class ReportController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("listAllName");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqReportService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ public enum BaseReportKeyEnum {
|
||||
YEAR("year","年份"),
|
||||
MONTH("month","月份"),
|
||||
DAY("day","日"),
|
||||
YEAR_MONTH_DAY("year-month-day","年-月-日");
|
||||
YEAR_MONTH_DAY("year-month-day","年-月-日"),
|
||||
TEMPERATURE("temp","温度"),
|
||||
HUMIDITY("hum","相对湿度"),
|
||||
DELEGATE("delegate","委托方");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.gather.report.pojo.enums;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/5/22 9:46
|
||||
*/
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 统计文档锚点类型
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2025/3/24 18:42
|
||||
*/
|
||||
@Getter
|
||||
public enum BookmarkEnum {
|
||||
|
||||
|
||||
DATA_LINE("data_line", "准确度数据展示区域,以测试回路维度展示", 1),
|
||||
DATA_SCRIPT("data_script", "准确度数据展示区域,以检测项维度展示", 1),
|
||||
TEST_RESULT_DEV("testResult_dev", "检测结论,仅有设备结论", 2),
|
||||
TEST_RESULT_LINE("testResult_line", "检测结论,仅有回路结论", 2),
|
||||
TEST_RESULT_DETAIL("testResult_detail", "检测结论,包含回路、设备结论", 2),
|
||||
CATALOG("catalog", "目录信息", 3);
|
||||
|
||||
private String key;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
BookmarkEnum(String key, String desc, Integer sort) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key找到适配的枚举
|
||||
*
|
||||
* @param key 枚举的key
|
||||
* @return 匹配的枚举实例,如果没有找到则返回null
|
||||
*/
|
||||
public static BookmarkEnum getByKey(String key) {
|
||||
for (BookmarkEnum bookmarkEnum : BookmarkEnum.values()) {
|
||||
if (bookmarkEnum.getKey().equalsIgnoreCase(key)) {
|
||||
return bookmarkEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,9 +16,9 @@ public enum PowerIndexEnum {
|
||||
FREQ("FREQ", "频率"),
|
||||
V("V", "电压"),
|
||||
I("I", "电流"),
|
||||
IMBV("IMBV", "三相电压不平衡度"),
|
||||
IMBA("IMBA", "三相电流不平衡度"),
|
||||
F("F", "闪变"),
|
||||
IMBV("IMBV", "负序电压不平衡度"),
|
||||
IMBA("IMBA", "负序电流不平衡度"),
|
||||
F("F", "短时电压闪变"),
|
||||
HP("HP", "谐波有功功率"),
|
||||
HV("HV", "谐波电压"),
|
||||
HI("HI", "谐波电流"),
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.njcn.gather.report.pojo.vo.PqReportVO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
@@ -67,5 +66,11 @@ public interface IPqReportService extends IService<PqReport> {
|
||||
|
||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||
|
||||
//Map<String, Object> getMap(DevReportParam devReportParam);
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(List<String> id);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.device.mapper.PqDevMapper;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
||||
@@ -39,10 +42,9 @@ import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.report.pojo.vo.Bookmark;
|
||||
import com.njcn.gather.report.pojo.vo.PqReportVO;
|
||||
import com.njcn.gather.report.service.IPqReportService;
|
||||
import com.njcn.gather.report.utils.BookmarkUtil;
|
||||
import com.njcn.gather.report.utils.Docx4jUtil;
|
||||
import com.njcn.gather.report.utils.WordUtil;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
@@ -56,6 +58,8 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
@@ -68,10 +72,14 @@ import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.docx4j.TraversalUtil;
|
||||
import org.docx4j.finders.RangeFinder;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
import org.docx4j.wml.CTBookmark;
|
||||
import org.docx4j.wml.Document;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -115,6 +123,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private final String BLACK = "000000";
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
private final PqDevMapper pqDevMapper;
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@@ -138,6 +147,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
|
||||
private final long FILE_SIZE_LIMIT = 5 * 1024 * 1024;
|
||||
|
||||
@Override
|
||||
@@ -605,7 +616,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
baseDocumentPart.variableReplace(baseModelDataMap);
|
||||
// 获取数据模版页内容,根据脚本动态组装数据页内容
|
||||
MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart();
|
||||
dealDataModelScattered(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// dealDataModelScattered(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
dealDataModelScatteredByBookmark(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// 保存新的文档
|
||||
String dirPath = reportPath.concat(File.separator).concat(devType.getName());
|
||||
// 确保目录存在
|
||||
@@ -620,6 +632,107 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过提前在模板文档里埋下书签
|
||||
* 1、目录信息
|
||||
* 2、准确度测试详情
|
||||
* 3、测试结果页
|
||||
* 上述3个锚点位置不固定,可能结果页在通用信息中间,也有可能在文档最末端。
|
||||
* 注:当存在目录信息时,目录最后生成。
|
||||
*
|
||||
* @param baseDocumentPart 通用信息文档
|
||||
* @param detailDocumentPart 数据项模板文档
|
||||
* @param devReportParam 测试报告参数
|
||||
* @param pqDevVO 被检设备
|
||||
*/
|
||||
private void dealDataModelScatteredByBookmark(MainDocumentPart baseDocumentPart, MainDocumentPart detailDocumentPart, DevReportParam devReportParam, PqDevVO pqDevVO) {
|
||||
// 查找 base 文档中所有书签
|
||||
List<BookmarkUtil.BookmarkInfo> bookmarks = BookmarkUtil.findAllBookmarks(baseDocumentPart);
|
||||
if (CollUtil.isNotEmpty(bookmarks)) {
|
||||
// 转换为枚举,便于排序,防止结论性的书签在文档的前面
|
||||
List<BookmarkEnum> bookmarkEnums = new ArrayList<>();
|
||||
for (BookmarkUtil.BookmarkInfo info : bookmarks) {
|
||||
String name = info.bookmark.getName();
|
||||
BookmarkEnum bookmarkEnum = BookmarkEnum.getByKey(name);
|
||||
if (Objects.nonNull(bookmarkEnum)) {
|
||||
bookmarkEnums.add(bookmarkEnum);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 从结构上分析,处理的顺序:
|
||||
* 1、数据项
|
||||
* 2、结果信息
|
||||
* 3、目录信息
|
||||
* 所以要先先获取的书签进行操作排序
|
||||
* */
|
||||
Collections.sort(bookmarkEnums);
|
||||
// 定义个结果,以便存在结果信息的书签
|
||||
Map<String/*指标名称*/, List<Boolean/*以回路的顺序填充结果*/>> resultMap = new HashMap<>();
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
BookmarkUtil.BookmarkInfo bookmarkInfo = null;
|
||||
// 书签在文档的位置
|
||||
for (int i = 0; i < bookmarkEnums.size(); i++) {
|
||||
BookmarkEnum bookmarkEnum = bookmarkEnums.get(i);
|
||||
switch (bookmarkEnum) {
|
||||
case DATA_LINE:
|
||||
// 获取标签信息
|
||||
bookmarkInfo = BookmarkUtil.getBookmarkInfo(BookmarkEnum.DATA_LINE.getKey(), bookmarks);
|
||||
todoInsertList = dealDataLine(detailDocumentPart, devReportParam, pqDevVO, resultMap);
|
||||
if (Objects.nonNull(bookmarkInfo) && CollectionUtil.isNotEmpty(todoInsertList)) {
|
||||
BookmarkUtil.insertElement(bookmarkInfo, todoInsertList);
|
||||
BookmarkUtil.removeBookmark(bookmarkInfo);
|
||||
}
|
||||
break;
|
||||
case DATA_SCRIPT:
|
||||
break;
|
||||
case TEST_RESULT_DEV:
|
||||
// 判断是否已经处理过数据了,有了结论性的描述
|
||||
if (CollUtil.isEmpty(resultMap)) {
|
||||
dealDataLine(baseDocumentPart, devReportParam, pqDevVO, resultMap);
|
||||
}
|
||||
bookmarkInfo = BookmarkUtil.getBookmarkInfo(BookmarkEnum.TEST_RESULT_DEV.getKey(), bookmarks);
|
||||
todoInsertList = dealTestResultLine(baseDocumentPart, detailDocumentPart, devReportParam, resultMap, DocAnchorEnum.TEST_RESULT_DEV);
|
||||
if (Objects.nonNull(bookmarkInfo) && CollectionUtil.isNotEmpty(todoInsertList)) {
|
||||
BookmarkUtil.insertElement(bookmarkInfo, todoInsertList);
|
||||
BookmarkUtil.removeBookmark(bookmarkInfo);
|
||||
}
|
||||
break;
|
||||
case TEST_RESULT_LINE:
|
||||
// 判断是否已经处理过数据了,有了结论性的描述
|
||||
if (CollUtil.isEmpty(resultMap)) {
|
||||
dealDataLine(baseDocumentPart, devReportParam, pqDevVO, resultMap);
|
||||
}
|
||||
bookmarkInfo = BookmarkUtil.getBookmarkInfo(BookmarkEnum.TEST_RESULT_LINE.getKey(), bookmarks);
|
||||
todoInsertList = dealTestResultLine(baseDocumentPart, detailDocumentPart, devReportParam, resultMap, DocAnchorEnum.TEST_RESULT_LINE);
|
||||
if (Objects.nonNull(bookmarkInfo) && CollectionUtil.isNotEmpty(todoInsertList)) {
|
||||
BookmarkUtil.insertElement(bookmarkInfo, todoInsertList);
|
||||
BookmarkUtil.removeBookmark(bookmarkInfo);
|
||||
}
|
||||
break;
|
||||
case TEST_RESULT_DETAIL:
|
||||
// 判断是否已经处理过数据了,有了结论性的描述
|
||||
if (CollUtil.isEmpty(resultMap)) {
|
||||
dealDataLine(baseDocumentPart, devReportParam, pqDevVO, resultMap);
|
||||
}
|
||||
bookmarkInfo = BookmarkUtil.getBookmarkInfo(BookmarkEnum.TEST_RESULT_LINE.getKey(), bookmarks);
|
||||
todoInsertList = dealTestResultLine(baseDocumentPart, detailDocumentPart, devReportParam, resultMap, DocAnchorEnum.TEST_RESULT_DETAIL);
|
||||
if (Objects.nonNull(bookmarkInfo) && CollectionUtil.isNotEmpty(todoInsertList)) {
|
||||
BookmarkUtil.insertElement(bookmarkInfo, todoInsertList);
|
||||
BookmarkUtil.removeBookmark(bookmarkInfo);
|
||||
}
|
||||
break;
|
||||
case CATALOG:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通用基础信息文档里可能会存在的书签锚点
|
||||
* 1、目录信息
|
||||
@@ -722,7 +835,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
ObjectFactory factory = Context.getWmlObjectFactory();
|
||||
// 结论
|
||||
P newParagraph = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, newParagraph, "检测结论", 28, true);
|
||||
Docx4jUtil.createTitle(factory, newParagraph, "检测结论", 24, true);
|
||||
//插入段落
|
||||
paragraphs.add(position++, newParagraph);
|
||||
// 源文档的内容
|
||||
@@ -751,8 +864,10 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<Integer> centerFlag = new ArrayList<>();
|
||||
centerFlag.add(0);
|
||||
Tr titleRow = Docx4jUtil.createCustomRow(factory, title, "Arial", "宋体", 21, true, centerFlag);
|
||||
|
||||
Tr titleRow = Docx4jUtil.createCustomRow(factory, title, "SimSun", "宋体", 21, true, false);
|
||||
table.getContent().add(titleRow);
|
||||
// 处理业务数据
|
||||
resultMap.forEach((key, value) -> {
|
||||
@@ -784,7 +899,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Tr tempRow = Docx4jUtil.createCustomRow(factory, cellValues, "SimSun", "宋体", 21, false, false);
|
||||
Tr tempRow = Docx4jUtil.createCustomRow(factory, cellValues, "Arial", "宋体", 21, false, centerFlag);
|
||||
table.getContent().add(tempRow);
|
||||
});
|
||||
TblPr tblPr = Docx4jUtil.getTblPr(factory);
|
||||
@@ -801,6 +916,103 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 如何处理结果性数据进文档,各省级平台的结果表格不一致,如何做到一致
|
||||
*
|
||||
* @param baseDocumentPart 基础模板文档
|
||||
* @param detailDocumentPart 数据模板文档
|
||||
* @param resultMap 各测试项的结果
|
||||
*/
|
||||
private List<Object> dealTestResultLine(MainDocumentPart baseDocumentPart, MainDocumentPart detailDocumentPart, DevReportParam devReportParam, Map<String, List<Boolean>> resultMap, DocAnchorEnum docAnchorEnum) {
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
// 先判断数据有没有,如果没有,则不处理
|
||||
if (CollUtil.isEmpty(resultMap.get(PowerIndexEnum.UNKNOWN.getKey()))) {
|
||||
ObjectFactory factory = Context.getWmlObjectFactory();
|
||||
// 源文档的内容
|
||||
// 创建表格(示例为3列,列数可任意调整)
|
||||
Tbl table = factory.createTbl();
|
||||
List<List<Boolean>> tempResultList = new ArrayList<>(resultMap.values());
|
||||
int lineNum = tempResultList.get(0).size();
|
||||
// 处理表头
|
||||
List<String> title = new ArrayList<>();
|
||||
title.add("检测项目");
|
||||
switch (docAnchorEnum) {
|
||||
case TEST_RESULT_DEV:
|
||||
title.add("结论");
|
||||
break;
|
||||
case TEST_RESULT_LINE:
|
||||
for (int i = 1; i < lineNum + 1; i++) {
|
||||
title.add("测量回路" + i);
|
||||
}
|
||||
break;
|
||||
case TEST_RESULT_DETAIL:
|
||||
for (int i = 1; i < lineNum + 1; i++) {
|
||||
title.add("测量回路" + i);
|
||||
}
|
||||
title.add("结论");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<Integer> centerFlag = new ArrayList<>();
|
||||
centerFlag.add(0);
|
||||
Tr titleRow = Docx4jUtil.createCustomRow(factory, title, "Arial", "宋体", 21, true, centerFlag);
|
||||
table.getContent().add(titleRow);
|
||||
|
||||
// 处理业务数据
|
||||
List<PqScriptDtlDataVO> pqScriptDtlsList = pqScriptDtlsService.getScriptDtlsDataList(devReportParam.getScriptId());
|
||||
pqScriptDtlsList.sort(Comparator.comparing(PqScriptDtlDataVO::getScriptIndex));
|
||||
Set<String> scriptCodeSet = new HashSet<>();
|
||||
for (PqScriptDtlDataVO pqScriptDtlDataVO : pqScriptDtlsList) {
|
||||
String scriptCode = pqScriptDtlDataVO.getScriptCode();
|
||||
if (scriptCodeSet.contains(scriptCode)) {
|
||||
continue;
|
||||
} else {
|
||||
scriptCodeSet.add(scriptCode);
|
||||
}
|
||||
List<Boolean> value = resultMap.get(scriptCode);
|
||||
List<String> cellValues = new ArrayList<>();
|
||||
PowerIndexEnum indexEnum = PowerIndexEnum.getByKey(scriptCode);
|
||||
if (indexEnum != null) {
|
||||
if (scriptCode.equals(PowerIndexEnum.VOLTAGE.getKey())) {
|
||||
cellValues.add(indexEnum.getDesc());
|
||||
} else {
|
||||
cellValues.add(indexEnum.getDesc().concat("测量准确度"));
|
||||
}
|
||||
} else {
|
||||
cellValues.add(PowerIndexEnum.UNKNOWN.getDesc().concat("测量准确度"));
|
||||
}
|
||||
// 判断是否有不合格的
|
||||
List<Boolean> totalValue = value.stream().filter(item -> !item).collect(Collectors.toList());
|
||||
String total = !totalValue.isEmpty() ? "不合格" : "合格";
|
||||
switch (docAnchorEnum) {
|
||||
case TEST_RESULT_DEV:
|
||||
cellValues.add(total);
|
||||
break;
|
||||
case TEST_RESULT_LINE:
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
cellValues.add(value.get(i) ? "合格" : "不合格");
|
||||
}
|
||||
break;
|
||||
case TEST_RESULT_DETAIL:
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
cellValues.add(value.get(i) ? "合格" : "不合格");
|
||||
}
|
||||
cellValues.add(total);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Tr tempRow = Docx4jUtil.createCustomRow(factory, cellValues, "Arial", "宋体", 21, false, centerFlag);
|
||||
table.getContent().add(tempRow);
|
||||
}
|
||||
TblPr tblPr = Docx4jUtil.getTblPr(factory);
|
||||
table.setTblPr(tblPr);
|
||||
todoInsertList.add(table);
|
||||
}
|
||||
return todoInsertList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理以回路为维度的数据项
|
||||
@@ -889,6 +1101,87 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理以回路为维度的数据项,书签占位符的方式
|
||||
*
|
||||
* @param detailModelDocument 数据项模板
|
||||
* @param devReportParam 测试报告参数
|
||||
* @param pqDevVO 被检设备
|
||||
*/
|
||||
private List<Object> dealDataLine(MainDocumentPart detailModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO, Map<String, List<Boolean>> resultMap) {
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
// 以回路维度处理数据项
|
||||
Integer devChns = pqDevVO.getDevChns();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
// 读取该计划的检测大项组装数据内容
|
||||
List<PqScriptDtlDataVO> pqScriptDtlsList = pqScriptDtlsService.getScriptDtlsDataList(devReportParam.getScriptId());
|
||||
Map<String, List<PqScriptDtlDataVO>> scriptMap = pqScriptDtlsList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptCode, LinkedHashMap::new, Collectors.toList()));
|
||||
List<Object> allContent = detailModelDocument.getContent();
|
||||
List<Docx4jUtil.HeadingContent> headingContents = Docx4jUtil.extractHeading5Contents(allContent);
|
||||
Map<String, List<Docx4jUtil.HeadingContent>> contentMap = headingContents.stream().collect(Collectors.groupingBy(Docx4jUtil.HeadingContent::getHeadingText, Collectors.toList()));
|
||||
for (int i = 0; i < devChns; i++) {
|
||||
// 回路标题
|
||||
P titleParagraph = factory.createP();
|
||||
Integer lineNo = i + 1;
|
||||
Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + lineNo, 28, true);
|
||||
todoInsertList.add(titleParagraph);
|
||||
// 依次处理大项文档内容
|
||||
Iterator<Map.Entry<String, List<PqScriptDtlDataVO>>> iterator = scriptMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<PqScriptDtlDataVO>> next = iterator.next();
|
||||
String scriptCode = next.getKey();
|
||||
List<PqScriptDtlDataVO> dtlScriptItemList = next.getValue();
|
||||
List<Docx4jUtil.HeadingContent> tempContent = contentMap.get(scriptCode);
|
||||
// 获取需要填充keys,索引0对应的段落key,索引1对应的表格key
|
||||
List<List<String>> keys = Docx4jUtil.getFillKeys(tempContent);
|
||||
// 段落keys值赋值
|
||||
List<String> pKeys = keys.get(0);
|
||||
Map<String, String> pKeyValueMap = resultService.getParagraphKeysValue(scriptCode, pKeys);
|
||||
List<String> tableKeys = keys.get(1);
|
||||
/* tableKeys值赋值,注:由于谐波类检测数据与非谐波检测类数据的区别,此处要做区分
|
||||
* 1、谐波类每个scriptIndex对应一个Excel表格
|
||||
* 2、非谐波类则是一个误差范围对应一个Excel表格
|
||||
*/
|
||||
SingleTestResult singleTestResult = null;
|
||||
// 根据code找到名称
|
||||
List<Boolean> scriptResult = resultMap.get(scriptCode);
|
||||
boolean needFill = false;
|
||||
if (CollUtil.isEmpty(scriptResult)) {
|
||||
scriptResult = new ArrayList<>();
|
||||
needFill = true;
|
||||
} else if (scriptResult.size() < lineNo) {
|
||||
needFill = true;
|
||||
}
|
||||
if (PowerConstant.TIME.contains(scriptCode)) {
|
||||
// 谐波类,以scriptIndex区分
|
||||
Map<Integer, List<PqScriptDtlDataVO>> scriptIndexMap = dtlScriptItemList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptIndex));
|
||||
for (List<PqScriptDtlDataVO> scriptDtlDataItem : scriptIndexMap.values()) {
|
||||
singleTestResult = resultService.getFinalContent(scriptDtlDataItem, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
||||
List<Object> tempList = fillContentInTemplate(singleTestResult.getDetail(), tempContent, factory, pKeyValueMap, tableKeys);
|
||||
todoInsertList.addAll(tempList);
|
||||
}
|
||||
} else {
|
||||
// 非谐波类
|
||||
singleTestResult = resultService.getFinalContent(dtlScriptItemList, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
||||
List<Object> tempList = fillContentInTemplate(singleTestResult.getDetail(), tempContent, factory, pKeyValueMap, tableKeys);
|
||||
todoInsertList.addAll(tempList);
|
||||
}
|
||||
if (Objects.nonNull(singleTestResult) && needFill) {
|
||||
singleTestResult.setScriptCode(scriptCode);
|
||||
scriptResult.add(singleTestResult.isQualified());
|
||||
resultMap.put(scriptCode, scriptResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果经过一顿处理后,结果性数据集合还是空,塞个特殊数据进去,避免嵌套循环
|
||||
if (CollUtil.isEmpty(resultMap)) {
|
||||
resultMap.put(PowerIndexEnum.UNKNOWN.getKey(), Collections.singletonList(false));
|
||||
}
|
||||
return todoInsertList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将查询的所有有效数据填充到模板中
|
||||
*/
|
||||
@@ -920,20 +1213,24 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
P paragraph = (P) object;
|
||||
// 获取该段落的样式
|
||||
RPr rPr = Docx4jUtil.getTcPrFromParagraph(paragraph);
|
||||
PPr pPr = paragraph.getPPr();
|
||||
String textFromP = Docx4jUtil.getTextFromP(paragraph);
|
||||
if (StrUtil.isNotBlank(textFromP)) {
|
||||
// 如果是段落内容,渲染段落内容
|
||||
String[] splitP = textFromP.split(StrPool.DASHED);
|
||||
String text = "";
|
||||
for (String item : splitP) {
|
||||
if (StrUtil.isNotBlank(pKeyValueMap.get(item))) {
|
||||
text = text.concat(pKeyValueMap.get(item));
|
||||
} else if (item.equalsIgnoreCase(ItemReportKeyEnum.ERROR_SCOPE.getKey())) {
|
||||
text = text.concat("(").concat("最大允许误差:").concat(key1).concat(")");
|
||||
if (textFromP.equalsIgnoreCase(ItemReportKeyEnum.SCRIPT_DETAIL.getKey())) {
|
||||
text = value1.get(0).get(ItemReportKeyEnum.SCRIPT_DETAIL.getKey());
|
||||
} else if (textFromP.startsWith(ItemReportKeyEnum.NAME.getKey())) {
|
||||
// 如果是段落内容,渲染段落内容
|
||||
String[] splitP = textFromP.split(StrPool.DASHED);
|
||||
for (String item : splitP) {
|
||||
if (StrUtil.isNotBlank(pKeyValueMap.get(item))) {
|
||||
text = text.concat(pKeyValueMap.get(item));
|
||||
} else if (item.equalsIgnoreCase(ItemReportKeyEnum.ERROR_SCOPE.getKey())) {
|
||||
text = text.concat("(").concat("最大允许误差:").concat(key1).concat(")");
|
||||
}
|
||||
}
|
||||
// 目前段落只有名称+误差范围,如果有补充后续在这里加。todo...
|
||||
}
|
||||
Docx4jUtil.addPContent(factory, innerP, text, rPr);
|
||||
Docx4jUtil.addPContent(factory, innerP, text, rPr,pPr);
|
||||
}
|
||||
//插入段落
|
||||
paragraphs.add(position++, innerP);
|
||||
@@ -972,15 +1269,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 纵向表格暂不考虑
|
||||
}
|
||||
// 插入段落,处理下样式
|
||||
|
||||
|
||||
paragraphs.add(position++, copiedTableElement);
|
||||
}
|
||||
}
|
||||
// 全部渲染完毕后,添加几个换行
|
||||
P p = factory.createP();
|
||||
Docx4jUtil.addBr(factory, p, 1);
|
||||
paragraphs.add(position++, p);
|
||||
// Docx4jUtil.addBr(factory, p, 1);
|
||||
// paragraphs.add(position++, p);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -990,6 +1285,116 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将查询的所有有效数据填充到集合中,待后续填充文档
|
||||
*/
|
||||
private List<Object> fillContentInTemplate(Map<String, List<Map<String, List<Map<String, String>>>>> finalContent, List<Docx4jUtil.HeadingContent> tempContent,
|
||||
ObjectFactory factory, Map<String, String> pKeyValueMap, List<String> tableKeys) {
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(finalContent)) {
|
||||
Iterator<Map.Entry<String, List<Map<String, List<Map<String, String>>>>>> iterator1 = finalContent.entrySet().iterator();
|
||||
while (iterator1.hasNext()) {
|
||||
Map.Entry<String, List<Map<String, List<Map<String, String>>>>> next1 = iterator1.next();
|
||||
// 此处的key是影响量的文字描述
|
||||
String key = next1.getKey();
|
||||
List<Map<String, List<Map<String, String>>>> value = next1.getValue();
|
||||
for (Map<String, List<Map<String, String>>> stringListMap : value) {
|
||||
Iterator<Map.Entry<String, List<Map<String, String>>>> iterator2 = stringListMap.entrySet().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Map.Entry<String, List<Map<String, String>>> next2 = iterator2.next();
|
||||
// 此处的key是误差范围
|
||||
String key1 = next2.getKey();
|
||||
List<Map<String, String>> value1 = next2.getValue();
|
||||
// 填充模板内容
|
||||
if (CollUtil.isNotEmpty(tempContent)) {
|
||||
// 读取该表下模板里面的内容,并动态赋值渲染文档
|
||||
Docx4jUtil.HeadingContent headingContent = tempContent.get(0);
|
||||
for (Object object : headingContent.getSubContent()) {
|
||||
// 段落
|
||||
if (object instanceof P) {
|
||||
P innerP = factory.createP();
|
||||
// 如果是段落,渲染段落内容
|
||||
P paragraph = (P) object;
|
||||
// 获取该段落的样式
|
||||
RPr rPr = Docx4jUtil.getTcPrFromParagraph(paragraph);
|
||||
PPr pPr = paragraph.getPPr();
|
||||
String textFromP = Docx4jUtil.getTextFromP(paragraph);
|
||||
if (StrUtil.isNotBlank(textFromP)) {
|
||||
String text = "";
|
||||
if (textFromP.equalsIgnoreCase(ItemReportKeyEnum.SCRIPT_DETAIL.getKey())) {
|
||||
text = value1.get(0).get(ItemReportKeyEnum.SCRIPT_DETAIL.getKey());
|
||||
System.out.println(text);
|
||||
} else if (textFromP.startsWith(ItemReportKeyEnum.NAME.getKey())) {
|
||||
// 如果是段落内容,渲染段落内容
|
||||
String[] splitP = textFromP.split(StrPool.DASHED);
|
||||
for (String item : splitP) {
|
||||
if (StrUtil.isNotBlank(pKeyValueMap.get(item))) {
|
||||
text = text.concat(pKeyValueMap.get(item));
|
||||
} else if (item.equalsIgnoreCase(ItemReportKeyEnum.ERROR_SCOPE.getKey())) {
|
||||
text = text.concat("(").concat("最大允许误差:").concat(key1).concat(")");
|
||||
}
|
||||
}
|
||||
}
|
||||
Docx4jUtil.addPContent(factory, innerP, text, rPr,pPr);
|
||||
}
|
||||
//插入段落
|
||||
todoInsertList.add(innerP);
|
||||
} else if (object instanceof JAXBElement) {
|
||||
// 表格需要注意深拷贝,避免修改了原对象
|
||||
JAXBElement<Tbl> temp = (JAXBElement<Tbl>) object;
|
||||
JAXBElement<Tbl> copiedTableElement;
|
||||
try {
|
||||
copiedTableElement = Docx4jUtil.deepCopyTbl(temp);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 解析表格并插入对应数据,最关键的是得知道表格是横向还是纵向以及表头占了几行
|
||||
Tbl tbl = copiedTableElement.getValue();
|
||||
// 获取表格的行
|
||||
List<Object> rows = tbl.getContent();
|
||||
boolean isRow = Docx4jUtil.judgeTableCross(rows.get(0));
|
||||
if (isRow) {
|
||||
// 获取现有行的样式
|
||||
Tr headerRow = (Tr) tbl.getContent().get(0);
|
||||
// 设置表头行属性
|
||||
TrPr headerTrPr = factory.createTrPr();
|
||||
headerRow.setTrPr(headerTrPr);
|
||||
|
||||
// 获取现有行的样式
|
||||
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
|
||||
// 获取现有样式
|
||||
TrPr trPr = existingRow.getTrPr();
|
||||
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
|
||||
TcPr tcPr = element.getValue().getTcPr();
|
||||
TblWidth cellWidth = factory.createTblWidth();
|
||||
cellWidth.setType("dxa");
|
||||
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
|
||||
tcPr.setTcW(cellWidth);
|
||||
tbl.getContent().remove(existingRow);
|
||||
// 迭代增加行,需要填充的表格keys在tableKeys集合中
|
||||
for (Map<String, String> stringStringMap : value1) {
|
||||
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPr, true);
|
||||
tbl.getContent().add(newRow);
|
||||
}
|
||||
} else {
|
||||
// 纵向表格暂不考虑
|
||||
}
|
||||
// 插入段落,处理下样式
|
||||
todoInsertList.add(copiedTableElement);
|
||||
}
|
||||
}
|
||||
// 全部渲染完毕后,添加几个换行
|
||||
// P p = factory.createP();
|
||||
// Docx4jUtil.addBr(factory, p, 1);
|
||||
// todoInsertList.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return todoInsertList;
|
||||
}
|
||||
|
||||
|
||||
private void updateDevAndPlanState(String devId, String planId) {
|
||||
// 将改设备的报告生成状态调整为已生成
|
||||
@@ -1018,8 +1423,15 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
throw new BusinessException("设备类型丢失,请联系管理员!");
|
||||
}
|
||||
// 找到该文件的路径
|
||||
String filePath = reportPath.concat(File.separator).concat(devType.getName()).concat(File.separator).concat(pqDevVO.getCreateId()).concat(".docx");
|
||||
File reportFile = new File(filePath);
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
|
||||
StringBuilder filePath = new StringBuilder(reportPath.concat(File.separator));
|
||||
if (SceneEnum.LEAVE_FACTORY_TEST.getValue().equals(currrentScene)) {
|
||||
filePath.append(pqDevVO.getCreateId()).append(".docx");
|
||||
} else {
|
||||
filePath.append(devType.getName()).append(File.separator).append(pqDevVO.getCreateId()).append(".docx");
|
||||
}
|
||||
File reportFile = new File(filePath.toString());
|
||||
if (!reportFile.exists()) {
|
||||
// 如果文件不存在,则将改设备的报告生成状态调整为未生成
|
||||
iPqDevService.updatePqDevReportState(devReportParam.getDevId(), 0);
|
||||
@@ -1049,6 +1461,55 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean documented(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
List<String> devIds = new ArrayList<>();
|
||||
PqDev tempPqDev = null;
|
||||
for (String id : ids) {
|
||||
// 只有检测完成的设备才可以进行归档
|
||||
PqDev pqDev = iPqDevService.getById(id);
|
||||
if (ObjectUtil.isNotNull(pqDev)) {
|
||||
// 只有检测完成、且已生成报告的设备才可以进行归档
|
||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||
devIds.add(id);
|
||||
tempPqDev = pqDev;
|
||||
}
|
||||
boolean update = iPqDevService.lambdaUpdate()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
|
||||
.eq(PqDev::getId, id)
|
||||
.update();
|
||||
if (update) {
|
||||
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
|
||||
// 查询该计划下所有设备的检测状态,是否有不为归档的
|
||||
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
|
||||
int count = iPqDevService.count(queryWrapper);
|
||||
if (count == 0) {
|
||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||
pqDevMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(devIds)) {
|
||||
DevReportParam devReportParam = new DevReportParam();
|
||||
devReportParam.setDevIdList(devIds);
|
||||
devReportParam.setPlanId(tempPqDev.getPlanId());
|
||||
AdPlan plan = adPlanService.getById(tempPqDev.getPlanId());
|
||||
devReportParam.setScriptId(plan.getScriptId());
|
||||
devReportParam.setPlanCode(String.valueOf(plan.getCode()));
|
||||
this.generateReport(devReportParam);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理基础模版中的信息,非数据页报告
|
||||
@@ -1084,12 +1545,32 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
} else {
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.MANUFACTURER.getKey() + suffix, StrPool.TAB);
|
||||
}
|
||||
// 委托方
|
||||
String delegate = pqDevVO.getDelegate();
|
||||
if(StrUtil.isNotBlank(delegate)){
|
||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(delegateDictData)) {
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, dictData.getName());
|
||||
} else {
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, StrPool.TAB);
|
||||
}
|
||||
}else{
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.DELEGATE.getKey() + suffix, StrPool.TAB);
|
||||
}
|
||||
|
||||
// 实验室温度
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.TEMPERATURE.getKey() + suffix, Objects.isNull(pqDevVO.getTemperature()) ? StrPool.TAB : pqDevVO.getTemperature().toString());
|
||||
// 实验室湿度
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.TEMPERATURE.getKey() + suffix, Objects.isNull(pqDevVO.getTemperature()) ? StrPool.TAB : pqDevVO.getTemperature().toString());
|
||||
|
||||
// 样品编号
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.SAMPLE_ID.getKey() + suffix, StrUtil.isEmpty(pqDevVO.getSampleId()) ? StrPool.TAB : pqDevVO.getSampleId());
|
||||
// 收样日期
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.ARRIVED_DATE.getKey() + suffix, Objects.isNull(pqDevVO.getArrivedDate()) ? StrPool.TAB : String.valueOf(pqDevVO.getArrivedDate()));
|
||||
// 检测日期
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.TEST_DATE.getKey() + suffix, Objects.isNull(pqDevVO.getCheckTime()) ? StrPool.TAB : String.valueOf(pqDevVO.getCheckTime()).substring(0, 10));
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.TEMPERATURE.getKey() + suffix, Objects.isNull(pqDevVO.getTemperature()) ? StrPool.TAB : pqDevVO.getTemperature().toString());
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.HUMIDITY.getKey() + suffix, Objects.isNull(pqDevVO.getHumidity()) ? StrPool.TAB : pqDevVO.getHumidity().toString());
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.YEAR.getKey() + suffix, DateUtil.format(new Date(), DatePattern.NORM_YEAR_PATTERN));
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.MONTH.getKey() + suffix, DateUtil.format(new Date(), DatePattern.SIMPLE_MONTH_PATTERN).substring(4));
|
||||
baseModelMap.put(prefix + BaseReportKeyEnum.DAY.getKey() + suffix, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN).substring(6));
|
||||
@@ -1983,32 +2464,6 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String path = "F:\\gitea\\fusionForce\\CN_Gather\\entrance\\src\\main\\resources\\model\\BaseDataModel.docx";
|
||||
FileInputStream dataModelFis = new FileInputStream(new File(path));
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(dataModelFis);
|
||||
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||
dataModelMap.put("${CreateId}", "123");
|
||||
dataModelMap.put("${total}", "123");
|
||||
dataModelMap.put("${count}", "1");
|
||||
dataModelMap.put("${57Ua}", "123456");
|
||||
dataModelMap.put("${Uha1}", "123456");
|
||||
dataModelMap.put("${Uha2}", "123456");
|
||||
WordUtil.replacePlaceholdersInParagraphs(dataModelDocumentTemp, dataModelMap);
|
||||
WordUtil.replacePlaceholdersInTables(dataModelDocumentTemp, dataModelMap);
|
||||
//最终文件输出的路径
|
||||
FileOutputStream out = new FileOutputStream("C:\\Users\\hongawen\\Desktop\\testModel\\BaseDataModel" + DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_PATTERN) + ".docx");
|
||||
// 4. 保存新的Word文档
|
||||
try {
|
||||
dataModelDocumentTemp.write(out);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException("生成报告文件失败");
|
||||
}
|
||||
out.close();
|
||||
System.out.println("报告生成成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试小项的index
|
||||
* 注:测试项下发的ABCT的index均是一样的
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
package com.njcn.gather.report.utils;
|
||||
|
||||
|
||||
import com.njcn.gather.report.pojo.enums.BookmarkEnum;
|
||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 递归查找所有书签,并在书签处插入内容
|
||||
*/
|
||||
public class BookmarkUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 书签信息
|
||||
*/
|
||||
public static class BookmarkInfo {
|
||||
public CTBookmark bookmark;
|
||||
public P parentParagraph;
|
||||
public ContentAccessor parentContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查找所有书签
|
||||
*/
|
||||
public static List<BookmarkInfo> findAllBookmarks(ContentAccessor contentAccessor) {
|
||||
List<BookmarkInfo> result = new ArrayList<>();
|
||||
for (Object obj : contentAccessor.getContent()) {
|
||||
Object realObj = (obj instanceof JAXBElement) ? ((JAXBElement<?>) obj).getValue() : obj;
|
||||
if (realObj instanceof P) {
|
||||
P p = (P) realObj;
|
||||
for (Object o2 : p.getContent()) {
|
||||
Object realO2 = (o2 instanceof JAXBElement) ? ((JAXBElement<?>) o2).getValue() : o2;
|
||||
if (realO2 instanceof CTBookmark) {
|
||||
BookmarkInfo info = new BookmarkInfo();
|
||||
info.bookmark = (CTBookmark) realO2;
|
||||
info.parentParagraph = p;
|
||||
info.parentContainer = contentAccessor;
|
||||
result.add(info);
|
||||
}
|
||||
}
|
||||
} else if (realObj instanceof ContentAccessor) {
|
||||
result.addAll(findAllBookmarks((ContentAccessor) realObj));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在书签后插入段落
|
||||
*/
|
||||
public static void insertParagraphsAfter(BookmarkInfo info, P paragraph) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
parentContent.add(idx + 1, paragraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在书签后插入表格
|
||||
*/
|
||||
public static void insertTableAfter(BookmarkInfo info, Tbl table) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
parentContent.add(idx + 1, table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在书签后插入元素,可能是段落、表格、图片、书签等
|
||||
*/
|
||||
public static void insertElement(BookmarkInfo info, List<Object> elements) {
|
||||
List<Object> parentContent = info.parentContainer.getContent();
|
||||
int idx = parentContent.indexOf(info.parentParagraph);
|
||||
// 遍历元素,如果是通道回路这种大标题需要新起一个空的文档页
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
Object element = elements.get(i);
|
||||
if (element instanceof P) {
|
||||
P p = (P) element;
|
||||
String textFromP = Docx4jUtil.getTextFromP(p);
|
||||
if (textFromP.contains("测量回路")) {
|
||||
if (!textFromP.contains("1")) {
|
||||
// 另起一页
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
}
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, p);
|
||||
} else if (textFromP.startsWith(PowerIndexEnum.IMBV.getDesc())
|
||||
|| textFromP.startsWith(PowerIndexEnum.HV.getDesc())
|
||||
|| textFromP.startsWith(PowerIndexEnum.HI.getDesc())
|
||||
|
||||
) {
|
||||
// 另起一页
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}else if(textFromP.startsWith("注:基波电流幅值5.000A,基波频率50.0Hz,各次间谐波电流含有率均为3.0%。")){
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
P pagePara = Docx4jUtil.getPageBreak();
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, pagePara);
|
||||
} else {
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}
|
||||
} else {
|
||||
idx = idx + 1;
|
||||
parentContent.add(idx, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档中的空白页
|
||||
* @param docx 要处理的Word文档
|
||||
*/
|
||||
public static void removeBlankPages(MainDocumentPart mainDocumentPart) {
|
||||
// 获取文档主体
|
||||
Document document = mainDocumentPart.getJaxbElement();
|
||||
Body body = document.getBody();
|
||||
|
||||
// 获取所有段落
|
||||
List<Object> paragraphs = body.getContent();
|
||||
|
||||
// 用于标记是否在空白页中
|
||||
boolean inBlankPage = false;
|
||||
// 用于存储要删除的段落
|
||||
List<P> paragraphsToRemove = new ArrayList<>();
|
||||
|
||||
for (Object paragraph : paragraphs) {
|
||||
if (paragraph instanceof P){
|
||||
P paragraphtemp = (P) paragraph;
|
||||
// 检查段落是否为空
|
||||
boolean isEmpty = isParagraphEmpty(paragraphtemp);
|
||||
|
||||
if (isEmpty) {
|
||||
if (!inBlankPage) {
|
||||
inBlankPage = true;
|
||||
}
|
||||
paragraphsToRemove.add(paragraphtemp);
|
||||
} else {
|
||||
inBlankPage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除空白段落
|
||||
for (P paragraph : paragraphsToRemove) {
|
||||
body.getContent().remove(paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查段落是否为空
|
||||
* @param paragraph 要检查的段落
|
||||
* @return 如果段落为空返回true,否则返回false
|
||||
*/
|
||||
private static boolean isParagraphEmpty(P paragraph) {
|
||||
// 检查段落是否包含分节符
|
||||
if (paragraph.getPPr() != null && paragraph.getPPr().getSectPr() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查段落中的文本内容
|
||||
for (Object obj : paragraph.getContent()) {
|
||||
if (obj instanceof R) {
|
||||
R run = (R) obj;
|
||||
// 在3.3.4版本中,使用getContent()获取文本内容
|
||||
for (Object runContent : run.getContent()) {
|
||||
if (runContent instanceof Text) {
|
||||
Text text = (Text) runContent;
|
||||
if (text.getValue() != null && !text.getValue().trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在插入前检查目标位置是否有分页符
|
||||
*
|
||||
* @param position 目标位置
|
||||
* @return 是否包含分页符
|
||||
*/
|
||||
private static boolean hasPageBreak(Object position) {
|
||||
if (position instanceof P) {
|
||||
P paragraph = (P) position;
|
||||
for (Object run : paragraph.getContent()) {
|
||||
if (run instanceof R) {
|
||||
R r = (R) run;
|
||||
for (Object element : r.getContent()) {
|
||||
if (element instanceof Br && ((Br) element).getType() != null
|
||||
&& ((Br) element).getType().equals("page")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除书签
|
||||
*
|
||||
* @param bookmarkInfo 书签信息
|
||||
*/
|
||||
public static void removeBookmark(BookmarkUtil.BookmarkInfo bookmarkInfo) {
|
||||
try {
|
||||
// 获取书签所在的段落
|
||||
P paragraph = bookmarkInfo.parentParagraph;
|
||||
|
||||
// 遍历段落内容,找到并删除书签开始和结束标记
|
||||
List<Object> paragraphContent = new ArrayList<>(paragraph.getContent());
|
||||
for (Object obj : paragraphContent) {
|
||||
if (obj instanceof JAXBElement) {
|
||||
JAXBElement<?> element = (JAXBElement<?>) obj;
|
||||
Object value = element.getValue();
|
||||
|
||||
// 删除书签开始标记
|
||||
if (value instanceof CTBookmark) {
|
||||
paragraph.getContent().remove(obj);
|
||||
}
|
||||
// 删除书签结束标记
|
||||
else if (value instanceof CTMarkupRange) {
|
||||
paragraph.getContent().remove(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 ObjectFactory 创建表格
|
||||
*
|
||||
* @param factory ObjectFactory 实例
|
||||
* @param data 二维数组,表格内容
|
||||
* @return Tbl 表格对象
|
||||
*/
|
||||
public static Tbl createTable(ObjectFactory factory, String[][] data) {
|
||||
Tbl table = factory.createTbl();
|
||||
for (String[] rowData : data) {
|
||||
Tr row = factory.createTr();
|
||||
for (String cellData : rowData) {
|
||||
Tc cell = factory.createTc();
|
||||
P para = factory.createP();
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(cellData);
|
||||
run.getContent().add(text);
|
||||
para.getContent().add(run);
|
||||
cell.getContent().add(para);
|
||||
row.getContent().add(cell);
|
||||
}
|
||||
table.getContent().add(row);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定标签的标签信息
|
||||
*
|
||||
* @param key 标签名
|
||||
* @param bookmarks 所有标签信息
|
||||
*/
|
||||
public static BookmarkInfo getBookmarkInfo(String key, List<BookmarkInfo> bookmarks) {
|
||||
BookmarkUtil.BookmarkInfo bookmarkInfo = null;
|
||||
for (BookmarkUtil.BookmarkInfo info : bookmarks) {
|
||||
String name = info.bookmark.getName();
|
||||
if (key.equalsIgnoreCase(name)) {
|
||||
bookmarkInfo = info;
|
||||
}
|
||||
}
|
||||
return bookmarkInfo;
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,12 @@ import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.gather.report.pojo.constant.ReportConstant;
|
||||
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
|
||||
import com.njcn.gather.report.pojo.vo.Bookmark;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.*;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -244,13 +237,14 @@ public class Docx4jUtil {
|
||||
/**
|
||||
* 段落中添加内容
|
||||
*/
|
||||
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr) {
|
||||
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr,PPr ppr) {
|
||||
R run = factory.createR();
|
||||
Text text = factory.createText();
|
||||
text.setValue(content);
|
||||
run.setRPr(rPr);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
paragraph.setPPr(ppr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,6 +341,20 @@ public class Docx4jUtil {
|
||||
text.setValue(value);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
// 字体
|
||||
// 设置字体
|
||||
RPr rPr = factory.createRPr();
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
if (containsChinese(value)) {
|
||||
rFonts.setEastAsia("宋体");
|
||||
rFonts.setAscii("宋体");
|
||||
rFonts.setHAnsi("宋体");
|
||||
} else {
|
||||
rFonts.setEastAsia("Arial");
|
||||
rFonts.setAscii("Arial");
|
||||
rFonts.setHAnsi("Arial");
|
||||
}
|
||||
rPr.setRFonts(rFonts);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
@@ -356,13 +364,17 @@ public class Docx4jUtil {
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
if (value.equals("不合格")) {
|
||||
RPr rPr = factory.createRPr();
|
||||
Color color = factory.createColor();
|
||||
// 红色
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
run.setRPr(rPr);
|
||||
}
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
// 10号字体 = 20 half-points
|
||||
sz.setVal(new BigInteger("20"));
|
||||
rPr.setSz(sz);
|
||||
|
||||
cell.getContent().add(paragraph);
|
||||
cell.setTcPr(tcPr);
|
||||
row.getContent().add(cell);
|
||||
@@ -372,20 +384,39 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断字符串是否包含中文
|
||||
* @param str 需要判断的字符串
|
||||
* @return 是否包含中文
|
||||
*/
|
||||
private static boolean containsChinese(String str) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
for (char c : str.toCharArray()) {
|
||||
if (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param cellValues 数据
|
||||
* @param factory 工厂
|
||||
* @param cellValues 数据
|
||||
* @param ascFontStyle 西文字体
|
||||
* @param eastFontStyle 中文字体
|
||||
* @param size 字体大小
|
||||
* @param boldFlag 是否加粗
|
||||
* @param centerFlag 是否居中
|
||||
* @param eastFontStyle 中文字体
|
||||
* @param size 字体大小
|
||||
* @param boldFlag 是否加粗
|
||||
* @param centerFlag 是否居中
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle,String eastFontStyle, Integer size, boolean boldFlag, boolean centerFlag) {
|
||||
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle, String eastFontStyle, Integer size, boolean boldFlag, List<Integer> centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (String value : cellValues) {
|
||||
for (int i = 0; i < cellValues.size(); i++) {
|
||||
String value = cellValues.get(i);
|
||||
Tc cell = factory.createTc();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
@@ -394,7 +425,7 @@ public class Docx4jUtil {
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
if (!centerFlag.contains(i)) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
@@ -408,7 +439,7 @@ public class Docx4jUtil {
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
}
|
||||
if(boldFlag){
|
||||
if (boldFlag) {
|
||||
BooleanDefaultTrue bold = factory.createBooleanDefaultTrue();
|
||||
rPr.setB(bold);
|
||||
}
|
||||
@@ -425,9 +456,20 @@ public class Docx4jUtil {
|
||||
rPr.setSz(fontSize);
|
||||
// 中文字号
|
||||
rPr.setSzCs(fontSize);
|
||||
|
||||
run.setRPr(rPr);
|
||||
cell.getContent().add(paragraph);
|
||||
// 设置单元格边距
|
||||
TcPr cellProperties = factory.createTcPr();
|
||||
cell.setTcPr(cellProperties);
|
||||
// 设置单元格上下边距(单位:缇)
|
||||
TcMar mar = factory.createTcMar();
|
||||
TblWidth top = factory.createTblWidth();
|
||||
top.setW(BigInteger.valueOf(100));
|
||||
mar.setTop(top);
|
||||
TblWidth bottom = factory.createTblWidth();
|
||||
bottom.setW(BigInteger.valueOf(100));
|
||||
mar.setBottom(bottom);
|
||||
cellProperties.setTcMar(mar);
|
||||
row.getContent().add(cell);
|
||||
}
|
||||
return row;
|
||||
@@ -448,7 +490,6 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 存储Heading 5及其子内容的辅助类
|
||||
public static class HeadingContent {
|
||||
private String headingText;
|
||||
@@ -471,6 +512,38 @@ public class Docx4jUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定书签在文档段落中的位置索引
|
||||
*
|
||||
* @param documentPart 主文档部分
|
||||
* @param bookmarkName 书签名称
|
||||
* @return 段落索引,找不到返回 -1
|
||||
*/
|
||||
public static int getParagraphPosition(MainDocumentPart documentPart, String bookmarkName) {
|
||||
List<Object> content = documentPart.getContent();
|
||||
for (int i = 0; i < content.size(); i++) {
|
||||
Object obj = content.get(i);
|
||||
// 只处理段落
|
||||
if (obj instanceof P) {
|
||||
P paragraph = (P) obj;
|
||||
// 提取段落纯文本
|
||||
String text = getTextFromP(paragraph).trim();
|
||||
if (text.startsWith("#{") && text.endsWith("}")) {
|
||||
// 提取书签名
|
||||
String name = text.substring(2, text.length() - 1);
|
||||
if (name.equals(bookmarkName)) {
|
||||
// 返回段落索引
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 找不到返回 -1
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取段落在文档中的位置
|
||||
*/
|
||||
@@ -534,4 +607,27 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分页符
|
||||
*/
|
||||
public static P getPageBreak() {
|
||||
try {
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
// 创建分页符
|
||||
R run = factory.createR();
|
||||
Br br = factory.createBr();
|
||||
br.setType(STBrType.PAGE);
|
||||
// 直接添加 br 对象
|
||||
run.getContent().add(br);
|
||||
// 创建包含分页符的段落
|
||||
P pageBreakParagraph = factory.createP();
|
||||
pageBreakParagraph.getContent().add(run);
|
||||
return pageBreakParagraph;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
@@ -53,10 +54,11 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -80,7 +82,6 @@ import java.util.stream.Collectors;
|
||||
public class ResultServiceImpl implements IResultService {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final AdNonHarmonicService adNonHarmonicService;
|
||||
private final AdHarmonicService adHarmonicService;
|
||||
@@ -90,6 +91,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final TableGenMapper tableGenMapper;
|
||||
private final DetectionServiceImpl detectionServiceImpl;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
private final IPqDevService iPqDevService;
|
||||
|
||||
/**
|
||||
* 谐波类code,取树形字典表中的code
|
||||
@@ -108,7 +112,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
adPlanService.visualize(Collections.singletonList(plan));
|
||||
}
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
|
||||
|
||||
List<Map<String, String>> chnList = new ArrayList<>();
|
||||
@@ -967,7 +971,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 暂态的valueType通常只有2个,一个特征幅值,一个持续时间
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (Integer sort : indexList) {
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
@@ -992,7 +996,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 查询结果数据,经过上层处理谐波类此处的scriptIndex确保只有一个
|
||||
if (indexList.size() == 1) {
|
||||
// 获取谐波数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueType, indexList.get(0));
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(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));
|
||||
@@ -1013,10 +1017,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
double timeDouble = Math.round(harmNum);
|
||||
int timeInt = (int) timeDouble;
|
||||
// 填充结果数据
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 按次数排序
|
||||
@@ -1037,16 +1039,14 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 非谐波的需要区分是否为ABC相还是T相
|
||||
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
||||
// 获取该三相的数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(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);
|
||||
}
|
||||
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 需要对所有的填充进行按误差范围分组
|
||||
@@ -1067,15 +1067,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
} else {
|
||||
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(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);
|
||||
}
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
@@ -1118,7 +1116,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param timeInt 谐波类需要传指定次数
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
*/
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap, String scriptCode) {
|
||||
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
||||
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
||||
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
||||
@@ -1127,50 +1125,64 @@ public class ResultServiceImpl implements IResultService {
|
||||
testA = "/", testB = "/", testC = "/",
|
||||
errorA = "/", errorB = "/", errorC = "/",
|
||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
||||
errorScope = "/", unit = "";
|
||||
errorScope = "/", unit = "", scriptDetail = "/";
|
||||
|
||||
if (Objects.nonNull(tempA) && (PowerConstant.DATA_RANGE.contains(tempA.getIsData()))) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : "不合格";
|
||||
errorScope = tempA.getRadius();
|
||||
unit = tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
if (Objects.nonNull(tempA)) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
if (Objects.nonNull(tempA.getErrorData())) {
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
}
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : tempA.getIsData() == 0 ? "不合格" : "/";
|
||||
errorScope = tempA.getRadius() == null ? "/" : tempA.getRadius();
|
||||
unit = tempA.getUnit() == null ? "" : tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempB) && (PowerConstant.DATA_RANGE.contains(tempB.getIsData()))) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempB)) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
if (Objects.nonNull(tempB.getErrorData())) {
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
}
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : tempB.getIsData() == 0 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempB.getRadius();
|
||||
errorScope = tempB.getRadius() == null ? "/" : tempB.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempB.getUnit();
|
||||
unit = tempB.getUnit() == null ? "" : tempB.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(tempC) && (PowerConstant.DATA_RANGE.contains(tempC.getIsData()))) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempC)) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
if (Objects.nonNull(tempC.getErrorData())) {
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
}
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : tempC.getIsData() == 0 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempC.getRadius();
|
||||
errorScope = tempC.getRadius() == null ? "/" : tempC.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempC.getUnit();
|
||||
unit = tempC.getUnit() == null ? "" : tempC.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
}
|
||||
}
|
||||
if (scriptCode.equalsIgnoreCase("I")) {
|
||||
resultA = "/";
|
||||
resultB = "/";
|
||||
resultC = "/";
|
||||
}
|
||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
||||
standard = standardA;
|
||||
}
|
||||
// 处理脚本输出
|
||||
scriptDetail = dealScriptDetail(scriptCode, standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.SCRIPT_DETAIL.getKey(), scriptDetail);
|
||||
// 标准值
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
||||
@@ -1198,6 +1210,45 @@ public class ResultServiceImpl implements IResultService {
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对浙江杭州处理脚本输出细节,todo... 需要更改更合理的方式,现在算是写死的了部分
|
||||
* 目前浙江这边就是(间)谐波电压/电流
|
||||
*/
|
||||
private String dealScriptDetail(String scriptCode, String standard) {
|
||||
String scriptDetail = "";
|
||||
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(scriptCode);
|
||||
if (powerIndexEnum != null) {
|
||||
switch (powerIndexEnum) {
|
||||
case HV:
|
||||
case HSV:
|
||||
// 注:基波电压幅值57.74V,基波频率50.0Hz。
|
||||
scriptDetail = "注:基波电压幅值57.74V,基波频率50.0Hz。";
|
||||
break;
|
||||
case HI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
case HSI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次间谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return scriptDetail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* T相的相关数据处理,非暂态数据
|
||||
@@ -1210,13 +1261,15 @@ public class ResultServiceImpl implements IResultService {
|
||||
private void fillTPhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/", unit = "";
|
||||
DetectionData tempT = getResultData(singleResult, timeInt, PowerConstant.PHASE_T);
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
result = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unit = tempT.getUnit();
|
||||
errorScope = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
result = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 0 ? "不合格" : "/";
|
||||
unit = tempT.getUnit() == null ? "" : tempT.getUnit();
|
||||
errorScope = tempT.getRadius() == null ? "/" : tempT.getRadius();
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
||||
@@ -1247,11 +1300,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
DictTree temp = dictTreeService.getById(adType);
|
||||
if (temp.getCode().equalsIgnoreCase("MAG")) {
|
||||
// 特征幅值
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 0 ? "不合格" : "/";
|
||||
unitMag = tempT.getUnit();
|
||||
errorScopeMag = tempT.getRadius();
|
||||
}
|
||||
@@ -1269,12 +1324,24 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
}
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unitDur = tempT.getUnit();
|
||||
errorScopeDur = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT.getResultData())) {
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getData())) {
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getIsData())) {
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getUnit())) {
|
||||
unitDur = tempT.getUnit();
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getRadius())) {
|
||||
errorScopeDur = tempT.getRadius();
|
||||
}
|
||||
if (timeUnit.equalsIgnoreCase("ms")) {
|
||||
// 如果是ms,上述的一些数据需要重新处理
|
||||
if (!standardDur.equalsIgnoreCase("/")) {
|
||||
@@ -1510,12 +1577,19 @@ public class ResultServiceImpl implements IResultService {
|
||||
// PqDev dev = pqDevService.getById(devId);
|
||||
devIdMapComm.put(devId, devId);
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
DictDataEnum dataRule;
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
// SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
// if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
// dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
// } else {
|
||||
// dataRule = DictDataEnum.SECTION_VALUE;
|
||||
// }
|
||||
AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
@@ -1553,6 +1627,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
});
|
||||
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(scriptId);
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), null, param.getTemperature(), param.getHumidity());
|
||||
}
|
||||
|
||||
private List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
|
||||
|
||||
@@ -20,7 +20,9 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -34,14 +36,14 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
|
||||
|
||||
private final String SYMBOL="$";
|
||||
private final String SYMBOL = "$";
|
||||
|
||||
private final DictTreeMapper dictTreeMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getValueType(PqScriptCheckDataParam param) {
|
||||
String dataType = param.getDataType();
|
||||
if(StrUtil.isNotBlank(dataType)){
|
||||
if (StrUtil.isNotBlank(dataType)) {
|
||||
String[] split = dataType.split(",");
|
||||
if (split.length > 1) {
|
||||
dataType = split[0];
|
||||
@@ -60,7 +62,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
|
||||
if (param.getIsValueTypeName()) {
|
||||
final String finalDataType = dataType;
|
||||
List<String> checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList());
|
||||
String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode();
|
||||
String U = finalDataType + SYMBOL + DetectionCodeEnum.U1.getCode();
|
||||
if (!checkData.contains(U)) {
|
||||
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) {
|
||||
checkData.add(U);
|
||||
|
||||
@@ -205,10 +205,10 @@ 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())){
|
||||
if (DicDataEnum.F.getCode().equals(issue.getType()) || DicDataEnum.VOLTAGE.getCode().equals(issue.getType())) {
|
||||
checkDataParam.setDataType("avg");
|
||||
issue.setDataType("avg");
|
||||
}else {
|
||||
} else {
|
||||
checkDataParam.setDataType(dataType);
|
||||
issue.setDataType(dataType);
|
||||
}
|
||||
@@ -641,7 +641,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
return this.update(new LambdaUpdateWrapper<PqScriptDtls>()
|
||||
.set(PqScriptDtls::getEnable, param.getEnable())
|
||||
.eq(PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptDtls::getScriptIndex, param.getIndex())
|
||||
.eq(ObjectUtil.isNotNull(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
@Override
|
||||
@Transactional
|
||||
public String addPqScript(PqScriptParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, false);
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
@@ -73,6 +74,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
this.checkRepeat(param, true);
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqSource(String patternId) {
|
||||
List<PqSource> pqSourceList = this.lambdaQuery().eq(PqSource::getPattern, patternId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<PqSource> pqSourceList = this.lambdaQuery().eq(PqSource::getPattern, patternId).orderByAsc(PqSource::getCreateTime).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqSourceList.stream().map(pqSource -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqSource.getId());
|
||||
|
||||
@@ -73,6 +73,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addDevType(DevTypeParam addParam) {
|
||||
addParam.setName(addParam.getName().trim());
|
||||
this.checkRepeat(addParam, false);
|
||||
DevType devType = new DevType();
|
||||
BeanUtil.copyProperties(addParam, devType);
|
||||
@@ -83,6 +84,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateDevType(DevTypeParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
this.checkRepeat(updateParam, true);
|
||||
DevType devType = new DevType();
|
||||
BeanUtil.copyProperties(updateParam, devType);
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs91003?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
username: root
|
||||
password: njcnpqs
|
||||
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
|
||||
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.
@@ -52,32 +52,32 @@ 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);
|
||||
public SingleNonHarmParam(String planCode, String devId, Integer channelNo, String adType, Integer sort) {
|
||||
this.planCode = 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);
|
||||
public SingleNonHarmParam(String planCode, String devId, Integer channelNo, String adType, List<Integer> sortList) {
|
||||
this.planCode = 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);
|
||||
public SingleNonHarmParam(String planCode, String devId, Integer channelNo, List<String> valueTypeList, Integer sort) {
|
||||
this.planCode = 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);
|
||||
public SingleNonHarmParam(String planCode, String devId, Integer channelNo, List<String> valueTypeList, List<Integer> sortList) {
|
||||
this.planCode = planCode;
|
||||
this.devId = devId;
|
||||
this.channelNo = channelNo;
|
||||
this.valueTypeList = valueTypeList;
|
||||
|
||||
@@ -48,10 +48,9 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
||||
* 获取索引
|
||||
*
|
||||
* @param param
|
||||
* @param isExculdePhaseAngle 是否排除电压相角、电流相角
|
||||
* @return
|
||||
*/
|
||||
List<Integer> getIndex(StorageParam param, Boolean isExculdePhaseAngle);
|
||||
List<Integer> getIndex(StorageParam param);
|
||||
|
||||
AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
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);
|
||||
adMap.forEach((ad,value)->{
|
||||
adMap.forEach((ad, value) -> {
|
||||
if (dictTreeByName.containsKey(ad)) {
|
||||
DictTree dictData = dictTreeByName.get(ad);
|
||||
List<RawDataVO> rawDataVOS = new ArrayList<>();
|
||||
@@ -147,7 +147,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
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)->{
|
||||
adMap.forEach((ad, value) -> {
|
||||
if (dictTreeByName.containsKey(ad)) {
|
||||
DictTree dictData = dictTreeByName.get(ad);
|
||||
List<RawResultDataVO> rawDataVOS = new ArrayList<>();
|
||||
@@ -201,29 +201,28 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getIndex(StorageParam param, Boolean isExculdePhaseAngle) {
|
||||
public List<Integer> getIndex(StorageParam param) {
|
||||
String prefix = "ad_harmonic_result_";
|
||||
String prefixNon = "ad_non_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
LambdaQueryWrapper<AdHarmonicResult> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(AdHarmonicResult::getSort)
|
||||
.likeRight(StrUtil.isNotBlank(param.getDevId()), AdHarmonicResult::getMonitorId, param.getDevId())
|
||||
.ne(AdHarmonicResult::getResultFlag, 1)
|
||||
.ne(AdHarmonicResult::getResultFlag, 5)
|
||||
.eq(AdHarmonicResult::getScriptId, param.getScriptId());
|
||||
List<AdHarmonicResult> adHarmonicResultList = this.list(lambdaQueryWrapper);
|
||||
List<Integer> indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).collect(Collectors.toList()));
|
||||
List<Integer> indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).distinct().collect(Collectors.toList()));
|
||||
|
||||
DynamicTableNameHandler.setTableName(prefixNon + param.getCode());
|
||||
LambdaQueryWrapper<AdNonHarmonicResult> resultLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
resultLambdaQueryWrapper.select(AdNonHarmonicResult::getSort)
|
||||
.likeRight(StrUtil.isNotBlank(param.getDevId()), AdNonHarmonicResult::getMonitorId, param.getDevId())
|
||||
.ne(AdNonHarmonicResult::getResultFlag, 1)
|
||||
.ne(AdNonHarmonicResult::getResultFlag, 5)
|
||||
.eq(AdNonHarmonicResult::getScriptId, param.getScriptId());
|
||||
;
|
||||
if (isExculdePhaseAngle) {
|
||||
List<String> phaseAngleIds = dictTreeMapper.getPhaseAngleIds();
|
||||
resultLambdaQueryWrapper.notIn(AdNonHarmonicResult::getAdType, phaseAngleIds);
|
||||
}
|
||||
List<AdNonHarmonicResult> nonHarmonicResults = adNonHarmonicMapper.selectList(resultLambdaQueryWrapper);
|
||||
indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).collect(Collectors.toList()));
|
||||
indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).distinct().collect(Collectors.toList()));
|
||||
DynamicTableNameHandler.remove();
|
||||
return indexes;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
* 暂态-电压幅值
|
||||
*/
|
||||
case "MAG":
|
||||
unit = "V";
|
||||
unit = "%";
|
||||
break;
|
||||
/**
|
||||
* 暂态-持续时间
|
||||
|
||||
@@ -36,9 +36,9 @@ public class SysTestConfigController extends BaseController {
|
||||
@GetMapping("/getConfig")
|
||||
@ApiOperation("获取检测相关配置信息")
|
||||
public HttpResult<SysTestConfig> getConfig() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
String methodDescribe = getMethodDescribe("getConfig");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
SysTestConfig sysTestConfig = sysTestConfigService.getConfig();
|
||||
SysTestConfig sysTestConfig = sysTestConfigService.getOneConfig();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sysTestConfig, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ public class SysTestConfigParam {
|
||||
@NotNull(message = SystemValidMessage.MAX_RECHECK_NOT_NULL)
|
||||
private Integer maxTime;
|
||||
|
||||
@ApiModelProperty(value = "数据处理规则")
|
||||
@NotBlank(message = SystemValidMessage.DATA_RULE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DATA_RULE_FORMAT_ERROR)
|
||||
private String dataRule;
|
||||
// @ApiModelProperty(value = "数据处理规则")
|
||||
// @NotBlank(message = SystemValidMessage.DATA_RULE_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DATA_RULE_FORMAT_ERROR)
|
||||
// private String dataRule;
|
||||
|
||||
@Data
|
||||
public static class UpdateParam extends SysTestConfigParam {
|
||||
|
||||
@@ -37,8 +37,8 @@ public class SysTestConfig extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 数据处理规则, 关联字典(所有值、部分值、cp95值、平均值、任意值),默认任意值
|
||||
*/
|
||||
@TableField("Data_Rule")
|
||||
private String dataRule;
|
||||
// @TableField("Data_Rule")
|
||||
// private String dataRule;
|
||||
|
||||
/**
|
||||
* 业务场景
|
||||
|
||||
@@ -10,12 +10,6 @@ import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
*/
|
||||
public interface ISysTestConfigService extends IService<SysTestConfig> {
|
||||
|
||||
/**
|
||||
* 获取检测配置
|
||||
* @return
|
||||
*/
|
||||
SysTestConfig getConfig();
|
||||
|
||||
/**
|
||||
* 添加检测配置
|
||||
* @param scene 场景
|
||||
|
||||
@@ -28,10 +28,6 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public SysTestConfig getConfig() {
|
||||
return this.getOne(new QueryWrapper<SysTestConfig>().last("LIMIT 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -40,7 +36,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
||||
sysTestConfig.setAutoGenerate(1);
|
||||
// 最大被检次数默认为3次
|
||||
sysTestConfig.setMaxTime(3);
|
||||
sysTestConfig.setDataRule("46cf964bd76fb12a19cfb1700442eeeb"); // 任意值
|
||||
//sysTestConfig.setDataRule("46cf964bd76fb12a19cfb1700442eeeb"); // 任意值
|
||||
sysTestConfig.setScene(scene);
|
||||
sysTestConfig.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(sysTestConfig);
|
||||
@@ -56,12 +52,10 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
||||
|
||||
@Override
|
||||
public SysTestConfig getOneConfig() {
|
||||
MPJLambdaWrapper<SysTestConfig> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(SysTestConfig.class)
|
||||
.selectAs(DictData::getCode, SysTestConfig::getDataRule)
|
||||
.leftJoin(DictData.class, DictData::getId, SysTestConfig::getDataRule)
|
||||
.eq(SysTestConfig::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.getBaseMapper().selectJoinOne(SysTestConfig.class, queryWrapper);
|
||||
QueryWrapper<SysTestConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
queryWrapper.last("LIMIT 1");
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,6 +77,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addDictData(DictDataParam dictDataParam) {
|
||||
dictDataParam.setName(dictDataParam.getName().trim());
|
||||
checkDicDataName(dictDataParam, false);
|
||||
DictData dictData = new DictData();
|
||||
BeanUtil.copyProperties(dictDataParam, dictData);
|
||||
@@ -89,6 +90,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateDictData(DictDataParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
checkDicDataName(updateParam, true);
|
||||
DictData dictData = new DictData();
|
||||
BeanUtil.copyProperties(updateParam, dictData);
|
||||
|
||||
@@ -58,6 +58,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addDictPq(DictPqParam dictPqParam) {
|
||||
dictPqParam.setName(dictPqParam.getName().trim());
|
||||
checkDicPqName(dictPqParam, false);
|
||||
DictPq dictPq = new DictPq();
|
||||
BeanUtil.copyProperties(dictPqParam, dictPq);
|
||||
@@ -69,6 +70,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateDictPq(DictPqParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
checkDicPqName(updateParam, true);
|
||||
DictPq dictPq = new DictPq();
|
||||
BeanUtil.copyProperties(updateParam, dictPq);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addDictTree(DictTreeParam dictTreeParam) {
|
||||
dictTreeParam.setName(dictTreeParam.getName().trim());
|
||||
checkRepeat(dictTreeParam, false);
|
||||
boolean result;
|
||||
DictTree dictTree = new DictTree();
|
||||
@@ -79,6 +80,7 @@ public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateDictTree(DictTreeParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
DictTree dictTree = this.getById(param.getId());
|
||||
if("975f63baeb6f653c54fca226a9ae36ca".equals(param.getId()) || dictTree.getPids().contains("975f63baeb6f653c54fca226a9ae36ca")){
|
||||
throw new BusinessException(SystemResponseEnum.CAN_NOT_UPDATE_USED_DICT);
|
||||
|
||||
@@ -60,6 +60,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addDictType(DictTypeParam dictTypeParam) {
|
||||
dictTypeParam.setName(dictTypeParam.getName().trim());
|
||||
checkDicTypeName(dictTypeParam, false);
|
||||
DictType dictType = new DictType();
|
||||
BeanUtil.copyProperties(dictTypeParam, dictType);
|
||||
@@ -71,6 +72,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateDictType(DictTypeParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
checkDicTypeName(updateParam, true);
|
||||
DictType dictType = new DictType();
|
||||
BeanUtil.copyProperties(updateParam, dictType);
|
||||
|
||||
@@ -48,6 +48,7 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addFunction(SysFunctionParam functionParam) {
|
||||
functionParam.setName(functionParam.getName().trim());
|
||||
functionParam.setPath(functionParam.getPath().trim());
|
||||
functionParam.setComponent(functionParam.getComponent().trim());
|
||||
checkFunctionParam(functionParam, false);
|
||||
@@ -71,6 +72,7 @@ public class SysFunctionServiceImpl extends ServiceImpl<SysFunctionMapper, SysFu
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateFunction(SysFunctionParam.UpdateParam param) {
|
||||
param.setName(param.getName().trim());
|
||||
boolean result = false;
|
||||
param.setPath(param.getPath().trim());
|
||||
param.setComponent(param.getComponent().trim());
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addRole(SysRoleParam sysRoleParam) {
|
||||
sysRoleParam.setName(sysRoleParam.getName().trim());
|
||||
checkRepeat(sysRoleParam, false);
|
||||
SysRole role = new SysRole();
|
||||
BeanUtil.copyProperties(sysRoleParam, role);
|
||||
@@ -66,6 +67,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateRole(SysRoleParam.UpdateParam updateParam) {
|
||||
updateParam.setName(updateParam.getName().trim());
|
||||
checkRepeat(updateParam, true);
|
||||
//不能修改超级管理员角色
|
||||
Integer count = this.lambdaQuery()
|
||||
@@ -99,7 +101,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
public List<SysRole> simpleList() {
|
||||
LambdaQueryWrapper<SysRole> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(SysRole::getId, SysRole::getName).ne(SysRole::getType, RoleConst.TYPE_SUPER_ADMINISTRATOR).eq(SysRole::getState, DataStateEnum.ENABLE.getCode());
|
||||
lambdaQueryWrapper.select(SysRole::getId, SysRole::getName).eq(SysRole::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addUser(SysUserParam.SysUserAddParam addUserParam) {
|
||||
addUserParam.setName(addUserParam.getName().trim());
|
||||
addUserParam.setLoginName(addUserParam.getLoginName().trim());
|
||||
if (UserConst.SUPER_ADMIN.equals(addUserParam.getLoginName())) {
|
||||
throw new BusinessException(UserResponseEnum.SUPER_ADMIN_REPEAT);
|
||||
}
|
||||
@@ -129,6 +131,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateUser(SysUserParam.SysUserUpdateParam updateUserParam) {
|
||||
updateUserParam.setName(updateUserParam.getName().trim());
|
||||
checkRepeat(updateUserParam, true, updateUserParam.getId());
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(updateUserParam, sysUser);
|
||||
|
||||
Reference in New Issue
Block a user