소스 검색

设备定时任务提醒,定时任务每天执行一次,【预计提醒日期】在今天及今天之前的数据,给所有设备管理员角色下的员工提醒(分所属工厂)

sucheng 1 년 전
부모
커밋
ccc014f72f

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

@@ -3,6 +3,7 @@ package com.rongwei.sfcommon.sys.dao;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.rongwe.scentity.domian.CheckItemsDo;
+import com.rongwe.scentity.vo.CheckItemsTypeVo;
 import com.rongwei.rwcommon.base.BaseDao;
 import org.apache.ibatis.annotations.Select;
 
@@ -20,8 +21,18 @@ public interface CheckItemsDao extends BaseDao<CheckItemsDo> {
     @Select("select *  from asp_check_items WHERE DELETED='0' and STANDBY='y' and (ENABLED is NULL  or ENABLED ='enable' or ENABLED='')")
     IPage<CheckItemsDo> spareList(Page page);
 
-    @Select("SELECT * FROM asp_check_items where DELETED = 0 and DATE_FORMAT(WARNDATE, '%Y-%m-%d') <= DATE_FORMAT(NOW(), '%Y-%m-%d')")
-    List<CheckItemsDo> selectNeedReportEqu();
+    @Select("SELECT\n" +
+            "\taci.*,\n" +
+            "\tb.`NAME` AS typeName \n" +
+            "FROM\n" +
+            "\tasp_check_items aci\n" +
+            "\tLEFT JOIN ( SELECT * FROM sys_dict WHERE DELETED = 0 AND DICTTYPE = 'asp_check_item_type' ) b ON aci.CHECKITEMTYPE = b.`VALUE` \n" +
+            "WHERE\n" +
+            "\taci.DELETED = 0 \n" +
+            "\tAND DATE_FORMAT( aci.WARNDATE, '%Y-%m-%d' ) <= DATE_FORMAT(\n" +
+            "\tNOW(),\n" +
+            "\t'%Y-%m-%d')")
+    List<CheckItemsTypeVo> selectNeedReportEqu();
 
     //特种设备管理员的ID:08e111e9dbc04706a3eb8367a65a3dc5
     @Select("SELECT\n" +

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

@@ -1,10 +1,12 @@
 package com.rongwei.sfcommon.sys.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.rongwe.scentity.domian.CheckItemsDo;
 import com.rongwe.scentity.domian.PointCheckDo;
+import com.rongwe.scentity.vo.CheckItemsTypeVo;
 import com.rongwei.safecommon.utils.CXCommonUtils;
 import com.rongwei.sfcommon.sys.dao.CheckItemsDao;
 import com.rongwei.sfcommon.sys.service.CheckItemsService;
@@ -23,37 +25,39 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
     private PointCheckService pointCheckService;
 
     @Autowired
-   private CheckItemsDao checkItemsDao;
+    private CheckItemsDao checkItemsDao;
 
     /**
      * 设备列表删除验证是否存在点检记录
+     *
      * @param ids
      */
-    public String deleteValidate(List<String> ids){
+    public String deleteValidate(List<String> ids) {
         String warnMes = null;
         List<String> retWarn = new ArrayList<>();
-        if(ids != null && ids.size()>0){
-            for(String id:ids){
+        if (ids != null && ids.size() > 0) {
+            for (String id : ids) {
                 CheckItemsDo checkItemsDo = this.getById(id);
-                Map<String,Object> pcMap = new HashMap<>();
-                pcMap.put("CHECKITEMID",id);
-                List<PointCheckDo> pointCheckDos = (List<PointCheckDo>)pointCheckService.listByMap(pcMap);
-                if(pointCheckDos != null && pointCheckDos.size()>0){
-                    retWarn.add("设备编号:"+checkItemsDo.getCheckitemcode()+";设备名称:"+checkItemsDo.getCheckitemname());
-                }else{
+                Map<String, Object> pcMap = new HashMap<>();
+                pcMap.put("CHECKITEMID", id);
+                List<PointCheckDo> pointCheckDos = (List<PointCheckDo>) pointCheckService.listByMap(pcMap);
+                if (pointCheckDos != null && pointCheckDos.size() > 0) {
+                    retWarn.add("设备编号:" + checkItemsDo.getCheckitemcode() + ";设备名称:" + checkItemsDo.getCheckitemname());
+                } else {
                     this.removeById(id);
                 }
             }
         }
-        if(retWarn != null && retWarn.size()>0){
-            warnMes = String.join("\n",retWarn);
-            warnMes = warnMes + "\n"+"以上设备已存在点检记录不可删除;";
+        if (retWarn != null && retWarn.size() > 0) {
+            warnMes = String.join("\n", retWarn);
+            warnMes = warnMes + "\n" + "以上设备已存在点检记录不可删除;";
         }
         return warnMes;
     }
 
     /**
      * 备用设备列表
+     *
      * @return
      */
     @Override
@@ -65,21 +69,22 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
     @Override
     public void reportEquMessage() {
         //查询所有需要提醒的设备
-        List<CheckItemsDo> list = this.baseMapper.selectNeedReportEqu();
+        List<CheckItemsTypeVo> list = this.baseMapper.selectNeedReportEqu();
         //查询设备的工厂,三个工厂的设备管理员角色下的员工ID
         Set<String> tenantIds = list.stream().map(CheckItemsDo::getTenantid).collect(Collectors.toSet());
         Map<String, List<String>> equManager = new HashMap<>();
-        tenantIds.forEach(tenantId ->{
+        tenantIds.forEach(tenantId -> {
             List<String> userIdList = this.baseMapper.selectUserByTenantId(tenantId);
             equManager.put(tenantId, userIdList);
         });
 
         //根据设备的所属工厂给自己工厂的设备管理员发送消息
-        list.forEach(item->{
-            if(ObjectUtil.isNotEmpty(item.getTenantid())) {
+        list.forEach(item -> {
+            if (ObjectUtil.isNotEmpty(item.getTenantid())) {
                 //发送消息
                 CXCommonUtils.sendNotify("特种设备提醒",
-                        "特种设备【" + item.getCheckitemname() + "】预计提醒时间已到",
+                        "【设备年检提醒】,您好,有如下设备即将年检到期,请及时处理:" +
+                                "设备类型:【" + item.getTypeName() + "】,设备编号:【" + item.getCheckitemcode() + "】,设备名称:【" + item.getCheckitemname() + "】,年检日期:【" + DateUtil.format(item.getNextcheckdate(), "yyy-MM-dd") + "】",
                         null,
                         equManager.get(item.getTenantid()),
                         item.getId(),

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

@@ -0,0 +1,14 @@
+package com.rongwe.scentity.vo;
+
+import com.rongwe.scentity.domian.CheckItemsDo;
+import lombok.Data;
+
+/**
+ * @author :sc
+ * @since :2023/12/27
+ */
+@Data
+public class CheckItemsTypeVo extends CheckItemsDo {
+    //设备类型名称
+    private String typeName;
+}