b609ff3e 张雷

Merge remote-tracking branch 'origin/master' into master

2 个父辈 e8f72998 73d2b11a
1 package com.skua.modules.dataAnalysis.controller;
2
3 import com.skua.common.constant.ReportConstant;
4 import com.skua.common.report.ReportViewUtil;
5 import com.skua.core.api.vo.Result;
6 import com.skua.core.context.SpringContextUtils;
7 import com.skua.modules.dataAnalysis.vo.WorkProgressVO;
8 import com.skua.tool.util.DateUtils;
9 import com.skua.tool.util.JSUtils;
10 import io.swagger.annotations.Api;
11 import io.swagger.annotations.ApiOperation;
12 import lombok.extern.slf4j.Slf4j;
13 import org.apache.commons.lang.StringUtils;
14 import org.springframework.jdbc.core.BeanPropertyRowMapper;
15 import org.springframework.jdbc.core.JdbcTemplate;
16 import org.springframework.web.bind.annotation.GetMapping;
17 import org.springframework.web.bind.annotation.RequestMapping;
18 import org.springframework.web.bind.annotation.RequestParam;
19 import org.springframework.web.bind.annotation.RestController;
20 import java.util.List;
21
22 /**
23 * @auther kangwei
24 * @create 2025-01-23-17:01
25 */
26 @Slf4j
27 @Api(tags="运营工作进度统计")
28 @RestController
29 @RequestMapping("/v1/dataAnalysis/work")
30 public class WorkAnalysisController {
31
32
33 @ApiOperation(value = "工作进度统计", notes = "工作进度统计 timeType = 1 表示月份,timeType=2 表示年")
34 @GetMapping("/analysisByWorkProgress")
35 public Result<List<WorkProgressVO>> analysisByWorkProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) {
36 Result<List<WorkProgressVO>> result = new Result<>();
37 String month = DateUtils.formatDate(startTime,"YYYY-MM");
38 if(2 == timeType){//表示年
39 month = DateUtils.formatDate(startTime,"YYYY");
40 }
41 String departIds = null;//DAY(LAST_DAY('"+startTime+"'))
42 String sql = "select d.id 'depart_id' , d.depart_name , (DATEDIFF('"+endTime+"', '"+startTime+"') +1) 'day_num' , (month('"+endTime+"') - month('"+startTime+"') + 1) month_num,ifnull(aaa.count,0) 'nh_num' ,ifnull(bbb.count,0) 'szsl_num' ,ifnull(ccc.count,0) 'hy_num' ,ifnull(ddd.count,0) 'yy_month_num',ifnull(fff.count,0) 'df_month_num' ,ifnull(ggg.count,0) 'year_target_num' from sys_depart d ";
43 sql += getSql(departIds, startTime, endTime, month);
44 sql += " where d.depart_type =1 ";
45 if(StringUtils.isNotEmpty(departIds)){
46 sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")";
47 }
48 sql += " order by (ifnull(aaa.count,0) + ifnull(bbb.count,0)+ifnull(ccc.count,0) +ifnull(ddd.count,0)+ifnull(fff.count,0) +ifnull(ggg.count,0) ) asc ";
49
50 System.out.println("sql = "+sql);
51 JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
52 List<WorkProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<WorkProgressVO>(WorkProgressVO.class));
53 result.setResult(dataList);
54 result.setSuccess(true);
55 return result;
56 }
57
58 @ApiOperation(value = "工作进度统计-数量", notes = "工作进度统计 timeType = 1 表示月份,timeType=2 表示年")
59 @GetMapping("/analysisTotalByWorkProgress")
60 public Result<WorkProgressVO> analysisTotalByWorkProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) {
61 Result<WorkProgressVO> result = new Result<>();
62 WorkProgressVO workProgressVO = null;
63 String month = DateUtils.formatDate(startTime,"YYYY-MM");
64 if(2 == timeType){//表示年
65 month = DateUtils.formatDate(startTime,"YYYY");
66 }
67 String departIds = null;//DAY(LAST_DAY('"+startTime+"'))
68 String sql = "select count(d.id) 'departNum', (DATEDIFF('"+endTime+"', '"+startTime+"') +1) 'day_num' , (month('"+endTime+"') - month('"+startTime+"') + 1) month_num,";
69 sql += " ifnull(sum(aaa.count),0) 'nh_num' ,ifnull(sum(bbb.count),0) 'szsl_num' ,ifnull(sum(ccc.count),0) 'hy_num' ,ifnull(sum(ddd.count),0) 'yy_month_num',ifnull(sum(fff.count),0) 'df_month_num' ,ifnull(sum(ggg.count),0) 'year_target_num' ";
70 sql += " from sys_depart d ";
71 sql += getSql(departIds, startTime, endTime, month);
72 sql += " where d.depart_type =1 ";
73 if(StringUtils.isNotEmpty(departIds)){
74 sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")";
75 }
76 System.out.println("sql = "+sql);
77 JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
78 List<WorkProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<WorkProgressVO>(WorkProgressVO.class));
79 if(dataList != null && !dataList.isEmpty()){
80 workProgressVO = dataList.get(0);
81 }
82 result.setResult(workProgressVO);
83 result.setSuccess(true);
84 return result;
85 }
86 private String getSql( String departIds,String startTime, String endTime,String month){
87 String sql = "";
88 //能耗日报
89 String view3a24Sql = ReportViewUtil.buildView(ReportConstant.view3a24,"DLHJ",departIds,startTime,endTime);
90 sql += " left join (select aa.depart_id ,count(1) 'count' from "+view3a24Sql+ " aa group by aa.depart_id )aaa on aaa.depart_id = d.id ";
91 //水质水量日报表
92 String view2119Sql = ReportViewUtil.buildView(ReportConstant.view2119,"CSL",departIds,startTime,endTime);
93 sql += " left join ( select bb.depart_id ,count(1) 'count' from "+view2119Sql+ " bb group by bb.depart_id )bbb on bbb.depart_id = d.id ";
94
95 //化验日报
96 String viewbffaSql = ReportViewUtil.buildView(ReportConstant.view9bff,"JSCODHY",departIds,startTime,endTime);
97 sql += " left join (select cc.depart_id ,count(1) 'count' from "+viewbffaSql+ " cc group by cc.depart_id )ccc on ccc.depart_id = d.id ";
98
99 //电费月报
100 sql += " left join( select ec.depart_id , ec.cost , count(1) 'count' from report_electric_cost ec where ec.month like '"+month+"%' group by ec.depart_id) ddd on ddd.depart_id = d.id ";
101
102 //生产运营月报表
103 String view4411Sql = ReportViewUtil.buildView(ReportConstant.view4411,"yyf,ysfsl",departIds,startTime,endTime);
104 sql += " left join (select eee.depart_id ,count(1) 'count' from (select left(ee.time,7) time , ee.depart_id from "+view4411Sql+ " ee where 1=1 group by ee.depart_id ,left(ee.time,7) HAVING ifnull(sum(ee.yyf),0) >0 and ifnull(sum(ee.ysfsl),0) > 0 )eee group by eee.depart_id )fff on fff.depart_id = d.id ";
105
106 //目标年报
107 sql += " left join(select depart_id ,count(depart_id) 'count' from report_target_config where target_year = year('"+startTime+"') group by depart_id) ggg on ggg.depart_id = d.id ";
108
109 return sql;
110 }
111
112 }
1 package com.skua.modules.dataAnalysis.vo;
2
3
4 /**
5 * @auther kangwei
6 * @create 2025-01-23-9:24
7 */
8 import io.swagger.annotations.ApiModel;
9 import io.swagger.annotations.ApiModelProperty;
10 import lombok.Data;
11 /**
12 * 工作进度
13 */
14 @Data
15 @ApiModel(value = "WorkProgressVO工作进度", description = "工作进度")
16 public class WorkProgressVO {
17
18 @ApiModelProperty(value = "所属厂站")
19 private String departId;
20 @ApiModelProperty(value = "所属厂站")
21 private String departName;
22
23 @ApiModelProperty(value = "所属厂站-数量")
24 private String departNum;
25 @ApiModelProperty(value = "日数量(天)")
26 private Integer dayNum = 30;
27 @ApiModelProperty(value = "月数量(月)")
28 private Integer monthNum =1;
29 @ApiModelProperty(value = "年数量(年)")
30 private Integer yearNum = 1;
31 @ApiModelProperty(value = "能耗-填报天数")
32 private Integer nhNum;
33 @ApiModelProperty(value = "水质水量-填报天数")
34 private Integer szslNum;
35 @ApiModelProperty(value = "化验报表-填报天数")
36 private Integer hyNum;
37 @ApiModelProperty(value = "运营月报-填报月数")
38 private Integer yyMonthNum;
39 @ApiModelProperty(value = "电费月报-填报月数")
40 private Integer dfMonthNum;
41 @ApiModelProperty(value = "年度目标表-填报年数")
42 private Integer yearTargetNum;
43
44 @ApiModelProperty(value = "是否完成: 0 未完成 1 已完成")
45 private Integer completeFlag ;
46
47 public Integer getCompleteFlag() {
48 completeFlag = 0;
49 if((nhNum +szslNum +hyNum) >=(dayNum*3) && (yyMonthNum +dfMonthNum) >=(monthNum*2) && yearTargetNum >=yearNum){
50 completeFlag = 1;
51 }
52 return completeFlag;
53 }
54 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!