浏览代码

发送短信相关

yjj 1 年之前
父节点
当前提交
f2eea99801
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. 12 10
      src/main/java/com/example/demo/demos/web/service/impl/EcsInfoServiceImpl.java

+ 12 - 10
src/main/java/com/example/demo/demos/web/service/impl/EcsInfoServiceImpl.java

@@ -30,14 +30,17 @@ public class EcsInfoServiceImpl extends ServiceImpl<EcsInfoMapper, EcsInfo> impl
 
         List<EcsInfo> list = new ArrayList<>();
         ecsInfos.forEach(ecsInfo -> {
-            String endOfExpiration = DateUtil.parseDateToStr(DateUtil.YYYY_MM_DD, ecsInfo.getNotAfter());
-            String nowDateStr = DateUtil.parseDateToStr(DateUtil.YYYY_MM_DD, DateUtil.getNowDate());
+            if (ecsInfo.getNotAfter() != null) {
 
-            Long[] longs = DateUtil.computeDate(nowDateStr, endOfExpiration);
-            Long month = longs[0];
-            Long day = longs[1];
-            if (month == 0 && day < 20) {
-                list.add(ecsInfo);
+                String endOfExpiration = DateUtil.parseDateToStr(DateUtil.YYYY_MM_DD, ecsInfo.getNotAfter());
+                String nowDateStr = DateUtil.parseDateToStr(DateUtil.YYYY_MM_DD, DateUtil.getNowDate());
+
+                Long[] longs = DateUtil.computeDate(nowDateStr, endOfExpiration);
+                Long month = longs[0];
+                Long day = longs[1];
+                if (month == 0 && day < 20) {
+                    list.add(ecsInfo);
+                }
             }
         });
 
@@ -47,10 +50,9 @@ public class EcsInfoServiceImpl extends ServiceImpl<EcsInfoMapper, EcsInfo> impl
         if (!list.isEmpty()) {
             for (String number : Constants.SEND_MSG_NUMBER) {
                 list.forEach(i -> {
-                    JSONObject entries = new JSONObject();
-                    entries.set("name",i.getUrl());
+                    String str = i.getUrl();
                     try {
-                        SMSUtil.sendMsg(number,"天目智能科技","SMS_475345133",entries.toString());
+                        SMSUtil.sendMsg(number,"天目智能科技","SMS_475345133","{\"name\":\""+str+"\"}");
                     } catch (Exception e) {
                         log.error("短信发送失败:{}",e);
                         throw new RuntimeException(e);