提交
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -49,6 +50,7 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final CommonService commonService;
|
||||
private final DecimalFormat df = new DecimalFormat("#0.0000");
|
||||
|
||||
@Override
|
||||
public List<ThdDataVO> queryThdData(String devId, String statisticalName) {
|
||||
@@ -174,21 +176,29 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
|
||||
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
||||
Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
|
||||
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||
|
||||
String frequency ="";
|
||||
if(Objects.isNull(commonStatisticalQueryParam.getFrequency())){
|
||||
frequency ="";
|
||||
}else {
|
||||
frequency = "_"+commonStatisticalQueryParam.getFrequency();
|
||||
}
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType());
|
||||
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
||||
String finalFrequency = frequency;
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
/*AB相映射A,BA相映射B,CA-》C*/
|
||||
|
||||
vo.setPhase(phaseReflection(temp.getPhaseType()));
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(data.getId());
|
||||
vo.setStatisticalName(data.getName()+"("+data.getUnit()+")");
|
||||
vo.setStatisticalName(data.getName()+ finalFrequency +"("+data.getUnit()+")");
|
||||
vo.setAnotherName(data.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@@ -219,7 +229,7 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(data.getId());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -256,7 +266,7 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(data.getId());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -264,4 +274,17 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
return collect1;
|
||||
}
|
||||
|
||||
private String phaseReflection(String phase){
|
||||
switch (phase) {
|
||||
case "AB":
|
||||
return "A";
|
||||
case "BC":
|
||||
return "B";
|
||||
case "CA":
|
||||
return "C";
|
||||
default:
|
||||
return phase;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user