refactor(data): 优化谐波和间谐波数据一二次值处理逻辑
This commit is contained in:
@@ -115,10 +115,10 @@ public class DataServiceImpl implements IDataService {
|
|||||||
finalResult.add(vo);
|
finalResult.add(vo);
|
||||||
}
|
}
|
||||||
} else if (Objects.equals(item2.getHarmStart(),2)) {
|
} else if (Objects.equals(item2.getHarmStart(),2)) {
|
||||||
List<RealTimeDataVo> harmList = getHarmData(item2,param.getLineId());
|
List<RealTimeDataVo> harmList = getHarmData(item2,param.getLineId(),param.getDataLevel(),csDataSet.getDataLevel(),pt,ct);
|
||||||
finalResult.addAll(harmList);
|
finalResult.addAll(harmList);
|
||||||
} else if (Objects.equals(item2.getHarmStart(),1)) {
|
} else if (Objects.equals(item2.getHarmStart(),1)) {
|
||||||
List<RealTimeDataVo> inuharmList = getInuHarmData(item2,param.getLineId());
|
List<RealTimeDataVo> inuharmList = getInuHarmData(item2,param.getLineId(),param.getDataLevel(),csDataSet.getDataLevel(),pt,ct);
|
||||||
finalResult.addAll(inuharmList);
|
finalResult.addAll(inuharmList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -568,7 +568,7 @@ public class DataServiceImpl implements IDataService {
|
|||||||
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct;
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct;
|
||||||
break;
|
break;
|
||||||
case "*PT*CT":
|
case "*PT*CT":
|
||||||
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct / 1000;
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
@@ -594,46 +594,158 @@ public class DataServiceImpl implements IDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//谐波数据
|
//谐波数据
|
||||||
public List<RealTimeDataVo> getHarmData(EleEpdPqd item2, String lineId) {
|
public List<RealTimeDataVo> getHarmData(EleEpdPqd item2, String lineId, String dataLevel, String csDataSetLevel, Double pt, Double ct) {
|
||||||
List<RealTimeDataVo> list = new ArrayList<>();
|
List<RealTimeDataVo> list = new ArrayList<>();
|
||||||
for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) {
|
for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) {
|
||||||
RealTimeDataVo vo = new RealTimeDataVo();
|
RealTimeDataVo vo = new RealTimeDataVo();
|
||||||
vo.setId(item2.getId());
|
vo.setId(item2.getId());
|
||||||
vo.setName(item2.getName().concat("_").concat(Integer.toString(i)));
|
vo.setName(item2.getName().concat("_").concat(Integer.toString(i)));
|
||||||
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId));
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId));
|
||||||
|
double re;
|
||||||
|
String unit;
|
||||||
|
if (Objects.equals("Primary",dataLevel)) {
|
||||||
|
if (Objects.equals("Primary",csDataSetLevel)) {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
} else {
|
||||||
|
if(Objects.nonNull(item2.getPrimaryFormula())){
|
||||||
|
switch (item2.getPrimaryFormula()) {
|
||||||
|
case "*PT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt / 1000;
|
||||||
|
unit = "k" + item2.getUnit();
|
||||||
|
break;
|
||||||
|
case "*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * ct;
|
||||||
|
unit = item2.getUnit();
|
||||||
|
break;
|
||||||
|
case "*PT*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt * ct / 1000;
|
||||||
|
unit = "k" + item2.getUnit();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Objects.equals("Primary",csDataSetLevel)) {
|
||||||
|
if(Objects.nonNull(item2.getPrimaryFormula())) {
|
||||||
|
switch (item2.getPrimaryFormula()) {
|
||||||
|
case "*PT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt;
|
||||||
|
break;
|
||||||
|
case "*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct;
|
||||||
|
break;
|
||||||
|
case "*PT*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
}
|
||||||
|
unit = item2.getUnit();
|
||||||
|
}
|
||||||
if (Objects.isNull(statisticalDataDTO)) {
|
if (Objects.isNull(statisticalDataDTO)) {
|
||||||
vo.setAvgValue(3.14159);
|
vo.setAvgValue(3.14159);
|
||||||
} else {
|
} else {
|
||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
vo.setAvgValue(Double.valueOf(df.format(statisticalDataDTO.getValue())));
|
vo.setAvgValue(Double.valueOf(df.format(re)));
|
||||||
}
|
}
|
||||||
vo.setPhase(item2.getPhase());
|
vo.setPhase(item2.getPhase());
|
||||||
vo.setOtherName(i + "次" + "(" + item2.getUnit() + ")");
|
vo.setOtherName(i + "次" + "(" + unit + ")");
|
||||||
vo.setSort(item2.getSort());
|
vo.setSort(item2.getSort());
|
||||||
vo.setUnit(item2.getUnit());
|
vo.setUnit(unit);
|
||||||
list.add(vo);
|
list.add(vo);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
//间谐波数据
|
//间谐波数据
|
||||||
public List<RealTimeDataVo> getInuHarmData(EleEpdPqd item2, String lineId) {
|
public List<RealTimeDataVo> getInuHarmData(EleEpdPqd item2, String lineId, String dataLevel, String csDataSetLevel, Double pt, Double ct) {
|
||||||
List<RealTimeDataVo> list = new ArrayList<>();
|
List<RealTimeDataVo> list = new ArrayList<>();
|
||||||
for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) {
|
for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) {
|
||||||
RealTimeDataVo vo = new RealTimeDataVo();
|
RealTimeDataVo vo = new RealTimeDataVo();
|
||||||
vo.setId(item2.getId());
|
vo.setId(item2.getId());
|
||||||
vo.setName(item2.getName().concat("_").concat(Integer.toString(i)));
|
vo.setName(item2.getName().concat("_").concat(Integer.toString(i)));
|
||||||
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId));
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId));
|
||||||
|
double re;
|
||||||
|
String unit;
|
||||||
|
if (Objects.equals("Primary",dataLevel)) {
|
||||||
|
if (Objects.equals("Primary",csDataSetLevel)) {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
} else {
|
||||||
|
if(Objects.nonNull(item2.getPrimaryFormula())){
|
||||||
|
switch (item2.getPrimaryFormula()) {
|
||||||
|
case "*PT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt / 1000;
|
||||||
|
unit = "k" + item2.getUnit();
|
||||||
|
break;
|
||||||
|
case "*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * ct;
|
||||||
|
unit = item2.getUnit();
|
||||||
|
break;
|
||||||
|
case "*PT*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt * ct / 1000;
|
||||||
|
unit = "k" + item2.getUnit();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
unit = item2.getUnit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Objects.equals("Primary",csDataSetLevel)) {
|
||||||
|
if(Objects.nonNull(item2.getPrimaryFormula())) {
|
||||||
|
switch (item2.getPrimaryFormula()) {
|
||||||
|
case "*PT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt;
|
||||||
|
break;
|
||||||
|
case "*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct;
|
||||||
|
break;
|
||||||
|
case "*PT*CT":
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue();
|
||||||
|
}
|
||||||
|
unit = item2.getUnit();
|
||||||
|
}
|
||||||
if (Objects.isNull(statisticalDataDTO)) {
|
if (Objects.isNull(statisticalDataDTO)) {
|
||||||
vo.setAvgValue(3.14159);
|
vo.setAvgValue(3.14159);
|
||||||
} else {
|
} else {
|
||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
vo.setAvgValue(Double.valueOf(df.format(statisticalDataDTO.getValue())));
|
vo.setAvgValue(Double.valueOf(df.format(re)));
|
||||||
}
|
}
|
||||||
vo.setPhase(item2.getPhase());
|
vo.setPhase(item2.getPhase());
|
||||||
vo.setOtherName((i-0.5) + "次" + "(" + item2.getUnit() + ")");
|
vo.setOtherName((i-0.5) + "次" + "(" + unit + ")");
|
||||||
vo.setSort(item2.getSort());
|
vo.setSort(item2.getSort());
|
||||||
vo.setUnit(item2.getUnit());
|
vo.setUnit(unit);
|
||||||
list.add(vo);
|
list.add(vo);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
Reference in New Issue
Block a user