if (mailInfoObj == null) {
throw new FixFlowException("系统邮件配置错误请检查流程邮件配置!");
}
// 获取到当前任务
TaskInstanceEntity taskInstance = (TaskInstanceEntity) executionContext.getTaskInstance();
String flowNameString = taskInstance.getProcessDefinition().getName();
String taskUrl = "http://localhost:8080/fixweb/";
if (mailTitle == null || mailTitle.equals("")) {
mailTitle = "[" + flowNameString + "] " + taskInstance.getDescription() + " is pending for your approval or handle";
}
String Fix_BizName = StringUtil.getString(Context.getAbstractScriptLanguageMgmt().execute("${Fix_BizName}", executionContext));
String Fix_BizKeyFile = StringUtil.getString(Context.getAbstractScriptLanguageMgmt().execute("${Fix_BizKeyFile}", executionContext));
if (Fix_BizName == null || Fix_BizName.equals("")) {
throw new FixFlowException("数据变量${Fix_BizName}未空");
}
if (Fix_BizKeyFile == null || Fix_BizKeyFile.equals("")) {
throw new FixFlowException("数据变量${Fix_BizKeyFile}未空");
}
String taskType="view";
if(taskInstance.getAssignee()!=null){
taskType="modify";
}
taskUrl = "http://localhost:8080/fixweb/framework.html?" + "_openMethod=tab&_title=view&_url='%2e%2e/%2e%2e/"
+ taskInstance.getFormUri() + "?_objName=" + Fix_BizName + "%26_defKey=" + taskInstance.getProcessDefinitionKey() + "%26_defId="
+ taskInstance.getProcessDefinitionId().replace(":", "%3A") + "%26_instId=" + taskInstance.getProcessInstanceId() + "%26_taskId="
+ taskInstance.getId() + "%26_nodeId=" + taskInstance.getNodeId() + "%26_agent=%26_pk=" + Fix_BizKeyFile + "%26_pkValue="
+ taskInstance.getBizKey() + "%26_useType="+taskType+"'";
//taskUrl=java.net.URLEncoder.encode(taskUrl,"UTF-8");
if (mailContent == null || mailContent.equals("")) {
mailContent = "<br>Hello,<br>你好,<br><br> " + mailTitle + "+<br><br>"
+ "Please click url to deal with job: <br>请访问此链接地址进入任务:<br> <a href=" + taskUrl + ">"
+ "http://localhost:8080/fixweb/</a><br><br>"
+ "Best Regards!<br>诚挚问候!<br>Note: Please do not reply to this email , This mailbox does not allow incoming messages."
+ "<br>注意: 本邮件为工作流系统发送,请勿回复。 ";
}
UserDefinition userDefinition = Context.getProcessEngineConfiguration().getUserDefinition();
List<GroupDefinition> groupDefinitions = Context.getProcessEngineConfiguration().getGroupDefinitions();
if (taskInstance.getAssignee() != null) {
String to = taskInstance.getAssignee();
if (!to.equals("")) {
UserTo userTo = userDefinition.findUserByUserId(to);
if (userTo != null) {
String eamil = StringUtil.getString(userTo.getPropertyValue("EMAIL"));
if (eamil != null && !eamil.equals("")) {
sendMail(eamil, mailTitle, mailContent,taskInstance);
}
}
}
} else {
String to = "";
for (IdentityLink identityLink : taskInstance.getTaskIdentityLinks()) {
if (identityLink.getUserId() != null) {
UserTo userTo = Authentication.findUserInfoByUserId(identityLink.getUserId());
if (userTo != null) {
String eamil = StringUtil.getString(userTo.getPropertyValue("EMAIL"));