有功功率趋势定时任务算法完善

This commit is contained in:
guofeihu
2024-09-05 14:17:11 +08:00
parent 9fca0e5714
commit 8e6f07330e
18 changed files with 772 additions and 183 deletions

View File

@@ -16,44 +16,44 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public class PowerStatisticsParam extends BaseParam {
@ApiModelProperty(name = "lineId", value = "监测点ID")
@ApiModelProperty("监测点ID")
@NotBlank(message = "监测点ID不能为空")
private String lineId;
@ApiModelProperty(name = "statisticalId", value = "指标分类ID(用于查询指标详细数据的指标分类ID)")
@ApiModelProperty("指标分类ID(用于查询指标详细数据的指标分类ID)")
private String statisticalId;
@ApiModelProperty(name = "field", value = "区间字段(用于查询指标越限列表)")
@ApiModelProperty("区间字段(用于查询指标越限列表)")
private String field;
@ApiModelProperty(name = "time0", value = "区间1时间集合")
@ApiModelProperty("区间1时间集合")
private List<String> time0;
@ApiModelProperty(name = "time1", value = "区间2时间集合")
@ApiModelProperty("区间2时间集合")
private List<String> time1;
@ApiModelProperty(name = "time2", value = "区间3时间集合")
@ApiModelProperty("区间3时间集合")
private List<String> time2;
@ApiModelProperty(name = "time3", value = "区间4时间集合")
@ApiModelProperty("区间4时间集合")
private List<String> time3;
@ApiModelProperty(name = "time4", value = "区间5时间集合")
@ApiModelProperty("区间5时间集合")
private List<String> time4;
@ApiModelProperty(name = "time5", value = "区间6时间集合")
@ApiModelProperty("区间6时间集合")
private List<String> time5;
@ApiModelProperty(name = "time6", value = "区间7时间集合")
@ApiModelProperty("区间7时间集合")
private List<String> time6;
@ApiModelProperty(name = "time7", value = "区间8时间集合")
@ApiModelProperty("区间8时间集合")
private List<String> time7;
@ApiModelProperty(name = "time8", value = "区间9时间集合")
@ApiModelProperty("区间9时间集合")
private List<String> time8;
@ApiModelProperty(name = "time9", value = "区间10时间集合")
@ApiModelProperty("区间10时间集合")
private List<String> time9;
}

View File

