|
|
|
@ -0,0 +1,352 @@
|
|
|
|
|
package com.customization.dito.sendtodo;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
public class SendPortalToReadUtil {
|
|
|
|
|
|
|
|
|
|
//public static String EMAIL_REGEX_DEFAULT = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
|
|
|
|
|
public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* 流程发起节点,提交到下个节点,发起节点没有待办,下个节点有待办
|
|
|
|
|
* @param requestid
|
|
|
|
|
* @param noideid
|
|
|
|
|
* @param user
|
|
|
|
|
*/
|
|
|
|
|
public void sendToReadDataByCreateNode(String requestid,String noideid,User user,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
|
|
|
|
|
|
|
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
|
|
SendMailUtil sendMailUtil = new SendMailUtil();
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
|
|
String requestname = "";
|
|
|
|
|
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
|
|
String emailArray = "";
|
|
|
|
|
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
bb.writeLog("sendToReadDataByCreateNode");
|
|
|
|
|
|
|
|
|
|
String terminal = "1" ;
|
|
|
|
|
String actionType = "0" ;
|
|
|
|
|
String taskType = "1";
|
|
|
|
|
String objectAction = "0" ;
|
|
|
|
|
String objectType = "0";
|
|
|
|
|
String objectId = "" ;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
|
|
|
|
|
String sql =" select t1.workflowid,t1.requestname,t1.requestmark,t1.creater,t1.createdate,t1.createtime,h1.lastname,h1.loginid,\n" +
|
|
|
|
|
" t1.requestid as taskCode,t1.currentnodeid as nodeid,d1.nodename\n" +
|
|
|
|
|
" from workflow_requestbase t1\n" +
|
|
|
|
|
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
|
|
|
|
|
" left join workflow_nodebase d1 on d1.id = t1.currentnodeid "+
|
|
|
|
|
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) h1 on h1.id = t1.creater\n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t1.requestid = "+requestid ;
|
|
|
|
|
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--sql:"+sql);
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
String workflowid = Util.null2String(rs.getString("workflowid")) ;
|
|
|
|
|
String workflowname = getWorkflowname(workflowid);
|
|
|
|
|
String title = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
String creator = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
String workcode = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
String taskCode = Util.null2String(rs.getString("taskcode")) ;
|
|
|
|
|
String nodeId = Util.null2String(rs.getString("nodeid")) ;
|
|
|
|
|
|
|
|
|
|
String createdate = Util.null2String(rs.getString("createdate")) ;
|
|
|
|
|
String createtime = Util.null2String(rs.getString("createtime")) ;
|
|
|
|
|
String messageTitle = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
String messageContent = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
|
|
|
|
|
requestname = messageTitle;
|
|
|
|
|
messageTitle = getShortMessageTitle(messageTitle);
|
|
|
|
|
|
|
|
|
|
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
|
|
|
|
|
String app_requestUrl = bpm_app_requesturl+requestid;
|
|
|
|
|
app_requestUrl = URLEncoder.encode(app_requestUrl,"UTF-8");
|
|
|
|
|
String urlApp = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
|
|
|
|
|
String urlDing = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
|
|
|
|
|
String nodeName = Util.null2String(rs.getString("nodeName")) ;
|
|
|
|
|
|
|
|
|
|
requestObject.put("center",center);
|
|
|
|
|
requestObject.put("title",title);
|
|
|
|
|
requestObject.put("creator",creator);
|
|
|
|
|
requestObject.put("taskCode",taskCode);
|
|
|
|
|
requestObject.put("nodeId",nodeId);
|
|
|
|
|
requestObject.put("taskType",taskType);
|
|
|
|
|
requestObject.put("actionType",actionType);
|
|
|
|
|
requestObject.put("createDate",createdate+" "+createtime);
|
|
|
|
|
requestObject.put("messageTitle",messageTitle);
|
|
|
|
|
requestObject.put("messageContent",messageContent);
|
|
|
|
|
requestObject.put("terminal",terminal);
|
|
|
|
|
requestObject.put("urlPc",urlPc);
|
|
|
|
|
requestObject.put("urlApp",urlApp);
|
|
|
|
|
requestObject.put("urlDing",urlDing);
|
|
|
|
|
requestObject.put("nodeName",nodeName);
|
|
|
|
|
requestObject.put("ticketType",workflowname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sql = " select t2.userid,h1.loginid,h1.email\n" +
|
|
|
|
|
" from workflow_requestbase t1\n" +
|
|
|
|
|
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
|
|
|
|
|
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t2.isremark in ('9')\n" +
|
|
|
|
|
" and t2.islasttimes = 1\n" +
|
|
|
|
|
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
|
|
" and t2.requestid = "+requestid;
|
|
|
|
|
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--sql:"+sql);
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
|
|
|
|
|
String usercode = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
bb.writeLog("usercode--sql:"+usercode);
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
|
|
|
|
|
|
|
String objectCode = usercode ;
|
|
|
|
|
String operatorCode = usercode ;
|
|
|
|
|
taskObject.put("objectAction",objectAction);
|
|
|
|
|
taskObject.put("objectType",objectType);
|
|
|
|
|
taskObject.put("objectCode",objectCode);
|
|
|
|
|
taskObject.put("objectId",objectId);
|
|
|
|
|
taskObject.put("operatorCode",operatorCode);
|
|
|
|
|
taskObjectList.add(taskObject);
|
|
|
|
|
|
|
|
|
|
String email = Util.null2String(rs.getString("email")) ;
|
|
|
|
|
bb.writeLog("email2:"+email);
|
|
|
|
|
Matcher matcher = regex.matcher(email);
|
|
|
|
|
if(matcher.matches()){
|
|
|
|
|
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
requestObject.put("taskObjectList",taskObjectList);
|
|
|
|
|
|
|
|
|
|
String auth = username + ":" + passwd;
|
|
|
|
|
//bb.writeLog("requestObject:"+requestObject.toJSONString());
|
|
|
|
|
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
|
|
|
|
|
bb.writeLog("msgdata:"+msgdata);
|
|
|
|
|
if(!"".equals(msgdata)){
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msgdata);
|
|
|
|
|
//{"resultCode":"1","resultMsg":"No Result"}
|
|
|
|
|
if(msgObject.containsKey("resultCode")){
|
|
|
|
|
String resultCode = msgObject.getString("resultCode");
|
|
|
|
|
if("0".equals(resultCode)){
|
|
|
|
|
|
|
|
|
|
bb.writeLog("emailArray:"+emailArray);
|
|
|
|
|
if(StringUtils.isNotEmpty(emailArray))
|
|
|
|
|
{
|
|
|
|
|
String notificationSubject = "You have a new to-read list:"+requestname+",Please handle it in time";
|
|
|
|
|
String notificationContent = "You have a new to-read list:"+requestname+",Please handle it in time";
|
|
|
|
|
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* 流程提交到写个节点,
|
|
|
|
|
* 如果流程提交节点还有待办,意味着流程还是提交节点,只是提交节点一个人删除待办
|
|
|
|
|
* 如果流程提交节点没有待办,意味着流程流转到下个节点,那么查询出来的待办都有新增,并且删除提交节点的所有待办
|
|
|
|
|
* @param requestid
|
|
|
|
|
* @param noideid
|
|
|
|
|
* @param user
|
|
|
|
|
*/
|
|
|
|
|
public void sendToReadDataByNode(String requestid,String noideid,User user,String portal_todourl,String bpm_app_workflowurl,String username,String passwd,String bpm_workflowurl,String center,String bpm_app_requesturl){
|
|
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
|
|
SendMailUtil sendMailUtil = new SendMailUtil();
|
|
|
|
|
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
bb.writeLog("sendToReadDataByNode");
|
|
|
|
|
|
|
|
|
|
String terminal = "1" ;
|
|
|
|
|
String taskType = "1";
|
|
|
|
|
String objectId = "" ;
|
|
|
|
|
String requestname = "" ;
|
|
|
|
|
String emailArray = "";
|
|
|
|
|
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
int count = 0 ;
|
|
|
|
|
String countSql =" select t2.userid,h1.loginid\n" +
|
|
|
|
|
" from workflow_requestbase t1\n" +
|
|
|
|
|
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
|
|
|
|
|
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id,lastname,loginid from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '8', '7', '11'))\n" +
|
|
|
|
|
" and t2.islasttimes = 1\n" +
|
|
|
|
|
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
|
|
" and t2.REQUESTID = "+requestid+
|
|
|
|
|
" and t2.nodeid = " + noideid ;
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--countSql:"+countSql);
|
|
|
|
|
rs.executeQuery(countSql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--count:"+count);
|
|
|
|
|
|
|
|
|
|
if(count == 0)
|
|
|
|
|
{
|
|
|
|
|
String actionType = "2" ;
|
|
|
|
|
String objectAction = "0" ;
|
|
|
|
|
String objectType = "0";
|
|
|
|
|
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
|
|
|
|
|
String sql =" select t1.workflowid,t1.requestname,t1.requestmark,t1.creater,t1.createdate,t1.createtime,h1.lastname,h1.loginid,\n" +
|
|
|
|
|
" t1.requestid as taskCode,t1.currentnodeid as nodeid,d1.nodename\n" +
|
|
|
|
|
" from workflow_requestbase t1\n" +
|
|
|
|
|
" inner join workflow_base t3 on t1.workflowid = t3.id\n" +
|
|
|
|
|
" left join workflow_nodebase d1 on d1.id = t1.currentnodeid "+
|
|
|
|
|
" left join (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) h1 on h1.id = t1.creater\n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t1.requestid = "+requestid ;
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--sql:"+sql);
|
|
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
String workflowid = Util.null2String(rs.getString("workflowid")) ;
|
|
|
|
|
String workflowname = getWorkflowname(workflowid);
|
|
|
|
|
String title = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
requestname = title;
|
|
|
|
|
String creator = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
String taskCode = Util.null2String(rs.getString("taskcode")) ;
|
|
|
|
|
String nodeId = Util.null2String(rs.getString("nodeid")) ;
|
|
|
|
|
String workcode = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
String createdate = Util.null2String(rs.getString("createdate")) ;
|
|
|
|
|
String createtime = Util.null2String(rs.getString("createtime")) ;
|
|
|
|
|
String messageTitle = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
messageTitle = getShortMessageTitle(messageTitle);
|
|
|
|
|
String messageContent = Util.null2String(rs.getString("requestname")) ;
|
|
|
|
|
|
|
|
|
|
String urlPc = "[newtab]"+bpm_workflowurl+"/workflow/request/ViewRequestForwardSPA.jsp?requestid="+requestid ;
|
|
|
|
|
String app_requestUrl = bpm_app_requesturl+requestid;
|
|
|
|
|
app_requestUrl = URLEncoder.encode(app_requestUrl,"UTF-8");
|
|
|
|
|
String urlApp = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
|
|
|
|
|
String urlDing = bpm_app_workflowurl+"/interface/mobilelogin/loginsso.jsp?em_auth_usercode="+workcode+"&forwardurl="+app_requestUrl;
|
|
|
|
|
String nodeName = Util.null2String(rs.getString("nodeName")) ;
|
|
|
|
|
|
|
|
|
|
requestObject.put("center",center);
|
|
|
|
|
requestObject.put("title",title);
|
|
|
|
|
requestObject.put("creator",creator);
|
|
|
|
|
requestObject.put("taskCode",taskCode);
|
|
|
|
|
requestObject.put("nodeId",nodeId);
|
|
|
|
|
requestObject.put("taskType",taskType);
|
|
|
|
|
requestObject.put("actionType",actionType);
|
|
|
|
|
requestObject.put("createDate",createdate+" "+createtime);
|
|
|
|
|
requestObject.put("messageTitle",messageTitle);
|
|
|
|
|
requestObject.put("messageContent",messageContent);
|
|
|
|
|
requestObject.put("terminal",terminal);
|
|
|
|
|
requestObject.put("urlPc",urlPc);
|
|
|
|
|
requestObject.put("urlApp",urlApp);
|
|
|
|
|
requestObject.put("urlDing",urlDing);
|
|
|
|
|
requestObject.put("nodeName",nodeName);
|
|
|
|
|
requestObject.put("ticketType",workflowname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sql = " select t2.userid,h1.loginid,h1.email\n" +
|
|
|
|
|
" from workflow_requestbase t1\n" +
|
|
|
|
|
" inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" +
|
|
|
|
|
" left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t2.isremark in ('9')\n" +
|
|
|
|
|
" and t2.islasttimes = 1\n" +
|
|
|
|
|
" and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
|
|
" and t2.REQUESTID = "+requestid;
|
|
|
|
|
|
|
|
|
|
bb.writeLog("sendTodoDataByNode--sql:"+sql);
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
|
|
|
|
|
String usercode = Util.null2String(rs.getString("loginid")) ;
|
|
|
|
|
String objectCode = usercode ;
|
|
|
|
|
String operatorCode = usercode ;
|
|
|
|
|
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
|
|
taskObject.put("objectAction",objectAction);
|
|
|
|
|
taskObject.put("objectType",objectType);
|
|
|
|
|
taskObject.put("objectCode",objectCode);
|
|
|
|
|
taskObject.put("objectId",objectId);
|
|
|
|
|
taskObject.put("operatorCode",operatorCode);
|
|
|
|
|
taskObjectList.add(taskObject);
|
|
|
|
|
|
|
|
|
|
String email = Util.null2String(rs.getString("email")) ;
|
|
|
|
|
bb.writeLog("email3:"+email);
|
|
|
|
|
Matcher matcher = regex.matcher(email);
|
|
|
|
|
if(matcher.matches()){
|
|
|
|
|
emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
requestObject.put("taskObjectList",taskObjectList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String auth = username + ":" + passwd;
|
|
|
|
|
//bb.writeLog("requestObject:"+requestObject.toJSONString());
|
|
|
|
|
String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth);
|
|
|
|
|
bb.writeLog("msgdata:"+msgdata);
|
|
|
|
|
if(!"".equals(msgdata)){
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msgdata);
|
|
|
|
|
//{"resultCode":"1","resultMsg":"No Result"}
|
|
|
|
|
if(msgObject.containsKey("resultCode")){
|
|
|
|
|
String resultCode = msgObject.getString("resultCode");
|
|
|
|
|
if("0".equals(resultCode)){
|
|
|
|
|
|
|
|
|
|
bb.writeLog("emailArray:"+emailArray);
|
|
|
|
|
if(StringUtils.isNotEmpty(emailArray))
|
|
|
|
|
{
|
|
|
|
|
String notificationSubject = "You have a new to-do list:"+requestname+",Please handle it in time";
|
|
|
|
|
String notificationContent = "You have a new to-do list:"+requestname+",Please handle it in time";
|
|
|
|
|
sendMailUtil.sendMail(requestid,emailArray,notificationSubject,notificationContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getShortMessageTitle(String messageTitle) {
|
|
|
|
|
if (messageTitle.length() > 20) {
|
|
|
|
|
messageTitle = messageTitle.substring(0, 17) + "...";
|
|
|
|
|
}
|
|
|
|
|
return messageTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getWorkflowname(String id){
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String name = "";
|
|
|
|
|
rs.executeQuery("select workflowname from workflow_base where id = ?",id);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
name = Util.null2String(rs.getString("workflowname"));
|
|
|
|
|
}
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|