Browse Source

:art: 不同设备的邮件信息设备名

Ritchie 1 year ago
parent
commit
09a87aa214

+ 8 - 4
src/main/java/com/szwl/service/impl/TEquipmentServiceImpl.java

@@ -333,6 +333,10 @@ public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipm
                     if(StringUtils.isEmpty(name)) {
                         name = equipment.getClientId().substring(equipment.getClientId().length() - 6);
                     }
+                    String machineType = equipment.getMachineType();
+                    if (StringUtils.isNotEmpty(machineType)) {
+                        machineType = "0";
+                    }
                     if(wechat != null) {
                         // 有绑定微信的话发公众号
                         String openId = wechat.getOpenId();
@@ -343,11 +347,11 @@ public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipm
                             if(StringUtils.isNotEmpty(messageReceiver)) {
                                 String[] split = messageReceiver.split(",");
                                 for (String s : split) {
-                                    WechatSendUtil.sentEmail(s, name, timeZone);
+                                    WechatSendUtil.sentEmail(s, name, timeZone, machineType);
                                 }
                             } else {
                                 if(StringUtils.isNotEmpty(admin.getEmail())){
-                                    WechatSendUtil.sentEmail(admin.getEmail(), name, timeZone);
+                                    WechatSendUtil.sentEmail(admin.getEmail(), name, timeZone, machineType);
                                 }
                             }
                         }
@@ -361,11 +365,11 @@ public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipm
                             if(StringUtils.isNotEmpty(messageReceiver)) {
                                 String[] split = messageReceiver.split(",");
                                 for (String s : split) {
-                                    WechatSendUtil.sentEmail(s, name, timeZone);
+                                    WechatSendUtil.sentEmail(s, name, timeZone, machineType);
                                 }
                             } else {
                                 if(StringUtils.isNotEmpty(admin.getEmail())){
-                                    WechatSendUtil.sentEmail(admin.getEmail(), name, timeZone);
+                                    WechatSendUtil.sentEmail(admin.getEmail(), name, timeZone, machineType);
                                 }
                             }
 

+ 17 - 3
src/main/java/com/szwl/util/WechatSendUtil.java

@@ -101,8 +101,22 @@ public class WechatSendUtil {
      * @param name
      * @param zoneID
      */
-    public static void sentEmail(String email, String name, String zoneID) {
-        String subject = "Error message from Cotton Candy Machine";
+    public static void sentEmail(String email, String name, String zoneID, String machineType) {
+        String machineTypeStr = "";
+        switch (machineType) {
+            case "0":
+                machineTypeStr = "Cotton Candy";  // 棉花糖
+                break;
+            case "1":
+                machineTypeStr = "Popcorn";  // 爆米花
+                break;
+            case "2":
+                machineTypeStr = "Ice Cream";  // 冰淇淋
+                break;
+            default:
+                machineTypeStr = "";
+        }
+        String subject = "Error message from " + machineTypeStr + " Machine";
         StringBuffer content = new StringBuffer();
         String str1 = " <b>Machine name: </b>";
         String str2 = "<br>" + " <b>Error message: </b>";
@@ -111,7 +125,7 @@ public class WechatSendUtil {
 //        String nowDateUTC = DateTimeFmtUtil.getNowDateUTC();
         String timeByZoneID = TimezoneFmtUtil.getTimeByZoneID(zoneID);
         String str4 = "<br>" + "<br>" + "Dear customer:<br>";
-        String str5 = " This is an automatic-sent mail to inform you that there is an error occurred on one of your Cotton Candy machines, please kindly check the details as above.<br>";
+        String str5 = " This is an automatic-sent mail to inform you that there is an error occurred on one of your " + machineTypeStr + " machines, please kindly check the details as above.<br>";
         String str6 = " <br>You don't have to reply this mail. What you need to do is to follow the instructions on the touch screen to clear the error and recover the machine. If there is any question or more information you need. Please do not be hesitated to contact your distributor.<br>" +
                 "<br>" +
                 " Thank you for choosing our machine!<br>" +