From 8615d92749f5af61cefd829644b7973fa9e52344 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 11 Apr 2024 14:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E6=AD=A3=EF=BC=9A=E6=B0=B4=E7=94=B5?= =?UTF-8?q?=E7=AB=99=E6=9C=88=E6=8A=A5=E7=BB=9F=E8=AE=A1=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/main/controller/AreaMonthReportController.java | 10 ++++++---- .../main/service/impl/AreaMonthReportServiceImpl.java | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java index 92e9e1d..57d6628 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java +++ b/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.springblade.core.boot.ctrl.BladeController; 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.utils.DateUtil; 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.http.HttpServletResponse; import javax.validation.constraints.NotNull; +import javax.xml.ws.WebServiceException; import java.io.IOException; import java.net.URLEncoder; import java.text.ParseException; @@ -156,16 +158,16 @@ public class AreaMonthReportController extends BladeController { @ApiOperationSupport(order = 3) @ApiOperation("导出水电站月报") @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 { HashMap map = new HashMap<>(); if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){ - return R.fail("传入格式不对,请重新导出"); + throw new ServiceException("传入格式不对,请重新导出"); } R deptNameR = sysClient.getDeptName(deptId); if (!deptNameR.isSuccess()) { - return R.fail("暂无该机构"); + throw new ServiceException("暂无该机构"); } String deptName = deptNameR.getData(); if (type==1){ @@ -191,8 +193,8 @@ public class AreaMonthReportController extends BladeController { outputStream.close(); xwpfDocument.close(); } catch (IOException e) { + log.error("统计月报数据报错:接口:/exportHydropowerStationMonthReport,错误原因"+e); e.printStackTrace(); } - return R.data("导出成功"); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index e91a0e7..b839e30 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/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.util.CellRangeAddress; import org.jfree.data.category.DefaultCategoryDataset; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; @@ -262,16 +263,16 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId,String deptName) throws ParseException { R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ - return R.fail("用户权限查询失败"); + throw new ServiceException("用户权限查询失败"); } R> deptR = sysClient.getDeptByType("200000", deptId, 4); if (!deptR.isSuccess() || deptR.getData() == null) { - return R.fail("该机构不包含水站信息"); + throw new ServiceException("该机构不包含水站信息"); } List deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList()); List deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList()); if (!deptByUser.contains(deptId)){ - return R.fail("该用户不包含该机构权限,请申请权限再试"); + throw new ServiceException("该用户不包含该机构权限,请申请权限再试"); } List deptIds = deptList.stream().map(Dept::getId).collect(Collectors.toList()); List stationEntityList = stationService.list(Wrappers.lambdaQuery()