报表导出

This commit is contained in:
2022-06-28 21:00:49 +08:00
parent d929fd22a5
commit 76747b5553
8 changed files with 403 additions and 6 deletions

View File

@@ -0,0 +1,45 @@
package com.njcn.harmonic.pojo.excel.monitor;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/28 15:32
*/
@Data
public class ITimes implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "3次", width = 25, needMerge = true)
private Integer overCurThreeTimes;
@Excel(name = "5次", width = 25, needMerge = true)
private Integer overCurFiveTimes;
@Excel(name = "7次", width = 25, needMerge = true)
private Integer overCurSevenTimes;
@Excel(name = "11次", width = 25, needMerge = true)
private Integer overCurElevenTimes;
@Excel(name = "13次", width = 25, needMerge = true)
private Integer overCurThirteenTimes;
@Excel(name = "23次", width = 25, needMerge = true)
private Integer overCurTwentyThreeTimes;
@Excel(name = "25次", width = 25, needMerge = true)
private Integer overCurTwentyFiveTimes;
@Excel(name = "其他次", width = 25, needMerge = true)
private Integer overCurOtherTimes;
}

View File

@@ -0,0 +1,54 @@
package com.njcn.harmonic.pojo.excel.monitor;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/28 13:26
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class MonitorExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "省公司", width = 25, needMerge = true)
private String provinceCompany;
@Excel(name = "地市公司", width = 25, needMerge = true)
private String cityCompany;
@Excel(name = "监测点名称", width = 25, needMerge = true)
private String lineName;
@Excel(name = "干扰源类型", width = 25, needMerge = true)
private String loadType;
@Excel(name = "监测点对象名称", width = 25, needMerge = true)
private String lineObjectName;
@Excel(name = "监测点电压等级", width = 25, needMerge = true)
private String lineScale;
@Excel(name = "变电站名称", width = 25, needMerge = true)
private String subName;
@Excel(name = "变电站电压等级", width = 25, needMerge = true)
private String subScale;
@Excel(name = "超标天数", width = 25, needMerge = true)
private Integer overDay;
@ExcelCollection(name = "各项指标超标天数")
private List<OverLimitDays> overLimitDays;
}

View File

@@ -0,0 +1,58 @@
package com.njcn.harmonic.pojo.excel.monitor;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/28 16:16
*/
@Data
public class OverLimitDays implements Serializable {
@Excel(name = "频率偏差", width = 25, needMerge = true)
private Integer freqOverDay;
@Excel(name = "电压偏差", width = 25, needMerge = true)
private Integer volDevOverDay;
@Excel(name = "谐波电压", width = 25, needMerge = true)
private Integer harmVolOverDay;
@Excel(name = "电压总谐波畸变率", width = 25, needMerge = true)
private Integer volDisOverDay;
@Excel(name = "谐波电压含有率", width = 25, needMerge = true)
private Integer volContainOverDay;
@Excel(name = "谐波电流", width = 25, needMerge = true)
private Integer harmCurOverDay;
@Excel(name = "间谐波电压含有率", width = 25, needMerge = true)
private Integer intHarmOverDay;
@Excel(name = "三相电压不平衡度", width = 25, needMerge = true)
private Integer threeUnbalance;
@Excel(name = "负序电流", width = 25, needMerge = true)
private Integer negativeOverDay;
@Excel(name = "闪变", width = 25, needMerge = true)
private Integer flickerOverDay;
@Excel(name = "监测点编号", width = 25, needMerge = true)
private String monitorNumber;
@ExcelCollection(name = "各次谐波电压含有率")
private List<UTimes> uTimes;
@ExcelCollection(name = "各次谐波电流含量")
private List<ITimes> iTimes;
}

View File

@@ -0,0 +1,44 @@
package com.njcn.harmonic.pojo.excel.monitor;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/28 15:32
*/
@Data
public class UTimes implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "3次", width = 25, needMerge = true)
private Integer overVolThreeTimes;
@Excel(name = "5次", width = 25, needMerge = true)
private Integer overVolFiveTimes;
@Excel(name = "7次", width = 25, needMerge = true)
private Integer overVolSevenTimes;
@Excel(name = "11次", width = 25, needMerge = true)
private Integer overVolElevenTimes;
@Excel(name = "13次", width = 25, needMerge = true)
private Integer overVolThirteenTimes;
@Excel(name = "23次", width = 25, needMerge = true)
private Integer overVolTwentyThreeTimes;
@Excel(name = "25次", width = 25, needMerge = true)
private Integer overVolTwentyFiveTimes;
@Excel(name = "其他次", width = 25, needMerge = true)
private Integer overVolOtherTimes;
}

