@@ -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 ad NonHarmonicService;
private final SimAndDigHarmonicService ad HarmonicService;
private final SimAndDigNonHarmonicService simAndDig NonHarmonicService;
private final SimAndDigHarmonicService simAndDig HarmonicService;
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 ( ad HarmonicService. get ( scriptId , indexList , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
allResultList . addAll ( simAndDig HarmonicService. get ( scriptId , indexList , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
} else {
allResultList . addAll ( ad NonHarmonicService. listSimAndDigBaseResult ( scriptId , indexList , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
allResultList . addAll ( simAndDig NonHarmonicService. listSimAndDigBaseResult ( scriptId , indexList , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
}
} else { //查询所有的脚本类型
allResultList . addAll ( ad HarmonicService. get ( scriptId , null , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
allResultList . addAll ( ad NonHarmonicService. listSimAndDigBaseResult ( scriptId , null , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
allResultList . addAll ( simAndDig HarmonicService. get ( scriptId , null , queryParam . getDeviceId ( ) , queryParam . getChnNum ( ) , plan . getCode ( ) + " " ) ) ;
allResultList . addAll ( simAndDig NonHarmonicService. 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 ( ad NonHarmonicService. listSimAndDigBaseResult ( param . getScriptId ( ) , indexList , param . getDevId ( ) , param . getDevNum ( ) , param . getCode ( ) ) ) ;
allResultList . addAll ( ad HarmonicService. get ( param . getScriptId ( ) , indexList , param . getDevId ( ) , param . getDevNum ( ) , param . getCode ( ) ) ) ;
allResultList . addAll ( simAndDig NonHarmonicService. listSimAndDigBaseResult ( param . getScriptId ( ) , indexList , param . getDevId ( ) , param . getDevNum ( ) , param . getCode ( ) ) ) ;
allResultList . addAll ( simAndDig HarmonicService. 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 ( ad NonHarmonicService. listNonHarmData ( storage ) ) ;
resultVO . setResultData ( ad NonHarmonicService. listNonHarmResultData ( storage ) ) ;
resultVO . setRawData ( simAndDig NonHarmonicService. listNonHarmData ( storage ) ) ;
resultVO . setResultData ( simAndDig NonHarmonicService. listNonHarmResultData ( storage ) ) ;
} else {
storage . setHarmNum ( harmNum ) ;
resultVO . setRawData ( ad HarmonicService. listHarmData ( storage ) ) ;
resultVO . setResultData ( ad HarmonicService. listHarmResultData ( storage ) ) ;
resultVO . setRawData ( simAndDig HarmonicService. listHarmData ( storage ) ) ;
resultVO . setResultData ( simAndDig HarmonicService. listHarmResultData ( storage ) ) ;
}
return resultVO ;
}
@@ -853,10 +863,10 @@ public class ResultServiceImpl implements IResultService {
}
ResultVO resultVO = new ResultVO ( ) ;
if ( CollUtil . isEmpty ( harmNum ) ) {
resultVO . setResultData ( ad NonHarmonicService. listNonHarmResultData ( storage ) ) ;
resultVO . setResultData ( simAndDig NonHarmonicService. listNonHarmResultData ( storage ) ) ;
} else {
storage . setHarmNum ( harmNum ) ;
resultVO . setResultData ( ad HarmonicService. listHarmResultData ( storage ) ) ;
resultVO . setResultData ( simAndDig HarmonicService. listHarmResultData ( storage ) ) ;
}
return resultVO ;
}
@@ -885,10 +895,10 @@ public class ResultServiceImpl implements IResultService {
Map < String , List < RawDataVO > > rawDataMap = null ;
if ( CollUtil . isEmpty ( harmNum ) ) {
rawDataMap = ad NonHarmonicService. listNonHarmData ( storage ) ;
rawDataMap = simAndDig NonHarmonicService. listNonHarmData ( storage ) ;
} else {
storage . setHarmNum ( harmNum ) ;
rawDataMap = ad HarmonicService. listHarmData ( storage ) ;
rawDataMap = simAndDig HarmonicService. 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 = ad NonHarmonicService. queryByCondition ( param ) ;
List < SimAndDigNonHarmonicResult > nonHarmList = simAndDig NonHarmonicService. 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 = ad HarmonicService. getSingleResult ( param ) ;
SimAndDigHarmonicResult singleResult = simAndDig HarmonicService. 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 = ad NonHarmonicService. queryByCondition ( param ) ;
List < SimAndDigNonHarmonicResult > nonHarmList = simAndDig NonHarmonicService. 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 = ad NonHarmonicService. queryByCondition ( param ) ;
List < SimAndDigNonHarmonicResult > nonHarmList = simAndDig NonHarmonicService. 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 = ad NonHarmonicService. listAllSimAndDigRawData ( scriptId , oldCode , devId ) ;
List < SimAndDigNonHarmonicResult > allNonHarmonicRawData = simAndDig NonHarmonicService. 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 = ad HarmonicService. listAllRawData ( scriptId , oldCode , devId ) ;
List < SimAndDigHarmonicResult > allHarmonicRawData = simAndDig HarmonicService. 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 ( ) ) ) ;