From 792c53d4a7f3a9ddb28d7e91d0a9224ff81b4eb0 Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Fri, 17 Nov 2023 17:57:05 +0800 Subject: [PATCH] =?UTF-8?q?#EC=5FHJ146#=20=E7=BB=9F=E4=B8=80=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=AE=8C=E6=88=90=E6=8E=A5=E5=8F=A3=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E6=8A=84=E9=80=81=E7=9A=84=E5=A4=84=E7=90=86=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sendtodo/SendPortalWithAddDoneCmd.java | 240 +++++++++--------- 1 file changed, 113 insertions(+), 127 deletions(-) diff --git a/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java index 9747b3ee..3152da53 100644 --- a/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java @@ -1,20 +1,16 @@ package com.customization.dito.sendtodo; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import weaver.interfaces.dito.constant.Constants; import com.engine.core.interceptor.CommandContext; import com.time.util.DateUtil; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; import weaver.interfaces.dito.comInfo.PropBean; - import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,7 +50,6 @@ public class SendPortalWithAddDoneCmd { sendPortalDoneData(requestid,donelist,portal_doneurl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,bpm_app_requesturl); - return null; } @@ -66,16 +61,15 @@ public class SendPortalWithAddDoneCmd { RecordSet rs = new RecordSet(); BaseBean bb = new BaseBean(); List userList = new ArrayList(); - try{ if(StringUtils.isNotBlank(requestid)) { String currentNodeId = "" ; String currentNodeType = "" ; String sql =" select t1.currentnodeid,t1.currentnodetype \n" + - " from workflow_requestbase t1\n" + - " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + - " and t1.requestid = "+requestid ; + " from workflow_requestbase t1\n" + + " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" + + " and t1.requestid = "+requestid ; bb.writeLog("getRequestArchivedReamrkUserIds--sql2:"+sql); rs.executeQuery(sql); @@ -127,31 +121,27 @@ public class SendPortalWithAddDoneCmd { * @param bpm_app_requesturl */ public void sendPortalDoneData(String requestid,List> donelist, String portal_doneurl, String bpm_app_workflowurl, String username, String passwd, String bpm_workflowurl, String bpm_app_requesturl) { + String zhjkbs = "com.customization.dito.sendtodo.SendPortalWithAddDoneCmd.sendPortalDoneData" ; BaseBean bb = new BaseBean(); bb.writeLog("sendPortalDoneData"); SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); - RecordSet rs = new RecordSet(); - - String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); +// RecordSet rs = new RecordSet(); +// String scopeid = "-1"; +// String scope = "HrmCustomFieldByInfoType" ; try { + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); String isRecall = "1"; String actionType = "0"; - - String center = PropBean.getUfPropValue("center"); - String urlPc = "[newtab]" + bpm_workflowurl + "/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestid; - -// String urlApp = "[newtab]" + bpm_app_workflowurl + "/interface/mobilelogin/loginsso.jsp?em_auth_usercode=" + workcode + "&forwardurl=" + app_requestUrl; 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)){ try { urlApp += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8"); @@ -160,104 +150,124 @@ public class SendPortalWithAddDoneCmd { unsupportedEncodingException.printStackTrace(); } } - for (Map doneMap:donelist){ - 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); + for (Map doneMap:donelist) + { +// boolean bool = checkIsAgent(workflowid,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); +// String sql = " select count(1) 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.doRecordPortalErrorInfo4Phase2(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 workflowid = Util.null2String(doneMap.get("workflowid")); + String userid = Util.null2String(doneMap.get("userid")); + bb.writeLog("=============== SendPortalWithAddDoneCmd workflowid =================== " + workflowid); + bb.writeLog("=============== SendPortalWithAddDoneCmd userid =================== " + userid); - 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")); + bb.writeLog("loginid1:"+loginid); + if("sysadmin".equals(loginid)){ + loginid = "Admin"; + } + bb.writeLog("loginid2:"+loginid); + String creater = Util.null2String(doneMap.get("creater")); + bb.writeLog("creater1:"+creater); + if("sysadmin".equals(creater)){ + creater = "Admin"; + } + bb.writeLog("creater2:"+creater); + String nodeName = Util.null2String(doneMap.get("nodename")); + String nodeid = Util.null2String(doneMap.get("noedid")); + bb.writeLog("nodeid:"+nodeid); + + if(StringUtils.isBlank(nodeid)){ + nodeid = requestid+userid; ; + } + bb.writeLog("nodeid2:"+nodeid); + 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("title", getShortMessageTitle(requestname)); requestObject.put("creator", creater); requestObject.put("processStaff", loginid); requestObject.put("processTime", processTime); @@ -267,27 +277,22 @@ public class SendPortalWithAddDoneCmd { 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); + sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,nodeid,nodeName,creater,requestObject.toJSONString(),resultCode,resultmsg,zhjkbs,userid); } } } - - } -// } +// } } - } catch (Exception e) { bb.writeLog("done Exception"); bb.writeLog(e.getMessage()); @@ -295,25 +300,6 @@ public class SendPortalWithAddDoneCmd { } - /*** - * - * @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; - } - /** * 判断流程是否有代理 * @param workflowid