|
|
|
@ -0,0 +1,619 @@
|
|
|
|
|
package com.engine.workflow.cmd.agent;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.customization.dito.sendtodo.HttpRequestUtil;
|
|
|
|
|
import com.customization.dito.sendtodo.SendMailUtil;
|
|
|
|
|
import com.customization.dito.sendtodo.SendPortalErrorUtil;
|
|
|
|
|
import com.time.util.DateUtil;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
import weaver.interfaces.dito.comInfo.PropBean;
|
|
|
|
|
import weaver.workflow.agent.AgentBean;
|
|
|
|
|
import weaver.workflow.agent.AgentManager;
|
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
public class AddAgentSaveRunnable implements Runnable{
|
|
|
|
|
private User user;
|
|
|
|
|
private List<Integer> bagentuidRange;
|
|
|
|
|
private AgentBean bean;
|
|
|
|
|
private int isPendThing;
|
|
|
|
|
private int agentuid;
|
|
|
|
|
private String workflowids;
|
|
|
|
|
private int overlapMethod;
|
|
|
|
|
|
|
|
|
|
public AddAgentSaveRunnable(User user,List<Integer> bagentuidRange,AgentBean bean,int isPendThing,int agentuid,String workflowids,int overlapMethod){
|
|
|
|
|
this.user = user;
|
|
|
|
|
this.bagentuidRange = bagentuidRange;
|
|
|
|
|
this.bean = bean;
|
|
|
|
|
this.isPendThing = isPendThing;
|
|
|
|
|
this.agentuid = agentuid;
|
|
|
|
|
this.workflowids = workflowids;
|
|
|
|
|
this.overlapMethod = overlapMethod ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time4:"+sdf.format(new Date()));
|
|
|
|
|
try{
|
|
|
|
|
String agentresult = "";
|
|
|
|
|
AgentManager agentManager = new AgentManager(user);
|
|
|
|
|
for(int bagentuid : bagentuidRange){
|
|
|
|
|
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time-1-"+bagentuid+":"+sdf.format(new Date()));
|
|
|
|
|
|
|
|
|
|
bean.setBagentuid(bagentuid);
|
|
|
|
|
//当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 1
|
|
|
|
|
if(isPendThing == 1){
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time-2-"+bagentuid+":"+sdf.format(new Date()));
|
|
|
|
|
//单独 处理待办的
|
|
|
|
|
DealPortalTodoAndDone(agentuid,bagentuid,workflowids);
|
|
|
|
|
//单独 处理抄送的
|
|
|
|
|
DealPortalChaoSong(agentuid,bagentuid,workflowids);
|
|
|
|
|
//单独 处理转发的
|
|
|
|
|
DealPortalForward(agentuid,bagentuid,workflowids);
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time-3-"+bagentuid+":"+sdf.format(new Date()));
|
|
|
|
|
}
|
|
|
|
|
agentresult = agentManager.batchAddAgent(workflowids, bean, overlapMethod);
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time-4-"+bagentuid+":"+sdf.format(new Date()));
|
|
|
|
|
|
|
|
|
|
if(!"success".equals(agentresult)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bb.writeLog("AddAgentSaveCmd--time5:"+sdf.format(new Date()));
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
bb.writeLog("AddAgentSaveRunnable-e:"+e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除
|
|
|
|
|
* @param agenterid 代理人
|
|
|
|
|
* @param beagenterid 被代理人
|
|
|
|
|
* @param workflowids 指定流程id
|
|
|
|
|
*/
|
|
|
|
|
public void DealPortalTodoAndDone(int agenterid, int beagenterid, String workflowids){
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
RecordSet rs1 = new RecordSet();
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
|
|
|
|
|
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
|
|
rs.writeLog("==================== AddAgentSaveCmd DealPortalTodoAndDone ===================");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
taskObject.put("objectAction", "0");
|
|
|
|
|
taskObject.put("objectType", "0");
|
|
|
|
|
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObject.put("objectId", getStaffId(agenterid));
|
|
|
|
|
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObjectList.add(taskObject);
|
|
|
|
|
|
|
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
|
|
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
|
|
|
|
|
SendMailUtil sendMailUtil = new SendMailUtil();
|
|
|
|
|
|
|
|
|
|
String scopeid = "-1";
|
|
|
|
|
String scope = "HrmCustomFieldByInfoType" ;
|
|
|
|
|
|
|
|
|
|
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
|
|
|
|
|
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
|
|
|
|
|
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
|
|
|
|
|
String username = PropBean.getUfPropValue("username");
|
|
|
|
|
String passwd = PropBean.getUfPropValue("passwd");
|
|
|
|
|
String center = PropBean.getUfPropValue("center");
|
|
|
|
|
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
|
|
|
|
|
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
|
|
|
|
|
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
|
|
|
|
|
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
|
|
|
|
|
" from workflow_base t " +
|
|
|
|
|
" left join workflow_requestbase t1 on t.id=t1.workflowid " +
|
|
|
|
|
" left join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
|
|
|
|
|
" left join hrmresource h1 on h1.id = t1.creater "+
|
|
|
|
|
" where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+
|
|
|
|
|
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('5','9','7','11') ) " +
|
|
|
|
|
" and t2.islasttimes=1 " +
|
|
|
|
|
" and (t.isvalid=3 or t.isvalid=1) ";
|
|
|
|
|
|
|
|
|
|
String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalTodoAndDone";
|
|
|
|
|
String actionType = "1";
|
|
|
|
|
String terminal = "1";
|
|
|
|
|
String taskType = "0";
|
|
|
|
|
rs1.executeQuery(sql);
|
|
|
|
|
while (rs1.next()) {
|
|
|
|
|
String userid = Util.null2String(rs1.getString("userid"));
|
|
|
|
|
String requestid = Util.null2String(rs1.getString("requestid"));
|
|
|
|
|
|
|
|
|
|
String workflowname = "";
|
|
|
|
|
String nodeId = "";
|
|
|
|
|
String nodeName = "";
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
|
|
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
|
|
|
|
|
String replace = bpm_app_workflowurl.replace("/bpm", "");
|
|
|
|
|
String urlDing = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
String urlApp = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
|
|
|
|
|
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String msgdata = "";
|
|
|
|
|
String requestname = "";
|
|
|
|
|
String lastname = "";
|
|
|
|
|
String userids = "";
|
|
|
|
|
String loginid = "";
|
|
|
|
|
String emailArray = "";
|
|
|
|
|
|
|
|
|
|
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
|
|
|
|
|
" 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 ) h2 on h2.id = t1.creater \n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t1.requestid = " + requestid;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd DealPortalTodoAndDone -- sql:" + sql);
|
|
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
requestname = Util.null2String(rs.getString("requestname"));
|
|
|
|
|
workflowname = Util.null2String(rs.getString("workflowname"));
|
|
|
|
|
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
|
|
|
|
|
nodeName = Util.null2String(rs.getString("nodeName"));
|
|
|
|
|
lastname = Util.null2String(rs.getString("lastname"));
|
|
|
|
|
loginid = Util.null2String(rs.getString("loginid"));
|
|
|
|
|
}
|
|
|
|
|
requestObject.put("center", center);
|
|
|
|
|
requestObject.put("title", requestname);
|
|
|
|
|
requestObject.put("creator", loginid);
|
|
|
|
|
requestObject.put("taskCode", "weaver" + requestid);
|
|
|
|
|
requestObject.put("nodeId", nodeId);
|
|
|
|
|
requestObject.put("taskType", taskType);
|
|
|
|
|
requestObject.put("actionType", actionType);
|
|
|
|
|
requestObject.put("createDate", processTime);
|
|
|
|
|
requestObject.put("messageTitle", getShortMessageTitle(requestname));
|
|
|
|
|
requestObject.put("messageContent", requestname);
|
|
|
|
|
requestObject.put("terminal", terminal);
|
|
|
|
|
requestObject.put("urlPc", urlPc);
|
|
|
|
|
requestObject.put("urlApp", urlApp);
|
|
|
|
|
requestObject.put("urlDing", urlDing);
|
|
|
|
|
requestObject.put("nodeName", nodeName);
|
|
|
|
|
requestObject.put("ticketType", workflowname);
|
|
|
|
|
|
|
|
|
|
JSONObject taskObject1 = new JSONObject();
|
|
|
|
|
taskObject1.put("objectAction", "1");
|
|
|
|
|
taskObject1.put("objectType", "0");
|
|
|
|
|
taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObject1.put("objectId", getStaffId(beagenterid));
|
|
|
|
|
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObjectList.add(taskObject1);
|
|
|
|
|
|
|
|
|
|
if (taskObjectList.size() > 0) {
|
|
|
|
|
requestObject.put("taskObjectList", taskObjectList);
|
|
|
|
|
} else {
|
|
|
|
|
requestObject.put("actionType", "3");
|
|
|
|
|
}
|
|
|
|
|
String auth = username + ":" + passwd;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("================== AddAgentSaveCmd DealPortalTodoAndDone ======================== "+requestObject.toJSONString());
|
|
|
|
|
|
|
|
|
|
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
|
|
|
|
|
if (!"".equals(msgdata)) {
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msgdata);
|
|
|
|
|
if (msgObject.containsKey("resultCode")) {
|
|
|
|
|
String resultCode = msgObject.getString("resultCode");
|
|
|
|
|
if ("0".equals(resultCode)) {
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray);
|
|
|
|
|
if (StringUtils.isNotEmpty(emailArray)) {
|
|
|
|
|
|
|
|
|
|
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
|
|
|
|
|
String notificationSubject = templateMap.get("notificationSubject");
|
|
|
|
|
String notificationContent = templateMap.get("notificationContent");
|
|
|
|
|
|
|
|
|
|
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
String resultmsg = msgObject.getString("resultMsg");
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
rs.writeLog(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单独处理 抄送 的
|
|
|
|
|
* 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除
|
|
|
|
|
* @param agenterid 代理人
|
|
|
|
|
* @param beagenterid 被代理人
|
|
|
|
|
* @param workflowids 指定流程id
|
|
|
|
|
*/
|
|
|
|
|
public void DealPortalChaoSong(int agenterid, int beagenterid, String workflowids){
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
RecordSet rs1 = new RecordSet();
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
|
|
|
|
|
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
|
|
rs.writeLog("==================== AddAgentSaveCmd DealPortalChaoSong ===================");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
taskObject.put("objectAction", "0");
|
|
|
|
|
taskObject.put("objectType", "0");
|
|
|
|
|
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObject.put("objectId", getStaffId(agenterid));
|
|
|
|
|
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObjectList.add(taskObject);
|
|
|
|
|
|
|
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
|
|
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
|
|
|
|
|
SendMailUtil sendMailUtil = new SendMailUtil();
|
|
|
|
|
|
|
|
|
|
String scopeid = "-1";
|
|
|
|
|
String scope = "HrmCustomFieldByInfoType" ;
|
|
|
|
|
|
|
|
|
|
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
|
|
|
|
|
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
|
|
|
|
|
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
|
|
|
|
|
String username = PropBean.getUfPropValue("username");
|
|
|
|
|
String passwd = PropBean.getUfPropValue("passwd");
|
|
|
|
|
String center = PropBean.getUfPropValue("center");
|
|
|
|
|
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
|
|
|
|
|
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
|
|
|
|
|
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
|
|
|
|
|
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
|
|
|
|
|
" from workflow_base t " +
|
|
|
|
|
" left join workflow_requestbase t1 on t.id=t1.workflowid " +
|
|
|
|
|
" left join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
|
|
|
|
|
" left join hrmresource h1 on h1.id = t1.creater "+
|
|
|
|
|
" where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+
|
|
|
|
|
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('8','9') " +
|
|
|
|
|
" and t2.islasttimes=1 " +
|
|
|
|
|
" and (t.isvalid=3 or t.isvalid=1) ";
|
|
|
|
|
|
|
|
|
|
String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalChaoSong";
|
|
|
|
|
String actionType = "1";
|
|
|
|
|
String terminal = "1";
|
|
|
|
|
String taskType = "0";
|
|
|
|
|
rs1.executeQuery(sql);
|
|
|
|
|
while (rs1.next()) {
|
|
|
|
|
String userid = Util.null2String(rs1.getString("userid"));
|
|
|
|
|
String requestid = Util.null2String(rs1.getString("requestid"));
|
|
|
|
|
|
|
|
|
|
String workflowname = "";
|
|
|
|
|
String nodeId = "";
|
|
|
|
|
String nodeName = "";
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
|
|
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
|
|
|
|
|
String replace = bpm_app_workflowurl.replace("/bpm", "");
|
|
|
|
|
String urlDing = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
String urlApp = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
|
|
|
|
|
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String msgdata = "";
|
|
|
|
|
String requestname = "";
|
|
|
|
|
String lastname = "";
|
|
|
|
|
String userids = "";
|
|
|
|
|
String loginid = "";
|
|
|
|
|
String emailArray = "";
|
|
|
|
|
|
|
|
|
|
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
|
|
|
|
|
" 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 ) h2 on h2.id = t1.creater \n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t1.requestid = " + requestid;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd DealPortalChaoSong -- sql:" + sql);
|
|
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
requestname = Util.null2String(rs.getString("requestname"));
|
|
|
|
|
workflowname = Util.null2String(rs.getString("workflowname"));
|
|
|
|
|
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
|
|
|
|
|
nodeName = Util.null2String(rs.getString("nodeName"));
|
|
|
|
|
lastname = Util.null2String(rs.getString("lastname"));
|
|
|
|
|
loginid = Util.null2String(rs.getString("loginid"));
|
|
|
|
|
}
|
|
|
|
|
requestObject.put("center", center);
|
|
|
|
|
requestObject.put("title", requestname);
|
|
|
|
|
requestObject.put("creator", loginid);
|
|
|
|
|
requestObject.put("taskCode", requestid+"_cs_"+ userid);
|
|
|
|
|
requestObject.put("nodeId", nodeId);
|
|
|
|
|
requestObject.put("taskType", taskType);
|
|
|
|
|
requestObject.put("actionType", actionType);
|
|
|
|
|
requestObject.put("createDate", processTime);
|
|
|
|
|
requestObject.put("messageTitle", getShortMessageTitle(requestname));
|
|
|
|
|
requestObject.put("messageContent", requestname);
|
|
|
|
|
requestObject.put("terminal", terminal);
|
|
|
|
|
requestObject.put("urlPc", urlPc);
|
|
|
|
|
requestObject.put("urlApp", urlApp);
|
|
|
|
|
requestObject.put("urlDing", urlDing);
|
|
|
|
|
requestObject.put("nodeName", nodeName);
|
|
|
|
|
requestObject.put("ticketType", workflowname);
|
|
|
|
|
|
|
|
|
|
JSONObject taskObject1 = new JSONObject();
|
|
|
|
|
taskObject1.put("objectAction", "1");
|
|
|
|
|
taskObject1.put("objectType", "0");
|
|
|
|
|
taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObject1.put("objectId", getStaffId(beagenterid));
|
|
|
|
|
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObjectList.add(taskObject1);
|
|
|
|
|
|
|
|
|
|
if (taskObjectList.size() > 0) {
|
|
|
|
|
requestObject.put("taskObjectList", taskObjectList);
|
|
|
|
|
} else {
|
|
|
|
|
requestObject.put("actionType", "3");
|
|
|
|
|
}
|
|
|
|
|
String auth = username + ":" + passwd;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("================== AddAgentSaveCmd DealPortalChaoSong ======================== "+requestObject.toJSONString());
|
|
|
|
|
|
|
|
|
|
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
|
|
|
|
|
if (!"".equals(msgdata)) {
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msgdata);
|
|
|
|
|
if (msgObject.containsKey("resultCode")) {
|
|
|
|
|
String resultCode = msgObject.getString("resultCode");
|
|
|
|
|
if ("0".equals(resultCode)) {
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray);
|
|
|
|
|
if (StringUtils.isNotEmpty(emailArray)) {
|
|
|
|
|
|
|
|
|
|
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
|
|
|
|
|
String notificationSubject = templateMap.get("notificationSubject");
|
|
|
|
|
String notificationContent = templateMap.get("notificationContent");
|
|
|
|
|
|
|
|
|
|
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
String resultmsg = msgObject.getString("resultMsg");
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
rs.writeLog(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单独处理 转发 的
|
|
|
|
|
* 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除
|
|
|
|
|
* @param agenterid 代理人
|
|
|
|
|
* @param beagenterid 被代理人
|
|
|
|
|
* @param workflowids 指定流程id
|
|
|
|
|
*/
|
|
|
|
|
public void DealPortalForward(int agenterid, int beagenterid, String workflowids){
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
RecordSet rs1 = new RecordSet();
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
|
|
|
|
|
Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT);
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
|
|
rs.writeLog("==================== AddAgentSaveCmd DealPortalForward ===================");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
taskObject.put("objectAction", "0");
|
|
|
|
|
taskObject.put("objectType", "0");
|
|
|
|
|
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObject.put("objectId", getStaffId(agenterid));
|
|
|
|
|
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
|
|
|
|
|
taskObjectList.add(taskObject);
|
|
|
|
|
|
|
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
|
|
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
|
|
|
|
|
SendMailUtil sendMailUtil = new SendMailUtil();
|
|
|
|
|
|
|
|
|
|
String scopeid = "-1";
|
|
|
|
|
String scope = "HrmCustomFieldByInfoType" ;
|
|
|
|
|
|
|
|
|
|
String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl");
|
|
|
|
|
String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl");
|
|
|
|
|
String portal_todourl = PropBean.getUfPropValue("portal_todourl");
|
|
|
|
|
String username = PropBean.getUfPropValue("username");
|
|
|
|
|
String passwd = PropBean.getUfPropValue("passwd");
|
|
|
|
|
String center = PropBean.getUfPropValue("center");
|
|
|
|
|
String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl");
|
|
|
|
|
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
|
|
|
|
|
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
|
|
|
|
|
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
String sql = " select distinct t2.userid,t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
|
|
|
|
|
" from workflow_base t " +
|
|
|
|
|
" left join workflow_requestbase t1 on t.id=t1.workflowid " +
|
|
|
|
|
" left join workflow_currentoperator t2 on t1.requestid = t2.requestid " +
|
|
|
|
|
" left join hrmresource h1 on h1.id = t1.creater "+
|
|
|
|
|
" where t2.usertype=0 and t2.userid in (" + beagenterid +") and t.id in (" + workflowids +") "+
|
|
|
|
|
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('1') " +
|
|
|
|
|
" and t2.islasttimes=1 " +
|
|
|
|
|
" and (t.isvalid=3 or t.isvalid=1) ";
|
|
|
|
|
|
|
|
|
|
String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalForward";
|
|
|
|
|
String actionType = "1";
|
|
|
|
|
String terminal = "1";
|
|
|
|
|
String taskType = "0";
|
|
|
|
|
rs1.executeQuery(sql);
|
|
|
|
|
while (rs1.next()) {
|
|
|
|
|
String userid = Util.null2String(rs1.getString("userid"));
|
|
|
|
|
String requestid = Util.null2String(rs1.getString("requestid"));
|
|
|
|
|
|
|
|
|
|
String workflowname = "";
|
|
|
|
|
String nodeId = "";
|
|
|
|
|
String nodeName = "";
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
|
|
String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid;
|
|
|
|
|
String replace = bpm_app_workflowurl.replace("/bpm", "");
|
|
|
|
|
String urlDing = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
String urlApp = replace + bpm_app_requesturl + requestid;
|
|
|
|
|
if (StringUtils.isNotEmpty(mobileJumpUrl)) {
|
|
|
|
|
urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String msgdata = "";
|
|
|
|
|
String requestname = "";
|
|
|
|
|
String lastname = "";
|
|
|
|
|
String userids = "";
|
|
|
|
|
String loginid = "";
|
|
|
|
|
String emailArray = "";
|
|
|
|
|
|
|
|
|
|
sql = " select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname,h2.loginid " +
|
|
|
|
|
" 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 ) h2 on h2.id = t1.creater \n" +
|
|
|
|
|
" where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
|
|
" and t1.requestid = " + requestid;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd DealPortalForward -- sql:" + sql);
|
|
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
requestname = Util.null2String(rs.getString("requestname"));
|
|
|
|
|
workflowname = Util.null2String(rs.getString("workflowname"));
|
|
|
|
|
nodeId = Util.null2String(rs.getString("nodeid") + user.getUID());
|
|
|
|
|
nodeName = Util.null2String(rs.getString("nodeName"));
|
|
|
|
|
lastname = Util.null2String(rs.getString("lastname"));
|
|
|
|
|
loginid = Util.null2String(rs.getString("loginid"));
|
|
|
|
|
}
|
|
|
|
|
requestObject.put("center", center);
|
|
|
|
|
requestObject.put("title", requestname);
|
|
|
|
|
requestObject.put("creator", loginid);
|
|
|
|
|
requestObject.put("taskCode", "weaver" + requestid+"_zf_"+ userid);
|
|
|
|
|
requestObject.put("nodeId", nodeId);
|
|
|
|
|
requestObject.put("taskType", taskType);
|
|
|
|
|
requestObject.put("actionType", actionType);
|
|
|
|
|
requestObject.put("createDate", processTime);
|
|
|
|
|
requestObject.put("messageTitle", getShortMessageTitle(requestname));
|
|
|
|
|
requestObject.put("messageContent", requestname);
|
|
|
|
|
requestObject.put("terminal", terminal);
|
|
|
|
|
requestObject.put("urlPc", urlPc);
|
|
|
|
|
requestObject.put("urlApp", urlApp);
|
|
|
|
|
requestObject.put("urlDing", urlDing);
|
|
|
|
|
requestObject.put("nodeName", nodeName);
|
|
|
|
|
requestObject.put("ticketType", workflowname);
|
|
|
|
|
|
|
|
|
|
JSONObject taskObject1 = new JSONObject();
|
|
|
|
|
taskObject1.put("objectAction", "1");
|
|
|
|
|
taskObject1.put("objectType", "0");
|
|
|
|
|
taskObject1.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObject1.put("objectId", getStaffId(beagenterid));
|
|
|
|
|
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
|
|
|
|
|
taskObjectList.add(taskObject1);
|
|
|
|
|
|
|
|
|
|
if (taskObjectList.size() > 0) {
|
|
|
|
|
requestObject.put("taskObjectList", taskObjectList);
|
|
|
|
|
} else {
|
|
|
|
|
requestObject.put("actionType", "3");
|
|
|
|
|
}
|
|
|
|
|
String auth = username + ":" + passwd;
|
|
|
|
|
|
|
|
|
|
rs.writeLog("================== AddAgentSaveCmd DealPortalForward ======================== "+requestObject.toJSONString());
|
|
|
|
|
|
|
|
|
|
msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth);
|
|
|
|
|
if (!"".equals(msgdata)) {
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msgdata);
|
|
|
|
|
if (msgObject.containsKey("resultCode")) {
|
|
|
|
|
String resultCode = msgObject.getString("resultCode");
|
|
|
|
|
if ("0".equals(resultCode)) {
|
|
|
|
|
|
|
|
|
|
rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray);
|
|
|
|
|
if (StringUtils.isNotEmpty(emailArray)) {
|
|
|
|
|
|
|
|
|
|
Map<String, String> templateMap = getEmailTemplate(requestname, lastname, processTime);
|
|
|
|
|
String notificationSubject = templateMap.get("notificationSubject");
|
|
|
|
|
String notificationContent = templateMap.get("notificationContent");
|
|
|
|
|
|
|
|
|
|
sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, "",zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
String resultmsg = msgObject.getString("resultMsg");
|
|
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, String.valueOf(beagenterid), requestObject.toJSONString(), resultCode, resultmsg ,zhjkbs,String.valueOf(agenterid));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
rs.writeLog(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getShortMessageTitle(String messageTitle) {
|
|
|
|
|
if (messageTitle.length() > 20) {
|
|
|
|
|
messageTitle = messageTitle.substring(0, 17) + "...";
|
|
|
|
|
}
|
|
|
|
|
return messageTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
*
|
|
|
|
|
* @param requestname
|
|
|
|
|
* @param operator
|
|
|
|
|
* @param operatorTime
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String,String> getEmailTemplate(String requestname,String operator,String operatorTime){
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
|
|
String notificationSubject = "You have a new To-Read - <"+requestname+"> ";
|
|
|
|
|
String notificationContent = operator + " created this task on "+operatorTime+"\n" +
|
|
|
|
|
" Please handle it in time.";
|
|
|
|
|
dataMap.put("notificationSubject",notificationSubject);
|
|
|
|
|
dataMap.put("notificationContent",notificationContent);
|
|
|
|
|
return dataMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getStaffId(int userid){
|
|
|
|
|
int result = -1;
|
|
|
|
|
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select "+ cus_staff + " from cus_fielddata where scopeid=-1 and scope = 'HrmCustomFieldByInfoType' and id=?",userid);
|
|
|
|
|
rs.next();
|
|
|
|
|
result = Util.getIntValue(rs.getString(cus_staff));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|