|
|
@@ -0,0 +1,71 @@
|
|
|
+package com.lc.ibps.platform.plan.job;
|
|
|
+
|
|
|
+import com.lc.ibps.base.core.util.AppUtil;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.core.util.JacksonUtil;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
+import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
+import org.quartz.JobDataMap;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Administrator
|
|
|
+ */
|
|
|
+public class DeviceToDoRemindJob extends BaseJob2 {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(CommonInsertJob.class);
|
|
|
+ private ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
+ JobDataMap dataMap = context.getMergedJobDataMap();
|
|
|
+ logger.warn("group={} job={} trigger={} is running.",
|
|
|
+ context.getJobDetail().getKey().getGroup(),
|
|
|
+ context.getJobDetail().getKey().getName(),
|
|
|
+ context.getTrigger().getKey().getName());
|
|
|
+ logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
|
|
|
+
|
|
|
+
|
|
|
+ // 按部门分组,查询每个部门没做保养的设备数量
|
|
|
+ String sql = "select bian_zhi_bu_men_ from t_mjsbwhbyjlby where shi_fou_guo_shen_ ='待处理' group by bian_zhi_bu_men_";
|
|
|
+ List<Map<String, Object>> deptList = (List<Map<String, Object>>)commonDao.query(sql);
|
|
|
+ if (BeanUtils.isNotEmpty(deptList)){
|
|
|
+ for (Map<String,Object> map : deptList){
|
|
|
+ String deptId = map.get("bian_zhi_bu_men_").toString();
|
|
|
+ Map<String,Object> total = commonDao.queryOne("select count(1) total from t_mjsbwhbyjlby where bian_zhi_bu_men_ ='"+deptId+"'");
|
|
|
+ long count = (long)total.get("total");
|
|
|
+ if (count>0){
|
|
|
+ // 发系统消息给对应的专业组组长
|
|
|
+ this.sendLeaders(deptId,count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendLeaders(String deptId,long total){
|
|
|
+ String SQL2 = "select *from v_professional_leader where id_ in(select id_ from ibps_party_employee where positions_ like '%%%s%%')";
|
|
|
+ SQL2 = String.format(SQL2,deptId);
|
|
|
+ List<Map<String, Object>> leads = (List<Map<String, Object>>)commonDao.query(SQL2);
|
|
|
+ if (BeanUtils.isNotEmpty(leads)){
|
|
|
+ for (Map<String,Object> lead : leads){
|
|
|
+ List<String> receiver = new ArrayList<>();
|
|
|
+ receiver.add(lead.get("ID_").toString());
|
|
|
+ String subject = "设备维护保养提醒";
|
|
|
+ String content = "您的专业组有"+total+"条待处理的设备维护保养记录,请通知相关人员及时处理!";
|
|
|
+ MessageQueueProductorUtil.send("DeviceToDoRemindJob", "DeviceToDoRemindJob" , "inner" , receiver,null , subject, content, null, null, null);
|
|
|
+ //TODO 消息模版
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|