From cc0d9d12b02ea3084132f3d3c4ed9fe501e37daa Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Tue, 28 May 2024 17:58:12 +0800 Subject: [PATCH] =?UTF-8?q?#EC=5FHJ158#=20=E6=9C=80=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dito/sendtodo/SendPortalToReadUtil.java | 4 +- .../workflow/cmd/agent/AddAgentSaveCmd.java | 48 +- .../cmd/agent/AddAgentSaveRunnable.java | 619 ++++++++++++++++++ .../dito/filter/PortalLoginBeforeFilter.java | 11 +- 4 files changed, 657 insertions(+), 25 deletions(-) create mode 100644 src/com/engine/workflow/cmd/agent/AddAgentSaveRunnable.java diff --git a/src/com/customization/dito/sendtodo/SendPortalToReadUtil.java b/src/com/customization/dito/sendtodo/SendPortalToReadUtil.java index 9332a862..57241be4 100644 --- a/src/com/customization/dito/sendtodo/SendPortalToReadUtil.java +++ b/src/com/customization/dito/sendtodo/SendPortalToReadUtil.java @@ -109,7 +109,7 @@ public class SendPortalToReadUtil { " 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" + " left join workflow_nodebase d1 on d1.id = t2.nodeid "+ " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + - " and t2.isremark in ('8','9')\n" + + " and t2.isremark in ('8','9') and t2.preisremark not in ('18') \n" + " and t2.islasttimes = 1 \n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and t2.requestid = "+requestid ; @@ -324,7 +324,7 @@ public class SendPortalToReadUtil { " 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" + " left join workflow_nodebase d1 on d1.id = t2.nodeid "+ " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + - " and t2.isremark in ('8','9')\n" + + " and t2.isremark in ('8','9') and t2.preisremark not in ('18') \n" + " and t2.islasttimes = 1\n" + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and t2.requestid = "+requestid ; diff --git a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java index ee058308..286b1077 100644 --- a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java +++ b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java @@ -12,6 +12,7 @@ import com.engine.workflow.biz.AgentBiz; 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; @@ -21,6 +22,8 @@ import weaver.workflow.agent.AgentManager; import javax.servlet.http.HttpServletRequest; import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,6 +40,9 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ public Map execute(CommandContext commandContext) { Map apidatas = new HashMap(); + BaseBean bb = new BaseBean(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + bb.writeLog("AddAgentSaveCmd--time1:"+sdf.format(new Date())); try{ int usertype = "2".equals(user.getLogintype()) ? 1 : 0; AgentBean bean = new AgentBean(); @@ -58,25 +64,31 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ String workflowids = agentManager.getAgentWorkflowRange(agentrange, rangetype, usertype); //重复处理方式 1、从新保存的代理设置中去除重复设置内容 2、以新保存的代理设置替换已有重复的代理设置 int overlapMethod = Util.getIntValue(request.getParameter("overlapMethod"), 0); - String agentresult = ""; + String agentresult = "success"; List bagentuidRange = AgentBiz.getBagentuidRange(request, user); - for(int bagentuid : bagentuidRange){ - bean.setBagentuid(bagentuid); - - //当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 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)) { - break; - } - } + bb.writeLog("AddAgentSaveCmd--time2:"+sdf.format(new Date())); + + AddAgentSaveRunnable addAgentSaveRunnable = new AddAgentSaveRunnable(user,bagentuidRange,bean,isPendThing,agentuid,workflowids,overlapMethod); + new Thread(addAgentSaveRunnable).start(); + bb.writeLog("AddAgentSaveCmd--time3:"+sdf.format(new Date())); + +// for(int bagentuid : bagentuidRange){ +// bean.setBagentuid(bagentuid); +// +// //当开启了代理原有待办时,对接门户,删除被代理人的待办,增加代理人的待办,部分流转 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)) { +// break; +// } +// } apidatas.put("agentresult", agentresult); }catch(Exception e){ apidatas.put("api_status", false); diff --git a/src/com/engine/workflow/cmd/agent/AddAgentSaveRunnable.java b/src/com/engine/workflow/cmd/agent/AddAgentSaveRunnable.java new file mode 100644 index 00000000..73a75403 --- /dev/null +++ b/src/com/engine/workflow/cmd/agent/AddAgentSaveRunnable.java @@ -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 bagentuidRange; + private AgentBean bean; + private int isPendThing; + private int agentuid; + private String workflowids; + private int overlapMethod; + + public AddAgentSaveRunnable(User user,List 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 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 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 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 getEmailTemplate(String requestname,String operator,String operatorTime){ + Map dataMap = new HashMap(); + 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; + } +} diff --git a/src/weaver/interfaces/dito/filter/PortalLoginBeforeFilter.java b/src/weaver/interfaces/dito/filter/PortalLoginBeforeFilter.java index bd2d1a50..902860c8 100644 --- a/src/weaver/interfaces/dito/filter/PortalLoginBeforeFilter.java +++ b/src/weaver/interfaces/dito/filter/PortalLoginBeforeFilter.java @@ -100,6 +100,8 @@ public class PortalLoginBeforeFilter implements Filter { } } + bb.writeLog("portal_uid8888:"+portal_uid); + //ecology=BA0A2738FBB4C7664CEECCC8B0CF408B; HTML_VERSION=1603079097996; // ZSMART_LOCALE=en; SESSION=4e101591-da0e-4425-b035-ffe684f85bca; // areaId=731; userId=1; orgId=1; @@ -111,8 +113,7 @@ public class PortalLoginBeforeFilter implements Filter { String weaver_uid = Util.null2String(request.getSession(true).getAttribute("weaver_uid")); //String portal_status = Util.null2String(request.getSession(true).getAttribute("portal_status")); -// bb.writeLog("weaver_uid:"+weaver_uid); -// bb.writeLog("uid:"+portal_uid); + bb.writeLog("weaver_uid:"+weaver_uid+" portal_uid:"+portal_uid); // bb.writeLog("portalUserAuth:"+portalUserAuth); if(StringUtils.isNotEmpty(weaver_uid)) @@ -121,7 +122,7 @@ public class PortalLoginBeforeFilter implements Filter { { // bb.writeLog("weaver_uid <> uid portal_status:"); String msg = httpRequestUtil.doGetHttp(portalUserAuth,portal_uid); -// bb.writeLog("msg:"+msg); + bb.writeLog("msg:"+msg); if (!"".equals(msg)) { JSONObject jsonObject = JSONObject.parseObject(msg); @@ -141,7 +142,7 @@ public class PortalLoginBeforeFilter implements Filter { User loginuser = (User) request.getSession(true).getAttribute("weaver_user@bean"); if(loginuser == null) { -// bb.writeLog("loginuser is null"); + bb.writeLog("loginuser is null"); String msg = httpRequestUtil.doGetHttp(portalUserAuth,portal_uid); if (StringUtils.isNotEmpty(msg)) { @@ -162,7 +163,7 @@ public class PortalLoginBeforeFilter implements Filter { }else { // bb.writeLog("weaver_uid is null "); String msg = httpRequestUtil.doGetHttp(portalUserAuth,portal_uid); -// bb.writeLog("msg:"+msg); + bb.writeLog("msg2:"+msg); if (StringUtils.isNotEmpty(msg)) { JSONObject jsonObject = JSONObject.parseObject(msg);