|
|
|
|
@@ -24,6 +24,7 @@ import com.njcn.gather.storage.service.AdHarmonicService;
|
|
|
|
|
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 lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
@@ -32,6 +33,7 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -44,6 +46,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
|
|
|
|
|
|
|
|
|
private final AdNonHarmonicMapper adNonHarmonicMapper;
|
|
|
|
|
private final DictTreeMapper dictTreeMapper;
|
|
|
|
|
private final IDictTreeService dictTreeService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, String code) {
|
|
|
|
|
@@ -73,65 +76,64 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
|
|
|
|
.orderByAsc(AdHarmonicResult::getTimeId)
|
|
|
|
|
;
|
|
|
|
|
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
|
|
|
|
LinkedHashMap<String, List<AdHarmonicResult>> adMap =
|
|
|
|
|
adHarmonicResults.stream().collect(Collectors.groupingBy(AdHarmonicResult::getAdType, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet()));
|
|
|
|
|
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
|
|
|
|
Map<String, List<RawDataVO>> info = new LinkedHashMap<>(3);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(adHarmonicResults)) {
|
|
|
|
|
List<Double> harmNum = param.getHarmNum();
|
|
|
|
|
RawDataVO dataVO;
|
|
|
|
|
List<RawDataVO> rawDataVOS;
|
|
|
|
|
DictTree dictData = dictTreeMapper.selectById(adHarmonicResults.get(0).getAdType());
|
|
|
|
|
String unit;
|
|
|
|
|
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "A";
|
|
|
|
|
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "W";
|
|
|
|
|
} else {
|
|
|
|
|
unit = "%";
|
|
|
|
|
}
|
|
|
|
|
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
|
|
|
|
for (Double i : harmNum) {
|
|
|
|
|
dataVO = new RawDataVO();
|
|
|
|
|
dataVO.setHarmNum(i);
|
|
|
|
|
dataVO.setUnit(unit);
|
|
|
|
|
try {
|
|
|
|
|
Field timeId = harmonicResult.getClass().getDeclaredField("timeId");
|
|
|
|
|
timeId.setAccessible(true);
|
|
|
|
|
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
|
|
|
|
|
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
|
|
|
|
|
|
|
|
|
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + 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());
|
|
|
|
|
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());
|
|
|
|
|
fieldC.setAccessible(true);
|
|
|
|
|
dataVO.setDataC(StrUtil.isNotBlank(fieldC.get(harmonicResult) + "") ? new BigDecimal(fieldC.get(harmonicResult) + "").toPlainString() : null);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
if (info.containsKey(String.valueOf(i))) {
|
|
|
|
|
info.get(String.valueOf(i)).add(dataVO);
|
|
|
|
|
} else {
|
|
|
|
|
rawDataVOS = new ArrayList<>();
|
|
|
|
|
rawDataVOS.add(dataVO);
|
|
|
|
|
info.put(String.valueOf(i), rawDataVOS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adMap.forEach((ad,value)->{
|
|
|
|
|
if (dictTreeByName.containsKey(ad)) {
|
|
|
|
|
DictTree dictData = dictTreeByName.get(ad);
|
|
|
|
|
List<RawDataVO> rawDataVOS = new ArrayList<>();
|
|
|
|
|
List<Double> harmNum = param.getHarmNum();
|
|
|
|
|
RawDataVO dataVO;
|
|
|
|
|
String unit;
|
|
|
|
|
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "A";
|
|
|
|
|
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "W";
|
|
|
|
|
} else {
|
|
|
|
|
unit = "%";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
|
|
|
|
for (Double i : harmNum) {
|
|
|
|
|
dataVO = new RawDataVO();
|
|
|
|
|
dataVO.setHarmNum(i);
|
|
|
|
|
dataVO.setUnit(unit);
|
|
|
|
|
try {
|
|
|
|
|
Field timeId = harmonicResult.getClass().getDeclaredField("timeId");
|
|
|
|
|
timeId.setAccessible(true);
|
|
|
|
|
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
|
|
|
|
|
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
|
|
|
|
|
|
|
|
|
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + 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());
|
|
|
|
|
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());
|
|
|
|
|
fieldC.setAccessible(true);
|
|
|
|
|
dataVO.setDataC(StrUtil.isNotBlank(fieldC.get(harmonicResult) + "") ? new BigDecimal(fieldC.get(harmonicResult) + "").toPlainString() : null);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
rawDataVOS.add(dataVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
info.put(dictData.getName(), rawDataVOS);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
DynamicTableNameHandler.remove();
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, RawResultDataVO> listHarmResultData(StorageParam param) {
|
|
|
|
|
public Map<String, List<RawResultDataVO>> listHarmResultData(StorageParam param) {
|
|
|
|
|
String prefix = "ad_harmonic_result_";
|
|
|
|
|
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
|
|
|
|
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
|
|
|
|
@@ -139,55 +141,61 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
|
|
|
|
.eq(ObjectUtil.isNotNull(param.getScriptId()), AdHarmonicResult::getScriptId, param.getScriptId())
|
|
|
|
|
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdHarmonicResult::getSort, param.getIndex())
|
|
|
|
|
.orderByAsc(AdHarmonicResult::getTimeId);
|
|
|
|
|
|
|
|
|
|
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
|
|
|
|
Map<String, RawResultDataVO> info = new LinkedHashMap<>(3);
|
|
|
|
|
if (CollUtil.isNotEmpty(adHarmonicResults)) {
|
|
|
|
|
List<Double> harmNum = param.getHarmNum();
|
|
|
|
|
RawResultDataVO dataVO;
|
|
|
|
|
DictTree dictData = dictTreeMapper.selectById(adHarmonicResults.get(0).getAdType());
|
|
|
|
|
String unit;
|
|
|
|
|
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "A";
|
|
|
|
|
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "W";
|
|
|
|
|
} else {
|
|
|
|
|
unit = "%";
|
|
|
|
|
}
|
|
|
|
|
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
|
|
|
|
for (Double i : harmNum) {
|
|
|
|
|
dataVO = new RawResultDataVO();
|
|
|
|
|
dataVO.setHarmNum(i);
|
|
|
|
|
dataVO.setUnit(unit);
|
|
|
|
|
try {
|
|
|
|
|
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + 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());
|
|
|
|
|
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());
|
|
|
|
|
fieldC.setAccessible(true);
|
|
|
|
|
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
|
|
|
|
dataVO.setDataC(c);
|
|
|
|
|
if (ObjectUtil.isNotNull(a)) {
|
|
|
|
|
dataVO.setRadius(a.getRadius());
|
|
|
|
|
}
|
|
|
|
|
dataVO.setIsData(setResultFlag(Arrays.asList(a, b, c)));
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
info.put(String.valueOf(i), dataVO);
|
|
|
|
|
LinkedHashMap<String, List<AdHarmonicResult>> adMap =
|
|
|
|
|
adHarmonicResults.stream().collect(Collectors.groupingBy(AdHarmonicResult::getAdType, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet()));
|
|
|
|
|
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
|
|
|
|
Map<String, List<RawResultDataVO>> info = new LinkedHashMap<>(3);
|
|
|
|
|
adMap.forEach((ad,value)->{
|
|
|
|
|
if (dictTreeByName.containsKey(ad)) {
|
|
|
|
|
DictTree dictData = dictTreeByName.get(ad);
|
|
|
|
|
List<RawResultDataVO> rawDataVOS = new ArrayList<>();
|
|
|
|
|
List<Double> harmNum = param.getHarmNum();
|
|
|
|
|
RawResultDataVO dataVO;
|
|
|
|
|
String unit;
|
|
|
|
|
if (DictDataEnum.I2_50.getCode().equals(dictData.getCode()) || DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "A";
|
|
|
|
|
} else if (DictDataEnum.P2_50.getCode().equals(dictData.getCode())) {
|
|
|
|
|
unit = "W";
|
|
|
|
|
} else {
|
|
|
|
|
unit = "%";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (AdHarmonicResult harmonicResult : value) {
|
|
|
|
|
for (Double i : harmNum) {
|
|
|
|
|
dataVO = new RawResultDataVO();
|
|
|
|
|
dataVO.setHarmNum(i);
|
|
|
|
|
dataVO.setUnit(unit);
|
|
|
|
|
try {
|
|
|
|
|
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + 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());
|
|
|
|
|
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());
|
|
|
|
|
fieldC.setAccessible(true);
|
|
|
|
|
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult) + "", RawResultDataVO.DetectionData.class);
|
|
|
|
|
dataVO.setDataC(c);
|
|
|
|
|
if (ObjectUtil.isNotNull(a)) {
|
|
|
|
|
dataVO.setRadius(a.getRadius());
|
|
|
|
|
}
|
|
|
|
|
dataVO.setIsData(setResultFlag(Arrays.asList(a, b, c)));
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
rawDataVOS.add(dataVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
info.put(dictData.getName(), rawDataVOS);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
DynamicTableNameHandler.remove();
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|