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();