Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java
#	src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java
#	src/weaver/interfaces/dito/mq/RocketmqUtil.java
main
shilei 1 year ago
commit ecebb296e3

@ -35,7 +35,6 @@ public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
this.user = user;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> apidatas = new HashMap<String,Object>();
try{
@ -66,7 +65,12 @@ public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
//当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 1
if(isPendThing == 1){
//单独 处理待办的
DealPortalTodoAndDone(agentuid,bagentuid,workflowids);
//单独 处理抄送的
DealPortalChaoSong(agentuid,bagentuid,workflowids);
//单独 处理转发的
DealPortalForward(agentuid,bagentuid,workflowids);
}
agentresult = agentManager.batchAddAgent(workflowids, bean, overlapMethod);
if(!"success".equals(agentresult)) {
@ -128,15 +132,15 @@ public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
String sql =" select distinct 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','7','11') ) " +
" and t2.islasttimes=1 " +
" and (t.isvalid=3 or t.isvalid=1) ";
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";
@ -144,6 +148,7 @@ public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
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 = "";
@ -251,6 +256,338 @@ public class AddAgentSaveCmd extends AbstractCommonCommand<Map<String,Object>>{
}
}
/**
*
*
* @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) + "...";

@ -119,7 +119,12 @@ public class TakeBackAgentCmd extends AbstractCommonCommand<Map<String,Object>>{
beagenterid = Util.getIntValue(rs.getString("beagenterid"));
workflowids = Util.null2String(rs.getString("workflowid"));
//单独 处理待办的
DealPortalTodoAndDone(agenterid,beagenterid,workflowids);
//单独 处理抄送的
DealPortalChaoSong(agenterid,beagenterid,workflowids);
//单独 处理转发的
DealPortalForward(agenterid,beagenterid,workflowids);
}
}
@ -167,13 +172,13 @@ public class TakeBackAgentCmd extends AbstractCommonCommand<Map<String,Object>>{
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
String sql = " select distinct t1.requestid,t1.requestname,t1.createdate,h1.lastname as creatorname,t2.receivedate,t2.receivetime " +
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 (" + agenterid +") and t.id in (" + workflowids +") "+
" and ((t2.isremark =0 and (t2.takisremark is null or t2.takisremark ='0')) or t2.isremark in('5','7','11') ) " +
" 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) and t2.agenttype = 2 ";
@ -183,6 +188,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand<Map<String,Object>>{
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 = "";
@ -290,6 +296,344 @@ public class TakeBackAgentCmd extends AbstractCommonCommand<Map<String,Object>>{
}
}
/**
*
*
* @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("==================== TakeBackAgentCmd DealPortalChaoSong ===================");
rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong agenterid ==================="+agenterid);
rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong beagenterid ==================="+ beagenterid);
rs.writeLog("==================== TakeBackAgentCmd DealPortalChaoSong workflowids ==================="+ workflowids);
try {
taskObject.put("objectAction", "0");
taskObject.put("objectType", "0");
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObject.put("objectId", getStaffId(beagenterid));
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
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 (" + agenterid +") 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) and t2.agenttype = 2 ";
String zhjkbs = "com.engine.workflow.cmd.agent.TakeBackAgentCmd.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("TakeBackAgentCmd 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(agenterid)));
taskObject1.put("objectId", getStaffId(agenterid));
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObjectList.add(taskObject1);
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
String auth = username + ":" + passwd;
rs.writeLog("================== TakeBackAgentCmd 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("TakeBackAgentCmd 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("==================== TakeBackAgentCmd DealPortalForward ===================");
rs.writeLog("==================== TakeBackAgentCmd DealPortalForward agenterid ==================="+agenterid);
rs.writeLog("==================== TakeBackAgentCmd DealPortalForward beagenterid ==================="+ beagenterid);
rs.writeLog("==================== TakeBackAgentCmd DealPortalForward workflowids ==================="+ workflowids);
try {
taskObject.put("objectAction", "0");
taskObject.put("objectType", "0");
taskObject.put("objectCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
taskObject.put("objectId", getStaffId(beagenterid));
taskObject.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(beagenterid)));
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 (" + agenterid +") 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) and t2.agenttype = 2 ";
String zhjkbs = "com.engine.workflow.cmd.agent.TakeBackAgentCmd.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("TakeBackAgentCmd 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(agenterid)));
taskObject1.put("objectId", getStaffId(agenterid));
taskObject1.put("operatorCode", new ResourceComInfo().getWorkcode(String.valueOf(agenterid)));
taskObjectList.add(taskObject1);
if (taskObjectList.size() > 0) {
requestObject.put("taskObjectList", taskObjectList);
} else {
requestObject.put("actionType", "3");
}
String auth = username + ":" + passwd;
rs.writeLog("================== TakeBackAgentCmd 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("TakeBackAgentCmd 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) + "...";

Loading…
Cancel
Save