|
|
import com.matrixone.apps.domain.DomainObject;
|
|
|
import com.matrixone.apps.domain.DomainRelationship;
|
|
|
import com.matrixone.apps.domain.util.ContextUtil;
|
|
|
import com.matrixone.apps.domain.util.FrameworkException;
|
|
|
import com.matrixone.apps.domain.util.MqlUtil;
|
|
|
import matrix.db.Context;
|
|
|
import matrix.db.JPO;
|
|
|
import matrix.util.MatrixException;
|
|
|
import matrix.util.StringList;
|
|
|
|
|
|
import javax.mail.*;
|
|
|
import javax.mail.internet.InternetAddress;
|
|
|
import javax.mail.internet.MimeMessage;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
public class AegChange5_mxJPO {
|
|
|
|
|
|
private static final Logger LOGGER = Logger.getLogger(AegChange2_mxJPO.class.getName());
|
|
|
private static final SimpleDateFormat NEW_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
|
|
|
|
|
|
private static final String IBC = "plm.ibc";
|
|
|
private static final String LV = "plm.lv";
|
|
|
private static final String RMU = "plm.rmu";
|
|
|
private static final String PURCHASE = "purchase.plm";
|
|
|
private static final String QUALITY = "quality.PLM";
|
|
|
|
|
|
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";
|
|
|
|
|
|
String projectSpaceName = "";
|
|
|
|
|
|
StringList publicAccountList = null;
|
|
|
Map treeMap = null;
|
|
|
Map purchaseMap = null;
|
|
|
Map qualityMap = null;
|
|
|
Map ibcMap = null;
|
|
|
Map lvMap = null;
|
|
|
Map rmuMap = null;
|
|
|
|
|
|
public AegChange5_mxJPO(){
|
|
|
publicAccountList = new StringList();
|
|
|
publicAccountList.add("plm.ibc");
|
|
|
publicAccountList.add("plm.lv");
|
|
|
publicAccountList.add("plm.rmu");
|
|
|
publicAccountList.add("quality.PLM");
|
|
|
publicAccountList.add("purchase.plm");
|
|
|
|
|
|
treeMap = new TreeMap();
|
|
|
treeMap.put("","");
|
|
|
treeMap.put("li.su_Purchase","li.su_Purchase");
|
|
|
treeMap.put("feng.shen_Purchase","feng.shen_Purchase");
|
|
|
treeMap.put("chuanyong.hu_Purchase","chuanyong.hu_Purchase");
|
|
|
treeMap.put("dongmei.tang_Purchase","dongmei.tang_Purchase");
|
|
|
treeMap.put("lilin.fu_Purchase","lilin.fu_Purchase");
|
|
|
treeMap.put("xiaoyi.liu_Purchase","xiaoyi.liu_Purchase");
|
|
|
treeMap.put("wei.zhang_Quality","wei.zhang_Quality");
|
|
|
treeMap.put("xiangdong.yu_Quality","xiangdong.yu_Quality");
|
|
|
treeMap.put("dong.zhu_Quality","dong.zhu_Quality");
|
|
|
treeMap.put("ge.zhang_Quality","ge.zhang_Quality");
|
|
|
treeMap.put("lei.wang_Quality","lei.wang_Quality");
|
|
|
treeMap.put("ruifu.wu_Quality","ruifu.wu_Quality");
|
|
|
treeMap.put("xiaojun.wei_Quality","xiaojun.wei_Quality");
|
|
|
treeMap.put("xicheng.chen_Quality","xicheng.chen_Quality");
|
|
|
treeMap.put("lin.shen_Quality","lin.shen_Quality");
|
|
|
treeMap.put("vincent.zhao_IBC","vincent.zhao_IBC");
|
|
|
treeMap.put("yu.wang_IBC","yu.wang_IBC");
|
|
|
treeMap.put("shenfeng.xu_IBC","shenfeng.xu_IBC");
|
|
|
treeMap.put("hao.chen_LV","hao.chen_LV");
|
|
|
treeMap.put("qiang.he_LV","qiang.he_LV");
|
|
|
treeMap.put("baoqiang.chen_LV","baoqiang.chen_LV");
|
|
|
treeMap.put("yan.guo_LV","yan.guo_LV");
|
|
|
treeMap.put("delv.qi_LV","delv.qi_LV");
|
|
|
treeMap.put("fugao.he_RMU","fugao.he_RMU");
|
|
|
treeMap.put("yan.gu_RMU","yan.gu_RMU");
|
|
|
|
|
|
purchaseMap = new HashMap();
|
|
|
purchaseMap.put("li.su_Purchase","li.su_Purchase");
|
|
|
purchaseMap.put("feng.shen_Purchase","feng.shen_Purchase");
|
|
|
purchaseMap.put("chuanyong.hu_Purchase","chuanyong.hu_Purchase");
|
|
|
purchaseMap.put("dongmei.tang_Purchase","dongmei.tang_Purchase");
|
|
|
purchaseMap.put("lilin.fu_Purchase","lilin.fu_Purchase");
|
|
|
purchaseMap.put("xiaoyi.liu_Purchase","xiaoyi.liu_Purchase");
|
|
|
|
|
|
qualityMap = new HashMap();
|
|
|
qualityMap.put("wei.zhang_Quality","wei.zhang_Quality");
|
|
|
qualityMap.put("xiangdong.yu_Quality","xiangdong.yu_Quality");
|
|
|
qualityMap.put("dong.zhu_Quality","dong.zhu_Quality");
|
|
|
qualityMap.put("ge.zhang_Quality","ge.zhang_Quality");
|
|
|
qualityMap.put("lei.wang_Quality","lei.wang_Quality");
|
|
|
qualityMap.put("ruifu.wu_Quality","ruifu.wu_Quality");
|
|
|
qualityMap.put("xiaojun.wei_Quality","xiaojun.wei_Quality");
|
|
|
qualityMap.put("xicheng.chen_Quality","xicheng.chen_Quality");
|
|
|
qualityMap.put("lin.shen_Quality","lin.shen_Quality");
|
|
|
|
|
|
ibcMap = new HashMap();
|
|
|
ibcMap.put("vincent.zhao_IBC","vincent.zhao_IBC");
|
|
|
ibcMap.put("yu.wang_IBC","yu.wang_IBC");
|
|
|
ibcMap.put("shenfeng.xu_IBC","shenfeng.xu_IBC");
|
|
|
|
|
|
lvMap = new HashMap();
|
|
|
lvMap.put("hao.chen_LV","hao.chen_LV");
|
|
|
lvMap.put("qiang.he_LV","qiang.he_LV");
|
|
|
lvMap.put("baoqiang.chen_LV","baoqiang.chen_LV");
|
|
|
lvMap.put("yan.guo_LV","yan.guo_LV");
|
|
|
lvMap.put("delv.qi_LV","delv.qi_LV");
|
|
|
|
|
|
rmuMap = new HashMap();
|
|
|
rmuMap.put("fugao.he_RMU","fugao.he_RMU");
|
|
|
rmuMap.put("yan.gu_RMU","yan.gu_RMU");
|
|
|
}
|
|
|
|
|
|
public StringList isPublicAccountTaskEditable(Context context, String[] args) throws Exception {
|
|
|
Map programMap = JPO.unpackArgs(args);
|
|
|
List list = (List) programMap.get("objectList");
|
|
|
StringList stringList = new StringList();
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map map = (Map) list.get(i);
|
|
|
String itemId = (String) map.get("id");
|
|
|
|
|
|
String getTypeInfo = "print bus " + itemId + " select type current dump |";
|
|
|
String type = MqlUtil.mqlCommand(context, getTypeInfo);
|
|
|
|
|
|
if("Task".equals(type.split("\\|")[0]) && "Create".equals(type.split("\\|")[1])){
|
|
|
stringList.add("true");
|
|
|
} else {
|
|
|
stringList.add("false");
|
|
|
}
|
|
|
}
|
|
|
return stringList;
|
|
|
}
|
|
|
|
|
|
public StringList getRangeInfo(Context context, String[] args) throws Exception{
|
|
|
Map programMap = JPO.unpackArgs(args);
|
|
|
List list = (List) programMap.get("objectList");
|
|
|
StringList stringList = new StringList();
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map map = (Map) list.get(i);
|
|
|
String itemId = (String) map.get("id");
|
|
|
|
|
|
String getTypeInfo = "print bus " + itemId + " select type dump |";
|
|
|
String type = MqlUtil.mqlCommand(context, getTypeInfo);
|
|
|
|
|
|
if("Task".equals(type)){
|
|
|
String getPublcAccountTaskInfo = "print bus " + itemId + " select attribute[XP_Task_Ext.PublcAccountTask] dump |";
|
|
|
String publcAccountTaskInfo = MqlUtil.mqlCommand(context, getPublcAccountTaskInfo);
|
|
|
stringList.add(publcAccountTaskInfo);
|
|
|
} else {
|
|
|
stringList.add("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return stringList;
|
|
|
}
|
|
|
|
|
|
public Map getPublcAccountTaskRange(Context context, String[] args) throws Exception {
|
|
|
return treeMap;
|
|
|
}
|
|
|
|
|
|
public void setPublicAccountTask(Context context, String[] args) throws Exception {
|
|
|
Map programMap = JPO.unpackArgs(args);
|
|
|
Map<String,String> paramMap = (Map) programMap.get("paramMap");
|
|
|
String newValue = paramMap.get("New Value");
|
|
|
String objId = paramMap.get("objectId");
|
|
|
|
|
|
if(!"".equals(newValue)){
|
|
|
String getTaskAssigns = "print bus " + objId + " select to[Assigned Tasks].from.name dump |";
|
|
|
String taskAssigns = MqlUtil.mqlCommand(context, getTaskAssigns);
|
|
|
|
|
|
LOGGER.info("taskAssigns ==> " + taskAssigns);
|
|
|
LOGGER.info("798798798");
|
|
|
|
|
|
if("".equals(taskAssigns)){
|
|
|
LOGGER.info("1321321312");
|
|
|
setPublicAccountForTask(context, objId, newValue);
|
|
|
}
|
|
|
|
|
|
// 循环判断 受托人中是否有公共账号的人
|
|
|
if(taskAssigns.contains("|")){
|
|
|
String[] taskAssignSplit = taskAssigns.split("\\|");
|
|
|
for (int i = 0; i < taskAssignSplit.length; i++) {
|
|
|
if (!isMatchPublicAccount(taskAssignSplit[i], newValue)) {
|
|
|
throw new MatrixException("\u516c\u5171\u8d26\u53f7\u4efb\u52a1\u6267\u884c\u4eba\u4e0e\u53d7\u6258\u4eba\u4e0d\u5339\u914d");
|
|
|
} else {
|
|
|
setPublicAccountForTask(context, objId, newValue);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
LOGGER.info("isMatchPublicAccount(taskAssigns, newValue) ==> " + isMatchPublicAccount(taskAssigns, newValue));
|
|
|
if(!isMatchPublicAccount(taskAssigns, newValue)){
|
|
|
throw new MatrixException("\u516c\u5171\u8d26\u53f7\u4efb\u52a1\u6267\u884c\u4eba\u4e0e\u53d7\u6258\u4eba\u4e0d\u5339\u914d");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String updateItemInfo = "";
|
|
|
|
|
|
if("".equals(newValue)){
|
|
|
updateItemInfo = "modify bus " + objId + " XP_Task_Ext.PublcAccountTask ''";
|
|
|
}else{
|
|
|
updateItemInfo = "modify bus " + objId + " XP_Task_Ext.PublcAccountTask " + newValue;
|
|
|
}
|
|
|
MqlUtil.mqlCommand(context, updateItemInfo);
|
|
|
}
|
|
|
|
|
|
public int CheckTrustee(Context context, String[] args) throws Exception {
|
|
|
String objId = args[0];
|
|
|
String personId = args[1];
|
|
|
String taskId = args[2];
|
|
|
|
|
|
LOGGER.info("objId ==> " + objId);
|
|
|
LOGGER.info("personId ==> " + personId);
|
|
|
LOGGER.info("taskId ==> " + taskId);
|
|
|
|
|
|
int isFlag = 0;
|
|
|
|
|
|
String getPersonName = "print bus " + personId + " select name dump |";
|
|
|
String personName = null;
|
|
|
try {
|
|
|
personName = MqlUtil.mqlCommand(context, getPersonName);
|
|
|
LOGGER.info("personName ==> " + personName);
|
|
|
List<String> publicAccount = isPublicAccount(personName);
|
|
|
LOGGER.info("publicAccount ==> " + publicAccount.toString());
|
|
|
|
|
|
if("true".equals(publicAccount.get(0))){
|
|
|
String getTaskAssigns = "print bus " + taskId + " select to[Assigned Tasks].from.name dump |";
|
|
|
String taskAssigns = MqlUtil.mqlCommand(context, getTaskAssigns);
|
|
|
LOGGER.info("taskAssigns ==> " + taskAssigns);
|
|
|
|
|
|
if(!"".equals(taskAssigns))
|
|
|
{
|
|
|
if(taskAssigns.contains("|"))
|
|
|
{
|
|
|
String[] taskAssignSplit = taskAssigns.split("\\|");
|
|
|
|
|
|
for (int i = 0; i < taskAssignSplit.length; i++) {
|
|
|
if("true".equals(isPublicAccount(taskAssignSplit[i]).get(0)))
|
|
|
{
|
|
|
isFlag = 1;
|
|
|
}
|
|
|
}
|
|
|
} else{
|
|
|
String isFlags = isPublicAccount(taskAssigns).get(0);
|
|
|
LOGGER.info("isFlags ==> " + isFlags );
|
|
|
if ("true".equals(isPublicAccount(taskAssigns).get(0)))
|
|
|
{
|
|
|
isFlag = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
} finally {
|
|
|
if(isFlag == 1){
|
|
|
throw new MatrixException("\u4efb\u52a1\u7684\u53d7\u6258\u4eba\u4e0d\u53ef\u9009\u62e9\u4e24\u4e2a\u516c\u7528\u8d26\u53f7");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return isFlag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 当给任务填写公共账号任务执行人的时候,如果没有受托人,则直接进行分配, 以下为分配的代码;
|
|
|
* @param context
|
|
|
* @param itemId 任务的Id
|
|
|
* @param newValue 编辑时填写的值
|
|
|
* @throws FrameworkException
|
|
|
*/
|
|
|
public void setPublicAccountForTask(Context context, String itemId, String newValue) throws FrameworkException {
|
|
|
LOGGER.info("setPublicAccountForTask");
|
|
|
LOGGER.info("itemId ==> " + itemId);
|
|
|
LOGGER.info("newValue ==> " + newValue);
|
|
|
|
|
|
String publicAccount = newValue.split("_")[1];
|
|
|
LOGGER.info("publicAccount ==> " + publicAccount);
|
|
|
|
|
|
if("LV".equals(publicAccount)){
|
|
|
String getPersonId = "temp query bus Person plm.lv * select id dump |";
|
|
|
String personId = MqlUtil.mqlCommand(context, getPersonId);
|
|
|
setRelationship(context, itemId, personId.split("\\|")[3]);
|
|
|
|
|
|
} else if ("IBC".equals(publicAccount)) {
|
|
|
String getPersonId = "temp query bus Person plm.ibc * select id dump |";
|
|
|
String personId = MqlUtil.mqlCommand(context, getPersonId);
|
|
|
setRelationship(context, itemId, personId.split("\\|")[3]);
|
|
|
|
|
|
} else if ("RMU".equals(publicAccount)) {
|
|
|
String getPersonId = "temp query bus Person plm.rmu * select id dump |";
|
|
|
String personId = MqlUtil.mqlCommand(context, getPersonId);
|
|
|
setRelationship(context, itemId, personId.split("\\|")[3]);
|
|
|
|
|
|
} else if ("Purchase".equals(publicAccount)) {
|
|
|
String getPersonId = "temp query bus Person purchase.plm * select id dump |";
|
|
|
String personId = MqlUtil.mqlCommand(context, getPersonId);
|
|
|
setRelationship(context, itemId, personId.split("\\|")[3]);
|
|
|
|
|
|
} else if ("Quality".equals(publicAccount)) {
|
|
|
String getPersonId = "temp query bus Person quality.PLM * select id dump |";
|
|
|
String personId = MqlUtil.mqlCommand(context, getPersonId);
|
|
|
setRelationship(context, itemId, personId.split("\\|")[3]);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void setRelationship(Context context, String itemId, String personId) throws FrameworkException {
|
|
|
LOGGER.info("setRelationship ==> 123");
|
|
|
LOGGER.info("itemId ==> " + itemId);
|
|
|
LOGGER.info("personId ==> " + personId);
|
|
|
|
|
|
DomainObject fromDomainObject = DomainObject.newInstance(context, personId);
|
|
|
DomainObject toDomainObject = DomainObject.newInstance(context, itemId);
|
|
|
DomainRelationship domainRelationship = DomainRelationship.connect(context, fromDomainObject, "Assigned Tasks", toDomainObject);
|
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("Assignee Role", "Task Assignee");
|
|
|
map.put("Percent Allocation", "100.0");
|
|
|
domainRelationship.setAttributeValues(context, map);
|
|
|
}
|
|
|
|
|
|
public void AEGAttributeTaskPublicAccountModify(Context context, String[] args) throws Exception {
|
|
|
String taskId = args[0];
|
|
|
String attrName = args[1];
|
|
|
String attrValue = args[2];
|
|
|
|
|
|
LOGGER.info("taskId ==> " + taskId);
|
|
|
LOGGER.info("attrName ==> " + attrName);
|
|
|
LOGGER.info("attrValue ==> " + attrValue);
|
|
|
|
|
|
int isFlag = 1;
|
|
|
|
|
|
if(!"".equals(attrValue)){
|
|
|
String getTaskAssigns = "print bus " + taskId + " select to[Assigned Tasks].from.name dump |";
|
|
|
String taskAssigns = MqlUtil.mqlCommand(context, getTaskAssigns);
|
|
|
LOGGER.info("taskAssigns ==> " + taskAssigns);
|
|
|
|
|
|
if("".equals(taskAssigns)){
|
|
|
setPublicAccountForTask(context, taskId, attrValue);
|
|
|
isFlag = 0;
|
|
|
} else {
|
|
|
if (taskAssigns.contains("|")){
|
|
|
String[] taskAssignSplit = taskAssigns.split("\\|");
|
|
|
for (int i = 0; i < taskAssignSplit.length; i++) {
|
|
|
LOGGER.info("taskAssignSplit ==> " + taskAssignSplit[i]);
|
|
|
LOGGER.info("=====>123<=====" + isPublicAccount(taskAssignSplit[i]).get(0));
|
|
|
if ("true".equals(isPublicAccount(taskAssignSplit[i]).get(0))) {
|
|
|
String publicAccountGroup = attrValue.split("_")[1].toLowerCase();
|
|
|
LOGGER.info("111==> "+ taskAssignSplit[i]);
|
|
|
LOGGER.info("222==> "+ publicAccountGroup);
|
|
|
if(taskAssignSplit[i].contains(publicAccountGroup)){
|
|
|
isFlag = 0;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if(taskAssigns.contains(attrValue.split("_")[1].toLowerCase())){
|
|
|
LOGGER.info("99998888");
|
|
|
isFlag = 0;
|
|
|
} else {
|
|
|
LOGGER.info("999988887777666");
|
|
|
setPublicAccountForTask(context, taskId, attrValue);
|
|
|
isFlag = 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
isFlag = 0;
|
|
|
}
|
|
|
|
|
|
LOGGER.info("====> " + isFlag);
|
|
|
if(isFlag == 1){
|
|
|
emxContextUtilBase_mxJPO.mqlError(context, "\u4efb\u52a1\u6267\u884c\u4eba\u4e0d\u662f\u5df2\u9009\u62e9\u7684\u516c\u5171\u8d26\u53f7\u90e8\u95e8");
|
|
|
throw new MatrixException("\u4efb\u52a1\u6267\u884c\u4eba\u4e0d\u662f\u5df2\u9009\u62e9\u7684\u516c\u5171\u8d26\u53f7\u90e8\u95e8");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void AEGRelationshipAssignTaskDelete(Context context, String[] args) throws FrameworkException {
|
|
|
String objId = args[0];
|
|
|
String personId = args[1];
|
|
|
String taskId = args[2];
|
|
|
String personName = args[3];
|
|
|
|
|
|
LOGGER.info("objId ==> " + objId);
|
|
|
LOGGER.info("personId ==> " + personId);
|
|
|
LOGGER.info("taskId ==> " + taskId);
|
|
|
LOGGER.info("personName ==> " + personName);
|
|
|
|
|
|
String getAssignTasks = "print bus " + taskId + " select to[Assign Task].from.name dump |";
|
|
|
String assignTasks = MqlUtil.mqlCommand(context, getAssignTasks);
|
|
|
LOGGER.info("assignTasks ==> " + assignTasks);
|
|
|
|
|
|
if("".equals(assignTasks)){
|
|
|
String getPublicAccountAttrValue = "print bus " + taskId + " select attribute[XP_Task_Ext.PublcAccountTask].value dump |";
|
|
|
String publicAccountAttrValue = MqlUtil.mqlCommand(context, getPublicAccountAttrValue);
|
|
|
LOGGER.info("publicAccountAttrValue ==> " + publicAccountAttrValue);
|
|
|
|
|
|
if(!"".equals(publicAccountAttrValue)){
|
|
|
String updatePublicAccountAttrValue = "modify bus " + taskId + " XP_Task_Ext.PublcAccountTask ''";
|
|
|
|
|
|
ContextUtil.pushContext(context);
|
|
|
MqlUtil.mqlCommand(context, updatePublicAccountAttrValue);
|
|
|
ContextUtil.popContext(context);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void AEGPolicyProjectTaskPromote(Context context, String[] args) throws Exception {
|
|
|
String objId = args[0];
|
|
|
LOGGER.info("objId ==> " + objId);
|
|
|
|
|
|
String getPublicAccountValue = "print bus " + objId + " select attribute[XP_Task_Ext.PublcAccountTask] dump |";
|
|
|
String publicAccount = MqlUtil.mqlCommand(context, getPublicAccountValue);
|
|
|
|
|
|
if(!"".equals(publicAccount)){
|
|
|
String emailInfo = publicAccount.split("_")[0];
|
|
|
String email = emailInfo + "@aeg-imc.com";
|
|
|
|
|
|
getProjectSpace(objId, context);
|
|
|
|
|
|
LOGGER.info("99999");
|
|
|
LOGGER.info(projectSpaceName);
|
|
|
|
|
|
String getTaskInfo = "print bus " + objId + " select name description attribute[Task Estimated Finish Date] owner dump |";
|
|
|
String taskInfo = MqlUtil.mqlCommand(context, getTaskInfo);
|
|
|
LOGGER.info("taskInfo ==> " + taskInfo);
|
|
|
|
|
|
String getAssignTask = "print bus " + objId + " select to[Assigned Tasks].from.name dump |";
|
|
|
String assignTasks = MqlUtil.mqlCommand(context, getAssignTask);
|
|
|
LOGGER.info("assignTasks ==> " + assignTasks);
|
|
|
|
|
|
String planFinishTimeInfo = taskInfo.split("\\|")[2];
|
|
|
LOGGER.info("planFinishTimeInfo ==> " + planFinishTimeInfo);
|
|
|
String planFinishTime = taskInfo.split("\\|")[2];
|
|
|
|
|
|
if(!"".equals(planFinishTimeInfo)) {
|
|
|
|
|
|
SimpleDateFormat inputFormat = new SimpleDateFormat("M/d/yyyy h:mm:ss a", Locale.ENGLISH);
|
|
|
|
|
|
try {
|
|
|
Date date = inputFormat.parse(planFinishTime);
|
|
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy\u5e74MM\u6708dd\u65e5 HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
|
|
|
planFinishTime = outputFormat.format(date);
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
LOGGER.info("planFinishTime ==> " + planFinishTime);
|
|
|
|
|
|
Map<String, String> map = new TreeMap<>();
|
|
|
map.put("name" , taskInfo.split("\\|")[0]);
|
|
|
map.put("description" , taskInfo.split("\\|")[1]);
|
|
|
map.put("taskPlanFinishDate" , taskInfo.split("\\|")[2]);
|
|
|
map.put("owner" , taskInfo.split("\\|")[3]);
|
|
|
|
|
|
map.put("taskExecutor" , assignTasks);
|
|
|
map.put("projectName" , projectSpaceName);
|
|
|
map.put("planFinishTime" , planFinishTime);
|
|
|
|
|
|
LOGGER.info("map ==> " + map.toString());
|
|
|
|
|
|
send(email, map);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void getProjectSpace (String taskId, Context context) throws Exception {
|
|
|
String getUpToLevelType = "print bus " + taskId + " select to[SubTask].from.id to[SubTask].from.Type to[SubTask].from.Name dump |";
|
|
|
String upToLevelInfo = MqlUtil.mqlCommand(context, getUpToLevelType);
|
|
|
LOGGER.info("upToLevelInfo ==> " + upToLevelInfo);
|
|
|
|
|
|
if(!"".equals(upToLevelInfo)) {
|
|
|
String Type = upToLevelInfo.split("\\|")[1];
|
|
|
if ("Project Space".equals(Type)) {
|
|
|
projectSpaceName = upToLevelInfo.split("\\|")[2];
|
|
|
|
|
|
} else {
|
|
|
getProjectSpace(upToLevelInfo.split("\\|")[0], context);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 第一个参数为公共账号受托人,第二个参数为编辑时填写的值。
|
|
|
* 如果编辑时填写的值是公共账号下的联系人则为true,否则返回false
|
|
|
* @param taskAssign
|
|
|
* @param taskAssign
|
|
|
* @param newValue
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean isMatchPublicAccount(String taskAssign, String newValue){
|
|
|
if(IBC.equals(taskAssign)){
|
|
|
return ibcMap.containsValue(newValue);
|
|
|
|
|
|
} else if (LV.equals(taskAssign)) {
|
|
|
return lvMap.containsValue(newValue);
|
|
|
|
|
|
} else if (RMU.equals(taskAssign)) {
|
|
|
return rmuMap.containsValue(newValue);
|
|
|
|
|
|
} else if (PURCHASE.equals(taskAssign)) {
|
|
|
return purchaseMap.containsValue(newValue);
|
|
|
|
|
|
} else if (QUALITY.equals(taskAssign)) {
|
|
|
return qualityMap.containsValue(newValue);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取他们的小写值
|
|
|
* @param taskAssign
|
|
|
* @return
|
|
|
*/
|
|
|
public List<String> isPublicAccount(String taskAssign){
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
|
if(IBC.equals(taskAssign)){
|
|
|
list.add("true");
|
|
|
list.add("ibc");
|
|
|
return list;
|
|
|
|
|
|
} else if (LV.equals(taskAssign)) {
|
|
|
list.add("true");
|
|
|
list.add("lv");
|
|
|
return list;
|
|
|
|
|
|
} else if (RMU.equals(taskAssign)) {
|
|
|
list.add("true");
|
|
|
list.add("rmu");
|
|
|
return list;
|
|
|
|
|
|
} else if (PURCHASE.equals(taskAssign)) {
|
|
|
list.add("true");
|
|
|
list.add("purchase");
|
|
|
return list;
|
|
|
|
|
|
} else if (QUALITY.equals(taskAssign)) {
|
|
|
list.add("true");
|
|
|
list.add("quality");
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
list.add("false");
|
|
|
list.add("");
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public void send(String emailInfo, Map<String, String> itemMap){
|
|
|
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(emailInfo));
|
|
|
// message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("1654607107@qq.com"));
|
|
|
|
|
|
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("name") + "</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\">" + "\u9879\u76ee\u540d\u79f0 : " + itemMap.get("projectName") + "</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\u5206\u914d\u4eba : " + itemMap.get("owner") + "</p>\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u4efb\u52a1\u6267\u884c\u4eba : " + itemMap.get("taskExecutor") + "</p>\n" +
|
|
|
" <p style=\"text-align: left;color: grey;font-size:large\">" + "\u8ba1\u5212\u5b8c\u6210\u65e5\u671f : " + itemMap.get("planFinishTime") + "</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 ();
|
|
|
}
|
|
|
System.out.println("Email sent successfully!");
|
|
|
}
|
|
|
}
|