feat(report): 优化电费报表和目标统计报表的部门查询逻辑- 在 ReportElectricCostServiceImpl 中添加 ICommonS…
…qlService 依赖,用于获取子工厂的 departIds - 优化 ReportTargetStatisticsServiceImpl 中的 SQL 查询条件,修复部门 ID 的拼接问题
正在显示
3 个修改的文件
包含
10 行增加
和
7 行删除
sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/controller/SysCommandCentreController.java
... | @@ -128,7 +128,7 @@ public class SysCommandCentreController { | ... | @@ -128,7 +128,7 @@ public class SysCommandCentreController { |
128 | Result<List<WaterTreatmentVO>> result = new Result<>(); | 128 | Result<List<WaterTreatmentVO>> result = new Result<>(); |
129 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 | 129 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 |
130 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ | 130 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ |
131 | departIds = reportItemvParam.getDepartIds(); | 131 | departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); |
132 | } | 132 | } |
133 | List<WaterTreatmentVO> waterTrendVOList = commandCentreService.statisticsCLSLXQ(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(), departIds); | 133 | List<WaterTreatmentVO> waterTrendVOList = commandCentreService.statisticsCLSLXQ(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(), departIds); |
134 | result.setResult(waterTrendVOList ); | 134 | result.setResult(waterTrendVOList ); |
... | @@ -157,7 +157,7 @@ public class SysCommandCentreController { | ... | @@ -157,7 +157,7 @@ public class SysCommandCentreController { |
157 | Result<List<ReportItemVO>> result = new Result(); | 157 | Result<List<ReportItemVO>> result = new Result(); |
158 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 | 158 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 |
159 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ | 159 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ |
160 | departIds = reportItemvParam.getDepartIds(); | 160 | departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); |
161 | } | 161 | } |
162 | List<ReportItemVO> dataList = reportItemvService.statisticsByCementList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); | 162 | List<ReportItemVO> dataList = reportItemvService.statisticsByCementList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); |
163 | result.setResult(dataList ); | 163 | result.setResult(dataList ); |
... | @@ -227,7 +227,7 @@ public class SysCommandCentreController { | ... | @@ -227,7 +227,7 @@ public class SysCommandCentreController { |
227 | Result<List<ReportItemVO>> result = new Result(); | 227 | Result<List<ReportItemVO>> result = new Result(); |
228 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 | 228 | String departIds = BaseContextHandler.getDeparts();//1818214519948836864,1711662624459804674 |
229 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ | 229 | if(StringUtils.isNotEmpty(reportItemvParam.getDepartIds()) ){ |
230 | departIds = reportItemvParam.getDepartIds(); | 230 | departIds = commonSqlService.getChildFactorys(reportItemvParam.getDepartIds()); |
231 | } | 231 | } |
232 | List<ReportItemVO> dataList = reportItemvService.statisticsByElectricityList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); | 232 | List<ReportItemVO> dataList = reportItemvService.statisticsByElectricityList(departIds,reportItemvParam.getStartDate(),reportItemvParam.getEndDate()); |
233 | result.setResult(dataList ); | 233 | result.setResult(dataList ); | ... | ... |
... | @@ -94,7 +94,7 @@ public class ReportTargetStatisticsServiceImpl implements IReportTargetStatisti | ... | @@ -94,7 +94,7 @@ public class ReportTargetStatisticsServiceImpl implements IReportTargetStatisti |
94 | 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"; | 94 | 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"; |
95 | sql += " where d.depart_type = 1 "; | 95 | sql += " where d.depart_type = 1 "; |
96 | if(StringUtils.isNotEmpty(departIds)){ | 96 | if(StringUtils.isNotEmpty(departIds)){ |
97 | sql += " and d.id in ("+departIds+") "; | 97 | sql += " and d.id in ("+departIds+") "; |
98 | } | 98 | } |
99 | List<ReportTargetEnergyVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetEnergyVO.class)); | 99 | List<ReportTargetEnergyVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetEnergyVO.class)); |
100 | return dataList; | 100 | return dataList; | ... | ... |
... | @@ -3,6 +3,7 @@ package com.skua.modules.report.service.impl; | ... | @@ -3,6 +3,7 @@ package com.skua.modules.report.service.impl; |
3 | import com.baomidou.mybatisplus.core.metadata.IPage; | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; |
4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
5 | import com.skua.core.context.BaseContextHandler; | 5 | import com.skua.core.context.BaseContextHandler; |
6 | import com.skua.modules.common.service.ICommonSqlService; | ||
6 | import com.skua.modules.report.entity.ReportElectricCost; | 7 | import com.skua.modules.report.entity.ReportElectricCost; |
7 | import com.skua.modules.report.mapper.ReportElectricCostMapper; | 8 | import com.skua.modules.report.mapper.ReportElectricCostMapper; |
8 | import com.skua.modules.report.service.IReportElectricCostService; | 9 | import com.skua.modules.report.service.IReportElectricCostService; |
... | @@ -24,15 +25,17 @@ public class ReportElectricCostServiceImpl extends ServiceImpl<ReportElectricCos | ... | @@ -24,15 +25,17 @@ public class ReportElectricCostServiceImpl extends ServiceImpl<ReportElectricCos |
24 | 25 | ||
25 | @Resource | 26 | @Resource |
26 | private ReportElectricCostMapper reportElectricCostMapper; | 27 | private ReportElectricCostMapper reportElectricCostMapper; |
28 | @Autowired | ||
29 | private ICommonSqlService commonSqlService; | ||
27 | //月度电费报表-分页列表查询 | 30 | //月度电费报表-分页列表查询 |
28 | @Override | 31 | @Override |
29 | public IPage<ReportElectricCost> getPage(Page<ReportElectricCost> page, ReportElectricCost reportElectricCost) { | 32 | public IPage<ReportElectricCost> getPage(Page<ReportElectricCost> page, ReportElectricCost reportElectricCost) { |
30 | if(StringUtils.isEmpty(reportElectricCost.getDepartId())){ | 33 | if(StringUtils.isEmpty(reportElectricCost.getDepartId())){ |
31 | reportElectricCost.setDepartId(BaseContextHandler.getDeparts()); | 34 | reportElectricCost.setDepartId(BaseContextHandler.getDeparts()); |
35 | }else{ | ||
36 | String departIds = commonSqlService.getChildFactorys(reportElectricCost.getDepartId()); | ||
37 | reportElectricCost.setDepartId(departIds); | ||
32 | } | 38 | } |
33 | // if(reportElectricCost.getMonth()!=null){ | ||
34 | // queryWrapper.like("month",reportElectricCost.getMonth()); | ||
35 | // } | ||
36 | List<ReportElectricCost> list = new ArrayList<>(); | 39 | List<ReportElectricCost> list = new ArrayList<>(); |
37 | list = reportElectricCostMapper.getPage(reportElectricCost); | 40 | list = reportElectricCostMapper.getPage(reportElectricCost); |
38 | page.setRecords(list); | 41 | page.setRecords(list); | ... | ... |
-
请 注册 或 登录 后发表评论