Browse Source

订正:水电站月报统计导出返回数据异常

zhongwei
ty 8 months ago
parent
commit
8615d92749
  1. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  2. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java

@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.xml.ws.WebServiceException;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.ParseException; import java.text.ParseException;
@ -156,16 +158,16 @@ public class AreaMonthReportController extends BladeController {
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation("导出水电站月报") @ApiOperation("导出水电站月报")
@GetMapping("/exportHydropowerStationMonthReport") @GetMapping("/exportHydropowerStationMonthReport")
public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month, public void exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month,
@ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) throws ParseException { @ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) throws ParseException {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){ if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){
return R.fail("传入格式不对,请重新导出"); throw new ServiceException("传入格式不对,请重新导出");
} }
R<String> deptNameR = sysClient.getDeptName(deptId); R<String> deptNameR = sysClient.getDeptName(deptId);
if (!deptNameR.isSuccess()) { if (!deptNameR.isSuccess()) {
return R.fail("暂无该机构"); throw new ServiceException("暂无该机构");
} }
String deptName = deptNameR.getData(); String deptName = deptNameR.getData();
if (type==1){ if (type==1){
@ -191,8 +193,8 @@ public class AreaMonthReportController extends BladeController {
outputStream.close(); outputStream.close();
xwpfDocument.close(); xwpfDocument.close();
} catch (IOException e) { } catch (IOException e) {
log.error("统计月报数据报错:接口:/exportHydropowerStationMonthReport,错误原因"+e);
e.printStackTrace(); e.printStackTrace();
} }
return R.data("导出成功");
} }
} }

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -48,6 +48,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.DefaultCategoryDataset;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
@ -262,16 +263,16 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) throws ParseException { public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) throws ParseException {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser(); R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){
return R.fail("用户权限查询失败"); throw new ServiceException("用户权限查询失败");
} }
R<List<Dept>> deptR = sysClient.getDeptByType("200000", deptId, 4); R<List<Dept>> deptR = sysClient.getDeptByType("200000", deptId, 4);
if (!deptR.isSuccess() || deptR.getData() == null) { if (!deptR.isSuccess() || deptR.getData() == null) {
return R.fail("该机构不包含水站信息"); throw new ServiceException("该机构不包含水站信息");
} }
List<Dept> deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList()); List<Dept> deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList());
List<Long> deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList()); List<Long> deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList());
if (!deptByUser.contains(deptId)){ if (!deptByUser.contains(deptId)){
return R.fail("该用户不包含该机构权限,请申请权限再试"); throw new ServiceException("该用户不包含该机构权限,请申请权限再试");
} }
List<Long> deptIds = deptList.stream().map(Dept::getId).collect(Collectors.toList()); List<Long> deptIds = deptList.stream().map(Dept::getId).collect(Collectors.toList());
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery() List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()

Loading…
Cancel
Save