From 69d21db4f7d65070502a1ac82d8b0def2fd1a1b2 Mon Sep 17 00:00:00 2001 From: zhanglei <lei.zhang@kingtroldata.com> Date: Mon, 24 Mar 2025 17:33:47 +0800 Subject: [PATCH] feat(report): 优化电费报表和目标统计报表的部门查询逻辑- 在 ReportElectricCostServiceImpl 中添加 ICommonSqlService 依赖,用于获取子工厂的 departIds - 优化 ReportTargetStatisticsServiceImpl 中的 SQL 查询条件,修复部门 ID 的拼接问题 --- sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java | 6 +++--- sk-module-biz/src/main/java/com/skua/modules/statistics/service/impl/ReportTargetStatisticsServiceImpl.java | 2 +- sk-module-datafill/src/main/java/com/skua/modules/report/service/impl/ReportElectricCostServiceImpl.java | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java b/sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java index aeea14a..b4db752 100644 --- a/sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java +++ b/sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java @@ -128,7 +128,7 @@ public class SysCommandCentreController { Result<List<WaterTreatmentVO>> result = new Result<>(); String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ - departIds = reportItemvParam.getDepartIds(); + departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); } List<WaterTreatmentVO> waterTrendVOList = commandCentreService.statisticsCLSLXQ(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(), departIds); result.setResult(waterTrendVOList ); @@ -157,7 +157,7 @@ public class SysCommandCentreController { Result<List<ReportItemVO>> result = new Result(); String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ - departIds = reportItemvParam.getDepartIds(); + departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); } List<ReportItemVO> dataList = reportItemvService.statisticsByCementList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); result.setResult(dataList ); @@ -227,7 +227,7 @@ public class SysCommandCentreController { Result<List<ReportItemVO>> result = new Result(); String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ - departIds = reportItemvParam.getDepartIds(); + departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); } List<ReportItemVO> dataList = reportItemvService.statisticsByElectricityList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); result.setResult(dataList ); diff --git a/sk-module-biz/src/main/java/com/skua/modules/statistics/service/impl/ReportTargetStatisticsServiceImpl.java b/sk-module-biz/src/main/java/com/skua/modules/statistics/service/impl/ReportTargetStatisticsServiceImpl.java index 3151430..79c28e5 100644 --- a/sk-module-biz/src/main/java/com/skua/modules/statistics/service/impl/ReportTargetStatisticsServiceImpl.java +++ b/sk-module-biz/src/main/java/com/skua/modules/statistics/service/impl/ReportTargetStatisticsServiceImpl.java @@ -94,7 +94,7 @@ public class ReportTargetStatisticsServiceImpl implements IReportTargetStatisti sql += " left join ( select aaa.depart_id , round(ifnull(avg(aaa.yyh),0),2) yyh ,round(ifnull(avg(aaa.ydh),0),2) ydh from "+dataViewName4411_month+" aaa group by aaa.depart_id )bbb on bbb.depart_id = d.id"; sql += " where d.depart_type = 1 "; if(StringUtils.isNotEmpty(departIds)){ - sql += " and d.id in ("+departIds+") "; + sql += " and d.id in ("+departIds+") "; } List<ReportTargetEnergyVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetEnergyVO.class)); return dataList; diff --git a/sk-module-datafill/src/main/java/com/skua/modules/report/service/impl/ReportElectricCostServiceImpl.java b/sk-module-datafill/src/main/java/com/skua/modules/report/service/impl/ReportElectricCostServiceImpl.java index 34463d4..4e5cfc2 100644 --- a/sk-module-datafill/src/main/java/com/skua/modules/report/service/impl/ReportElectricCostServiceImpl.java +++ b/sk-module-datafill/src/main/java/com/skua/modules/report/service/impl/ReportElectricCostServiceImpl.java @@ -3,6 +3,7 @@ package com.skua.modules.report.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.skua.core.context.BaseContextHandler; +import com.skua.modules.common.service.ICommonSqlService; import com.skua.modules.report.entity.ReportElectricCost; import com.skua.modules.report.mapper.ReportElectricCostMapper; import com.skua.modules.report.service.IReportElectricCostService; @@ -24,15 +25,17 @@ public class ReportElectricCostServiceImpl extends ServiceImpl<ReportElectricCos @Resource private ReportElectricCostMapper reportElectricCostMapper; + @Autowired + private ICommonSqlService commonSqlService; //月度电费报表-分页列表查询 @Override public IPage<ReportElectricCost> getPage(Page<ReportElectricCost> page, ReportElectricCost reportElectricCost) { if(StringUtils.isEmpty(reportElectricCost.getDepartId())){ reportElectricCost.setDepartId(BaseContextHandler.getDeparts()); + }else{ + String departIds = commonSqlService.getChildFactorys(reportElectricCost.getDepartId()); + reportElectricCost.setDepartId(departIds); } -// if(reportElectricCost.getMonth()!=null){ -// queryWrapper.like("month",reportElectricCost.getMonth()); -// } List<ReportElectricCost> list = new ArrayList<>(); list = reportElectricCostMapper.getPage(reportElectricCost); page.setRecords(list); -- libgit2 0.24.0