Commit d3439d39 authored by chenzhao's avatar chenzhao

增加代码

parent 3e2256aa
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.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* @author DELL
*/
@Data
public class TdHYGFStationDayGenerateDto implements Serializable {
/**
* 创建时间
*/
@ExcelIgnore
private Long createdTime;
/**
* 第三方场站id
*/
@ExcelIgnore
private String thirdStationId;
/**
*日 yyyy-MM-dd
*/
@ExcelProperty(value = "时间")
private String dayTime;
/**
*月 yyyy-MM
*/
@ExcelIgnore
private String yearMonth;
/**
* 发电量
*/
@ExcelProperty(value = "日发电量(kWh)")
private Double generate;
@ExcelProperty(value = "日满发小时数(h)")
private Double fullhour;
@ExcelProperty(value = "当前状态")
private String workstatus;
@ExcelProperty(value = "日收益(元)")
private Double income;
@ExcelProperty(value = "电站编号")
private String stationCode;
@ExcelProperty(value = "电站名称")
private String stationName;
@ExcelProperty(value = "业主姓名")
private String user_name;
@ExcelProperty(value = "电站联系人")
private String station_contact;
}
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.DropDown;
import com.yeejoin.amos.boot.module.hygf.api.dto.ReviewDto;
......@@ -18,14 +22,20 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.JpStationServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto;
......@@ -610,4 +620,36 @@ public class JpStationController extends BaseController {
return jpStationMapper.getJpStation(null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/jpstationReportExport", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "电站日报表导出", notes = "电站日报表导出")
public void jpstationReportExport( @RequestParam(required = false)String time,@RequestParam(required = false) List<String> snCodes, HttpServletResponse response,String type) {
List<JpStation> jpStation=jpStationServiceImpl.getJpStation(new JpStationDto());
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(time, snCodes, type);
try {
setResponseHeadForDowload(response,"电站报表.xls");
EasyExcel.write(response.getOutputStream()).head(JpStationDto.class).excelType(ExcelTypeEnum.XLS).sheet("逆变器日报表").doWrite(jpStationDtos);
} catch (IOException 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();
}
}
}
......@@ -335,9 +335,16 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
}else if (date.equals("month")){
return tdHYGFInverterYearGenerateMapper.selectYearTotal(time, snCode, thirdStationId);
}else if (date.equals("year")){
TdHYGFInverterTotalGenerate tdHYGFInverterTotalGenerate = tdHYGFInverterYearGenerateMapper.selectTotalSum(time, snCode, thirdStationId).get(0);
return Bean.BeantoMap(tdHYGFInverterTotalGenerate) ;
List<TdHYGFInverterTotalGenerate> tdHYGFInverterTotalGenerates = tdHYGFInverterYearGenerateMapper.selectTotalSum(time, snCode, thirdStationId);
if (CollectionUtil.isNotEmpty(tdHYGFInverterTotalGenerates)){
TdHYGFInverterTotalGenerate tdHYGFInverterTotalGenerate = tdHYGFInverterTotalGenerates.get(0);
return Bean.BeantoMap(tdHYGFInverterTotalGenerate) ;
}
Map<String,Object> map = new HashMap<>();
map.put("fullhour",0);
map.put("income",0);
map.put("generate",0);
return map;
}else {
List<TdHYGFInverterTotalGenerate> maps = tdHYGFInverterYearGenerateMapper.selectTotalSum(null, snCode, thirdStationId);
double fullhour = maps.stream().mapToDouble(TdHYGFInverterTotalGenerate::getFullhour).sum();
......
......@@ -502,9 +502,41 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
}
public List<JpStationDto> selectReportDate(String time, List<String> snCodes,String type) {
//权限
List<String> statioId=new ArrayList();
List<JpStation> dataJpStation= this.getJpStation(new JpStationDto());
for (JpStation jpStation : dataJpStation) {
statioId.add(jpStation.getThirdStationId());
}
List<JpStationDto> list = null;
switch (type){
case"day":
LambdaQueryWrapper<DayGenerate> wapper = new LambdaQueryWrapper<DayGenerate>();
wapper.in(statioId!=null,DayGenerate::getThirdStationId,statioId);
wapper.eq(DayGenerate::getDayTime,time);
List<DayGenerate> listday= dayGenerateMapper.selectList(wapper);
list = getJpStationDtoday( dataJpStation, listday);
break;
case"month":
LambdaQueryWrapper<MonthGenerate> wapper1 = new LambdaQueryWrapper<MonthGenerate>();
wapper1.in(statioId!=null,MonthGenerate::getThirdStationId,statioId);
wapper1.eq(MonthGenerate::getMonthTime,time);
List<MonthGenerate> listmonth= monthGenerateMapper.selectList(wapper1);
list = getJpStationDtomonth( dataJpStation, listmonth);
break;
case"year":
LambdaQueryWrapper<YearGenerate> wapper2 = new LambdaQueryWrapper<YearGenerate>();
wapper2.in(statioId!=null,YearGenerate::getThirdStationId,statioId);
wapper2.eq(YearGenerate::getYear,time);
List<YearGenerate> listyear= yearGenerateMapper.selectList(wapper2);
list = getJpStationDtoyear( dataJpStation, listyear);
break;
default:
list = getJpStationDtoAll(dataJpStation);
}
return list;
}
}
\ 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