运营月报
正在显示
3 个修改的文件
包含
245 行增加
和
12 行删除
1 | package com.skua.modules.report.controller; | 1 | package com.skua.modules.report.controller; |
2 | 2 | ||
3 | 3 | ||
4 | import com.skua.aop.annotation.CustomExceptionAnno; | ||
4 | import com.skua.core.api.vo.Result; | 5 | import com.skua.core.api.vo.Result; |
5 | import com.skua.core.aspect.annotation.AutoLog; | 6 | import com.skua.core.aspect.annotation.AutoLog; |
6 | import com.skua.core.context.BaseContextHandler; | 7 | import com.skua.core.context.BaseContextHandler; |
8 | import com.skua.core.util.ConvertUtils; | ||
9 | import com.skua.modules.biz.IBusinessService; | ||
7 | import com.skua.modules.custom.service.IFCustomReportDatasetService; | 10 | import com.skua.modules.custom.service.IFCustomReportDatasetService; |
8 | import com.skua.modules.report.service.IOperationReportService; | 11 | import com.skua.modules.report.service.IOperationReportService; |
9 | import com.skua.modules.report.vo.JnhbReportData; | 12 | import com.skua.modules.report.vo.JnhbReportData; |
10 | import com.skua.modules.report.vo.ProductDataVO; | 13 | import com.skua.modules.report.vo.ProductDataVO; |
14 | import com.skua.modules.system.service.ISysDepartService; | ||
11 | import io.swagger.annotations.Api; | 15 | import io.swagger.annotations.Api; |
12 | import io.swagger.annotations.ApiOperation; | 16 | import io.swagger.annotations.ApiOperation; |
13 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
... | @@ -18,7 +22,10 @@ import org.springframework.web.bind.annotation.RequestParam; | ... | @@ -18,7 +22,10 @@ import org.springframework.web.bind.annotation.RequestParam; |
18 | import org.springframework.web.bind.annotation.RestController; | 22 | import org.springframework.web.bind.annotation.RestController; |
19 | 23 | ||
20 | import javax.servlet.http.HttpServletRequest; | 24 | import javax.servlet.http.HttpServletRequest; |
25 | import java.util.ArrayList; | ||
26 | import java.util.HashMap; | ||
21 | import java.util.List; | 27 | import java.util.List; |
28 | import java.util.Map; | ||
22 | 29 | ||
23 | @Slf4j | 30 | @Slf4j |
24 | @Api(tags = "数据接口") | 31 | @Api(tags = "数据接口") |
... | @@ -28,6 +35,12 @@ public class OperationReportController { | ... | @@ -28,6 +35,12 @@ public class OperationReportController { |
28 | 35 | ||
29 | @Autowired | 36 | @Autowired |
30 | private IOperationReportService operationReportService; | 37 | private IOperationReportService operationReportService; |
38 | |||
39 | @Autowired | ||
40 | private ISysDepartService departService; | ||
41 | @Autowired | ||
42 | private IBusinessService businessService; | ||
43 | |||
31 | /** | 44 | /** |
32 | * 功能描述: 运营日报进出水初始化 | 45 | * 功能描述: 运营日报进出水初始化 |
33 | */ | 46 | */ |
... | @@ -47,4 +60,31 @@ public class OperationReportController { | ... | @@ -47,4 +60,31 @@ public class OperationReportController { |
47 | return result; | 60 | return result; |
48 | } | 61 | } |
49 | 62 | ||
63 | @GetMapping(value = "/operationMonthReport") | ||
64 | @CustomExceptionAnno(description = "报表:运营月报") | ||
65 | public Result<Object> operationMonthReportCtrl(@RequestParam Map<String,Object> paramsMap) { | ||
66 | // 请求参数 | ||
67 | String departId = ConvertUtils.getString(paramsMap.get("departId")); | ||
68 | String startTime = ConvertUtils.getString(paramsMap.get("startTime")); | ||
69 | String endTime = ConvertUtils.getString(paramsMap.get("endTime")); | ||
70 | String[] departIdArray = departId.split(","); | ||
71 | // 翻译 | ||
72 | Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null); | ||
73 | // 封装结果集 | ||
74 | List<Map<String, Object>> resMapList = new ArrayList<>(); | ||
75 | for (String tmpDepartId : departIdArray) { | ||
76 | String childDepartId = departService.getChildDepartId(tmpDepartId); | ||
77 | // 获取机构子集 | ||
78 | Map<String, Object> paramMap = new HashMap<>(); | ||
79 | paramMap.put("startTime", startTime); | ||
80 | paramMap.put("endTime", endTime); | ||
81 | paramMap.put("departId", childDepartId); | ||
82 | Map<String, Object> resMap = operationReportService.dataAnalysisOfMonth(paramMap); | ||
83 | resMap.put("departId", tmpDepartId); | ||
84 | resMap.put("departName", sysDepartDictMap.get(tmpDepartId)); | ||
85 | resMapList.add(resMap); | ||
86 | } | ||
87 | return Result.ok(resMapList); | ||
88 | } | ||
89 | |||
50 | } | 90 | } | ... | ... |
... | @@ -17,5 +17,5 @@ public interface IOperationReportService { | ... | @@ -17,5 +17,5 @@ public interface IOperationReportService { |
17 | */ | 17 | */ |
18 | ProductDataVO handeReportMonthData(String departIds,Integer year, Integer season,String startDate,String endDate); | 18 | ProductDataVO handeReportMonthData(String departIds,Integer year, Integer season,String startDate,String endDate); |
19 | 19 | ||
20 | Map<String, String> dataAnalysisOfMonth(Map<String, Object> paramMap); | 20 | Map<String, Object> dataAnalysisOfMonth(Map<String, Object> paramMap); |
21 | } | 21 | } | ... | ... |
... | @@ -13,6 +13,7 @@ import com.skua.modules.biz.IBusinessService; | ... | @@ -13,6 +13,7 @@ import com.skua.modules.biz.IBusinessService; |
13 | import com.skua.modules.report.mapper.OperationReportMapper; | 13 | import com.skua.modules.report.mapper.OperationReportMapper; |
14 | import com.skua.modules.report.service.IOperationReportService; | 14 | import com.skua.modules.report.service.IOperationReportService; |
15 | import com.skua.modules.report.vo.*; | 15 | import com.skua.modules.report.vo.*; |
16 | import com.skua.tool.dfs.CaseWhen; | ||
16 | import com.skua.tool.util.DateUtils; | 17 | import com.skua.tool.util.DateUtils; |
17 | import com.skua.tool.util.DigitalUtils; | 18 | import com.skua.tool.util.DigitalUtils; |
18 | import com.skua.tool.util.JSUtils; | 19 | import com.skua.tool.util.JSUtils; |
... | @@ -220,25 +221,217 @@ public class OperationReportServiceImpl implements IOperationReportService { | ... | @@ -220,25 +221,217 @@ public class OperationReportServiceImpl implements IOperationReportService { |
220 | } | 221 | } |
221 | 222 | ||
222 | @Override | 223 | @Override |
223 | public Map<String, String> dataAnalysisOfMonth(Map<String, Object> paramMap) { | 224 | public Map<String, Object> dataAnalysisOfMonth(Map<String, Object> paramMap) { |
224 | // 请求参数 | 225 | // 请求参数 |
225 | String startTime = ConvertUtils.getString(paramMap.get("startTime")); | 226 | String startTime = ConvertUtils.getString(paramMap.get("startTime")); |
226 | String endTime = ConvertUtils.getString(paramMap.get("endTime")); | 227 | String endTime = ConvertUtils.getString(paramMap.get("endTime")); |
227 | List<String> timeList = DateUtils.intervalByDay(startTime, endTime, BusinessConstant.dateFormat.split("-")[0]); | 228 | List<String> timeList = DateUtils.intervalByDay(startTime, endTime, BusinessConstant.dateFormat.substring(0, 10)); |
229 | // 同比时间 | ||
230 | String[] timeArray = DateUtils.tbTime(startTime, endTime); | ||
231 | List<String> timeListTb = DateUtils.intervalByDay(timeArray[0], timeArray[1], BusinessConstant.dateFormat.substring(0, 10)); | ||
228 | String departId = ConvertUtils.getString(paramMap.get("departId")); | 232 | String departId = ConvertUtils.getString(paramMap.get("departId")); |
229 | List<String> departIdList = Arrays.asList(departId.split(",")); | 233 | List<String> departIdList = Arrays.asList(departId.split(",")); |
230 | List<String> codeList = new ArrayList<String>(){{ | 234 | // 翻译 |
231 | // 污水(万吨) 水质水量日数据报表-出水量 | 235 | Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", departIdList); |
232 | add(""); | 236 | Map<String, String[]> dictMap0 = new LinkedHashMap<String, String[]>(){{ |
237 | // 污水水量 | ||
238 | put("1816743130490388481", new String[]{"wssl", "10"}); | ||
239 | // 收费水量 | ||
240 | put("1818936220739293185", new String[]{"sfsl", "7"}); | ||
241 | // 生产供水量 | ||
242 | put("1818218432697643010", new String[]{"scgsl", "10"}); | ||
243 | // 污泥处置量 | ||
244 | put("1910571063704104961", new String[]{"wnczl", "7"}); | ||
245 | // 实际水费 | ||
246 | put("1912415992428384257", new String[]{"sjsf", "7"}); | ||
247 | // 实际水量 | ||
248 | put("1818936221372633089", new String[]{"sjsl", "7"}); | ||
249 | // 实际药费 | ||
250 | put("1818936218910576642", new String[]{"sjyf", "7"}); | ||
251 | // 实际电耗 | ||
252 | put("1818936219699105793", new String[]{"sjdh", "7"}); | ||
253 | // 实际药耗 | ||
254 | put("1818936218491146241", new String[]{"sjyh", "7"}); | ||
233 | }}; | 255 | }}; |
256 | CaseWhen caseWhen0 = new CaseWhen(); | ||
257 | for (Map.Entry<String, String[]> entry: dictMap0.entrySet()) { | ||
258 | String reitId = entry.getKey(); | ||
259 | String alias = entry.getValue()[0]; | ||
260 | int timeLength = Integer.parseInt(entry.getValue()[1]); | ||
261 | caseWhen0.selectCaseWhen("reit_id = '" + reitId + "' and data_time >= '" + startTime.substring(0, timeLength) + "' and data_time <= '" + endTime.substring(0, timeLength) + "'", "item_value", "0", alias); | ||
262 | caseWhen0.selectCaseWhen("reit_id = '" + reitId + "' and data_time >= '" + timeArray[0].substring(0, timeLength) + "' and data_time <= '" + timeArray[1].substring(0, timeLength) + "'", "item_value", "0", "tb_" + alias); | ||
263 | } | ||
234 | QueryWrapper<?> queryWrapper0 = new QueryWrapper<>(); | 264 | QueryWrapper<?> queryWrapper0 = new QueryWrapper<>(); |
235 | queryWrapper0.in("", codeList) | 265 | queryWrapper0.in("reit_id", dictMap0.keySet()) |
236 | .ge("", startTime) | 266 | .in("depart_id", departIdList); |
237 | .le("", endTime) | 267 | Map<String, Object> queryMap0 = baseService.queryForMap("select " + caseWhen0.print() + " from f_report_itemv", queryWrapper0); |
238 | .groupBy("f_report_itemv.depart_id"); | 268 | // 年度目标 |
239 | List<Map<String, Object>> queryMapList0 = baseService.queryForList("", queryWrapper0); | 269 | Map<String, String> dictMap1 = new LinkedHashMap<String, String>(){{ |
270 | // 目标水量 | ||
271 | put("target_water", "mbsl"); | ||
272 | // 目标水费 | ||
273 | put("target_cost", "mbsf"); | ||
274 | // 目标电费 | ||
275 | put("target_power_cost", "mbdf"); | ||
276 | // 目标药费 | ||
277 | put("target_drug * target_water", "mbyf"); | ||
278 | // 目标电耗 | ||
279 | put("target_power", "mbdh"); | ||
280 | // 目标药耗 | ||
281 | put("target_drug", "mbyh"); | ||
282 | }}; | ||
283 | QueryWrapper<?> queryWrapper1 = new QueryWrapper<>(); | ||
284 | queryWrapper1.in("depart_id", departIdList); | ||
285 | CaseWhen caseWhen1 = new CaseWhen(); | ||
286 | for (Map.Entry<String, String> entry: dictMap1.entrySet()) { | ||
287 | caseWhen1.selectCaseWhen("target_year = '" + endTime.substring(0, 4) + "'", entry.getKey(), "0", entry.getValue()); | ||
288 | caseWhen1.selectCaseWhen("target_year = '" + timeArray[1].substring(0, 4) + "'", entry.getKey(), "0", "tb_" + entry.getValue()); | ||
289 | } | ||
290 | Map<String, Object> queryMap1 = baseService.queryForMap("select " + caseWhen1.print() + " from report_target_config", queryWrapper1); | ||
291 | // 实际电费信息 | ||
292 | Map<String, String> dictMap2 = new LinkedHashMap<String, String>(){{ | ||
293 | // 实际电费 | ||
294 | put("cost", "sjdf"); | ||
295 | }}; | ||
296 | QueryWrapper<?> queryWrapper2 = new QueryWrapper<>(); | ||
297 | queryWrapper2.in("depart_id", departIdList); | ||
298 | CaseWhen caseWhen2 = new CaseWhen(); | ||
299 | for (Map.Entry<String, String> entry: dictMap2.entrySet()) { | ||
300 | caseWhen2.selectCaseWhen("month >= '" + startTime.substring(0, 7) + "' and month <= '" + endTime.substring(0, 7) + "'", entry.getKey(), "0", entry.getValue()); | ||
301 | caseWhen2.selectCaseWhen("month >= '" + timeArray[0].substring(0, 7) + "' and month <= '" + timeArray[1].substring(0, 7) + "'", entry.getKey(), "0", "tb_" + entry.getValue()); | ||
302 | } | ||
303 | Map<String, Object> queryMap2 = baseService.queryForMap("select " + caseWhen2.print() + " from report_electric_cost", queryWrapper2); | ||
304 | // 详情信息 | ||
305 | QueryWrapper<?> queryWrapper3 = new QueryWrapper<>(); | ||
306 | queryWrapper3.in("aaa.depart_id", departIdList); | ||
307 | String reitIdStr = dictMap0.keySet().stream().map(key -> "'" + key + "'").collect(Collectors.joining(",")); | ||
308 | String departIdStr = departIdList.stream().map(key -> "'" + key + "'").collect(Collectors.joining(",")); | ||
309 | String sql0 = "(select depart_id, " + caseWhen0.print() + " from f_report_itemv where reit_id in (" + reitIdStr + ") and depart_id in (" + departIdStr + ") group by depart_id) as aaa"; | ||
310 | String sq1 = "(select depart_id, " + caseWhen1.print() + " from report_target_config where depart_id in (" + departIdStr + ") group by depart_id) as bbb"; | ||
311 | String sql2 = "(select depart_id, " + caseWhen2.print() + " from report_electric_cost where depart_id in (" + departIdStr + ") group by depart_id) as ccc"; | ||
312 | List<Map<String, Object>> queryMapList3 = baseService.queryForList("select aaa.*, bbb.*, ccc.* from " + sql0 + " left join " + sq1 + " on aaa.depart_id = bbb.depart_id left join " + sql2 + " on bbb.depart_id = ccc.depart_id", queryWrapper3); | ||
313 | // 详情-水费 | ||
314 | List<Map<String, Object>> sfwwcList = new ArrayList<>(); | ||
315 | List<Map<String, Object>> sfywcList = new ArrayList<>(); | ||
316 | List<Map<String, Object>> sjslxjList = new ArrayList<>(); | ||
317 | List<Map<String, Object>> dfcbList = new ArrayList<>(); | ||
318 | List<Map<String, Object>> yfcbList = new ArrayList<>(); | ||
319 | List<Map<String, Object>> dhcbList = new ArrayList<>(); | ||
320 | List<Map<String, Object>> yhcbList = new ArrayList<>(); | ||
321 | for (Map<String, Object> item: queryMapList3) { | ||
322 | String tmpDepartId = ConvertUtils.getString(item.get("depart_id")); | ||
323 | String tmpDepartName = sysDepartDictMap.get(tmpDepartId); | ||
324 | // 水费收入 未完成 | ||
325 | if (ConvertUtils.getDouble(item.get("sjsf"), 0D) / ConvertUtils.getDouble(item.get("mbsf"), 0D) < 0.25) { | ||
326 | sfwwcList.add(new LinkedHashMap<String, Object>(){{ | ||
327 | put("departId", tmpDepartId); | ||
328 | put("departName", tmpDepartName); | ||
329 | put("sjsf", item.get("sjsf")); | ||
330 | put("mbsf", item.get("mbsf")); | ||
331 | put("reason", ""); | ||
332 | }}); | ||
333 | } | ||
334 | // 水费已完成 | ||
335 | if (ConvertUtils.getDouble(item.get("sjsf"), 0D) >= ConvertUtils.getDouble(item.get("mbsf"), 0D)) { | ||
336 | sfywcList.add(new LinkedHashMap<String, Object>(){{ | ||
337 | put("departId", tmpDepartId); | ||
338 | put("departName", tmpDepartName); | ||
339 | put("sjsf", item.get("sjsf")); | ||
340 | put("mbsf", item.get("mbsf")); | ||
341 | }}); | ||
342 | } | ||
343 | // 实际水量同比下降 | ||
344 | if (ConvertUtils.getDouble(item.get("sjsl"), 0D) < ConvertUtils.getDouble(item.get("tb_sjsl"), 0D)) { | ||
345 | sjslxjList.add(new LinkedHashMap<String, Object>(){{ | ||
346 | put("departId", tmpDepartId); | ||
347 | put("departName", tmpDepartName); | ||
348 | put("sjsl", item.get("sjsl")); | ||
349 | put("tb_sjsl", item.get("tb_sjsl")); | ||
350 | put("reason", ""); | ||
351 | }}); | ||
352 | } | ||
353 | // 电费超标 | ||
354 | if (ConvertUtils.getDouble(item.get("sjdf"), 0D) > ConvertUtils.getDouble(item.get("mbdf"), 0D)) { | ||
355 | dfcbList.add(new LinkedHashMap<String, Object>(){{ | ||
356 | put("departId", tmpDepartId); | ||
357 | put("departName", tmpDepartName); | ||
358 | put("sjdf", item.get("sjdf")); | ||
359 | put("mbdf", item.get("mbdf")); | ||
360 | put("reason", ""); | ||
361 | }}); | ||
362 | } | ||
363 | // 药费超标 | ||
364 | if (ConvertUtils.getDouble(item.get("sjyf"), 0D) > ConvertUtils.getDouble(item.get("mbyf"), 0D)) { | ||
365 | yfcbList.add(new LinkedHashMap<String, Object>(){{ | ||
366 | put("departId", tmpDepartId); | ||
367 | put("departName", tmpDepartName); | ||
368 | put("sjyf", item.get("sjyf")); | ||
369 | put("mbyf", item.get("mbyf")); | ||
370 | put("reason", ""); | ||
371 | }}); | ||
372 | } | ||
373 | // 电耗超标 | ||
374 | if (ConvertUtils.getDouble(item.get("sjdh"), 0D) > ConvertUtils.getDouble(item.get("mbdh"), 0D)) { | ||
375 | dhcbList.add(new LinkedHashMap<String, Object>(){{ | ||
376 | put("departId", tmpDepartId); | ||
377 | put("departName", tmpDepartName); | ||
378 | put("sjdh", item.get("sjdh")); | ||
379 | put("mbdh", item.get("mbdh")); | ||
380 | put("reason", ""); | ||
381 | }}); | ||
382 | } | ||
383 | // 药耗超标 | ||
384 | if (ConvertUtils.getDouble(item.get("sjyh"), 0D) > ConvertUtils.getDouble(item.get("mbyh"), 0D)) { | ||
385 | yhcbList.add(new LinkedHashMap<String, Object>(){{ | ||
386 | put("departId", tmpDepartId); | ||
387 | put("departName", tmpDepartName); | ||
388 | put("sjyh", item.get("sjyh")); | ||
389 | put("mbyh", item.get("mbyh")); | ||
390 | put("reason", ""); | ||
391 | }}); | ||
392 | } | ||
393 | } | ||
394 | // 重点工作推进情况 | ||
395 | List<Map<String, Object>> priorityWorkItemList = new ArrayList<>(), hiddenDangerInspectionList = new ArrayList<>(); | ||
396 | QueryWrapper<?> queryWrapper10 = new QueryWrapper<>(); | ||
397 | queryWrapper10 | ||
398 | .in("issue_type", Arrays.asList("1", "2")) | ||
399 | .eq("status", "2") | ||
400 | .ge("end_time", startTime.substring(0, 10)) | ||
401 | .le("end_time", endTime.substring(0, 10)) | ||
402 | .in("depart_id", departIdList); | ||
403 | List<Map<String, Object>> queryMapList10 = baseService.queryForList("select * from f_major_issues_process", queryWrapper10); | ||
404 | queryMapList10.forEach(item -> { | ||
405 | String issueType = ConvertUtils.getString(item.get("issue_type")); | ||
406 | Map<String, Object> entityMap = item.keySet().stream().collect(Collectors.toMap(StrUtil::toCamelCase, key -> (item.get(key) == null ? "" : item.get(key)))); | ||
407 | entityMap.put("departName", sysDepartDictMap.get(item.get("depart_id"))); | ||
408 | if ("1".equals(issueType)) { | ||
409 | priorityWorkItemList.add(entityMap); | ||
410 | } else if ("2".equals(issueType)) { | ||
411 | hiddenDangerInspectionList.add(entityMap); | ||
412 | } | ||
413 | }); | ||
240 | // 封装结果集 | 414 | // 封装结果集 |
241 | Map<String, String> resMap = new LinkedHashMap<>(); | 415 | Map<String, Object> resMap = new LinkedHashMap<>(); |
416 | for (String key: queryMap0.keySet()) { | ||
417 | resMap.put(key, queryMap0.get(key)); | ||
418 | if (key.startsWith("tb_")) { | ||
419 | resMap.put(key + "_avg", ConvertUtils.getDouble(queryMap0.get(key), 0) / timeListTb.size()); | ||
420 | } else { | ||
421 | resMap.put(key + "_avg", ConvertUtils.getDouble(queryMap0.get(key), 0) / timeList.size()); | ||
422 | } | ||
423 | } | ||
424 | resMap.putAll(queryMap1); | ||
425 | resMap.putAll(queryMap2); | ||
426 | resMap.put("sfwwcList", sfwwcList); | ||
427 | resMap.put("sfywcList", sfywcList); | ||
428 | resMap.put("sjslxjList", sjslxjList); | ||
429 | resMap.put("dfcbList", dfcbList); | ||
430 | resMap.put("yfcbList", yfcbList); | ||
431 | resMap.put("dhcbList", dhcbList); | ||
432 | resMap.put("yhcbList", yhcbList); | ||
433 | resMap.put("priorityWorkItemList", priorityWorkItemList); | ||
434 | resMap.put("hiddenDangerInspectionList", hiddenDangerInspectionList); | ||
242 | return resMap; | 435 | return resMap; |
243 | } | 436 | } |
244 | 437 | ... | ... |
-
请 注册 或 登录 后发表评论