kangwei: 运营工作进度统计--安全管理进度统计
正在显示
2 个修改的文件
包含
113 行增加
和
3 行删除
... | @@ -4,6 +4,7 @@ import com.skua.common.constant.ReportConstant; | ... | @@ -4,6 +4,7 @@ import com.skua.common.constant.ReportConstant; |
4 | import com.skua.common.report.ReportViewUtil; | 4 | import com.skua.common.report.ReportViewUtil; |
5 | import com.skua.core.api.vo.Result; | 5 | import com.skua.core.api.vo.Result; |
6 | import com.skua.core.context.SpringContextUtils; | 6 | import com.skua.core.context.SpringContextUtils; |
7 | import com.skua.modules.dataAnalysis.vo.SafeProgressVO; | ||
7 | import com.skua.modules.dataAnalysis.vo.WorkProgressVO; | 8 | import com.skua.modules.dataAnalysis.vo.WorkProgressVO; |
8 | import com.skua.tool.util.DateUtils; | 9 | import com.skua.tool.util.DateUtils; |
9 | import com.skua.tool.util.JSUtils; | 10 | import com.skua.tool.util.JSUtils; |
... | @@ -40,7 +41,7 @@ public class WorkAnalysisController { | ... | @@ -40,7 +41,7 @@ public class WorkAnalysisController { |
40 | } | 41 | } |
41 | String departIds = null;//DAY(LAST_DAY('"+startTime+"')) | 42 | 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 | 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 += getWorkProgressSql(departIds, startTime, endTime, month); |
44 | sql += " where d.depart_type =1 "; | 45 | sql += " where d.depart_type =1 "; |
45 | if(StringUtils.isNotEmpty(departIds)){ | 46 | if(StringUtils.isNotEmpty(departIds)){ |
46 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; | 47 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; |
... | @@ -68,7 +69,7 @@ public class WorkAnalysisController { | ... | @@ -68,7 +69,7 @@ public class WorkAnalysisController { |
68 | String sql = "select count(d.id) 'departNum', (DATEDIFF('"+endTime+"', '"+startTime+"') +1) 'day_num' , (month('"+endTime+"') - month('"+startTime+"') + 1) month_num,"; | 69 | 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 += " 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 += " from sys_depart d "; |
71 | sql += getSql(departIds, startTime, endTime, month); | 72 | sql += getWorkProgressSql(departIds, startTime, endTime, month); |
72 | sql += " where d.depart_type =1 "; | 73 | sql += " where d.depart_type =1 "; |
73 | if(StringUtils.isNotEmpty(departIds)){ | 74 | if(StringUtils.isNotEmpty(departIds)){ |
74 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; | 75 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; |
... | @@ -83,7 +84,67 @@ public class WorkAnalysisController { | ... | @@ -83,7 +84,67 @@ public class WorkAnalysisController { |
83 | result.setSuccess(true); | 84 | result.setSuccess(true); |
84 | return result; | 85 | return result; |
85 | } | 86 | } |
86 | private String getSql( String departIds,String startTime, String endTime,String month){ | 87 | |
88 | |||
89 | @ApiOperation(value = "安全管理进度统计", notes = "安全管理进度统计 timeType = 1 表示月份,timeType=2 表示年") | ||
90 | @GetMapping("/analysisBySafeProgress") | ||
91 | public List<SafeProgressVO> analysisBySafeProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) { | ||
92 | JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
93 | String departIds = null; | ||
94 | |||
95 | String sql = "select d.id 'depart_id' , d.depart_name , ifnull(aaa.count,0) 'meet_num', ifnull(bbb.count,0) 'meet_total', ifnull(ccc.count,0) 'exam_num', ifnull(ddd.count,0) 'exam_total',ifnull(eee.count, 0) 'frequency_num' , ifnull(fff.count , 0) 'frequency_total'"; | ||
96 | sql += " from sys_depart d "; | ||
97 | sql += getSafeProgressSql(departIds, startTime,endTime); | ||
98 | sql += " where d.depart_type =1 "; | ||
99 | if(StringUtils.isNotEmpty(departIds)){ | ||
100 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; | ||
101 | } | ||
102 | sql += " order by (ifnull(aaa.count,0) + ifnull(bbb.count,0) + ifnull(ccc.count,0) + ifnull(ddd.count,0) + ifnull(fff.count,0) ) asc "; | ||
103 | System.out.println("sql = "+sql); | ||
104 | List<SafeProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<SafeProgressVO>(SafeProgressVO.class)); | ||
105 | |||
106 | return dataList; | ||
107 | } | ||
108 | @ApiOperation(value = "安全管理进度统计-数量", notes = "安全管理进度统计 timeType = 1 表示月份,timeType=2 表示年") | ||
109 | @GetMapping("/analysisTotalBySafeProgress") | ||
110 | public SafeProgressVO analysisTotalBySafeProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) { | ||
111 | String departIds = null;//DAY(LAST_DAY('"+startTime+"')) | ||
112 | String sql = "select count(d.id) 'departNum', ifnull(sum(aaa.count),0) 'meet_num' ,ifnull(sum(bbb.count),0) 'meet_total' ,ifnull(sum(ccc.count),0) 'exam_num' ,ifnull(sum(ddd.count),0) 'exam_total',ifnull(sum(eee.count),0) 'frequency_num' ,ifnull(sum(fff.count),0) 'frequency_total' "; | ||
113 | sql += " from sys_depart d "; | ||
114 | sql += getSafeProgressSql(departIds, startTime,endTime); | ||
115 | sql += " where d.depart_type =1 "; | ||
116 | if(StringUtils.isNotEmpty(departIds)){ | ||
117 | sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")"; | ||
118 | } | ||
119 | System.out.println("sql = "+sql); | ||
120 | JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
121 | List<SafeProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<SafeProgressVO>(SafeProgressVO.class)); | ||
122 | if(dataList != null && !dataList.isEmpty()){ | ||
123 | return dataList.get(0); | ||
124 | } | ||
125 | return null; | ||
126 | } | ||
127 | private String getSafeProgressSql( String departIds,String startTime, String endTime){ | ||
128 | JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
129 | String userIdsSql = "select GROUP_CONCAT( DISTINCT exam_user_ids) 'user_ids' from edu_paper where end_time >='"+startTime+"' and end_time <= '"+endTime+"'"; | ||
130 | String userIds = jdbcTemplate.queryForObject(userIdsSql , String.class); | ||
131 | if(StringUtils.isNotEmpty(userIds)){ | ||
132 | userIds = JSUtils.quoteEach(userIds,","); | ||
133 | }else{ | ||
134 | userIds = "''"; | ||
135 | } | ||
136 | String sql = ""; | ||
137 | sql += " left join( select depart_id , count(1) 'count' from ajh_meeting_send where meet_status =2 and meet_end_time >='"+startTime+"' and meet_end_time <= '"+endTime+"' group by depart_id )aaa on aaa.depart_id = d.id "; | ||
138 | sql += " left join (select depart_id , count(1) 'count' from ajh_meeting_send where meet_id in (select id from ajh_meeting where end_time >='"+startTime+"' and end_time <= '"+endTime+"') group by depart_id ) bbb on bbb.depart_id = d.id "; | ||
139 | sql += " left join (select depart_id,count(user_id) 'count' from edu_user_paper where DATE_FORMAT(end_time,'%Y-%m-%d') >='"+startTime+"' and end_time <= '"+endTime+"' and user_id in("+userIds+") group by depart_id )ccc on ccc.depart_id = d.id"; | ||
140 | sql += " left join ( select dep_id,count(user_id) 'count' from sys_user_depart where user_id in("+userIds+") group by dep_id )ddd on ddd.dep_id = d.id"; | ||
141 | sql += " left join ( select depart_id ,count(id) 'count' from danger_inspection_record where status = '2' and end_date >= '"+startTime+" 00:00:00' and end_date <='"+endTime+" 23:59:59' group by depart_id ) eee on eee.depart_id = d.id "; | ||
142 | sql += " left join( select sum( (DATEDIFF('"+endTime+"', '"+startTime+"') +1)*24/ dlm.frequency ) 'count' , dlm.depart_id from danger_level_manage dlm where dlm.frequency IS NOT NULL and frequency <> '' ) fff on fff.depart_id = d.id "; | ||
143 | |||
144 | return sql ; | ||
145 | } | ||
146 | |||
147 | private String getWorkProgressSql( String departIds,String startTime, String endTime,String month){ | ||
87 | String sql = ""; | 148 | String sql = ""; |
88 | //能耗日报 | 149 | //能耗日报 |
89 | String view3a24Sql = ReportViewUtil.buildView(ReportConstant.view3a24,"DLHJ",departIds,startTime,endTime); | 150 | String view3a24Sql = ReportViewUtil.buildView(ReportConstant.view3a24,"DLHJ",departIds,startTime,endTime); | ... | ... |
1 | package com.skua.modules.dataAnalysis.vo; | ||
2 | |||
3 | /** | ||
4 | * @auther kangwei | ||
5 | * @create 2025-01-23-9:24 | ||
6 | */ | ||
7 | import io.swagger.annotations.ApiModel; | ||
8 | import io.swagger.annotations.ApiModelProperty; | ||
9 | import lombok.Data; | ||
10 | |||
11 | /** | ||
12 | * 工作进度 | ||
13 | */ | ||
14 | @Data | ||
15 | @ApiModel(value = "SafeProgressVO安全管理进度", description = "安全管理进度") | ||
16 | public class SafeProgressVO { | ||
17 | |||
18 | @ApiModelProperty(value = "所属厂站") | ||
19 | private String departId; | ||
20 | @ApiModelProperty(value = "所属厂站") | ||
21 | private String departName; | ||
22 | |||
23 | @ApiModelProperty(value = "所属厂站-数量") | ||
24 | private String departNum; | ||
25 | |||
26 | @ApiModelProperty(value = "会议任务--完成数量") | ||
27 | private Integer meetNum; | ||
28 | @ApiModelProperty(value = "会议任务--计划总数") | ||
29 | private Integer meetTotal; | ||
30 | @ApiModelProperty(value = "考试任务-完成数量") | ||
31 | private Integer examNum; | ||
32 | @ApiModelProperty(value = "考试任务-计划总数") | ||
33 | private Integer examTotal; | ||
34 | @ApiModelProperty(value = "巡检任务-完成数量") | ||
35 | private Integer frequencyNum; | ||
36 | @ApiModelProperty(value = "巡检任务-计划总数") | ||
37 | private Integer frequencyTotal; | ||
38 | |||
39 | @ApiModelProperty(value = "是否完成: 0 未完成 1 已完成") | ||
40 | private Integer completeFlag ; | ||
41 | |||
42 | public Integer getCompleteFlag() { | ||
43 | completeFlag = 0; | ||
44 | if((meetNum >= meetTotal) && (examNum >= examTotal) && (frequencyNum >= frequencyTotal)){ | ||
45 | completeFlag = 1; | ||
46 | } | ||
47 | return completeFlag; | ||
48 | } | ||
49 | } |
-
请 注册 或 登录 后发表评论