@@ -3,6 +3,8 @@ package com.njcn.harmonic.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 有功功率趋势指标 实体类
@@ -17,27 +19,84 @@ public class PowerStatisticsTargetVO {
private String time;
@ApiModelProperty("电压偏差")
private Integer voltageOffset;
private Integer voltageOffset = 0;
@ApiModelProperty(value = "谐波电压")
private Integer vTimes;
@ApiModelProperty("谐波电压")
private Integer vTimes = 0;
@ApiModelProperty(value = "谐波电流")
private Integer iTimes;
@ApiModelProperty("谐波电流")
private Integer iTimes = 0;
@ApiModelProperty("三相电压不平衡度")
private Integer ubalance;
private Integer ubalance = 0;
@ApiModelProperty(value="电压波动")
private Integer voltageFluctuation;
@ApiModelProperty("电压波动")
private Integer voltageFluctuation = 0;
@ApiModelProperty("闪变")
private Integer flicker;
private Integer flicker = 0;
@ApiModelProperty("间谐波电压含有率")
private Integer interHarmonic;
private Integer interHarmonic = 0;
@ApiModelProperty("电流不平衡度")
private Integer sequenceCurrentUnbalance;
private Integer sequenceCurrentUnbalance = 0;
@ApiModelProperty("区间字段(标识是哪个区间:10%~20%、20%~30%....)用于后端辅助计算")
private String field;
@ApiModelProperty("电压偏差详情")
private List<ThdDataVO> voltageOffsetList = new ArrayList<>();
@ApiModelProperty("谐波电压详情")
private List<ThdDataVO> vTimesList = new ArrayList<>();
@ApiModelProperty("谐波电流详情")
private List<ThdDataVO> iTimestList = new ArrayList<>();
@ApiModelProperty("三相电压不平衡度详情")
private List<ThdDataVO> ubalanceList = new ArrayList<>();
@ApiModelProperty("电压波动")
private List<ThdDataVO> voltageFluctuationList = new ArrayList<>();
@ApiModelProperty("闪变详情")
private List<ThdDataVO> flickerList = new ArrayList<>();
@ApiModelProperty("间谐波电压含有率详情")
private List<ThdDataVO> interHarmonicList = new ArrayList<>();
@ApiModelProperty("电流不平衡度详情")
private List<ThdDataVO> sequenceCurrentUnbalanceList = new ArrayList<>();
@ApiModelProperty("越限相别(用于后端辅助计算)")
private String phasicType;
@ApiModelProperty("越限统计方式(用于后端辅助计算)")
private String valueType;;
@ApiModelProperty("电压偏差国标限制(用于后端辅助计算)")
private Float voltageOffsetLimit;
@ApiModelProperty("谐波电压国标限制(用于后端辅助计算)")
private Float vTimesLimit;
@ApiModelProperty("谐波电流国标限制(用于后端辅助计算)")
private Float iTimesLimit;
@ApiModelProperty("三相电压不平衡度国标限制(用于后端辅助计算)")
private Float ubalanceLimit;
@ApiModelProperty("电压波动国标限制(用于后端辅助计算)")
private Float voltageFluctuationLimit;
@ApiModelProperty("闪变国标限制(用于后端辅助计算)")
private Float flickerLimit;
@ApiModelProperty("间谐波电压含有率国标限制(用于后端辅助计算)")
private Float interHarmonicLimit;
@ApiModelProperty("电流不平衡度国标限制(用于后端辅助计算)")
private Float sequenceCurrentUnbalanceLimit;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.harmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -10,22 +11,64 @@ import lombok.Data;
@Data
public class ThdDataVO {
@ApiModelProperty("名称")
private String anotherName;
@ApiModelProperty("单位")
private String unit;
private Double AVGPhaseA;
private Double AVGPhaseB;
private Double AVGPhaseC;
private Double CP95PhaseA;
private Double CP95PhaseB;
private Double CP95PhaseC;
@ApiModelProperty("平均值A相")
private String AVGPhaseA;
private Double MINPhaseA;
private Double MINPhaseB;
private Double MINPhaseC;
@ApiModelProperty("平均值B相")
private String AVGPhaseB;
private Double MAXPhaseA;
private Double MAXPhaseB;
private Double MAXPhaseC;
@ApiModelProperty("平均值C相")
private String AVGPhaseC;
@ApiModelProperty("CP95A相")
private String CP95PhaseA;
@ApiModelProperty("CP95B相")
private String CP95PhaseB;
@ApiModelProperty("CP95C相")
private String CP95PhaseC;
@ApiModelProperty("最小值A相")
private String MINPhaseA;
@ApiModelProperty("最小值B相")
private String MINPhaseB;
@ApiModelProperty("最小值C相")
private String MINPhaseC;
@ApiModelProperty("最大值A相")
private String MAXPhaseA;
@ApiModelProperty("最大值B相")
private String MAXPhaseB;
@ApiModelProperty("最大值C相")
private String MAXPhaseC;
@ApiModelProperty("国标限值")
private Float limit;
public void init(){
this.AVGPhaseA = "0";
this.AVGPhaseB = "0";
this.AVGPhaseC = "0";
this.CP95PhaseA = "0";
this.CP95PhaseB = "0";
this.CP95PhaseC = "0";
this.MINPhaseA = "0";
this.MINPhaseB = "0";
this.MINPhaseC = "0";
this.MAXPhaseA = "0";
this.MAXPhaseB = "0";
this.MAXPhaseC = "0";
}
}

View File

@@ -2,10 +2,8 @@ package com.njcn.harmonic.service.activepowerrange.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
import cn.hutool.core.bean.BeanUtil;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
import com.njcn.harmonic.pojo.vo.PowerStatisticsExcelRangVO;
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
@@ -13,10 +11,12 @@ import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
import com.njcn.harmonic.pojo.vo.ThdDataVO;
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.service.CommonService;
import com.njcn.poi.util.PoiUtil;
import com.njcn.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
import com.njcn.prepare.harmonic.pojo.param.RActivePowerRangeParam;
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd;
@@ -29,9 +29,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* 有功功率趋势统计 服务实现类
@@ -61,7 +60,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId(),
powerStatisticsParam.getSearchBeginTime(),powerStatisticsParam.getSearchEndTime()).getData();
if(rActivePowerRangePO == null){
throw new BusinessException(HarmonicResponseEnum.NO_LINE_DATA.getMessage());
rActivePowerRangePO = new RActivePowerRangePO();
}
PowerStatisticsVO powerStatisticsVO = new PowerStatisticsVO();
BeanUtils.copyProperties(rActivePowerRangePO, powerStatisticsVO);
@@ -87,21 +86,140 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
@Override
public List<PowerStatisticsTargetVO> getTargetLimitById(PowerStatisticsParam powerStatisticsParam) {
List<PowerStatisticsTargetVO> list = new ArrayList();
for (int i = 0; i < (int) (Math.random() * 10 + 1); i++) {
List<PowerStatisticsTargetVO> data = new ArrayList<>();
RActivePowerRangeParam rActivePowerRangeParam = new RActivePowerRangeParam();
BeanUtil.copyProperties(powerStatisticsParam, rActivePowerRangeParam);
rActivePowerRangeParam.setSearch(true);
//重点说明:powerStatisticsTargetVO结构(维度)为:time可能多组相同,取决于功率表data_harmpower_p中的相别及统计方式,标识每个指标是否越限,总之一句话:当前时间中八个指标是否越限及他们的相别和统计方式是什么
//基于record结构需要做维度的转换
List<PowerStatisticsTargetVO> record = rActivePowerRangeFeignClient.record(rActivePowerRangeParam).getData();
//根据时间分组:
Map<String,List<PowerStatisticsTargetVO>> map = record.stream().collect(Collectors.groupingBy(PowerStatisticsTargetVO::getTime));
map.forEach((key, value) ->{
PowerStatisticsTargetVO powerStatisticsTargetVO = new PowerStatisticsTargetVO();
powerStatisticsTargetVO.setTime("2023-02-10 09:00:0" + i);
powerStatisticsTargetVO.setVoltageOffset(1);
powerStatisticsTargetVO.setVTimes(0);
powerStatisticsTargetVO.setITimes(1);
powerStatisticsTargetVO.setUbalance(1);
powerStatisticsTargetVO.setVoltageFluctuation(0);
powerStatisticsTargetVO.setFlicker(0);
powerStatisticsTargetVO.setInterHarmonic(1);
powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
list.add(powerStatisticsTargetVO);
}
return list;
powerStatisticsTargetVO.setTime(key);
ThdDataVO thdDataVO = new ThdDataVO();
thdDataVO.init();
Map<String,String> voltageOffsetPV = new HashMap<>();
Map<String,String> vTimesPV = new HashMap<>();
Map<String,String> iTimesPV = new HashMap<>();
Map<String,String> ubalancePV = new HashMap<>();
Map<String,String> voltageFluctuationPV = new HashMap<>();
Map<String,String> flickerPV = new HashMap<>();
Map<String,String> interHarmonicPV = new HashMap<>();
Map<String,String> sequenceCurrentUnbalancePV = new HashMap<>();
for(PowerStatisticsTargetVO vo : value){
if(vo.getVoltageOffset() == 1){
powerStatisticsTargetVO.setVoltageOffset(1);
voltageOffsetPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getVTimes() == 1){
powerStatisticsTargetVO.setVTimes(1);
vTimesPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getITimes() == 1){
powerStatisticsTargetVO.setITimes(1);
iTimesPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getUbalance() == 1){
powerStatisticsTargetVO.setUbalance(1);
ubalancePV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getVoltageFluctuation() == 1){
powerStatisticsTargetVO.setVoltageFluctuation(1);
voltageFluctuationPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getFlicker() == 1){
powerStatisticsTargetVO.setFlicker(1);
flickerPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getInterHarmonic() == 1){
powerStatisticsTargetVO.setInterHarmonic(1);
interHarmonicPV.put(vo.getPhasicType(),vo.getValueType());
}
if(vo.getSequenceCurrentUnbalance() == 1){
powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
sequenceCurrentUnbalancePV.put(vo.getPhasicType(),vo.getValueType());
}
}
powerStatisticsTargetVO.setVoltageOffsetList(initPV(voltageOffsetPV,"电压偏差",value.get(0).getVoltageOffsetLimit()));
powerStatisticsTargetVO.setVTimesList(initPV(vTimesPV,"谐波电压",value.get(0).getVTimesLimit()));
powerStatisticsTargetVO.setITimestList(initPV(iTimesPV,"谐波电流",value.get(0).getITimesLimit()));
powerStatisticsTargetVO.setUbalanceList(initPV(ubalancePV,"三相电压不平衡度",value.get(0).getUbalanceLimit()));
powerStatisticsTargetVO.setVoltageFluctuationList(initPV(voltageFluctuationPV,"电压波动",value.get(0).getVoltageFluctuationLimit()));
powerStatisticsTargetVO.setFlickerList(initPV(flickerPV,"闪变",value.get(0).getFlickerLimit()));
powerStatisticsTargetVO.setInterHarmonicList(initPV(interHarmonicPV,"间谐波电压含有率",value.get(0).getInterHarmonicLimit()));
powerStatisticsTargetVO.setSequenceCurrentUnbalanceList(initPV(sequenceCurrentUnbalancePV,"电流不平衡度",value.get(0).getSequenceCurrentUnbalanceLimit()));
data.add(powerStatisticsTargetVO);
});
return data;
}
private List<ThdDataVO> initPV(Map<String,String> pv,String name,Float limit){
List<ThdDataVO> thdDataVOS = new ArrayList<>();
ThdDataVO tdv = new ThdDataVO();
tdv.setAnotherName(name);
tdv.setLimit(limit);
tdv.init();
pv.forEach((phasicType, valueType) ->{
switch (valueType){
case InfluxDBTableConstant.AVG:
switch (valueType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setAVGPhaseA("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setAVGPhaseB("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setAVGPhaseC("1");
break;
}
break;
case InfluxDBTableConstant.CP95:
switch (valueType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setCP95PhaseA("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setCP95PhaseB("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setCP95PhaseC("1");
break;
}
break;
case InfluxDBTableConstant.MIN:
switch (valueType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMINPhaseA("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMINPhaseB("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMINPhaseC("1");
break;
}
break;
case InfluxDBTableConstant.MAX:
switch (valueType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMAXPhaseA("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMAXPhaseB("1");
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMAXPhaseC("1");
break;
}
break;
}
});
thdDataVOS.add(tdv);
return thdDataVOS;
}
@Override
@@ -190,71 +308,71 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
commonQueryParam.setLineId(powerStatisticsParam.getLineId());
commonQueryParam.setTableName(epdPqd.getClassId());
commonQueryParam.setColumnName(columnName == null ? epdPqd.getOtherName():columnName);
commonQueryParam.setStartTime(powerStatisticsParam.getSearchBeginTime());
commonQueryParam.setEndTime(powerStatisticsParam.getSearchEndTime());
commonQueryParam.setStartTime(powerStatisticsParam.getSearchBeginTime()+Param.START_TIME);
commonQueryParam.setEndTime(powerStatisticsParam.getSearchEndTime()+ Param.END_TIME);
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())));
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())));
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())));
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())));
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())));
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())));
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())));
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())));
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())));
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())));
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())));
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())));
if(!deviceRtData.isEmpty()) thdDataVO.setMAXPhaseC(Double.valueOf(df.format(deviceRtData.get(0).getValue()))+"");
return thdDataVO;
}
@@ -263,40 +381,44 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
PowerStatisticsVO powerStatisticsVO = getDataByLineId(powerStatisticsParam);
//开始组装excel所需数据
List<PowerStatisticsExcelRangVO> powerStatisticsVOS = new ArrayList<>();
ExportParams exportParams = new ExportParams(powerStatisticsParam.getSearchValue(), "区间数据");
//各区间数量
PowerStatisticsExcelRangVO num = new PowerStatisticsExcelRangVO();
num.setMinsNum0(powerStatisticsVO.getMinsNum0()+"");
num.setMinsNum1(powerStatisticsVO.getMinsNum1()+"");
num.setMinsNum2(powerStatisticsVO.getMinsNum2()+"");
num.setMinsNum3(powerStatisticsVO.getMinsNum3()+"");
num.setMinsNum4(powerStatisticsVO.getMinsNum4()+"");
num.setMinsNum5(powerStatisticsVO.getMinsNum5()+"");
num.setMinsNum6(powerStatisticsVO.getMinsNum6()+"");
num.setMinsNum7(powerStatisticsVO.getMinsNum7()+"");
num.setMinsNum8(powerStatisticsVO.getMinsNum8()+"");
num.setMinsNum9(powerStatisticsVO.getMinsNum9()+"");
num.setMinsNum0(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum0()+"");
num.setMinsNum1(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum1()+"");
num.setMinsNum2(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum2()+"");
num.setMinsNum3(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum3()+"");
num.setMinsNum4(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum4()+"");
num.setMinsNum5(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum5()+"");
num.setMinsNum6(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum6()+"");
num.setMinsNum7(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum7()+"");
num.setMinsNum8(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum8()+"");
num.setMinsNum9(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getMinsNum9()+"");
num.setText("个数");
powerStatisticsVOS.add(num);
//各区间是否越限
PowerStatisticsExcelRangVO isOrNot = new PowerStatisticsExcelRangVO();
isOrNot.setMinsNum0(powerStatisticsVO.getIsOrNot0()>0?"":"");
isOrNot.setMinsNum1(powerStatisticsVO.getIsOrNot1()>0?"":"");
isOrNot.setMinsNum2(powerStatisticsVO.getIsOrNot2()>0?"":"");
isOrNot.setMinsNum3(powerStatisticsVO.getIsOrNot3()>0?"":"");
isOrNot.setMinsNum4(powerStatisticsVO.getIsOrNot4()>0?"":"");
isOrNot.setMinsNum5(powerStatisticsVO.getIsOrNot5()>0?"":"");
isOrNot.setMinsNum6(powerStatisticsVO.getIsOrNot6()>0?"":"");
isOrNot.setMinsNum7(powerStatisticsVO.getIsOrNot7()>0?"":"");
isOrNot.setMinsNum8(powerStatisticsVO.getIsOrNot8()>0?"":"");
isOrNot.setMinsNum9(powerStatisticsVO.getIsOrNot9()>0?"":"");
isOrNot.setMinsNum0(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot0()>0?"":"");
isOrNot.setMinsNum1(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot1()>0?"":"");
isOrNot.setMinsNum2(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot2()>0?"":"");
isOrNot.setMinsNum3(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot3()>0?"":"");
isOrNot.setMinsNum4(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot4()>0?"":"");
isOrNot.setMinsNum5(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot5()>0?"":"");
isOrNot.setMinsNum6(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot6()>0?"":"");
isOrNot.setMinsNum7(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot7()>0?"":"");
isOrNot.setMinsNum8(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot8()>0?"":"");
isOrNot.setMinsNum9(powerStatisticsVO.getLineId() == null? "":powerStatisticsVO.getIsOrNot9()>0?"":"");
isOrNot.setText("是否越限");
powerStatisticsVOS.add(isOrNot);
//各区间占比
PowerStatisticsExcelRangVO proportion = new PowerStatisticsExcelRangVO();
int total = powerStatisticsVO.getMinsNum0() + powerStatisticsVO.getMinsNum1() + powerStatisticsVO.getMinsNum2()
+ powerStatisticsVO.getMinsNum3() + powerStatisticsVO.getMinsNum4() + powerStatisticsVO.getMinsNum5()
+ powerStatisticsVO.getMinsNum6() + powerStatisticsVO.getMinsNum7() + powerStatisticsVO.getMinsNum8()
+ powerStatisticsVO.getMinsNum9();
int total = 0;
if(powerStatisticsVO.getLineId() != null){
total = powerStatisticsVO.getMinsNum0() + powerStatisticsVO.getMinsNum1() + powerStatisticsVO.getMinsNum2()
+ powerStatisticsVO.getMinsNum3() + powerStatisticsVO.getMinsNum4() + powerStatisticsVO.getMinsNum5()
+ powerStatisticsVO.getMinsNum6() + powerStatisticsVO.getMinsNum7() + powerStatisticsVO.getMinsNum8()
+ powerStatisticsVO.getMinsNum9();
}
if(total != 0){
proportion.setMinsNum0(dftwo.format((double)powerStatisticsVO.getMinsNum0().intValue() / total * 100) + "%");
proportion.setMinsNum1(dftwo.format((double)powerStatisticsVO.getMinsNum1().intValue() / total * 100) + "%");
@@ -308,11 +430,21 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
proportion.setMinsNum7(dftwo.format((double)powerStatisticsVO.getMinsNum7().intValue() / total * 100) + "%");
proportion.setMinsNum8(dftwo.format((double)powerStatisticsVO.getMinsNum8().intValue() / total * 100) + "%");
proportion.setMinsNum9(dftwo.format((double)powerStatisticsVO.getMinsNum9().intValue() / total * 100) + "%");
}else{
proportion.setMinsNum0("");
proportion.setMinsNum1("");
proportion.setMinsNum2("");
proportion.setMinsNum3("");
proportion.setMinsNum4("");
proportion.setMinsNum5("");
proportion.setMinsNum6("");
proportion.setMinsNum7("");
proportion.setMinsNum8("");
proportion.setMinsNum9("");
}
proportion.setText("占比");
powerStatisticsVOS.add(proportion);
//数据准备完毕开始渲染excel
ExportParams exportParams = new ExportParams("", "区间数据");
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PowerStatisticsExcelRangVO.class, powerStatisticsVOS);
Sheet sheet = workbook.getSheet("区间数据");
Font redFont = workbook.createFont();
@@ -347,8 +479,8 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
//设置斜线的开始位置,我这里是从第0行到第1行从第0列到第1列
anchor.setCol1(0);
anchor.setCol2(1);
anchor.setRow1(0);
anchor.setRow2(1);
anchor.setRow1(1);
anchor.setRow2(2);
XSSFSimpleShape simpleShape = xssfDrawing.createSimpleShape((XSSFClientAnchor) anchor);
//设置形状类型未线型
simpleShape.setShapeType(ShapeTypes.LINE);
@@ -359,18 +491,18 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
//设置线的颜色
simpleShape.setLineStyleColor(0,0,0);
//删除第一行title
sheet.removeRow(sheet.getRow(0));
//sheet.removeRow(sheet.getRow(0));
//上移(因为删除一行只是将数据清空了留下空行)
sheet.shiftRows(1, sheet.getLastRowNum(), -1);
PoiUtil.exportFileByWorkbook(workbook, "区间数据.xlsx", response);
//sheet.shiftRows(1, sheet.getLastRowNum(), -1);
PoiUtil.exportFileByWorkbook(workbook, powerStatisticsParam.getSearchValue()+".xlsx", response);
}
@Override
public void exportExcelListTemplate(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);
ExportParams exportParams = new ExportParams(powerStatisticsParam.getSearchValue(), "指标越限列表数据");
List<PowerStatisticsTargetVO> powerStatisticsTargetVOS = getTargetLimitById(powerStatisticsParam);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PowerStatisticsTargetVO.class, powerStatisticsTargetVOS);
PoiUtil.exportFileByWorkbook(workbook, powerStatisticsParam.getSearchValue()+".xlsx", response);
}
}