Commit 3e289e90 authored by caotao's avatar caotao

1.逆变器日报表接口及导出增加权限。

parent cbf46ebf
...@@ -4,7 +4,9 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,7 +4,9 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.support.ExcelTypeEnum;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate; import com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.JpStationServiceImpl;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -56,6 +58,8 @@ public class JpInverterController extends BaseController { ...@@ -56,6 +58,8 @@ public class JpInverterController extends BaseController {
@Autowired @Autowired
JpInverterServiceImpl jpInverterServiceImpl; JpInverterServiceImpl jpInverterServiceImpl;
@Autowired
JpStationServiceImpl jpStationServiceImpl;
@Autowired @Autowired
JpPersonStationMapper pPersonStationMapper; JpPersonStationMapper pPersonStationMapper;
...@@ -221,14 +225,18 @@ public class JpInverterController extends BaseController { ...@@ -221,14 +225,18 @@ public class JpInverterController extends BaseController {
@GetMapping(value = "/jpInverterDayReport") @GetMapping(value = "/jpInverterDayReport")
@ApiOperation(httpMethod = "GET", value = "逆变器日报表", notes = "逆变器日报表") @ApiOperation(httpMethod = "GET", value = "逆变器日报表", notes = "逆变器日报表")
public ResponseModel<Page<TdHYGFInverterDayGenerate>> jpInverterDayReport(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size, String time, @RequestParam(required = false) List<String> snCodes) { public ResponseModel<Page<TdHYGFInverterDayGenerate>> jpInverterDayReport(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size, String time, @RequestParam(required = false) List<String> snCodes) {
return ResponseHelper.buildResponse(jpInverterServiceImpl.jpInverterDayReport(current,size,time,snCodes)); List<JpStation> jpStation=jpStationServiceImpl.getJpStation(null);
List<String> stationids = jpStation.stream().map(jpStation1 -> jpStation1.getThirdStationId()).collect(Collectors.toList());
return ResponseHelper.buildResponse(jpInverterServiceImpl.jpInverterDayReport(current,size,time,snCodes,stationids));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/jpInverterDayReportExport", method = RequestMethod.GET) @RequestMapping(value = "/jpInverterDayReportExport", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "逆变器日报表导出", notes = "逆变器日报表导出") @ApiOperation(httpMethod = "GET", value = "逆变器日报表导出", notes = "逆变器日报表导出")
public void jpInverterDayReportExport( String time,@RequestParam(required = false) List<String> snCodes, HttpServletResponse response) { public void jpInverterDayReportExport( String time,@RequestParam(required = false) List<String> snCodes, HttpServletResponse response) {
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates =jpInverterServiceImpl.jpInverterDayReportExport(time,snCodes); List<JpStation> jpStation=jpStationServiceImpl.getJpStation(null);
List<String> stationids = jpStation.stream().map(jpStation1 -> jpStation1.getThirdStationId()).collect(Collectors.toList());
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates =jpInverterServiceImpl.jpInverterDayReportExport(time,snCodes,stationids);
try { try {
setResponseHeadForDowload(response,"逆变器日报表.xls"); setResponseHeadForDowload(response,"逆变器日报表.xls");
EasyExcel.write(response.getOutputStream()).head(TdHYGFInverterDayGenerate.class).excelType(ExcelTypeEnum.XLS).sheet("逆变器日报表").doWrite(tdHYGFInverterDayGenerates); EasyExcel.write(response.getOutputStream()).head(TdHYGFInverterDayGenerate.class).excelType(ExcelTypeEnum.XLS).sheet("逆变器日报表").doWrite(tdHYGFInverterDayGenerates);
......
...@@ -89,14 +89,15 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter ...@@ -89,14 +89,15 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
} }
public Page<TdHYGFInverterDayGenerate> jpInverterDayReport(int current, int size, String time, List<String> sncodes) { public Page<TdHYGFInverterDayGenerate> jpInverterDayReport(int current, int size, String time, List<String> sncodes,List<String> stationIds) {
Page<TdHYGFInverterDayGenerate> tdHYGFInverterDayGeneratePage = new Page<>(); Page<TdHYGFInverterDayGenerate> tdHYGFInverterDayGeneratePage = new Page<>();
Date date = DateUtil.parse(time, "yyyy-MM-dd"); Date date = DateUtil.parse(time, "yyyy-MM-dd");
String startTime = DateUtil.format(date, "yyyy-MM-dd") + "00:00:00"; String startTime = DateUtil.format(date, "yyyy-MM-dd") + "00:00:00";
String endTime = DateUtil.format(date, "yyyy-MM-dd") + "23:59:59"; String endTime = DateUtil.format(date, "yyyy-MM-dd") + "23:59:59";
QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>() QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
.ge("created_time", startTime) .ge("created_time", startTime)
.le("created_time", endTime); .le("created_time", endTime)
.in("third_station_id",stationIds);;
if (CollectionUtil.isNotEmpty(sncodes)) { if (CollectionUtil.isNotEmpty(sncodes)) {
queryWrapper.in("sn_code", sncodes); queryWrapper.in("sn_code", sncodes);
} }
...@@ -114,13 +115,14 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter ...@@ -114,13 +115,14 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
return tdHYGFInverterDayGeneratePage; return tdHYGFInverterDayGeneratePage;
} }
public List<TdHYGFInverterDayGenerate> jpInverterDayReportExport(String time, List<String> sncodes) { public List<TdHYGFInverterDayGenerate> jpInverterDayReportExport(String time, List<String> sncodes,List<String> stationIds) {
Date date = DateUtil.parse(time, "yyyy-MM-dd"); Date date = DateUtil.parse(time, "yyyy-MM-dd");
String startTime = DateUtil.format(date, "yyyy-MM-dd") + "00:00:00"; String startTime = DateUtil.format(date, "yyyy-MM-dd") + "00:00:00";
String endTime = DateUtil.format(date, "yyyy-MM-dd") + "23:59:59"; String endTime = DateUtil.format(date, "yyyy-MM-dd") + "23:59:59";
QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>() QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
.ge("created_time", startTime) .ge("created_time", startTime)
.le("created_time", endTime); .le("created_time", endTime)
.in("third_station_id",stationIds);
if (CollectionUtil.isNotEmpty(sncodes)) { if (CollectionUtil.isNotEmpty(sncodes)) {
queryWrapper.in("sn_code", sncodes); queryWrapper.in("sn_code", sncodes);
} }
......
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