有功功率趋势2
This commit is contained in:
@@ -8,7 +8,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
||||
import com.njcn.device.pq.utils.ExcelStyleUtil;
|
||||
import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
@@ -45,18 +44,18 @@ public class PowerStatisticsController extends BaseController {
|
||||
* 根据监测点ID及时间获取有功功率趋势
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getDataByLineId")
|
||||
@PostMapping("/getDataByLineId")
|
||||
@ApiOperation("根据监测点ID及时间获取有功功率趋势")
|
||||
public HttpResult<PowerStatisticsVO> getDataByLineId(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getDataByLineId");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, powerStatisticsService.getDataByLine(powerStatisticsParam), methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, powerStatisticsService.getDataByLineId(powerStatisticsParam), methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getTargetLimitById")
|
||||
@PostMapping("/getTargetLimitById")
|
||||
@ApiOperation("根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表")
|
||||
public HttpResult<List<PowerStatisticsTargetVO>> getTargetLimitById(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getTargetLimitById");
|
||||
@@ -67,7 +66,7 @@ public class PowerStatisticsController extends BaseController {
|
||||
* 点击越限列表时间查询指标的详细数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getTargetByTime")
|
||||
@PostMapping("/getTargetByTime")
|
||||
@ApiOperation("点击越限列表时间查询指标的详细数据")
|
||||
public HttpResult<List<ThdDataVO>> getTargetByTime(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getTargetByTime");
|
||||
@@ -75,13 +74,23 @@ public class PowerStatisticsController extends BaseController {
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("导出设备基础数据模板")
|
||||
@GetMapping(value = "getExcelTemplate")
|
||||
public HttpResult<String> getExcelTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("数据", "数据");
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
@ApiOperation("导出区间数据")
|
||||
@PostMapping(value = "exportExcelRangTemplate")
|
||||
public HttpResult<String> getExcelRangTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("区间数据", "区间数据");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TerminalBaseExcel.class, new ArrayList<TerminalBaseExcel>());
|
||||
String fileName = "数据.xlsx";
|
||||
String fileName = "导出区间数据.xlsx";
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("导出指标越限列表数据")
|
||||
@PostMapping(value = "exportExcelListTemplate")
|
||||
public HttpResult<String> getExcelListTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("指标越限列表数据", "指标越限列表数据");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TerminalBaseExcel.class, new ArrayList<TerminalBaseExcel>());
|
||||
String fileName = "导出指标越限列表数据.xlsx";
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface PowerStatisticsService {
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
PowerStatisticsVO getDataByLine(PowerStatisticsParam powerStatisticsParam);
|
||||
PowerStatisticsVO getDataByLineId(PowerStatisticsParam powerStatisticsParam);
|
||||
|
||||
/**
|
||||
* 根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表
|
||||
|
||||
@@ -13,13 +13,14 @@ import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -34,15 +35,20 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
|
||||
private final RActivePowerRangeFeignClient rActivePowerRangeFeignClient;
|
||||
|
||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||
|
||||
private final CommonService commonService;
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat(Param.DECIMAL_FORMATSTR);
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private List<String> METHODS = Arrays.asList("AVG","CP95","MIN","MAX");
|
||||
|
||||
private List<String> PHASE = Arrays.asList("A","B","C");
|
||||
|
||||
@Override
|
||||
public PowerStatisticsVO getDataByLine(PowerStatisticsParam powerStatisticsParam) {
|
||||
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId()).getData();
|
||||
public PowerStatisticsVO getDataByLineId(PowerStatisticsParam powerStatisticsParam) {
|
||||
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId(),
|
||||
powerStatisticsParam.getSearchBeginTime(),powerStatisticsParam.getSearchEndTime()).getData();
|
||||
if(rActivePowerRangePO == null){
|
||||
throw new BusinessException(HarmonicResponseEnum.NO_LINE_DATA.getMessage());
|
||||
}
|
||||
@@ -56,7 +62,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
List<PowerStatisticsTargetVO> list = new ArrayList();
|
||||
for (int i = 0; i < (int) (Math.random() * 10 + 1); i++) {
|
||||
PowerStatisticsTargetVO powerStatisticsTargetVO = new PowerStatisticsTargetVO();
|
||||
powerStatisticsTargetVO.setTime("2024-06-01 18:00:00");
|
||||
powerStatisticsTargetVO.setTime("2023-02-10 09:00:0" + i);
|
||||
powerStatisticsTargetVO.setVoltageOffset(1);
|
||||
powerStatisticsTargetVO.setVTimes(0);
|
||||
powerStatisticsTargetVO.setITimes(1);
|
||||
@@ -73,29 +79,152 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
@Override
|
||||
public List<ThdDataVO> getTargetByTime(PowerStatisticsParam powerStatisticsParam) {
|
||||
List<ThdDataVO> result = new ArrayList();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(powerStatisticsParam.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = new ArrayList<>();
|
||||
if("1".equals(powerStatisticsParam.getStatisticalId())){
|
||||
com.njcn.device.pq.constant.Param.DATABSEMAP.forEach((key,value) ->{
|
||||
List<EleEpdPqd> epdPqds = epdFeignClient.findListByShowName(key).getData();
|
||||
for(EleEpdPqd epdPqd : epdPqds){
|
||||
epdPqd.setShowName(value);
|
||||
}
|
||||
if(!epdPqds.isEmpty()){
|
||||
//这边相别只需要获得一个即可
|
||||
eleEpdPqds.add(epdPqds.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
if("2".equals(powerStatisticsParam.getStatisticalId())){
|
||||
com.njcn.device.pq.constant.Param.UHARMMAP.forEach((key,value) ->{
|
||||
List<EleEpdPqd> epdPqds = epdFeignClient.findListByShowName(key).getData();
|
||||
for(EleEpdPqd epdPqd : epdPqds){
|
||||
epdPqd.setShowName(value);
|
||||
}
|
||||
if(!epdPqds.isEmpty()){
|
||||
//这边相别只需要获得一个即可
|
||||
eleEpdPqds.add(epdPqds.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
if("3".equals(powerStatisticsParam.getStatisticalId())){
|
||||
com.njcn.device.pq.constant.Param.IHARMMAP.forEach((key,value) ->{
|
||||
List<EleEpdPqd> epdPqds = epdFeignClient.findListByShowName(key).getData();
|
||||
for(EleEpdPqd epdPqd : epdPqds){
|
||||
epdPqd.setShowName(value);
|
||||
}
|
||||
if(!epdPqds.isEmpty()){
|
||||
//这边相别只需要获得一个即可
|
||||
eleEpdPqds.add(epdPqds.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
if("4".equals(powerStatisticsParam.getStatisticalId())){
|
||||
com.njcn.device.pq.constant.Param.INTERHARMONICMAP.forEach((key,value) ->{
|
||||
List<EleEpdPqd> epdPqds = epdFeignClient.findListByShowName(key).getData();
|
||||
for(EleEpdPqd epdPqd : epdPqds){
|
||||
epdPqd.setShowName(value);
|
||||
}
|
||||
if(!epdPqds.isEmpty()){
|
||||
//这边相别只需要获得一个即可
|
||||
eleEpdPqds.add(epdPqds.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
eleEpdPqds.forEach(epdPqd->{
|
||||
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
|
||||
commonQueryParams.clear();
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(powerStatisticsParam.getLineId());
|
||||
commonQueryParam.setTableName(epdPqd.getClassId());
|
||||
commonQueryParam.setColumnName(epdPqd.getName());
|
||||
commonQueryParam.setStartTime(powerStatisticsParam.getSearchBeginTime());
|
||||
commonQueryParam.setEndTime(powerStatisticsParam.getSearchEndTime());
|
||||
commonQueryParams.add(commonQueryParam);
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
if(epdPqd.getHarmEnd()!=null && epdPqd.getHarmStart()!=null){
|
||||
for (int i = epdPqd.getHarmStart().intValue(); i <= epdPqd.getHarmEnd().intValue(); i++) {
|
||||
ThdDataVO thdDataVO = new ThdDataVO();
|
||||
String index = i+"";
|
||||
if(epdPqd.getShowName().equals("间谐波电压含有率")){
|
||||
thdDataVO.setAnotherName(Integer.parseInt(index) - 0.5 + "次");
|
||||
}else{
|
||||
thdDataVO.setAnotherName(index + "次");
|
||||
}
|
||||
getThdDataVO(epdPqd.getOtherName()+"_"+index,thdDataVO,epdPqd,powerStatisticsParam);
|
||||
result.add(thdDataVO);
|
||||
}
|
||||
}else{
|
||||
ThdDataVO thdDataVO = new ThdDataVO();
|
||||
thdDataVO.setAnotherName(epdPqd.getShowName());
|
||||
getThdDataVO(null,thdDataVO,epdPqd,powerStatisticsParam);
|
||||
result.add(thdDataVO);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private ThdDataVO getThdDataVO(String columnName,ThdDataVO thdDataVO,EleEpdPqd epdPqd,PowerStatisticsParam powerStatisticsParam){
|
||||
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(powerStatisticsParam.getLineId());
|
||||
commonQueryParam.setTableName(epdPqd.getClassId());
|
||||
commonQueryParam.setColumnName(columnName == null ? epdPqd.getOtherName():columnName);
|
||||
commonQueryParam.setStartTime(powerStatisticsParam.getSearchBeginTime());
|
||||
commonQueryParam.setEndTime(powerStatisticsParam.getSearchEndTime());
|
||||
commonQueryParam.setDataType(METHODS.get(0));
|
||||
commonQueryParam.setPhasic(PHASE.get(0));
|
||||
commonQueryParams.add(commonQueryParam);
|
||||
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setAVGPhaseA(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(0));
|
||||
commonQueryParam.setPhasic(PHASE.get(1));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setAVGPhaseB(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(0));
|
||||
commonQueryParam.setPhasic(PHASE.get(2));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setAVGPhaseC(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(1));
|
||||
commonQueryParam.setPhasic(PHASE.get(0));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setCP95PhaseA(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(1));
|
||||
commonQueryParam.setPhasic(PHASE.get(1));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setCP95PhaseB(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(1));
|
||||
commonQueryParam.setPhasic(PHASE.get(2));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setCP95PhaseC(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(2));
|
||||
commonQueryParam.setPhasic(PHASE.get(0));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMINPhaseA(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(2));
|
||||
commonQueryParam.setPhasic(PHASE.get(1));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMINPhaseB(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(2));
|
||||
commonQueryParam.setPhasic(PHASE.get(2));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMINPhaseC(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(3));
|
||||
commonQueryParam.setPhasic(PHASE.get(0));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMAXPhaseA(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(3));
|
||||
commonQueryParam.setPhasic(PHASE.get(1));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMAXPhaseB(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
|
||||
commonQueryParam.setDataType(METHODS.get(3));
|
||||
commonQueryParam.setPhasic(PHASE.get(2));
|
||||
deviceRtData = commonService.getNewDeviceRtDataByTime(commonQueryParams);
|
||||
if(!deviceRtData.isEmpty()) thdDataVO.setMAXPhaseC(Double.valueOf(df.format(deviceRtData.get(0).getValue())));
|
||||
return thdDataVO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user