From d17d3e74dec5a44231d2d562196bd3be4a60479c Mon Sep 17 00:00:00 2001 From: wcf Date: Tue, 24 Oct 2023 13:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=8F=91=E3=80=81=E8=BD=AC=E5=8A=9E?= =?UTF-8?q?=E3=80=81=E6=B5=81=E7=A8=8B=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E9=83=A8=E5=88=86=E6=BA=90=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B91024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dito/sendtodo/SendPortalAtAddTodoCmd.java | 165 +++++++++- .../dito/sendtodo/SendPortalErrorUtil.java | 40 ++- .../dito/sendtodo/SendPortalForwardCmd.java | 304 +++++++++--------- .../sendtodo/SendPortalWithAddDoneCmd.java | 249 +++++++------- .../sendtodo/SendPortalWithAddTodoCmd.java | 196 ++++++++++- .../workflow/cmd/agent/AddAgentSaveCmd.java | 4 +- .../workflow/cmd/agent/TakeBackAgentCmd.java | 59 +++- .../cmd/requestForm/ForwardSubmitCmd.java | 8 +- .../communication/DoSaveReply.java | 221 +++++++++++++ 9 files changed, 950 insertions(+), 296 deletions(-) create mode 100644 src/com/engine/workflow/cmd/requestForm/communication/DoSaveReply.java diff --git a/src/com/customization/dito/sendtodo/SendPortalAtAddTodoCmd.java b/src/com/customization/dito/sendtodo/SendPortalAtAddTodoCmd.java index a5b4987d..94a8b6a0 100644 --- a/src/com/customization/dito/sendtodo/SendPortalAtAddTodoCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalAtAddTodoCmd.java @@ -7,6 +7,7 @@ import com.time.util.DateUtil; import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; +import weaver.general.TimeUtil; import weaver.general.Util; import weaver.hrm.User; import weaver.interfaces.dito.comInfo.PropBean; @@ -52,14 +53,14 @@ public class SendPortalAtAddTodoCmd { */ public void sendTodoDataByNode(String requestid, List> todolist, String username, String passwd, String center, String portal_todourl, String bpm_workflowurl, String bpm_app_workflowurl, String bpm_app_requesturl){ HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); - + String zhjkbs = "com.customization.dito.sendtodo.SendPortalAtAddTodoCmd.sendTodoDataByNode"; String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); JSONObject requestObject = new JSONObject(); RecordSet rs = new RecordSet(); BaseBean bb = new BaseBean(); - bb.writeLog("SendPortalQithRawRunnable--sendTodoDataByNode"); + bb.writeLog("SendPortalAtAddTodoCmd--sendTodoDataByNode"); String terminal = "1" ; String taskType = "0"; @@ -172,7 +173,8 @@ public class SendPortalAtAddTodoCmd { if (msgObject.containsKey("resultCode")) { String resultCode = msgObject.getString("resultCode"); if ("0".equals(resultCode)) { - sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,""); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,nodeId,nodeName, (String) todoMap.get("id"),requestObject2.toJSONString(),resultCode,"",zhjkbs); + sendPortalErrorUtil.saveAtRyjb(requestid,nodeId,(String) todoMap.get("id")); }else if ("TODO-FAIL-002".equals(resultCode)){ //The task does not exist.任务不存在,则新增 User user = new User(); @@ -183,7 +185,7 @@ public class SendPortalAtAddTodoCmd { }else{ String resultmsg = msgObject.getString("resultMsg"); - sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,rs.getString("nodename"),rs.getString("userid"),requestObject2.toJSONString(),resultCode,resultmsg); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,nodeId,nodeName, (String) todoMap.get("id"),requestObject2.toJSONString(),resultCode,resultmsg,zhjkbs); } } @@ -196,4 +198,159 @@ public class SendPortalAtAddTodoCmd { } } + /** + * 去除掉关于流程中@人员的所有门户待阅记录 + * @param requestid + */ + public void dealPortalAtRyjl(String requestid){ + RecordSet rs = new RecordSet(); + String uf_table = "uf_lcatryjlb" ; + rs.executeQuery("select * from "+ uf_table +" where requestid=?",requestid); + String nodeid = ""; + String userid = ""; + while(rs.next()){ + nodeid = Util.null2o(rs.getString("nodeid")); + userid = Util.null2o(rs.getString("userid")); + completePortalReadData(requestid,nodeid,userid); + } + } + + /*** + * + * @param requestid + * @param nodeid + * @param userid + */ + public String completePortalReadData(String requestid, String nodeid,String userid){ + String resultCode = "" ; + String zhjkbs = "com.engine.dito.reqremark.cmd.AtRequestRemarkCmd.completePortalReadData"; + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + + 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"); + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + String actionType = "3" ; + String terminal = "1" ; + String taskType = "1"; //0 – 待办 1 –待阅 + String objectAction = "0" ; + String objectType = "0"; + String objectId = "" ; + + JSONObject requestObject = new JSONObject(); + try { + + String workcode = ""; + String sql = " select * from (select id, lastname,loginid from hrmresource where status = 1 union all select id, lastname,loginid from hrmresourcemanager ) w where w.id = '" + userid + "'"; + rs.executeQuery(sql); + while (rs.next()) { + workcode = Util.null2String(rs.getString("loginid")); + } + + 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 requestname = ""; + String workflowname = "" ; + + sql = " select t1.requestname,t3.workflowname\n" + + " from workflow_requestbase t1\n" + + " inner join workflow_base t3 on t1.workflowid = t3.id\n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = " + requestid; + + rs.execute(sql); + if (rs.next()) { + workflowname = Util.null2String(rs.getString("workflowname")) ; + requestname = Util.null2String(rs.getString("requestname")) ; + } + + + String createdate = TimeUtil.getCurrentDateString(); + String createtime = TimeUtil.getCurrentTimeString(); + String nodename = getNodeName(nodeid); + + requestObject.put("center",center); + requestObject.put("title",requestname); + requestObject.put("creator",workcode); + requestObject.put("taskCode", requestid+"_at_"+userid); + requestObject.put("nodeId",nodeid); + requestObject.put("taskType",taskType); + requestObject.put("actionType",actionType); + requestObject.put("createDate",createdate+" "+createtime); + requestObject.put("messageTitle",requestname); + requestObject.put("messageContent",requestname); + requestObject.put("terminal",terminal); + requestObject.put("urlPc",urlPc); + requestObject.put("urlApp",urlApp); + requestObject.put("urlDing",urlDing); + requestObject.put("nodeName",getNodeName(nodeid)); + requestObject.put("ticketType",workflowname); + + + JSONArray taskObjectList = new JSONArray(); + JSONObject taskObject = new JSONObject(); + + String objectCode = workcode ; + String operatorCode = workcode ; + taskObject.put("objectAction",objectAction); + taskObject.put("objectType",objectType); + taskObject.put("objectCode",objectCode); + taskObject.put("objectId",objectId); + taskObject.put("operatorCode",operatorCode); + taskObjectList.add(taskObject); + + requestObject.put("taskObjectList",taskObjectList); + String auth = username + ":" + passwd; + String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth); + bb.writeLog("msgdata:"+msgdata); + if(StringUtils.isNotEmpty(msgdata)){ + JSONObject msgObject = JSONObject.parseObject(msgdata); + //{"resultCode":"1","resultMsg":"No Result"} + if(msgObject.containsKey("resultCode")){ + resultCode = msgObject.getString("resultCode"); + if(!"0".equals(resultCode)){ + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,nodeid,nodename,userid,requestObject.toJSONString(),resultCode,resultmsg,zhjkbs); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog(e); + } + return resultCode; + } + + /*** + * + * @param id + * @return + */ + private String getNodeName(String id){ + RecordSet rs = new RecordSet(); + String name = ""; + rs.executeQuery(" select nodename from workflow_nodebase where id = ?",id); + while (rs.next()){ + name = Util.null2String(rs.getString("nodename")); + } + return name; + } } diff --git a/src/com/customization/dito/sendtodo/SendPortalErrorUtil.java b/src/com/customization/dito/sendtodo/SendPortalErrorUtil.java index e5f24aa7..52d2342e 100644 --- a/src/com/customization/dito/sendtodo/SendPortalErrorUtil.java +++ b/src/com/customization/dito/sendtodo/SendPortalErrorUtil.java @@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; +import weaver.general.TimeUtil; import weaver.general.Util; import java.text.SimpleDateFormat; @@ -31,8 +32,8 @@ public class SendPortalErrorUtil { } String formmodeid = "" ; String sql =" select k.id from modeinfo k \n" + - " inner join workflow_bill l on formid = l.id\n" + - " where l.tablename = '"+uf_table+"' " ; + " inner join workflow_bill l on formid = l.id\n" + + " where l.tablename = '"+uf_table+"' " ; rs.execute(sql); if(rs.next()){ formmodeid = Util.null2String(rs.getString("id")); @@ -198,6 +199,39 @@ public class SendPortalErrorUtil { } } - + public void saveAtRyjb(String requestid,String nodeid,String userid){ + RecordSet rs = new RecordSet(); + String uf_table = "uf_lcatryjlb" ; + ModeRightInfo modeRightInfo = new ModeRightInfo(); + modeRightInfo.setNewRight(true); + String currentdate = TimeUtil.getCurrentDateString(); + String currenttime = TimeUtil.getOnlyCurrentTimeString(); + String uuid = UUID.randomUUID().toString(); + String formmodeid = "" ; + String sql =" select k.id from modeinfo k \n" + + " inner join workflow_bill l on formid = l.id\n" + + " where l.tablename = '"+uf_table+"' " ; + rs.execute(sql); + if(rs.next()){ + formmodeid = Util.null2String(rs.getString("id")); + } + sql = "insert into uf_lcatryjlb(lcid,nodeid,userid,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid,modeuuid) values(?,?,?,?,?,?,?,?)"; + boolean boo = rs.executeUpdate(sql,requestid,nodeid,userid,"1",currentdate,currenttime,formmodeid,uuid); + if(boo) + { + String dataid = "" ; + sql = " select * from "+uf_table+" where uuid='"+uuid+"' " ; + rs.writeLog("sql:"+sql); + rs.execute(sql); + if(rs.next()){ + dataid = Util.null2String(rs.getString("id")); + } + rs.writeLog("dataid:"+dataid); + if(!"".equals(dataid)) + { + modeRightInfo.editModeDataShare(1, Integer.parseInt(formmodeid), Integer.parseInt(dataid)); + } + } + } } diff --git a/src/com/customization/dito/sendtodo/SendPortalForwardCmd.java b/src/com/customization/dito/sendtodo/SendPortalForwardCmd.java index 9fcaa968..73d881e8 100644 --- a/src/com/customization/dito/sendtodo/SendPortalForwardCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalForwardCmd.java @@ -14,6 +14,7 @@ import weaver.interfaces.dito.comInfo.PropBean; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -48,8 +49,8 @@ public class SendPortalForwardCmd { } //转发 - public void forwardSendPortal(String requestid,int currentnodeid,User user) { - bb.writeLog("======== SendPortalForwardCmd forwardSendPortal ========================="); + public void forwardSendPortal(String requestid,int currentnodeid,User user,Set resourceids) { + bb.writeLog("======== SendPortalForwardCmd forwardSendPortal ========================="+ requestid); 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"); @@ -58,163 +59,165 @@ public class SendPortalForwardCmd { String center = PropBean.getUfPropValue("center"); String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); - String portal_doneurl = PropBean.getUfPropValue("portal_doneurl"); String cus_staff = PropBean.getUfPropValue("cus_staff") ; - String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); RecordSet rs = new RecordSet(); - try { - String zhjkbs = "com.customization.dito.sendtodo.SendPortalForwardCmd.forwardSendPortal"; - String actionType = "0"; - String terminal = "1"; - String taskType = "0"; - String objectAction = "0"; - String objectType = "0"; - - String sql = ""; - 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; - - 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; - - bb.writeLog("SendPortalForwardCmd --sql2:" + 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")); - } - - if (StringUtils.isNotEmpty(mobileJumpUrl)) { - urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); - urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); - } - JSONArray taskObjectList = new JSONArray(); - - bb.writeLog("SendPortalForwardCmd urlDing", urlDing); - - requestObject.put("center", center); - requestObject.put("title", requestname); - requestObject.put("creator", loginid); - requestObject.put("taskCode", "weaver_zf_" + requestid); - requestObject.put("nodeId", currentnodeid); - 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", getNodeName(currentnodeid)); - requestObject.put("ticketType", workflowname); - sql = " select t2.userid,h1.loginid,h1.email,c1." + cus_staff + " as staffid " + - " from workflow_requestbase t1\n" + - " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + - " left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= " + scopeid + " and c1.scope = '" + scope + "' " + - " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + - " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + - " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '7','11'))\n" + - " and t2.islasttimes = 1\n" + - " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + - " and t2.requestid = " + requestid; - - bb.writeLog("SendPortalForwardCmd forward --sql:" + sql); - rs.executeQuery(sql); - while (rs.next()) { - JSONObject taskObject = new JSONObject(); - - String usercode = Util.null2String(rs.getString("loginid")); - String staffid = Util.null2String(rs.getString("staffid")); - String userid1 = Util.null2String(rs.getString("userid")); - userids += StringUtils.isEmpty(userids) ? userid1 : "," + userid1; - - if ("sysadmin".equals(usercode)) { - usercode = "Admin"; + String zhjkbs = "com.customization.dito.sendtodo.SendPortalForwardCmd.forwardSendPortal"; + String actionType = "0"; + String terminal = "1"; + String taskType = "0"; + String objectAction = "0"; + String objectType = "0"; + + String sql = ""; + 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; + + String msgdata = ""; + String requestname = ""; + String lastname = ""; + String userids = ""; + String loginid = ""; + String emailArray = ""; + for(String userid : resourceids){ + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + try { + 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; + + bb.writeLog("SendPortalForwardCmd forward --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")); } - String objectCode = usercode; - String operatorCode = usercode; - - taskObject.put("objectAction", objectAction); - taskObject.put("objectType", objectType); - taskObject.put("objectCode", objectCode); - taskObject.put("objectId", staffid); - taskObject.put("operatorCode", operatorCode); - taskObjectList.add(taskObject); + if (StringUtils.isNotEmpty(mobileJumpUrl)) { + urlDing += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + urlApp += "&returnUrl=" + URLEncoder.encode(mobileJumpUrl, "UTF-8"); + } + JSONArray taskObjectList = new JSONArray(); + + bb.writeLog("SendPortalForwardCmd urlDing", urlDing); + + requestObject.put("center", center); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + requestObject.put("taskCode", "weaver_zf_" + requestid+"_"+ userid); + requestObject.put("nodeId", currentnodeid); + 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", getNodeName(currentnodeid)); + requestObject.put("ticketType", workflowname); + + sql = " select t2.userid,h1.loginid,h1.email,c1." + cus_staff + " as staffid " + + " from workflow_requestbase t1\n" + + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + + " left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= " + scopeid + " and c1.scope = '" + scope + "' " + + " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '7','11'))\n" + + " and t2.islasttimes = 1\n" + + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + + " and t2.requestid = " + requestid +" and t2.userid ="+ userid; + + bb.writeLog("SendPortalForwardCmd forward --sql:" + sql); + rs.executeQuery(sql); + while (rs.next()) { + JSONObject taskObject = new JSONObject(); + + String usercode = Util.null2String(rs.getString("loginid")); + String staffid = Util.null2String(rs.getString("staffid")); + String userid1 = Util.null2String(rs.getString("userid")); + userids += StringUtils.isEmpty(userids) ? userid1 : "," + userid1; + + if ("sysadmin".equals(usercode)) { + usercode = "Admin"; + } - String email = Util.null2String(rs.getString("email")); - bb.writeLog("SendPortalForwardCmd email3:" + email); - Matcher matcher = regex.matcher(email); - if (matcher.matches()) { - emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email; + String objectCode = usercode; + String operatorCode = usercode; + + taskObject.put("objectAction", objectAction); + taskObject.put("objectType", objectType); + taskObject.put("objectCode", objectCode); + taskObject.put("objectId", staffid); + taskObject.put("operatorCode", operatorCode); + taskObjectList.add(taskObject); + + String email = Util.null2String(rs.getString("email")); + bb.writeLog("SendPortalForwardCmd email3:" + email); + Matcher matcher = regex.matcher(email); + if (matcher.matches()) { + emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email; + } } - } - if (taskObjectList.size() > 0) { - requestObject.put("taskObjectList", taskObjectList); - } else { - requestObject.put("actionType", "3"); - } - bb.writeLog("SendPortalForwardCmd requestObject:" + requestObject.toJSONString()); - String auth = username + ":" + passwd; - 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)) { + if (taskObjectList.size() > 0) { + requestObject.put("taskObjectList", taskObjectList); + } else { + requestObject.put("actionType", "3"); + } + bb.writeLog("SendPortalForwardCmd forward requestObject:" + requestObject.toJSONString()); + String auth = username + ":" + passwd; + msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); + if (!"".equals(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + bb.writeLog("================ SendPortalForwardCmd forward msgObject ============= "+ msgObject.toJSONString()); + if (msgObject.containsKey("resultCode")) { + String resultCode = msgObject.getString("resultCode"); + if ("0".equals(resultCode)) { - bb.writeLog("SendPortalForwardCmd emailArray:" + emailArray); - if (StringUtils.isNotEmpty(emailArray)) { + bb.writeLog("SendPortalForwardCmd forward emailArray:" + emailArray); + if (StringUtils.isNotEmpty(emailArray)) { - Map templateMap = getEmailTemplate(requestname, lastname, processTime); - String notificationSubject = templateMap.get("notificationSubject"); - String notificationContent = templateMap.get("notificationContent"); + Map templateMap = getEmailTemplate(requestname, lastname, processTime); + String notificationSubject = templateMap.get("notificationSubject"); + String notificationContent = templateMap.get("notificationContent"); - sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); - } + sendMailUtil.sendMail(requestid, emailArray, notificationSubject, notificationContent); + } - sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "", zhjkbs); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, "", zhjkbs); - } else { - String resultmsg = msgObject.getString("resultMsg"); - sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg, zhjkbs); + } else { + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid, nodeId, nodeName, userids, requestObject.toJSONString(), resultCode, resultmsg, zhjkbs); + } } } + }catch (Exception e){ + bb.writeLog(e); + e.printStackTrace(); } - }catch (Exception e){ - bb.writeLog(e); - e.printStackTrace(); } } //转办 public void transferSendPortal(String requestid,int currentnodeid,User user){ - bb.writeLog("======== SendPortalForwardCmd transferSendPortal ========================="); + bb.writeLog("======== SendPortalForwardCmd transferSendPortal ========================="+requestid); 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"); @@ -267,7 +270,7 @@ public class SendPortalForwardCmd { " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " and t1.requestid = " + requestid; - bb.writeLog("SendPortalForwardCmd --sql2:" + sql); + bb.writeLog("SendPortalForwardCmd transfer --sql:" + sql); rs.executeQuery(sql); if (rs.next()) { @@ -285,7 +288,7 @@ public class SendPortalForwardCmd { } JSONArray taskObjectList = new JSONArray(); - bb.writeLog("SendPortalForwardCmd urlDing", urlDing); + bb.writeLog("SendPortalForwardCmd transfer urlDing", urlDing); requestObject.put("center", center); requestObject.put("title", requestname); @@ -315,7 +318,7 @@ public class SendPortalForwardCmd { " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + " and t2.requestid = " + requestid; - bb.writeLog("SendPortalForwardCmd forward --sql:" + sql); + bb.writeLog("SendPortalForwardCmd transfer --sql:" + sql); rs.executeQuery(sql); while (rs.next()) { JSONObject taskObject = new JSONObject(); @@ -340,7 +343,7 @@ public class SendPortalForwardCmd { taskObjectList.add(taskObject); String email = Util.null2String(rs.getString("email")); - bb.writeLog("SendPortalForwardCmd email3:" + email); + bb.writeLog("SendPortalForwardCmd transfer email:" + email); Matcher matcher = regex.matcher(email); if (matcher.matches()) { emailArray += StringUtils.isEmpty(emailArray) ? email : "," + email; @@ -351,16 +354,17 @@ public class SendPortalForwardCmd { } else { requestObject.put("actionType", "3"); } - bb.writeLog("================ SendPortalForwardCmd requestObject ============= "+ requestObject.toJSONString()); + bb.writeLog("================ SendPortalForwardCmd transfer requestObject ============= "+ requestObject.toJSONString()); String auth = username + ":" + passwd; msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); if (!"".equals(msgdata)) { JSONObject msgObject = JSONObject.parseObject(msgdata); + bb.writeLog("================ SendPortalForwardCmd transfer msgObject ============= "+ msgObject.toJSONString()); if (msgObject.containsKey("resultCode")) { String resultCode = msgObject.getString("resultCode"); if ("0".equals(resultCode)) { - bb.writeLog("SendPortalForwardCmd emailArray:" + emailArray); + bb.writeLog("SendPortalForwardCmd transfer emailArray:" + emailArray); if (StringUtils.isNotEmpty(emailArray)) { Map templateMap = getEmailTemplate(requestname, lastname, processTime); @@ -386,7 +390,7 @@ public class SendPortalForwardCmd { //流程归档转发处理 public void delTodoAddDoneSendPortal(String requestid,int currentnodeid,User user){ - bb.writeLog("======== SendPortalForwardCmd delTodoAddDoneSendPortal ========================="); + bb.writeLog("======== SendPortalForwardCmd delTodoAddDoneSendPortal ========================="+requestid); 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"); @@ -445,10 +449,10 @@ public class SendPortalForwardCmd { jsonObject.put("center", center); jsonObject.put("title", requestname); jsonObject.put("creator", loginid); - jsonObject.put("taskCode", "weaver_zf_" + requestid); + jsonObject.put("taskCode", "weaver_zf_" + requestid+"_"+user.getUID()); jsonObject.put("taskType", "0"); - jsonObject.put("actionType", "1"); + jsonObject.put("actionType", "3"); jsonObject.put("createDate", processTime); jsonObject.put("messageTitle", getShortMessageTitle(requestname)); jsonObject.put("messageContent", requestname); @@ -468,12 +472,13 @@ public class SendPortalForwardCmd { taskObject.put("objectId", rs.getString("staffid")); taskObject.put("operatorCode", user.getLoginid()); jsonObject.put("taskObjectList", list); - bb.writeLog("SendPortalWithAddDoneCmd--delTodoAddDoneSendPortal--requestObject:" + jsonObject.toJSONString()); + bb.writeLog("SendPortalWithAddDoneCmd--delTodoAddDoneSendPortal--deltodo--requestObject:" + jsonObject.toJSONString()); String auth = username + ":" + passwd; msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, jsonObject.toJSONString(), auth); bb.writeLog("SendPortalWithAddDoneCmd-delTodoAddDoneSendPortal-msgdata:" + msgdata); if (StringUtils.isNotEmpty(msgdata)) { JSONObject msgObject = JSONObject.parseObject(msgdata); + bb.writeLog("SendPortalWithAddDoneCmd--delTodoAddDoneSendPortal--msgObject:" + msgObject.toJSONString()); if (msgObject.containsKey("resultCode")) { String resultCode = msgObject.getString("resultCode"); if (!"0".equals(resultCode)) { @@ -506,6 +511,7 @@ public class SendPortalForwardCmd { bb.writeLog("delTodoAddDoneSendPortal done msgdata:" + msgdata); if (StringUtils.isNotEmpty(msgdata)) { JSONObject msgObject = JSONObject.parseObject(msgdata); + bb.writeLog("SendPortalWithAddDoneCmd--delTodoAddDoneSendPortal--adddone--msgObject:" + msgObject.toJSONString()); //{"resultCode":"1","resultMsg":"No Result"} if (msgObject.containsKey("resultCode")) { String resultCode = msgObject.getString("resultCode"); diff --git a/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java index 0dbe2202..00d7b518 100644 --- a/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java @@ -5,12 +5,10 @@ import com.alibaba.fastjson.JSONObject; import com.constant.Constants; import com.engine.core.interceptor.CommandContext; import com.time.util.DateUtil; -import org.apache.bcel.classfile.Constant; import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; -import weaver.hrm.User; import weaver.interfaces.dito.comInfo.PropBean; import java.io.UnsupportedEncodingException; @@ -18,8 +16,6 @@ import java.net.URLEncoder; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class SendPortalWithAddDoneCmd { private Map params; @@ -89,121 +85,130 @@ public class SendPortalWithAddDoneCmd { } } for (Map doneMap:donelist){ - - //判断是否是抄送流程 - // String cus_staff = PropBean.getUfPropValue("cus_staff") ; - String scopeid = "-1"; - String scope = "HrmCustomFieldByInfoType" ; - String sql = " select count(0) num "+ - " from workflow_requestbase t1\n" + - " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + - " left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' "+ - " 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 t1.currentnodetype <> 3"+ - " and t2.isremark in ('2','9')\n" + - " and t2.preisremark in ('8','9')\n" + - " and t2.islasttimes = 1\n" + - " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + - " and t2.requestid = "+requestid + " and t2.userid = "+doneMap.get("id"); - - rs.executeQuery(sql); - int num = 0; - //过滤非归档节点,抄送待阅流程 - if(rs.next()){ - num = rs.getInt("num"); - } - //判断是否为转发节点 - sql = "SELECT c1."+PropBean.getUfPropValue("cus_staff")+" as staffid FROM workflow_currentoperator t1 left join cus_fielddata c1 on c1.id = t1.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' WHERE t1.preisremark=1 and t1.REQUESTID=? and t1.USERID=?"; - rs.executeQuery(sql,requestid,doneMap.get("id")); - if (rs.next()){ - //删除转发的待办 - JSONObject jsonObject = new JSONObject(); - - jsonObject.put("center",center); - jsonObject.put("title",doneMap.get("requestname")); - jsonObject.put("creator",doneMap.get("creater")); - jsonObject.put("taskCode","weaver"+requestid); - - jsonObject.put("taskType","0"); - jsonObject.put("actionType","1"); - jsonObject.put("createDate",processTime); - jsonObject.put("messageTitle",getShortMessageTitle(doneMap.get("requestname").toString())); - jsonObject.put("messageContent",doneMap.get("requestname")); - jsonObject.put("terminal","1"); - jsonObject.put("urlPc",urlPc); - jsonObject.put("urlApp",urlApp); - jsonObject.put("urlDing",urlDing); - jsonObject.put("nodeName",doneMap.get("nodename")); - jsonObject.put("ticketType",doneMap.get("workflowname")); - - JSONArray list = new JSONArray(); - JSONObject taskObject = new JSONObject(); - list.add(taskObject); - taskObject.put("objectAction","1"); - taskObject.put("objectType","0"); - taskObject.put("objectCode",doneMap.get("loginid")); - taskObject.put("objectId",rs.getString("staffid")); - taskObject.put("operatorCode",doneMap.get("loginid")); - jsonObject.put("taskObjectList",list); - bb.writeLog("SendPortalWithAddDoneCmd--delete forward workflow--requestObject:" + jsonObject.toJSONString()); - String auth = username + ":" + passwd; - String msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, jsonObject.toJSONString(), auth); - bb.writeLog("SendPortalToReadUtil-msgdata:" + msgdata); - if(StringUtils.isNotEmpty(msgdata)) { - JSONObject msgObject = JSONObject.parseObject(msgdata); - if(msgObject.containsKey("resultCode")){ - String resultCode = msgObject.getString("resultCode"); - if(!"0".equals(resultCode)){ - String resultmsg = msgObject.getString("resultMsg"); - sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,doneMap.get("id").toString(),doneMap.get("nodename").toString(),doneMap.get("id").toString(),jsonObject.toJSONString(),resultCode,resultmsg); + int workflowid = (int) doneMap.get("workflowid"); + int userid= (int) doneMap.get("id"); + + boolean bool = checkIsAgent(workflowid,userid); + bb.writeLog("=============== SendPortalWithAddDoneCmd workflowid =================== " + workflowid); + bb.writeLog("=============== SendPortalWithAddDoneCmd userid =================== " + userid); + bb.writeLog("=============== SendPortalWithAddDoneCmd bool =================== " + bool); + //没有流程代理的情况下 + if(!bool){ + //判断是否是抄送流程 + // String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + String sql = " select count(0) num "+ + " from workflow_requestbase t1\n" + + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + + " left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' "+ + " 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 t1.currentnodetype <> 3"+ + " and t2.isremark in ('2','9')\n" + + " and t2.preisremark in ('8','9')\n" + + " and t2.islasttimes = 1\n" + + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + + " and t2.requestid = "+requestid + " and t2.userid = "+ userid; + + rs.executeQuery(sql); + int num = 0; + //过滤非归档节点,抄送待阅流程 + if(rs.next()){ + num = rs.getInt("num"); + } + //判断是否为转发节点 + sql = "SELECT c1."+ PropBean.getUfPropValue("cus_staff")+" as staffid FROM workflow_currentoperator t1 left join cus_fielddata c1 on c1.id = t1.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' WHERE t1.preisremark=1 and t1.REQUESTID=? and t1.USERID=?"; + rs.executeQuery(sql,requestid,doneMap.get("id")); + if (rs.next()){ + //删除转发的待办 + JSONObject jsonObject = new JSONObject(); + + jsonObject.put("center",center); + jsonObject.put("title",doneMap.get("requestname")); + jsonObject.put("creator",doneMap.get("creater")); + jsonObject.put("taskCode","weaver"+requestid); + + jsonObject.put("taskType","0"); + jsonObject.put("actionType","1"); + jsonObject.put("createDate",processTime); + jsonObject.put("messageTitle",getShortMessageTitle(doneMap.get("requestname").toString())); + jsonObject.put("messageContent",doneMap.get("requestname")); + jsonObject.put("terminal","1"); + jsonObject.put("urlPc",urlPc); + jsonObject.put("urlApp",urlApp); + jsonObject.put("urlDing",urlDing); + jsonObject.put("nodeName",doneMap.get("nodename")); + jsonObject.put("ticketType",doneMap.get("workflowname")); + + JSONArray list = new JSONArray(); + JSONObject taskObject = new JSONObject(); + list.add(taskObject); + taskObject.put("objectAction","1"); + taskObject.put("objectType","0"); + taskObject.put("objectCode",doneMap.get("loginid")); + taskObject.put("objectId",rs.getString("staffid")); + taskObject.put("operatorCode",doneMap.get("loginid")); + jsonObject.put("taskObjectList",list); + bb.writeLog("SendPortalWithAddDoneCmd--delete forward workflow--requestObject:" + jsonObject.toJSONString()); + String auth = username + ":" + passwd; + String msgdata = httpRequestUtil.doPostByAuth(Constants.portal_todourl, jsonObject.toJSONString(), auth); + bb.writeLog("SendPortalToReadUtil-msgdata:" + msgdata); + if(StringUtils.isNotEmpty(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + if(msgObject.containsKey("resultCode")){ + String resultCode = msgObject.getString("resultCode"); + if(!"0".equals(resultCode)){ + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,doneMap.get("id").toString(),doneMap.get("nodename").toString(),doneMap.get("id").toString(),jsonObject.toJSONString(),resultCode,resultmsg); + } } } - } - } - if (num == 0){ - - bb.writeLog("num :"+num+",userid"+doneMap.get("id")); - String nodeid = requestid+doneMap.get("id"); - String workflowname = Util.null2String(doneMap.get("workflowname")); - String requestname = Util.null2String(doneMap.get("requestname")); - String loginid = Util.null2String(doneMap.get("loginid")); - String creater = Util.null2String(doneMap.get("creater")); - String nodeName = Util.null2String(doneMap.get("nodename")); - JSONObject requestObject = new JSONObject(); - requestObject.put("center", center); - requestObject.put("taskCode", "weaver"+requestid); - requestObject.put("nodeId", nodeid); - requestObject.put("ticketType", workflowname); - requestObject.put("title", requestname); - requestObject.put("creator", creater); - requestObject.put("processStaff", loginid); - requestObject.put("processTime", processTime); - requestObject.put("isRecall", isRecall); - requestObject.put("actionType", actionType); - requestObject.put("urlPC", urlPc); - requestObject.put("urlApp", urlApp); - requestObject.put("urlDing",urlDing); - - String userids = Util.null2String(doneMap.get("id")) ; - String auth = username + ":" + passwd; - bb.writeLog("done requestObject:" + requestObject.toJSONString()); - String msgdata = httpRequestUtil.doPostByAuth(portal_doneurl, requestObject.toJSONString(), auth); - bb.writeLog("done msgdata:" + msgdata); - if(StringUtils.isNotEmpty(msgdata)) { - JSONObject msgObject = JSONObject.parseObject(msgdata); - //{"resultCode":"1","resultMsg":"No Result"} - if(msgObject.containsKey("resultCode")){ - String resultCode = msgObject.getString("resultCode"); - if(!"0".equals(resultCode)){ - String resultmsg = msgObject.getString("resultMsg"); - sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeid,nodeName,userids,requestObject.toJSONString(),resultCode,resultmsg); + } + if (num == 0){ + + bb.writeLog("num :"+num+",userid"+doneMap.get("id")); + String nodeid = requestid+doneMap.get("id"); + String workflowname = Util.null2String(doneMap.get("workflowname")); + String requestname = Util.null2String(doneMap.get("requestname")); + String loginid = Util.null2String(doneMap.get("loginid")); + String creater = Util.null2String(doneMap.get("creater")); + String nodeName = Util.null2String(doneMap.get("nodename")); + JSONObject requestObject = new JSONObject(); + requestObject.put("center", center); + requestObject.put("taskCode", "weaver"+requestid); + requestObject.put("nodeId", nodeid); + requestObject.put("ticketType", workflowname); + requestObject.put("title", requestname); + requestObject.put("creator", creater); + requestObject.put("processStaff", loginid); + requestObject.put("processTime", processTime); + requestObject.put("isRecall", isRecall); + requestObject.put("actionType", actionType); + requestObject.put("urlPC", urlPc); + requestObject.put("urlApp", urlApp); + requestObject.put("urlDing",urlDing); + + String userids = Util.null2String(doneMap.get("id")) ; + String auth = username + ":" + passwd; + bb.writeLog("done requestObject:" + requestObject.toJSONString()); + String msgdata = httpRequestUtil.doPostByAuth(portal_doneurl, requestObject.toJSONString(), auth); + bb.writeLog("done msgdata:" + msgdata); + if(StringUtils.isNotEmpty(msgdata)) { + JSONObject msgObject = JSONObject.parseObject(msgdata); + //{"resultCode":"1","resultMsg":"No Result"} + if(msgObject.containsKey("resultCode")){ + String resultCode = msgObject.getString("resultCode"); + if(!"0".equals(resultCode)){ + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeid,nodeName,userids,requestObject.toJSONString(),resultCode,resultmsg); + } } } - } + } } } @@ -232,4 +237,22 @@ public class SendPortalWithAddDoneCmd { dataMap.put("notificationContent",notificationContent); return dataMap; } + + /** + * 判断流程是否有代理 + * @param workflowid + * @param userid + * @return + */ + public boolean checkIsAgent(int workflowid,int userid){ + boolean flag = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select distinct b.* from workflow_requestbase a,Workflow_Agent b " + + " where a.workflowid=b.workflowId " + + " and b.workflowid=? and b.beagenterId=? and b.agenttype=1",workflowid,userid); + if(rs.next()){ + flag = true; + } + return flag; + } } diff --git a/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java index fb230ae3..0036dc92 100644 --- a/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java @@ -26,6 +26,9 @@ public class SendPortalWithAddTodoCmd { private Map params; public static String EMAIL_REGEX_DEFAULT = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; + public SendPortalWithAddTodoCmd(){ + } + public SendPortalWithAddTodoCmd(Map params){ this.params=params; } @@ -48,7 +51,7 @@ public class SendPortalWithAddTodoCmd { return null; } - private String getShortMessageTitle(String messageTitle) { + public String getShortMessageTitle(String messageTitle) { if (messageTitle.length() > 20) { messageTitle = messageTitle.substring(0, 17) + "..."; } @@ -84,7 +87,7 @@ public class SendPortalWithAddTodoCmd { try { bb.writeLog("SendPortalWithAddTodoCmd sleep start"); - Thread.sleep(1000); + Thread.sleep(2000); bb.writeLog("sleep end "); String sql = ""; @@ -154,7 +157,7 @@ public class SendPortalWithAddTodoCmd { JSONArray taskObjectList = new JSONArray(); for (Map todoMap: todolist){ JSONObject taskObject = new JSONObject(); - + bb.writeLog("=============================== SendPortalWithAddTodoCmd todoMap ========================== "+ todoMap); // sql = " select count(0) num "+ // " from workflow_requestbase t1\n" + // " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + @@ -177,6 +180,141 @@ public class SendPortalWithAddTodoCmd { // continue; // } // bb.writeLog("num :"+num+",userid:"+todoMap.get("id")); + bb.writeLog("=============================== SendPortalWithAddTodoCmd nodeid ========================== "+ todoMap.get("nodeid")); + String lastnodeid = getLastnodeid(requestid, (int) todoMap.get("nodeid")); + bb.writeLog("=============================== SendPortalWithAddTodoCmd lastnodeid ========================== "+ lastnodeid); + boolean flag = checkIsOvertime(requestid,lastnodeid); + bb.writeLog("=============================== SendPortalWithAddTodoCmd 上一节点是超时提交的 flag ========================== "+ flag); + //上一节点是超时提交的 + if(flag){ + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + SendMailUtil sendMailUtil = new SendMailUtil(); + String msgdata = ""; + String lastname = ""; + String userids = "" ; + String loginid = "" ; + Pattern regex = Pattern.compile(EMAIL_REGEX_DEFAULT); + 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 ; + + bb.writeLog("SendPortalWithAddTodoCmd overtime --sql2:"+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")+todoMap.get("id")) ; + nodeName = Util.null2String(rs.getString("nodeName")) ; + lastname = Util.null2String(rs.getString("lastname")) ; + loginid = Util.null2String(rs.getString("loginid")) ; + } + + if(StringUtils.isNotEmpty(mobileJumpUrl)){ + urlDing += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8"); + urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8"); + } + + + bb.writeLog("urlDing", urlDing); + + requestObject.put("center",center); + requestObject.put("title",requestname); + requestObject.put("creator",loginid); + requestObject.put("taskCode","weaver"+requestid); + requestObject.put("nodeId",lastnodeid); + requestObject.put("taskType",taskType); + requestObject.put("actionType","2"); + 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",getNodeName(lastnodeid)); + requestObject.put("ticketType",workflowname); + + sql = " select t2.userid,h1.loginid,h1.email,c1."+cus_staff+" as staffid "+ + " from workflow_requestbase t1\n" + + " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\n" + + " left join cus_fielddata c1 on c1.id = t2.userid and c1.scopeid= "+scopeid+" and c1.scope = '"+scope+"' "+ + " left join (select id, lastname,loginid,email from hrmresource where STATUS = 1 union all select id,lastname,loginid,'' as email from hrmresourcemanager ) h1 on h1.id = t2.userid\n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and ((t2.isremark = '0' and (t2.takisremark is null or t2.takisremark = 0)) or t2.isremark in ('1', '5', '7','11'))\n" + + " and t2.islasttimes = 1\n" + + " and (t2.isprocessing = '' or t2.isprocessing is null)\n" + + " and t2.requestid = "+requestid; + + bb.writeLog("SendPortalWithAddTodoCmd overtime --sql:"+sql); + rs.executeQuery(sql); + while (rs.next()){ + + String usercode = Util.null2String(rs.getString("loginid")) ; + String staffid = Util.null2String(rs.getString("staffid")) ; + String userid = Util.null2String(rs.getString("userid")) ; + userids += StringUtils.isEmpty(userids) ? userid : ","+userid ; + + if("sysadmin".equals(usercode)){ + usercode = "Admin"; + } + + String objectCode = usercode ; + String operatorCode = usercode ; + + taskObject.put("objectAction","0"); + taskObject.put("objectType","0"); + taskObject.put("objectCode",objectCode); + taskObject.put("objectId",staffid); + taskObject.put("operatorCode",operatorCode); + taskObjectList.add(taskObject); + + String email = Util.null2String(rs.getString("email")) ; + bb.writeLog("email3:"+email); + Matcher matcher = regex.matcher(email); + if(matcher.matches()){ + emailArray += StringUtils.isEmpty(emailArray) ? email : ","+email ; + } + } + if (taskObjectList.size() >0){ + requestObject.put("taskObjectList",taskObjectList); + }else { + requestObject.put("actionType","3"); + } + String auth = username + ":" + passwd; + 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)){ + + bb.writeLog("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.doRecordPortalErrorInfo(requestid,nodeId,nodeName,userids,requestObject.toJSONString(),resultCode,""); + + }else{ + String resultmsg = msgObject.getString("resultMsg"); + sendPortalErrorUtil.doRecordPortalErrorInfo(requestid,nodeId,nodeName,userids,requestObject.toJSONString(),resultCode,resultmsg); + } + } + } + } sql = " select t2.userid,h1.loginid,h1.lastname,h1.email,t2.isremark,t1.requestid,t2.nodeid,d1.nodename,c1."+cus_staff+" as staffid "+ " from workflow_requestbase t1\n" + @@ -205,7 +343,6 @@ public class SendPortalWithAddTodoCmd { String email = Util.null2String(rs.getString("email")); requestObject2.put("nodeName",rs.getString("nodename")); requestObject2.put("nodeId",rs.getString("nodeid")); - //requestObject2.put("taskCode",rs.getString("requestid")+"_cs_"+nodeId+"_"+rs.getString("userid")); requestObject2.put("taskCode",rs.getString("requestid")+"_cs_"+rs.getString("userid")); @@ -328,6 +465,7 @@ public class SendPortalWithAddTodoCmd { } catch (Exception e) { e.printStackTrace(); + bb.writeLog(e); } } /*** @@ -349,4 +487,54 @@ public class SendPortalWithAddTodoCmd { return dataMap; } + /** + * 判断流程节点是否是 超时处理提交的 + * @param requestid + * @param nodeid + * @return + */ + public boolean checkIsOvertime(String requestid,String nodeid){ + boolean flag = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from workflow_currentoperator where requestid=? and nodeid=?",requestid,nodeid); + if(rs.next()){ + double overtime = Util.getDoubleValue(rs.getString("overtime"),0); + if(overtime > 0){ + flag = true; + } + } + return flag; + } + + /** + * 获取上一节点id + * @param requestid + * @param nodeid + * @return + */ + public String getLastnodeid(String requestid,int nodeid){ + String result = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from workflow_requestbase where requestid=? and currentnodeid=?",requestid,nodeid); + if(rs.next()){ + result = Util.null2String(rs.getString("lastnodeid")); + } + return result; + } + + /*** + * + * @param id + * @return + */ + public String getNodeName(String id){ + RecordSet rs = new RecordSet(); + String name = ""; + rs.executeQuery(" select nodename from workflow_nodebase where id = ?",id); + while (rs.next()){ + name = Util.null2String(rs.getString("nodename")); + } + return name; + } + } diff --git a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java index 229e5637..7c35e205 100644 --- a/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java +++ b/src/com/engine/workflow/cmd/agent/AddAgentSaveCmd.java @@ -224,7 +224,7 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ String resultCode = msgObject.getString("resultCode"); if ("0".equals(resultCode)) { - rs.writeLog("SendPortalForwardCmd emailArray:" + emailArray); + rs.writeLog("AddAgentSaveCmd emailArray:" + emailArray); if (StringUtils.isNotEmpty(emailArray)) { Map templateMap = getEmailTemplate(requestname, lastname, processTime); @@ -279,7 +279,7 @@ public class AddAgentSaveCmd extends AbstractCommonCommand>{ 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("")); + result = Util.getIntValue(rs.getString(cus_staff)); return result; } diff --git a/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java b/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java index 0dea3ace..643d3579 100644 --- a/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java +++ b/src/com/engine/workflow/cmd/agent/TakeBackAgentCmd.java @@ -42,24 +42,31 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ AgentManager agentManager = new AgentManager(user); String symbol = Util.null2String(request.getParameter("symbol")); boolean needBackRunning = "1".equals(Util.null2String(request.getParameter("backRunning"))); //收回流转中数据 + List range = new ArrayList(); if ("it".equals(symbol) || "mt".equals(symbol)) { //单个、批量收回代理 String agentids = Util.null2String(request.getParameter("agentid")); agentids = this.getAuthByUser(agentids); - List range = new ArrayList(); for(String keyid : agentids.split(",")){ if(!"".equals(keyid)) range.add(keyid); } agentManager.takeBackAgent(range, needBackRunning); + if(needBackRunning){ + SendPortalTodoAndDone(range); + } }else if ("pt".equals(symbol)) { // 全部收回逻辑 int agentid = Util.getIntValue(request.getParameter("agentid")); int bagentuid = Util.getIntValue(request.getParameter("bagentuid")); String agentuid = agentManager.getAgentuid(agentid, bagentuid); if(Util.getIntValue(agentuid) > 0){ - List range = agentManager.getAgentRangeByUser(Util.getIntValue(agentuid), bagentuid); + range = agentManager.getAgentRangeByUser(Util.getIntValue(agentuid), bagentuid); agentManager.takeBackAgent(range, needBackRunning); } } + // 推送门户处理待办和已办 + if(needBackRunning){ + SendPortalTodoAndDone(range); + } } catch (Exception e) { flag = false; e.printStackTrace(); @@ -101,26 +108,44 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ } public void SendPortalTodoAndDone(List range){ - int agenterid = -1; - int beagenterid = -1; + RecordSet rs = new RecordSet(); + int agenterid = 1; + int beagenterid = 1; String workflowids = ""; for(String agentid : range){ + rs.executeQuery("select * from workflow_agent where agentid=?",agentid); + rs.next(); + agenterid = Util.getIntValue(rs.getString("agenterid")); + beagenterid = Util.getIntValue(rs.getString("beagenterid")); + workflowids = Util.null2String(rs.getString("workflowid")); + DealPortalTodoAndDone(agenterid,beagenterid,workflowids); } + } + + /** + * 先查询出被代理人的待办,然后一一推送给门户,代理人待办增加,被代理人待办删除 + * @param agenterid 代理人 + * @param beagenterid 被代理人 + * @param workflowids 指定流程id + */ + public void DealPortalTodoAndDone(int agenterid, int beagenterid, String workflowids){ RecordSet rs = 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 ==================="); - + rs.writeLog("==================== TakeBackAgentCmd DealPortalTodoAndDone ==================="); + rs.writeLog("==================== TakeBackAgentCmd DealPortalTodoAndDone agenterid ==================="+agenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalTodoAndDone beagenterid ==================="+ beagenterid); + rs.writeLog("==================== TakeBackAgentCmd DealPortalTodoAndDone workflowids ==================="+ workflowids); 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))); + 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(); @@ -151,7 +176,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ " and t2.islasttimes=1 " + " and (t.isvalid=3 or t.isvalid=1) "; - String zhjkbs = "com.engine.workflow.cmd.agent.AddAgentSaveCmd.DealPortalTodoAndDone"; + String zhjkbs = "com.engine.workflow.cmd.agent.TakeBackAgentCmd.DealPortalTodoAndDone"; String actionType = "1"; String terminal = "1"; String taskType = "0"; @@ -187,7 +212,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + " and t1.requestid = " + requestid; - rs.writeLog("AddAgentSaveCmd DealPortalTodoAndDone -- sql:" + sql); + rs.writeLog("TakeBackAgentCmd DealPortalTodoAndDone -- sql:" + sql); rs.executeQuery(sql); if (rs.next()) { @@ -218,9 +243,9 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ 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))); + 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) { @@ -230,7 +255,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ } String auth = username + ":" + passwd; - rs.writeLog("================== AddAgentSaveCmd DealPortalTodoAndDone ======================== "+requestObject.toJSONString()); + rs.writeLog("================== TakeBackAgentCmd DealPortalTodoAndDone ======================== "+requestObject.toJSONString()); msgdata = httpRequestUtil.doPostByAuth(portal_todourl, requestObject.toJSONString(), auth); if (!"".equals(msgdata)) { @@ -239,7 +264,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ String resultCode = msgObject.getString("resultCode"); if ("0".equals(resultCode)) { - rs.writeLog("SendPortalForwardCmd emailArray:" + emailArray); + rs.writeLog("TakeBackAgentCmd emailArray:" + emailArray); if (StringUtils.isNotEmpty(emailArray)) { Map templateMap = getEmailTemplate(requestname, lastname, processTime); @@ -294,7 +319,7 @@ public class TakeBackAgentCmd extends AbstractCommonCommand>{ 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("")); + result = Util.getIntValue(rs.getString(cus_staff)); return result; } diff --git a/src/com/engine/workflow/cmd/requestForm/ForwardSubmitCmd.java b/src/com/engine/workflow/cmd/requestForm/ForwardSubmitCmd.java index ac61055f..f7a8ccc5 100644 --- a/src/com/engine/workflow/cmd/requestForm/ForwardSubmitCmd.java +++ b/src/com/engine/workflow/cmd/requestForm/ForwardSubmitCmd.java @@ -1609,11 +1609,11 @@ public class ForwardSubmitCmd extends AbstractCommonCommand>{ if(forwardflag == 1){ try { Class clazz = Class.forName("com.customization.dito.sendtodo.SendPortalForwardCmd"); - if (clazz.getMethod("forwardSendPortal", new Class[]{String.class, int.class, User.class}) != null) { - Method method = clazz.getMethod("forwardSendPortal", new Class[]{String.class, int.class, User.class}); + if (clazz.getMethod("forwardSendPortal", new Class[]{String.class, int.class, User.class,Set.class}) != null) { + Method method = clazz.getMethod("forwardSendPortal", new Class[]{String.class, int.class, User.class, Set.class}); Object newInstance = clazz.newInstance(); - method.invoke(newInstance, requestid, currentnodeid, user); + method.invoke(newInstance, requestid, currentnodeid, user, resourceids); } }catch (Exception e){ e.printStackTrace(); @@ -1729,7 +1729,7 @@ public class ForwardSubmitCmd extends AbstractCommonCommand>{ Map params = new HashMap<>(); - params.put("reminder", StringUtils.join(resourceids,",")); + params.put("reminder",StringUtils.join(resourceids,",")); params.put("requestId",requestId); params.put("workflowId",wfId); params.put("submitType",submitType); diff --git a/src/com/engine/workflow/cmd/requestForm/communication/DoSaveReply.java b/src/com/engine/workflow/cmd/requestForm/communication/DoSaveReply.java new file mode 100644 index 00000000..f694dae7 --- /dev/null +++ b/src/com/engine/workflow/cmd/requestForm/communication/DoSaveReply.java @@ -0,0 +1,221 @@ +package com.engine.workflow.cmd.requestForm.communication; + +import com.customization.qc2563600.CCOperatorUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.workflow.biz.WorkflowCommunicationBiz; +import com.engine.workflow.entity.requestForm.communication.Reply; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.dito.comInfo.PropBean; + +import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 保存回复 + */ +public class DoSaveReply extends AbstractCommonCommand> { + + public DoSaveReply() {} + + public DoSaveReply(Map params, User user) { + this.params = params; + this.user = user; + } + + /** + * 生成logContext对象 + * + * @return BizLogContext对象 + */ + @Override + public BizLogContext getLogContext() { + return null; + } + + protected String getParams(String key) { + return Util.null2String(params.get(key)); + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap<>(); + int contentId = Util.getIntValue(getParams("contentId")); + int communicationId = Util.getIntValue(getParams("communicationId")); + int requestid = Util.getIntValue(getParams("requestid")); + String nodeid = getParams("nodeid"); + if(communicationId<0){ + + int refRequestId = Util.getIntValue(Util.null2String(getParams("refRequestId"))); + int isSubReqeuestid = Util.getIntValue(Util.null2String(getParams("isSubReqeuestid"))); + if(isSubReqeuestid==1){ + requestid = refRequestId; + } + communicationId = WorkflowCommunicationBiz.getCommunicationId(requestid); + } + String remark = getParams("remark"); + + int resiveUser = Util.getIntValue(getParams("receiveUser"), -1); + int resiveUserType = Util.getIntValue(getParams("resiveUserType"), 1); + int replyId = Util.getIntValue(getParams("replayid")); + + Date newDate = new Date(); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); + + String dateStr = dateFormat.format(newDate); + String timeStr = timeFormat.format(newDate); + + String projectIDs = Util.null2String(params.get("projectIDs")); + String relatedacc = Util.null2String(params.get("relatedacc")); + String relatedcus = Util.null2String(params.get("relatedcus")); + String relateddoc = Util.null2String(params.get("relateddoc")); + String relatedprj = Util.null2String(params.get("relatedprj")); + String relatedwf = Util.null2String(params.get("relatedwf")); + + Reply reply = new Reply(); + reply.setContentId(contentId); + reply.setRemark(remark); + reply.setResiveUser(resiveUser); + reply.setResiveUserType(resiveUserType); + reply.setCreateUser(user.getUID()); + reply.setCreateUserType(Util.getIntValue(user.getLogintype(), 1)); + reply.setCreateDate(dateStr); + reply.setCreateTime(timeStr); + reply.setProjectIds(projectIDs); + reply.setRelatedAcc(relatedacc); + reply.setRelatedCus(relatedcus); + reply.setRelatedDoc(relateddoc); + reply.setRelatedPrj(relatedprj); + reply.setRelatedWf(relatedwf); + reply.setReplyId(replyId); + int insertReplyId = reply.insertReplayToDB(); + + if (resiveUser < 0) {//没有被回复人,则提醒交流内容的创建人 + RecordSet rs = new RecordSet(); + rs.executeQuery("select createuser from workflow_communicationcontent where id = ?", contentId); + if (rs.next()) { + resiveUser = Util.getIntValue(rs.getString("createuser")); + } + } + + if(insertReplyId > 0) { + //回复成功后,更新消息提醒 + WorkflowCommunicationBiz.updateMessageRemind4Reply(contentId, resiveUser, insertReplyId); + //修改内容后,重置相关交流的新消息提醒 + WorkflowCommunicationBiz.resetNewCommunicationReadLog(communicationId, user, remark); + + //抄送(不需提交)给@的人员 + CctoAtUser(nodeid,requestid,remark,user); + + //发送给门户抄送不需提交,待阅 + toMenhuDaiyue(communicationId,requestid,nodeid,remark); + } + + apidatas.put("result", insertReplyId > 0); + + return apidatas; + } + + /** + * 抄送(不需提交)给@的人员 + * @param nodeid + * @param requestid + * @param remark + */ + private void CctoAtUser(String nodeid, int requestid, String remark,User user) { + + String pattern = "(?i)atsome=\\\"\\@[0-9]*"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(remark); + Set userIds = new HashSet<>(); + while (m.find()) { + String replace = m.group().replace("atsome=\"@", ""); + if(!"".equals(replace)) + userIds.add(replace); + } + List list = new ArrayList<>(userIds); + if(list.size() > 0) + CCOperatorUtil.insert(requestid + "",list,nodeid,"8",user); + } + + private void toMenhuDaiyue(int communicationId, int reqid,String nodeid,String remark){ + List> todolist = new ArrayList(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + Map rsojson = new HashMap<>(); + try { + + String pattern = "(?i)atsome=\\\"\\@[0-9]*"; + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(remark); + Set userIds = new HashSet<>(); + while (m.find()) { + String replace = m.group().replace("atsome=\"@", ""); + if(!"".equals(replace)) { + userIds.add(replace); + } + } + rs1.executeQuery("select * from workflow_communicationbase where id=?", communicationId); + rs1.next(); + reqid = Util.getIntValue(rs1.getString("requestid")); + + rs1.executeQuery("select * from workflow_requestbase where requestid=?", reqid); + rs1.next(); + String requestname = Util.null2String(rs1.getString("requestname")); + nodeid = Util.null2String(rs1.getString("currentnodeid")); + + rs1.executeQuery("select * from workflow_nodebase where id=?", nodeid); + rs1.next(); + String nodename = Util.null2String(rs1.getString("nodename")); + + List list = new ArrayList<>(userIds); + if(list.size() > 0){ + for(String userid : list){ + rsojson.put("requestname", requestname); + rsojson.put("requestid", reqid); + rsojson.put("username", new ResourceComInfo().getLastname(userid) + "(" + userid + ")"); + rsojson.put("id", userid); + rsojson.put("nodeid", nodeid); + rsojson.put("nodename", nodename); + rsojson.put("isremark", "8");//抄送无需提交 + rsojson.put("loginid", new ResourceComInfo().getLoginID(userid)); + + rs.writeLog("=================== DoSaveReply toMenhuDaiyue ============== " + rsojson); + todolist.add(rsojson); + } + Map params = new HashMap<>(); + params.put("TodoDatas", todolist); + params.put("requestid", reqid); + + 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"); + + Class clazz = Class.forName("com.customization.dito.sendtodo.SendPortalAtAddTodoCmd"); + if(clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class}) != null) { + Method method = clazz.getMethod("sendTodoDataByNode",new Class[]{String.class,List.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class}); + + Object newInstance = clazz.newInstance(); + method.invoke(newInstance,reqid+"",todolist,username,passwd,center,portal_todourl,bpm_workflowurl,bpm_app_workflowurl,bpm_app_requesturl); + } + } + }catch (Exception e){ + rs.writeLog(e); + e.printStackTrace(); + } + } + +}