Просмотр исходного кода

[task-2132] 设施环境未填写提醒需要把所有设备合并成一条消息

Li Yuan 1 год назад
Родитель
Сommit
fc7a9f527d

+ 34 - 24
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/DeviceToDoRemindJob.java

@@ -13,9 +13,7 @@ import org.quartz.JobExecutionContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author Administrator
@@ -36,46 +34,58 @@ public class DeviceToDoRemindJob extends BaseJob2 {
 
 
         // 按部门分组,查询每个部门没做保养的设备数量
-        String sql = "select bian_zhi_bu_men_ from t_mjsbwhbyjlby where shi_fou_guo_shen_ ='待处理' and ji_hua_shi_jian_=current_date group by bian_zhi_bu_men_";
+        String sql = "select bian_zhi_bu_men_, count(1) total from t_mjsbwhbyjlby where shi_fou_guo_shen_ ='待处理' and ji_hua_shi_jian_=current_date 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 ji_hua_shi_jian_=current_date and bian_zhi_bu_men_ ='"+deptId+"'");
-                long count = (long)total.get("total");
-                if (count>0){
-                    // 发系统消息给对应的专业组组长和设备管理小组负责人
-                    this.sendLeaders(deptId,"设备维护保养提醒","%s有"+count+"条待处理的设备维护保养记录,请通知相关人员及时处理!","sbglxzfzr");
-                }
+                long count = (long)map.get("total");
+                // 发系统消息给对应的专业组组长和设备管理小组负责人
+                this.sendLeaders(deptId,"%s设备维护保养提醒","您的专业组有"+count+"条待处理的设备维护保养记录,请通知相关人员及时处理!","sbglxzfzr","/sbgls/mywh");
             }
         }
 
         // 设施环境待处理推送
-        String sshjSql = "select facs_type,bian_zhi_bu_men_ from v_facs_summary_daily where shi_fou_guo_shen_ ='待处理' GROUP BY bian_zhi_bu_men_";
-        List<Map<String, Object>> bumen = (List<Map<String, Object>>)commonDao.query(sshjSql);
-        if (BeanUtils.isNotEmpty(bumen)){
-            for (Map<String,Object> map : bumen){
+        String sshjSql = "SELECT facs_type,bian_zhi_bu_men_,COUNT(1) AS total FROM v_facs_summary_daily WHERE shi_fou_guo_shen_ ='待处理'" +
+                " GROUP BY bian_zhi_bu_men_,facs_type ORDER BY bian_zhi_bu_men_,facs_type";
+        List<Map<String, Object>> mapList = (List<Map<String, Object>>)commonDao.query(sshjSql);
+        if (BeanUtils.isNotEmpty(mapList)){
+            String preBumen = null;
+            StringJoiner content = new StringJoiner("<br />").add("您好,今天%s存在待处理的设施环境监控数据,请及时安排人员处理!详细情况如下:");
+            for (Map<String,Object> map : mapList){
                 String deptId = map.get("bian_zhi_bu_men_").toString();
-                String taskName = map.get("facs_type").toString();
-                taskName = taskName.substring(3);
-                Map<String,Object> total = commonDao.queryOne("select count(1) total from v_facs_summary_daily where bian_zhi_bu_men_ ='"+deptId+"'");
-                long count = (long)total.get("total");
-                if (count>0){
+                if(preBumen == null) preBumen = deptId;
+                if(!preBumen.equals(deptId)){
                     // 发系统消息给对应的专业组组长和安全管理小组负责人
-                    this.sendLeaders(deptId,taskName+"待处理提醒","%s有"+count+"条待处理的"+taskName+"记录,请通知相关人员及时处理!","aqglxzfzr");
+                    this.sendLeaders(deptId,"%s设施环境监控提醒",content.toString(),"aqglxzfzr","/sshjgl/sshjjk/sshjkzzl");
+                    preBumen = deptId;
+                    content = new StringJoiner("<br />").add("您好,今天%s存在待处理的设施环境监控数据,请及时安排人员处理!详细情况如下:");
                 }
+                String taskName = map.get("facs_type").toString();
+                taskName = taskName.substring(3);
+                long count = (long)map.get("total");
+                content.add("【"+taskName+"】 有"+count+"条待处理的记录");
+            }
+            //last one
+            if(preBumen !=null){
+                // 发系统消息给对应的专业组组长和安全管理小组负责人
+                this.sendLeaders(preBumen,"%s设施环境监控提醒",content.toString(),"aqglxzfzr","/sshjgl/sshjjk/sshjkzzl");
             }
         }
     }
 
-    private void sendLeaders(String deptId,String subject ,String content,String roleString){
+    private void sendLeaders(String deptId,String subject ,String content,String roleString,String routeString){
+        Map<String, Object> map2 = new HashMap<>();
+        map2.put("skipTypeMsg","{\"skipType\": 3,\"pathInfo\": \""+routeString+"\"}");
+
         // 获取地点和专业组名称
         String sql1 = " SELECT name_,path_ FROM `ibps_party_entity` WHERE party_type_='position' AND id_ LIKE '%%%s%%'";
         sql1 = String.format(sql1,deptId);
         Map<String, Object> entity = (Map<String, Object>)commonDao.queryOne(sql1);
         if(entity == null) return;
         String deptName = entity.get("name_").toString();
-        content = String.format(content,deptName);
+        subject = String.format(subject,deptName);
+        content =  String.format(content,deptName);
         String path = entity.get("path_").toString();
         String diDian = "";
         try{
@@ -100,7 +110,7 @@ public class DeviceToDoRemindJob extends BaseJob2 {
             for (Map<String,Object> lead : leads){
                 List<String> receiver = new ArrayList<>();
                 receiver.add(lead.get("ID_").toString());
-                MessageQueueProductorUtil.send("DeviceToDoRemindJob", "DeviceToDoRemindJob" , "inner" , receiver,null , subject, content, null, null, null);
+                MessageQueueProductorUtil.send("DeviceToDoRemindJob", "DeviceToDoRemindJob" , "inner" , receiver,null , subject, content, null, null, map2);
                 //TODO 消息模版
             }
         }
@@ -124,7 +134,7 @@ public class DeviceToDoRemindJob extends BaseJob2 {
                 for (Map<String,Object> lead : lead2){
                     List<String> receiver = new ArrayList<>();
                     receiver.add(lead.get("ID_").toString());
-                    MessageQueueProductorUtil.send("DeviceToDoRemindJob", "DeviceToDoRemindJob" , "inner" , receiver,null , subject, content, null, null, null);
+                    MessageQueueProductorUtil.send("DeviceToDoRemindJob", "DeviceToDoRemindJob" , "inner" , receiver,null , subject, content, null, null, map2);
                 }
             }
         }