调整表结构、编写查看检测结果接口、误差计算逻辑调整
This commit is contained in:
@@ -581,11 +581,9 @@ public class SocketContrastResponseService {
|
||||
this.saveAlignData();
|
||||
|
||||
this.clearData();
|
||||
|
||||
return;
|
||||
scheduler.shutdown();
|
||||
scheduler = null;
|
||||
}
|
||||
scheduler.shutdown();
|
||||
scheduler = null;
|
||||
}, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@@ -593,13 +591,17 @@ public class SocketContrastResponseService {
|
||||
String standardDevMonitorId = monitorId1;
|
||||
if (FormalTestManager.devDataMap.containsKey(monitorId1)) {
|
||||
standardDevMonitorId = FormalTestManager.pairsIpMap.get(monitorId1);
|
||||
FormalTestManager.devDataMap.get(monitorId1).add(devData);
|
||||
Collections.sort(FormalTestManager.devDataMap.get(monitorId1), Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
if (!successPair.containsKey(devMonitorId)) {
|
||||
FormalTestManager.devDataMap.get(devMonitorId).add(devData);
|
||||
Collections.sort(FormalTestManager.devDataMap.get(devMonitorId), Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
}
|
||||
}
|
||||
if (FormalTestManager.standardDevDataMap.containsKey(monitorId1)) {
|
||||
devMonitorId = FormalTestManager.pairsIpMap.inverse().get(monitorId1);
|
||||
FormalTestManager.standardDevDataMap.get(monitorId1).add(devData);
|
||||
Collections.sort(FormalTestManager.standardDevDataMap.get(monitorId1), Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
if (!successPair.containsKey(devMonitorId)) {
|
||||
FormalTestManager.standardDevDataMap.get(standardDevMonitorId).add(devData);
|
||||
Collections.sort(FormalTestManager.standardDevDataMap.get(standardDevMonitorId), Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
}
|
||||
}
|
||||
|
||||
// 进行单个监测点的对齐校验
|
||||
@@ -882,6 +884,12 @@ public class SocketContrastResponseService {
|
||||
webSend.setData(MsgUtil.getPairStr(devMonitorId, standardDevMonitorId, FormalTestManager.devNameMapComm) + " 数据收集成功!");
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
|
||||
FormalTestManager.devDataMap.get(devMonitorId).clear();
|
||||
FormalTestManager.standardDevDataMap.get(standardDevMonitorId).clear();
|
||||
|
||||
FormalTestManager.devDataMap.get(devMonitorId).addAll(singleMonitorAlignData.get(0));
|
||||
FormalTestManager.standardDevDataMap.get(standardDevMonitorId).addAll(singleMonitorAlignData.get(1));
|
||||
|
||||
if (successPair.keySet().containsAll(FormalTestManager.pairsIpMap.keySet())) {
|
||||
isReceiveData = false;
|
||||
// 断开与设备的连接,但是不要将Socket移除
|
||||
@@ -890,6 +898,7 @@ public class SocketContrastResponseService {
|
||||
scheduledFuture.cancel(true);
|
||||
scheduler.shutdown();
|
||||
|
||||
|
||||
String errorSysId = FormalTestManager.currentTestPlan.getErrorSysId();
|
||||
String code = String.valueOf(FormalTestManager.currentTestPlan.getCode());
|
||||
|
||||
@@ -911,8 +920,8 @@ public class SocketContrastResponseService {
|
||||
|
||||
// 进行误差计算
|
||||
List<DevLineTestResult> allResultList = detectionService.processing(
|
||||
FormalTestManager.devDataMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList()),
|
||||
FormalTestManager.standardDevDataMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList()),
|
||||
FormalTestManager.devDataMap.values().stream().flatMap(List::stream).collect(Collectors.toList()),
|
||||
FormalTestManager.standardDevDataMap.values().stream().flatMap(List::stream).collect(Collectors.toList()),
|
||||
FormalTestManager.pairsIpMap,
|
||||
FormalTestManager.devIdMapComm,
|
||||
FormalTestManager.testItemMap.keySet().stream().collect(Collectors.toList()),
|
||||
@@ -1685,9 +1694,11 @@ public class SocketContrastResponseService {
|
||||
if (isStdDev) {
|
||||
adNonHarmonicResult.setDevMonitorId(FormalTestManager.pairsIdMap.inverse().get(temId));
|
||||
adNonHarmonicResult.setStdDevMonitorId(temId);
|
||||
adNonHarmonicResult.setFlag(1);
|
||||
} else {
|
||||
adNonHarmonicResult.setDevMonitorId(temId);
|
||||
adNonHarmonicResult.setStdDevMonitorId(FormalTestManager.pairsIdMap.get(temId));
|
||||
adNonHarmonicResult.setFlag(0);
|
||||
}
|
||||
|
||||
Double a = listDTO.getA();
|
||||
@@ -1720,9 +1731,11 @@ public class SocketContrastResponseService {
|
||||
if (isStdDev) {
|
||||
adHarmonicResult.setDevMonitorId(FormalTestManager.pairsIdMap.inverse().get(temId));
|
||||
adHarmonicResult.setStdDevMonitorId(temId);
|
||||
adHarmonicResult.setFlag(1);
|
||||
} else {
|
||||
adHarmonicResult.setDevMonitorId(temId);
|
||||
adHarmonicResult.setStdDevMonitorId(FormalTestManager.pairsIdMap.get(temId));
|
||||
adHarmonicResult.setFlag(0);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotNull(dui)) {
|
||||
|
||||
@@ -46,6 +46,8 @@ public class AlignDataVO {
|
||||
|
||||
private Double ucDev;
|
||||
|
||||
private Double utDev;
|
||||
|
||||
private String timeStdDev;
|
||||
|
||||
private Double uaStdDev;
|
||||
@@ -53,5 +55,7 @@ public class AlignDataVO {
|
||||
private Double ubStdDev;
|
||||
|
||||
private Double ucStdDev;
|
||||
|
||||
private Double utStdDev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,12 @@ import com.njcn.gather.detection.pojo.po.AdPair;
|
||||
* @data 2025-08-18
|
||||
*/
|
||||
public interface IAdPariService extends IService<AdPair> {
|
||||
|
||||
/**
|
||||
* 获取最大的检测次数
|
||||
*
|
||||
* @param devMonitorId
|
||||
* @return
|
||||
*/
|
||||
Integer getMaxNum(String devMonitorId);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.detection.mapper.AdPairMapper;
|
||||
import com.njcn.gather.detection.pojo.po.AdPair;
|
||||
@@ -7,6 +8,8 @@ import com.njcn.gather.detection.service.IAdPariService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-08-18
|
||||
@@ -14,4 +17,16 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdPairServiceImpl extends ServiceImpl<AdPairMapper, AdPair> implements IAdPariService {
|
||||
|
||||
@Override
|
||||
public Integer getMaxNum(String devMonitorId) {
|
||||
List<AdPair> adPairList = this.lambdaQuery().select(AdPair::getNum)
|
||||
.eq(AdPair::getDevMonitorId, devMonitorId)
|
||||
.orderByDesc(AdPair::getNum)
|
||||
.last("LIMIT 1").list();
|
||||
if (CollUtil.isNotEmpty(adPairList)) {
|
||||
return adPairList.get(0).getNum();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,6 +1581,9 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
String scriptType = split[1];
|
||||
if (isDelta) {
|
||||
if (DetectionCodeEnum.PVRMS.getCode().equals(scriptType)) {
|
||||
scriptType = DetectionCodeEnum.VRMS.getCode();
|
||||
}
|
||||
if (DetectionCodeEnum.PV2_50.getCode().equals(scriptType)) {
|
||||
scriptType = DetectionCodeEnum.V2_50.getCode();
|
||||
}
|
||||
@@ -1605,10 +1608,10 @@ public class DetectionServiceImpl {
|
||||
resultMap.put(PowerIndexEnum.P.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn * fIn, DetectionCodeEnum.P_FUND.getCode(), dataRule, num, code, oneConfig.getScale()));
|
||||
break;
|
||||
case V_UNBAN:
|
||||
resultMap.put(PowerIndexEnum.IMBV.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, DetectionCodeEnum.V_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale()));
|
||||
resultMap.put(PowerIndexEnum.IMBV.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fUn, DetectionCodeEnum.V_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale()));
|
||||
break;
|
||||
case I_UNBAN:
|
||||
resultMap.put(PowerIndexEnum.IMBA.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fIn, DetectionCodeEnum.I_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale()));
|
||||
resultMap.put(PowerIndexEnum.IMBA.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fIn, DetectionCodeEnum.I_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale()));
|
||||
break;
|
||||
case V2_50:
|
||||
case PV2_50:
|
||||
@@ -1999,11 +2002,21 @@ public class DetectionServiceImpl {
|
||||
if (DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
||||
first1 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
} else {
|
||||
// 防止出现有PU1而没有PV2_50、SV_1_49的情况
|
||||
if ((DetectionCodeEnum.PV2_50.getCode().equals(harmCode) || DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) && DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
||||
first1 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
}
|
||||
if (!first2.isPresent()) {
|
||||
if (DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
||||
first2 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
} else {
|
||||
// 防止出现有PU1而没有PV2_50、SV_1_49的情况
|
||||
if ((DetectionCodeEnum.PV2_50.getCode().equals(harmCode) || DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) && DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
||||
first2 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
DevData.SqlDataDTO fund1 = null;
|
||||
@@ -2172,13 +2185,13 @@ public class DetectionServiceImpl {
|
||||
startRadiusEnd(x.getEndValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||
x.getEndFlag(),
|
||||
ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData)).collect(Collectors.toList());
|
||||
detectionData.setData(devData);
|
||||
detectionData.setResultData(stdDevData);
|
||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||
detectionData.setNum(harmonicNum);
|
||||
detectionData.setData(devData);
|
||||
detectionData.setResultData(stdDevData);
|
||||
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
|
||||
detectionData.setErrorDtlId(errSysDtl.getId());
|
||||
detectionData.setUnit(errSysDtl.getErrorUnit());
|
||||
detectionData.setErrorDtlId(errSysDtl.getId());
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl, fData, ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData, scale));
|
||||
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||
|
||||
@@ -2194,8 +2207,8 @@ public class DetectionServiceImpl {
|
||||
} else {
|
||||
detectionData.setIsData(ResultEnum.NOT_QUALIFIED.getValue());
|
||||
}
|
||||
detectionDataList.add(detectionData);
|
||||
}
|
||||
detectionDataList.add(detectionData);
|
||||
}
|
||||
return detectionDataList;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.njcn.gather.result.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.result.pojo.vo.ContrastResultVO;
|
||||
import com.njcn.gather.detection.service.IAdPariService;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -35,6 +38,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ResultController extends BaseController {
|
||||
private final IResultService resultService;
|
||||
private final IAdPariService adPariService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/formContent")
|
||||
@@ -120,4 +124,31 @@ public class ResultController extends BaseController {
|
||||
resultService.deleteTempTable(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getContrastFormContent")
|
||||
@ApiOperation("获取比对式检测结果-表单内容")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<FormContentVO> getContrastFormContent(@RequestBody @Validated ResultParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getContrastFormContent");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
|
||||
FormContentVO result = resultService.getContrastFormContent(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getContrastResult")
|
||||
@ApiOperation("获取比对式检测结果")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<ContrastResultVO> getContrastResult(@RequestBody @Validated ResultParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getContrastResult");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
|
||||
if (ObjectUtil.isEmpty(queryParam.getNum())) {
|
||||
queryParam.setNum(adPariService.getMaxNum(queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getNum()));
|
||||
}
|
||||
ContrastResultVO result = resultService.getContrastResult(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ public class ResultParam {
|
||||
|
||||
// 通道号,当为-1时,表示查询所有通道号,否则只查询指定通道号
|
||||
private String chnNum;
|
||||
|
||||
// 第几次检测
|
||||
private Integer num;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.gather.result.pojo.vo;
|
||||
|
||||
import com.njcn.gather.detection.pojo.vo.AlignDataVO;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastBaseResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-08-21
|
||||
*/
|
||||
@Data
|
||||
public class ContrastResultVO {
|
||||
|
||||
/**
|
||||
* 检测结果。key为具体检测项名称,value为具体检测项的检测结果。
|
||||
*/
|
||||
private Map<String, List<RawResultDataVO>> resultMap;
|
||||
|
||||
/**
|
||||
* 原始数据。key为具体检测项名称,value为具体检测项的原始数据。
|
||||
*/
|
||||
private Map<String, List<AlignDataVO.RawData>> rawDataMap;
|
||||
}
|
||||
@@ -21,4 +21,14 @@ public class FormContentVO {
|
||||
private String deviceName;
|
||||
|
||||
private List<Map<String, String>> chnList;
|
||||
|
||||
/**
|
||||
* key为通道号,value为该通道检测的次数
|
||||
*/
|
||||
private Map<String, List<Integer>> chnMap;
|
||||
|
||||
/**
|
||||
* 选中的第几次
|
||||
*/
|
||||
private Integer checkNum;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.result.service;
|
||||
|
||||
import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.ContrastResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
@@ -97,4 +98,21 @@ public interface IResultService {
|
||||
* @param pKeys 待填充的值
|
||||
*/
|
||||
Map<String, String> getParagraphKeysValue(String itemCode, List<String> pKeys);
|
||||
|
||||
/**
|
||||
* 获取比对式表单头
|
||||
*
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
FormContentVO getContrastFormContent(ResultParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取比对式检测结果
|
||||
*
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
ContrastResultVO getContrastResult(ResultParam.QueryParam queryParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -16,9 +17,13 @@ import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.AlignDataVO;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.detection.service.IAdPariService;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -30,10 +35,7 @@ import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||
import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.RawDataExcel;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.pojo.vo.*;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
@@ -48,17 +50,21 @@ import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.*;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import com.njcn.gather.storage.service.ContrastHarmonicService;
|
||||
import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||
import com.njcn.gather.storage.service.impl.SimAndDigHarmonicServiceImpl;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import com.njcn.gather.util.StorageUtil;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -70,6 +76,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -82,8 +89,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final SimAndDigNonHarmonicService adNonHarmonicService;
|
||||
private final SimAndDigHarmonicService adHarmonicService;
|
||||
private final SimAndDigNonHarmonicService simAndDigNonHarmonicService;
|
||||
private final SimAndDigHarmonicService simAndDigHarmonicService;
|
||||
private final ContrastHarmonicService contrastHarmonicService;
|
||||
private final ContrastNonHarmonicService contrastNonHarmonicService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final PqScriptMapper scriptMapper;
|
||||
private final IDictTreeService dictTreeService;
|
||||
@@ -93,6 +102,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IAdPariService adPairService;
|
||||
|
||||
/**
|
||||
* 谐波类code,取树形字典表中的code
|
||||
@@ -123,13 +133,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
DictTree dictTree = dictTreeService.getById(queryParam.getScriptType());
|
||||
|
||||
if (HARMONIC_TYPE_CODE.contains(dictTree.getCode())) {
|
||||
allResultList.addAll(adHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(simAndDigHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
} else {
|
||||
allResultList.addAll(adNonHarmonicService.listSimAndDigBaseResult(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(simAndDigNonHarmonicService.listSimAndDigBaseResult(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
}
|
||||
} else { //查询所有的脚本类型
|
||||
allResultList.addAll(adHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(adNonHarmonicService.listSimAndDigBaseResult(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(simAndDigHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
allResultList.addAll(simAndDigNonHarmonicService.listSimAndDigBaseResult(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum(), plan.getCode() + ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -169,8 +179,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
if (StrUtil.isNotBlank(param.getScriptType())) {
|
||||
indexList = pqScriptDtlsService.getIndexList(param.getScriptType(), param.getScriptId());
|
||||
}
|
||||
allResultList.addAll(adNonHarmonicService.listSimAndDigBaseResult(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
allResultList.addAll(adHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
allResultList.addAll(simAndDigNonHarmonicService.listSimAndDigBaseResult(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
allResultList.addAll(simAndDigHarmonicService.get(param.getScriptId(), indexList, param.getDevId(), param.getDevNum(), param.getCode()));
|
||||
if (CollUtil.isNotEmpty(allResultList)) {
|
||||
resultMap = allResultList.stream().collect(Collectors.groupingBy(SimAndDigBaseResult::getSort, Collectors.mapping(SimAndDigBaseResult::getResultFlag, Collectors.toSet())));
|
||||
}
|
||||
@@ -820,12 +830,12 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
ResultVO resultVO = new ResultVO();
|
||||
if (CollUtil.isEmpty(harmNum)) {
|
||||
resultVO.setRawData(adNonHarmonicService.listNonHarmData(storage));
|
||||
resultVO.setResultData(adNonHarmonicService.listNonHarmResultData(storage));
|
||||
resultVO.setRawData(simAndDigNonHarmonicService.listNonHarmData(storage));
|
||||
resultVO.setResultData(simAndDigNonHarmonicService.listNonHarmResultData(storage));
|
||||
} else {
|
||||
storage.setHarmNum(harmNum);
|
||||
resultVO.setRawData(adHarmonicService.listHarmData(storage));
|
||||
resultVO.setResultData(adHarmonicService.listHarmResultData(storage));
|
||||
resultVO.setRawData(simAndDigHarmonicService.listHarmData(storage));
|
||||
resultVO.setResultData(simAndDigHarmonicService.listHarmResultData(storage));
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
@@ -853,10 +863,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
ResultVO resultVO = new ResultVO();
|
||||
if (CollUtil.isEmpty(harmNum)) {
|
||||
resultVO.setResultData(adNonHarmonicService.listNonHarmResultData(storage));
|
||||
resultVO.setResultData(simAndDigNonHarmonicService.listNonHarmResultData(storage));
|
||||
} else {
|
||||
storage.setHarmNum(harmNum);
|
||||
resultVO.setResultData(adHarmonicService.listHarmResultData(storage));
|
||||
resultVO.setResultData(simAndDigHarmonicService.listHarmResultData(storage));
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
@@ -885,10 +895,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
|
||||
Map<String, List<RawDataVO>> rawDataMap = null;
|
||||
if (CollUtil.isEmpty(harmNum)) {
|
||||
rawDataMap = adNonHarmonicService.listNonHarmData(storage);
|
||||
rawDataMap = simAndDigNonHarmonicService.listNonHarmData(storage);
|
||||
} else {
|
||||
storage.setHarmNum(harmNum);
|
||||
rawDataMap = adHarmonicService.listHarmData(storage);
|
||||
rawDataMap = simAndDigHarmonicService.listHarmData(storage);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(rawDataMap)) {
|
||||
@@ -971,7 +981,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (Integer sort : indexList) {
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = simAndDigNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillVoltagePhaseData(nonHarmList, keyFillMap, tableKeys);
|
||||
@@ -996,7 +1006,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
if (indexList.size() == 1) {
|
||||
// 获取谐波数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueType, indexList.get(0));
|
||||
SimAndDigHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
||||
SimAndDigHarmonicResult singleResult = simAndDigHarmonicService.getSingleResult(param);
|
||||
// 注:如果ABC的标准值一致,则同步到standard中
|
||||
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
@@ -1039,7 +1049,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
||||
// 获取该三相的数据
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = simAndDigNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (SimAndDigNonHarmonicResult SimAndDigNonHarmonicResult : nonHarmList) {
|
||||
@@ -1067,7 +1077,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||
List<SimAndDigNonHarmonicResult> nonHarmList = simAndDigNonHarmonicService.queryByCondition(param);
|
||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||
for (SimAndDigNonHarmonicResult simAndDigNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(8);
|
||||
@@ -1491,6 +1501,271 @@ public class ResultServiceImpl implements IResultService {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormContentVO getContrastFormContent(ResultParam.QueryParam queryParam) {
|
||||
FormContentVO formContentVO = new FormContentVO();
|
||||
|
||||
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
|
||||
PqDev dev = pqDevService.getById(queryParam.getDeviceId());
|
||||
DictData dictData = dictDataService.getById(plan.getDataRule());
|
||||
formContentVO.setDataRule(dictData.getName());
|
||||
formContentVO.setDeviceName(dev.getName());
|
||||
formContentVO.setErrorSysId(plan.getErrorSysId());
|
||||
|
||||
List<DictTree> dictTreeList = dictTreeService.getDictTreeById(Collections.singletonList(queryParam.getScriptType()));
|
||||
List<String> fatherIdList = dictTreeList.stream().map(DictTree::getId).collect(Collectors.toList());
|
||||
List<DictTree> childDictTreeList = dictTreeService.listByFatherIds(fatherIdList);
|
||||
List<String> adTypeList = childDictTreeList.stream().map(DictTree::getId).collect(Collectors.toList());
|
||||
List<ContrastBaseResult> allResultList = new ArrayList<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, queryParam.getDeviceId(), adTypeList);
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(String.valueOf(plan.getCode()), null, queryParam.getDeviceId(), adTypeList);
|
||||
allResultList.addAll(contrastHarmonicResults);
|
||||
allResultList.addAll(contrastNonHarmonicResults);
|
||||
|
||||
Map<String, List<Integer>> chnMap = new HashMap<>();
|
||||
Map<String, List<ContrastBaseResult>> devMonitorIdMap = allResultList.stream().collect(Collectors.groupingBy(ContrastBaseResult::getDevMonitorId));
|
||||
devMonitorIdMap.forEach((devMonitorId, resultList) -> {
|
||||
Integer maxNum = resultList.stream().map(ContrastBaseResult::getNum).max(Comparator.comparing(Integer::valueOf)).orElse(1);
|
||||
List<Integer> numList = Stream.iterate(1, n -> n + 1).limit(maxNum).collect(Collectors.toList());
|
||||
String[] split = devMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
chnMap.put(split[1], numList);
|
||||
|
||||
if (ObjectUtil.isNull(queryParam.getNum())) {
|
||||
formContentVO.setCheckNum(maxNum);
|
||||
} else {
|
||||
formContentVO.setCheckNum(queryParam.getNum());
|
||||
}
|
||||
});
|
||||
|
||||
formContentVO.setChnMap(chnMap);
|
||||
return formContentVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
List<DictTree> childDictTreeList = dictTreeService.listByFatherIds(fatherIdList);
|
||||
List<String> adTypeList = childDictTreeList.stream().map(DictTree::getId).collect(Collectors.toList());
|
||||
DictTree dictTree = dictTreeList.get(0);
|
||||
|
||||
contrastResultVO.setResultMap(this.getResultMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), queryParam.getNum(), String.valueOf(plan.getCode())));
|
||||
contrastResultVO.setRawDataMap(this.getRawDataMap(dictTree, adTypeList, queryParam.getDeviceId() + CnSocketUtil.SPLIT_TAG + queryParam.getChnNum(), queryParam.getNum(), String.valueOf(plan.getCode())));
|
||||
return contrastResultVO;
|
||||
}
|
||||
|
||||
private Map<String, List<RawResultDataVO>> getResultMap(DictTree dictTree, List<String> adTypeList, String monitorId, Integer num, String code) {
|
||||
Map<String, List<RawResultDataVO>> resultMap = new LinkedHashMap<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = contrastNonHarmonicService.listAllResultData(code, num, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> contrastHarmonicResults = contrastHarmonicService.listAllResultData(code, num, monitorId, adTypeList);
|
||||
|
||||
String unit = StorageUtil.unit(dictTree.getCode());
|
||||
|
||||
if (CollUtil.isNotEmpty(contrastNonHarmonicResults)) {
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResult = contrastNonHarmonicResults.get(0);
|
||||
List<RawResultDataVO.DetectionData> aList = JSON.parseArray(contrastNonHarmonicResult.getAValue() + "", RawResultDataVO.DetectionData.class);
|
||||
List<RawResultDataVO.DetectionData> bList = JSON.parseArray(contrastNonHarmonicResult.getBValue() + "", RawResultDataVO.DetectionData.class);
|
||||
List<RawResultDataVO.DetectionData> cList = JSON.parseArray(contrastNonHarmonicResult.getCValue() + "", RawResultDataVO.DetectionData.class);
|
||||
List<RawResultDataVO.DetectionData> tList = JSON.parseArray(contrastNonHarmonicResult.getTValue() + "", RawResultDataVO.DetectionData.class);
|
||||
|
||||
List<RawResultDataVO> rawResultDataVOList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(aList) && CollUtil.isNotEmpty(bList) && CollUtil.isNotEmpty(cList)) {
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setUnit(unit);
|
||||
dataVO.setDataA(aList.get(i));
|
||||
dataVO.setDataB(bList.get(i));
|
||||
dataVO.setDataC(cList.get(i));
|
||||
dataVO.setRadius(aList.get(i).getRadius());
|
||||
dataVO.setIsData(SimAndDigHarmonicServiceImpl.setResultFlag(Arrays.asList(aList.get(i), bList.get(i), cList.get(i))));
|
||||
rawResultDataVOList.add(dataVO);
|
||||
}
|
||||
} else if (CollUtil.isNotEmpty(bList)) {
|
||||
for (int i = 0; i < bList.size(); i++) {
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setUnit(unit);
|
||||
dataVO.setDataB(bList.get(i));
|
||||
dataVO.setRadius(bList.get(i).getRadius());
|
||||
dataVO.setIsData(SimAndDigHarmonicServiceImpl.setResultFlag(Arrays.asList(bList.get(i))));
|
||||
rawResultDataVOList.add(dataVO);
|
||||
}
|
||||
} else if (CollUtil.isNotEmpty(tList)) {
|
||||
for (int i = 0; i < tList.size(); i++) {
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setUnit(unit);
|
||||
dataVO.setDataT(tList.get(i));
|
||||
dataVO.setRadius(tList.get(i).getRadius());
|
||||
dataVO.setIsData(SimAndDigHarmonicServiceImpl.setResultFlag(Arrays.asList(tList.get(i))));
|
||||
rawResultDataVOList.add(dataVO);
|
||||
}
|
||||
}
|
||||
resultMap.put(dictTree.getName(), rawResultDataVOList);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(contrastHarmonicResults)) {
|
||||
ContrastHarmonicResult contrastHarmonicResult = contrastHarmonicResults.get(0);
|
||||
List<Double> harmonicNum = null;
|
||||
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||
unit = "%";
|
||||
if (DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
||||
unit = "A";
|
||||
}
|
||||
}
|
||||
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||
unit = "%";
|
||||
if (DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||
unit = "A";
|
||||
}
|
||||
}
|
||||
for (Double n : harmonicNum) {
|
||||
try {
|
||||
int i = StorageUtil.isHarmOrInHarm(n).intValue();
|
||||
String finalUnit = unit;
|
||||
|
||||
Field fieldA = contrastHarmonicResult.getClass().getDeclaredField("aValue" + i);
|
||||
fieldA.setAccessible(true);
|
||||
List<RawResultDataVO.DetectionData> aList = JSON.parseArray(fieldA.get(contrastHarmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
|
||||
Field fieldB = contrastHarmonicResult.getClass().getDeclaredField("bValue" + i);
|
||||
fieldB.setAccessible(true);
|
||||
List<RawResultDataVO.DetectionData> bList = JSON.parseArray(fieldB.get(contrastHarmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
|
||||
Field fieldC = contrastHarmonicResult.getClass().getDeclaredField("cValue" + i);
|
||||
fieldC.setAccessible(true);
|
||||
List<RawResultDataVO.DetectionData> cList = JSON.parseArray(fieldC.get(contrastHarmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
|
||||
List<RawResultDataVO> rawResultDataVOList = new ArrayList<>();
|
||||
for (int j = 0; j < aList.size(); j++) {
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(n);
|
||||
dataVO.setUnit(finalUnit);
|
||||
dataVO.setDataA(aList.get(j));
|
||||
dataVO.setDataB(bList.get(j));
|
||||
dataVO.setDataC(cList.get(j));
|
||||
dataVO.setRadius(aList.get(j).getRadius());
|
||||
dataVO.setIsData(SimAndDigHarmonicServiceImpl.setResultFlag(Arrays.asList(aList.get(j), bList.get(j), cList.get(j))));
|
||||
rawResultDataVOList.add(dataVO);
|
||||
}
|
||||
resultMap.put(String.valueOf(n), rawResultDataVOList);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private Map<String, List<AlignDataVO.RawData>> getRawDataMap(DictTree dictTree, List<String> adTypeList, String monitorId, Integer num, String code) {
|
||||
Map<String, List<AlignDataVO.RawData>> resultMap = new LinkedHashMap<>();
|
||||
|
||||
List<ContrastNonHarmonicResult> devNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, 0, monitorId, adTypeList);
|
||||
List<ContrastNonHarmonicResult> stdDevNonHarmonicRawDataList = contrastNonHarmonicService.listAllRawData(code, num, 1, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> devHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, 0, monitorId, adTypeList);
|
||||
List<ContrastHarmonicResult> stdDevHarmonicRawDataList = contrastHarmonicService.listAllRawData(code, num, 1, monitorId, adTypeList);
|
||||
|
||||
List<AlignDataVO.RawData> rawDataVOList = new ArrayList<>();
|
||||
for (int i = 0; i < devNonHarmonicRawDataList.size(); i++) {
|
||||
AlignDataVO.RawData rawDataVO = new AlignDataVO.RawData();
|
||||
ContrastNonHarmonicResult contrastNonHarmonicResult = devNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeDev(String.valueOf(contrastNonHarmonicResult.getTimeId()));
|
||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUbDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUtDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
|
||||
contrastNonHarmonicResult = stdDevNonHarmonicRawDataList.get(i);
|
||||
rawDataVO.setTimeStdDev(String.valueOf(contrastNonHarmonicResult.getTimeId()));
|
||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResult.getAValue()));
|
||||
rawDataVO.setUbStdDev(getValue(contrastNonHarmonicResult.getBValue()));
|
||||
rawDataVO.setUcStdDev(getValue(contrastNonHarmonicResult.getCValue()));
|
||||
rawDataVO.setUtStdDev(getValue(contrastNonHarmonicResult.getTValue()));
|
||||
|
||||
rawDataVOList.add(rawDataVO);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(rawDataVOList)) {
|
||||
resultMap.put(dictTree.getName(), rawDataVOList);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(devHarmonicRawDataList) && CollUtil.isNotEmpty(stdDevHarmonicRawDataList)) {
|
||||
List<Double> harmonicNum = null;
|
||||
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||
}
|
||||
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||
}
|
||||
for (Double n : harmonicNum) {
|
||||
List<AlignDataVO.RawData> rawDataVOList1 = new ArrayList<>();
|
||||
int i = StorageUtil.isHarmOrInHarm(n).intValue();
|
||||
for (int j = 0; j < devHarmonicRawDataList.size(); j++) {
|
||||
AlignDataVO.RawData rawDataVO = new AlignDataVO.RawData();
|
||||
ContrastHarmonicResult devHarmonicResult = devHarmonicRawDataList.get(j);
|
||||
ContrastHarmonicResult stdDevHarmonicResult = stdDevHarmonicRawDataList.get(j);
|
||||
|
||||
rawDataVO.setTimeDev(String.valueOf(devHarmonicResult.getTimeId()));
|
||||
rawDataVO.setTimeStdDev(String.valueOf(stdDevHarmonicResult.getTimeId()));
|
||||
|
||||
try {
|
||||
Field fieldA = devHarmonicResult.getClass().getDeclaredField("aValue" + i);
|
||||
fieldA.setAccessible(true);
|
||||
Double aValue = JSON.parseObject(fieldA.get(devHarmonicResult) + "", Double.class);
|
||||
|
||||
rawDataVO.setUaDev(aValue);
|
||||
Field fieldB = devHarmonicResult.getClass().getDeclaredField("bValue" + i);
|
||||
fieldB.setAccessible(true);
|
||||
Double bValue = JSON.parseObject(fieldB.get(devHarmonicResult) + "", Double.class);
|
||||
rawDataVO.setUbDev(bValue);
|
||||
|
||||
Field fieldC = devHarmonicResult.getClass().getDeclaredField("cValue" + i);
|
||||
fieldC.setAccessible(true);
|
||||
Double cValue = JSON.parseObject(fieldC.get(devHarmonicResult) + "", Double.class);
|
||||
rawDataVO.setUcDev(cValue);
|
||||
|
||||
Field fieldAStdDev = stdDevHarmonicResult.getClass().getDeclaredField("aValue" + i);
|
||||
fieldAStdDev.setAccessible(true);
|
||||
Double aValueStdDev = JSON.parseObject(fieldAStdDev.get(stdDevHarmonicResult) + "", Double.class);
|
||||
rawDataVO.setUaStdDev(aValueStdDev);
|
||||
|
||||
Field fieldBStdDev = stdDevHarmonicResult.getClass().getDeclaredField("bValue" + i);
|
||||
fieldBStdDev.setAccessible(true);
|
||||
Double bValueStdDev = JSON.parseObject(fieldBStdDev.get(stdDevHarmonicResult) + "", Double.class);
|
||||
rawDataVO.setUbStdDev(bValueStdDev);
|
||||
|
||||
Field fieldCStdDev = stdDevHarmonicResult.getClass().getDeclaredField("cValue" + i);
|
||||
fieldCStdDev.setAccessible(true);
|
||||
Double cValueStdDev = JSON.parseObject(fieldCStdDev.get(stdDevHarmonicResult) + "", Double.class);
|
||||
rawDataVO.setUcStdDev(cValueStdDev);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
rawDataVOList1.add(rawDataVO);
|
||||
}
|
||||
resultMap.put(String.valueOf(n), rawDataVOList1);
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private Double getValue(String value) {
|
||||
if (ObjectUtil.isNull(value)) {
|
||||
return null;
|
||||
} else {
|
||||
return Double.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
@@ -1597,10 +1872,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
List<SimAndDigNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllSimAndDigRawData(scriptId, oldCode, devId);
|
||||
List<SimAndDigNonHarmonicResult> allNonHarmonicRawData = simAndDigNonHarmonicService.listAllSimAndDigRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<SimAndDigNonHarmonicResult>> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(SimAndDigNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(SimAndDigNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<SimAndDigHarmonicResult> allHarmonicRawData = adHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
List<SimAndDigHarmonicResult> allHarmonicRawData = simAndDigHarmonicService.listAllRawData(scriptId, oldCode, devId);
|
||||
LinkedHashMap<Integer, List<SimAndDigHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(SimAndDigHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(SimAndDigHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',
|
||||
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
|
||||
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
|
||||
Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',
|
||||
A_Value_0 float NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
@@ -54,9 +55,10 @@
|
||||
Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',
|
||||
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
|
||||
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
|
||||
A_Value_0 json NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 json NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 json NULL COMMENT 'B相基波有效值',
|
||||
Flag tinyint(1) unsigned DEFAULT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',
|
||||
A_Value_0 json NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 json NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 json NULL COMMENT 'B相基波有效值',
|
||||
PRIMARY KEY (Id)
|
||||
</when>
|
||||
<otherwise>
|
||||
|
||||
@@ -21,4 +21,9 @@ public class ContrastBaseResult extends BaseResult {
|
||||
* 标准设备监测点id
|
||||
*/
|
||||
private String stdDevMonitorId;
|
||||
|
||||
/**
|
||||
* 0表示被检设备数据,1表示标准设备数据
|
||||
*/
|
||||
private Integer flag;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,33 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-28
|
||||
*/
|
||||
public interface ContrastHarmonicService extends IService<ContrastHarmonicResult> {
|
||||
|
||||
/**
|
||||
* 获取所有原始数据
|
||||
*
|
||||
* @param code
|
||||
* @param num 第几次检测
|
||||
* @param flag 0:被检设备,1:标准设备
|
||||
* @param devId 设备ID
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取所有谐波结果数据
|
||||
*
|
||||
* @param code
|
||||
* @param num 第几次检测
|
||||
* @param devId 设备ID
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, String devId, List<String> adTypeList);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,34 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-28
|
||||
*/
|
||||
public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonicResult> {
|
||||
|
||||
/**
|
||||
* 获取所有原始数据
|
||||
*
|
||||
* @param code
|
||||
* @param num 第几次检测
|
||||
* @param flag 0:被检设备,1:标准设备
|
||||
* @param devId 设备ID
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取所有非谐波结果数据
|
||||
*
|
||||
* @param code
|
||||
* @param num 第几次检测
|
||||
* @param devId 设备ID
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, String devId, List<String> adTypeList);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package com.njcn.gather.storage.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.storage.mapper.ContrastHarmonicMappper;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
import com.njcn.gather.storage.service.ContrastHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-28
|
||||
@@ -14,4 +19,29 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMappper, ContrastHarmonicResult> implements ContrastHarmonicService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
List<ContrastHarmonicResult> result = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.eq(ContrastHarmonicResult::getFlag, flag)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastHarmonicResult::getTimeId).list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllResultData(String code, Integer num, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
List<ContrastHarmonicResult> result = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList).list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package com.njcn.gather.storage.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.storage.mapper.ContrastNonHarmonicMappper;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-07-28
|
||||
@@ -14,4 +19,29 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmonicMappper, ContrastNonHarmonicResult> implements ContrastNonHarmonicService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
List<ContrastNonHarmonicResult> result = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, flag)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastNonHarmonicResult::getTimeId).list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
List<ContrastNonHarmonicResult> result = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList).list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.njcn.gather.storage.mapper.SimAndDigHarmonicMappper;
|
||||
import com.njcn.gather.storage.mapper.SimAndDigNonHarmonicMapper;
|
||||
import com.njcn.gather.storage.pojo.param.SingleNonHarmParam;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
@@ -25,6 +26,7 @@ import com.njcn.gather.system.dictionary.mapper.DictTreeMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.util.StorageUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -106,15 +108,15 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
||||
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
|
||||
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.ISO8601_PATTERN)));
|
||||
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
dataVO.setDataA(StrUtil.isNotBlank(fieldA.get(harmonicResult) + "") ? new BigDecimal(fieldA.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
dataVO.setDataB(StrUtil.isNotBlank(fieldB.get(harmonicResult) + "") ? new BigDecimal(fieldB.get(harmonicResult) + "").toPlainString() : null);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
dataVO.setDataC(StrUtil.isNotBlank(fieldC.get(harmonicResult) + "") ? new BigDecimal(fieldC.get(harmonicResult) + "").toPlainString() : null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
@@ -167,17 +169,17 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataB(b);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + StorageUtil.isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataC(c);
|
||||
@@ -275,7 +277,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
||||
return results;
|
||||
}
|
||||
|
||||
private Integer setResultFlag(List<RawResultDataVO.DetectionData> numbers) {
|
||||
public static Integer setResultFlag(List<RawResultDataVO.DetectionData> numbers) {
|
||||
List<Integer> isData = numbers.stream().filter(Objects::nonNull)
|
||||
.filter(x -> ObjectUtil.isNotNull(x.getData()))
|
||||
.map(RawResultDataVO.DetectionData::getIsData)
|
||||
@@ -284,7 +286,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
||||
return getInteger(isData);
|
||||
}
|
||||
|
||||
private static Integer getInteger(List<Integer> isData) {
|
||||
public static Integer getInteger(List<Integer> isData) {
|
||||
if (CollUtil.isNotEmpty(isData)) {
|
||||
List<Integer> isQualified = isData.stream().filter(x -> 1 == x || 2 == x).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(isQualified)) {
|
||||
@@ -306,11 +308,4 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
||||
return 4;
|
||||
}
|
||||
|
||||
public Double isHarmOrInHarm(Double value) {
|
||||
if (value == value.longValue()) {
|
||||
return value;
|
||||
} else {
|
||||
return value + 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.util.StorageUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -75,7 +76,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
|
||||
List<RawDataVO> rawDataVOS = new ArrayList<>();
|
||||
for (SimAndDigNonHarmonicResult result : value) {
|
||||
RawDataVO dataVO = new RawDataVO();
|
||||
dataVO.setUnit(dictTree.getCode().equals("MAG")?"%":unit(dictTree.getCode()));
|
||||
dataVO.setUnit(dictTree.getCode().equals("MAG")?"%": StorageUtil.unit(dictTree.getCode()));
|
||||
dataVO.setTime(result.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.ISO8601_PATTERN)));
|
||||
dataVO.setDataA(StrUtil.isNotBlank(result.getAValue()) ? new BigDecimal(result.getAValue()).toPlainString() : null);
|
||||
dataVO.setDataB(StrUtil.isNotBlank(result.getBValue()) ? new BigDecimal(result.getBValue()).toPlainString() : null);
|
||||
@@ -112,7 +113,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
|
||||
DictTree treeName = dictTreeByName.get(key);
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setIsData(result.getResultFlag());
|
||||
dataVO.setUnit(unit(treeName.getCode()));
|
||||
dataVO.setUnit(StorageUtil.unit(treeName.getCode()));
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(result.getAValue(), RawResultDataVO.DetectionData.class);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(result.getBValue(), RawResultDataVO.DetectionData.class);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(result.getCValue(), RawResultDataVO.DetectionData.class);
|
||||
@@ -196,96 +197,5 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
|
||||
return results;
|
||||
}
|
||||
|
||||
private String unit(String code) {
|
||||
String unit = "";
|
||||
switch (code) {
|
||||
/**
|
||||
* 频率
|
||||
*/
|
||||
case "FREQ":
|
||||
unit = "Hz";
|
||||
break;
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
case "VRMS":
|
||||
unit = "V";
|
||||
break;
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
case "IRMS":
|
||||
unit = "A";
|
||||
break;
|
||||
/**
|
||||
* 谐波电压
|
||||
*/
|
||||
case "V2-50":
|
||||
/**
|
||||
* 谐波电流
|
||||
*/
|
||||
case "I2-50":
|
||||
/**
|
||||
* 间谐波电压
|
||||
*/
|
||||
case "SV_1-49":
|
||||
/**
|
||||
* 间谐波电流
|
||||
*/
|
||||
case "SI_1-49":
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
*/
|
||||
case "V_UNBAN":
|
||||
/**
|
||||
* 三相电流不平衡度
|
||||
*/
|
||||
case "I_UNBAN":
|
||||
unit = "%";
|
||||
break;
|
||||
/**
|
||||
* 谐波有功功率
|
||||
*/
|
||||
case "P2-50":
|
||||
unit = "W";
|
||||
break;
|
||||
/**
|
||||
* 功率
|
||||
*/
|
||||
case "P":
|
||||
unit = "P";
|
||||
break;
|
||||
/**
|
||||
* 闪变
|
||||
*/
|
||||
case "PST":
|
||||
break;
|
||||
/**
|
||||
* 暂态-电压幅值
|
||||
*/
|
||||
case "MAG":
|
||||
unit = "%";
|
||||
break;
|
||||
/**
|
||||
* 暂态-持续时间
|
||||
*/
|
||||
case "DUR":
|
||||
unit = "s";
|
||||
break;
|
||||
/**
|
||||
* 相角
|
||||
*/
|
||||
case "VA":
|
||||
case "IA":
|
||||
unit = "°";
|
||||
break;
|
||||
/**
|
||||
* 电压偏差
|
||||
*/
|
||||
case "DELTA_V":
|
||||
unit = "%";
|
||||
break;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
"Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',\n" +
|
||||
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
|
||||
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
|
||||
"Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',\n" +
|
||||
"A_Value_0 float NULL COMMENT 'A相基波有效值',\n" +
|
||||
"C_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
"B_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
@@ -70,6 +71,7 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
"Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',\n" +
|
||||
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
|
||||
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
|
||||
"Flag tinyint(1) unsigned DEFAULT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',\n" +
|
||||
"A_Value_0 json NULL COMMENT 'A相基波有效值',\n" +
|
||||
"B_Value_0 json NULL COMMENT 'B相基波有效值',\n" +
|
||||
"C_Value_0 json NULL COMMENT 'B相基波有效值',\n" +
|
||||
|
||||
113
storage/src/main/java/com/njcn/gather/util/StorageUtil.java
Normal file
113
storage/src/main/java/com/njcn/gather/util/StorageUtil.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.njcn.gather.util;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-08-21
|
||||
*/
|
||||
public class StorageUtil {
|
||||
|
||||
public static Double isHarmOrInHarm(Double value) {
|
||||
if (value == value.longValue()) {
|
||||
return value;
|
||||
} else {
|
||||
return value + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public static String unit(String code) {
|
||||
String unit = "";
|
||||
switch (code) {
|
||||
/**
|
||||
* 频率
|
||||
*/
|
||||
case "FREQ":
|
||||
unit = "Hz";
|
||||
break;
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
case "V":
|
||||
case "VRMS":
|
||||
unit = "V";
|
||||
break;
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
case "I":
|
||||
case "IRMS":
|
||||
unit = "A";
|
||||
break;
|
||||
/**
|
||||
* 谐波电压
|
||||
*/
|
||||
case "V2-50":
|
||||
/**
|
||||
* 谐波电流
|
||||
*/
|
||||
case "I2-50":
|
||||
/**
|
||||
* 间谐波电压
|
||||
*/
|
||||
case "SV_1-49":
|
||||
/**
|
||||
* 间谐波电流
|
||||
*/
|
||||
case "SI_1-49":
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
*/
|
||||
case "V_UNBAN":
|
||||
case "IMBV":
|
||||
/**
|
||||
* 三相电流不平衡度
|
||||
*/
|
||||
case "I_UNBAN":
|
||||
case "IMBA":
|
||||
unit = "%";
|
||||
break;
|
||||
/**
|
||||
* 谐波有功功率
|
||||
*/
|
||||
case "P2-50":
|
||||
unit = "W";
|
||||
break;
|
||||
/**
|
||||
* 功率
|
||||
*/
|
||||
case "P":
|
||||
unit = "W";
|
||||
break;
|
||||
/**
|
||||
* 闪变
|
||||
*/
|
||||
case "PST":
|
||||
break;
|
||||
/**
|
||||
* 暂态-电压幅值
|
||||
*/
|
||||
case "MAG":
|
||||
unit = "%";
|
||||
break;
|
||||
/**
|
||||
* 暂态-持续时间
|
||||
*/
|
||||
case "DUR":
|
||||
unit = "s";
|
||||
break;
|
||||
/**
|
||||
* 相角
|
||||
*/
|
||||
case "VA":
|
||||
case "IA":
|
||||
unit = "°";
|
||||
break;
|
||||
/**
|
||||
* 电压偏差
|
||||
*/
|
||||
case "DELTA_V":
|
||||
unit = "%";
|
||||
break;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user