Jelajahi Sumber

危险作业提醒

chenguangyu 1 tahun lalu
induk
melakukan
1cbb2ae0da

+ 5 - 0
bs-common/src/main/java/com/rongwei/safecommon/utils/SaveConstans.java

@@ -139,6 +139,8 @@ public class SaveConstans {
          * 检查任务提醒
           */
         public static final String INSPECTION_TASKS_TITLE = "检查任务提醒";
+        public static final String DANGEROUS_TITLE = "危险作业处罚提醒";
+
     }
 
     public static class NotifyContent {
@@ -160,5 +162,8 @@ public class SaveConstans {
         public static final String QUESTIONNAIRE_SURVEY_CONTENT = "%s年%s培训需求,已发布";
 
          public static final String INSPECTION_TASKS_CONTENT = "日常检查%s将于%tF %tT开始检查区域为%s-;-%s";
+
+        public static final String DANGEROUS_CONTENT = "%s:%s-%s,处罚金额:%s,时间:%s";
+
     }
 }

+ 5 - 1
cx-question/cx-question-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ExportServiceImpl.java

@@ -216,7 +216,11 @@ public class ExportServiceImpl implements ExportService {
             } catch (Exception e) {
                 log.error("图片url:{}不存在", url);
             }
-            builder.writeln();
+            try {
+                builder.writeln();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
         });
     }
 

+ 17 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/DangerousDao.java

@@ -0,0 +1,17 @@
+package com.rongwei.sfcommon.sys.dao;
+
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+public interface DangerousDao {
+    @Select("SELECT a.*, b.JOBTYPE, b.ASSIGNMENTTIMESTART, b.ASSIGNMENTTIMEEND FROM asp_inspectrecords a LEFT JOIN asp_job_management b ON a.JOBID = b.ID WHERE a.deleted = 0 AND a.PUNISHPERSONNELID IS NOT NULL AND a.STATUS = '1' AND a.GENERATEPENALTYORNOT = 'y'")
+    List<Map<String, Object>> getDangerousDailyNotify();
+
+    @Select("SELECT a.*, b.JOBTYPE, b.ASSIGNMENTTIMESTART, b.ASSIGNMENTTIMEEND FROM asp_inspectrecords a LEFT JOIN asp_job_management b ON a.JOBID = b.ID WHERE a.deleted = 0 AND a.ID = #{id}")
+    Map<String, Object> getDangerousNotify(@Param("id") String id);
+
+
+}

+ 4 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/SafeCheckSendNotifyService.java

@@ -1,5 +1,7 @@
 package com.rongwei.sfcommon.sys.service;
 
+import com.rongwei.rwcommon.base.R;
+
 /**
  * SendNotifyService class
  *
@@ -13,4 +15,6 @@ public interface SafeCheckSendNotifyService {
      */
     void inspectionTasks();
 
+
+    R sendDangerousTimelyNotify(String id);
 }

+ 49 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/SafeCheckSendNotifyServiceImpl.java

@@ -1,15 +1,22 @@
 package com.rongwei.sfcommon.sys.service.impl;
 
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.safecommon.utils.CXCommonUtils;
+import com.rongwei.sfcommon.sys.dao.DangerousDao;
 import com.rongwei.sfcommon.sys.service.SafeCheckSendNotifyService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 
 import static com.rongwei.safecommon.utils.SaveConstans.DEFAULT_SEPARATOR;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.DANGEROUS_CONTENT;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.DANGEROUS_TITLE;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.INSPECTION_TASKS_TITLE;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.DANGEROUS;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.INSPECTIONTASKS;
 
 /**
@@ -20,6 +27,9 @@ import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.INSPECTIONTAS
  */
 @Service
 public class SafeCheckSendNotifyServiceImpl implements SafeCheckSendNotifyService {
+
+    @Autowired
+    private DangerousDao dangerousDao;
     @Override
     public void inspectionTasks() {
 
@@ -35,4 +45,43 @@ public class SafeCheckSendNotifyServiceImpl implements SafeCheckSendNotifyServic
                     new ArrayList<>(v), k.split(DEFAULT_SEPARATOR)[1], INSPECTIONTASKS);
         });
     }
+
+
+    /**
+     * 危险作业每日处罚提醒
+     */
+    public void dangerousDailyNotify() {
+        List<Map<String, Object>> dangerous = dangerousDao.getDangerousDailyNotify();
+        if (dangerous != null) {
+            for (Map<String, Object> item : dangerous) {
+                String punishPersonnelId = (String) item.get("PUNISHPERSONNELID");
+                List<String> personnelIdList = new ArrayList<>();
+                personnelIdList.add(punishPersonnelId);
+                CXCommonUtils.sendNotify(DANGEROUS_TITLE, String.format(DANGEROUS_CONTENT,
+                                item.get("JOBTYPE"), item.get("ASSIGNMENTTIMESTART"), item.get("ASSIGNMENTTIMEEND"),
+                                item.get("PENALTYAMOUNT"), item.get("MODIFYDATE")),
+                        "", personnelIdList, null, DANGEROUS);
+            }
+        }
+    }
+
+    /**
+     * 危险作业处罚提醒
+     */
+    @Override
+    public R sendDangerousTimelyNotify(String id) {
+        Map<String, Object> dangerous = dangerousDao.getDangerousNotify(id);
+        if (dangerous != null) {
+            String punishPersonnelId = (String) dangerous.get("PUNISHPERSONNELID");
+            List<String> personnelIdList = new ArrayList<>();
+            personnelIdList.add(punishPersonnelId);
+            CXCommonUtils.sendNotify(DANGEROUS_TITLE, String.format(DANGEROUS_CONTENT,
+                            dangerous.get("JOBTYPE"), dangerous.get("ASSIGNMENTTIMESTART"), dangerous.get("ASSIGNMENTTIMEEND"),
+                            dangerous.get("PENALTYAMOUNT"), dangerous.get("MODIFYDATE")),
+                    "", personnelIdList, null, DANGEROUS);
+        }
+
+
+        return R.ok();
+    }
 }

+ 44 - 0
cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/SafeSendNotifyController.java

@@ -0,0 +1,44 @@
+package com.rongwei.savecheck.controller;
+
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.StringUtils;
+import com.rongwei.sfcommon.sys.service.SafeCheckSendNotifyService;
+import com.rongwei.sfcommon.sys.service.impl.SafeCheckSendNotifyServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * SendNotifyController class
+ *
+ * @author XH
+ * @date 2023/12/15
+ */
+@RestController
+@RequestMapping("/notify")
+@Slf4j
+public class SafeSendNotifyController {
+    @Autowired
+    private SafeCheckSendNotifyService sendNotify;
+    @Autowired
+    private SafeCheckSendNotifyServiceImpl sendNotifyService;
+    @PostMapping("/dangerousDailyNotify")
+    public void dangerousNotify(){
+        log.info("开始发送每日危险作业处罚提醒");
+        sendNotifyService.dangerousDailyNotify();
+    }
+    @PostMapping("/dangerousNotify/{id}")
+    public R dangerousTimelyNotify(@PathVariable String id) {
+        try {
+            log.info("开始即使发送危险作业处罚提醒");
+            return sendNotify.sendDangerousTimelyNotify(id);
+        } catch (Exception e) {
+            log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
+            return R.queryError();
+        }
+
+    }
+}