kangwei:新增三个大屏组件开发-接口
正在显示
7 个修改的文件
包含
575 行增加
和
2 行删除
sk-module-biz/src/main/java/com/skua/modules/erp/service/impl/MaterialAcceptanceFormServiceImpl.java
... | @@ -29,7 +29,7 @@ public class MaterialAcceptanceFormServiceImpl extends ServiceImpl<MaterialAccep | ... | @@ -29,7 +29,7 @@ public class MaterialAcceptanceFormServiceImpl extends ServiceImpl<MaterialAccep |
29 | @Transactional | 29 | @Transactional |
30 | @Override | 30 | @Override |
31 | public void saveOrUpdateMaterialAcceptanceForm(MaterialAcceptanceForm materialAcceptanceForm) { | 31 | public void saveOrUpdateMaterialAcceptanceForm(MaterialAcceptanceForm materialAcceptanceForm) { |
32 | MaterialAcceptanceForm materialAcceptanceFormEntity = baseMapper.queryByMaterialInId(materialAcceptanceForm.getId()); | 32 | MaterialAcceptanceForm materialAcceptanceFormEntity = baseMapper.queryById(materialAcceptanceForm.getId()); |
33 | if(materialAcceptanceFormEntity==null) { | 33 | if(materialAcceptanceFormEntity==null) { |
34 | //result.error500("未找到对应实体"); | 34 | //result.error500("未找到对应实体"); |
35 | baseMapper.insert(materialAcceptanceForm); | 35 | baseMapper.insert(materialAcceptanceForm); |
... | @@ -37,7 +37,7 @@ public class MaterialAcceptanceFormServiceImpl extends ServiceImpl<MaterialAccep | ... | @@ -37,7 +37,7 @@ public class MaterialAcceptanceFormServiceImpl extends ServiceImpl<MaterialAccep |
37 | baseMapper.updateById(materialAcceptanceForm); | 37 | baseMapper.updateById(materialAcceptanceForm); |
38 | } | 38 | } |
39 | //修改药剂入库的确认状态 | 39 | //修改药剂入库的确认状态 |
40 | baseMapper.updateMaterialINConfirmStatus(materialAcceptanceForm.getId(),materialAcceptanceForm.getConfirmStatus()); | 40 | baseMapper.updateMaterialINConfirmStatus(materialAcceptanceForm.getMaterialInId(),materialAcceptanceForm.getConfirmStatus()); |
41 | 41 | ||
42 | } | 42 | } |
43 | public MaterialAcceptanceForm queryById(String id){ | 43 | public MaterialAcceptanceForm queryById(String id){ | ... | ... |
1 | package com.skua.modules.statistics.controller; | ||
2 | |||
3 | import com.skua.core.api.vo.Result; | ||
4 | import com.skua.core.context.BaseContextHandler; | ||
5 | import com.skua.modules.statistics.service.IReportTargetStatisticsService; | ||
6 | import com.skua.modules.statistics.vo.ReportTargetEnergyVO; | ||
7 | import com.skua.modules.statistics.vo.ReportTargetStatisticsVO; | ||
8 | import com.skua.modules.system.entity.SysDepart; | ||
9 | import com.skua.modules.system.service.ISysDepartService; | ||
10 | import com.skua.tool.util.JSUtils; | ||
11 | import io.swagger.annotations.Api; | ||
12 | import io.swagger.annotations.ApiOperation; | ||
13 | import lombok.extern.slf4j.Slf4j; | ||
14 | import org.apache.commons.lang3.StringUtils; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | ||
16 | import org.springframework.web.bind.annotation.GetMapping; | ||
17 | import org.springframework.web.bind.annotation.RequestMapping; | ||
18 | import org.springframework.web.bind.annotation.RestController; | ||
19 | |||
20 | import java.util.ArrayList; | ||
21 | import java.util.List; | ||
22 | |||
23 | /** | ||
24 | * @auther kangwei | ||
25 | * @create 2025-03-21-14:17 | ||
26 | */ | ||
27 | @Slf4j | ||
28 | @Api(tags = "/经营目标报表分析") | ||
29 | @RestController | ||
30 | @RequestMapping("/web/reportTarget/statistics") | ||
31 | public class ReportTargetStatisticsController { | ||
32 | |||
33 | @Autowired | ||
34 | private IReportTargetStatisticsService targetStatisticsService; | ||
35 | |||
36 | @Autowired | ||
37 | private ISysDepartService departService; | ||
38 | |||
39 | |||
40 | @ApiOperation(value = "水量经营分析", notes = "水量经营分析") | ||
41 | @GetMapping(value = "/targetWaterStatistics") | ||
42 | public Result<ReportTargetStatisticsVO> targetWaterStatistics(String departId,String year,String startTime, String endTime) { | ||
43 | Result<ReportTargetStatisticsVO> result = new Result<>(); | ||
44 | try { | ||
45 | String departIds = BaseContextHandler.getDeparts(); | ||
46 | if(StringUtils.isNotEmpty(departId)){ | ||
47 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
48 | } | ||
49 | ReportTargetStatisticsVO targetStatisticsVO = targetStatisticsService.targetWaterStatistics(departIds,year,startTime,endTime); | ||
50 | |||
51 | SysDepart depart = departService.getById("1892199062790823936"); | ||
52 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199062790823936","1"); | ||
53 | ReportTargetStatisticsVO targetStatisticsVO_nj = targetStatisticsService.targetWaterStatistics(departIds,year,startTime,endTime); | ||
54 | targetStatisticsVO_nj.setDepartName(depart.getDepartName()); targetStatisticsVO_nj.setDepartId(depart.getId()); | ||
55 | |||
56 | depart = departService.getById("1892199890272477184"); | ||
57 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199890272477184","1"); | ||
58 | ReportTargetStatisticsVO targetStatisticsVO_wh = targetStatisticsService.targetWaterStatistics(departIds,year,startTime,endTime); | ||
59 | targetStatisticsVO_wh.setDepartName(depart.getDepartName()); targetStatisticsVO_wh.setDepartId(depart.getId()); | ||
60 | |||
61 | depart = departService.getById("1818215543140909056"); | ||
62 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1818215543140909056","1"); | ||
63 | ReportTargetStatisticsVO targetStatisticsVO_ef = targetStatisticsService.targetWaterStatistics(departIds,year,startTime,endTime); | ||
64 | targetStatisticsVO_ef.setDepartName(depart.getDepartName()); targetStatisticsVO_ef.setDepartId(depart.getId()); | ||
65 | |||
66 | List<ReportTargetStatisticsVO> dataList = new ArrayList<>(); | ||
67 | dataList.add( targetStatisticsVO_nj); | ||
68 | dataList.add(targetStatisticsVO_wh ); | ||
69 | dataList.add(targetStatisticsVO_ef ); | ||
70 | |||
71 | targetStatisticsVO.setDataList( dataList ); | ||
72 | result.setSuccess(true); | ||
73 | result.setResult(targetStatisticsVO); | ||
74 | } catch (Exception e) { | ||
75 | log.error("水量经营分析", e.getMessage()); | ||
76 | result.error500("水量经营分析"); | ||
77 | } | ||
78 | return result; | ||
79 | } | ||
80 | |||
81 | @ApiOperation(value = "水量经营分析-列表", notes = "水量经营分析-列表") | ||
82 | @GetMapping(value = "/targetWaterStatisticsList") | ||
83 | public Result<List<ReportTargetStatisticsVO>> targetWaterStatisticsList(String departId,String year,String startTime, String endTime) { | ||
84 | Result<List<ReportTargetStatisticsVO>> result = new Result<>(); | ||
85 | try { | ||
86 | String departIds = BaseContextHandler.getDeparts(); | ||
87 | if(StringUtils.isNotEmpty(departId)){ | ||
88 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
89 | } | ||
90 | List<ReportTargetStatisticsVO> dataList = targetStatisticsService.targetWaterStatisticsList(departIds,year,startTime,endTime); | ||
91 | result.setSuccess(true); | ||
92 | result.setResult(dataList); | ||
93 | } catch (Exception e) { | ||
94 | log.error("水量经营分析-列表", e.getMessage()); | ||
95 | result.error500("水量经营分析-列表"); | ||
96 | } | ||
97 | return result; | ||
98 | } | ||
99 | |||
100 | |||
101 | @ApiOperation(value = "能耗经营分析", notes = "能耗经营分析") | ||
102 | @GetMapping(value = "/targetEnergyStatistics") | ||
103 | public Result<ReportTargetEnergyVO> targetEnergyStatistics(String departId,String year,String startTime, String endTime) { | ||
104 | Result<ReportTargetEnergyVO> result = new Result<>(); | ||
105 | try { | ||
106 | String departIds = BaseContextHandler.getDeparts(); | ||
107 | if(StringUtils.isNotEmpty(departId)){ | ||
108 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
109 | } | ||
110 | ReportTargetEnergyVO targetStatisticsVO = targetStatisticsService.targetEnergyStatistics(departIds,year,startTime,endTime); | ||
111 | |||
112 | SysDepart depart = departService.getById("1892199062790823936"); | ||
113 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199062790823936","1"); | ||
114 | ReportTargetEnergyVO targetStatisticsVO_nj = targetStatisticsService.targetEnergyStatistics(departIds,year,startTime,endTime); | ||
115 | targetStatisticsVO_nj.setDepartName(depart.getDepartName()); targetStatisticsVO_nj.setDepartId(depart.getId()); | ||
116 | |||
117 | depart = departService.getById("1892199890272477184"); | ||
118 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199890272477184","1"); | ||
119 | ReportTargetEnergyVO targetStatisticsVO_wh = targetStatisticsService.targetEnergyStatistics(departIds,year,startTime,endTime); | ||
120 | targetStatisticsVO_wh.setDepartName(depart.getDepartName()); targetStatisticsVO_wh.setDepartId(depart.getId()); | ||
121 | |||
122 | depart = departService.getById("1818215543140909056"); | ||
123 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1818215543140909056","1"); | ||
124 | ReportTargetEnergyVO targetStatisticsVO_ef = targetStatisticsService.targetEnergyStatistics(departIds,year,startTime,endTime); | ||
125 | targetStatisticsVO_ef.setDepartName(depart.getDepartName()); targetStatisticsVO_ef.setDepartId(depart.getId()); | ||
126 | |||
127 | List<ReportTargetEnergyVO> dataList = new ArrayList<>(); | ||
128 | dataList.add( targetStatisticsVO_nj); | ||
129 | dataList.add(targetStatisticsVO_wh ); | ||
130 | dataList.add(targetStatisticsVO_ef ); | ||
131 | |||
132 | targetStatisticsVO.setDataList( dataList ); | ||
133 | result.setSuccess(true); | ||
134 | result.setResult(targetStatisticsVO); | ||
135 | } catch (Exception e) { | ||
136 | log.error("分析经营分析", e.getMessage()); | ||
137 | result.error500("费用经营分析"+e.getMessage()); | ||
138 | } | ||
139 | return result; | ||
140 | } | ||
141 | |||
142 | @ApiOperation(value = "能耗经营分析-列表", notes = "能耗经营分析-列表") | ||
143 | @GetMapping(value = "/targetEnergyStatisticsList") | ||
144 | public Result<List<ReportTargetEnergyVO>> targetEnergyStatisticsList(String departId, String year, String startTime, String endTime) { | ||
145 | Result<List<ReportTargetEnergyVO>> result = new Result<>(); | ||
146 | try { | ||
147 | String departIds = BaseContextHandler.getDeparts(); | ||
148 | if(StringUtils.isNotEmpty(departId)){ | ||
149 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
150 | } | ||
151 | List<ReportTargetEnergyVO> dataList = targetStatisticsService.targetEnergyStatisticsList(departIds,year,startTime,endTime); | ||
152 | result.setSuccess(true); | ||
153 | result.setResult(dataList); | ||
154 | } catch (Exception e) { | ||
155 | log.error("能耗经营分析-列表", e.getMessage()); | ||
156 | result.error500("能耗经营分析-列表"); | ||
157 | } | ||
158 | return result; | ||
159 | } | ||
160 | |||
161 | |||
162 | |||
163 | |||
164 | |||
165 | @ApiOperation(value = "费用经营分析", notes = "费用经营分析") | ||
166 | @GetMapping(value = "/targetCostStatistics") | ||
167 | public Result<ReportTargetStatisticsVO> targetCostStatistics(String departId,String year,String startTime, String endTime) { | ||
168 | Result<ReportTargetStatisticsVO> result = new Result<>(); | ||
169 | try { | ||
170 | String departIds = BaseContextHandler.getDeparts(); | ||
171 | if(StringUtils.isNotEmpty(departId)){ | ||
172 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
173 | } | ||
174 | ReportTargetStatisticsVO targetStatisticsVO = targetStatisticsService.targetCostStatistics(departIds,year,startTime,endTime); | ||
175 | |||
176 | SysDepart depart = departService.getById("1892199062790823936"); | ||
177 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199062790823936","1"); | ||
178 | ReportTargetStatisticsVO targetStatisticsVO_nj = targetStatisticsService.targetCostStatistics(departIds,year,startTime,endTime); | ||
179 | targetStatisticsVO_nj.setDepartName(depart.getDepartName()); targetStatisticsVO_nj.setDepartId(depart.getId()); | ||
180 | |||
181 | depart = departService.getById("1892199890272477184"); | ||
182 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1892199890272477184","1"); | ||
183 | ReportTargetStatisticsVO targetStatisticsVO_wh = targetStatisticsService.targetCostStatistics(departIds,year,startTime,endTime); | ||
184 | targetStatisticsVO_wh.setDepartName(depart.getDepartName()); targetStatisticsVO_wh.setDepartId(depart.getId()); | ||
185 | |||
186 | depart = departService.getById("1818215543140909056"); | ||
187 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),"1818215543140909056","1"); | ||
188 | ReportTargetStatisticsVO targetStatisticsVO_ef = targetStatisticsService.targetCostStatistics(departIds,year,startTime,endTime); | ||
189 | targetStatisticsVO_ef.setDepartName(depart.getDepartName()); targetStatisticsVO_ef.setDepartId(depart.getId()); | ||
190 | |||
191 | List<ReportTargetStatisticsVO> dataList = new ArrayList<>(); | ||
192 | dataList.add( targetStatisticsVO_nj); | ||
193 | dataList.add(targetStatisticsVO_wh ); | ||
194 | dataList.add(targetStatisticsVO_ef ); | ||
195 | |||
196 | targetStatisticsVO.setDataList( dataList ); | ||
197 | result.setSuccess(true); | ||
198 | result.setResult(targetStatisticsVO); | ||
199 | } catch (Exception e) { | ||
200 | log.error("费用经营分析", e.getMessage()); | ||
201 | result.error500("费用经营分析"); | ||
202 | } | ||
203 | return result; | ||
204 | } | ||
205 | |||
206 | @ApiOperation(value = "费用经营分析-列表", notes = "费用经营分析-列表") | ||
207 | @GetMapping(value = "/targetCostStatisticsList") | ||
208 | public Result<List<ReportTargetStatisticsVO>> targetCostStatisticsList(String departId,String year,String startTime, String endTime) { | ||
209 | Result<List<ReportTargetStatisticsVO>> result = new Result<>(); | ||
210 | try { | ||
211 | String departIds = BaseContextHandler.getDeparts(); | ||
212 | if(StringUtils.isNotEmpty(departId)){ | ||
213 | departIds = departService.getChildDepartId(BaseContextHandler.getDeparts(),departId,"1"); | ||
214 | } | ||
215 | List<ReportTargetStatisticsVO> dataList = targetStatisticsService.targetCostStatisticsList(departIds,year,startTime,endTime); | ||
216 | result.setSuccess(true); | ||
217 | result.setResult(dataList); | ||
218 | } catch (Exception e) { | ||
219 | log.error("费用经营分析-列表", e.getMessage()); | ||
220 | result.error500("费用经营分析-列表"); | ||
221 | } | ||
222 | return result; | ||
223 | } | ||
224 | |||
225 | } |
sk-module-biz/src/main/java/com/skua/modules/statistics/service/IReportTargetStatisticsService.java
0 → 100644
1 | package com.skua.modules.statistics.service; | ||
2 | |||
3 | import com.skua.modules.statistics.vo.ReportTargetEnergyVO; | ||
4 | import com.skua.modules.statistics.vo.ReportTargetStatisticsVO; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | /** | ||
9 | * @auther kangwei | ||
10 | * @create 2025-03-21-14:19 | ||
11 | */ | ||
12 | public interface IReportTargetStatisticsService { | ||
13 | /*** | ||
14 | * 水量经营分析 | ||
15 | * @param departIds | ||
16 | * @param year | ||
17 | * @param endTime | ||
18 | * @return | ||
19 | */ | ||
20 | public ReportTargetStatisticsVO targetWaterStatistics(String departIds, String year , String startTime, String endTime ); | ||
21 | //水量经营分析 列表 | ||
22 | public List<ReportTargetStatisticsVO> targetWaterStatisticsList(String departIds, String year , String startTime, String endTime); | ||
23 | |||
24 | /*** | ||
25 | * 能耗经营分析 | ||
26 | * @param departIds | ||
27 | * @param year | ||
28 | * @param | ||
29 | * @return | ||
30 | */ | ||
31 | public ReportTargetEnergyVO targetEnergyStatistics(String departIds, String year , String startTime, String endTime); | ||
32 | //能耗分析:列表 | ||
33 | public List<ReportTargetEnergyVO> targetEnergyStatisticsList(String departIds,String year ,String startTime,String endTime); | ||
34 | |||
35 | /*** | ||
36 | * 费用经营分析 | ||
37 | * @param departIds | ||
38 | * @param year | ||
39 | * @param | ||
40 | * @return | ||
41 | */ | ||
42 | public ReportTargetStatisticsVO targetCostStatistics(String departIds,String year ,String startTime,String endTime); | ||
43 | //费用经营分析 --列表 | ||
44 | public List<ReportTargetStatisticsVO> targetCostStatisticsList(String departIds,String year ,String startTime,String endTime); | ||
45 | } |
1 | package com.skua.modules.statistics.service.impl; | ||
2 | |||
3 | import com.skua.common.constant.ReportConstant; | ||
4 | import com.skua.common.report.ReportViewUtil; | ||
5 | import com.skua.core.context.SpringContextUtils; | ||
6 | import com.skua.core.util.ConvertUtils; | ||
7 | import com.skua.modules.statistics.service.IReportTargetStatisticsService; | ||
8 | import com.skua.modules.statistics.vo.ReportTargetEnergyVO; | ||
9 | import com.skua.modules.statistics.vo.ReportTargetStatisticsVO; | ||
10 | import com.skua.tool.util.DateUtils; | ||
11 | import com.skua.tool.util.JSUtils; | ||
12 | import org.apache.commons.lang3.StringUtils; | ||
13 | import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
14 | import org.springframework.jdbc.core.JdbcTemplate; | ||
15 | import org.springframework.stereotype.Service; | ||
16 | import java.util.List; | ||
17 | import java.util.Map; | ||
18 | |||
19 | /** | ||
20 | * @auther kangwei | ||
21 | * @create 2025-03-21-14:19 | ||
22 | */ | ||
23 | @Service("IReportTargetStatisticsService") | ||
24 | public class ReportTargetStatisticsServiceImpl implements IReportTargetStatisticsService { | ||
25 | |||
26 | /*** | ||
27 | * 水量经营分析 | ||
28 | * @param departIds | ||
29 | * @param year | ||
30 | * @param endTime | ||
31 | * @return | ||
32 | */ | ||
33 | public ReportTargetStatisticsVO targetWaterStatistics(String departIds,String year ,String startTime,String endTime ){ | ||
34 | String sql = "select ifnull(sum(t.target_water),0) target_water from report_target_config t where t.target_year = '"+year+"' and t.depart_id in ( "+JSUtils.quoteEach(departIds,",")+")"; | ||
35 | String yearTarget = getJdbcTemplate().queryForObject(sql,String.class); | ||
36 | sql ="select ifnull(SUM(target_value),0) FROM report_target_config_sub WHERE target_type = 'SL' AND target_time= '"+ DateUtils.formatDate(startTime,"yyyy-MM") +"' AND depart_id in ("+JSUtils.quoteEach(departIds,",")+")"; | ||
37 | String monthTarget = getJdbcTemplate().queryForObject(sql,String.class); | ||
38 | |||
39 | String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,"CSL", departIds, year+"-01-01",year+"-12-31"); | ||
40 | sql = "select round(ifnull(sum(aaa.CSL)/10000,0),2) 'CSL' from "+ dataViewName2119 + " aaa"; | ||
41 | String yearValue = getJdbcTemplate().queryForObject(sql,String.class); | ||
42 | |||
43 | dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,"CSL", departIds, startTime,endTime); | ||
44 | sql = "select round(ifnull(sum(aaa.CSL)/10000,0),2) 'CSL' from "+ dataViewName2119 + " aaa"; | ||
45 | String monthValue = getJdbcTemplate().queryForObject(sql,String.class); | ||
46 | |||
47 | ReportTargetStatisticsVO targetStatisticsVO = new ReportTargetStatisticsVO(yearTarget, yearValue, monthTarget, monthValue); | ||
48 | return targetStatisticsVO; | ||
49 | } | ||
50 | |||
51 | public List<ReportTargetStatisticsVO> targetWaterStatisticsList(String departIds,String year ,String startTime,String endTime){ | ||
52 | String month = DateUtils.formatDate(startTime,"yyyy-MM"); | ||
53 | String dataViewName2119_year = ReportViewUtil.buildView(ReportConstant.view2119,"CSL", departIds, year+"-01-01",year+"-12-31"); | ||
54 | String dataViewName2119_month = ReportViewUtil.buildView(ReportConstant.view2119,"CSL", departIds, startTime,endTime); | ||
55 | |||
56 | String sql = " select d.depart_name ,ifnull(tc.target_water,0) 'yearTarget' ,ifnull(tcs.target_value,0) 'monthTarget',ifnull(ccc.CSL,0) 'yearValue',ifnull(ddd.CSL,0) 'monthValue' from sys_depart d "; | ||
57 | sql += " left join report_target_config tc on (tc.depart_id = d.id and tc.target_year = '"+year+"') "; | ||
58 | sql += " left join report_target_config_sub tcs on (tcs.depart_id = d.id and target_type = 'SL' AND target_time= '"+month+"') "; | ||
59 | sql += " left join( select aaa.depart_id, round(ifnull(sum(aaa.CSL)/10000,0),2) 'CSL' from " + dataViewName2119_year+"aaa group by aaa.depart_id ) ccc on ccc.depart_id = d.id "; | ||
60 | sql += " left join( select aaa.depart_id, round(ifnull(sum(aaa.CSL)/10000,0),2) 'CSL' from " + dataViewName2119_month+"aaa group by aaa.depart_id ) ddd on ddd.depart_id = d.id "; | ||
61 | sql += " where d.depart_type = 1 "; | ||
62 | if(StringUtils.isNotEmpty(departIds)){ | ||
63 | sql += " and d.id in ("+departIds+") "; | ||
64 | } | ||
65 | sql += "order by ccc.CSL desc "; | ||
66 | List<ReportTargetStatisticsVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetStatisticsVO.class)); | ||
67 | return dataList; | ||
68 | } | ||
69 | /*** | ||
70 | * 能耗经营分析 | ||
71 | * @param departIds | ||
72 | * @param year | ||
73 | * @param | ||
74 | * @return | ||
75 | */ | ||
76 | public ReportTargetEnergyVO targetEnergyStatistics(String departIds, String year , String startTime, String endTime){ | ||
77 | String sql = "select round(ifnull(avg(target_power),0),2) target_power,round(ifnull(avg(target_drug),0),2) target_drug from report_target_config t where t.target_year = '"+year+"' and t.depart_id in ( "+JSUtils.quoteEach(departIds,",")+")"; | ||
78 | Map<String, Object> targetMap = getJdbcTemplate().queryForMap(sql); | ||
79 | |||
80 | String dataViewName4411_year = ReportViewUtil.buildView(ReportConstant.view4411,"bnsjyh,bnsjdh", departIds, year+"-01",year+"-12") ; | ||
81 | sql = " select round(ifnull(avg(aaa.bnsjyh),0),2) 'dsyf',round(ifnull(avg(aaa.bnsjdh),0),2) 'dsdf' from "+dataViewName4411_year +" aaa" ; | ||
82 | Map<String, Object> dataMap = getJdbcTemplate().queryForMap(sql); | ||
83 | |||
84 | ReportTargetEnergyVO targetEnergyVO = new ReportTargetEnergyVO(ConvertUtils.getString(targetMap.get("target_power"),"0"),ConvertUtils.getString(dataMap.get("dsdf"),"0"), | ||
85 | ConvertUtils.getString(targetMap.get("target_drug"),"0"),ConvertUtils.getString(dataMap.get("dsdf"),"0")); | ||
86 | return targetEnergyVO; | ||
87 | } | ||
88 | public List<ReportTargetEnergyVO> targetEnergyStatisticsList(String departIds,String year ,String startTime,String endTime){ | ||
89 | String month = DateUtils.formatDate(startTime,"yyyy-MM"); | ||
90 | String dataViewName4411_month = ReportViewUtil.buildView(ReportConstant.view4411,"yyh,ydh", departIds, month,month) ; | ||
91 | |||
92 | String sql = " select d.depart_name , tc.target_power 'dsdfYearTarget',tc.target_drug 'dsyfYearTarget', ifnull(bbb.yyh,0) 'dsyfValue' , ifnull(bbb.ydh,0) 'dsdfValue' from sys_depart d "; | ||
93 | sql += " left join report_target_config tc on (tc.depart_id = d.id and tc.target_year = '"+year+"' ) "; | ||
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 "; | ||
96 | if(StringUtils.isNotEmpty(departIds)){ | ||
97 | sql += " and d.id in ("+departIds+") "; | ||
98 | } | ||
99 | List<ReportTargetEnergyVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetEnergyVO.class)); | ||
100 | return dataList; | ||
101 | } | ||
102 | /*** | ||
103 | * 水量经营分析 | ||
104 | * @param departIds | ||
105 | * @param year | ||
106 | * @param | ||
107 | * @return | ||
108 | */ | ||
109 | public ReportTargetStatisticsVO targetCostStatistics(String departIds,String year ,String startTime,String endTime){ | ||
110 | String month = DateUtils.formatDate(startTime,"yyyy-MM"); | ||
111 | |||
112 | String sql = "select ifnull(sum(t.target_cost),0) target_cost from report_target_config t where t.target_year = '"+year+"' and t.depart_id in ( "+ JSUtils.quoteEach(departIds,",")+")"; | ||
113 | String yearTarget = getJdbcTemplate().queryForObject(sql,String.class); | ||
114 | |||
115 | sql ="select ifnull(SUM(target_value),0) FROM report_target_config_sub WHERE target_type = 'fy' AND target_time= '"+ DateUtils.formatDate(startTime,"yyyy-MM") +"' AND depart_id in ("+JSUtils.quoteEach(departIds,",")+")"; | ||
116 | String monthTarget = getJdbcTemplate().queryForObject(sql,String.class); | ||
117 | |||
118 | String dataViewName4411_year = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsf", departIds, year+"-01-01",year+"-12-31"); | ||
119 | sql = "select round(ifnull(sum(aaa.ysjsf)/10000,0),2) 'ysjsf' from "+ dataViewName4411_year + " aaa"; | ||
120 | String yearValue = getJdbcTemplate().queryForObject(sql,String.class); | ||
121 | |||
122 | String dataViewName4411_month = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsf", departIds, month,month) ; | ||
123 | sql = "select round(ifnull(sum(aaa.ysjsf)/10000,0),2) 'ysjsf' from "+ dataViewName4411_month + " aaa"; | ||
124 | String monthValue = getJdbcTemplate().queryForObject(sql,String.class); | ||
125 | |||
126 | ReportTargetStatisticsVO targetStatisticsVO = new ReportTargetStatisticsVO(yearTarget, yearValue, monthTarget, monthValue); | ||
127 | return targetStatisticsVO; | ||
128 | } | ||
129 | |||
130 | public List<ReportTargetStatisticsVO> targetCostStatisticsList(String departIds,String year ,String startTime,String endTime){ | ||
131 | String month = DateUtils.formatDate(startTime,"yyyy-MM"); | ||
132 | String dataViewName4411_year = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsf", departIds, year+"-01-01",year+"-12-31"); | ||
133 | String dataViewName4411_month = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsf", departIds, month,month) ; | ||
134 | |||
135 | String sql = " select d.depart_name ,ifnull(tc.target_cost,0) 'yearTarget' ,ifnull(tcs.target_value,0) 'monthTarget',ifnull(ccc.ysjsf,0) 'yearValue',ifnull(ddd.ysjsf,0) 'monthValue' from sys_depart d "; | ||
136 | sql += " left join report_target_config tc on (tc.depart_id = d.id and tc.target_year = '"+year+"') "; | ||
137 | sql += " left join report_target_config_sub tcs on (tcs.depart_id = d.id and target_type = 'fy' AND target_time= '"+month+"') "; | ||
138 | |||
139 | sql += " left join( select aaa.depart_id, round(ifnull(sum(aaa.ysjsf)/10000,0),2) 'ysjsf' from " + dataViewName4411_year+"aaa group by aaa.depart_id ) ccc on ccc.depart_id = d.id "; | ||
140 | sql += " left join( select aaa.depart_id, round(ifnull(sum(aaa.ysjsf)/10000,0),2) 'ysjsf' from " + dataViewName4411_month+"aaa group by aaa.depart_id ) ddd on ddd.depart_id = d.id "; | ||
141 | sql += " where d.depart_type = 1 "; | ||
142 | if(StringUtils.isNotEmpty(departIds)){ | ||
143 | sql += " and d.id in ("+departIds+") "; | ||
144 | } | ||
145 | List<ReportTargetStatisticsVO> dataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<>(ReportTargetStatisticsVO.class)); | ||
146 | return dataList; | ||
147 | } | ||
148 | |||
149 | private JdbcTemplate getJdbcTemplate(){ | ||
150 | JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
151 | return jdbcTemplate; | ||
152 | } | ||
153 | } |
1 | package com.skua.modules.statistics.vo; | ||
2 | |||
3 | import io.swagger.annotations.ApiModel; | ||
4 | import io.swagger.annotations.ApiModelProperty; | ||
5 | import lombok.Data; | ||
6 | |||
7 | import java.util.List; | ||
8 | |||
9 | /** | ||
10 | * @auther kangwei | ||
11 | * @create 2025-03-21-15:10 | ||
12 | */ | ||
13 | @Data | ||
14 | @ApiModel(value="ReportTargetInfoVO ", description="运营目标报表分析对象") | ||
15 | public class ReportTargetEnergyVO { | ||
16 | |||
17 | @ApiModelProperty(value = "机构ID") | ||
18 | private String departId; | ||
19 | |||
20 | @ApiModelProperty(value = "机构名称") | ||
21 | private String departName; | ||
22 | |||
23 | @ApiModelProperty(value = "吨水电费年目标") | ||
24 | private String dsdfYearTarget; | ||
25 | |||
26 | @ApiModelProperty(value = "吨水药费年目标") | ||
27 | private String dsyfYearTarget; | ||
28 | |||
29 | @ApiModelProperty(value = "吨水电费实际值") | ||
30 | private String dsdfValue; | ||
31 | |||
32 | @ApiModelProperty(value = "吨水药费实际值") | ||
33 | private String dsyfValue; | ||
34 | |||
35 | |||
36 | public ReportTargetEnergyVO(){ | ||
37 | |||
38 | } | ||
39 | |||
40 | public ReportTargetEnergyVO(String dsdfYearTarget, String dsdfValue, String dsyfYearTarget, String dsyfValue) { | ||
41 | this.dsdfYearTarget = dsdfYearTarget; | ||
42 | this.dsyfYearTarget = dsyfYearTarget; | ||
43 | this.dsdfValue = dsdfValue; | ||
44 | this.dsyfValue = dsyfValue; | ||
45 | } | ||
46 | |||
47 | @ApiModelProperty(value = "列表数据") | ||
48 | private List<ReportTargetEnergyVO> dataList = null; | ||
49 | } |
1 | package com.skua.modules.statistics.vo; | ||
2 | |||
3 | import com.skua.core.aspect.annotation.Dict; | ||
4 | import com.skua.tool.util.JSUtils; | ||
5 | import io.swagger.annotations.ApiModel; | ||
6 | import io.swagger.annotations.ApiModelProperty; | ||
7 | import lombok.Data; | ||
8 | |||
9 | /** | ||
10 | * @auther kangwei | ||
11 | * @create 2025-03-21-14:22 | ||
12 | */ | ||
13 | @Data | ||
14 | @ApiModel(value="ReportTargetInfoVO ", description="运营目标报表分析对象") | ||
15 | public class ReportTargetInfoVO { | ||
16 | |||
17 | |||
18 | @ApiModelProperty(value = "目标Code") | ||
19 | private String targetCode; | ||
20 | |||
21 | @ApiModelProperty(value = "目标名称") | ||
22 | private String targetName; | ||
23 | |||
24 | @ApiModelProperty(value = "目标值") | ||
25 | private String targetValue; | ||
26 | |||
27 | @ApiModelProperty(value = "实际值") | ||
28 | private String value; | ||
29 | |||
30 | public ReportTargetInfoVO() { | ||
31 | } | ||
32 | |||
33 | public ReportTargetInfoVO(String targetCode, String targetName, String targetValue, String value) { | ||
34 | this.targetCode = targetCode; | ||
35 | this.targetName = targetName; | ||
36 | this.targetValue = targetValue; | ||
37 | this.value = value; | ||
38 | } | ||
39 | } |
1 | package com.skua.modules.statistics.vo; | ||
2 | |||
3 | import com.skua.core.aspect.annotation.Dict; | ||
4 | import com.skua.tool.util.JSUtils; | ||
5 | import io.swagger.annotations.ApiModel; | ||
6 | import io.swagger.annotations.ApiModelProperty; | ||
7 | import lombok.Data; | ||
8 | |||
9 | import java.util.List; | ||
10 | |||
11 | /** | ||
12 | * @auther kangwei | ||
13 | * @create 2025-03-21-14:22 | ||
14 | */ | ||
15 | @Data | ||
16 | @ApiModel(value="ReportTargetStatisticsVO ", description="运营目标报表分析对象") | ||
17 | public class ReportTargetStatisticsVO { | ||
18 | |||
19 | @ApiModelProperty(value = "机构ID") | ||
20 | private String departId; | ||
21 | |||
22 | @ApiModelProperty(value = "机构名称") | ||
23 | private String departName; | ||
24 | |||
25 | |||
26 | @ApiModelProperty(value = "年目标") | ||
27 | private String yearTarget; | ||
28 | |||
29 | @ApiModelProperty(value = "年完成值") | ||
30 | private String yearValue; | ||
31 | |||
32 | @ApiModelProperty(value = "年度完成比例") | ||
33 | private String yearWcBL; | ||
34 | |||
35 | @ApiModelProperty(value = "月目标") | ||
36 | private String monthTarget; | ||
37 | |||
38 | @ApiModelProperty(value = "月完成值") | ||
39 | private String monthValue; | ||
40 | |||
41 | @ApiModelProperty(value = "月度完成比例") | ||
42 | private String monthWcBL; | ||
43 | |||
44 | @ApiModelProperty(value = "数据列表") | ||
45 | private List<ReportTargetStatisticsVO> dataList = null; | ||
46 | |||
47 | |||
48 | |||
49 | public ReportTargetStatisticsVO() { | ||
50 | } | ||
51 | |||
52 | public ReportTargetStatisticsVO(String yearTarget, String yearValue, String monthTarget, String monthValue) { | ||
53 | this.yearTarget = yearTarget; | ||
54 | this.yearValue = yearValue; | ||
55 | String expression = "100 * ( "+yearValue+"/"+yearTarget+" )"; | ||
56 | this.yearWcBL = JSUtils.executeExpression(expression,"0.00"); | ||
57 | this.monthTarget = monthTarget; | ||
58 | this.monthValue = monthValue; | ||
59 | expression = "100 * ( "+monthValue+"/"+monthTarget+" )"; | ||
60 | this.monthWcBL = JSUtils.executeExpression(expression,"0.00"); | ||
61 | } | ||
62 | } |
-
请 注册 或 登录 后发表评论