feat(equipment): 添加维保任务提醒定时 job
- 新增 TaskRemindJob 类实现人员任务提醒定时任务 - 添加维保任务查询和消息推送逻辑 -优化 EquipmentMaintainTaskMapper 接口,增加 getList 方法 -调整 NFDataSyncJob 中的 SQL 查询条件 - 移除 WorkAnalysisController 中的冗余代码
正在显示
11 个修改的文件
包含
201 行增加
和
108 行删除
... | @@ -312,31 +312,17 @@ public class WorkAnalysisController { | ... | @@ -312,31 +312,17 @@ public class WorkAnalysisController { |
312 | } | 312 | } |
313 | 313 | ||
314 | private String getSafeProgressSql( String departIds,String startTime, String endTime){ | 314 | private String getSafeProgressSql( String departIds,String startTime, String endTime){ |
315 | /* JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
316 | String userIdsSql = "select GROUP_CONCAT( DISTINCT exam_user_ids) 'user_ids' from edu_paper where end_time >='"+startTime+"' and end_time <= '"+endTime+"'"; | ||
317 | String userIds = jdbcTemplate.queryForObject(userIdsSql , String.class); | ||
318 | if(StringUtils.isNotEmpty(userIds)){ | ||
319 | userIds = JSUtils.quoteEach(userIds,","); | ||
320 | }else{ | ||
321 | userIds = "''"; | ||
322 | }*/ | ||
323 | String sql = ""; | 315 | String sql = ""; |
324 | //会议任务 | 316 | //会议任务 |
325 | sql += " left join( select depart_id , count(1) 'count' from ajh_meeting_send where meet_status =2 and meet_time >='"+startTime+"' and meet_time <= '"+endTime+"' group by depart_id )aaa on aaa.depart_id = d.id "; | 317 | sql += " left join( select depart_id , count(1) 'count' from ajh_meeting_send where meet_status =2 and meet_time >='"+startTime+"' and meet_time <= '"+endTime+"' group by depart_id )aaa on aaa.depart_id = d.id "; |
326 | sql += " left join (select depart_id , count(1) 'count' from ajh_meeting_send where meet_id in (select id from ajh_meeting where send_time >='"+startTime+"' and send_time <= '"+endTime+"') group by depart_id ) bbb on bbb.depart_id = d.id "; | 318 | sql += " left join (select depart_id , count(1) 'count' from ajh_meeting_send where meet_id in (select id from ajh_meeting where send_time >='"+startTime+"' and send_time <= '"+endTime+"') group by depart_id ) bbb on bbb.depart_id = d.id "; |
327 | // 考试任务 | 319 | // 考试任务 |
328 | // 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"; | 320 | sql += " left join (select depart_id ,count(id) 'count' from edu_paper_task where DATE_FORMAT(end_time,'%Y-%m-%d') >='"+startTime+"' and DATE_FORMAT(end_time,'%Y-%m-%d') <= '"+endTime+"' and status=1 group by depart_id )ccc on ccc.depart_id = d.id"; |
329 | // 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"; | 321 | sql += " left join ( select depart_id ,count(id) 'count' from edu_paper_task where DATE_FORMAT(create_time,'%Y-%m-%d') >='"+startTime+"' and DATE_FORMAT(end_time,'%Y-%m-%d') <= '"+endTime+"' group by depart_id ) ddd on ddd.depart_id = d.id"; |
330 | |||
331 | sql += " left join (select depart_id ,count(id) 'count' from edu_paper_task where DATE_FORMAT(end_time,'%Y-%m-%d') >='"+startTime+"' and DATE_FORMAT(end_time,'%Y-%m-%d') <= '"+endTime+"' and status=1 group by depart_id )ccc on ccc.depart_id = d.id"; | ||
332 | sql += " left join ( select depart_id ,count(id) 'count' from edu_paper_task where DATE_FORMAT(create_time,'%Y-%m-%d') >='"+startTime+"' and DATE_FORMAT(end_time,'%Y-%m-%d') <= '"+endTime+"' group by depart_id )ddd on ddd.dep_id = d.id"; | ||
333 | |||
334 | |||
335 | //风险排查任务 | 322 | //风险排查任务 |
336 | sql += " left join ( select depart_id ,count(id) 'count' from danger_inspection_record where status = '2' and report_date >= '"+startTime+" 00:00:00' and report_date <='"+endTime+" 23:59:59' group by depart_id ) eee on eee.depart_id = d.id "; | 323 | sql += " left join ( select depart_id ,count(id) 'count' from danger_inspection_record where status = '2' and report_date >= '"+startTime+" 00:00:00' and report_date <='"+endTime+" 23:59:59' group by depart_id ) eee on eee.depart_id = d.id "; |
337 | sql += " left join ( select depart_id ,count(id) 'count' from danger_inspection_record where report_date >= '"+startTime+" 00:00:00' and report_date <='"+endTime+" 23:59:59' group by depart_id ) ggg on ggg.depart_id = d.id "; | 324 | sql += " left join ( select depart_id ,count(id) 'count' from danger_inspection_record where report_date >= '"+startTime+" 00:00:00' and report_date <='"+endTime+" 23:59:59' group by depart_id ) ggg on ggg.depart_id = d.id "; |
338 | 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 "; | 325 | 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 "; |
339 | |||
340 | return sql ; | 326 | return sql ; |
341 | } | 327 | } |
342 | 328 | ... | ... |
... | @@ -32,7 +32,7 @@ public class NFDataSyncJob implements Job { | ... | @@ -32,7 +32,7 @@ public class NFDataSyncJob implements Job { |
32 | //供水指标 | 32 | //供水指标 |
33 | private static String gsFields = "GSL,YSSD,CCSWD,YSWD,CCSPH,YSPH,CCSAD,YSAD,CCSHYL,YSHYL,CCSSD," + | 33 | private static String gsFields = "GSL,YSSD,CCSWD,YSWD,CCSPH,YSPH,CCSAD,YSAD,CCSHYL,YSHYL,CCSSD," + |
34 | "YSNRDCGJQ,CCSRYHT,YSRYHT,CCSNRDCGJQ,CCSZDCGJQ,CCSJLZS,YSZDCGJQ,YSJLZS,CCSRYKJD,YSRYKJD,CCSCHW,YSCHW,CCSHZD,YSHZD"; | 34 | "YSNRDCGJQ,CCSRYHT,YSRYHT,CCSNRDCGJQ,CCSZDCGJQ,CCSJLZS,YSZDCGJQ,YSJLZS,CCSRYKJD,YSRYKJD,CCSCHW,YSCHW,CCSHZD,YSHZD"; |
35 | 35 | private static String nhFields = "DLHJ"; | |
36 | /** | 36 | /** |
37 | * 若参数变量名修改 QuartzJobController中也需对应修改 | 37 | * 若参数变量名修改 QuartzJobController中也需对应修改 |
38 | */ | 38 | */ |
... | @@ -51,7 +51,7 @@ public class NFDataSyncJob implements Job { | ... | @@ -51,7 +51,7 @@ public class NFDataSyncJob implements Job { |
51 | Map<String,String> nfData = nfDrugConvert(); | 51 | Map<String,String> nfData = nfDrugConvert(); |
52 | log.info("开始同步【"+yesterday+"】恩菲的数据入报表"); | 52 | log.info("开始同步【"+yesterday+"】恩菲的数据入报表"); |
53 | JdbcTemplate nfDb = (JdbcTemplate) SpringContextUtils.getBean("nf-db"); | 53 | JdbcTemplate nfDb = (JdbcTemplate) SpringContextUtils.getBean("nf-db"); |
54 | String sql = "select * from day_report_data where update_time like '"+yesterday+"%' and item_type = 'nhrb'"; | 54 | String sql = "select * from day_report_data where update_time like '"+yesterday+"%'"; |
55 | List<Map<String, Object>> dataList = nfDb.queryForList(sql); | 55 | List<Map<String, Object>> dataList = nfDb.queryForList(sql); |
56 | if(dataList.size() > 0){ | 56 | if(dataList.size() > 0){ |
57 | for (Map<String, Object> map : dataList) { | 57 | for (Map<String, Object> map : dataList) { |
... | @@ -76,6 +76,10 @@ public class NFDataSyncJob implements Job { | ... | @@ -76,6 +76,10 @@ public class NFDataSyncJob implements Job { |
76 | data.put(itemCode, itemValue); | 76 | data.put(itemCode, itemValue); |
77 | data.put("reportId", ReportConstant.view6643); | 77 | data.put("reportId", ReportConstant.view6643); |
78 | reportDataService.insertOrUpdateReportData(departId, time, data, ReportConstant.view6643); | 78 | reportDataService.insertOrUpdateReportData(departId, time, data, ReportConstant.view6643); |
79 | }else if(nhFields.contains(itemCode)){ | ||
80 | data.put(itemCode, itemValue); | ||
81 | data.put("reportId", ReportConstant.view3a24); | ||
82 | reportDataService.insertOrUpdateReportData(departId, time, data, ReportConstant.view3a24); | ||
79 | }else{ | 83 | }else{ |
80 | data.put(itemCode, itemValue); | 84 | data.put(itemCode, itemValue); |
81 | } | 85 | } | ... | ... |
sk-module-equipment/src/main/java/com/skua/modules/equipment/mapper/EquipmentMaintainTaskMapper.java
... | @@ -2,6 +2,7 @@ package com.skua.modules.equipment.mapper; | ... | @@ -2,6 +2,7 @@ package com.skua.modules.equipment.mapper; |
2 | 2 | ||
3 | import java.util.Date; | 3 | import java.util.Date; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | import java.util.Map; | ||
5 | 6 | ||
6 | import com.baomidou.mybatisplus.core.metadata.IPage; | 7 | import com.baomidou.mybatisplus.core.metadata.IPage; |
7 | import com.skua.modules.equipment.vo.*; | 8 | import com.skua.modules.equipment.vo.*; |
... | @@ -58,7 +59,8 @@ public interface EquipmentMaintainTaskMapper extends BaseMapper<EquipmentMaintai | ... | @@ -58,7 +59,8 @@ public interface EquipmentMaintainTaskMapper extends BaseMapper<EquipmentMaintai |
58 | 59 | ||
59 | Integer deleteMaintainTask(@Param("time") String time, @Param("id") String id); | 60 | Integer deleteMaintainTask(@Param("time") String time, @Param("id") String id); |
60 | 61 | ||
61 | Integer updateResultsEnforcement(@Param("nowDate") Date nowDate, @Param("afterResultsEnforcement") Integer afterResultsEnforcement, @Param("nowResultsEnforcement") Integer nowResultsEnforcement, @Param("id") String id); | 62 | Integer updateResultsEnforcement(@Param("nowDate") Date nowDate, @Param("afterResultsEnforcement") Integer afterResultsEnforcement, |
63 | @Param("nowResultsEnforcement") Integer nowResultsEnforcement, @Param("id") String id); | ||
62 | 64 | ||
63 | //新增每个任务对应维护内容的结果 | 65 | //新增每个任务对应维护内容的结果 |
64 | Integer addTaskResult(String id,String taskId,String standardId,String result); | 66 | Integer addTaskResult(String id,String taskId,String standardId,String result); |
... | @@ -77,5 +79,8 @@ public interface EquipmentMaintainTaskMapper extends BaseMapper<EquipmentMaintai | ... | @@ -77,5 +79,8 @@ public interface EquipmentMaintainTaskMapper extends BaseMapper<EquipmentMaintai |
77 | */ | 79 | */ |
78 | List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList(EquipmentMaintainTaskForm maintainTaskForm); | 80 | List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList(EquipmentMaintainTaskForm maintainTaskForm); |
79 | 81 | ||
80 | IPage<EquipmentMaintainTaskForm> queryMaintainTaskFormByPage(Page<EquipmentMaintainTaskForm> page, @Param("param") EquipmentMaintainTaskForm maintainTaskForm); | 82 | IPage<EquipmentMaintainTaskForm> queryMaintainTaskFormByPage(Page<EquipmentMaintainTaskForm> page, |
83 | @Param("param") EquipmentMaintainTaskForm maintainTaskForm); | ||
84 | |||
85 | List<Map<String, Object>> getList(@Param("startTime") String startTime, @Param("endTime") String endTime); | ||
81 | } | 86 | } | ... | ... |
... | @@ -56,7 +56,11 @@ | ... | @@ -56,7 +56,11 @@ |
56 | and emt.plan_id=#{equipmentMaintainTask.planId} | 56 | and emt.plan_id=#{equipmentMaintainTask.planId} |
57 | </if> | 57 | </if> |
58 | <if test="equipmentMaintainTask.departId !=null and equipmentMaintainTask.departId !=''"> | 58 | <if test="equipmentMaintainTask.departId !=null and equipmentMaintainTask.departId !=''"> |
59 | and emt. depart_id=#{equipmentMaintainTask.departId} | 59 | and emt.depart_id in |
60 | <foreach item="item" index="index" collection="equipmentMaintainTask.departId.split(',')" open="(" | ||
61 | separator="," close=")"> | ||
62 | '${item}' | ||
63 | </foreach> | ||
60 | </if> | 64 | </if> |
61 | <if test="equipmentMaintainTask.maintainPlanName !=null and equipmentMaintainTask.maintainPlanName !=''"> | 65 | <if test="equipmentMaintainTask.maintainPlanName !=null and equipmentMaintainTask.maintainPlanName !=''"> |
62 | and emt.maintain_plan_name like concat('%',#{equipmentMaintainTask.maintainPlanName},'%') | 66 | and emt.maintain_plan_name like concat('%',#{equipmentMaintainTask.maintainPlanName},'%') |
... | @@ -81,7 +85,7 @@ | ... | @@ -81,7 +85,7 @@ |
81 | and emt.results_enforcement=#{equipmentMaintainTask.resultsEnforcement} | 85 | and emt.results_enforcement=#{equipmentMaintainTask.resultsEnforcement} |
82 | </if> | 86 | </if> |
83 | <if test="equipmentMaintainTask.maintainTime !=null "> | 87 | <if test="equipmentMaintainTask.maintainTime !=null "> |
84 | and #{equipmentMaintainTask.maintainTime}>= emt. maintain_time | 88 | and #{equipmentMaintainTask.maintainTime}>= emt.maintain_time |
85 | </if> | 89 | </if> |
86 | <!-- <if test="equipmentMaintainTask.taskStartTime !=null and equipmentMaintainTask.taskStartTime !=''"> | 90 | <!-- <if test="equipmentMaintainTask.taskStartTime !=null and equipmentMaintainTask.taskStartTime !=''"> |
87 | and emt.maintain_time BETWEEN #{equipmentMaintainTask.taskStartTime} and | 91 | and emt.maintain_time BETWEEN #{equipmentMaintainTask.taskStartTime} and |
... | @@ -271,5 +275,8 @@ | ... | @@ -271,5 +275,8 @@ |
271 | 275 | ||
272 | order by aaa.end_time desc | 276 | order by aaa.end_time desc |
273 | </select> | 277 | </select> |
278 | <select id="getList" resultType="java.util.HashMap"> | ||
279 | |||
280 | </select> | ||
274 | 281 | ||
275 | </mapper> | 282 | </mapper> | ... | ... |
1 | package com.skua.modules.equipment.quartz; | ||
2 | |||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
4 | import com.google.common.collect.Lists; | ||
5 | import com.skua.core.util.push.MessageEntity; | ||
6 | import com.skua.modules.alarmtmp.entity.AlarmRecordHistory; | ||
7 | import com.skua.modules.equipment.entity.EquipmentMaintainTask; | ||
8 | import com.skua.modules.equipment.service.IEquipmentInfoService; | ||
9 | import com.skua.modules.equipment.service.IEquipmentMaintainTaskService; | ||
10 | import com.skua.modules.system.service.WebNoticePushServiceExt; | ||
11 | import lombok.extern.slf4j.Slf4j; | ||
12 | import org.quartz.Job; | ||
13 | import org.quartz.JobExecutionContext; | ||
14 | import org.quartz.JobExecutionException; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | ||
16 | import org.springframework.stereotype.Component; | ||
17 | |||
18 | import java.time.LocalDateTime; | ||
19 | import java.time.format.DateTimeFormatter; | ||
20 | import java.time.temporal.ChronoUnit; | ||
21 | import java.util.ArrayList; | ||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | |||
25 | /** | ||
26 | * @program: skboot | ||
27 | * @description: 人员任务提醒定时任务 | ||
28 | * @author: zhanglei | ||
29 | * @create: 2025/03/08 16:05:05 | ||
30 | */ | ||
31 | @Slf4j | ||
32 | @Component | ||
33 | public class TaskRemindJob implements Job { | ||
34 | |||
35 | @Autowired | ||
36 | private IEquipmentMaintainTaskService equipmentMaintainTaskService; | ||
37 | |||
38 | @Autowired | ||
39 | private WebNoticePushServiceExt webNoticePushServiceExt; | ||
40 | |||
41 | @Override | ||
42 | public void execute(JobExecutionContext context) throws JobExecutionException { | ||
43 | log.info("人员任务提醒定时任务开始"); | ||
44 | //当前时间 | ||
45 | LocalDateTime now = LocalDateTime.now(); | ||
46 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
47 | //一小时后时间 | ||
48 | LocalDateTime oneHourLater = now.plus(1, ChronoUnit.HOURS); | ||
49 | String startTime = now.format(formatter); | ||
50 | String endTime = oneHourLater.format(formatter); | ||
51 | startTime = "2025-04-07 00:00:00"; | ||
52 | endTime = "2025-04-08 23:59:59"; | ||
53 | List<Map<String, Object>> wbList = getWbList(startTime,endTime); | ||
54 | //推送维保消息 | ||
55 | pushWbMessage(wbList); | ||
56 | |||
57 | log.info("人员任务提醒定时任务结束"); | ||
58 | } | ||
59 | |||
60 | private boolean pushWbMessage(List<Map<String, Object>> wbList) { | ||
61 | for (Map<String, Object> wbMap : wbList) { | ||
62 | //获取用户列表后做消息推送 | ||
63 | MessageEntity messageEntity = new MessageEntity(); | ||
64 | messageEntity.setMessageTitle("流程审批消息"); | ||
65 | messageEntity.setMessageBody("您有一条【" + wbMap.get("taskName") + "】维保任务需要完成,请及时处理"); | ||
66 | messageEntity.setReceiveUser(null); | ||
67 | messageEntity.setReceiveUserCid(null); | ||
68 | messageEntity.setSendUser("系统"); | ||
69 | messageEntity.setForwardTag("maintain"); | ||
70 | webNoticePushServiceExt.pushMessage(messageEntity, "maintain", "M"); | ||
71 | } | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | //maintain_plan_name 计划名称' maintainer_id` 维保人 | ||
76 | private List<Map<String, Object>> getWbList(String startTime, String endTime) { | ||
77 | List<Map<String, Object>> list = new ArrayList<>(); | ||
78 | list = equipmentMaintainTaskService.getList(startTime, endTime); | ||
79 | return list; | ||
80 | } | ||
81 | |||
82 | |||
83 | } |
... | @@ -58,4 +58,5 @@ public interface IEquipmentMaintainTaskService extends IService<EquipmentMaintai | ... | @@ -58,4 +58,5 @@ public interface IEquipmentMaintainTaskService extends IService<EquipmentMaintai |
58 | */ | 58 | */ |
59 | List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList( EquipmentMaintainTaskForm maintainTaskForm); | 59 | List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList( EquipmentMaintainTaskForm maintainTaskForm); |
60 | 60 | ||
61 | List<Map<String, Object>> getList(String startTime, String endTime); | ||
61 | } | 62 | } | ... | ... |
... | @@ -8,6 +8,7 @@ import java.util.List; | ... | @@ -8,6 +8,7 @@ import java.util.List; |
8 | import java.util.UUID; | 8 | import java.util.UUID; |
9 | import java.util.stream.Collectors; | 9 | import java.util.stream.Collectors; |
10 | 10 | ||
11 | import com.skua.core.util.ConvertUtils; | ||
11 | import org.apache.commons.collections.CollectionUtils; | 12 | import org.apache.commons.collections.CollectionUtils; |
12 | import org.springframework.beans.BeanUtils; | 13 | import org.springframework.beans.BeanUtils; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
... | @@ -133,17 +134,27 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint | ... | @@ -133,17 +134,27 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint |
133 | 134 | ||
134 | @Override | 135 | @Override |
135 | public void release(EquipmentMaintainPlanDTO equipmentMaintainPlanDTO) throws Exception { | 136 | public void release(EquipmentMaintainPlanDTO equipmentMaintainPlanDTO) throws Exception { |
137 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
136 | //判断状态 | 138 | //判断状态 |
137 | EquipmentMaintainPlan equipmentMaintainPlan = equipmentMaintainPlanMapper.selectById(equipmentMaintainPlanDTO.getId()); | 139 | EquipmentMaintainPlan equipmentMaintainPlan = equipmentMaintainPlanMapper.selectById(equipmentMaintainPlanDTO.getId()); |
138 | if (null != equipmentMaintainPlan && equipmentMaintainPlanDTO.getReleaseStatus() == 0) { | 140 | if (null != equipmentMaintainPlan && equipmentMaintainPlanDTO.getReleaseStatus() == 0) { |
139 | //取消发布动作,保留已经开始的任务,删除未来没有开始的任务 | 141 | //取消发布动作,保留已经开始的任务,删除未来没有开始的任务 |
140 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
141 | String a = sdf.format(new Date())+" 00:00:00"; | 142 | String a = sdf.format(new Date())+" 00:00:00"; |
142 | equipmentMaintainTaskMapper.deleteMaintainTask(a, equipmentMaintainPlanDTO.getId()); | 143 | equipmentMaintainTaskMapper.deleteMaintainTask(a, equipmentMaintainPlanDTO.getId()); |
143 | } | 144 | } |
144 | if (equipmentMaintainPlanDTO.getReleaseStatus() == 1) { | 145 | if (equipmentMaintainPlanDTO.getReleaseStatus() == 1) { |
145 | |||
146 | String startTimeStr = DateUtils.format(equipmentMaintainPlan.getStartTime(), "yyyy-MM-dd"); | 146 | String startTimeStr = DateUtils.format(equipmentMaintainPlan.getStartTime(), "yyyy-MM-dd"); |
147 | Calendar calendar = Calendar.getInstance(); | ||
148 | calendar.set(Calendar.HOUR_OF_DAY, 0); | ||
149 | calendar.set(Calendar.MINUTE, 0); | ||
150 | calendar.set(Calendar.SECOND, 0); | ||
151 | calendar.set(Calendar.MILLISECOND, 0); | ||
152 | Date today = calendar.getTime(); | ||
153 | Date startTime = equipmentMaintainPlan.getStartTime(); | ||
154 | // 比较 startTime 是否大于当天零点 | ||
155 | if (!startTime.after(today)) { | ||
156 | startTimeStr = sdf.format(new Date())+" 00:00:00"; | ||
157 | } | ||
147 | String endTimeStr = DateUtils.format(equipmentMaintainPlan.getEndTime(), "yyyy-MM-dd")+" 00:00:00"; | 158 | String endTimeStr = DateUtils.format(equipmentMaintainPlan.getEndTime(), "yyyy-MM-dd")+" 00:00:00"; |
148 | //循环周期 | 159 | //循环周期 |
149 | int cycle = equipmentMaintainPlan.getCycle(); | 160 | int cycle = equipmentMaintainPlan.getCycle(); |
... | @@ -186,7 +197,6 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint | ... | @@ -186,7 +197,6 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint |
186 | } | 197 | } |
187 | } | 198 | } |
188 | 199 | ||
189 | |||
190 | //厂站 | 200 | //厂站 |
191 | List<EquipmentMaintainStandard> equipmentMaintainStandardByPlanId = equipmentMaintainPlanMapper.getEquipmentMaintainStandardByPlanId(equipmentMaintainPlan.getId()); | 201 | List<EquipmentMaintainStandard> equipmentMaintainStandardByPlanId = equipmentMaintainPlanMapper.getEquipmentMaintainStandardByPlanId(equipmentMaintainPlan.getId()); |
192 | List<String> collect = equipmentMaintainStandardByPlanId.stream().map(EquipmentMaintainStandard::getId).collect(Collectors.toList()); | 202 | List<String> collect = equipmentMaintainStandardByPlanId.stream().map(EquipmentMaintainStandard::getId).collect(Collectors.toList()); |
... | @@ -194,35 +204,54 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint | ... | @@ -194,35 +204,54 @@ public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaint |
194 | List<EquipmentInformationVO> equipmentInformationByPlanId = equipmentMaintainPlanMapper.getEquipmentInformationByPlanId(equipmentMaintainPlan.getId()); | 204 | List<EquipmentInformationVO> equipmentInformationByPlanId = equipmentMaintainPlanMapper.getEquipmentInformationByPlanId(equipmentMaintainPlan.getId()); |
195 | List<String> collect1 = equipmentInformationByPlanId.stream().map(EquipmentInformationVO::getId).collect(Collectors.toList()); | 205 | List<String> collect1 = equipmentInformationByPlanId.stream().map(EquipmentInformationVO::getId).collect(Collectors.toList()); |
196 | equipmentMaintainPlanDTO.setEquipmentIds(collect1); | 206 | equipmentMaintainPlanDTO.setEquipmentIds(collect1); |
197 | for (int m = 0; m < equipmentMaintainPlanDTO.getEquipmentIds().size(); m++) { | 207 | if(equipmentMaintainPlanDTO.getEquipmentIds().size()==0){ |
198 | if(timeList!=null&&timeList.size()<500) { | 208 | createTaskByTimeList(timeList,equipmentMaintainPlan,null,modeAndLevelByIds); |
199 | for(String time : timeList) { | 209 | }else{ |
200 | String[] timeArray = time.split("#"); | 210 | for (int m = 0; m < equipmentMaintainPlanDTO.getEquipmentIds().size(); m++) { |
201 | EquipmentMaintainTask equipmentMaintainTask = new EquipmentMaintainTask(); | 211 | createTaskByTimeList(timeList,equipmentMaintainPlan,equipmentMaintainPlanDTO.getEquipmentIds().get(m),modeAndLevelByIds); |
202 | equipmentMaintainTask.setEquipmentId(equipmentMaintainPlanDTO.getEquipmentIds().get(m)); | 212 | } |
203 | equipmentMaintainTask.setDepartId(equipmentMaintainPlan.getDepartId()); | 213 | } |
204 | equipmentMaintainTask.setMaintainPlanName(equipmentMaintainPlan.getPlanName()); | 214 | } |
215 | equipmentMaintainPlan.setReleaseStatus(equipmentMaintainPlanDTO.getReleaseStatus()); | ||
216 | equipmentMaintainPlanMapper.updateById(equipmentMaintainPlan); | ||
217 | } | ||
218 | |||
219 | //创建任务 | ||
220 | private void createTaskByTimeList(List<String> timeList,EquipmentMaintainPlan equipmentMaintainPlan,String equipmentId,EquipmentMaintainStandard modeAndLevelByIds) { | ||
221 | try{ | ||
222 | if(timeList!=null&&timeList.size()<500) { | ||
223 | for(String time : timeList) { | ||
224 | String[] timeArray = time.split("#"); | ||
225 | EquipmentMaintainTask equipmentMaintainTask = new EquipmentMaintainTask(); | ||
226 | equipmentMaintainTask.setEquipmentId(equipmentId); | ||
227 | equipmentMaintainTask.setDepartId(equipmentMaintainPlan.getDepartId()); | ||
228 | equipmentMaintainTask.setMaintainPlanName(equipmentMaintainPlan.getPlanName()); | ||
229 | if(ConvertUtils.isNotEmpty(modeAndLevelByIds)){ | ||
205 | equipmentMaintainTask.setMaintainMode(modeAndLevelByIds.getMaintenanceMode()); | 230 | equipmentMaintainTask.setMaintainMode(modeAndLevelByIds.getMaintenanceMode()); |
206 | equipmentMaintainTask.setMaintainLevel(modeAndLevelByIds.getMaintenanceLevel()); | 231 | equipmentMaintainTask.setMaintainLevel(modeAndLevelByIds.getMaintenanceLevel()); |
207 | equipmentMaintainTask.setResultsEnforcement(1); | 232 | }else{ |
208 | equipmentMaintainTask.setStartTime(DateUtils.parse(timeArray[0], "yyyy-MM-dd HH:mm:ss")); | 233 | equipmentMaintainTask.setMaintainMode(null); |
209 | equipmentMaintainTask.setEndTime(DateUtils.parse(timeArray[1], "yyyy-MM-dd HH:mm:ss")); | 234 | equipmentMaintainTask.setMaintainLevel(null); |
210 | equipmentMaintainTask.setDelFlag(0); | ||
211 | equipmentMaintainTask.setCreateTime(new Date()); | ||
212 | equipmentMaintainTask.setCreateBy(BaseContextHandler.getUserLoginName()); | ||
213 | equipmentMaintainTask.setResultsEnforcement(1); | ||
214 | equipmentMaintainTask.setPlanId(equipmentMaintainPlan.getId()); | ||
215 | //默认计划安排人作为维护负责人 | ||
216 | equipmentMaintainTask.setMaintainerId(equipmentMaintainPlan.getPlanArrangerId()); | ||
217 | //检验日期 | ||
218 | equipmentMaintainTask.setMaintainTime(DateUtils.parse(timeArray[0], "yyyy-MM-dd HH:mm:ss")); | ||
219 | equipmentMaintainTaskMapper.insert(equipmentMaintainTask); | ||
220 | } | 235 | } |
221 | } | 236 | equipmentMaintainTask.setResultsEnforcement(1); |
237 | equipmentMaintainTask.setStartTime(DateUtils.parse(timeArray[0], "yyyy-MM-dd HH:mm:ss")); | ||
238 | equipmentMaintainTask.setEndTime(DateUtils.parse(timeArray[1], "yyyy-MM-dd HH:mm:ss")); | ||
239 | equipmentMaintainTask.setDelFlag(0); | ||
240 | equipmentMaintainTask.setCreateTime(new Date()); | ||
241 | equipmentMaintainTask.setCreateBy(BaseContextHandler.getUserLoginName()); | ||
242 | equipmentMaintainTask.setResultsEnforcement(1); | ||
243 | equipmentMaintainTask.setPlanId(equipmentMaintainPlan.getId()); | ||
244 | //默认计划安排人作为维护负责人 | ||
245 | equipmentMaintainTask.setMaintainerId(equipmentMaintainPlan.getPlanArrangerId()); | ||
246 | //检验日期 | ||
247 | equipmentMaintainTask.setMaintainTime(DateUtils.parse(timeArray[0], "yyyy-MM-dd HH:mm:ss")); | ||
248 | equipmentMaintainTaskMapper.insert(equipmentMaintainTask); | ||
249 | } | ||
222 | } | 250 | } |
251 | }catch (Exception e) { | ||
252 | e.printStackTrace(); | ||
223 | } | 253 | } |
224 | equipmentMaintainPlan.setReleaseStatus(equipmentMaintainPlanDTO.getReleaseStatus()); | 254 | |
225 | equipmentMaintainPlanMapper.updateById(equipmentMaintainPlan); | ||
226 | } | 255 | } |
227 | 256 | ||
228 | 257 | ... | ... |
1 | package com.skua.modules.equipment.service.impl; | 1 | package com.skua.modules.equipment.service.impl; |
2 | 2 | ||
3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
4 | import java.util.ArrayList; | 4 | import java.util.*; |
5 | import java.util.Date; | ||
6 | import java.util.HashMap; | ||
7 | import java.util.List; | ||
8 | import java.util.Map; | ||
9 | import java.util.Set; | ||
10 | import java.util.UUID; | ||
11 | 5 | ||
12 | import com.baomidou.mybatisplus.core.metadata.IPage; | 6 | import com.baomidou.mybatisplus.core.metadata.IPage; |
13 | import com.skua.modules.equipment.vo.*; | 7 | import com.skua.modules.equipment.vo.*; |
... | @@ -161,20 +155,26 @@ public class EquipmentMaintainTaskServiceImpl extends ServiceImpl<EquipmentMaint | ... | @@ -161,20 +155,26 @@ public class EquipmentMaintainTaskServiceImpl extends ServiceImpl<EquipmentMaint |
161 | if (null != equipmentMaintainTask.getType() && equipmentMaintainTask.getType() == 0) { | 155 | if (null != equipmentMaintainTask.getType() && equipmentMaintainTask.getType() == 0) { |
162 | //type=0表示保养任务查询,type=1表示保养记录查询 | 156 | //type=0表示保养任务查询,type=1表示保养记录查询 |
163 | equipmentMaintainTask.setPlanArrangerId(userCode); | 157 | equipmentMaintainTask.setPlanArrangerId(userCode); |
158 | }else{ | ||
159 | if (null == equipmentMaintainTask.getType()) { | ||
160 | if(ConvertUtils.isEmpty(equipmentMaintainTask.getDepartId())){ | ||
161 | equipmentMaintainTask.setDepartId(BaseContextHandler.getDeparts()); | ||
162 | } | ||
163 | equipmentMaintainTask.setResultsEnforcement(1); | ||
164 | } | ||
164 | } | 165 | } |
165 | List<EquipmentMaintainTaskVO> equipmentMaintainTasks = baseMapper.queryCustomPageList(pageList, equipmentMaintainTask); | 166 | List<EquipmentMaintainTaskVO> equipmentMaintainTasks = baseMapper.queryCustomPageList(pageList, equipmentMaintainTask); |
166 | equipmentMaintainTasks.forEach(e -> { | 167 | equipmentMaintainTasks.forEach(e -> { |
167 | e.setCycleUnit(UnitUtils.getCycleUnitName(e.getCycleUnit())); | 168 | e.setCycleUnit(UnitUtils.getCycleUnitName(e.getCycleUnit())); |
168 | //状态<=2的时候,执行人 具有操作权限,其他人查看权限 | 169 | //状态<=2的时候,执行人 具有操作权限,其他人查看权限 |
169 | if(e.getResultsEnforcement()<=2&&userCode.equals(e.getPlanArrangerId())) { | 170 | if(e.getResultsEnforcement()<=2&&userCode.equals(e.getPlanArrangerId())) { |
170 | e.setCurrentState(2); | 171 | e.setCurrentState(2); |
171 | } | 172 | } |
172 | //状态=3的时候,验收人具有操作权限,其他人查看权限 | 173 | //状态=3的时候,验收人具有操作权限,其他人查看权限 |
173 | if(e.getResultsEnforcement()==3&&userCode.equals(e.getPlanAccepterId())) { | 174 | if(e.getResultsEnforcement()==3&&userCode.equals(e.getPlanAccepterId())) { |
174 | e.setCurrentState(3); | 175 | e.setCurrentState(3); |
175 | } | 176 | } |
176 | } | 177 | }); |
177 | ); | ||
178 | return pageList.setRecords(equipmentMaintainTasks); | 178 | return pageList.setRecords(equipmentMaintainTasks); |
179 | } | 179 | } |
180 | 180 | ||
... | @@ -364,20 +364,28 @@ public class EquipmentMaintainTaskServiceImpl extends ServiceImpl<EquipmentMaint | ... | @@ -364,20 +364,28 @@ public class EquipmentMaintainTaskServiceImpl extends ServiceImpl<EquipmentMaint |
364 | * @param maintainTaskForm | 364 | * @param maintainTaskForm |
365 | * @return | 365 | * @return |
366 | */ | 366 | */ |
367 | @Override | ||
367 | public IPage<EquipmentMaintainTaskForm> queryMaintainTaskFormByPage(Page<EquipmentMaintainTaskForm> page, EquipmentMaintainTaskForm maintainTaskForm){ | 368 | public IPage<EquipmentMaintainTaskForm> queryMaintainTaskFormByPage(Page<EquipmentMaintainTaskForm> page, EquipmentMaintainTaskForm maintainTaskForm){ |
368 | return this.baseMapper.queryMaintainTaskFormByPage(page,maintainTaskForm); | 369 | return this.baseMapper.queryMaintainTaskFormByPage(page,maintainTaskForm); |
369 | } | 370 | } |
370 | /** | 371 | /** |
371 | * 列表 | 372 | * 列表 |
372 | * @param maintainTaskForm | 373 | * @param maintainTaskForm |
373 | * @return | 374 | * @return |
374 | */ | 375 | */ |
376 | @Override | ||
375 | public List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList( EquipmentMaintainTaskForm maintainTaskForm){ | 377 | public List<EquipmentMaintainTaskForm> queryMaintainTaskFormByList( EquipmentMaintainTaskForm maintainTaskForm){ |
376 | List<EquipmentMaintainTaskForm> dataList = this.baseMapper.queryMaintainTaskFormByList(maintainTaskForm); | 378 | List<EquipmentMaintainTaskForm> dataList = this.baseMapper.queryMaintainTaskFormByList(maintainTaskForm); |
377 | return dataList; | 379 | return dataList; |
378 | } | 380 | } |
379 | 381 | ||
380 | @Override | 382 | @Override |
383 | public List<Map<String, Object>> getList(String startTime, String endTime) { | ||
384 | List<Map<String, Object>> list = baseMapper.getList(startTime, endTime); | ||
385 | return list; | ||
386 | } | ||
387 | |||
388 | @Override | ||
381 | public boolean updateResultsEnforcement(String id) { | 389 | public boolean updateResultsEnforcement(String id) { |
382 | baseMapper.updateResultsEnforcement(new Date(), 1, 2, id); | 390 | baseMapper.updateResultsEnforcement(new Date(), 1, 2, id); |
383 | return true; | 391 | return true; | ... | ... |
... | @@ -417,42 +417,15 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi | ... | @@ -417,42 +417,15 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi |
417 | return pageList.setRecords(equipmentStatistics); | 417 | return pageList.setRecords(equipmentStatistics); |
418 | } | 418 | } |
419 | 419 | ||
420 | |||
421 | |||
422 | @Override | 420 | @Override |
423 | public IPage<EquipmentStatisticsCountVO> getEquipmentStatisticsDetailsNew(Page<EquipmentStatisticsCountVO> pageList, ReportStatisticsDTO reportStatisticsDTO) { | 421 | public IPage<EquipmentStatisticsCountVO> getEquipmentStatisticsDetailsNew(Page<EquipmentStatisticsCountVO> pageList, ReportStatisticsDTO reportStatisticsDTO) { |
424 | 422 | IPage<EquipmentStatisticsCountVO> page = productionEquipmentMapper.getEquipmentStatisticsDetailsNew(pageList,reportStatisticsDTO); | |
425 | /* String dict_sql = "select t.item_value as 'id' , t.item_text , 'name' from sys_dict_item t where t.dict_id in (select id from sys_dict where dict_code = 'equipment-equipment_level') order by t.id asc "; | 423 | return page; |
426 | List<Map<String,Object>> mapList = commonSqlService.queryForList(dict_sql); | ||
427 | List<String> categoryNameList = new ArrayList<>(); | ||
428 | List<String> categoryIdList = new ArrayList<>();*/ | ||
429 | /* String startTime; | ||
430 | String endTime = DateUtils.getDateByAfterMonth(0);//当前日期 | ||
431 | if (6 == reportStatisticsDTO.getTimeUnit()) { | ||
432 | startTime = DateUtils.getDateByAfterMonth(-6); | ||
433 | } else { | ||
434 | startTime = DateUtils.getDateByAfterMonth(-12); | ||
435 | } | ||
436 | reportStatisticsDTO.setStartTime(startTime); | ||
437 | reportStatisticsDTO.setEndTime(endTime);*/ | ||
438 | return productionEquipmentMapper.getEquipmentStatisticsDetailsNew(pageList,reportStatisticsDTO); | ||
439 | } | 424 | } |
425 | |||
440 | @Override | 426 | @Override |
441 | public List<TOPTenVO> getEquipmentState(ReportStatisticsDTO reportStatisticsDTO) { | 427 | public List<TOPTenVO> getEquipmentState(ReportStatisticsDTO reportStatisticsDTO) { |
442 | List<TOPTenVO> list = new ArrayList<>(); | 428 | List<TOPTenVO> list = new ArrayList<>(); |
443 | /* TOPTenVO topTenVO = new TOPTenVO(); | ||
444 | reportStatisticsDTO.setEquipmentType("wxdd"); | ||
445 | Integer equipmentStatus = productionEquipmentMapper.getEquipmentStatus(reportStatisticsDTO); | ||
446 | topTenVO.setFactoryName("待修"); | ||
447 | topTenVO.setNum(equipmentStatus.toString()); | ||
448 | list.add(topTenVO); | ||
449 | TOPTenVO topTenVO1 = new TOPTenVO(); | ||
450 | reportStatisticsDTO.setEquipmentType("sbwx"); | ||
451 | Integer equipmentStatus1 = productionEquipmentMapper.getEquipmentStatus(reportStatisticsDTO); | ||
452 | topTenVO1.setFactoryName("在修"); | ||
453 | topTenVO1.setNum(equipmentStatus1.toString()); | ||
454 | list.add(topTenVO1);*/ | ||
455 | |||
456 | String sql = "select count(1) from equipment_repair where del_flag = 1 AND finish_flag = 'djx' "; | 429 | String sql = "select count(1) from equipment_repair where del_flag = 1 AND finish_flag = 'djx' "; |
457 | if(StringUtils.isNotEmpty(reportStatisticsDTO.getStartTime() )){ | 430 | if(StringUtils.isNotEmpty(reportStatisticsDTO.getStartTime() )){ |
458 | sql += " AND create_time >='"+reportStatisticsDTO.getStartTime()+"' "; | 431 | sql += " AND create_time >='"+reportStatisticsDTO.getStartTime()+"' "; | ... | ... |
1 | package com.skua.modules.equipment.vo; | 1 | package com.skua.modules.equipment.vo; |
2 | 2 | ||
3 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
4 | import com.skua.core.aspect.annotation.Dict; | 3 | import com.skua.core.aspect.annotation.Dict; |
5 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
6 | import io.swagger.annotations.ApiModelProperty; | 5 | import io.swagger.annotations.ApiModelProperty; |
7 | import lombok.Data; | 6 | import lombok.Data; |
8 | import lombok.EqualsAndHashCode; | ||
9 | import lombok.experimental.Accessors; | ||
10 | import org.jeecgframework.poi.excel.annotation.Excel; | 7 | import org.jeecgframework.poi.excel.annotation.Excel; |
11 | import org.springframework.format.annotation.DateTimeFormat; | ||
12 | |||
13 | import java.util.Date; | ||
14 | 8 | ||
15 | /** | 9 | /** |
16 | * @auther kangwei | 10 | * @auther kangwei | ... | ... |
-
请 注册 或 登录 后发表评论