Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
873e920add | ||
|
|
fd7c6ada6b | ||
|
|
c148bddfc9 | ||
|
|
f0857b7c46 | ||
| 9b1c6f61e6 | |||
|
|
3f72c52cdc | ||
|
|
ef757c52ea | ||
|
|
4110a835c8 | ||
|
|
e78ce544e3 | ||
|
|
c10d54e79a | ||
|
|
2796558040 | ||
|
|
920a808729 | ||
|
|
8e24ac4b71 | ||
|
|
3eb2736edb | ||
|
|
8c3eba9224 | ||
|
|
6288aa565e | ||
|
|
0fa7ec91c4 | ||
|
|
fdb4b7060a | ||
| 3f47b0f008 | |||
|
|
cb431b5af1 | ||
|
|
153428b24f | ||
|
|
d92544f7c4 | ||
|
|
3f1ae1886a | ||
|
|
af4863af65 | ||
|
|
4b7c1259a7 | ||
|
|
de1496389e | ||
| 79003cd0f4 | |||
|
|
c3443fcc91 | ||
|
|
5105e77823 | ||
|
|
eb068b76a4 | ||
| 9f11f7ec11 | |||
| 2012221b73 | |||
|
|
9ab5d42439 | ||
| 7abcaefeb1 | |||
|
|
f4df52dd1c | ||
| db115bb27d | |||
|
|
68d96e67aa | ||
| 3f94012faa | |||
| 41c557118c | |||
| 6596a572d6 | |||
| 139c7b0651 | |||
|
|
ab236cd34f | ||
|
|
786bd5d660 | ||
|
|
21d2c2b7a7 | ||
|
|
48fa4c2390 | ||
|
|
033330b005 | ||
|
|
f81123c3f7 | ||
|
|
5539cb2887 | ||
|
|
1df9c8d703 | ||
|
|
1cbed2a620 | ||
| 89667367ea | |||
| 92b95dd86d | |||
|
|
6b7e38fef6 | ||
|
|
f10debe2f2 | ||
|
|
9d15351fba | ||
|
|
2339a006ec | ||
|
|
7fd904ab79 | ||
|
|
61f149b562 | ||
|
|
40cb153656 | ||
|
|
f922ee97aa | ||
|
|
26c5e933f5 | ||
|
|
c7d8fc3168 | ||
|
|
bb22857fc9 | ||
|
|
6ef908ff60 | ||
|
|
7461801657 |
@@ -155,4 +155,25 @@ public class PreDetectionController extends BaseController {
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
preDetectionService.exportAlignData();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/canCoefficient")
|
||||
@ApiOperation("比对模式是否能够进行系数校验")
|
||||
public HttpResult<Boolean> canCoefficient() {
|
||||
String methodDescribe = getMethodDescribe("canCoefficient");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, preDetectionService.getCanCoefficient(), methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/startCoefficient")
|
||||
@ApiOperation("比对模式开启系数校验")
|
||||
public HttpResult<String> startCoefficient() {
|
||||
String methodDescribe = getMethodDescribe("startCoefficient");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
|
||||
preDetectionService.startCoefficient();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||
import com.njcn.gather.detection.pojo.dto.WaveCommandDTO;
|
||||
import com.njcn.gather.detection.pojo.dto.WaveResultDTO;
|
||||
import com.njcn.gather.detection.pojo.enums.*;
|
||||
@@ -24,15 +26,17 @@ import com.njcn.gather.detection.pojo.vo.*;
|
||||
import com.njcn.gather.detection.service.IAdPariService;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.DetectionUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.IPqStandardDevGainRecordService;
|
||||
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -62,6 +66,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -92,6 +97,8 @@ public class SocketContrastResponseService {
|
||||
private final IAdPariService adPairService;
|
||||
private final ICompareWaveService compareWaveService;
|
||||
private final IAdPlanTestConfigService adPlanTestConfigService;
|
||||
private final IPqStandardDevGainService pqStandardDevGainService;
|
||||
private final IPqStandardDevGainRecordService pqStandardDevGainRecordService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -120,7 +127,7 @@ public class SocketContrastResponseService {
|
||||
// private SysRegRes contrastRegRes = null;
|
||||
|
||||
|
||||
@Value("${log.homeDir}")
|
||||
@Value("${report.reportDir}")
|
||||
private String alignDataFilePath;
|
||||
|
||||
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
||||
@@ -182,7 +189,10 @@ public class SocketContrastResponseService {
|
||||
FormalTestManager.pstDataType = null;
|
||||
FormalTestManager.isPstData = false;
|
||||
FormalTestManager.isWaveCheck = false;
|
||||
FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false;
|
||||
// FormalTestManager.isXu = true;
|
||||
FormalTestManager.nonWaveDataSourceEnum = null;
|
||||
DetectionServiceImpl.vAndIResultMap = new HashMap<>();
|
||||
|
||||
String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(",");
|
||||
for (String datasourceId : datasourceIds) {
|
||||
@@ -219,7 +229,13 @@ public class SocketContrastResponseService {
|
||||
FormalTestManager.isRemoveSocket = false;
|
||||
FormalTestManager.waveCheckFlag = false;
|
||||
FormalTestManager.scheduler = null;
|
||||
FormalTestManager.scheduledFuture = null;
|
||||
if (FormalTestManager.scheduledFuture != null) {
|
||||
FormalTestManager.scheduledFuture.cancel(true);
|
||||
if (FormalTestManager.scheduler != null) {
|
||||
FormalTestManager.scheduler.shutdown();
|
||||
}
|
||||
FormalTestManager.scheduledFuture = null;
|
||||
}
|
||||
|
||||
HashBiMap<String, String> hashBiMap = HashBiMap.create(param.getPairs());
|
||||
FormalTestManager.pairsIdMap.clear();
|
||||
@@ -369,6 +385,10 @@ public class SocketContrastResponseService {
|
||||
case RECORD_WAVE_STEP1:
|
||||
this.recordWave(param, socketDataMsg);
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
this.coefficient(param, socketDataMsg);
|
||||
break;
|
||||
//退出关闭
|
||||
case QUITE:
|
||||
quitDeal(socketDataMsg, param);
|
||||
@@ -716,9 +736,14 @@ public class SocketContrastResponseService {
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
System.out.println("(仅有录波)模型一致性校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
|
||||
this.sendXu(s);
|
||||
this.resetTimer();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
if (FormalTestManager.isXu) {
|
||||
this.sendXu(s);
|
||||
this.resetTimer();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
} else {
|
||||
System.out.println("跳过相序校验!");
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -909,9 +934,14 @@ public class SocketContrastResponseService {
|
||||
|
||||
this.clearData();
|
||||
|
||||
System.out.println("数据对齐校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》");
|
||||
this.sendXu(s);
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
if (FormalTestManager.isXu) {
|
||||
System.out.println("数据对齐校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始相序校验》》》》》》》》》》》》》》》》");
|
||||
this.sendXu(s);
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.YJC_XUJY;
|
||||
} else {
|
||||
System.out.println("跳过相序校验!");
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
this.resetTimer();
|
||||
}
|
||||
}
|
||||
@@ -1035,60 +1065,7 @@ public class SocketContrastResponseService {
|
||||
webSend.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());//最终成功推送
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
|
||||
// 后续做正式检测
|
||||
if (param.getTestItemList().get(2)) {
|
||||
System.out.println("相序校验成功!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始正式检测》》》》》》》》》》》》》》》》");
|
||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||
socketMsg.setOperateCode(requestOperateCode.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(Arrays.asList(FormalTestManager.monitorMap.keySet().toArray(new String[FormalTestManager.monitorMap.size()])));
|
||||
List<String> allDataType = this.getAllDataType();
|
||||
FormalTestManager.pstDataType = new ArrayList<>();
|
||||
if (allDataType.contains(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode())) {
|
||||
FormalTestManager.pstDataType.add(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
allDataType.remove(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(allDataType)) {
|
||||
phaseSequenceParam.setDataType(allDataType);
|
||||
} else {
|
||||
if (CollUtil.isNotEmpty(FormalTestManager.pstDataType)) {
|
||||
FormalTestManager.isPstData = true;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
phaseSequenceParam.setDataType(FormalTestManager.pstDataType);
|
||||
}
|
||||
}
|
||||
phaseSequenceParam.setReadCount(this.getReadCount(this.getTargetCount()));
|
||||
phaseSequenceParam.setIgnoreCount(0);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
this.resetTimer();
|
||||
checkResult = false;
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
// 录波数据
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
successComm.clear();
|
||||
failComm.clear();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.RECORD_WAVE_STEP1;
|
||||
// 发送录波指令
|
||||
this.sendRecordWave(s);
|
||||
}
|
||||
} else {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
if (FormalTestManager.voltageProtocol) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
}
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
FormalTestManager.isTesting = false;
|
||||
}
|
||||
this.sendFormalTest(s, param, requestOperateCode, quitOperateCode);
|
||||
}
|
||||
} else if (successComm.size() == FormalTestManager.monitorMap.size()) {
|
||||
this.clearData();
|
||||
@@ -1174,6 +1151,63 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
||||
// 后续做正式检测
|
||||
if (param.getTestItemList().get(2)) {
|
||||
System.out.println("开始正式检测!");
|
||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||
socketMsg.setOperateCode(requestOperateCode.getValue());
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(Arrays.asList(FormalTestManager.monitorMap.keySet().toArray(new String[FormalTestManager.monitorMap.size()])));
|
||||
List<String> allDataType = this.getAllDataType();
|
||||
FormalTestManager.pstDataType = new ArrayList<>();
|
||||
if (allDataType.contains(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode())) {
|
||||
FormalTestManager.pstDataType.add(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
allDataType.remove(DetectionCodeEnum.AVG_PREFIX.getCode() + DetectionCodeEnum.PST.getCode());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(allDataType)) {
|
||||
phaseSequenceParam.setDataType(allDataType);
|
||||
} else {
|
||||
if (CollUtil.isNotEmpty(FormalTestManager.pstDataType)) {
|
||||
FormalTestManager.isPstData = true;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
phaseSequenceParam.setDataType(FormalTestManager.pstDataType);
|
||||
}
|
||||
}
|
||||
phaseSequenceParam.setReadCount(this.getReadCount(this.getTargetCount()));
|
||||
phaseSequenceParam.setIgnoreCount(0);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
this.resetTimer();
|
||||
checkResult = false;
|
||||
} else if (FormalTestManager.isWaveCheck) {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
// 录波数据
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
successComm.clear();
|
||||
failComm.clear();
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.RECORD_WAVE_STEP1;
|
||||
// 发送录波指令
|
||||
this.sendRecordWave(s);
|
||||
}
|
||||
} else {
|
||||
if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
}
|
||||
if (FormalTestManager.voltageProtocol) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
}
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
FormalTestManager.isTesting = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正式检测
|
||||
*
|
||||
@@ -1208,39 +1242,6 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
}
|
||||
this.setScheduler(targetCount, param.getUserPageId(), requestOperateCode, quitOperateCode);
|
||||
// if (Objects.isNull(FormalTestManager.scheduler)) {
|
||||
// FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
||||
// long delay = this.getDelay(targetCount);
|
||||
// FormalTestManager.scheduledFuture = FormalTestManager.scheduler.schedule(() -> {
|
||||
// if (!checkResult) {
|
||||
// System.out.println("正式检测-" + delay + "s内收集数据不完整!");
|
||||
// // 断开与设备的连接,但是不要将Socket移除
|
||||
// if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) {
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||
// }
|
||||
// if (FormalTestManager.voltageProtocol) {
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
// }
|
||||
// CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false);
|
||||
// FormalTestManager.isTesting = false;
|
||||
//
|
||||
// this.clearData();
|
||||
//
|
||||
// Collection<String> disjunction = CollectionUtil.disjunction(FormalTestManager.pairsIpMap.keySet(), successPair.keySet());
|
||||
// // 向前端推送收集数据不完整的配对项
|
||||
// for (String key : disjunction) {
|
||||
// webSend.setCode(SourceResponseCodeEnum.FAIL.getCode());
|
||||
// webSend.setData(MsgUtil.getPairStr(key, FormalTestManager.pairsIpMap.inverse().get(key), FormalTestManager.devNameMapComm) + " 数据收集不完整!");
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
// }
|
||||
// // 推送最终失败结果
|
||||
// webSend.setCode(SourceResponseCodeEnum.ALL_FAIL.getCode());//最终错误推送
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
// }
|
||||
// FormalTestManager.scheduler.shutdown();
|
||||
// FormalTestManager.scheduler = null;
|
||||
// }, delay, TimeUnit.SECONDS);
|
||||
// }
|
||||
|
||||
String monitorId1 = devData.getId();
|
||||
String devMonitorId = monitorId1;
|
||||
@@ -1416,6 +1417,28 @@ public class SocketContrastResponseService {
|
||||
pqDevService.updateResult(id1.split(CnSocketUtil.SPLIT_TAG)[0], param.getUserId());
|
||||
});
|
||||
FormalTestManager.isTesting = false;
|
||||
|
||||
if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) {
|
||||
// 是否进行系数校准
|
||||
//万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果
|
||||
|
||||
XiNumberManager.xiDevList.clear();
|
||||
XiNumberManager.devXiNumDataMap.clear();
|
||||
List<String> stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList());
|
||||
XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList());
|
||||
// 逐一设备向通讯模块要原始系数
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
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() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 配对关系入库
|
||||
@@ -1693,6 +1716,160 @@ public class SocketContrastResponseService {
|
||||
}
|
||||
}
|
||||
|
||||
private void coefficient(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getOperateCode());
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
SocketMsg<String> xiSocket = new SocketMsg<>();
|
||||
xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
|
||||
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||
case DATA_CHNFACTOR$01:
|
||||
//获取系数
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) {
|
||||
List<DevXiNumData.GF> gfList = JSON.parseArray(socketDataMsg.getData(), DevXiNumData.GF.class);
|
||||
DevXiNumData devXiNumData = new DevXiNumData();
|
||||
String ip = XiNumberManager.xiDevList.get(0).getDevIP();
|
||||
devXiNumData.setDevIP(ip);
|
||||
//String stdMonitorId = DetectionServiceImpl.vAndIResultMap.keySet().stream().filter(key -> key.contains(ip)).findFirst().get();
|
||||
|
||||
List<PqStandardDevGain> pqStandardDevGainList = new ArrayList<>();
|
||||
List<PqStandardDevGainRecord> recordList = new ArrayList<>();
|
||||
for (int i = 0; i < gfList.size(); i++) {
|
||||
DevXiNumData.GF gf = gfList.get(i);
|
||||
String stdDevMonitorId = FormalTestManager.devIdMapComm.get(ip) + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1);
|
||||
String devMonitorId = FormalTestManager.pairsIdMap.inverse().get(stdDevMonitorId);
|
||||
PqStandardDevGain pqStandardDevGain = new PqStandardDevGain();
|
||||
pqStandardDevGain.setStdDevMonitorId(stdDevMonitorId);
|
||||
|
||||
DevXiNumData.F f = gf.getF();
|
||||
pqStandardDevGain.setUaGain(f.getUa_gain());
|
||||
pqStandardDevGain.setUbGain(f.getUb_gain());
|
||||
pqStandardDevGain.setUcGain(f.getUc_gain());
|
||||
pqStandardDevGain.setU0Gain(f.getU0_gain());
|
||||
pqStandardDevGain.setIaGain(f.getIa_gain());
|
||||
pqStandardDevGain.setIbGain(f.getIb_gain());
|
||||
pqStandardDevGain.setIcGain(f.getIc_gain());
|
||||
pqStandardDevGain.setI0Gain(f.getI0_gain());
|
||||
pqStandardDevGain.setUabGain(f.getUab_gain());
|
||||
pqStandardDevGain.setUbcGain(f.getUbc_gain());
|
||||
pqStandardDevGain.setUcaGain(f.getUca_gain());
|
||||
pqStandardDevGain.setState(DataStateEnum.ENABLE.getCode());
|
||||
pqStandardDevGainList.add(pqStandardDevGain);
|
||||
DetectionServiceImpl.VAndIResult vAndIResult = DetectionServiceImpl.vAndIResultMap.get(ip + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1));
|
||||
if (ObjectUtil.isNotNull(vAndIResult)) {
|
||||
int maxNum = pqStandardDevGainRecordService.getMaxNum(stdDevMonitorId, devMonitorId);
|
||||
PqStandardDevGainRecord record = new PqStandardDevGainRecord();
|
||||
record.setStdDevMonitorId(stdDevMonitorId);
|
||||
record.setDevMonitorId(devMonitorId);
|
||||
record.setNum(maxNum + 1);
|
||||
recordList.add(record);
|
||||
updateGfList(f, vAndIResult, stdDevMonitorId, maxNum);
|
||||
}
|
||||
}
|
||||
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||
devXiNumData.setGf(gfList);
|
||||
xiSocket.setData(JSON.toJSONString(devXiNumData));
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket));
|
||||
|
||||
// 原始系数入库
|
||||
pqStandardDevGainService.add(pqStandardDevGainList);
|
||||
pqStandardDevGainRecordService.addOrUpdate(recordList);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case NORMAL_RESPONSE:
|
||||
break;
|
||||
case DATA_RESOLVE:
|
||||
break;
|
||||
case COMMUNICATION_ERR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case DATA_CHNFACTOR$02:
|
||||
//系数下发后的响应
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
//单台装置系数下发后,需要删除集合中存在的当前装置
|
||||
XiNumberManager.xiDevList.remove(0);
|
||||
//继续下发每台装置系数,只到集合为空
|
||||
if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) {
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.xiDevList.get(0))));
|
||||
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
xiSocket.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket));
|
||||
} else {
|
||||
//{"requestId":"Coefficient_Check","operateCode":"DATA_CHNFACTOR$02","data":"end","code":10200}
|
||||
// 通知前端全部下发系数完成
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case NORMAL_RESPONSE:
|
||||
break;
|
||||
case DATA_RESOLVE:
|
||||
//quitSend(param);
|
||||
break;
|
||||
case COMMUNICATION_ERR:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// case DEV_DATA_REQUEST_02:
|
||||
// //实时采集申请
|
||||
// String data = socketDataMsg.getData();
|
||||
// DevData devData = JSON.parseObject(data, DevData.class);
|
||||
// if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
// switch (dictDataEnumByCode) {
|
||||
// case SUCCESS:
|
||||
// if (devData.getResult()) {
|
||||
// FormalTestManager.realDataXiList.add(devData);
|
||||
// successComm.add(devData.getId());
|
||||
// System.out.println(successComm.size() + " ==" + FormalTestManager.monitorIdListComm.size() + "FormalTestManager.realDataXiList:" + FormalTestManager.realDataXiList.size() + "当前步骤" + XiNumberManager.stepNumber);
|
||||
// if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
// processData(param, xiSocket);
|
||||
// }
|
||||
// } else {
|
||||
// System.out.println("系数校准抛除数据" + devData);
|
||||
// }
|
||||
// break;
|
||||
// case UNPROCESSED_BUSINESS:
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
// break;
|
||||
// case NORMAL_RESPONSE:
|
||||
// if (devData.getResult()) {
|
||||
// FormalTestManager.realDataXiList.add(devData);
|
||||
// } else {
|
||||
// System.out.println("系数校准抛除数据" + devData);
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// xiSocket.setRequestId(socketDataMsg.getRequestId());
|
||||
// xiSocket.setOperateCode(socketDataMsg.getOperateCode());
|
||||
// xiSocket.setData(dictDataEnumByCode.getMessage());
|
||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(xiSocket));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出检测返回
|
||||
@@ -1867,13 +2044,13 @@ public class SocketContrastResponseService {
|
||||
*/
|
||||
private Integer getTargetCount() {
|
||||
if (FormalTestManager.isPstData) {
|
||||
return FormalTestManager.curretntTestPlanConfig.getFlicker();
|
||||
return FormalTestManager.curretntTestPlanConfig.getFlicker() * 2;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||
if (FormalTestManager.nonWaveDataSourceEnum == DataSourceEnum.REAL_DATA) {
|
||||
return FormalTestManager.curretntTestPlanConfig.getRealTime();
|
||||
return FormalTestManager.curretntTestPlanConfig.getRealTime() * 2;
|
||||
} else {
|
||||
return FormalTestManager.curretntTestPlanConfig.getStatistics();
|
||||
return FormalTestManager.curretntTestPlanConfig.getStatistics() * 2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -1959,8 +2136,13 @@ public class SocketContrastResponseService {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2063,8 +2245,13 @@ public class SocketContrastResponseService {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2127,7 +2314,7 @@ public class SocketContrastResponseService {
|
||||
});
|
||||
});
|
||||
|
||||
ExcelUtil.saveExcel(alignDataFilePath, "实时数据.xlsx", sheetsList);
|
||||
ExcelUtil.saveExcel(alignDataFilePath, "对齐数据.xlsx", sheetsList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2284,8 +2471,13 @@ public class SocketContrastResponseService {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||
isStar = true;
|
||||
isDelta = false;
|
||||
} else {
|
||||
isStar = false;
|
||||
isDelta = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2603,18 +2795,30 @@ public class SocketContrastResponseService {
|
||||
devInfo = pqDevService.getDevInfo(Collections.singletonList(devId));
|
||||
}
|
||||
Integer usePhaseIndex = devInfo.get(0).getUsePhaseIndex();
|
||||
|
||||
List<String> allDesc = data.getSqlData().stream().map(x -> x.getDesc()).collect(Collectors.toList());
|
||||
allDesc.addAll(data.getSqlDataHarm().stream().map(x -> x.getDesc()).collect(Collectors.toList()));
|
||||
|
||||
String bzDevId = devId;
|
||||
if (isStdDev) {
|
||||
String s = FormalTestManager.pairsIdMap.inverse().get(devId + CnSocketUtil.SPLIT_TAG + splitArr[1]);
|
||||
bzDevId = s.split(CnSocketUtil.SPLIT_TAG)[0];
|
||||
}
|
||||
PqMonitor monitor = pqMonitorService.getByDevIdAndNum(bzDevId, Integer.parseInt(splitArr[1]));
|
||||
DictData dictData = dictDataService.getById(monitor.getConnection());
|
||||
for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) {
|
||||
if (usePhaseIndex.equals(1)) {
|
||||
if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) {
|
||||
if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ((DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc()))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2662,8 +2866,14 @@ public class SocketContrastResponseService {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) {
|
||||
if (DetectionCodeEnum.PV2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PSV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3300,4 +3510,46 @@ public class SocketContrastResponseService {
|
||||
devData.setSqlDataHarm(sqlDataHarmDTOS);
|
||||
return devData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通道系数
|
||||
*
|
||||
* @param f
|
||||
*/
|
||||
private void updateGfList(DevXiNumData.F f, DetectionServiceImpl.VAndIResult vAndIResult, String stdDevMonitorId, int maxNum) {
|
||||
DevXiNumData.F originF = BeanUtil.copyProperties(f, DevXiNumData.F.class);
|
||||
if (maxNum != 0) {
|
||||
PqStandardDevGain pqStandardDevGain = pqStandardDevGainService.get(stdDevMonitorId);
|
||||
originF.setUa_gain(pqStandardDevGain.getUaGain());
|
||||
originF.setUb_gain(pqStandardDevGain.getUbGain());
|
||||
originF.setUc_gain(pqStandardDevGain.getUcGain());
|
||||
originF.setU0_gain(pqStandardDevGain.getU0Gain());
|
||||
originF.setIa_gain(pqStandardDevGain.getIaGain());
|
||||
originF.setIb_gain(pqStandardDevGain.getIbGain());
|
||||
originF.setIc_gain(pqStandardDevGain.getIcGain());
|
||||
originF.setI0_gain(pqStandardDevGain.getI0Gain());
|
||||
originF.setUab_gain(pqStandardDevGain.getUabGain());
|
||||
originF.setUbc_gain(pqStandardDevGain.getUbcGain());
|
||||
originF.setUca_gain(pqStandardDevGain.getUcaGain());
|
||||
}
|
||||
|
||||
if (vAndIResult.getVa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVaXi() * 10000), BigDecimal.valueOf(originF.getUa_gain() * 0.95), BigDecimal.valueOf(originF.getUa_gain() * 1.05))) {
|
||||
f.setUa_gain(BigDecimal.valueOf(f.getUa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVaXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (vAndIResult.getVb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVbXi() * 10000), BigDecimal.valueOf(originF.getUb_gain() * 0.95), BigDecimal.valueOf(originF.getUb_gain() * 1.05))) {
|
||||
f.setUb_gain(BigDecimal.valueOf(f.getUb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVbXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (vAndIResult.getVc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVcXi() * 10000), BigDecimal.valueOf(originF.getUc_gain() * 0.95), BigDecimal.valueOf(originF.getUc_gain() * 1.05))) {
|
||||
f.setUc_gain(BigDecimal.valueOf(f.getUc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVcXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (vAndIResult.getIa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIaXi() * 10000), BigDecimal.valueOf(originF.getIa_gain() * 0.95), BigDecimal.valueOf(originF.getIa_gain() * 1.05))) {
|
||||
f.setIa_gain(BigDecimal.valueOf(f.getIa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIaXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (vAndIResult.getIb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIbXi() * 10000), BigDecimal.valueOf(originF.getIb_gain() * 0.95), BigDecimal.valueOf(originF.getIb_gain() * 1.05))) {
|
||||
f.setIb_gain(BigDecimal.valueOf(f.getIb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIbXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
if (vAndIResult.getIc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIcXi() * 10000), BigDecimal.valueOf(originF.getIc_gain() * 0.95), BigDecimal.valueOf(originF.getIc_gain() * 1.05))) {
|
||||
f.setIc_gain(BigDecimal.valueOf(f.getIc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIcXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,6 +439,7 @@ public class SocketDevResponseService {
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
String type = sourceIssues.get(0).getType();
|
||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||
@@ -612,7 +613,7 @@ public class SocketDevResponseService {
|
||||
|
||||
private void assemblyEntity(List<DevData> deList, DevXiNumData.F F, DevXiNumData.GF startF, CoefficientVO coefficientVO, CoefficientVO.DevParameter devParameter) {
|
||||
//表示接收完成,必须保证3个数
|
||||
if (deList.size() >= 3) {
|
||||
if (deList.size() >= 7) {
|
||||
List<Double> aList = deList.stream().map(it -> it.getSqlData().get(0).getList().getA()).collect(Collectors.toList());
|
||||
List<Double> bList = deList.stream().map(it -> it.getSqlData().get(0).getList().getB()).collect(Collectors.toList());
|
||||
List<Double> cList = deList.stream().map(it -> it.getSqlData().get(0).getList().getC()).collect(Collectors.toList());
|
||||
@@ -687,7 +688,7 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
private Double reduceList(List<Double> valList) {
|
||||
// valList.subList(0, 5).clear();
|
||||
// valList.subList(valList.size() - 3, valList.size() - 1).clear();
|
||||
valList.subList(valList.size() - 2, valList.size()).clear();
|
||||
return valList.stream().mapToDouble(Double::doubleValue).average().getAsDouble();
|
||||
}
|
||||
|
||||
@@ -953,6 +954,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||
}
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
@@ -1210,6 +1212,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||
}
|
||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
@@ -1782,6 +1785,7 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
FormalTestManager.currentTestPlan = plan;
|
||||
|
||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||
FormalTestManager.patternEnum = PatternEnum.getEnum(code);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||
@@ -14,7 +15,12 @@ import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -56,6 +62,8 @@ public class SocketSourceResponseService {
|
||||
* 设备信息服务,提供设备基础信息查询功能
|
||||
*/
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IAdPlanSourceService adPlanSourceService;
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
/**
|
||||
* Socket连接管理器,负责管理设备和源的Socket连接
|
||||
@@ -334,9 +342,9 @@ public class SocketSourceResponseService {
|
||||
// 系数校验固定检测项:实时电压有效值和实时电流有效值
|
||||
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
|
||||
// 读取3次数据用于系数计算
|
||||
phaseSequenceParam.setReadCount(3);
|
||||
phaseSequenceParam.setReadCount(7); //3
|
||||
// 忽略前4次数据,等待测量稳定
|
||||
phaseSequenceParam.setIgnoreCount(4);
|
||||
phaseSequenceParam.setIgnoreCount(3); //4
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||
|
||||
@@ -363,18 +371,32 @@ public class SocketSourceResponseService {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
// 使用智能发送工具类,自动管理设备连接
|
||||
socketManager.smartSendToDevice(param, json);
|
||||
if (FormalTestManager.unknownError) {
|
||||
FormalTestManager.unknownError = false;
|
||||
|
||||
//重新下发脚本
|
||||
String type = FormalTestManager.currentIssue.getType();
|
||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||
FormalTestManager.currentIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||
}
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||
} else {
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
//开始设备通讯检测(发送设备初始化)
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
// 使用智能发送工具类,自动管理设备连接
|
||||
socketManager.smartSendToDevice(param, json);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
@@ -570,6 +592,10 @@ public class SocketSourceResponseService {
|
||||
case UNPROCESSED_BUSINESS:
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
break;
|
||||
case UNKNOWN_ERROR: //-1源未知异常
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
FormalTestManager.unknownError = true;
|
||||
break;
|
||||
default:
|
||||
sendErrorAndQuit(param, socketDataMsg, dictDataEnumByCode);
|
||||
break;
|
||||
@@ -601,9 +627,23 @@ public class SocketSourceResponseService {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
if (FormalTestManager.unknownError) {
|
||||
//获取源初始化参数
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
SocketMsg<String> socketMsg1 = new SocketMsg<>();
|
||||
socketMsg1.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketMsg1.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketMsg1.setData(JSON.toJSONString(sourceParam));
|
||||
//使用智能发送工具类,自动管理与源控程序的socket连接
|
||||
socketManager.smartSendToSource(param, JSON.toJSONString(socketMsg1));
|
||||
}
|
||||
} else {
|
||||
//通讯校验成功
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
@@ -653,6 +693,8 @@ public class SocketSourceResponseService {
|
||||
|
||||
// 同步更新系数管理器中的设备列表
|
||||
XiNumberManager.xiDevList = devList;
|
||||
FormalTestManager.unknownError = false;
|
||||
FormalTestManager.currentIssue = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,9 @@ public class ContrastDetectionParam {
|
||||
private List<Boolean> testItemList;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 是否进行相许校验
|
||||
*/
|
||||
private Integer phaseCheck;
|
||||
}
|
||||
|
||||
@@ -53,4 +53,9 @@ public class DetectionData {
|
||||
* 误差体系详情ID(比对式使用)
|
||||
*/
|
||||
private String errorDtlId;
|
||||
|
||||
/**
|
||||
* 有效组数
|
||||
*/
|
||||
private Integer validGroupNum;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -63,4 +64,8 @@ public interface PreDetectionService {
|
||||
* 导出实时数据对齐过程中的数据
|
||||
*/
|
||||
void exportAlignData();
|
||||
|
||||
boolean getCanCoefficient();
|
||||
|
||||
void startCoefficient();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,8 @@ import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
@@ -38,6 +40,7 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
@@ -75,8 +78,10 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
private final SocketContrastResponseService socketContrastResponseService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
private final SocketManager socketManager;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
|
||||
@Value("${log.homeDir}")
|
||||
|
||||
@Value("${report.reportDir}")
|
||||
private String alignDataFilePath;
|
||||
|
||||
|
||||
@@ -337,7 +342,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void exportAlignData() {
|
||||
String fileName = "实时数据.xlsx";
|
||||
String fileName = "对齐数据.xlsx";
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
@@ -358,6 +363,36 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanCoefficient() {
|
||||
return CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCoefficient() {
|
||||
if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) {
|
||||
// 是否进行系数校准
|
||||
//万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果
|
||||
|
||||
XiNumberManager.xiDevList.clear();
|
||||
XiNumberManager.devXiNumDataMap.clear();
|
||||
List<String> stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList());
|
||||
XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList());
|
||||
// 逐一设备向通讯模块要原始系数
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
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(NettyContrastClientHandler.param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
|
||||
FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比对式-与通信模块进行连接
|
||||
*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -421,7 +422,7 @@ public class DetectionUtil {
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,4 +438,94 @@ public class DetectionUtil {
|
||||
System.out.println(" 文件大小: " + file.length() + " bytes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取皮尔逊系数
|
||||
*
|
||||
* <p>相关系数绝对值|r|所代表的相关强度</p>
|
||||
* <ul>
|
||||
* <li>0.8 - 1.0:极强相关</li>
|
||||
* <li>0.6 - 0.8:强相关</li>
|
||||
* <li>0.4 - 0.6:中等程度相关</li>
|
||||
* <li>0.2 - 0.4:弱相关</li>
|
||||
* <li>0.0 - 0.2:极弱相关或无相关</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal getPearsonCorrelationCoefficient(List<Double> x, List<Double> y) {
|
||||
Double xAvg = x.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||
Double yAvg = y.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||
|
||||
// 协方差求和
|
||||
BigDecimal covarianceSum = BigDecimal.ZERO;
|
||||
// x的方差
|
||||
BigDecimal varianceX = BigDecimal.ZERO;
|
||||
// y的方差
|
||||
BigDecimal varianceY = BigDecimal.ZERO;
|
||||
for (int i = 0; i < x.size(); i++) {
|
||||
covarianceSum = covarianceSum.add(BigDecimal.valueOf((x.get(i) - xAvg) * (y.get(i) - yAvg)));
|
||||
varianceX = varianceX.add(BigDecimal.valueOf(Math.pow(x.get(i) - xAvg, 2)));
|
||||
varianceY = varianceY.add(BigDecimal.valueOf(Math.pow(y.get(i) - yAvg, 2)));
|
||||
}
|
||||
BigDecimal fm = BigDecimal.valueOf(Math.sqrt(varianceX.doubleValue()) * Math.sqrt(varianceY.doubleValue()));
|
||||
if (NumberUtil.equals(fm.doubleValue(), BigDecimal.ZERO.doubleValue())) {
|
||||
if (NumberUtil.equals(covarianceSum, BigDecimal.ZERO)) {
|
||||
return BigDecimal.valueOf(1.0);
|
||||
} else {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
} else {
|
||||
return BigDecimal.valueOf(Math.abs(covarianceSum.divide(fm, 8, BigDecimal.ROUND_HALF_UP).doubleValue())); //相关系数
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比值一致性,获取CV系数
|
||||
*
|
||||
* <p>一致性等级</p>
|
||||
* <ul>
|
||||
* <li>CV<1%:非常优秀</li>
|
||||
* <li>1%≤CV<5%:优良</li>
|
||||
* <li>5%≤CV<10%:良好</li>
|
||||
* <li>10%≤CV<20%:中等</li>
|
||||
* <li>20%≤CV:较差</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal getCvCoefficient(List<Double> x, List<Double> y) {
|
||||
List<BigDecimal> ratioList = new ArrayList<>();
|
||||
for (int i = 0; i < x.size(); i++) {
|
||||
ratioList.add(BigDecimal.valueOf(x.get(i) / y.get(i)));
|
||||
}
|
||||
|
||||
BigDecimal avg = BigDecimal.valueOf(ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue).average().orElse(0.0));
|
||||
BigDecimal variance = BigDecimal.valueOf(
|
||||
ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue)
|
||||
.map(v -> Math.pow(v - avg.doubleValue(), 2)).average().orElse(0.0));
|
||||
|
||||
return BigDecimal.valueOf(Math.sqrt(variance.doubleValue()) / avg.doubleValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算新的系数
|
||||
*
|
||||
* @param devList
|
||||
* @param stdDevList
|
||||
* @return
|
||||
*/
|
||||
public static Double getNewXi(List<Double> devList, List<Double> stdDevList) {
|
||||
ArrayList<Double> xiList = new ArrayList<>();
|
||||
for (int i = 0; i < stdDevList.size(); i++) {
|
||||
if (!stdDevList.get(i).equals(0)) {
|
||||
BigDecimal bigDecimalDev = BigDecimal.valueOf(devList.get(i));
|
||||
BigDecimal bigDecimalStdDev = BigDecimal.valueOf(stdDevList.get(i));
|
||||
xiList.add((bigDecimalDev.subtract(bigDecimalStdDev)).divide(BigDecimal.valueOf(2.0).multiply(bigDecimalDev), 8, BigDecimal.ROUND_HALF_UP).doubleValue() + 1.0);
|
||||
}
|
||||
}
|
||||
return xiList.stream().mapToDouble(Double::doubleValue).average().orElse(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanTestConfig;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -195,4 +196,16 @@ public class FormalTestManager {
|
||||
public static boolean statisticsProtocol;
|
||||
|
||||
public static boolean voltageProtocol;
|
||||
|
||||
public static boolean unknownError;
|
||||
|
||||
/**
|
||||
* 当前下发的脚本
|
||||
*/
|
||||
public static SourceIssue currentIssue;
|
||||
|
||||
/**
|
||||
* 是否进行相序校验
|
||||
*/
|
||||
public static boolean isXu;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
devLineTestResult.setDeviceName(dev.getDevName());
|
||||
|
||||
Integer[] resultFlags = dev.getMonitorList().stream()
|
||||
.map(monitor -> ResultEnum.NETWORK_TIMEOUT)
|
||||
.map(monitor -> ResultEnum.NETWORK_TIMEOUT.getValue())
|
||||
.toArray(Integer[]::new);
|
||||
devLineTestResult.setChnResult(resultFlags);
|
||||
|
||||
|
||||
@@ -169,4 +169,24 @@ public class PqDevController extends BaseController {
|
||||
Map<String, List<String>> result = pqDevService.listSelectOptions(pattern);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/ttt")
|
||||
@ApiOperation("批量导入被检设备")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult ttt(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, @RequestParam("planId") String planId, @RequestParam(value = "cover", defaultValue = "0") Integer cover, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("ttt");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
if ("null".equals(planId)) {
|
||||
planId = null;
|
||||
}
|
||||
return pqDevService.importDev(file, patternId, planId, response, cover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
@@ -55,10 +56,10 @@ public class PqStandardDevController extends BaseController {
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询标准设备")
|
||||
@ApiImplicitParam(name = "id", value = "标准设备id", required = true)
|
||||
public HttpResult<PqStandardDev> getById(@RequestParam("id") String id) {
|
||||
public HttpResult<PqStandardDevVO> getById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
||||
PqStandardDev result = pqStandardDevService.getPqStandardDevById(id);
|
||||
PqStandardDevVO result = pqStandardDevService.getPqStandardDevById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-12
|
||||
*/
|
||||
public interface PqStandardDevGainMapper extends MPJBaseMapper<PqStandardDevGain> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public interface PqStandardDevGainRecordMapper extends MPJBaseMapper<PqStandardDevGainRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.mapper.PqStandardDevGainMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.mapper.PqStandardDevGainRecordMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-12
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_standard_dev_gain")
|
||||
public class PqStandardDevGain extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -46280767885558804L;
|
||||
|
||||
|
||||
/**
|
||||
* 标准设备Id_通道号
|
||||
*/
|
||||
@TableId
|
||||
private String stdDevMonitorId;
|
||||
|
||||
private Integer uaGain;
|
||||
|
||||
private Integer ubGain;
|
||||
|
||||
|
||||
private Integer ucGain;
|
||||
|
||||
|
||||
private Integer u0Gain;
|
||||
|
||||
|
||||
private Integer iaGain;
|
||||
|
||||
|
||||
private Integer ibGain;
|
||||
|
||||
|
||||
private Integer icGain;
|
||||
|
||||
|
||||
private Integer i0Gain;
|
||||
|
||||
|
||||
private Integer uabGain;
|
||||
|
||||
|
||||
private Integer ubcGain;
|
||||
|
||||
|
||||
private Integer ucaGain;
|
||||
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_standard_dev_gain_record")
|
||||
public class PqStandardDevGainRecord implements Serializable {
|
||||
private static final long serialVersionUID = 477276215572686991L;
|
||||
|
||||
/**
|
||||
* 标准设备监测点id,由设备id_通道号组成
|
||||
*/
|
||||
private String stdDevMonitorId;
|
||||
|
||||
/**
|
||||
* 被检设备监测点id,由设备id_通道号组成
|
||||
*/
|
||||
private String devMonitorId;
|
||||
|
||||
/**
|
||||
* 系数下发次数
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class ContrastDevExcel implements Serializable {
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备序列号*", width = 20, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
@Excel(name = "设备序列号", width = 20, needMerge = true, orderNum = "5")
|
||||
// @NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, needMerge = true, orderNum = "6")
|
||||
@@ -91,8 +91,8 @@ public class ContrastDevExcel implements Serializable {
|
||||
@NotNull(message = DetectionValidMessage.INSPECT_DATE_NOT_NULL)
|
||||
private LocalDate inspectDate;
|
||||
|
||||
@Excel(name = "谐波系统设备id*", width = 30, needMerge = true, orderNum = "18")
|
||||
@NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
|
||||
@Excel(name = "谐波系统设备id", width = 30, needMerge = true, orderNum = "18")
|
||||
// @NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@ExcelCollection(name = "监测点信息", orderNum = "19")
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-01-19
|
||||
*/
|
||||
@Data
|
||||
public class PqStandardDevVO extends PqStandardDev {
|
||||
|
||||
/**
|
||||
* 通道系数
|
||||
*/
|
||||
List<PqStandardDevGain> gainList;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public interface IPqStandardDevGainRecordService extends IService<PqStandardDevGainRecord> {
|
||||
|
||||
/**
|
||||
* 获取最大下发系数的次数
|
||||
*
|
||||
* @param stdDevMonitorId
|
||||
* @param devMonitorId
|
||||
* @return
|
||||
*/
|
||||
int getMaxNum(String stdDevMonitorId, String devMonitorId);
|
||||
|
||||
/**
|
||||
* 批量新增或更新记录
|
||||
* @param recordList
|
||||
* @return
|
||||
*/
|
||||
boolean addOrUpdate(List<PqStandardDevGainRecord> recordList);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-12
|
||||
*/
|
||||
public interface IPqStandardDevGainService extends IService<PqStandardDevGain> {
|
||||
|
||||
boolean add(List<PqStandardDevGain> pqStandardDevGainList);
|
||||
|
||||
PqStandardDevGain get(String stdDevMonitorId);
|
||||
|
||||
List<PqStandardDevGain> list(String stdDevId);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -30,7 +31,7 @@ public interface IPqStandardDevService extends IService<PqStandardDev> {
|
||||
* @param id 设备id
|
||||
* @return 设备对象
|
||||
*/
|
||||
PqStandardDev getPqStandardDevById(String id);
|
||||
PqStandardDevVO getPqStandardDevById(String id);
|
||||
|
||||
/**
|
||||
* 新增标准设备
|
||||
|
||||
@@ -68,6 +68,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -1340,9 +1341,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (CollUtil.isNotEmpty(hasList)) {
|
||||
importPqDev.setId(hasList.get(0).getId());
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor pqMonitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
pqMonitor.setDevId(importPqDev.getId());
|
||||
monitorList.add(pqMonitor);
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
finalUpdateDevList.add(importPqDev);
|
||||
@@ -1366,6 +1369,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
@@ -1375,6 +1380,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
for (PqMonitorExcel pqMonitorExcel : pqMonitorExcelList) {
|
||||
PqMonitor monitor = BeanUtil.copyProperties(pqMonitorExcel, PqMonitor.class);
|
||||
monitor.setDevId(importPqDev.getId());
|
||||
monitor.setPt(pqMonitorExcel.getPt1() + StrUtil.C_COLON + pqMonitorExcel.getPt2());
|
||||
monitor.setCt(pqMonitorExcel.getCt1() + StrUtil.C_COLON + pqMonitorExcel.getCt2());
|
||||
monitorList.add(monitor);
|
||||
}
|
||||
importPqDev.setMonitorList(monitorList);
|
||||
@@ -1496,13 +1503,19 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 24);
|
||||
pullDown.setLastCol(startCol + 24);
|
||||
pullDown.setFirstCol(startCol + 26);
|
||||
pullDown.setLastCol(startCol + 26);
|
||||
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 27);
|
||||
pullDown.setLastCol(startCol + 27);
|
||||
pullDown.setStrings(Stream.iterate(1, x -> x + 1).limit(10).map(String::valueOf).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
@@ -1564,7 +1577,22 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
contrastDevExcels.forEach(contrastDevExcel -> {
|
||||
List<PqMonitor> monitorList = pqMonitorService.listPqMonitorByDevIds(Collections.singletonList(contrastDevExcel.getId()));
|
||||
pqMonitorService.visualizeMonitor(monitorList);
|
||||
List<PqMonitorExcel> pqMonitorExcelList = BeanUtil.copyToList(monitorList, PqMonitorExcel.class);
|
||||
List<PqMonitorExcel> pqMonitorExcelList = new ArrayList<>();
|
||||
for (int i = 0; i < monitorList.size(); i++) {
|
||||
PqMonitor pqMonitor = monitorList.get(i);
|
||||
PqMonitorExcel pqMonitorExcel = BeanUtil.copyProperties(pqMonitor, PqMonitorExcel.class);
|
||||
String pt = pqMonitor.getPt();
|
||||
String[] split1 = pt.split(String.valueOf(StrUtil.C_COLON));
|
||||
pqMonitorExcel.setPt1(split1[0]);
|
||||
pqMonitorExcel.setPt2(split1[1]);
|
||||
|
||||
String ct = pqMonitor.getCt();
|
||||
String[] split2 = ct.split(String.valueOf(StrUtil.C_COLON));
|
||||
pqMonitorExcel.setCt1(split2[0]);
|
||||
pqMonitorExcel.setCt2(split2[1]);
|
||||
|
||||
pqMonitorExcelList.add(pqMonitorExcel);
|
||||
}
|
||||
contrastDevExcel.setPqMonitorExcelList(pqMonitorExcelList);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.mapper.PqStandardDevGainRecordMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||
import com.njcn.gather.device.service.IPqStandardDevGainRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqStandardDevGainRecordServiceImpl extends ServiceImpl<PqStandardDevGainRecordMapper, PqStandardDevGainRecord> implements IPqStandardDevGainRecordService {
|
||||
|
||||
@Override
|
||||
public int getMaxNum(String stdDevMonitorId, String devMonitorId) {
|
||||
return this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, stdDevMonitorId)
|
||||
.eq(PqStandardDevGainRecord::getDevMonitorId, devMonitorId)
|
||||
.list().stream().mapToInt(PqStandardDevGainRecord::getNum).max().orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOrUpdate(List<PqStandardDevGainRecord> recordList) {
|
||||
recordList.forEach(record -> {
|
||||
List<PqStandardDevGainRecord> list = this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId())
|
||||
.eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId()).list();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.lambdaUpdate().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId())
|
||||
.eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId())
|
||||
.set(PqStandardDevGainRecord::getNum, record.getNum()).update();
|
||||
} else {
|
||||
this.save(record);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.mapper.PqStandardDevGainMapper;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2026-01-12
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqStandardDevGainServiceImpl extends ServiceImpl<PqStandardDevGainMapper, PqStandardDevGain> implements IPqStandardDevGainService {
|
||||
|
||||
@Override
|
||||
public boolean add(List<PqStandardDevGain> pqStandardDevGainList) {
|
||||
log.info("add PqStandardDevGainList: {}", pqStandardDevGainList.size());
|
||||
List<String> stdMonitorIdList = pqStandardDevGainList.stream().map(PqStandardDevGain::getStdDevMonitorId).distinct().collect(Collectors.toList());
|
||||
List<String> existingStdMonitorIdList = this.listByIds(stdMonitorIdList).stream().map(PqStandardDevGain::getStdDevMonitorId).collect(Collectors.toList());
|
||||
|
||||
pqStandardDevGainList = pqStandardDevGainList.stream().filter(pqStandardDevGain -> !existingStdMonitorIdList.contains(pqStandardDevGain.getStdDevMonitorId())).collect(Collectors.toList());
|
||||
return this.saveBatch(pqStandardDevGainList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqStandardDevGain get(String stdDevMonitorId) {
|
||||
return this.lambdaQuery().eq(PqStandardDevGain::getStdDevMonitorId, stdDevMonitorId).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqStandardDevGain> list(String stdDevId) {
|
||||
return this.lambdaQuery().likeRight(PqStandardDevGain::getStdDevMonitorId, stdDevId).orderByAsc(PqStandardDevGain::getStdDevMonitorId).list();
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,11 @@ import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.gather.device.mapper.PqStandardDevMapper;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||
import com.njcn.gather.plan.service.IAdPlanStandardDevService;
|
||||
@@ -58,8 +61,7 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
|
||||
private final IAdPlanStandardDevService adPlanStandardDevService;
|
||||
private final IPqStandardDevGainService pqStandardDevGainService;
|
||||
|
||||
@Override
|
||||
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
||||
@@ -73,13 +75,17 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqStandardDev getPqStandardDevById(String id) {
|
||||
public PqStandardDevVO getPqStandardDevById(String id) {
|
||||
PqStandardDev standardDev = this.getById(id);
|
||||
PqStandardDevVO pqStandardDevVO = BeanUtil.copyProperties(standardDev, PqStandardDevVO.class);
|
||||
if (standardDev.getEncryptionFlag() == 1) {
|
||||
standardDev.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
|
||||
standardDev.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
|
||||
pqStandardDevVO.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
|
||||
pqStandardDevVO.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
|
||||
}
|
||||
return standardDev;
|
||||
|
||||
List<PqStandardDevGain> gainList = pqStandardDevGainService.list(id);
|
||||
pqStandardDevVO.setGainList(gainList);
|
||||
return pqStandardDevVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PqIcdPathController extends BaseController {
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated PqIcdPathParam param) {
|
||||
public HttpResult<Boolean> add(PqIcdPathParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class PqIcdPathController extends BaseController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改icd")
|
||||
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
|
||||
public HttpResult<Boolean> update(PqIcdPathParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.icd.pojo.enums;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-11-11
|
||||
*/
|
||||
public enum IcdResponseEnum {
|
||||
FILE_NOT_NULL("A018001", "映射文件不能为空"),
|
||||
FILE_TYPE_ERROR("A018002", "映射文件类型错误"),
|
||||
FILE_SIZE_ERROR("A018003", "映射文件大小超出限制");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
IcdResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
@@ -32,6 +33,9 @@ public class PqIcdPathParam {
|
||||
@ApiModelProperty(value = "角型接线时是否使用相别的指标来进行检测,0表示否,1表示是", required = true)
|
||||
private Integer usePhaseIndex;
|
||||
|
||||
@ApiModelProperty(value = "映射文件", required = true)
|
||||
private MultipartFile mappingFile;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.icd.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
@@ -46,5 +47,18 @@ public class PqIcdPath extends BaseEntity implements Serializable {
|
||||
* 角型接线时是否使用相别的指标来进行检测,0表示否,1表示是
|
||||
*/
|
||||
private Integer usePhaseIndex;
|
||||
|
||||
/**
|
||||
* 映射文件路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private FileVO mappingFile;
|
||||
|
||||
@Data
|
||||
public static class FileVO{
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.icd.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -7,17 +8,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||
import com.njcn.gather.icd.pojo.enums.IcdResponseEnum;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -41,6 +51,13 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
||||
.orderByDesc(PqIcdPath::getCreateTime);
|
||||
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
page.getRecords().forEach(pqIcdPath -> {
|
||||
PqIcdPath.FileVO fileVO = new PqIcdPath.FileVO();
|
||||
fileVO.setUrl(commInstallPath + "\\DeviceControl\\Config\\" + pqIcdPath.getName() + ".txt");
|
||||
fileVO.setName(pqIcdPath.getName() + ".txt");
|
||||
pqIcdPath.setMappingFile(fileVO);
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -52,9 +69,81 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
System.out.println("commInstallPath = " + commInstallPath);
|
||||
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||
MultipartFile mappingFile = param.getMappingFile();
|
||||
|
||||
System.out.println("mappingFile = " + ObjectUtil.isNotNull(mappingFile) + " " + !mappingFile.isEmpty());
|
||||
if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||
String mappingFilename = mappingFile.getOriginalFilename();
|
||||
|
||||
if (!mappingFilename.endsWith(".txt")) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||
}
|
||||
if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果文件存在,则先删除
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + mappingFilename;
|
||||
System.out.println("mappingFilePath = " + mappingFilePath);
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
byte[] bytes = mappingFile.getBytes();
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||
bufferedOutputStream.write(bytes);
|
||||
bufferedOutputStream.flush();
|
||||
|
||||
bufferedOutputStream.close();
|
||||
System.out.println("File saved successfully");
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||
}
|
||||
} else {
|
||||
System.out.println("mappingFile is null or empty");
|
||||
throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL);
|
||||
}
|
||||
|
||||
this.executeRestartCmd(commInstallPath);
|
||||
|
||||
return this.save(pqIcdPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行重启通讯服务脚本
|
||||
*
|
||||
* @param commInstallPath
|
||||
*/
|
||||
private void executeRestartCmd(String commInstallPath) {
|
||||
// 以管理员身份运行bat脚本
|
||||
String batFilePath = commInstallPath + "\\重启所有服务.bat";
|
||||
try {
|
||||
Runtime.getRuntime().exec(batFilePath);
|
||||
} catch (IOException e) {
|
||||
log.error("重启通讯服务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCommInstallPath() {
|
||||
String workDir = System.getProperty("user.dir");
|
||||
// String workDir = "D:\\program\\CN_Gather";
|
||||
// 获取映射文件存放文件夹
|
||||
String dirPath = workDir + "\\9100";
|
||||
int index = workDir.indexOf("\\resources\\extraResources\\java");
|
||||
if (index != -1) {
|
||||
dirPath = workDir.substring(0, workDir.indexOf("\\resources\\extraResources\\java")) + "\\9100";
|
||||
}
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
@@ -62,12 +151,60 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||
MultipartFile mappingFile = param.getMappingFile();
|
||||
if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||
String mappingFilename = mappingFile.getOriginalFilename();
|
||||
|
||||
if (!mappingFilename.endsWith(".txt")) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||
}
|
||||
if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||
throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
// 如果文件存在,则先删除
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + mappingFilename;
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
byte[] bytes = mappingFile.getBytes();
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||
bufferedOutputStream.write(bytes);
|
||||
bufferedOutputStream.flush();
|
||||
|
||||
bufferedOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
this.executeRestartCmd(commInstallPath);
|
||||
|
||||
return this.updateById(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteIcd(List<String> ids) {
|
||||
List<PqIcdPath> pqIcdPaths = this.listByIds(ids);
|
||||
String commInstallPath = this.getCommInstallPath();
|
||||
pqIcdPaths.forEach(pqIcdPath -> {
|
||||
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config\\" + pqIcdPath.getName() + ".txt";
|
||||
Path path = Paths.get(mappingFilePath);
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
});
|
||||
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class PqMonitorExcel {
|
||||
|
||||
@Excel(name = "谐波系统监测点ID*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
|
||||
@Excel(name = "谐波系统监测点ID", width = 20, orderNum = "1")
|
||||
// @NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@Excel(name = "所属母线*", width = 20, orderNum = "2")
|
||||
@Excel(name = "母线名称*", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String busbar;
|
||||
|
||||
@@ -30,19 +30,27 @@ public class PqMonitorExcel {
|
||||
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
|
||||
private Integer num;
|
||||
|
||||
@Excel(name = "PT变比(pt1:pt2)*", width = 20, orderNum = "5")
|
||||
@Excel(name = "PT一次变比*", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt;
|
||||
private String pt1;
|
||||
|
||||
@Excel(name = "CT变比(ct1:ct2)*", width = 20, orderNum = "6")
|
||||
@Excel(name = "PT二次变比*", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
|
||||
private String pt2;
|
||||
|
||||
@Excel(name = "CT一次变比*", width = 20, orderNum = "7")
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct;
|
||||
private String ct1;
|
||||
|
||||
@Excel(name = "接线方式*", width = 20, orderNum = "7")
|
||||
@Excel(name = "CT二次变比*", width = 20, orderNum = "8")
|
||||
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
|
||||
private String ct2;
|
||||
|
||||
@Excel(name = "接线方式*", width = 20, orderNum = "9")
|
||||
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
|
||||
private String connection;
|
||||
|
||||
@Excel(name = "统计间隔*", width = 10, orderNum = "8")
|
||||
@Excel(name = "统计间隔*", width = 20, orderNum = "10")
|
||||
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
|
||||
private Integer statInterval;
|
||||
}
|
||||
|
||||
@@ -118,4 +118,11 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
* @return
|
||||
*/
|
||||
boolean removeByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 根据被检设备id和监测点编号获取监测点信息
|
||||
* @param devId 设备id
|
||||
* @param monitorNum 监测点编号
|
||||
*/
|
||||
PqMonitor getByDevIdAndNum(String devId, int monitorNum);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
if (ObjectUtil.isNotNull(pqMonitor)) {
|
||||
BeanUtil.copyProperties(monitorList.get(0), pqMonitor, "id", "realtimeResult", "statisticsResult", "recordedResult", "realtimeNum", "statisticsNum", "recordedNum", "resultType", "qualifiedNum");
|
||||
newMonitorList.add(pqMonitor);
|
||||
existedMonitorList.remove(pqMonitor);
|
||||
} else {
|
||||
newMonitorList.addAll(monitorList);
|
||||
}
|
||||
@@ -135,35 +136,40 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
|
||||
// 同步更新计划的状态
|
||||
AdPlan plan = this.baseMapper.getPlanByDevId(devId);
|
||||
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
|
||||
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
||||
List<PqDevSub> checkingDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKING.getValue()).collect(Collectors.toList());
|
||||
if (checkedDevSubList.size() == devSubList.size() && devSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
||||
} else if (checkedDevSubList.size() > 0 || checkingDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
||||
if (accordDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.ACCORD.getValue());
|
||||
} else if (accordDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.UNCHECKED.getValue());
|
||||
}
|
||||
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
||||
|
||||
List<PqDevSub> generatedDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getReportState() == DevReportStateEnum.GENERATED.getValue()).collect(Collectors.toList());
|
||||
if (generatedDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getValue());
|
||||
} else if (generatedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
||||
List<PqDevSub> checkingDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKING.getValue()).collect(Collectors.toList());
|
||||
if (checkedDevSubList.size() == devSubList.size() && devSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
||||
} else if (checkedDevSubList.size() > 0 || checkingDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
||||
if (accordDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.ACCORD.getValue());
|
||||
} else if (accordDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckResult(plan.getId(), CheckResultEnum.UNCHECKED.getValue());
|
||||
}
|
||||
|
||||
List<PqDevSub> generatedDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getReportState() == DevReportStateEnum.GENERATED.getValue()).collect(Collectors.toList());
|
||||
if (generatedDevSubList.size() == checkedDevSubList.size() && checkedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getValue());
|
||||
} else if (generatedDevSubList.size() > 0) {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
}
|
||||
}
|
||||
this.removeByIds(existedMonitorList.stream().map(PqMonitor::getId).collect(Collectors.toList()));
|
||||
return this.saveOrUpdateBatch(newMonitorList);
|
||||
}
|
||||
|
||||
@@ -432,4 +438,16 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
return this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqMonitor getByDevIdAndNum(String devId, int monitorNum) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId)
|
||||
.eq("pq_monitor.Num", monitorNum);
|
||||
List<PqMonitor> pqMonitors = this.list(wrapper);
|
||||
if (CollUtil.isNotEmpty(pqMonitors)) {
|
||||
return pqMonitors.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,6 +554,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
child.put("pid", adPlan.getFatherPlanId());
|
||||
child.put("name", adPlan.getName());
|
||||
child.put("timeCheck", adPlan.getTimeCheck());
|
||||
child.put("dataRule", adPlan.getDataRule());
|
||||
|
||||
List<PqStandardDev> pqStandardDevs = adPlanStandardDevMapper.listByPlanId(Collections.singletonList(adPlan.getId()));
|
||||
List<String> devTypeIdList = pqStandardDevs.stream().map(PqStandardDev::getDevType).collect(Collectors.toList());
|
||||
@@ -1264,7 +1265,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
for (int i = 1; i <= maxTime; i++) {
|
||||
row2[i] = i + "次检测";
|
||||
int tempI = i;
|
||||
List<PqDevVO> tempDevList = devList.stream().filter(dev -> dev.getRecheckNum() <= tempI).collect(Collectors.toList());
|
||||
List<PqDevVO> tempDevList = devList.stream().filter(dev -> dev.getRecheckNum() == tempI).collect(Collectors.toList());
|
||||
long passCount = tempDevList.stream().filter(dev -> dev.getCheckResult() == CheckResultEnum.ACCORD.getValue()).count();
|
||||
row3[i] = passCount + "";
|
||||
row4[i] = total + "";
|
||||
@@ -1554,8 +1555,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
// 检测脚本
|
||||
List<Map<String, Object>> maps1 = pqScriptService.listAllPqScript(null);
|
||||
List<String> scriptNameList = maps1.stream().map(m -> (String) m.get("name")).collect(Collectors.toList());
|
||||
List<PqScript> pqScriptList = pqScriptService.listAllPqScript(null);
|
||||
List<String> scriptNameList = pqScriptList.stream().map(m -> m.getName()).collect(Collectors.toList());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(3);
|
||||
pullDown.setLastCol(3);
|
||||
@@ -1721,8 +1722,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
String zipFileName = URLEncoder.encode(subPlan.getName() + ".zip", "UTF-8");
|
||||
File zipFile = FileUtil.file(tempDir, zipFileName);
|
||||
|
||||
// 先将json文件添加到zip中
|
||||
ZipUtil.zip(jsonFile.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 先将json文件添加到zip中(使用UTF-8编码)
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, jsonFile);
|
||||
|
||||
|
||||
// 创建一个临时目录存放两个文件
|
||||
@@ -1744,8 +1745,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
|
||||
// 重新创建zip文件,包含所有文件
|
||||
ZipUtil.zip(tempZipDir.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 重新创建zip文件,包含所有文件,使用UTF-8编码
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, FileUtil.file(tempZipDir));
|
||||
|
||||
// 删除临时目录
|
||||
FileUtil.del(tempZipDir);
|
||||
@@ -1779,9 +1780,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
File zipFile = FileUtil.file(tempDir, file.getOriginalFilename());
|
||||
file.transferTo(zipFile);
|
||||
|
||||
// 解压zip文件
|
||||
// 解压zip文件,使用UTF-8编码
|
||||
File unzipDir = FileUtil.mkdir(FileUtil.file(tempDir, "unzip"));
|
||||
ZipUtil.unzip(zipFile.getAbsolutePath(), unzipDir.getAbsolutePath());
|
||||
ZipUtil.unzip(zipFile, unzipDir, CharsetUtil.CHARSET_UTF_8);
|
||||
|
||||
// 查找解压目录中的json文件
|
||||
File[] files = unzipDir.listFiles();
|
||||
@@ -2099,8 +2100,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
}
|
||||
|
||||
// 重新创建zip文件,包含所有文件
|
||||
ZipUtil.zip(tempZipDir.getAbsolutePath(), zipFile.getAbsolutePath());
|
||||
// 重新创建zip文件,包含所有文件,使用UTF-8编码
|
||||
ZipUtil.zip(zipFile, CharsetUtil.CHARSET_UTF_8, false, FileUtil.file(tempZipDir));
|
||||
|
||||
// 删除临时目录
|
||||
FileUtil.del(tempZipDir);
|
||||
|
||||
@@ -39,7 +39,10 @@ public enum BaseReportKeyEnum {
|
||||
CREATE_DATE("createDate","生产日期"),
|
||||
TEMPERATURE("temp","温度"),
|
||||
HUMIDITY("hum","相对湿度"),
|
||||
DELEGATE("delegate","委托方");
|
||||
DELEGATE("delegate","委托方"),
|
||||
CREATEDATE("createDate","出厂日期"),
|
||||
HW_VERSION("hardwareVersion","硬件版本"),
|
||||
SW_VERSION("softwareVersion","软件版本");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.IPqDevSubService;
|
||||
import com.njcn.gather.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
@@ -59,6 +61,7 @@ import com.njcn.gather.report.service.IPqReportService;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||
@@ -86,6 +89,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
@@ -113,6 +117,7 @@ import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -162,6 +167,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
@Value("${qr.gcDev.path}")
|
||||
private String gcDevPath;
|
||||
|
||||
@Value("${report.dateFormat}")
|
||||
private String dateFormat;
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
private final PqDevMapper pqDevMapper;
|
||||
@@ -179,6 +186,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private final ISysUserService sysUserService;
|
||||
private final IPqErrSysService pqErrSysService;
|
||||
private final IAdPlanTestConfigService adPlanTestConfigService;
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
|
||||
@Resource
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
@@ -307,7 +315,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) {
|
||||
MultipartFile baseFile = reportParam.getBaseFile();
|
||||
MultipartFile detailFile = reportParam.getDetailFile();
|
||||
String newDir = templatePath + File.separator + reportParam.getName() + File.separator + reportParam.getVersion() + File.separator;
|
||||
String relativePath = reportParam.getName() + File.separator + reportParam.getVersion() + File.separator;
|
||||
String newDir = templatePath + File.separator + relativePath;
|
||||
|
||||
long FILE_SIZE_LIMIT = 5 * 1024 * 1024;
|
||||
if (isAdd) {
|
||||
@@ -326,13 +335,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
|
||||
pqReport.setBasePath(newDir + baseOriginalFilename);
|
||||
pqReport.setDetailPath(newDir + detailOriginalFilename);
|
||||
pqReport.setBasePath(relativePath + baseOriginalFilename);
|
||||
pqReport.setDetailPath(relativePath + detailOriginalFilename);
|
||||
|
||||
this.createDirectory(newDir);
|
||||
this.clearDirectory(newDir);
|
||||
this.uploadFile(baseFile, pqReport.getBasePath());
|
||||
this.uploadFile(detailFile, pqReport.getDetailPath());
|
||||
this.uploadFile(baseFile, newDir + baseOriginalFilename);
|
||||
this.uploadFile(detailFile, newDir + detailOriginalFilename);
|
||||
} else {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL);
|
||||
}
|
||||
@@ -380,34 +389,34 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
//若修改了文件名称、版本号,则需要重命名文件
|
||||
this.createDirectory(newDir);
|
||||
if (!oldDir.equals(newDir)) {
|
||||
if (!oldDir.equals(relativePath)) {
|
||||
// 文件夹重命名
|
||||
String oldBasePathStr = oldPqReport.getBasePath();
|
||||
String baseName = oldBasePathStr.substring(oldBasePathStr.lastIndexOf(File.separator) + 1);
|
||||
Path oldBasePath = Paths.get(oldBasePathStr);
|
||||
Path oldBasePath = Paths.get(templatePath + File.separator + oldBasePathStr);
|
||||
Path newBasePath = Paths.get(newDir + baseName);
|
||||
pqReport.setBasePath(newDir + baseName);
|
||||
pqReport.setBasePath(relativePath + baseName);
|
||||
|
||||
String oldDetailPathStr = oldPqReport.getDetailPath();
|
||||
String detailName = oldDetailPathStr.substring(oldDetailPathStr.lastIndexOf(File.separator) + 1);
|
||||
Path oldDetailPath = Paths.get(oldDetailPathStr);
|
||||
Path oldDetailPath = Paths.get(templatePath + File.separator + oldDetailPathStr);
|
||||
Path newDetailPath = Paths.get(newDir + detailName);
|
||||
pqReport.setDetailPath(newDir + detailName);
|
||||
pqReport.setDetailPath(relativePath + detailName);
|
||||
|
||||
try {
|
||||
// windows下文件夹名称不区分大小写
|
||||
if (!oldDir.equalsIgnoreCase(newDir)) {
|
||||
if (!oldDir.equalsIgnoreCase(relativePath)) {
|
||||
this.clearDirectory(newDir);
|
||||
Files.move(oldBasePath, newBasePath);
|
||||
Files.move(oldDetailPath, newDetailPath);
|
||||
if (!oldPqReport.getName().equals(reportParam.getName()) && !this.existSameName(pqReport.getId(), oldPqReport.getName())) {
|
||||
this.recursionDeleteDirectory(templatePath + File.separator + oldPqReport.getName());
|
||||
} else {
|
||||
Paths.get(oldDir).toFile().delete();
|
||||
Paths.get(templatePath + oldDir).toFile().delete();
|
||||
}
|
||||
} else {
|
||||
// 文件夹重命名
|
||||
Paths.get(oldDir).toFile().renameTo(Paths.get(newDir).toFile());
|
||||
Paths.get(templatePath + oldDir).toFile().renameTo(Paths.get(newDir).toFile());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ReportResponseEnum.FILE_RENAME_FAILED);
|
||||
@@ -415,16 +424,16 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
}
|
||||
|
||||
if (!baseFileOriginalFilename.isEmpty()) {
|
||||
pqReport.setBasePath(newDir + baseFileOriginalFilename);
|
||||
Paths.get(oldPqReport.getBasePath()).toFile().delete();
|
||||
pqReport.setBasePath(relativePath + baseFileOriginalFilename);
|
||||
Paths.get(templatePath + File.separator + oldPqReport.getBasePath()).toFile().delete();
|
||||
Paths.get(newDir + oldPqReport.getBasePath().substring(oldPqReport.getBasePath().lastIndexOf(File.separator) + 1)).toFile().delete();
|
||||
this.uploadFile(baseFile, pqReport.getBasePath());
|
||||
this.uploadFile(baseFile, newDir + baseFileOriginalFilename);
|
||||
}
|
||||
if (!detailFileOriginalFilename.isEmpty()) {
|
||||
pqReport.setDetailPath(newDir + detailFileOriginalFilename);
|
||||
Paths.get(oldPqReport.getDetailPath()).toFile().delete();
|
||||
pqReport.setDetailPath(relativePath + detailFileOriginalFilename);
|
||||
Paths.get(templatePath + File.separator + oldPqReport.getDetailPath()).toFile().delete();
|
||||
Paths.get(newDir + oldPqReport.getDetailPath().substring(oldPqReport.getDetailPath().lastIndexOf(File.separator) + 1)).toFile().delete();
|
||||
this.uploadFile(detailFile, pqReport.getDetailPath());
|
||||
this.uploadFile(detailFile, newDir + detailFileOriginalFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -786,53 +795,63 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
if (Objects.isNull(pqDevVO)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_NOT_EXIST);
|
||||
}
|
||||
devReportParam.setDevId(devId);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_TYPE_NOT_EXIST);
|
||||
}
|
||||
PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getReportTemplateId()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(report.getBasePath());
|
||||
Path detailPath = Paths.get(report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
// 获取文档基础部分,并替换占位符
|
||||
Map<String, String> baseModelDataMap = dealBaseModelContrastData(plan, pqDevVO, devType);
|
||||
InputStream wordFinishInputStream = wordReportService.replacePlaceholders(baseInputStream, baseModelDataMap);
|
||||
WordprocessingMLPackage baseModelDocument = WordprocessingMLPackage.load(wordFinishInputStream);
|
||||
MainDocumentPart baseDocumentPart = baseModelDocument.getMainDocumentPart();
|
||||
if (CheckStateEnum.CHECKED.getValue().compareTo(pqDevVO.getCheckState()) <= 0) {
|
||||
devReportParam.setDevId(devId);
|
||||
// 获取设备型号
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (Objects.isNull(devType)) {
|
||||
throw new BusinessException(ReportResponseEnum.DEVICE_TYPE_NOT_EXIST);
|
||||
}
|
||||
PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getReportTemplateId()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(templatePath + File.separator + report.getBasePath());
|
||||
Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
// 获取文档基础部分,并替换占位符
|
||||
Map<String, String> baseModelDataMap = dealBaseModelContrastData(plan, pqDevVO, devType);
|
||||
InputStream wordFinishInputStream = wordReportService.replacePlaceholders(baseInputStream, baseModelDataMap);
|
||||
WordprocessingMLPackage baseModelDocument = WordprocessingMLPackage.load(wordFinishInputStream);
|
||||
MainDocumentPart baseDocumentPart = baseModelDocument.getMainDocumentPart();
|
||||
|
||||
// 获取数据模版页内容,根据脚本动态组装数据页内容
|
||||
MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart();
|
||||
dealDataModelScatteredByBookmarkByPlanContrast(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// 保存新的文档
|
||||
String dirPath = reportPath.concat(File.separator).concat(plan.getName());
|
||||
// 确保目录存在
|
||||
ensureDirectoryExists(dirPath);
|
||||
// 构建文件名:cityName_gdName_subName_name.docx
|
||||
String fileName = String.format("%s_%s_%s_%s.docx",
|
||||
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
|
||||
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
|
||||
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
|
||||
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
|
||||
Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument);
|
||||
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName)));
|
||||
this.updateDevAndPlanState(devId, devReportParam.getPlanId());
|
||||
} catch (NoSuchFileException e) {
|
||||
String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件";
|
||||
log.error("报告模板文件不存在 - 文件路径: {}", filePath, e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
log.error("报告文件读写异常", e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||
// 获取数据模版页内容,根据脚本动态组装数据页内容
|
||||
MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart();
|
||||
dealDataModelScatteredByBookmarkByPlanContrast(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO);
|
||||
// 保存新的文档
|
||||
String dirPath = reportPath.concat(File.separator).concat(plan.getName());
|
||||
// 确保目录存在
|
||||
ensureDirectoryExists(dirPath);
|
||||
// 构建文件名:cityName_gdName_subName_name.docx
|
||||
String fileName = String.format("%s_%s_%s_%s.docx",
|
||||
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
|
||||
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
|
||||
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
|
||||
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
|
||||
// 判断是否需要在报告上输出水印
|
||||
String leader = baseModelDataMap.get(BaseReportKeyEnum.AUDIT_BY.getKey());
|
||||
String loginName = RequestUtil.getLoginNameByToken();
|
||||
SysUser user = sysUserService.getUserByLoginName(loginName);
|
||||
if (!leader.equals(user.getName())) {
|
||||
log.info("当前用户不是审核人,添加非正式水印");
|
||||
Docx4jUtil.addWatermarkToDocument(baseModelDocument, "非正式");
|
||||
}
|
||||
Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument);
|
||||
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName)));
|
||||
this.updateDevAndPlanState(devId, devReportParam.getPlanId());
|
||||
} catch (NoSuchFileException e) {
|
||||
String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件";
|
||||
log.error("报告模板文件不存在 - 文件路径: {}", filePath, e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
log.error("报告文件读写异常", e);
|
||||
throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -864,8 +883,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
if (Objects.isNull(report)) {
|
||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
Path basePath = Paths.get(report.getBasePath());
|
||||
Path detailPath = Paths.get(report.getDetailPath());
|
||||
Path basePath = Paths.get(templatePath + File.separator + report.getBasePath());
|
||||
Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath());
|
||||
try (InputStream baseInputStream = Files.newInputStream(basePath);
|
||||
InputStream detailInputStream = Files.newInputStream(detailPath)) {
|
||||
WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);
|
||||
@@ -1154,10 +1173,11 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
Integer monitorNum = next.getKey();
|
||||
// 线路下的指标数据
|
||||
List<ContrastTestResult> contrastTestResults = next.getValue();
|
||||
PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum);
|
||||
// 插入回路号前,先换个页
|
||||
todoInsertList.add(Docx4jUtil.createPageBreakParagraph());
|
||||
// 回路标题
|
||||
todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory));
|
||||
todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory, pqDevVO));
|
||||
int scriptIndex = 1;
|
||||
for (ContrastTestResult contrastTestResult : contrastTestResults) {
|
||||
// 比如电压 V
|
||||
@@ -1168,7 +1188,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 根据code获取对应需要填充的内容
|
||||
List<Docx4jUtil.HeadingContent> tempContent = contentMap.get(scriptCode);
|
||||
// 需要区分下谐波类和非谐波类
|
||||
List<Object> tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult);
|
||||
List<Object> tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult, pqMonitor);
|
||||
todoInsertList.addAll(tempList);
|
||||
scriptIndex++;
|
||||
}
|
||||
@@ -1586,18 +1606,37 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
|
||||
// 获取现有行的样式
|
||||
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
|
||||
|
||||
// 获取现有样式
|
||||
TrPr trPr = existingRow.getTrPr();
|
||||
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
|
||||
TcPr tcPr = element.getValue().getTcPr();
|
||||
TblWidth cellWidth = factory.createTblWidth();
|
||||
cellWidth.setType("dxa");
|
||||
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
|
||||
tcPr.setTcW(cellWidth);
|
||||
// 获取每个单元格的TcPr(保留各单元格独立的边框设置)
|
||||
List<TcPr> tcPrList = new ArrayList<>();
|
||||
RPr templateRPr = null;
|
||||
for (Object cellObj : existingRow.getContent()) {
|
||||
if (cellObj instanceof JAXBElement) {
|
||||
JAXBElement<Tc> cellElement = (JAXBElement<Tc>) cellObj;
|
||||
Tc templateCell = cellElement.getValue();
|
||||
TcPr tcPr = templateCell.getTcPr();
|
||||
// 设置单元格宽度
|
||||
if (tcPr == null) {
|
||||
tcPr = factory.createTcPr();
|
||||
}
|
||||
TblWidth cellWidth = factory.createTblWidth();
|
||||
cellWidth.setType("dxa");
|
||||
cellWidth.setW(BigInteger.valueOf(5000 / tableKeys.size()));
|
||||
tcPr.setTcW(cellWidth);
|
||||
tcPrList.add(tcPr);
|
||||
// 从第一个单元格获取字体样式
|
||||
if (templateRPr == null && !templateCell.getContent().isEmpty() && templateCell.getContent().get(0) instanceof P) {
|
||||
P templateP = (P) templateCell.getContent().get(0);
|
||||
templateRPr = Docx4jUtil.getTcPrFromParagraph(templateP);
|
||||
}
|
||||
}
|
||||
}
|
||||
tbl.getContent().remove(existingRow);
|
||||
// 迭代增加行,需要填充的表格keys在tableKeys集合中
|
||||
for (Map<String, String> stringStringMap : dataList) {
|
||||
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPr, true);
|
||||
Tr newRow = Docx4jUtil.createCustomRow(factory, stringStringMap, tableKeys, trPr, tcPrList, templateRPr, true);
|
||||
tbl.getContent().add(newRow);
|
||||
}
|
||||
} else {
|
||||
@@ -1624,7 +1663,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<Object> fillContentInTemplateContrast(List<Docx4jUtil.HeadingContent> tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult) {
|
||||
private List<Object> fillContentInTemplateContrast(List<Docx4jUtil.HeadingContent> tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult, PqMonitor pqMonitor) {
|
||||
List<Object> todoInsertList = new ArrayList<>();
|
||||
Docx4jUtil.HeadingContent headingContent = tempContent.get(0);
|
||||
List<String> tableKeys = Docx4jUtil.getTableFillKeys(tempContent);
|
||||
@@ -1738,9 +1777,47 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 纵向表格暂不考虑
|
||||
}
|
||||
|
||||
// 如果存在特殊说明,在表格后添加一个段落
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) {
|
||||
P specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase());
|
||||
StringBuilder description = new StringBuilder();
|
||||
if (contrastTestResult.getScriptCode().equalsIgnoreCase("I")) {
|
||||
// 获取该通道的额定电流
|
||||
String ct = pqMonitor.getCt();
|
||||
// 理论上ct是 xxx:xxx的格式。比如10:1,100:5
|
||||
if (ct.indexOf(":") > 0) {
|
||||
String[] ctArray = ct.split(":");
|
||||
description.append("注:当前回路额定电流为:").append(ctArray[1]).append("A。");
|
||||
}
|
||||
} else if (contrastTestResult.getScriptCode().equalsIgnoreCase("V")) {
|
||||
// 获取该通道的额定电压
|
||||
String pt = pqMonitor.getPt();
|
||||
// 理论上pt是 xxx:xxx的格式。比如380:380,10000:100
|
||||
if (pt.indexOf(":") > 0) {
|
||||
String[] ptArray = pt.split(":");
|
||||
// 电压需要特殊处理下,处理为相电压值
|
||||
String voltage = ptArray[1];
|
||||
if (voltage.equalsIgnoreCase("100")) {
|
||||
voltage = "57.74";
|
||||
} else if (voltage.equalsIgnoreCase("380")) {
|
||||
voltage = "220";
|
||||
} else {
|
||||
// 其他场景下就除以根号3
|
||||
double result = Double.parseDouble(voltage) / Math.sqrt(3);
|
||||
voltage = doubleRound(2, result);
|
||||
}
|
||||
description.append("注:当前回路额定电流为:").append(voltage).append("V。");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果存在特殊说明,在表格后添加一个段落 如果有电压和电流需要把额定电压和电流标注进来 pqMonitor
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase()) || StrUtil.isNotBlank(description.toString())) {
|
||||
P specialCaseP;
|
||||
if (StrUtil.isNotBlank(description.toString())) {
|
||||
if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) {
|
||||
description.append(contrastTestResult.getSpecialCase().replace("注:", ""));
|
||||
}
|
||||
specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, description.toString());
|
||||
} else {
|
||||
specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase());
|
||||
}
|
||||
todoInsertList.add(specialCaseP);
|
||||
}
|
||||
}
|
||||
@@ -1948,6 +2025,18 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
baseModelMap.put(BaseReportKeyEnum.DEV_TYPE.getKey(), devType.getName());
|
||||
// 检测员
|
||||
baseModelMap.put(BaseReportKeyEnum.INSPECTOR.getKey(), pqDevVO.getCheckBy() + "");
|
||||
baseModelMap.put(BaseReportKeyEnum.INSPECTOR.getKey(), pqDevVO.getCheckBy() + "");
|
||||
String datePattern = DatePattern.NORM_DATE_PATTERN;
|
||||
if (DatePattern.CHINESE_DATE_PATTERN.equals(dateFormat)) {
|
||||
datePattern = DatePattern.CHINESE_DATE_PATTERN;
|
||||
}
|
||||
|
||||
// 出厂日期
|
||||
baseModelMap.put(BaseReportKeyEnum.CREATEDATE.getKey(), pqDevVO.getCreateDate().format(DateTimeFormatter.ofPattern(datePattern)));
|
||||
// 硬件版本
|
||||
baseModelMap.put(BaseReportKeyEnum.HW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getHardwareVersion()) ? pqDevVO.getHardwareVersion() : StrUtil.EMPTY);
|
||||
// 软件版本
|
||||
baseModelMap.put(BaseReportKeyEnum.SW_VERSION.getKey(), StrUtil.isNotBlank(pqDevVO.getSoftwareVersion()) ? pqDevVO.getSoftwareVersion() : StrUtil.EMPTY);
|
||||
// 调试日期
|
||||
if (pqDevVO.getCheckTime() != null) {
|
||||
baseModelMap.put(BaseReportKeyEnum.TEST_DATE.getKey(), DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN));
|
||||
@@ -2016,7 +2105,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
// 委托方
|
||||
String delegate = pqDevVO.getDelegate();
|
||||
if (StrUtil.isNotBlank(delegate)) {
|
||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer());
|
||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getDelegate());
|
||||
if (ObjectUtil.isNotNull(delegateDictData)) {
|
||||
baseModelMap.put(BaseReportKeyEnum.DELEGATE.getKey(), delegateDictData.getName());
|
||||
} else {
|
||||
@@ -2088,7 +2177,19 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
private void dealDataModel(List<InputStream> wordFileInputStreams, DevReportParam devReportParam, PqDevVO pqDevVO) throws Exception {
|
||||
Integer devChns = pqDevVO.getDevChns();
|
||||
for (int i = 1; i <= devChns; i++) {
|
||||
ClassPathResource resource = new ClassPathResource("/model/report_table.docx");
|
||||
String path = "/model/report_table.docx";
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (devType.getName().equals("PQ-COM")) {
|
||||
path = "/model/report_table - PQ-COM.docx";
|
||||
}
|
||||
ClassPathResource resource = new ClassPathResource(path);
|
||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||
|
||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||
singleNonHarmParam.setPlanCode(devReportParam.getPlanCode());
|
||||
singleNonHarmParam.setDevId(pqDevVO.getId());
|
||||
singleNonHarmParam.setChannelNo(i);
|
||||
|
||||
// 获取数据
|
||||
Map<String, String> dataModelMap = new HashMap<>(16);
|
||||
// 读取模板文件中的占位符
|
||||
@@ -2106,11 +2207,20 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
List<SimAndDigHarmonicResult> adHarmonicResultList = adHarmonicService.listAllResultData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + i);
|
||||
|
||||
// 填充数据
|
||||
int finalI = i;
|
||||
indexKeysMap.forEach((index, keys) -> {
|
||||
String s1 = keys.stream().findFirst().get();
|
||||
// 谐波类
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(s1) || DetectionCodeEnum.I2_50.getCode().equals(s1) || DetectionCodeEnum.SV_1_49.getCode().equals(s1) || DetectionCodeEnum.SI_1_49.getCode().equals(s1)) {
|
||||
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index);
|
||||
// 查找一下U1
|
||||
double u1 = 57.74;
|
||||
List<SimAndDigHarmonicResult> rawData = adHarmonicService.listAllRawData(devReportParam.getScriptId(), devReportParam.getPlanCode(), devReportParam.getDevId() + "_" + finalI);
|
||||
SimAndDigHarmonicResult adHarmonicResult = rawData.stream().filter(obj -> obj.getAdType().equals(DetectionCodeEnum.V2_50.getCode())).sorted((obj1, obj2) -> obj2.getTimeId().compareTo(obj1.getTimeId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(adHarmonicResult)) {
|
||||
String aValue1 = adHarmonicResult.getAValue1();
|
||||
u1 = Double.parseDouble(aValue1);
|
||||
}
|
||||
fillMapValueHarm(adHarmonicResultList, dataModelMap, keys, index, u1);
|
||||
} else {
|
||||
// 非谐波类
|
||||
if (DetectionCodeEnum.V_UNBAN.getCode().equals(s1) || DetectionCodeEnum.FREQ.getCode().equals(s1)) {
|
||||
@@ -2178,14 +2288,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
* @param keys key
|
||||
* @param index index
|
||||
*/
|
||||
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index) {
|
||||
private void fillMapValueHarm(List<SimAndDigHarmonicResult> allHarmonicResultList, Map<String, String> dataModelMap, Set<String> keys, String index, double baseValue) {
|
||||
keys.forEach(key -> {
|
||||
List<SimAndDigHarmonicResult> resultList = allHarmonicResultList.stream().filter(obj -> obj.getAdType().equals(key) && obj.getSort().toString().equals(index)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(resultList)) {
|
||||
SimAndDigHarmonicResult adHarmonicResult = resultList.get(0);
|
||||
if (Objects.nonNull(adHarmonicResult)) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(key) || DetectionCodeEnum.SV_1_49.getCode().equals(key)) {
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, 57.74, 100);
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, baseValue, 100);
|
||||
}
|
||||
if (DetectionCodeEnum.I2_50.getCode().equals(key) || DetectionCodeEnum.SI_1_49.getCode().equals(key)) {
|
||||
fillHarm(dataModelMap, adHarmonicResult, index, key, 1, 1);
|
||||
@@ -2392,16 +2502,21 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
/**
|
||||
* 创建回路标题到报告中
|
||||
*/
|
||||
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory) {
|
||||
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) {
|
||||
PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum);
|
||||
String monitorInfoName = "";
|
||||
if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) {
|
||||
monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")";
|
||||
}
|
||||
List<Docx4jUtil.HeadingContent> headingContents = contentMap.get(PowerIndexEnum.LINE_TITLE.getKey());
|
||||
// 如果contentMap中有指定内容,创建大纲级别为2的标题
|
||||
if (CollUtil.isNotEmpty(headingContents)) {
|
||||
return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum,
|
||||
return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum + monitorInfoName,
|
||||
"SimSun", 30, true);
|
||||
}
|
||||
// 没有模板配置时,创建默认样式段落
|
||||
P titleParagraph = factory.createP();
|
||||
Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum,
|
||||
Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum + monitorInfoName,
|
||||
28, true);
|
||||
return titleParagraph;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ResultController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("getCheckItem");
|
||||
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, monitorQueryParam);
|
||||
List<ContrastTestItemVO> result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum());
|
||||
List<ContrastTestItemVO> result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum(), monitorQueryParam.getCode());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,6 @@ public class MonitorQueryParam {
|
||||
private Integer waveNum;
|
||||
|
||||
private String planId;
|
||||
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.result.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -74,6 +75,8 @@ public class ResultParam {
|
||||
|
||||
// 模式id
|
||||
private String patternId;
|
||||
|
||||
private String code;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -100,5 +103,11 @@ public class ResultParam {
|
||||
|
||||
@ApiModelProperty(value = "模式Id", required = true)
|
||||
private String patternId;
|
||||
|
||||
@ApiModelProperty(value = "通道号", required = true)
|
||||
private String chnNum;
|
||||
|
||||
@ApiModelProperty(value = "数据处理原则", required = true)
|
||||
private String dataRuleId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +123,10 @@ public interface IResultService {
|
||||
* @param devId
|
||||
* @param chnNum
|
||||
* @param num
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num);
|
||||
List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num,String code);
|
||||
|
||||
/**
|
||||
* 获取设备比对式结果,用于出比对检测的报告
|
||||
|
||||
@@ -146,11 +146,11 @@ public class ResultServiceImpl implements IResultService {
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
String scriptId = null;
|
||||
if (ObjectUtil.isNotNull(plan)) {
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
scriptId = plan.getScriptId();
|
||||
adPlanService.visualize(Collections.singletonList(plan));
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
}
|
||||
formContentVO.setScriptName(plan.getScriptId());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
|
||||
|
||||
List<Map<String, String>> chnList = new ArrayList<>();
|
||||
@@ -341,10 +341,19 @@ public class ResultServiceImpl implements IResultService {
|
||||
private void dipScriptTypeName(List<PqScriptDtls> subValue, List<TreeDataVO> subTypeList, Map<Integer, Set<Integer>> finalResultMap, Boolean isValueType, String name, Integer start, Integer end) {
|
||||
List<TreeDataVO> info = new ArrayList<>();
|
||||
List<PqScriptDtls> dip = subValue.stream()
|
||||
.filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
||||
// .filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
||||
.filter(x -> "Dip".equals(x.getValueType()))
|
||||
.filter(x -> x.getTransValue() >= start && x.getTransValue() <= end)
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
.collect(Collectors.toList());
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> idxDipMap = dip.stream().collect(Collectors.groupingBy(d -> d.getScriptIndex(), LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
dip.clear();
|
||||
idxDipMap.forEach((idx, scriptDtlList) -> {
|
||||
scriptDtlList.sort(Comparator.comparing(PqScriptDtls::getPhase));
|
||||
dip.add(scriptDtlList.get(0));
|
||||
});
|
||||
|
||||
TreeDataVO vo = new TreeDataVO();
|
||||
vo.setScriptTypeName(name);
|
||||
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
||||
@@ -983,10 +992,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
DictData dictData = dictDataService.getDictDataById(param.getPatternId());
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
this.createTempResultTable(param.getCode() + "_temp", true);
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId());
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId(), false, param.getDataRuleId());
|
||||
} else {
|
||||
this.createTempResultTable(param.getCode() + "_temp", false);
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId());
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId(), param.getDataRuleId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,9 +1009,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
public void reCalculate(ResultParam.ChangeErrorSystemParam param) {
|
||||
DictData dictData = dictDataService.getDictDataById(param.getPatternId());
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
this.contrastCalculateResult(param.getPlanId(), param.getCode(), param.getErrorSysId(), param.getDeviceId(), true, param.getDataRuleId());
|
||||
} else {
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
this.simAndDigCalculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId(), param.getDataRuleId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,8 +1542,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
PqDev dev = pqDevService.getById(queryParam.getDeviceId());
|
||||
DictData dictData = dictDataService.getById(plan.getDataRule());
|
||||
formContentVO.setDataRule(dictData.getName());
|
||||
formContentVO.setDataRule(plan.getDataRule());
|
||||
formContentVO.setDeviceName(dev.getName());
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
|
||||
@@ -1581,8 +1589,6 @@ public class ResultServiceImpl implements IResultService {
|
||||
public ContrastResultVO getContrastResult(ResultParam.QueryParam queryParam) {
|
||||
ContrastResultVO contrastResultVO = new ContrastResultVO();
|
||||
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
|
||||
List<DictTree> dictTreeList = dictTreeService.getDictTreeById(Collections.singletonList(queryParam.getScriptType()));
|
||||
|
||||
List<String> fatherIdList = dictTreeList.stream().map(DictTree::getId).collect(Collectors.toList());
|
||||
@@ -1604,8 +1610,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
|
||||
contrastResultVO.setResultMap(this.getResultMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), String.valueOf(plan.getCode())));
|
||||
contrastResultVO.setRawDataMap(this.getRawDataMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), String.valueOf(plan.getCode()), contrastResultVO.getResultMap().keySet().stream().collect(Collectors.toList())));
|
||||
contrastResultVO.setResultMap(this.getResultMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), queryParam.getCode()));
|
||||
contrastResultVO.setRawDataMap(this.getRawDataMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), unit, queryParam.getNum(), queryParam.getWaveNum(), queryParam.getIsWave(), queryParam.getCode(), contrastResultVO.getResultMap().keySet().stream().collect(Collectors.toList())));
|
||||
return contrastResultVO;
|
||||
}
|
||||
|
||||
@@ -1886,10 +1892,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num) {
|
||||
public List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num, String code) {
|
||||
// PqDev dev = pqDevService.getById(devId);
|
||||
AdPlan plan = adPlanService.getById(planId);
|
||||
String code = String.valueOf(plan.getCode());
|
||||
// String code = String.valueOf(plan.getCode());
|
||||
|
||||
String monitorId = devId + CnSocketUtil.SPLIT_TAG + chnNum;
|
||||
|
||||
@@ -2872,23 +2878,23 @@ public class ResultServiceImpl implements IResultService {
|
||||
for (int i = 0; i < devNonHarmonicRawDataList.size(); i++) {
|
||||
AlignDataVO.RawData rawDataVO = new AlignDataVO.RawData();
|
||||
rawDataVO.setUnit(unit);
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResult = devNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeDev(contrastNonHarmonicResult.getTimeId().format(dtf));
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResultDev = devNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeDev(contrastNonHarmonicResultDev.getTimeId().format(dtf));
|
||||
|
||||
rawDataVO.setUbDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUtDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
rawDataVO.setUbDev(getValue(contrastNonHarmonicResultDev.getBValue()));
|
||||
rawDataVO.setUtDev(getValue(contrastNonHarmonicResultDev.getTValue()));
|
||||
|
||||
contrastNonHarmonicResult = stdDevNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResult.getTimeId().format(dtf));
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
||||
if (!DicDataEnum.IMBV.getCode().equals(dictTree.getCode()) && !DicDataEnum.IMBA.getCode().equals(dictTree.getCode())) {
|
||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUcStdDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
||||
rawDataVO.setUcStdDev(getValue(contrastNonHarmonicResultStdDev.getCValue()));
|
||||
}
|
||||
|
||||
rawDataVO.setUbStdDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUtStdDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
rawDataVO.setUbStdDev(getValue(contrastNonHarmonicResultStdDev.getBValue()));
|
||||
rawDataVO.setUtStdDev(getValue(contrastNonHarmonicResultStdDev.getTValue()));
|
||||
|
||||
rawDataVOList.add(rawDataVO);
|
||||
}
|
||||
@@ -3067,7 +3073,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param errorSysId
|
||||
* @param devId
|
||||
*/
|
||||
private void simAndDigCalculateResult(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
private void simAndDigCalculateResult(String planId, String scriptId, String code, String errorSysId, String devId, String dataRuleId) {
|
||||
String oldCode = code.replace("_temp", "");
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setCode(code);
|
||||
@@ -3085,8 +3091,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
// } else {
|
||||
// dataRule = DictDataEnum.SECTION_VALUE;
|
||||
// }
|
||||
AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
// AdPlan plan = adPlanService.getById(planId);
|
||||
DictData dictData = dictDataService.getDictDataById(dataRuleId);
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
@@ -3144,8 +3150,9 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param code
|
||||
* @param errorSysId
|
||||
* @param deviceId
|
||||
* @param updateResult
|
||||
*/
|
||||
private void contrastCalculateResult(String planId, String code, String errorSysId, String deviceId) {
|
||||
private void contrastCalculateResult(String planId, String code, String errorSysId, String deviceId, boolean updateResult, String dataRuleId) {
|
||||
String oldCode = code.replace("_temp", "");
|
||||
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
@@ -3188,33 +3195,38 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
|
||||
DictDataEnum dataRule;
|
||||
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
|
||||
DictData dictData = dictDataService.getDictDataById(dataRuleId);
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
|
||||
} else {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
pqMonitorService.lambdaUpdate().set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRealtimeNum, null)
|
||||
.set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRecordedNum, null)
|
||||
.set(PqMonitor::getStatisticsResult, null)
|
||||
.set(PqMonitor::getStatisticsNum, null)
|
||||
.set(PqMonitor::getResultType, null)
|
||||
.set(PqMonitor::getQualifiedNum, 0)
|
||||
.eq(PqMonitor::getDevId, deviceId)
|
||||
.eq(PqMonitor::getCheckFlag, 1)
|
||||
.update();
|
||||
if (updateResult) {
|
||||
pqMonitorService.lambdaUpdate().set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRealtimeNum, null)
|
||||
.set(PqMonitor::getRecordedResult, null)
|
||||
.set(PqMonitor::getRecordedNum, null)
|
||||
.set(PqMonitor::getStatisticsResult, null)
|
||||
.set(PqMonitor::getStatisticsNum, null)
|
||||
.set(PqMonitor::getResultType, null)
|
||||
.set(PqMonitor::getQualifiedNum, 0)
|
||||
.eq(PqMonitor::getDevId, deviceId)
|
||||
// .eq(PqMonitor::getNum, Integer.parseInt(chnNum))
|
||||
.eq(PqMonitor::getCheckFlag, 1)
|
||||
.update();
|
||||
}
|
||||
|
||||
// String monitorId = deviceId + CnSocketUtil.SPLIT_TAG + chnNum;
|
||||
List<AdPair> adPairList = adPairService.listByDevIds(Arrays.asList(deviceId));
|
||||
Map<Integer, List<AdPair>> numAdPairsMap = adPairList.stream().collect(Collectors.groupingBy(AdPair::getNum, Collectors.toList()));
|
||||
|
||||
numAdPairsMap.forEach((num, pairList) -> {
|
||||
BiMap<String, String> parsIp = HashBiMap.create();
|
||||
BiMap<String, String> parsId = HashBiMap.create();
|
||||
Map<String, Integer> numMap = new HashMap<>();
|
||||
Map<String, List<AdPair>> devMonitroIdMap = pairList.stream().collect(Collectors.groupingBy(AdPair::getDevMonitorId, Collectors.toList()));
|
||||
devMonitroIdMap.forEach((devMonitorId, pairList1) -> {
|
||||
BiMap<String, String> parsIp = HashBiMap.create();
|
||||
BiMap<String, String> parsId = HashBiMap.create();
|
||||
String[] split1 = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
AdPair adPair = pairList1.get(0);
|
||||
String[] split2 = adPair.getStdDevMonitorId().split(CnSocketUtil.SPLIT_TAG);
|
||||
@@ -3225,42 +3237,40 @@ public class ResultServiceImpl implements IResultService {
|
||||
numMap.put(devMonitorId, num);
|
||||
numMap.put(adPair.getStdDevMonitorId(), num);
|
||||
devIdMapComm.put(standardDev.getIp(), standardDev.getId());
|
||||
});
|
||||
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, deviceId, null);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, deviceId, null);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, deviceId, null);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, deviceId, null);
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, devMonitorId, null);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, devMonitorId, null);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 0, devMonitorId, null);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, null, false, null, 1, devMonitorId, null);
|
||||
|
||||
List<DevData> devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
List<DevData> standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
List<DevData> devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
List<DevData> standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
|
||||
if (CollUtil.isNotEmpty(devData) && CollUtil.isNotEmpty(standardDevData)) {
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, code, null, finalNonWaveDataSourceEnum);
|
||||
if (CollUtil.isNotEmpty(devData) && CollUtil.isNotEmpty(standardDevData)) {
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, code, null, finalNonWaveDataSourceEnum);
|
||||
|
||||
parsId.forEach((devMonitorId, stdDevMonitorId) -> {
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, finalNonWaveDataSourceEnum, num, null, oldCode);
|
||||
pqDevService.updateResult(split[0], null);
|
||||
});
|
||||
}
|
||||
if (updateResult) {
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, finalNonWaveDataSourceEnum, num, null, oldCode);
|
||||
pqDevService.updateResult(split1[0], null);
|
||||
}
|
||||
}
|
||||
|
||||
AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(planId);
|
||||
for (int i = 1; i <= adPlanTestConfig.getWaveRecord(); i++) {
|
||||
devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, deviceId, null);
|
||||
stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, deviceId, null);
|
||||
devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, deviceId, null);
|
||||
stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, deviceId, null);
|
||||
AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(planId);
|
||||
for (int i = 1; i <= adPlanTestConfig.getWaveRecord(); i++) {
|
||||
devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, devMonitorId, null);
|
||||
stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, devMonitorId, null);
|
||||
devHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 0, devMonitorId, null);
|
||||
stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(oldCode, num, i, true, null, 1, devMonitorId, null);
|
||||
|
||||
devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, oldCode, i, DataSourceEnum.WAVE_DATA);
|
||||
}
|
||||
devData = contrastToList(devNonHarmonicRawDataList, devHarmonicRawDataList, testItemMap, 0);
|
||||
standardDevData = contrastToList(stdDevNonHarmonicRawDataList, stdDevHarmonicRawDataList, testItemMap, 1);
|
||||
detectionServiceImpl.processing(devData, standardDevData, parsIp, devIdMapComm, testItemMap.keySet().stream().collect(Collectors.toList()), errorSysId, dataRule, numMap, oldCode, i, DataSourceEnum.WAVE_DATA);
|
||||
}
|
||||
|
||||
parsId.forEach((devMonitorId, stdDevMonitorId) -> {
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, WAVE_DATA, num, adPlanTestConfig.getWaveRecord(), oldCode);
|
||||
pqDevService.updateResult(split[0], null);
|
||||
if (updateResult) {
|
||||
pqMonitorService.updateMonitorResult(devMonitorId, null, WAVE_DATA, num, adPlanTestConfig.getWaveRecord(), oldCode);
|
||||
pqDevService.updateResult(split1[0], null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -3604,7 +3614,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
return 4;
|
||||
// 保留3位小数
|
||||
case "I": // 电流
|
||||
return 3;
|
||||
return 5;
|
||||
// 保留4位小数
|
||||
case "IMBV": // 电压不平衡度
|
||||
case "IMBA": // 电流不平衡度
|
||||
|
||||
@@ -126,10 +126,10 @@ public class PqScriptController extends BaseController {
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取指定模式下的所有检测脚本")
|
||||
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
public HttpResult<List<PqScript>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
String methodDescribe = getMethodDescribe("getAllPqScript");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
|
||||
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
|
||||
List<PqScript> result = pqScriptService.listAllPqScript(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class PqScriptParam {
|
||||
@Max(value = 20, message = DetectionValidMessage.SCRIPT_CURR_FORMAT_ERROR)
|
||||
private Double ratedCurr;
|
||||
|
||||
@ApiModelProperty("是否为Fluke专用脚本")
|
||||
private Integer fluke;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
@@ -73,6 +73,11 @@ public class PqScript extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Double ratedCurr;
|
||||
|
||||
/**
|
||||
* 是否为福禄克专用脚本。0-否 1-是
|
||||
*/
|
||||
private Integer fluke;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
|
||||
@@ -92,6 +92,18 @@ public class PqScriptDtls implements Serializable {
|
||||
@TableField("RetainTime")
|
||||
private Double retainTime;
|
||||
|
||||
/**
|
||||
* 暂态前延时间(S)
|
||||
*/
|
||||
@TableField("FPreTime")
|
||||
private Double fPreTime;
|
||||
|
||||
/**
|
||||
* 暂态后延时间(S)
|
||||
*/
|
||||
@TableField("FAfterTime")
|
||||
private Double fAfterTime;
|
||||
|
||||
/**
|
||||
* 变动频度(次/min)
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* @param patternId 模式id
|
||||
* @return 检测脚本列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqScript(String patternId);
|
||||
List<PqScript> listAllPqScript(String patternId);
|
||||
|
||||
/**
|
||||
* 根据脚本名称查询脚本
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
@@ -67,14 +68,14 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final static String INHARM_I = "InHarm_I";
|
||||
private final static String DIP = "Dip";
|
||||
private final static String FLICKER = "Flicker";
|
||||
@Value("${Dip.fPreTime}")
|
||||
private Double fPreTime;
|
||||
// @Value("${Dip.fPreTime}")
|
||||
// private Double fPreTime;
|
||||
@Value("${Dip.fRampIn}")
|
||||
private Double fRampIn;
|
||||
@Value("${Dip.fRampOut}")
|
||||
private Double fRampOut;
|
||||
@Value("${Dip.fAfterTime}")
|
||||
private Double fAfterTime;
|
||||
// @Value("${Dip.fAfterTime}")
|
||||
// private Double fAfterTime;
|
||||
@Value("${Flicker.waveFluType}")
|
||||
private String waveFluType;
|
||||
@Value("${Flicker.waveType}")
|
||||
@@ -384,6 +385,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
dip.setPhase(phase);
|
||||
dip.setTransValue(dipData.getFTransValue());
|
||||
dip.setRetainTime(dipData.getRetainTime());
|
||||
dip.setFPreTime(dipData.getFPreTime());
|
||||
dip.setFAfterTime(dipData.getFAfterTime());
|
||||
info.add(dip);
|
||||
}
|
||||
}
|
||||
@@ -959,6 +962,22 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
pqScriptDtls = this.list(queryWrapper);
|
||||
// 相序校验中电流需加量需要依据企标10650.2中章节5.5.3的描述过载能力:2 倍额定电流连续,10 倍额定电流持续 1 s。
|
||||
// 考虑到有可能存在1A的额定电流,本处做特殊处理,加量分别为额定电流的0.2/0.4/0.6的标幺乘积加量
|
||||
// 电压暂不做处理,原因:1、电压的企标描述过载能力为4倍,空间较大;2、额定电压比如57.74V为浮点数,存在不确定小数位,避免引起算术误差;
|
||||
// 1. 获取额定电流,前端已做限制,相同额定电流才能一起检测
|
||||
String deviceId = param.getDevIds().get(0);
|
||||
PqDevVO pqDev = pqDevService.getPqDevById(deviceId);
|
||||
String devTypeId = pqDev.getDevType();
|
||||
DevType devType = devTypeService.getById(devTypeId);
|
||||
Double devCurr = devType.getDevCurr();
|
||||
for (int i = 0; i < pqScriptDtls.size(); i++) {
|
||||
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
|
||||
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
|
||||
if(scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0){
|
||||
scriptDtls.setValue(devCurr * scriptDtls.getValue());
|
||||
}
|
||||
}
|
||||
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
|
||||
//系数
|
||||
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())
|
||||
@@ -1037,10 +1056,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
dipDataDTO.setFTransValue(0.0);
|
||||
dipDataDTO.setFRetainTime(0.0);
|
||||
|
||||
dipDataDTO.setFPreTime(fPreTime);
|
||||
// dipDataDTO.setFPreTime(fPreTime);
|
||||
dipDataDTO.setFRampIn(fRampIn);
|
||||
dipDataDTO.setFRampOut(fRampOut);
|
||||
dipDataDTO.setFAfterTime(fAfterTime);
|
||||
// dipDataDTO.setFAfterTime(fAfterTime);
|
||||
|
||||
|
||||
channelListDTO.setDipData(dipDataDTO);
|
||||
@@ -1087,6 +1106,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
if (CollUtil.isNotEmpty(dipList)) {
|
||||
PqScriptDtls dip = dipList.get(0);
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
dipDataDTO.setFPreTime(dip.getFPreTime());
|
||||
dipDataDTO.setFAfterTime(dip.getFAfterTime());
|
||||
if (devFly) {
|
||||
// if (isValueType) {
|
||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||
|
||||
@@ -112,15 +112,15 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqScript(String patternId) {
|
||||
public List<PqScript> listAllPqScript(String patternId) {
|
||||
List<PqScript> pqScriptList = this.lambdaQuery().eq(StrUtil.isNotBlank(patternId), PqScript::getPattern, patternId).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqScript.getId());
|
||||
map.put("name", pqScript.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
// List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("id", pqScript.getId());
|
||||
// map.put("name", pqScript.getName());
|
||||
// return map;
|
||||
// }).collect(Collectors.toList());
|
||||
return pqScriptList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
wrapper.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
wrapper.eq("name", param.getName());
|
||||
if (isExcludeSelf) {
|
||||
if(param instanceof PqScriptParam.UpdateParam){
|
||||
if (param instanceof PqScriptParam.UpdateParam) {
|
||||
wrapper.ne("id", ((PqScriptParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ spring:
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://localhost:13306/pqs9100w?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://127.0.0.1:3306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: njcnpqs
|
||||
#初始化建立物理连接的个数、最小、最大连接数
|
||||
@@ -36,9 +36,9 @@ mybatis-plus:
|
||||
#驼峰命名
|
||||
map-underscore-to-camel-case: true
|
||||
#配置sql日志输出
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#关闭日志输出
|
||||
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
db-config:
|
||||
#指定主键生成策略
|
||||
@@ -85,6 +85,7 @@ log:
|
||||
report:
|
||||
template: D:\template
|
||||
reportDir: D:\report
|
||||
dateFormat: yyyy年MM月dd日
|
||||
data:
|
||||
homeDir: D:\data
|
||||
qr:
|
||||
@@ -121,4 +122,4 @@ power-quality:
|
||||
# 激活配置
|
||||
activate:
|
||||
private-key: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcUyYhVqczGxblL+o/xZzF/8nf+LjrfUE/dS1aRHM7uMDD0cgCArhjtfneFePrMxt+Z7W8yNBzSarub8qsfhaVNikV7Es7oaeTygfjQXTi2n4AFkir3fM07J08RpWhl5M8f8uWTCuvFUYAw00gq55typqmnbkmJa2VIUy/iQf+cMCP7abz4/jNhUzUR3qA7TV4oMRgTdIEDUp63YF8dOC+JH8XxYrCVeHXV6fLCwmesdMzl0lB2VTEKMfLbXhOmF5g7P9y/16VCcN8UBuZlbyYfn+GAxJOSbeHi5HshOKfoSuD7Jz+3WQZpNavOWjIFExKIU38/CvnJCOP7XBCqpSTAgMBAAECggEAYeWokWRE3TpvwiOZnUpR/aVMdVi75a3ROL5XIpqPV61B+t/bU3cEpl0GF9C5pUeiRi0IoStZb3mI9D1KPW/REKyUWkhabQO1gFYbTnRlkNOn6MILzKX4cwJjDaZeeo4EBPU7N+qHyOOXrU6hdH5FfxhMdV983ajm5eeuupxER1C2kAcIklTeVpTX6EKOgZb5LBp5ssOVm2P42pOauvcRozRcvZmqnErXmukv0H4l3EVNt4rHpTn9riHUC63e8JfiYzVaF6zuNUxv6nHEft0/SRMw11XSTnNfDzcKqgjz6ksFBS/6eQQYKESk+ONC53HUuYHFAknkwsPupDCT2W8FIQKBgQDLHT/xCU3nxGr4vFKBDNaO2D5oK20ECbBO4oDvLWWmQG7f+6TsMy8PgVdMnoL4RfqGlwFAKEpS6KVFHnBVqnNEhcdy9uCI7x7Xx8UnyUtxj1EDTm76uta9Ki9OrlqB6tImDM9+Ya3vGktW37ht4WOx2OsJRhG1dbf6RLwFlH7DWwKBgQDFBxvi5I1BR6hg6Tj7xd2SqOT2Y+BED3xuSYENhWbmMhLJDResaB7mjztbxlYaY2mOE0holWm2uDmVFFhMh4jYXik4hYH8nmDzq9mDpZCZ9pyjYqnAP8THoAa8EbgrUWB8A6BPH4iL3KbMnBfBKY0pIr2xrvnjQjNBAgta7KDRKQKBgCe6oe4wxrdF2TKsC2tIqpMoQxS3Icy/ZGgZr+SYuaBKTCWtoDW/UT40K3JGMxIDBhzbXphBCUCsVt9tM8Xd4EwP6tJW7dZ7B0pnve2pVwNwaAVAiz6p2yUHIle+jN+Koe5lZRSwYIg7WW81tWpwwsJfzqFyvjYDP6hJV4mz4ROvAoGAaRcdnKvjXApomShMqJ4lTPChD3q+SA8qg3jZSOj6tZXHx00gb2kp8jg7pPvpOTIFPy6x1Ha9aCRjMk0ju84fA6lVuzwa1S907wOehUVuF3Eeo1cgy9Y3k3KbpPyeixxgpkUY4JslLdSHc2NemD0dee951qhJyRmqVOZOQDUuoeECgYEAqBw2cAFk3vM97WY06TSldGA8ajVHx3BYRjj+zl62NTQthy8fw3tqxb3c5e8toOmZWKjZvDhg2TRLhsDDQWEYg3LZG87REqVIjgEPcpjNLidjygGX8n3JF2o0O5I/EMvl0s/+LVQONfduOBvhwDqr8QNisbLsyneiAq7umewMolo="
|
||||
public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFMmIVanMxsW5S/qP8Wcxf/J3/i4631BP3UtWkRzO7jAw9HIAgK4Y7X53hXj6zMbfme1vMjQc0mq7m/KrH4WlTYpFexLO6Gnk8oH40F04tp+ABZIq93zNOydPEaVoZeTPH/LlkwrrxVGAMNNIKuebcqapp25JiWtlSFMv4kH/nDAj+2m8+P4zYVM1Ed6gO01eKDEYE3SBA1Ket2BfHTgviR/F8WKwlXh11enywsJnrHTM5dJQdlUxCjHy214TpheYOz/cv9elQnDfFAbmZW8mH5/hgMSTkm3h4uR7ITin6Erg+yc/t1kGaTWrzloyBRMSiFN/Pwr5yQjj+1wQqqUkwIDAQAB"
|
||||
public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFMmIVanMxsW5S/qP8Wcxf/J3/i4631BP3UtWkRzO7jAw9HIAgK4Y7X53hXj6zMbfme1vMjQc0mq7m/KrH4WlTYpFexLO6Gnk8oH40F04tp+ABZIq93zNOydPEaVoZeTPH/LlkwrrxVGAMNNIKuebcqapp25JiWtlSFMv4kH/nDAj+2m8+P4zYVM1Ed6gO01eKDEYE3SBA1Ket2BfHTgviR/F8WKwlXh11enywsJnrHTM5dJQdlUxCjHy214TpheYOz/cv9elQnDfFAbmZW8mH5/hgMSTkm3h4uR7ITin6Erg+yc/t1kGaTWrzloyBRMSiFN/Pwr5yQjj+1wQqqUkwIDAQAB"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- 直接使用固定配置,避免Spring配置解析时机问题 -->
|
||||
<property name="log.projectName" value="entrance"/>
|
||||
<property name="logCommonLevel" value="info"/>
|
||||
<property name="logHomeDir" value="D:\logs"/>
|
||||
<property name="logHomeDir" value="${logHomeDir:-D:\logs}"/>
|
||||
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
entrance/src/main/resources/model/report_table - PQ-COM.docx
Normal file
BIN
entrance/src/main/resources/model/report_table - PQ-COM.docx
Normal file
Binary file not shown.
@@ -25,10 +25,10 @@ public class AnalysisServiceStreamTest {
|
||||
private ICompareWaveService compareWaveServiceImpl;
|
||||
|
||||
// 测试文件路径 - 请根据实际情况修改
|
||||
private static final String SOURCE_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.200\\PQ_PQLD1_000020_20251017_140358_193.cfg";
|
||||
private static final String SOURCE_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.200\\PQ_PQLD1_000020_20251017_140358_193.dat";
|
||||
private static final String TARGET_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.168\\PQ_PQLD1_000018_20251017_140357_625.cfg";
|
||||
private static final String TARGET_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wavedata\\192.168.1.168\\PQ_PQLD1_000018_20251017_140357_625.dat";
|
||||
private static final String SOURCE_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.241\\PQ_PQLD2_000177_20251028_112422_833.cfg";
|
||||
private static final String SOURCE_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.241\\PQ_PQLD2_000177_20251028_112422_833.dat";
|
||||
private static final String TARGET_CFG_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.242\\PQ_PQLD2_000238_20251028_112422_518.cfg";
|
||||
private static final String TARGET_DAT_PATH = "C:\\Users\\Administrator\\Desktop\\wave\\192.168.1.242\\PQ_PQLD2_000238_20251028_112422_518.dat";
|
||||
|
||||
|
||||
// private static final String SOURCE_CFG_PATH = "F:\\hatch\\wavecompare\\数据比对\\统计数据1\\B码\\217\\PQMonitor_PQM1_000006_20200430_115517_889.cfg";
|
||||
|
||||
1
license.key
Normal file
1
license.key
Normal file
@@ -0,0 +1 @@
|
||||
AoNUHvLQag9nPPxWDsf5EwwBqifh5wnoFjrU01w+kIA7TPdRl0AQDBSA3IU7AY28Liubt6Rl8CsDtxEDrz8L5m0FqQrmZ1TmIJtZWbBR16NxXRgf8izM5JurYEY6ZbjU021yCu0fitxB0DJZ8LB8zfUDsV1MFGHl+yPjh4ZQrYDffID4rk/mRe/EE6F7bS19upStSOnQxVQVJSXwCVVHgsuFXqiuagM21OmxpYNjqaPnvAKoHRXTTxXn9BrSgZBocxuHB/IE+a0a+Q2eQo4RZa2IQpneEA/QIKEqezqsABxmM33duQ4eKt17hAttISV1J0R1cKpwZ4tYuSoHCuMONA==
|
||||
@@ -28,6 +28,9 @@ public class SysTestConfigParam {
|
||||
@ApiModelProperty(value = "场景")
|
||||
private String scene;
|
||||
|
||||
@ApiModelProperty(value = "比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准")
|
||||
private Integer coefficient;
|
||||
|
||||
@Data
|
||||
public static class UpdateParam extends SysTestConfigParam {
|
||||
@ApiModelProperty("id")
|
||||
|
||||
@@ -51,6 +51,11 @@ public class SysTestConfig extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Integer scale;
|
||||
|
||||
/**
|
||||
* 比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准
|
||||
*/
|
||||
private Integer coefficient;
|
||||
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
|
||||
@@ -49,6 +49,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
||||
oneConfig.setScale(ObjectUtil.isNotNull(param.getScale()) ? param.getScale() : oneConfig.getScale());
|
||||
oneConfig.setMaxTime(ObjectUtil.isNotNull(param.getMaxTime()) ? param.getMaxTime() : oneConfig.getMaxTime());
|
||||
oneConfig.setScene(StringUtils.isNotBlank(param.getScene()) ? param.getScene() : oneConfig.getScene());
|
||||
oneConfig.setCoefficient(param.getCoefficient());
|
||||
return this.updateById(oneConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.docx4j.XmlUtils;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
@@ -27,6 +28,7 @@ import java.util.Map;
|
||||
* @version 1.0
|
||||
* @data 2025/3/26 13:47
|
||||
*/
|
||||
@Slf4j
|
||||
public class Docx4jUtil {
|
||||
|
||||
/**
|
||||
@@ -434,7 +436,93 @@ public class Docx4jUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新航
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param valueMap 数据
|
||||
* @param tableKeys keys
|
||||
* @param trPr 行样式
|
||||
* @param tcPrList 每个单元格的样式列表(用于保留各单元格独立的边框设置)
|
||||
* @param templateRPr 模板中的字体样式(可为null,为null时使用默认宋体10号)
|
||||
* @param centerFlag 是否居中
|
||||
*/
|
||||
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, List<TcPr> tcPrList, RPr templateRPr, boolean centerFlag) {
|
||||
Tr row = factory.createTr();
|
||||
for (int i = 0; i < tableKeys.size(); i++) {
|
||||
String tableKey = tableKeys.get(i);
|
||||
Tc cell = factory.createTc();
|
||||
P paragraph = factory.createP();
|
||||
R run = factory.createR();
|
||||
String value = valueMap.get(tableKey);
|
||||
Text text = factory.createText();
|
||||
text.setValue(value);
|
||||
run.getContent().add(text);
|
||||
paragraph.getContent().add(run);
|
||||
|
||||
// 从模板复制字体样式
|
||||
RPr rPr = factory.createRPr();
|
||||
if (templateRPr != null) {
|
||||
// 复制字体
|
||||
if (templateRPr.getRFonts() != null) {
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
rFonts.setEastAsia(templateRPr.getRFonts().getEastAsia());
|
||||
rFonts.setAscii(templateRPr.getRFonts().getAscii());
|
||||
rFonts.setHAnsi(templateRPr.getRFonts().getHAnsi());
|
||||
rPr.setRFonts(rFonts);
|
||||
}
|
||||
// 复制字号
|
||||
if (templateRPr.getSz() != null) {
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
sz.setVal(templateRPr.getSz().getVal());
|
||||
rPr.setSz(sz);
|
||||
}
|
||||
if (templateRPr.getSzCs() != null) {
|
||||
HpsMeasure szCs = factory.createHpsMeasure();
|
||||
szCs.setVal(templateRPr.getSzCs().getVal());
|
||||
rPr.setSzCs(szCs);
|
||||
}
|
||||
} else {
|
||||
// 默认使用宋体10号
|
||||
RFonts rFonts = factory.createRFonts();
|
||||
rFonts.setEastAsia("宋体");
|
||||
rFonts.setAscii("宋体");
|
||||
rFonts.setHAnsi("宋体");
|
||||
rPr.setRFonts(rFonts);
|
||||
HpsMeasure sz = factory.createHpsMeasure();
|
||||
sz.setVal(new BigInteger("20"));
|
||||
rPr.setSz(sz);
|
||||
}
|
||||
|
||||
// 设置段落居中
|
||||
if (centerFlag) {
|
||||
PPr pPr = factory.createPPr();
|
||||
Jc jc = factory.createJc();
|
||||
jc.setVal(JcEnumeration.CENTER);
|
||||
pPr.setJc(jc);
|
||||
paragraph.setPPr(pPr);
|
||||
}
|
||||
// 不合格标红
|
||||
if (value != null && value.equals("不合格")) {
|
||||
Color color = factory.createColor();
|
||||
color.setVal("FF0000");
|
||||
rPr.setColor(color);
|
||||
}
|
||||
run.setRPr(rPr);
|
||||
|
||||
cell.getContent().add(paragraph);
|
||||
// 使用对应位置的单元格样式(保留边框设置)
|
||||
if (tcPrList != null && i < tcPrList.size()) {
|
||||
cell.setTcPr(tcPrList.get(i));
|
||||
}
|
||||
row.getContent().add(cell);
|
||||
row.setTrPr(trPr);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据已知信息创建新行
|
||||
*
|
||||
* @param factory 工厂
|
||||
* @param valueMap 数据
|
||||
@@ -2139,5 +2227,83 @@ public class Docx4jUtil {
|
||||
return specialCaseP;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为Word文档添加水印
|
||||
* 使用页眉方式,但设置页眉高度为0,确保不影响文档结构
|
||||
*
|
||||
* @param wordPackage Word文档包
|
||||
* @param watermarkText 水印文字(如:"非正式")
|
||||
* @throws Exception 添加水印失败时抛出异常
|
||||
*/
|
||||
public static void addWatermarkToDocument(WordprocessingMLPackage wordPackage, String watermarkText) throws Exception {
|
||||
try {
|
||||
MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart();
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
|
||||
// 创建页眉部分
|
||||
org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart headerPart =
|
||||
new org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart();
|
||||
|
||||
// 将页眉部分添加到文档并获取关系ID
|
||||
org.docx4j.relationships.Relationship relationship = mainDocumentPart.addTargetPart(headerPart);
|
||||
|
||||
// 创建页眉对象
|
||||
org.docx4j.wml.Hdr hdr = factory.createHdr();
|
||||
|
||||
// 创建段落
|
||||
P paragraph = factory.createP();
|
||||
|
||||
// 创建Run
|
||||
R run = factory.createR();
|
||||
|
||||
// 使用VML textbox方式创建水印文本(绝对定位,显示在页面中部)
|
||||
String vmlString = String.format(
|
||||
"<w:pict xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" " +
|
||||
"xmlns:v=\"urn:schemas-microsoft-com:vml\">" +
|
||||
"<v:shape style=\"position:absolute;left:0;text-align:center;margin-left:0;margin-top:0;" +
|
||||
"width:500pt;height:200pt;z-index:-251658240;" +
|
||||
"mso-position-horizontal:center;mso-position-horizontal-relative:page;" +
|
||||
"mso-position-vertical:center;mso-position-vertical-relative:page\" " +
|
||||
"fillcolor=\"none\" stroked=\"f\">" +
|
||||
"<v:textbox style=\"mso-fit-shape-to-text:t\">" +
|
||||
"<w:txbxContent>" +
|
||||
"<w:p><w:pPr><w:jc w:val=\"center\"/></w:pPr>" +
|
||||
"<w:r><w:rPr>" +
|
||||
"<w:color w:val=\"D8D8D8\"/>" +
|
||||
"<w:sz w:val=\"240\"/>" +
|
||||
"<w:szCs w:val=\"240\"/>" +
|
||||
"<w:rFonts w:ascii=\"微软雅黑\" w:eastAsia=\"微软雅黑\" w:hAnsi=\"微软雅黑\"/>" +
|
||||
"</w:rPr><w:t>%s</w:t></w:r></w:p>" +
|
||||
"</w:txbxContent></v:textbox>" +
|
||||
"</v:shape></w:pict>", watermarkText);
|
||||
|
||||
// 解析VML并添加到Run
|
||||
Object vmlObject = XmlUtils.unmarshalString(vmlString);
|
||||
run.getContent().add(vmlObject);
|
||||
|
||||
paragraph.getContent().add(run);
|
||||
hdr.getContent().add(paragraph);
|
||||
headerPart.setJaxbElement(hdr);
|
||||
|
||||
// 获取或创建节属性(SectPr)
|
||||
SectPr sectPr = mainDocumentPart.getJaxbElement().getBody().getSectPr();
|
||||
if (sectPr == null) {
|
||||
sectPr = factory.createSectPr();
|
||||
mainDocumentPart.getJaxbElement().getBody().setSectPr(sectPr);
|
||||
}
|
||||
|
||||
// 创建页眉引用并关联到节属性
|
||||
org.docx4j.wml.HeaderReference headerReference = factory.createHeaderReference();
|
||||
headerReference.setId(relationship.getId());
|
||||
headerReference.setType(org.docx4j.wml.HdrFtrRef.DEFAULT);
|
||||
sectPr.getEGHdrFtrReferences().add(headerReference);
|
||||
|
||||
log.info("成功添加水印:{}", watermarkText);
|
||||
} catch (Exception e) {
|
||||
log.error("添加水印失败:{}", e.getMessage(), e);
|
||||
throw new Exception("添加水印失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user