调整表结构、编写查看检测结果接口、误差计算逻辑调整

This commit is contained in:
caozehui
2025-08-22 16:27:48 +08:00
parent 7b9954f1fe
commit d020890639
22 changed files with 712 additions and 158 deletions

View File

@@ -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);
}
}

View File

@@ -63,6 +63,9 @@ public class ResultParam {
// 通道号,当为-1时表示查询所有通道号否则只查询指定通道号
private String chnNum;
// 第几次检测
private Integer num;
}
@Data

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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()));