View File

@@ -0,0 +1,77 @@
package com.njcn.harmonic.pojo.excel.substation;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/28 11:40
*/
@Data
public class SubstationExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "省公司", width = 25, needMerge = true)
private String provinceCompany;
@Excel(name = "地市公司", width = 25, needMerge = true)
private String cityCompany;
@Excel(name = "电站名称", width = 25, needMerge = true)
private String plantName;
@Excel(name = "电站电压等级", width = 25, needMerge = true)
private String plantVoltageLevel;
@Excel(name = "在线监测点数量(个)", width = 25, needMerge = true)
private Integer onlineMonitorCounts;
@Excel(name = "告警监测点数量(个)", width = 25, needMerge = true)
private Integer alertMonitorCounts;
@Excel(name = "告警次数", width = 25, needMerge = true)
private Integer alertCounts;
@Excel(name = "告警频次(次/点)", width = 25, needMerge = true, replace = "暂无数据_-1.0")
private Double alertAlarmFrequency;
@Excel(name = "频率偏差", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double frequencyDeviation;
@Excel(name = "电压偏差", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double voltageDeviation;
@Excel(name = "谐波电压", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double harmonicVoltage;
@Excel(name = "谐波电流", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double harmonicCurrent;
@Excel(name = "三相电压不平衡", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double threePhaseVoltageUnbalance;
@Excel(name = "闪变", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double flicker;
@Excel(name = "间谐波电压", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double interHarmonic;
@Excel(name = "负序电流", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项稳态指标告警频次(次/点)")
private Double negative;
@Excel(name = "短时中断", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项暂态指标告警频次(次/点)")
private Double shortInterruption;
@Excel(name = "电压暂降", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项暂态指标告警频次(次/点)")
private Double voltageDip;
@Excel(name = "电压暂升", width = 25, needMerge = true, replace = "暂无数据_-1.0", groupName = "各项暂态指标告警频次(次/点)")
private Double voltageSwell;
}

View File

@@ -2,6 +2,7 @@ package com.njcn.harmonic.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
@@ -14,6 +15,7 @@ import com.njcn.harmonic.pojo.vo.*;
import com.njcn.harmonic.service.IAnalyzeService;
import com.njcn.harmonic.service.IHarmonicService;
import com.njcn.harmonic.service.IPollutionService;
import com.njcn.poi.util.PoiUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -21,11 +23,9 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -191,4 +191,32 @@ public class AnalyzeController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, IAnalyzeService.exportArea(param,methodDescribe), methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/exportHarmonicSubstation")
@ApiOperation("告警变电站明细导出")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> exportHarmonicSubstation(@Validated @RequestBody OverAreaVO param) {
String methodDescribe = getMethodDescribe("exportHarmonicSubstation");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, IAnalyzeService.exportSubstation(param,methodDescribe), methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/exportHarmonicMonitor")
@ApiOperation("监测点超标统计导出")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> exportHarmonicMonitor(@Validated @RequestBody OverAreaVO param) {
String methodDescribe = getMethodDescribe("exportHarmonicMonitor");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, IAnalyzeService.exportMonitor(param,methodDescribe), methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@GetMapping("/exportDataExcel")
@ApiOperation("导出数据报表")
@ApiImplicitParam(name = "filePath", value = "报表路径", required = true)
public void exportDataExcel(String filePath, HttpServletResponse response) {
PoiUtil.exportFileByAbsolutePath(filePath,response);
}
}

View File

@@ -46,7 +46,33 @@ public interface IAnalyzeService {
*/
Page<MonitorOverLimitVO> monitorOverLimitVO(OverAreaVO param);
/**
* 功能描述: 获取下载地址
* @author xy
* @param param 参数
* @param methodDescribe 方法描述
* @date 2022/6/28 20:54
* @return 地址
*/
String exportArea(OverAreaVO param, String methodDescribe);
/**
* 功能描述: 获取下载地址
* @author xy
* @param param 参数
* @param methodDescribe 方法描述
* @date 2022/6/28 20:54
* @return 地址
*/
String exportSubstation(OverAreaVO param, String methodDescribe);
/**
* 功能描述: 获取下载地址
* @author xy
* @param param 参数
* @param methodDescribe 方法描述
* @date 2022/6/28 20:54
* @return 地址
*/
String exportMonitor(OverAreaVO param, String methodDescribe);
}

View File

@@ -15,6 +15,11 @@ import com.njcn.device.pojo.dto.PollutionParamDTO;
import com.njcn.device.pojo.dto.WarningSubstationDTO;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.pojo.excel.area.AreaExcel;
import com.njcn.harmonic.pojo.excel.monitor.ITimes;
import com.njcn.harmonic.pojo.excel.monitor.MonitorExcel;
import com.njcn.harmonic.pojo.excel.monitor.OverLimitDays;
import com.njcn.harmonic.pojo.excel.monitor.UTimes;
import com.njcn.harmonic.pojo.excel.substation.SubstationExcel;
import com.njcn.harmonic.pojo.po.EventDetail;
import com.njcn.harmonic.pojo.po.LimitRate;
import com.njcn.harmonic.pojo.po.LimitTarget;
@@ -147,6 +152,8 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
LimitRate limitRate = map.get(item2).get(0);
if (!Objects.isNull(limitRate)){
onlineMonitorCount++;
System.out.println("1==:" + limitRate.getFreqDevOverTime());
System.out.println("2==:" + limitRate.getVoltageDevOverTime());
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
alertMonitorCount++;
}
@@ -441,6 +448,64 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
return FileUtil.getAbsolutePath(excel);
}
@Override
public String exportSubstation(OverAreaVO param, String methodDescribe) {
List<SubstationExcel> result = new ArrayList<>();
String fileName = methodDescribe + CharUtil.UNDERLINE + param.getSearchBeginTime()+ CharUtil.DASHED + param.getSearchEndTime() + CharUtil.UNDERLINE + param.getStatisticalType().getName() +".xlsx";
String targetDir = generalInfo.getBusinessTempPath() + File.separator + RequestUtil.getUserIndex();
log.error("文件路径" + targetDir);
log.error("文件名" + fileName);
File excel = new File(targetDir, fileName);
List<WarningSubstationVO> list = getWarningSubstation(param).getRecords();
if (!CollectionUtil.isEmpty(list)) {
list.forEach(item->{
SubstationExcel substationExcel = new SubstationExcel();
BeanUtil.copyProperties(item,substationExcel);
result.add(substationExcel);
});
}
ExcelUtil.exportExcelWithTargetFile(excel, param.getStatisticalType().getName(), methodDescribe, SubstationExcel.class, result);
return FileUtil.getAbsolutePath(excel);
}
@Override
public String exportMonitor(OverAreaVO param, String methodDescribe) {
List<MonitorExcel> result = new ArrayList<>();
String fileName = methodDescribe + CharUtil.UNDERLINE + param.getSearchBeginTime()+ CharUtil.DASHED + param.getSearchEndTime() + CharUtil.UNDERLINE + param.getStatisticalType().getName() +".xlsx";
String targetDir = generalInfo.getBusinessTempPath() + File.separator + RequestUtil.getUserIndex();
log.error("文件路径" + targetDir);
log.error("文件名" + fileName);
File excel = new File(targetDir, fileName);
List<MonitorOverLimitVO> list = monitorOverLimitVO(param).getRecords();
if (!CollectionUtil.isEmpty(list)) {
list.forEach(item->{
MonitorExcel monitorExcel = new MonitorExcel();
BeanUtil.copyProperties(item,monitorExcel);
OverLimitDays overLimitDays = new OverLimitDays();
List<UTimes> list1 = new ArrayList<>();
UTimes uTimes = new UTimes();
BeanUtil.copyProperties(item,uTimes);
list1.add(uTimes);
overLimitDays.setUTimes(list1);
List<ITimes> list2 = new ArrayList<>();
ITimes iTimes = new ITimes();
BeanUtil.copyProperties(item,iTimes);
list2.add(iTimes);
overLimitDays.setITimes(list2);
List<OverLimitDays> list3 = new ArrayList<>();
BeanUtil.copyProperties(item,overLimitDays);
list3.add(overLimitDays);
monitorExcel.setOverLimitDays(list3);
result.add(monitorExcel);
});
}
ExcelUtil.exportExcelWithTargetFile(excel, param.getStatisticalType().getName(), methodDescribe, MonitorExcel.class, result);
return FileUtil.getAbsolutePath(excel);
}
/**
* 功能描述: 处理区域(变电站)在线监测点数、超标监测点数、平均超标天数、占比