From e4b07e86677e124765233bb7bf68c440c0171996 Mon Sep 17 00:00:00 2001 From: tyty Date: Mon, 14 Aug 2023 17:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=B0=B4=E7=94=B5=E7=AB=99?= =?UTF-8?q?=E6=9C=88=E6=8A=A5=E5=AF=BC=E5=87=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/controller/AreaMonthReportController.java | 12 ++++++++--- .../service/impl/AreaMonthReportServiceImpl.java | 23 +++++++--------------- 2 files changed, 16 insertions(+), 19 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 ad1c3b8..7720bc9 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 @@ -20,6 +20,7 @@ import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.system.feign.ISysClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -43,7 +44,8 @@ public class AreaMonthReportController extends BladeController { @NotNull private final IAreaMonthReportService service; - + @NotNull + private final ISysClient sysClient; @ApiLog @ApiOperationSupport(order = 1) @ApiOperation("生成区域月报") @@ -129,14 +131,18 @@ public class AreaMonthReportController extends BladeController { if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){ return R.fail("传入格式不对,请重新导出"); } - String deptName=""; + R deptNameR = sysClient.getDeptName(deptId); + if (!deptNameR.isSuccess()) { + return R.fail("暂无该机构"); + } + String deptName = deptNameR.getData(); if (type==1){ service.exportHydropowerStationMonthReport(response, map,year,month,deptId,deptName); //word模板相对路径、word生成路径、word生成的文件名称、数据源 } XWPFDocument xwpfDocument = WordUtils.exportWordV2("template/waterMonReport.docx", map); // 下载导出 - String filename = "(" + year+"年"+month+"月"+ ")"+deptName+"水电站月报"; + String filename = year+"年"+month+"月"+deptName+"月报"; // 设置头信息 response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); 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 0e7ad35..bcc9c75 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 @@ -50,10 +50,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.jfree.data.category.DefaultCategoryDataset; import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; @@ -204,18 +201,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return R.data("success"); } @Override - public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId,String name) { + public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId,String deptName) { R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ return R.fail("用户权限查询失败"); } - R deptNameR = sysClient.getDeptName(deptId); - if (!deptNameR.isSuccess()) { - return R.fail("暂无该机构"); - } - String deptName = deptNameR.getData(); -// 赋值给导出表格名称 - name=deptName; R> deptR = sysClient.getDeptByType("200000", deptId, 4); if (!deptR.isSuccess() || deptR.getData() == null) { return R.fail("该机构不包含水站信息"); @@ -229,12 +219,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List stationEntityList = stationService.list(Wrappers.lambdaQuery() .in(StationEntity::getRefDept, deptIds) .eq(StationEntity::getType, HomePageConstant.HYDROPOWER)); + stationEntityList=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(stationEntityList)) { - Integer commissionTime = stationEntityList.stream().map(s -> { + int commissionTime = stationEntityList.stream().map(s -> { Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); return (int) dur.toDays(); }).reduce(Integer::max).get(); - map.put("commissionTime", commissionTime.toString()); + map.put("commissionTime", String.valueOf(commissionTime)); }else { map.put("commissionTime", 0); } @@ -782,11 +773,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { private static void getTabelSum(Long deptId, List powerPercentageVoList, List planYearAll, List planMonAll, HashMap map) { Float planGeneration = 0f; - if (CollectionUtil.isNotEmpty(planYearAll)) { + if (Func.isNotEmpty(planYearAll)) { planGeneration = planYearAll.get(0).getPlanGeneration(); } Float planMonGeneration = 0f; - if (CollectionUtil.isNotEmpty(planYearAll)) { + if (Func.isNotEmpty(planMonAll)) { planMonGeneration = planMonAll.get(0).getPlanGeneration(); } MonPowerPercentageVo powerVo = new MonPowerPercentageVo();