Ver Fonte

邮件通知开关

skyline há 1 ano atrás
pai
commit
4e73b420ca

+ 6 - 1
admin/src/main/java/com/kym/admin/jobs/OfflineNotifyJob.java

@@ -31,6 +31,9 @@ public class OfflineNotifyJob {
     @Value("${kym.notify-email}")
     private String notifyEmail;
 
+    @Value("${kym.notify-email-switch}")
+    private boolean notifyEmailSwitch;
+
     public OfflineNotifyJob(StringRedisTemplate redisTemplate) {
         this.redisTemplate = redisTemplate;
     }
@@ -56,9 +59,11 @@ public class OfflineNotifyJob {
             list.forEach((k, v) -> sb.append(temp.formatted(k, StringUtils.join(v.stream().map(Map.Entry::getKey).sorted(Comparator.comparingInt(Integer::parseInt)).toList(), ","))));
             log.warn(sb.toString());
             // 格式化信息,发送邮件
-            MailUtil.send(notifyEmail, "【设备离线通知】", sb.toString(), false);
             redisTemplate.opsForZSet().remove(RedisKeys.OFFLINE, offlineList.toArray(Object[]::new));
             redisTemplate.opsForSet().add(RedisKeys.OFFLINE_EXPIRED, offlineList.toArray(String[]::new));
+            if (notifyEmailSwitch) {
+                MailUtil.send(notifyEmail, "【设备离线通知】", sb.toString(), false);
+            }
         }
 
     }

+ 1 - 0
admin/src/main/resources/application-dev.yml

@@ -120,3 +120,4 @@ spring:
 
 kym:
   notify-email: skyline@kuaiyuman.cn
+  notify-email-switch: true

+ 1 - 0
admin/src/main/resources/application-prod.yml

@@ -120,3 +120,4 @@ spring:
 
 kym:
   notify-email: zaizai@kuaiyuman.cn,skyline@kuaiyuman.cn
+  notify-email-switch: false

+ 1 - 1
common/pom.xml

@@ -133,7 +133,7 @@
         <dependency>
             <groupId>org.gavaghan</groupId>
             <artifactId>geodesy</artifactId>
-            <version>1.1.3</version>
+            <version>${geodesy.version.version}</version>
         </dependency>
 
     </dependencies>

+ 1 - 0
miniapp/src/main/resources/application-dev.yml

@@ -111,3 +111,4 @@ spring:
 
 kym:
   notify-email: skyline@kuaiyuman.cn
+  notify-email-switch: true

+ 1 - 0
miniapp/src/main/resources/application-prod.yml

@@ -111,3 +111,4 @@ spring:
 
 kym:
   notify-email: zaizai@kuaiyuman.cn,skyline@kuaiyuman.cn
+  notify-email-switch: false

+ 1 - 0
pom.xml

@@ -47,6 +47,7 @@
         <gson.version>2.10.1</gson.version>
         <jwt.version>4.4.0</jwt.version>
         <jjwt-api.version>0.11.5</jjwt-api.version>
+        <geodesy.version.version>1.1.3</geodesy.version.version>
     </properties>
 
     <dependencies>

+ 4 - 1
service/src/main/java/com/kym/service/platform/impl/PlatformNotifyServiceImpl.java

@@ -67,6 +67,9 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
     @Value("${kym.notify-email}")
     private String notifyEmail;
 
+    @Value("${kym.notify-email-switch}")
+    private boolean notifyEmailSwitch;
+
     public PlatformNotifyServiceImpl(ChargeOrderService chargeOrderService, ChargeService chargeService,
                                      AccountService accountService, WalletDetailService walletDetailService,
                                      MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
@@ -157,7 +160,7 @@ public class PlatformNotifyServiceImpl implements PlatformNotifyService {
                         .set(MonitorLog::getRecoverTime, LocalDateTime.now()).set(MonitorLog::getIsRecover, MonitorLog.IS_RECOVER_已恢复) // 设置为已恢复
                         .update();
             }
-            if (exist != null && exist > 0) {
+            if (exist != null && exist > 0 && notifyEmailSwitch) {
                 MailUtil.send(notifyEmail, "【设备上线通知】", "站点:%s,设备%s恢复上线".formatted(KymCache.INSTANCE.getStationNameByConnectorId(connectorStatusInfo.getConnectorId()), KymCache.INSTANCE.getShortIdByEquipmentIdOrConnectorId(connectorStatusInfo.getConnectorId())), false);
             }
         }