Quellcode durchsuchen

危险作业处罚人员提醒

chenguangyu vor 1 Jahr
Ursprung
Commit
8dfb97d9c0

+ 26 - 0
rw-training/training-common/src/main/java/com/rongwei/trainingcommon/sys/dao/DangerousDao.java

@@ -0,0 +1,26 @@
+package com.rongwei.trainingcommon.sys.dao;
+
+import com.rongwei.training.vo.DemandUserVo;
+import com.rongwei.training.vo.WordEmpInfoVo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * CommonDao class
+ *
+ * @author XH
+ * @date 2020/12/18
+ */
+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
rw-training/training-common/src/main/java/com/rongwei/trainingcommon/sys/service/SendNotifyService.java

@@ -1,7 +1,9 @@
 package com.rongwei.trainingcommon.sys.service;
 
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.training.domain.PlanDo;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -22,4 +24,6 @@ public interface SendNotifyService {
 
 
     void questionnaireSurvey();
+
+    R sendDangerousTimelyNotify(String id);
 }

+ 47 - 4
rw-training/training-common/src/main/java/com/rongwei/trainingcommon/sys/service/impl/SendNotifyServiceImpl.java

@@ -3,12 +3,14 @@ package com.rongwei.trainingcommon.sys.service.impl;
 import cn.hutool.core.thread.ExecutorBuilder;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.rongwei.rwcommon.base.BaseDo;
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.safecommon.utils.CXCommonUtils;
 import com.rongwei.training.domain.EmpExamDo;
 import com.rongwei.training.domain.PlanDo;
 import com.rongwei.training.domain.PlanPaperDo;
 import com.rongwei.training.domain.TrainingDemandSurveyBackupsDo;
+import com.rongwei.trainingcommon.sys.dao.DangerousDao;
 import com.rongwei.trainingcommon.sys.service.EmpExamService;
 import com.rongwei.trainingcommon.sys.service.PlanPaperService;
 import com.rongwei.trainingcommon.sys.service.PlanService;
@@ -23,8 +25,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.TRAINING;
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.TRAININGFORM;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.*;
 
 /**
  * SendNotifyService class
@@ -44,6 +45,8 @@ public class SendNotifyServiceImpl implements SendNotifyService {
     @Autowired
     private PlanService planService;
     @Autowired
+    private DangerousDao dangerousDao;
+    @Autowired
     private PlanPaperService planPaperService;
     @Autowired
     private SendMailServiceImpl sendMailService;
@@ -57,8 +60,11 @@ public class SendNotifyServiceImpl implements SendNotifyService {
     public static final String CANCEL_TRAIN_TITLE = "培训取消提醒";
     public static final String CANCEL_TRAIN_CONTENT = "%s已取消";
 
-    public static final String QUESTIONNAIRE_SURVEY_TITLE="培训需求调查提醒";
-    public static final String QUESTIONNAIRE_SURVEY_CONTENT="%s年%s培训需求,已发布";
+    public static final String QUESTIONNAIRE_SURVEY_TITLE = "培训需求调查提醒";
+    public static final String QUESTIONNAIRE_SURVEY_CONTENT = "%s年%s培训需求,已发布";
+    public static final String DANGEROUS_TITLE = "危险作业处罚提醒";
+    public static final String DANGEROUS_CONTENT = "%s:%s-%s,处罚金额:%s,时间:%s";
+
 
     // 培训计划已发布
     private static final String TRAINING_PLAN_PUBLISH = "y";
@@ -161,4 +167,41 @@ public class SendNotifyServiceImpl implements SendNotifyService {
         });
     }
 
+    /**
+     * 危险作业每日处罚提醒
+     */
+    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();
+    }
 }

+ 27 - 3
rw-training/training-server/src/main/java/com/rongwei/training/controller/SendNotifyController.java

@@ -1,11 +1,14 @@
 package com.rongwei.training.controller;
 
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.StringUtils;
+import com.rongwei.trainingcommon.sys.service.SendNotifyService;
 import com.rongwei.trainingcommon.sys.service.impl.SendNotifyServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * SendNotifyController class
@@ -20,6 +23,9 @@ public class SendNotifyController {
     @Autowired
     private SendNotifyServiceImpl sendNotifyService;
 
+    @Autowired
+    private SendNotifyService sendNotify;
+
     @PostMapping("/end/reminder-email")
     public void endReminderMail() {
         log.info("开始发送考试截止提醒邮件");
@@ -36,4 +42,22 @@ public class SendNotifyController {
         log.info("开始发送问卷调查通知");
         sendNotifyService.trainingPlan();
     }
+
+    @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();
+        }
+
+    }
 }