Przeglądaj źródła

feature 代码优化

xiahan 1 rok temu
rodzic
commit
a72108310b

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

@@ -309,6 +309,10 @@ public class SaveConstans {
          * 作业延期提醒
          */
         public static final String PROCESSDELAY_TITLE = "订单作业未按计划完成";
+        /**
+         * 特种设备提醒
+         */
+        public static final String SPECIALEQUIPMENT_TITLE="特种设备提醒";
     }
 
     public static class NotifyContent {
@@ -421,6 +425,14 @@ public class SaveConstans {
          * 作业延期提醒
          */
         public static final String PROCESSDELAY_CONTENT = "订单【%s】有作业未按计划完工,请及时调整计划";
+        /**
+         * 特种设备提醒内容前缀
+         */
+        public static final String SPECIALEQUIPMENT_CONTENT_PREFIX="【设备年检提醒】,您好,有如下设备即将年检到期,请及时处理";
+        /**
+         * 特种设备提醒内容
+         */
+        public static final String SPECIALEQUIPMENT_CONTENT="设备类型:【%s】,设备编号:【%s】,设备名称:【%s】,年检日期:【%s】";
     }
 
     /**

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

@@ -18,6 +18,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.NotifyTitle.SPECIALEQUIPMENT_TITLE;
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.SPECIALEQUIPMENT;
+
 @Service("checkItemsService")
 public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItemsDo> implements CheckItemsService {
 
@@ -77,7 +82,23 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
             List<String> userIdList = this.baseMapper.selectUserByTenantId(tenantId);
             equManager.put(tenantId, userIdList);
         });
-
+        // 多个设备 只给收件人发送一条信息
+//        equManager.forEach((k,v)->{
+//            String content = list.stream().filter(data->k.equals(data.getTenantid())).map(item ->{
+//                String typeName = ObjectUtil.isNotEmpty(item.getTypeName()) ? item.getTypeName() : "";
+//                String checkItemCode = ObjectUtil.isNotEmpty(item.getCheckitemcode()) ? item.getCheckitemcode() : "";
+//                String checkItemName = ObjectUtil.isNotEmpty(item.getCheckitemname()) ? item.getCheckitemname() : "";
+//                String nextCheckDate = ObjectUtil.isNotEmpty(item.getNextcheckdate()) ? DateUtil.format(item.getNextcheckdate(), "yyy-MM-dd") : "";
+//                return  String.format(SPECIALEQUIPMENT_CONTENT,typeName,checkItemCode,checkItemName,nextCheckDate);
+//            }).collect(Collectors.joining("</br>"));
+//            //发送消息
+//            CXCommonUtils.sendNotify(SPECIALEQUIPMENT_TITLE,
+//                    SPECIALEQUIPMENT_CONTENT_PREFIX +  content,
+//                    null,
+//                    equManager.get(k.getTenantid()),
+//                    item.getId(),
+//                    SPECIALEQUIPMENT);
+//        });
         //根据设备的所属工厂给自己工厂的设备管理员发送消息
         list.forEach(item -> {
             if (ObjectUtil.isNotEmpty(item.getTenantid())) {
@@ -86,15 +107,13 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
                 String checkItemName = ObjectUtil.isNotEmpty(item.getCheckitemname()) ? item.getCheckitemname() : "";
                 String nextCheckDate = ObjectUtil.isNotEmpty(item.getNextcheckdate()) ? DateUtil.format(item.getNextcheckdate(), "yyy-MM-dd") : "";
 
-
                 //发送消息
-                CXCommonUtils.sendNotify("特种设备提醒",
-                        "【设备年检提醒】,您好,有如下设备即将年检到期,请及时处理:" +
-                                "设备类型:【" + typeName + "】,设备编号:【" + checkItemCode + "】,设备名称:【" + checkItemName + "】,年检日期:【" + nextCheckDate + "】",
+                CXCommonUtils.sendNotify(SPECIALEQUIPMENT_TITLE,
+                        SPECIALEQUIPMENT_CONTENT_PREFIX + String.format(SPECIALEQUIPMENT_CONTENT,typeName,checkItemCode,checkItemName,nextCheckDate),
                         null,
                         equManager.get(item.getTenantid()),
                         item.getId(),
-                        "specialequipment");
+                        SPECIALEQUIPMENT);
             }
         });