Commit cbae9d04 authored by tangwei's avatar tangwei

修改电站报表导出

parent 1fe30cbd
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
/**
* @description:
* @author: tw
* @createDate: 2023/11/20
*/
public class DayGenerateEX {
@ExcelProperty(value = "电站编码", index = 0)
@ApiModelProperty(value = "电站编码")
private String code;
@ExcelProperty(value = "电站名称", index = 1)
@ApiModelProperty(value = "电站名称")
private String name;
@ExcelProperty(value = "时间", index = 2)
String timeDate;
@ExcelProperty(value = "业主姓名", index = 3)
@ApiModelProperty(value = "业主姓名")
private String userName;
@ExcelProperty(value = "电站联系人", index = 4)
@ApiModelProperty(value = "电站联系人")
private String stationContact;
/**
* 满发小时数
*
* */
@ExcelProperty(value = "满发小时数", index = 5)
private Double fullhour;
@ExcelProperty(value = "日发电量", index = 6)
// 日发电量
private Double dayGenerate;
@ExcelProperty(value = "日收益", index = 7)
// 日收益
private Double dayIncome;
/**
* 累计发电量
*/
@ExcelProperty(value = "累计发电量", index = 8)
private Double accumulatedPower;
/**
* 状态
*/
@ExcelProperty(value = "状态", index = 9)
private String state;
}
package com.yeejoin.amos.boot.module.hygf.api.dto; package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpCollector; import com.yeejoin.amos.boot.module.hygf.api.entity.JpCollector;
...@@ -26,74 +28,77 @@ import java.util.Map; ...@@ -26,74 +28,77 @@ import java.util.Map;
public class JpStationDto extends BaseDto { public class JpStationDto extends BaseDto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ExcelIgnore
@ApiModelProperty(value = "sn编码") @ApiModelProperty(value = "sn编码")
private String snCode; private String snCode;
@ExcelIgnore
@ApiModelProperty(value = "装机容量") @ApiModelProperty(value = "装机容量")
private Double capacity; private Double capacity;
@ExcelProperty(value = "电站名称", index = 1)
@ApiModelProperty(value = "电站名称") @ApiModelProperty(value = "电站名称")
private String name; private String name;
@ExcelProperty(value = "电站编码", index = 0)
@ApiModelProperty(value = "电站编码") @ApiModelProperty(value = "电站编码")
private String code; private String code;
@ExcelIgnore
@ApiModelProperty(value = "组织编码") @ApiModelProperty(value = "组织编码")
private String systemCode; private String systemCode;
@ExcelIgnore
@ApiModelProperty(value = "接入平台时间") @ApiModelProperty(value = "接入平台时间")
private Date accessTime; private Date accessTime;
@ExcelIgnore
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private Date createTime; private Date createTime;
@ExcelIgnore
@ApiModelProperty(value = "地址") @ApiModelProperty(value = "地址")
private String address; private String address;
@ExcelIgnore
@ApiModelProperty(value = "经度") @ApiModelProperty(value = "经度")
private String longitude; private String longitude;
@ExcelIgnore
@ApiModelProperty(value = "维度") @ApiModelProperty(value = "维度")
private String latitude; private String latitude;
@ExcelIgnore
@ApiModelProperty(value = "上网电价") @ApiModelProperty(value = "上网电价")
private Double price; private Double price;
@ExcelProperty(value = "业主姓名", index = 3)
@ApiModelProperty(value = "业主姓名") @ApiModelProperty(value = "业主姓名")
private String userName; private String userName;
@ExcelIgnore
@ApiModelProperty(value = "业主电话") @ApiModelProperty(value = "业主电话")
private String userPhone; private String userPhone;
@ExcelProperty(value = "电站联系人", index = 4)
@ApiModelProperty(value = "电站联系人") @ApiModelProperty(value = "电站联系人")
private String stationContact; private String stationContact;
@ExcelIgnore
@ApiModelProperty(value = "组件数量") @ApiModelProperty(value = "组件数量")
private Integer moduleCount; private Integer moduleCount;
@ExcelIgnore
@ApiModelProperty(value = "并网类型") @ApiModelProperty(value = "并网类型")
private String onGridType; private String onGridType;
@ExcelIgnore
@ApiModelProperty(value = "并网时间") @ApiModelProperty(value = "并网时间")
private Date onGridTime; private Date onGridTime;
@ExcelIgnore
@ApiModelProperty(value = "第三方电站id") @ApiModelProperty(value = "第三方电站id")
private String thirdStationId; private String thirdStationId;
@ApiModelProperty(value = "电站id") @ApiModelProperty(value = "电站id")
private Long stationId; private Long stationId;
@ExcelIgnore
@ApiModelProperty(value = "第三方厂商标识") @ApiModelProperty(value = "第三方厂商标识")
private String thirdCode; private String thirdCode;
/** /**
* 实时功率 * 实时功率
*/ */
@ExcelIgnore
private Double realTimePower; private Double realTimePower;
/** /**
* 累计发电量 * 累计发电量
*/ */
@ExcelProperty(value = "累计发电量", index = 6)
private Double accumulatedPower; private Double accumulatedPower;
@ExcelIgnore
/** /**
* 状态 * 状态
*/ */
...@@ -101,63 +106,77 @@ public class JpStationDto extends BaseDto { ...@@ -101,63 +106,77 @@ public class JpStationDto extends BaseDto {
/** /**
* 电站类型 * 电站类型
*/ */
@ExcelIgnore
private String type; private String type;
/** /**
* 组织编码 * 组织编码
*/ */
@ExcelIgnore
private String organizationalCode; private String organizationalCode;
@ExcelIgnore
// 日发电量 // 日发电量
private Double dayGenerate; private Double dayGenerate;
@ExcelIgnore
// 月发电量 // 月发电量
private Double monthGenerate; private Double monthGenerate;
@ExcelIgnore
// 年发电量 // 年发电量
private Double yearGenerate; private Double yearGenerate;
// 日收益 // 日收益
private Double dayIncome; private Double dayIncome;
@ExcelIgnore
// 月收益 // 月收益
private Double monthIncome; private Double monthIncome;
@ExcelIgnore
// 年收益 // 年收益
private Double yearIncome; private Double yearIncome;
// 地区 // 地区
@ExcelIgnore
private String area; private String area;
@ExcelIgnore
List<JpPersonStation> statioId; List<JpPersonStation> statioId;
@ExcelProperty(value = "累计收益", index = 7)
// 累计收益 // 累计收益
private Double cumulativeIncome; private Double cumulativeIncome;
@ExcelIgnore
private Double dayPowerUse; // 日用电量 private Double dayPowerUse; // 日用电量
@ExcelIgnore
private Double monthPowerUse; // 月用电量 private Double monthPowerUse; // 月用电量
@ExcelIgnore
private Double yearPowerUse; // 年用电量 private Double yearPowerUse; // 年用电量
@ExcelIgnore
private int countBuiltNum;// 已建设场站数量 private int countBuiltNum;// 已建设场站数量
@ExcelIgnore
private int countNBuiltNum;// 未建设场站数量 private int countNBuiltNum;// 未建设场站数量
@ExcelIgnore
List<JpInverter> jpInverter; List<JpInverter> jpInverter;
@ExcelIgnore
List<JpCollector> JpCollector; List<JpCollector> JpCollector;
// 时间 // 时间
@ExcelIgnore
String dateType; String dateType;
@ExcelIgnore
private String email; private String email;
@ExcelIgnore
private Double ratedPower; private Double ratedPower;
@ExcelIgnore
private String regionalCompaniesCode; private String regionalCompaniesCode;
@ExcelIgnore
private String regionalCompaniesName; private String regionalCompaniesName;
@ExcelIgnore
private String amosCompanyCode; private String amosCompanyCode;
//场站id //场站id
@ExcelIgnore
private List<String> thirdStationIds; private List<String> thirdStationIds;
@ExcelProperty(value = "时间", index = 2)
String timeDate; String timeDate;
/** /**
* 满发小时数 * 满发小时数
* *
* */ * */
@ExcelProperty(value = "满发小时数", index = 5)
private Double fullhour; private Double fullhour;
...@@ -165,11 +184,13 @@ public class JpStationDto extends BaseDto { ...@@ -165,11 +184,13 @@ public class JpStationDto extends BaseDto {
* *
* 实时功率比/ * 实时功率比/
* **/ * **/
@ExcelIgnore
List<Map<String,Object>> powerRatio; List<Map<String,Object>> powerRatio;
@ExcelIgnore
String timeDateMonth; String timeDateMonth;
@ExcelIgnore
String timeDateYear; String timeDateYear;
} }
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
/**
* @description:
* @author: tw
* @createDate: 2023/11/20
*/
public class MonthGenerateEX {
@ExcelProperty(value = "电站编码", index = 0)
@ApiModelProperty(value = "电站编码")
private String code;
@ExcelProperty(value = "电站名称", index = 1)
@ApiModelProperty(value = "电站名称")
private String name;
@ExcelProperty(value = "时间", index = 2)
String timeDate;
@ExcelProperty(value = "业主姓名", index = 3)
@ApiModelProperty(value = "业主姓名")
private String userName;
@ExcelProperty(value = "电站联系人", index = 4)
@ApiModelProperty(value = "电站联系人")
private String stationContact;
/**
* 满发小时数
*
* */
@ExcelProperty(value = "满发小时数", index = 5)
private Double fullhour;
// 月发电量
@ExcelProperty(value = "月发电量", index = 6)
private Double monthGenerate;
// 月收益
@ExcelProperty(value = "月收益", index = 7)
private Double monthIncome;
/**
* 累计发电量
*/
@ExcelProperty(value = "累计发电量", index = 8)
private Double accumulatedPower;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
/**
* @description:
* @author: tw
* @createDate: 2023/11/20
*/
public class YearGenerateEX {
@ExcelProperty(value = "电站编码", index = 0)
@ApiModelProperty(value = "电站编码")
private String code;
@ExcelProperty(value = "电站名称", index = 1)
@ApiModelProperty(value = "电站名称")
private String name;
@ExcelProperty(value = "时间", index = 2)
String timeDate;
@ExcelProperty(value = "业主姓名", index = 3)
@ApiModelProperty(value = "业主姓名")
private String userName;
@ExcelProperty(value = "电站联系人", index = 4)
@ApiModelProperty(value = "电站联系人")
private String stationContact;
/**
* 满发小时数
*
* */
@ExcelProperty(value = "满发小时数", index = 5)
private Double fullhour;
// 年发电量
@ExcelProperty(value = "年发电量", index = 6)
private Double yearGenerate;
// 年收益
@ExcelProperty(value = "年收益", index = 7)
private Double yearIncome;
/**
* 累计发电量
*/
@ExcelProperty(value = "累计发电量", index = 8)
private Double accumulatedPower;
}
...@@ -24,6 +24,8 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController; ...@@ -24,6 +24,8 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
...@@ -611,7 +613,7 @@ public class JpStationController extends BaseController { ...@@ -611,7 +613,7 @@ public class JpStationController extends BaseController {
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
} }
@TycloudOperation(needAuth = false,ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "工率曲线", notes = "电站监控电量收益") @ApiOperation(httpMethod = "GET",value = "工率曲线", notes = "电站监控电量收益")
@GetMapping(value = "/getPowerqxnew") @GetMapping(value = "/getPowerqxnew")
public ResponseModel< Map<String, List<Object>>> getPowerqxnew(JpStationDto reviewDto,String date) { public ResponseModel< Map<String, List<Object>>> getPowerqxnew(JpStationDto reviewDto,String date) {
...@@ -666,32 +668,22 @@ public class JpStationController extends BaseController { ...@@ -666,32 +668,22 @@ public class JpStationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/jpstationReportExport", method = RequestMethod.GET) @RequestMapping(value = "/jpstationReportExport", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "电站报表导出", notes = "电站报表导出") @ApiOperation(httpMethod = "GET", value = "电站报表导出", notes = "电站报表导出")
public void jpstationReportExport( @RequestParam(required = false)String time,@RequestParam(required = false) List<String> snCodes, HttpServletResponse response,String type) { public void jpstationReportExport( HttpServletResponse response,JpStationDto reviewDto,String type) {
List<JpStation> jpStation=jpStationServiceImpl.getJpStation(new JpStationDto()); List<JpStation> jpStation=jpStationServiceImpl.getJpStation(new JpStationDto());
List<String> stationIds = jpStation.stream().map(jpStation1 -> jpStation1.getThirdStationId()).collect(Collectors.toList()); List<String> stationIds = jpStation.stream().map(jpStation1 -> jpStation1.getThirdStationId()).collect(Collectors.toList());
if(StringUtils.isEmpty(time)){
time = DateUtil.format(new Date(),"yyyy-MM-dd"); List<JpStationDto> jpStationDtos = jpStationServiceImpl.selectReportDate(reviewDto, type,response);
} // try {
List<JpStationDto> jpStationDtos = jpStationServiceImpl.selectReportDate(time, snCodes, type); // setResponseHeadForDowload(response,"电站报表.xls");
try { // EasyExcel.write(response.getOutputStream()).head(JpStationDto.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表")
setResponseHeadForDowload(response,"电站报表.xls"); //
EasyExcel.write(response.getOutputStream()).head(JpStationDto.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表").doWrite(jpStationDtos); // .doWrite(jpStationDtos);
} catch (IOException e) { // } catch (IOException e) {
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
} }
public void setResponseHeadForDowload(HttpServletResponse response, String dowloadFileName) {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(dowloadFileName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
} }
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -7,12 +9,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -7,12 +9,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits; import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.PowerCurveDto; import com.yeejoin.amos.boot.module.hygf.api.dto.*;
import com.yeejoin.amos.boot.module.hygf.api.dto.ReviewDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.*; import com.yeejoin.amos.boot.module.hygf.api.entity.*;
import com.yeejoin.amos.boot.module.hygf.api.mapper.JpStationMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.JpStationMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IJpStationService; import com.yeejoin.amos.boot.module.hygf.api.service.IJpStationService;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.DayGenerateMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.DayGenerateMapper;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthGenerateMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthGenerateMapper;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper;
...@@ -26,6 +26,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -26,6 +26,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import springfox.bean.validators.plugins.schema.MinMaxAnnotationPlugin; import springfox.bean.validators.plugins.schema.MinMaxAnnotationPlugin;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -246,10 +250,11 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -246,10 +250,11 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
} }
@Override @Override
@UserLimits
public Map<String, List<Object>> getPowerqxnew(String date,JpStationDto reviewDto) { public Map<String, List<Object>> getPowerqxnew(String date,JpStationDto reviewDto) {
List<String> statioId=new ArrayList(); List<String> statioId=new ArrayList();
List<JpStation> dataJpStation= this.getJpStation(reviewDto); List<JpStation> dataJpStation= jpStationMapper.getJpStation(reviewDto);
for (JpStation jpStation : dataJpStation) { for (JpStation jpStation : dataJpStation) {
statioId.add(jpStation.getThirdStationId()); statioId.add(jpStation.getThirdStationId());
} }
...@@ -273,8 +278,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -273,8 +278,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
} }
} }
} }
map.put("x",listx); map.put("axisData",listx);
map.put("y",listy); map.put("seriesData",listy);
return map; return map;
} }
...@@ -410,6 +415,7 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -410,6 +415,7 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
break; break;
default: default:
count= reviewDto.getThirdStationIds()!=null?reviewDto.getThirdStationIds().size():0;
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
List<JpStationDto> listJ= jpStationMapper.queryForDealerReviewPage(reviewDto); List<JpStationDto> listJ= jpStationMapper.queryForDealerReviewPage(reviewDto);
...@@ -442,7 +448,6 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -442,7 +448,6 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
hd.setFullhour(Double.valueOf(String.format("%.2f", jpStation.getAccumulatedPower()/jpStation.getCapacity()))); hd.setFullhour(Double.valueOf(String.format("%.2f", jpStation.getAccumulatedPower()/jpStation.getCapacity())));
hd.setAccumulatedPower(jpStation.getAccumulatedPower()); hd.setAccumulatedPower(jpStation.getAccumulatedPower());
hd.setCumulativeIncome(jpStation.getCumulativeIncome()); hd.setCumulativeIncome(jpStation.getCumulativeIncome());
hd.setDayIncome(null);
ld.add(hd); ld.add(hd);
} }
...@@ -462,7 +467,7 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -462,7 +467,7 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
hd.setState(jpStation.getState()); hd.setState(jpStation.getState());
hd.setAccumulatedPower(jpStation.getAccumulatedPower()); hd.setAccumulatedPower(jpStation.getAccumulatedPower());
hd.setFullhour(Double.valueOf(String.format("%.2f", jpStation.getAccumulatedPower()/jpStation.getCapacity()))); hd.setFullhour(Double.valueOf(String.format("%.2f", jpStation.getAccumulatedPower()/jpStation.getCapacity())));
hd.setAccumulatedPower(jpStation.getAccumulatedPower()); hd.setCumulativeIncome(jpStation.getCumulativeIncome());
ld.add(hd); ld.add(hd);
} }
...@@ -543,42 +548,81 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -543,42 +548,81 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
return ld; return ld;
} }
@UserLimits
public List<JpStationDto> selectReportDate(String time, List<String> snCodes,String type) { public List<JpStationDto> selectReportDate(JpStationDto reviewDto,String type,HttpServletResponse response) {
//权限
//权限 //权限
List<String> statioId=new ArrayList(); List<String> statioId=new ArrayList();
List<JpStation> dataJpStation= jpStationMapper.getJpStation(reviewDto);
List<JpStation> dataJpStation= this.getJpStation(new JpStationDto()); if(reviewDto.getThirdStationIds()==null){
for (JpStation jpStation : dataJpStation) { for (JpStation jpStation : dataJpStation) {
statioId.add(jpStation.getThirdStationId()); statioId.add(jpStation.getThirdStationId());
}
reviewDto.setThirdStationIds(statioId);
} }
List<JpStationDto> list = null; List<JpStationDto> list = null;
try {
switch (type){ switch (type){
case"day": case"day":
LambdaQueryWrapper<DayGenerate> wapper = new LambdaQueryWrapper<DayGenerate>(); LambdaQueryWrapper<DayGenerate> wapper = new LambdaQueryWrapper<DayGenerate>();
wapper.in(statioId!=null,DayGenerate::getThirdStationId,statioId); wapper.in(DayGenerate::getThirdStationId,reviewDto.getThirdStationIds());
wapper.eq(DayGenerate::getDayTime,time); wapper.eq(reviewDto.getTimeDate()!=null,DayGenerate::getDayTime,reviewDto.getTimeDate());
List<DayGenerate> listday= dayGenerateMapper.selectList(wapper); List<DayGenerate> listday= dayGenerateMapper.selectList(wapper);
list = getJpStationDtoday( dataJpStation, listday); list = getJpStationDtoday( dataJpStation, listday);
setResponseHeadForDowload(response,"电站日报表.xls");
EasyExcel.write(response.getOutputStream()).head(DayGenerateEX.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表")
.doWrite(list);
break; break;
case"month": case"month":
LambdaQueryWrapper<MonthGenerate> wapper1 = new LambdaQueryWrapper<MonthGenerate>(); LambdaQueryWrapper<MonthGenerate> wapper1 = new LambdaQueryWrapper<MonthGenerate>();
wapper1.in(statioId!=null,MonthGenerate::getThirdStationId,statioId); wapper1.in(MonthGenerate::getThirdStationId,reviewDto.getThirdStationIds());
wapper1.eq(MonthGenerate::getMonthTime,time); wapper1.eq(reviewDto.getTimeDate()!=null,MonthGenerate::getMonthTime,reviewDto.getTimeDate());
List<MonthGenerate> listmonth= monthGenerateMapper.selectList(wapper1); List<MonthGenerate> listmonth= monthGenerateMapper.selectList(wapper1);
list = getJpStationDtomonth( dataJpStation, listmonth); list = getJpStationDtomonth( dataJpStation, listmonth);
setResponseHeadForDowload(response,"电站月报表.xls");
EasyExcel.write(response.getOutputStream()).head(MonthGenerateEX.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表")
.doWrite(list);
break; break;
case"year": case"year":
LambdaQueryWrapper<YearGenerate> wapper2 = new LambdaQueryWrapper<YearGenerate>(); LambdaQueryWrapper<YearGenerate> wapper2 = new LambdaQueryWrapper<YearGenerate>();
wapper2.in(statioId!=null,YearGenerate::getThirdStationId,statioId); wapper2.in(YearGenerate::getThirdStationId,reviewDto.getThirdStationIds());
wapper2.eq(YearGenerate::getYear,time); wapper2.eq(reviewDto.getTimeDate()!=null,YearGenerate::getYear,reviewDto.getTimeDate());
List<YearGenerate> listyear= yearGenerateMapper.selectList(wapper2); List<YearGenerate> listyear= yearGenerateMapper.selectList(wapper2);
list = getJpStationDtoyear( dataJpStation, listyear); list = getJpStationDtoyear( dataJpStation, listyear);
setResponseHeadForDowload(response,"电站年报表.xls");
EasyExcel.write(response.getOutputStream()).head(YearGenerateEX.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表")
.doWrite(list);
break; break;
default: default:
list = getJpStationDtoAll(dataJpStation); list = getJpStationDtoAll(dataJpStation);
setResponseHeadForDowload(response,"电站累计报表.xls");
EasyExcel.write(response.getOutputStream()).head(JpStationDto.class).excelType(ExcelTypeEnum.XLS).sheet("电站报表")
.doWrite(list);
}
} catch (IOException e) {
throw new RuntimeException(e);
} }
return list; return list;
} }
public void setResponseHeadForDowload(HttpServletResponse response, String dowloadFileName) {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(dowloadFileName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment