Browse Source

feature 增加相关定时任务

xiahan 1 năm trước cách đây
mục cha
commit
7e495b8e22
18 tập tin đã thay đổi với 736 bổ sung7 xóa
  1. 24 1
      bs-common/src/main/java/com/rongwei/safecommon/utils/SaveConstans.java
  2. 15 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/AspSafeAttachmentsDao.java
  3. 15 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/AspSpecialEquipmentCertificateDao.java
  4. 2 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/SaveCheckCommonDao.java
  5. 12 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/AspSafeAttachmentsService.java
  6. 12 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/AspSpecialEquipmentCertificateService.java
  7. 3 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/CheckItemsService.java
  8. 108 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspSafeAttachmentsServiceImpl.java
  9. 110 0
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspSpecialEquipmentCertificateServiceImpl.java
  10. 92 5
      cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/CheckItemsServiceImpl.java
  11. 19 0
      cx-safe-check/cx-save-check-common/src/main/resources/mybatis/SaveCheckCommonDao.xml
  12. 161 0
      cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AspSafeAttachmentsDo.java
  13. 81 0
      cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AspSpecialEquipmentCertificateDo.java
  14. 4 1
      cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/CheckItemsDo.java
  15. 2 0
      cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/UserMailOrgVo.java
  16. 34 0
      cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/AspSafeAttachmentsController.java
  17. 34 0
      cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/AspSpecialEquipmentCertificateController.java
  18. 8 0
      cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/CheckItemsController.java

+ 24 - 1
bs-common/src/main/java/com/rongwei/safecommon/utils/SaveConstans.java

@@ -208,6 +208,10 @@ public class SaveConstans {
          * 安全附件
          */
         public static final String SAFETY_ATTACHMENT_VERIFICATION = "safeAttachments";
+        /**
+         * 特种设备作业人员证书提醒
+         */
+        public static final String PERSONNEL_CERTIFICATES="PersonnelCertificates";
     }
 
     public static class NotifyTitle {
@@ -341,6 +345,14 @@ public class SaveConstans {
          * 安全附件检验提醒
          */
         public static final String SAFETY_ATTACHMENT_VERIFICATION_TITLE = "安全附件检验提醒";
+        /**
+         * 特种设备作业人员证书提醒
+         */
+        public static final String PERSONNEL_CERTIFICATES_TITLE="特种设备人员证书年检提醒";
+        /**
+         * 设备年检
+         */
+        public static final String EQUIPMENT_CHECK_TITLE="设备年检提醒";
     }
 
     public static class NotifyContent {
@@ -470,8 +482,19 @@ public class SaveConstans {
          * 安全观察指标提醒
          */
         public static final String OBSERVATION_CONTENT = "新的安全观察目标值【%s】已下达,请及时完成!";
-
+        /**
+         * 安全附件
+         */
         public static final String SAFETY_ATTACHMENT_VERIFICATION_CONTENT = "  名称:【%s】,编号:【%s】,检验/更换日期:【%tF】,下次检验/更换日期:【%tF】,负责人:【%s】";
+        /**
+         * 特种设备作业人员证书提醒
+         */
+        public static final String PERSONNEL_CERTIFICATES_CONTENT="您好,有如下人员证书即将到期,请及时处理 姓名:【%s】,所属部门:【%s】证书类别:【%s】,复审日期:【%tF】";
+
+        /**
+         * 设备年检
+         */
+        public static final String EQUIPMENT_CHECK_CONTENT=" 您好,有如下设备即将年检到期,请及时处理! 设备类型:【%s】,设备编号:【%s】,设备名称:【%s】,年检日期:【%tF】";
     }
 
     /**

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

@@ -0,0 +1,15 @@
+package com.rongwei.sfcommon.sys.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.scentity.domian.AspSafeAttachmentsDo;
+
+/**
+ * @Entity com.rongwei.training.domain.AspSafeAttachments
+ */
+public interface AspSafeAttachmentsDao extends BaseMapper<AspSafeAttachmentsDo> {
+
+}
+
+
+
+

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

@@ -0,0 +1,15 @@
+package com.rongwei.sfcommon.sys.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.scentity.domian.AspSpecialEquipmentCertificateDo;
+
+/**
+ * @Entity com.rongwei.training.domain.AspSpecialEquipmentCertificate
+ */
+public interface AspSpecialEquipmentCertificateDao extends BaseMapper<AspSpecialEquipmentCertificateDo> {
+
+}
+
+
+
+

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

@@ -28,4 +28,6 @@ public interface SaveCheckCommonDao {
     List<String> getUserIdByRoleCodeAndOrgIdAndTenantId(@Param("roleCodes") List<String> roleCode,
                                                         @Param("orgIds") List<String> orgIds,
                                                         @Param("tenantId") String tenantId);
+
+    List<UserMailOrgVo> getUserInfoByTenantIdAndRoleCode(@Param("tenantId") String tenantId,@Param("roleCodes") List<String> roleCodes);
 }

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

@@ -0,0 +1,12 @@
+package com.rongwei.sfcommon.sys.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.scentity.domian.AspSafeAttachmentsDo;
+import com.rongwei.rwcommon.base.R;
+
+/**
+ *
+ */
+public interface AspSafeAttachmentsService extends IService<AspSafeAttachmentsDo> {
+  R stateUpdateScheduledTasks();
+}

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

@@ -0,0 +1,12 @@
+package com.rongwei.sfcommon.sys.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.scentity.domian.AspSpecialEquipmentCertificateDo;
+import com.rongwei.rwcommon.base.R;
+
+/**
+ *
+ */
+public interface AspSpecialEquipmentCertificateService extends IService<AspSpecialEquipmentCertificateDo> {
+    R stateUpdateScheduledTasks();
+}

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwe.scentity.domian.CheckItemsDo;
+import com.rongwei.rwcommon.base.R;
 
 import java.util.List;
 
@@ -22,5 +23,7 @@ public interface CheckItemsService extends IService<CheckItemsDo> {
     IPage<CheckItemsDo> spareList(Page page);
 
     void reportEquMessage();
+
+    R stateUpdateScheduledTasks();
 }
 

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

@@ -0,0 +1,108 @@
+package com.rongwei.sfcommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.scentity.domian.AspSafeAttachmentsDo;
+import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.safecommon.utils.CXCommonUtils;
+import com.rongwei.sfcommon.sys.dao.AspSafeAttachmentsDao;
+import com.rongwei.sfcommon.sys.dao.SaveCheckCommonDao;
+import com.rongwei.sfcommon.sys.service.AspSafeAttachmentsService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.rongwei.safecommon.utils.SaveConstans.*;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.SAFETY_ATTACHMENT_VERIFICATION_CONTENT;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.SAFETY_ATTACHMENT_VERIFICATION_TITLE;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.SAFETY_ATTACHMENT_VERIFICATION;
+
+/**
+ *
+ */
+@Service
+public class AspSafeAttachmentsServiceImpl extends ServiceImpl<AspSafeAttachmentsDao, AspSafeAttachmentsDo>
+        implements AspSafeAttachmentsService {
+    /**
+     * 组织机构代码
+     */
+    public static final List<String> ROLE_CODE_LIST = new ArrayList<String>() {{
+        add("code-safe");
+        add("role031");
+    }};
+    /**
+     * 特种设备管理员
+     */
+    public static final String SPECIAL_EQUIPMENT_ADMINISTRATOR = "role031";
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+    @Autowired
+    private SaveCheckCommonDao saveCheckCommonDao;
+
+    @Override
+    public R stateUpdateScheduledTasks() {
+        // 获取所有的安全附件
+        List<AspSafeAttachmentsDo> safeAttachmentsDos = this.list();
+        if (safeAttachmentsDos.isEmpty()) {
+            return R.ok("暂无安全附件");
+        }
+        // 对数据按照租户ID 分组
+        Map<String, List<AspSafeAttachmentsDo>> dataMap = safeAttachmentsDos.stream().collect(Collectors.groupingBy(AspSafeAttachmentsDo::getTenantid));
+        List<AspSafeAttachmentsDo> saveData = new ArrayList<>();
+        // 发送消息提醒的参数
+        Map<AspSafeAttachmentsDo, List<String>> sendNotifyMap = new HashMap<AspSafeAttachmentsDo, List<String>>();
+        dataMap.forEach((k, v) -> {
+            //获取工厂对应的 安全管理员和特种设备管理员
+            List<UserMailOrgVo> userInfO = saveCheckCommonDao.getUserInfoByTenantIdAndRoleCode(k, ROLE_CODE_LIST);
+            Date manufacturedate;
+            long daysBetween;
+            List<String> alertUser;
+            for (AspSafeAttachmentsDo data : v) {
+                manufacturedate = data.getManufacturedate();
+                LocalDate date1 = manufacturedate.toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalDate();
+                daysBetween = ChronoUnit.DAYS.between(LocalDate.now(), date1);
+                if (daysBetween <= 30) {
+                    data.setReminderstate(HIGH);
+                    alertUser = userInfO.stream().map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                } else if (daysBetween <= 90) {
+                    alertUser = userInfO.stream().filter(user -> SPECIAL_EQUIPMENT_ADMINISTRATOR.equals(user.getRoleCode())).map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                    data.setReminderstate(MIDDLE);
+                } else {
+
+                    data.setReminderstate(LOW);
+                }
+
+                saveData.add(data);
+            }
+        });
+        this.updateBatchById(saveData);
+        sendNotify(sendNotifyMap);
+        return R.ok();
+    }
+
+    public void sendNotify(Map<AspSafeAttachmentsDo, List<String>> sendNotifyMap) {
+        sendNotifyMap.forEach((k, v) -> {
+            // 发送消息提醒
+            CXCommonUtils.sendNotify(SAFETY_ATTACHMENT_VERIFICATION_TITLE,
+                    String.format(SAFETY_ATTACHMENT_VERIFICATION_CONTENT, k.getName(), k.getNumber(), k.getInspectiondate(),
+                            k.getNextinspectiondate(), k.getResponsible()), null, v.stream().distinct().collect(Collectors.toList()),
+                    k.getId(), SAFETY_ATTACHMENT_VERIFICATION, false);
+        });
+    }
+}
+
+
+
+

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

@@ -0,0 +1,110 @@
+package com.rongwei.sfcommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.scentity.domian.AspSpecialEquipmentCertificateDo;
+import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.safecommon.utils.CXCommonUtils;
+import com.rongwei.sfcommon.sys.dao.AspSpecialEquipmentCertificateDao;
+import com.rongwei.sfcommon.sys.dao.SaveCheckCommonDao;
+import com.rongwei.sfcommon.sys.service.AspSpecialEquipmentCertificateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.rongwei.safecommon.utils.SaveConstans.*;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.PERSONNEL_CERTIFICATES_CONTENT;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.SAFETY_ATTACHMENT_VERIFICATION_CONTENT;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.PERSONNEL_CERTIFICATES_TITLE;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.SAFETY_ATTACHMENT_VERIFICATION_TITLE;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.PERSONNEL_CERTIFICATES;
+
+/**
+ *
+ */
+@Service
+public class AspSpecialEquipmentCertificateServiceImpl extends ServiceImpl<AspSpecialEquipmentCertificateDao, AspSpecialEquipmentCertificateDo>
+        implements AspSpecialEquipmentCertificateService {
+    /**
+     * 组织机构代码
+     */
+    public static final List<String> ROLE_CODE_LIST = new ArrayList<String>() {{
+        add("code-safe");
+        add("role031");
+    }};
+    /**
+     * 特种设备管理员
+     */
+    public static final String SPECIAL_EQUIPMENT_ADMINISTRATOR = "role031";
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+    @Autowired
+    private SaveCheckCommonDao saveCheckCommonDao;
+
+    @Override
+    public R stateUpdateScheduledTasks() {
+        // 获取所有的安全附件
+        List<AspSpecialEquipmentCertificateDo> safeAttachmentsDos = this.list();
+        if (safeAttachmentsDos.isEmpty()) {
+            return R.ok("暂无安全附件");
+        }
+        // 对数据按照租户ID 分组
+        Map<String, List<AspSpecialEquipmentCertificateDo>> dataMap = safeAttachmentsDos.stream().collect(Collectors.groupingBy(AspSpecialEquipmentCertificateDo::getTenantid));
+        List<AspSpecialEquipmentCertificateDo> saveData = new ArrayList<>();
+        // 发送消息提醒的参数
+        Map<AspSpecialEquipmentCertificateDo, List<String>> sendNotifyMap = new HashMap<>();
+        dataMap.forEach((k, v) -> {
+            //获取工厂对应的 安全管理员和特种设备管理员
+            List<UserMailOrgVo> userInfO = saveCheckCommonDao.getUserInfoByTenantIdAndRoleCode(k, ROLE_CODE_LIST);
+            Date manufacturedate;
+            long daysBetween;
+            List<String> alertUser;
+            for (AspSpecialEquipmentCertificateDo data : v) {
+                manufacturedate = data.getReviewdate();
+                LocalDate date1 = manufacturedate.toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalDate();
+                daysBetween = ChronoUnit.DAYS.between(LocalDate.now(), date1);
+                if (daysBetween <= 30) {
+                    data.setReminderstate(HIGH);
+                    alertUser = userInfO.stream().map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                } else if (daysBetween <= 90) {
+                    alertUser = userInfO.stream().filter(user -> SPECIAL_EQUIPMENT_ADMINISTRATOR.equals(user.getRoleCode())).map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                    data.setReminderstate(MIDDLE);
+                } else {
+                    data.setReminderstate(LOW);
+                }
+
+                saveData.add(data);
+            }
+        });
+        this.updateBatchById(saveData);
+        sendNotify(sendNotifyMap);
+        return R.ok();
+    }
+
+
+    public void sendNotify(Map<AspSpecialEquipmentCertificateDo, List<String>> sendNotifyMap) {
+        sendNotifyMap.forEach((k, v) -> {
+            // 发送消息提醒
+            CXCommonUtils.sendNotify(PERSONNEL_CERTIFICATES_TITLE,
+                    String.format(PERSONNEL_CERTIFICATES_CONTENT, k.getName(), k.getOrgname(), k.getCertificatesort(),
+                            k.getReviewdate()), null, v.stream().distinct().collect(Collectors.toList()),
+                    k.getId(), PERSONNEL_CERTIFICATES, false);
+        });
+    }
+}
+
+
+
+

+ 92 - 5
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/CheckItemsServiceImpl.java

@@ -2,35 +2,62 @@ package com.rongwei.sfcommon.sys.service.impl;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.scentity.domian.CheckItemsDo;
 import com.rongwe.scentity.domian.PointCheckDo;
 import com.rongwe.scentity.vo.CheckItemsTypeVo;
+import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwadmincommon.system.domain.SysDictDo;
+import com.rongwei.rwadmincommon.system.service.impl.SysDictServiceImpl;
+import com.rongwei.rwcommon.base.R;
 import com.rongwei.safecommon.utils.CXCommonUtils;
 import com.rongwei.sfcommon.sys.dao.CheckItemsDao;
+import com.rongwei.sfcommon.sys.dao.SaveCheckCommonDao;
 import com.rongwei.sfcommon.sys.service.CheckItemsService;
 import com.rongwei.sfcommon.sys.service.PointCheckService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.SPECIALEQUIPMENT_CONTENT;
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.SPECIALEQUIPMENT_CONTENT_PREFIX;
+import static com.rongwei.safecommon.utils.SaveConstans.*;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.*;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.EQUIPMENT_CHECK_TITLE;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.SPECIALEQUIPMENT_TITLE;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.SPECIALEQUIPMENT;
 
 @Service("checkItemsService")
 public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItemsDo> implements CheckItemsService {
 
+    /**
+     * 组织机构代码
+     */
+    public static final List<String> ROLE_CODE_LIST = new ArrayList<String>() {{
+        add("code-safe");
+        add("role031");
+    }};
+    /**
+     * 特种设备管理员
+     */
+    public static final String SPECIAL_EQUIPMENT_ADMINISTRATOR = "role031";
     @Autowired
+    @Lazy
     private PointCheckService pointCheckService;
-
     @Autowired
     private CheckItemsDao checkItemsDao;
+    @Autowired
+    private SaveCheckCommonDao saveCheckCommonDao;
+    @Autowired
+    private SysDictServiceImpl sysDictService;
 
     /**
      * 设备列表删除验证是否存在点检记录
@@ -109,7 +136,7 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
 
                 //发送消息
                 CXCommonUtils.sendNotify(SPECIALEQUIPMENT_TITLE,
-                        SPECIALEQUIPMENT_CONTENT_PREFIX + String.format(SPECIALEQUIPMENT_CONTENT,typeName,checkItemCode,checkItemName,nextCheckDate),
+                        SPECIALEQUIPMENT_CONTENT_PREFIX + String.format(SPECIALEQUIPMENT_CONTENT, typeName, checkItemCode, checkItemName, nextCheckDate),
                         null,
                         equManager.get(item.getTenantid()),
                         item.getId(),
@@ -120,4 +147,64 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
 
     }
 
+    @Override
+    public R stateUpdateScheduledTasks() {
+        // 获取所有的安全附件
+        List<CheckItemsDo> safeAttachmentsDos = this.list(new LambdaQueryWrapper<CheckItemsDo>().eq(CheckItemsDo::getSource, 1));
+        if (safeAttachmentsDos.isEmpty()) {
+            return R.ok("暂无设备需要检验");
+        }
+        // 对数据按照租户ID 分组
+        Map<String, List<CheckItemsDo>> dataMap = safeAttachmentsDos.stream().collect(Collectors.groupingBy(CheckItemsDo::getTenantid));
+        List<CheckItemsDo> saveData = new ArrayList<>();
+        // 发送消息提醒的参数
+        Map<CheckItemsDo, List<String>> sendNotifyMap = new HashMap<CheckItemsDo, List<String>>();
+        dataMap.forEach((k, v) -> {
+            //获取工厂对应的 安全管理员和特种设备管理员
+            List<UserMailOrgVo> userInfO = saveCheckCommonDao.getUserInfoByTenantIdAndRoleCode(k, ROLE_CODE_LIST);
+            Date manufacturedate;
+            long daysBetween;
+            List<String> alertUser;
+            for (CheckItemsDo data : v) {
+                manufacturedate = data.getNextcheckdate();
+                LocalDate date1 = manufacturedate.toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalDate();
+                daysBetween = ChronoUnit.DAYS.between(LocalDate.now(), date1);
+                if (daysBetween <= 30) {
+                    data.setReminderstate(HIGH);
+                    alertUser = userInfO.stream().map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                } else if (daysBetween <= 90) {
+                    alertUser = userInfO.stream().filter(user -> SPECIAL_EQUIPMENT_ADMINISTRATOR.equals(user.getRoleCode())).map(UserMailOrgVo::getId).collect(Collectors.toList());
+                    sendNotifyMap.put(data, alertUser);
+                    data.setReminderstate(MIDDLE);
+                } else {
+                    data.setReminderstate(LOW);
+                }
+
+                saveData.add(data);
+            }
+        });
+        this.updateBatchById(saveData);
+        sendNotify(sendNotifyMap);
+        return R.ok();
+    }
+
+    public void sendNotify(Map<CheckItemsDo, List<String>> sendNotifyMap) {
+        if (sendNotifyMap.isEmpty()) {
+            return;
+        }
+        // 获取数据字典
+        List<SysDictDo> aspCheckItemType = sysDictService.getDictsByType("asp_check_item_type");
+        sendNotifyMap.forEach((k, v) -> {
+            SysDictDo sysDictDo = aspCheckItemType.stream().filter(info -> info.getValue().equals(k.getCheckitemtype())).findFirst().orElse(null);
+
+            // 发送消息提醒
+            CXCommonUtils.sendNotify(EQUIPMENT_CHECK_TITLE,
+                    String.format(EQUIPMENT_CHECK_CONTENT, sysDictDo == null ? "" : sysDictDo.getName(), k.getCheckitemcode(), k.getCheckitemname(),
+                            k.getNextcheckdate()), null, v.stream().distinct().collect(Collectors.toList()),
+                    k.getId(), SPECIALEQUIPMENT, false);
+        });
+    }
 }

+ 19 - 0
cx-safe-check/cx-save-check-common/src/main/resources/mybatis/SaveCheckCommonDao.xml

@@ -98,4 +98,23 @@
             </if>
         </where>
     </select>
+    <select id="getUserInfoByTenantIdAndRoleCode" resultType="com.rongwe.scentity.vo.UserMailOrgVo">
+        select
+        su.ID as id,
+        su.NAME as name,
+        sr.CODE AS roleCode
+        from sys_user su
+        LEFT JOIN sys_user_role sur on sur.USERID = su.ID and sur.DELETED = '0'
+        LEFT JOIN sys_role sr on sur.ROLEID = sr.ID and sr.DELETED = '0'
+        lEFT JOIN sys_user_org suo on suo.USERID = su.ID and suo.DELETED = '0'
+        LEFT JOIN sys_organization so on suo.ORGID=so.ID and so.DELETED='0'
+        <where>
+            su.DELETED='0'
+            AND FIND_IN_SET(#{tenantId},so.FULLPID)
+            AND sr.CODE in
+            <foreach collection="roleCodes" item="code" open="(" close=")" separator=",">
+                #{code}
+            </foreach>
+        </where>
+    </select>
 </mapper>

+ 161 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AspSafeAttachmentsDo.java

@@ -0,0 +1,161 @@
+package com.rongwe.scentity.domian;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 安全附件
+ *
+ * @TableName asp_safe_attachments
+ */
+@TableName(value = "asp_safe_attachments")
+@Data
+public class AspSafeAttachmentsDo extends BaseDo implements Serializable {
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键
+     */
+    private String id;
+    /**
+     * 所属租户ID
+     */
+    private String tenantid;
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 型号
+     */
+    private String model;
+    /**
+     * 编号
+     */
+    private String number;
+    /**
+     * 制造厂
+     */
+    private String manufacturer;
+    /**
+     * 出厂日期
+     */
+    private Date manufacturedate;
+    /**
+     * 检测周期
+     */
+    private String detectionperiod;
+    /**
+     * 检测类型
+     */
+    private String detectiontype;
+    /**
+     * 检测单位
+     */
+    private String testingcompany;
+    /**
+     * 检测/更换日期
+     */
+    private Date inspectiondate;
+    /**
+     * 下次检测/更换日期
+     */
+    private Date nextinspectiondate;
+    /**
+     * 等级
+     */
+    private String grade;
+    /**
+     * 证书编号
+     */
+    private String certificatenumber;
+    /**
+     * 责任人
+     */
+    private String responsible;
+    /**
+     * 责任人ID
+     */
+    private String responsibleid;
+    /**
+     * 数量
+     */
+    private String quantity;
+    /**
+     * 防雷类型
+     */
+    private String antilightingtype;
+    /**
+     * 位置编号
+     */
+    private String positionnumber;
+    /**
+     * 使用车间
+     */
+    private String useshop;
+    /**
+     * 使用车间ID
+     */
+    private String useshopid;
+    /**
+     * 使用地点
+     */
+    private String useplace;
+    /**
+     * 安装地点
+     */
+    private String installplace;
+    /**
+     * 最大误差
+     */
+    private String maximumerror;
+    /**
+     * 测量范围
+     */
+    private String measuringrange;
+    /**
+     * 拾包公司名称
+     */
+    private String pickupcompany;
+    /**
+     * 安装部位
+     */
+    private String installsite;
+    /**
+     * 检测气体
+     */
+    private String tracergas;
+    /**
+     * 环境温度
+     */
+    private String ambienttemperature;
+    /**
+     * 工作电压
+     */
+    private String workingvoltage;
+    /**
+     * 附件
+     */
+    private String annex;
+    /**
+     * 提醒状态
+     */
+    private String reminderstate;
+    /**
+     * 主表ID(asp_check_items_area的ID)
+     */
+    private String mainid;
+    /**
+     * 附件类型
+     */
+    private String attachmenttype;
+}

+ 81 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/AspSpecialEquipmentCertificateDo.java

@@ -0,0 +1,81 @@
+package com.rongwe.scentity.domian;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 特种设备作业人员证书表
+ *
+ * @TableName asp_special_equipment_certificate
+ */
+@TableName(value = "asp_special_equipment_certificate")
+@Data
+public class AspSpecialEquipmentCertificateDo extends BaseDo implements Serializable {
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键ID
+     */
+    private String id;
+    /**
+     *
+     */
+    private String tenantid;
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+    /**
+     * 部门ID
+     */
+    private String orgid;
+    /**
+     * 部门名称
+     */
+    private String orgname;
+    /**
+     * 姓名
+     */
+    private String name;
+    /**
+     * 性别
+     */
+    private String sex;
+    /**
+     * 身份证号
+     */
+    private String idcard;
+    /**
+     * 作业种类
+     */
+    private String certificatesort;
+    /**
+     * 档案编号
+     */
+    private String fileno;
+    /**
+     * 证件编号
+     */
+    private String certificateno;
+    /**
+     * 证书类别
+     */
+    private String jobtype;
+    /**
+     * 发证日期
+     */
+    private Date dareofissuance;
+    /**
+     * 复审日期
+     */
+    private Date reviewdate;
+    /**
+     * 预警级别
+     */
+    private String reminderstate;
+}

+ 4 - 1
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/domian/CheckItemsDo.java

@@ -362,5 +362,8 @@ public class CheckItemsDo extends BaseDo implements Serializable {
 	 * 所属工厂
 	 */
 	private String ownedfactory;
-
+	/**
+	 * 提醒状态
+	 */
+	private String reminderstate;
 }

+ 2 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/UserMailOrgVo.java

@@ -14,4 +14,6 @@ public class UserMailOrgVo {
     private String email;
     private String orgId;
     private String name;
+    private String roleCode;
+
 }

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

@@ -0,0 +1,34 @@
+package com.rongwei.savecheck.controller;
+
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.sfcommon.sys.service.impl.AspSafeAttachmentsServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * AspSafeAttachmentsController class
+ *
+ * @author XH
+ * @date 2024/06/15
+ */
+@RestController
+@RequestMapping("/safe/attachments")
+public class AspSafeAttachmentsController {
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    @Autowired
+    private AspSafeAttachmentsServiceImpl aspSafeAttachmentsService;
+
+    @Scheduled(cron = "0 0 3 ? * *")
+    @PostMapping("/state")
+    public R stateUpdateScheduledTasks(){
+        log.info("安全附件定时任务,更改安全附件预警级别");
+        return aspSafeAttachmentsService.stateUpdateScheduledTasks();
+    }
+}

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

@@ -0,0 +1,34 @@
+package com.rongwei.savecheck.controller;
+
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.sfcommon.sys.service.AspSpecialEquipmentCertificateService;
+import com.rongwei.sfcommon.sys.service.impl.AspSafeAttachmentsServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * AspSafeAttachmentsController class
+ *
+ * @author XH
+ * @date 2024/06/15
+ */
+@RestController
+@RequestMapping("/special/equipment")
+public class AspSpecialEquipmentCertificateController {
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    @Autowired
+    private AspSpecialEquipmentCertificateService aspSpecialEquipmentCertificateService;
+
+    @Scheduled(cron = "0 0 3 ? * *")
+    @PostMapping("/state")
+    public R stateUpdateScheduledTasks(){
+        log.info("特种设备作业人员证书管理,更改预警级别");
+        return aspSpecialEquipmentCertificateService.stateUpdateScheduledTasks();
+    }
+}

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

@@ -4,6 +4,7 @@ import com.rongwei.rwcommon.base.R;
 import com.rongwei.sfcommon.sys.service.CheckItemsService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -52,4 +53,11 @@ public class CheckItemsController {
             return R.error(e.getMessage());
         }
     }
+
+    @Scheduled(cron = "0 0 3 ? * *")
+    @PostMapping("/state")
+    public R stateUpdateScheduledTasks(){
+        log.info("安全附件定时任务,更改安全附件预警级别");
+        return checkItemsService.stateUpdateScheduledTasks();
+    }
 }