Ver código fonte

:pencil2: 拼写错误, 取消周六值日通知

Ritchie 1 ano atrás
pai
commit
677b34b394

+ 18 - 21
src/main/java/com/szwl/controller/ScheduledService.java

@@ -106,48 +106,45 @@ public class ScheduledService {
 //        }
 //    }
 
-    // 值日通知1
-    // 每天8:20执行一次
-    @Scheduled(cron = "0 20 8 * * ?")
+    // 值日通知
+    // 每天8:25执行一次
+    @Scheduled(cron = "0 25 8 * * ?")
     public void scheduled() {
         if (isDo()) {
             Calendar calendar = Calendar.getInstance();
             int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
-            // 如果不是周日 1
+            // 如果不是周日 1,周六 7
             if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) {
                 tDepartmentService.onTime();
             }
         }
     }
 
-    private Boolean isDo() {
-        try {
-            String hostAddress = InetAddress.getLocalHost().getHostAddress();
-            // 弹性112.74.63.148服务器的私网ip
-            if (hostAddress.equals("10.0.0.153")) {
-                return true;
-            } else {
-                return false;
-            }
-        } catch (UnknownHostException e) {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
     // 值日通知2
     // 每天17:55执行一次
     @Scheduled(cron = "0 55 17 * * ?")
     public void scheduled2() {
         if (isDo()) {
             Calendar calendar = Calendar.getInstance();
-            int number = calendar.get(Calendar.DAY_OF_WEEK);
-            if (number != 1) {
+            int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
+            // 如果不是周日 1,周六 7
+            if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) {
                 tDepartmentService.onTime2();
             }
         }
     }
 
+    private Boolean isDo() {
+        try {
+            String hostAddress = InetAddress.getLocalHost().getHostAddress();
+            // 弹性112.74.63.148服务器的私网ip
+            return hostAddress.equals("10.0.0.153");
+        } catch (UnknownHostException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
     // 设备状态检测
     @Scheduled(cron = "0 */30 * * * ?")
     public void checkEquipmentStatus() {

+ 2 - 2
src/main/java/com/szwl/controller/TMessageCodeController.java

@@ -74,7 +74,7 @@ public class TMessageCodeController {
 //        String SZ = "Sunzee";
         String SC = "Sevencloud";
         String AETI = "Portalmcc";
-        String companyType = "";
+        String companyType;
         if (SC.equals(hostName)) {
             companyType = "1";
         } else {
@@ -143,7 +143,7 @@ public class TMessageCodeController {
             ifForeign = "0";
         }
         String SZ = "Sunzee";
-        String companyType = "";
+        String companyType;
         if (StringUtils.isNotEmpty(hostName) && SZ.equals(hostName)) {
             companyType = "0";
         } else {

+ 27 - 23
src/main/java/com/szwl/service/impl/TMessageCodeServiceImpl.java

@@ -30,6 +30,7 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     TMessageCodeMapper tMessageCodeMapper;
 
     private static final String appid = "07784f5fedb508046c841b391005b7de";
+
     /*
      * 发送短信验证码
      * */
@@ -43,8 +44,8 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
             JSONObject sult = JSONObject.parseObject(result);
             Object msg = sult.get("msg");
             Object mobile = sult.get("mobile");
-            retu = msg+":" + phone;
-            if(mobile!=null){
+            retu = msg + ":" + phone;
+            if (mobile != null) {
                 TMessageCode tMessageCode = new TMessageCode();
                 tMessageCode.setType(type);
                 tMessageCode.setCode(code);
@@ -54,13 +55,14 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
                 tMessageCode.setStatus("0");
                 int insert = tMessageCodeMapper.insert(tMessageCode);
             }
-            int a= 0;
+            int a = 0;
         } catch (Exception e) {
 
         }
 
         return retu;
     }
+
     /*
      * 发送邮箱验证码
      * */
@@ -68,10 +70,10 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     public String sentEmail(String type, String email) {
         String code = addCode();
 //        String subject = "Verification code message";
-        String subject =getSubject(type);
+        String subject = getSubject(type);
         String contnet = "";
-        contnet = getContnet(type,code);
-        new MailUtil().send(email,subject,contnet);
+        contnet = getContent(type, code);
+        new MailUtil().send(email, subject, contnet);
         TMessageCode tMessageCode = new TMessageCode();
         tMessageCode.setType(type);
         tMessageCode.setCode(code);
@@ -86,9 +88,9 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     @Override
     public String sendEmailAbroad(String type, String email) {
         String code = addCode();
-        String contnet = "";
-        contnet = getContnet(type,code);
-        new SampleMail().sendAuthCode(email, contnet);
+        String content;
+        content = getContent(type, code);
+        new SampleMail().sendAuthCode(email, content);
         TMessageCode tMessageCode = new TMessageCode();
         tMessageCode.setType(type);
         tMessageCode.setCode(code);
@@ -112,9 +114,9 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     @Override
     public String sendEmailPortalmcc(String type, String email) {
         String code = addCode();
-        String contnet = "";
-        contnet = getContnet(type,code);
-        new SampleMail().sendAuthCodePortalmcc(email, contnet);
+        String content;
+        content = getContent(type, code);
+        new SampleMail().sendAuthCodePortalmcc(email, content);
         TMessageCode tMessageCode = new TMessageCode();
         tMessageCode.setType(type);
         tMessageCode.setCode(code);
@@ -129,24 +131,26 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     //邮件标题
     private String getSubject(String type) {
         String subject = "";
-        if(type.equals("0")||type.equals("1")){
+        if (type.equals("0") || type.equals("1")) {
             subject = "Verification code message";
         }
         return subject;
     }
+
     //邮件内容
-    private String getContnet(String type, String code) {
-        StringBuffer contnet = new StringBuffer();
-        if(type.equals("0")||type.equals("1")){
+    private String getContent(String type, String code) {
+        StringBuffer content = new StringBuffer();
+        if (type.equals("0") || type.equals("1")) {
 
-            String str1="Dear customer<br>" +
+            String str1 = "Dear customer<br>" +
                     "<br>" +
                     "Hello, your verification code is: ";
 //            String str2=",please enter it within 3 minutes.";
-            contnet.append(str1).append(code);
+            content.append(str1).append(code);
         }
-        return contnet.toString();
+        return content.toString();
     }
+
     //生成6位随机数字
     private String addCode() {
         int code = (int) ((Math.random() * 9 + 1) * 100000);
@@ -156,11 +160,11 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
 
     private String getMessage(String companyType, String code) {
         String message = "";
-        if(StringUtils.isNotEmpty(companyType)&&companyType.equals("0")){
-            message = "【申泽智能】您好,您的验证码是"+code+",请于3分钟内输入。";
+        if (StringUtils.isNotEmpty(companyType) && companyType.equals("0")) {
+            message = "【申泽智能】您好,您的验证码是" + code + ",请于3分钟内输入。";
         }
-        if(StringUtils.isNotEmpty(companyType)&&companyType.equals("1")){
-            message = "【七云科技】您好,您的验证码是"+code+",请于3分钟内输入。";
+        if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
+            message = "【七云科技】您好,您的验证码是" + code + ",请于3分钟内输入。";
         }
         return message;
     }