package com.szwl.util;
import com.szwl.model.utils.MailUtil;
import com.szwl.model.utils.SampleMail;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@Slf4j
public class WechatSendUtil {
/**
* 发送邮件
* @param email
* @param name
* @param zoneId
*/
public static void sentEmail(String email, String name, String zoneId, String machineType) {
String machineTypeStr = "";
if (StringUtils.isEmpty(zoneId)) {
zoneId = "Asia/Shanghai";
}
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 = " Machine name: ";
String str2 = "
" + " Error message: ";
String sContent = "Abnormal shutdown/The network is disconnected.";
String str3 = "
" + " Time&Date: ";
// String nowDateUTC = DateTimeFmtUtil.getNowDateUTC();
String timeByZoneID = TimezoneFmtUtil.getTimeByZoneID(zoneId);
String str4 = "
" + "
" + "Dear customer:
";
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.
";
String str6 = "
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.
" +
"
" +
" Thank you for choosing our machine!
" +
"
" +
"
" +
"Best Regards.
" +
"Cotton Candy Service Team";
content.append(str1).append(name).append(str2).append(sContent).append(str3).append(timeByZoneID).append(str4).append(str5).append(str6);
MailUtil mailUtil = new MailUtil();
mailUtil.send(email, subject, content.toString());
System.out.println("邮件发送成功");
}
/**
* 发送邮件
* @param email
* @param name
* @param zoneId
*/
public static void sentEmail(String email, String name, String zoneId, String machineType, String alarmContent) {
String machineTypeStr = "";
if (StringUtils.isEmpty(zoneId)) {
zoneId = "Asia/Shanghai";
}
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 = " Machine name: ";
String str2 = "
" + " Error message: ";
String str3 = "
" + " Time&Date: ";
String timeByZoneID = TimezoneFmtUtil.getTimeByZoneID(zoneId);
String str4 = "
" + "
" + "Dear customer:
";
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.
";
String str6 = "
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.
" +
"
" +
" Thank you for choosing our machine!
" +
"
" +
"
" +
"Best Regards.
" +
"Cotton Candy Service Team";
content.append(str1).append(name).append(str2).append(alarmContent).append(str3).append(timeByZoneID).append(str4).append(str5).append(str6);
// MailUtil mailUtil = new MailUtil();
// mailUtil.send(email, subject, content.toString());
new SampleMail().sendAuthCode(email, content.toString(), subject);
System.out.println("邮件发送成功");
}
/**
* 发送设备上下线邮件
* @param email
* @param name
* @param zoneId
*/
public static void sentEmail(String email, String name, String zoneId, String machineType, Integer eqeStatus) {
String machineTypeStr = "";
if (StringUtils.isEmpty(zoneId)) {
zoneId = "Asia/Shanghai";
}
switch (machineType) {
case "0":
machineTypeStr = "Cotton Candy"; // 棉花糖
break;
case "1":
machineTypeStr = "Popcorn"; // 爆米花
break;
case "2":
machineTypeStr = "Ice Cream"; // 冰淇淋
break;
default:
machineTypeStr = "";
}
String eqeStatusStr = "";
String eqeStatusContent = "";
if (eqeStatus == 0) {
eqeStatusStr = "Machine offline";
eqeStatusContent = "Your machine is offline.";
} else {
eqeStatusStr = "Machine online";
eqeStatusContent = "Your machine is online!";
}
String subject = eqeStatusStr + " message from " + machineTypeStr + " Machine";
StringBuilder content = new StringBuilder();
String str1 = " Machine name: ";
String str3 = "
" + " Time&Date: ";
String timeByZoneId = TimezoneFmtUtil.getTimeByZoneID(zoneId);
String str4 = "
" + "
" + "Dear customer:
";
String str5 = eqeStatusContent + " This email is just a reminder, you don't need to reply.
";
String str6 = "
" + " Thank you for choosing our machine!
" +
"
" +
"
" +
"Best Regards.
" +
"Cotton Candy Service Team";
content.append(str1).append(name).append(str3).append(timeByZoneId).append(str4).append(str5).append(str6);
MailUtil mailUtil = new MailUtil();
mailUtil.send(email, subject, content.toString());
// new SampleMail().sendAuthCode(email, content.toString(), subject);
System.out.println("邮件发送成功");
}
}