|
|
import com.matrixone.apps.domain.util.MqlUtil;
|
|
|
import matrix.db.Context;
|
|
|
|
|
|
import javax.mail.*;
|
|
|
import javax.mail.internet.InternetAddress;
|
|
|
import javax.mail.internet.MimeMessage;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Properties;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
public class AegChange2_mxJPO {
|
|
|
|
|
|
private static final Logger LOGGER = Logger.getLogger(AegChange2_mxJPO.class.getName());
|
|
|
private static final String SEND_EMAIL = "aegplm@aeg-imc.com";
|
|
|
private static final String SEND_PASSWORD = "Aeg-1887";
|
|
|
private static final String SMTP_HOST = "smtp.partner.outlook.cn";
|
|
|
private static final String SMTP_PORT = "587";
|
|
|
private static final String EMAIL = "beiqi.xi@aeg-imc.com";
|
|
|
|
|
|
public void AegChangeNotify(Context context, String[] args) throws Exception {
|
|
|
String caId = args[0];
|
|
|
LOGGER.info("caId == > " + caId);
|
|
|
|
|
|
String getChangeTypeAndValue = "print bus " + caId + " select attribute[XP_ChangeAction_Ext.DistributionPersonList].value type dump |";
|
|
|
String changeTypeAndValue = MqlUtil.mqlCommand(context, getChangeTypeAndValue);
|
|
|
LOGGER.info("changeTypeAndValue ==> " + changeTypeAndValue);
|
|
|
|
|
|
String[] changInfoSplit = changeTypeAndValue.split("\\|");
|
|
|
LOGGER.info("changInfoSplit0 ==> " + changInfoSplit[0]);
|
|
|
LOGGER.info("changInfoSplit1 ==> " + changInfoSplit[1]);
|
|
|
|
|
|
if("Change Action".equals(changInfoSplit[1]) && !"".equals(changInfoSplit[0])){
|
|
|
|
|
|
String getCAInfo = "print bus " + caId + " select name attribute[Synopsis] description attribute[XP_ChangeAction_Ext.DistributionPersonList] attribute[Originator] dump |";
|
|
|
String caInfo = MqlUtil.mqlCommand(context, getCAInfo);
|
|
|
LOGGER.info("caInfo ==> " + caInfo);
|
|
|
|
|
|
String[] caInfoItem = caInfo.split("\\|");
|
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("projectName", caInfoItem[0]);
|
|
|
map.put("taskName", caInfoItem[1]);
|
|
|
map.put("description", caInfoItem[2]);
|
|
|
map.put("DocumentRecipient", caInfoItem[3]);
|
|
|
map.put("taskOwner", caInfoItem[4]);
|
|
|
|
|
|
send(map);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void send(Map<String, String> itemMap){
|
|
|
LOGGER.info("=============> + <=================");
|
|
|
|
|
|
Properties properties = new Properties();
|
|
|
properties.put("mail.smtp.auth", "true");
|
|
|
properties.put("mail.smtp.starttls.enable", "true");
|
|
|
properties.put("mail.smtp.host", SMTP_HOST);
|
|
|
properties.put("mail.smtp.port", SMTP_PORT);
|
|
|
properties.put("mail.smtp.ssl.protocols", "TLSv1.2");
|
|
|
|
|
|
Session session = Session.getInstance(properties,
|
|
|
new javax.mail.Authenticator() {
|
|
|
protected PasswordAuthentication getPasswordAuthentication() {
|
|
|
return new PasswordAuthentication(SEND_EMAIL, SEND_PASSWORD);
|
|
|
}
|
|
|
});
|
|
|
session.setDebug(true);
|
|
|
|
|
|
Message message = new MimeMessage(session);
|
|
|
try {
|
|
|
message.setFrom(new InternetAddress(SEND_EMAIL));
|
|
|
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(EMAIL));
|
|
|
|
|
|
String body = "<div style=\"text-align: center;margin-left:12px;margin-right: 12px;margin-top:100px;background-color:#005685;\n" +
|
|
|
" ;border-radius: 30px\">" +
|
|
|
" <div style=\"padding-top: 30px;padding-left: 50px;padding-right: 50px\">\n" +
|
|
|
" <p style=\"text-align: center;color:azure;font-size: xx-large\">" + itemMap.get("projectName") + "</p>\n" +
|
|
|
" </div>" +
|
|
|
" <div style=\"display: flex;justify-content: center;align-items: center\">\n" +
|
|
|
" <div style=\"padding-left: 30px;background-color: white;border-radius: 10px;height: 260px;min-width:400px;padding-top: 30px;\">\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u4efb\u52a1\u540d\u79f0: " + itemMap.get("taskName") + "</p>\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u4efb\u52a1\u63cf\u8ff0: " + itemMap.get("description") + "</p>\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u4efb\u52a1\u6240\u6709\u8005: " + itemMap.get("taskOwner") + "</p>\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u6587\u4ef6\u63a5\u6536\u4eba: " + itemMap.get("DocumentRecipient") + "</p>\n" +
|
|
|
" <a href=\"https://plm.aegpm.com/3ddashboard\" style=\"font-size:medium\">查看任务</a>\n" +
|
|
|
" </div>\n" +
|
|
|
" </div>\n" +
|
|
|
" <div style=\" padding-top:10px;color: white;padding-left: 20px;padding-right: 20px\" >\n" +
|
|
|
" <p>\u672c\u90ae\u4ef6\u53ca\u6240\u6709\u9644\u4ef6\u4ec5\u4f9b\u6536\u4ef6\u5730\u5740\u4e2d\u7684\u4e2a\u4eba\u6216\u5b9e\u4f53\u4f7f\u7528\uff0c\u8fd9\u4e9b\u5185\u5bb9\u5747\u5c5e\u673a\u5bc6\u4fe1\u606f\u5e76\u6216\u8bbe\u6709\u6743\u9650</p>\n" +
|
|
|
" </div>\n" +
|
|
|
" <div style=\"display: flex;justify-content: center;align-items: center;margin-bottom: 50px\">\n" +
|
|
|
" <p style=\"text-align: left;margin-left:50px;margin-right: 50px;color:lightgray;font-size: small\">\u5982\u679c\u60a8\u4e0d\u662f\u4efb\u4f55\u6307\u5b9a\u7684\u6536\u4ef6\u4eba\u6216\u8bef\u6536\u5230\u672c\u90ae\u4ef6,<br>\n" +
|
|
|
" (i) \u60a8\u4e0d\u80fd\u9605\u8bfb\u3001\u6cc4\u6f0f\u6216\u590d\u5236\u672c\u90ae\u4ef6;<br>\n" +
|
|
|
" (ii) \u8bf7\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u901a\u77e5\u60a8\u6536\u4ef6\u7684\u53d1\u4ef6\u4eba\u5e76\u5220\u9664\u672c\u90ae\u4ef6\u53ca\u6240\u6709\u9644\u4ef6;<br>\n" +
|
|
|
" (iii) \u5bf9\u4e8e\u56e0\u4f7f\u7528\u6216\u4f9d\u636e\u672c\u90ae\u4ef6\u800c\u5f15\u8d77\u7684\u4efb\u4f55\u635f\u5931\u6216\u635f\u5bb3,Dassault Systemes \u6982\u4e0d\u8d1f\u8d23\u6216\u627f\u62c5\u8d23\u4efb。</p>\n" +
|
|
|
" </div>\n" +
|
|
|
" </div>";
|
|
|
message.setSubject("subject");
|
|
|
message.setContent(body, "text/html;charset=utf-8");
|
|
|
Transport.send(message);
|
|
|
} catch (MessagingException e) {
|
|
|
throw new RuntimeException();
|
|
|
}
|
|
|
}
|
|
|
}
|