有功功率趋势区间excel导出
This commit is contained in:
@@ -69,4 +69,6 @@ public interface Param {
|
||||
|
||||
//DecimalFormat格式化
|
||||
String DECIMAL_FORMATSTR = "#0.0000";
|
||||
|
||||
String DECIMAL_FORMATTWOSTR = "#.##";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.harmonic.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 有功功率趋势区间Excel 实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-20
|
||||
*/
|
||||
@Data
|
||||
public class PowerStatisticsExcelRangVO {
|
||||
|
||||
@Excel(name = "详情 区间")
|
||||
private String text;
|
||||
|
||||
@Excel(name = "0%~10%")
|
||||
private String minsNum0;
|
||||
|
||||
@Excel(name = "10%~20%")
|
||||
private String minsNum1;
|
||||
|
||||
@Excel(name = "20%~30%")
|
||||
private String minsNum2;
|
||||
|
||||
@Excel(name = "30%~40%")
|
||||
private String minsNum3;
|
||||
|
||||
@Excel(name = "40%~50%")
|
||||
private String minsNum4;
|
||||
|
||||
@Excel(name = "50%~60%")
|
||||
private String minsNum5;
|
||||
|
||||
@Excel(name = "60%~70%")
|
||||
private String minsNum6;
|
||||
|
||||
@Excel(name = "70%~80%")
|
||||
private String minsNum7;
|
||||
|
||||
@Excel(name = "80%~90%")
|
||||
private String minsNum8;
|
||||
|
||||
@Excel(name = "90%~100%")
|
||||
private String minsNum9;
|
||||
|
||||
}
|
||||
@@ -30,6 +30,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("0%~10%区间是否越限")
|
||||
private Integer isOrNot0;
|
||||
|
||||
@ApiModelProperty("0%~10%百分比")
|
||||
private Double proportion0 = 0.0;
|
||||
|
||||
@ApiModelProperty("10%~20%区间时间Json")
|
||||
private String minsTime1;
|
||||
|
||||
@@ -39,6 +42,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("10%~20%区间是否越限")
|
||||
private Integer isOrNot1;
|
||||
|
||||
@ApiModelProperty("10%~20%百分比")
|
||||
private Double proportion1 = 0.0;;
|
||||
|
||||
@ApiModelProperty("20%~30%区间时间Json")
|
||||
private String minsTime2;
|
||||
|
||||
@@ -48,6 +54,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("20%~30%区间是否越限")
|
||||
private Integer isOrNot2;
|
||||
|
||||
@ApiModelProperty("20%~30%百分比")
|
||||
private Double proportion2 = 0.0;;
|
||||
|
||||
@ApiModelProperty("30%~40%区间时间Json")
|
||||
private String minsTime3;
|
||||
|
||||
@@ -57,6 +66,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("30%~40%区间是否越限")
|
||||
private Integer isOrNot3;
|
||||
|
||||
@ApiModelProperty("30%~40%百分比")
|
||||
private Double proportion3 = 0.0;;
|
||||
|
||||
@ApiModelProperty("40%~50%区间时间Json")
|
||||
private String minsTime4;
|
||||
|
||||
@@ -66,6 +78,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("40%~50%区间是否越限")
|
||||
private Integer isOrNot4;
|
||||
|
||||
@ApiModelProperty("40%~50%百分比")
|
||||
private Double proportion4 = 0.0;;
|
||||
|
||||
@ApiModelProperty("50%~60%区间时间Json")
|
||||
private String minsTime5;
|
||||
|
||||
@@ -75,6 +90,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("50%~60%区间是否越限")
|
||||
private Integer isOrNot5;
|
||||
|
||||
@ApiModelProperty("50%~60%百分比")
|
||||
private Double proportion5 = 0.0;;
|
||||
|
||||
@ApiModelProperty("60%~70%区间时间Json")
|
||||
private String minsTime6;
|
||||
|
||||
@@ -84,6 +102,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("60%~70%区间是否越限")
|
||||
private Integer isOrNot6;
|
||||
|
||||
@ApiModelProperty("60%~70%百分比")
|
||||
private Double proportion6 = 0.0;;
|
||||
|
||||
@ApiModelProperty("70%~80%区间时间Json")
|
||||
private String minsTime7;
|
||||
|
||||
@@ -93,6 +114,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("70%~80%区间是否越限")
|
||||
private Integer isOrNot7;
|
||||
|
||||
@ApiModelProperty("70%~80%百分比")
|
||||
private Double proportion7 = 0.0;;
|
||||
|
||||
@ApiModelProperty("80%~90%区间时间Json")
|
||||
private String minsTime8;
|
||||
|
||||
@@ -102,6 +126,9 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("80%~90%区间是否越限")
|
||||
private Integer isOrNot8;
|
||||
|
||||
@ApiModelProperty("80%~90%百分比")
|
||||
private Double proportion8 = 0.0;;
|
||||
|
||||
@ApiModelProperty("90%~100%区间时间Json")
|
||||
private String minsTime9;
|
||||
|
||||
@@ -111,4 +138,7 @@ public class PowerStatisticsVO {
|
||||
@ApiModelProperty("90%~100%区间是否越限")
|
||||
private Integer isOrNot9;
|
||||
|
||||
@ApiModelProperty("90%~100%百分比")
|
||||
private Double proportion9 = 0.0;;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.Data;
|
||||
public class ThdDataVO {
|
||||
|
||||
private String anotherName;
|
||||
private String unit;
|
||||
private Double AVGPhaseA;
|
||||
private Double AVGPhaseB;
|
||||
private Double AVGPhaseC;
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
package com.njcn.harmonic.controller.powerstatistics;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
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.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -76,23 +70,15 @@ public class PowerStatisticsController extends BaseController {
|
||||
@ResponseBody
|
||||
@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";
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
public void exportExcelRangTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
powerStatisticsService.exportExcelRangTemplate(powerStatisticsParam,response);
|
||||
}
|
||||
|
||||
@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;
|
||||
public void exportExcelListTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
powerStatisticsService.exportExcelListTemplate(powerStatisticsParam,response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -34,4 +35,18 @@ public interface PowerStatisticsService {
|
||||
*/
|
||||
List<ThdDataVO> getTargetByTime(PowerStatisticsParam powerStatisticsParam);
|
||||
|
||||
/**
|
||||
* 导出区间数据
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
void exportExcelRangTemplate(PowerStatisticsParam powerStatisticsParam, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导出指标越限列表数据
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
void exportExcelListTemplate(PowerStatisticsParam powerStatisticsParam,HttpServletResponse response);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
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 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;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
@@ -11,18 +15,23 @@ import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
|
||||
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
||||
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.po.RActivePowerRangePO;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDrawing;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
|
||||
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.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 有功功率趋势统计 服务实现类
|
||||
@@ -39,6 +48,8 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat(Param.DECIMAL_FORMATSTR);
|
||||
|
||||
private final DecimalFormat dftwo = new DecimalFormat(Param.DECIMAL_FORMATTWOSTR);
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private List<String> METHODS = Arrays.asList("AVG","CP95","MIN","MAX");
|
||||
@@ -54,6 +65,23 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
}
|
||||
PowerStatisticsVO powerStatisticsVO = new PowerStatisticsVO();
|
||||
BeanUtils.copyProperties(rActivePowerRangePO, powerStatisticsVO);
|
||||
//计算各区间占比
|
||||
int total = powerStatisticsVO.getMinsNum0() + powerStatisticsVO.getMinsNum1() + powerStatisticsVO.getMinsNum2()
|
||||
+ powerStatisticsVO.getMinsNum3() + powerStatisticsVO.getMinsNum4() + powerStatisticsVO.getMinsNum5()
|
||||
+ powerStatisticsVO.getMinsNum6() + powerStatisticsVO.getMinsNum7() + powerStatisticsVO.getMinsNum8()
|
||||
+ powerStatisticsVO.getMinsNum9();
|
||||
if(total != 0){
|
||||
powerStatisticsVO.setProportion0(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum0().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion1(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum1().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion2(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum2().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion3(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum3().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion4(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum4().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion5(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum5().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion6(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum6().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion7(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum7().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion8(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum8().intValue() / total * 100)));
|
||||
powerStatisticsVO.setProportion9(Double.parseDouble(dftwo.format((double)powerStatisticsVO.getMinsNum9().intValue() / total * 100)));
|
||||
}
|
||||
return powerStatisticsVO;
|
||||
}
|
||||
|
||||
@@ -134,6 +162,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
if(epdPqd.getHarmEnd()!=null && epdPqd.getHarmStart()!=null){
|
||||
for (int i = epdPqd.getHarmStart().intValue(); i <= epdPqd.getHarmEnd().intValue(); i++) {
|
||||
ThdDataVO thdDataVO = new ThdDataVO();
|
||||
thdDataVO.setUnit(epdPqd.getUnit());
|
||||
String index = i+"";
|
||||
if(epdPqd.getShowName().equals("间谐波电压含有率")){
|
||||
thdDataVO.setAnotherName(Integer.parseInt(index) - 0.5 + "次");
|
||||
@@ -146,6 +175,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
}else{
|
||||
ThdDataVO thdDataVO = new ThdDataVO();
|
||||
thdDataVO.setAnotherName(epdPqd.getShowName());
|
||||
thdDataVO.setUnit(epdPqd.getUnit());
|
||||
getThdDataVO(null,thdDataVO,epdPqd,powerStatisticsParam);
|
||||
result.add(thdDataVO);
|
||||
}
|
||||
@@ -153,6 +183,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
//将各个指标的所有的相别统计方式以表格的维度进行组装数据
|
||||
private ThdDataVO getThdDataVO(String columnName,ThdDataVO thdDataVO,EleEpdPqd epdPqd,PowerStatisticsParam powerStatisticsParam){
|
||||
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
@@ -227,4 +258,119 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
return thdDataVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportExcelRangTemplate(PowerStatisticsParam powerStatisticsParam, HttpServletResponse response) {
|
||||
PowerStatisticsVO powerStatisticsVO = getDataByLineId(powerStatisticsParam);
|
||||
//开始组装excel所需数据
|
||||
List<PowerStatisticsExcelRangVO> powerStatisticsVOS = new ArrayList<>();
|
||||
//各区间数量
|
||||
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.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.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();
|
||||
if(total != 0){
|
||||
proportion.setMinsNum0(dftwo.format((double)powerStatisticsVO.getMinsNum0().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum1(dftwo.format((double)powerStatisticsVO.getMinsNum1().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum2(dftwo.format((double)powerStatisticsVO.getMinsNum2().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum3(dftwo.format((double)powerStatisticsVO.getMinsNum3().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum4(dftwo.format((double)powerStatisticsVO.getMinsNum4().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum5(dftwo.format((double)powerStatisticsVO.getMinsNum5().intValue() / total * 100) + "%");
|
||||
proportion.setMinsNum6(dftwo.format((double)powerStatisticsVO.getMinsNum6().intValue() / total * 100) + "%");
|
||||
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) + "%");
|
||||
}
|
||||
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();
|
||||
redFont.setColor(IndexedColors.RED.getIndex());
|
||||
//将数据的表格加边框
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
for (int j = 0; j <= 10; j++) {
|
||||
Cell cell = row.getCell(j);
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
//如果当前表格为是(是否越限:是)则红色字体显示
|
||||
if(cell.getStringCellValue().equals("是")){
|
||||
style.setFont(redFont);
|
||||
}
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
//设置统一列宽
|
||||
for (int j = 0; j <= 10; j++) {
|
||||
sheet.setColumnWidth(j, 4295);
|
||||
}
|
||||
//第一行第一列设置斜杠
|
||||
CreationHelper helper = workbook.getCreationHelper();
|
||||
XSSFDrawing xssfDrawing = (XSSFDrawing) sheet.createDrawingPatriarch();
|
||||
ClientAnchor anchor = helper.createClientAnchor();
|
||||
//设置斜线的开始位置,我这里是从第0行到第1行,从第0列到第1列
|
||||
anchor.setCol1(0);
|
||||
anchor.setCol2(1);
|
||||
anchor.setRow1(0);
|
||||
anchor.setRow2(1);
|
||||
XSSFSimpleShape simpleShape = xssfDrawing.createSimpleShape((XSSFClientAnchor) anchor);
|
||||
//设置形状类型未线型
|
||||
simpleShape.setShapeType(ShapeTypes.LINE);
|
||||
//设置线宽
|
||||
simpleShape.setLineWidth(0.5);
|
||||
//设置线的风格
|
||||
simpleShape.setLineStyle(0);
|
||||
//设置线的颜色
|
||||
simpleShape.setLineStyleColor(0,0,0);
|
||||
//删除第一行title
|
||||
sheet.removeRow(sheet.getRow(0));
|
||||
//上移(因为删除一行只是将数据清空了留下空行)
|
||||
sheet.shiftRows(1, sheet.getLastRowNum(), -1);
|
||||
PoiUtil.exportFileByWorkbook(workbook, "区间数据.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,29 +126,32 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
|
||||
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId,lineId).eq(RActivePowerRangePO::getState,"1")
|
||||
.between(RActivePowerRangePO::getTimeId,startTime,endTime);
|
||||
List<RActivePowerRangePO> rActivePowerRangePOS = this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
|
||||
for(RActivePowerRangePO rangePO : rActivePowerRangePOS){
|
||||
rActivePowerRangePO.setMinsNum0(rangePO.getMinsNum0()+rActivePowerRangePO.getMinsNum0());
|
||||
rActivePowerRangePO.setMinsNum1(rangePO.getMinsNum1()+rActivePowerRangePO.getMinsNum1());
|
||||
rActivePowerRangePO.setMinsNum2(rangePO.getMinsNum2()+rActivePowerRangePO.getMinsNum2());
|
||||
rActivePowerRangePO.setMinsNum3(rangePO.getMinsNum3()+rActivePowerRangePO.getMinsNum3());
|
||||
rActivePowerRangePO.setMinsNum4(rangePO.getMinsNum4()+rActivePowerRangePO.getMinsNum4());
|
||||
rActivePowerRangePO.setMinsNum5(rangePO.getMinsNum5()+rActivePowerRangePO.getMinsNum5());
|
||||
rActivePowerRangePO.setMinsNum6(rangePO.getMinsNum6()+rActivePowerRangePO.getMinsNum6());
|
||||
rActivePowerRangePO.setMinsNum7(rangePO.getMinsNum7()+rActivePowerRangePO.getMinsNum7());
|
||||
rActivePowerRangePO.setMinsNum8(rangePO.getMinsNum8()+rActivePowerRangePO.getMinsNum8());
|
||||
rActivePowerRangePO.setMinsNum9(rangePO.getMinsNum9()+rActivePowerRangePO.getMinsNum9());
|
||||
rActivePowerRangePO.setIsOrNot0(rangePO.getIsOrNot0()+rActivePowerRangePO.getIsOrNot0());
|
||||
rActivePowerRangePO.setIsOrNot1(rangePO.getIsOrNot1()+rActivePowerRangePO.getIsOrNot1());
|
||||
rActivePowerRangePO.setIsOrNot2(rangePO.getIsOrNot2()+rActivePowerRangePO.getIsOrNot2());
|
||||
rActivePowerRangePO.setIsOrNot3(rangePO.getIsOrNot3()+rActivePowerRangePO.getIsOrNot3());
|
||||
rActivePowerRangePO.setIsOrNot4(rangePO.getIsOrNot4()+rActivePowerRangePO.getIsOrNot4());
|
||||
rActivePowerRangePO.setIsOrNot5(rangePO.getIsOrNot5()+rActivePowerRangePO.getIsOrNot5());
|
||||
rActivePowerRangePO.setIsOrNot6(rangePO.getIsOrNot6()+rActivePowerRangePO.getIsOrNot6());
|
||||
rActivePowerRangePO.setIsOrNot7(rangePO.getIsOrNot7()+rActivePowerRangePO.getIsOrNot7());
|
||||
rActivePowerRangePO.setIsOrNot8(rangePO.getIsOrNot8()+rActivePowerRangePO.getIsOrNot8());
|
||||
rActivePowerRangePO.setIsOrNot9(rangePO.getIsOrNot9()+rActivePowerRangePO.getIsOrNot9());
|
||||
if(!rActivePowerRangePOS.isEmpty()){
|
||||
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
|
||||
for(RActivePowerRangePO rangePO : rActivePowerRangePOS){
|
||||
rActivePowerRangePO.setMinsNum0(rangePO.getMinsNum0()+rActivePowerRangePO.getMinsNum0());
|
||||
rActivePowerRangePO.setMinsNum1(rangePO.getMinsNum1()+rActivePowerRangePO.getMinsNum1());
|
||||
rActivePowerRangePO.setMinsNum2(rangePO.getMinsNum2()+rActivePowerRangePO.getMinsNum2());
|
||||
rActivePowerRangePO.setMinsNum3(rangePO.getMinsNum3()+rActivePowerRangePO.getMinsNum3());
|
||||
rActivePowerRangePO.setMinsNum4(rangePO.getMinsNum4()+rActivePowerRangePO.getMinsNum4());
|
||||
rActivePowerRangePO.setMinsNum5(rangePO.getMinsNum5()+rActivePowerRangePO.getMinsNum5());
|
||||
rActivePowerRangePO.setMinsNum6(rangePO.getMinsNum6()+rActivePowerRangePO.getMinsNum6());
|
||||
rActivePowerRangePO.setMinsNum7(rangePO.getMinsNum7()+rActivePowerRangePO.getMinsNum7());
|
||||
rActivePowerRangePO.setMinsNum8(rangePO.getMinsNum8()+rActivePowerRangePO.getMinsNum8());
|
||||
rActivePowerRangePO.setMinsNum9(rangePO.getMinsNum9()+rActivePowerRangePO.getMinsNum9());
|
||||
rActivePowerRangePO.setIsOrNot0(rangePO.getIsOrNot0()+rActivePowerRangePO.getIsOrNot0());
|
||||
rActivePowerRangePO.setIsOrNot1(rangePO.getIsOrNot1()+rActivePowerRangePO.getIsOrNot1());
|
||||
rActivePowerRangePO.setIsOrNot2(rangePO.getIsOrNot2()+rActivePowerRangePO.getIsOrNot2());
|
||||
rActivePowerRangePO.setIsOrNot3(rangePO.getIsOrNot3()+rActivePowerRangePO.getIsOrNot3());
|
||||
rActivePowerRangePO.setIsOrNot4(rangePO.getIsOrNot4()+rActivePowerRangePO.getIsOrNot4());
|
||||
rActivePowerRangePO.setIsOrNot5(rangePO.getIsOrNot5()+rActivePowerRangePO.getIsOrNot5());
|
||||
rActivePowerRangePO.setIsOrNot6(rangePO.getIsOrNot6()+rActivePowerRangePO.getIsOrNot6());
|
||||
rActivePowerRangePO.setIsOrNot7(rangePO.getIsOrNot7()+rActivePowerRangePO.getIsOrNot7());
|
||||
rActivePowerRangePO.setIsOrNot8(rangePO.getIsOrNot8()+rActivePowerRangePO.getIsOrNot8());
|
||||
rActivePowerRangePO.setIsOrNot9(rangePO.getIsOrNot9()+rActivePowerRangePO.getIsOrNot9());
|
||||
}
|
||||
return rActivePowerRangePO;
|
||||
}
|
||||
return rActivePowerRangePO;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user