You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AEG_Development/AegChange3_mxJPO.java

108 lines
6.3 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import com.dassault_systemes.enovia.changerequest.impl.AffectedItem;
import com.dassault_systemes.enovia.enterprisechangemgt.common.ChangeAction;
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 AegChange3_mxJPO {
private static final Logger LOGGER = Logger.getLogger(AegChange3_mxJPO.class.getName());
private static final String SEND_EMAIL = "aeg-scan@csge.com";
private static final String SEND_PASSWORD = "abcd-1234";
private static final String SMTP_HOST = "smtp.qiye.aliyun.com";
private static final String SMTP_PORT = "25";
private static final String EMAIL = "1654607107@qq.com";
public void AegChangeNotify(Context context, String[] args) throws Exception {
String caId = args[0];
LOGGER.info("caId == > " + caId);
// String getChangeType = "print bus " + caId + " select type dump |";
// String changeType = MqlUtil.mqlCommand(context, getChangeType);
//
// if("Change Action".equals(changeType)){
//
// String getCAInfo = "print bus " + caId + " select name attribute[Synopsis] description attribute[XP_ChangeAction_Ext.DistributionPersonList] attribute[Originator] dump |";
// String caInfo = MqlUtil.mqlCommand(context, getCAInfo);
//
// String[] caInfoItem = caInfo.split("\\|");
//
// }
ChangeAction changeAction = new ChangeAction("");
changeAction.getAffectedItems(context);
Map<String, String> map = new HashMap<>();
map.put("projectName", "123");
map.put("taskName", "123");
map.put("description", "123");
map.put("DocumentRecipient", "123");
map.put("taskOwner", "123");
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\u5bb3Dassault 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();
}
}
}