diff --git a/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java new file mode 100644 index 00000000..47bb404b --- /dev/null +++ b/src/com/customization/dito/sendtodo/SendPortalWithAddDoneCmd.java @@ -0,0 +1,131 @@ +package com.customization.dito.sendtodo; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.core.interceptor.CommandContext; +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.interfaces.dito.comInfo.PropBean; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SendPortalWithAddDoneCmd { + private Map params; + + public SendPortalWithAddDoneCmd(Map params){ + this.params=params; + } + + public Map execute(CommandContext commandContext) { + + List> donelist = (List>)(params.get("doneDatas")); + String requestid = Util.null2String(params.get("requestid")); + String bpm_app_workflowurl = PropBean.getUfPropValue("bpm_app_workflowurl"); + String bpm_app_requesturl = PropBean.getUfPropValue("bpm_app_requesturl"); + String portal_doneurl = PropBean.getUfPropValue("portal_doneurl"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + + sendPortalDoneData(requestid,donelist,portal_doneurl,bpm_app_workflowurl,username,passwd,bpm_workflowurl,bpm_app_requesturl); + + + return null; + } + + private String getShortMessageTitle(String messageTitle) { + if (messageTitle.length() > 20) { + messageTitle = messageTitle.substring(0, 17) + "..."; + } + return messageTitle; + } + + 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) { + BaseBean bb = new BaseBean(); + bb.writeLog("sendPortalDoneData"); + SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); + HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); + + + String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + + try { + + 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"); + urlDing += "&returnUrl="+URLEncoder.encode(mobileJumpUrl,"UTF-8"); + } catch (UnsupportedEncodingException unsupportedEncodingException) { + unsupportedEncodingException.printStackTrace(); + } + } + for (Map doneMap:donelist){ + String nodeid = Util.null2String(doneMap.get("noedid")); + String workflowname = Util.null2String(doneMap.get("workflowname")); + String requestname = Util.null2String(doneMap.get("requestname")); + String loginid = Util.null2String(doneMap.get("loginid")); + String nodeName = Util.null2String(doneMap.get("nodename")); + + JSONObject requestObject = new JSONObject(); + requestObject.put("center", center); + requestObject.put("taskCode", requestid); + requestObject.put("nodeId", nodeid); + requestObject.put("ticketType", workflowname); + requestObject.put("title", requestname); + requestObject.put("creator", loginid); + 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); + } + } + } + } + + } catch (Exception e) { + bb.writeLog("done Exception"); + bb.writeLog(e.getMessage()); + } + } + +} diff --git a/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java new file mode 100644 index 00000000..58dcce57 --- /dev/null +++ b/src/com/customization/dito/sendtodo/SendPortalWithAddTodoCmd.java @@ -0,0 +1,193 @@ +package com.customization.dito.sendtodo; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.core.interceptor.CommandContext; +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.interfaces.dito.comInfo.PropBean; + +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 流程增加代办后给门户发送增加代办消息,进行同步 + */ +public class SendPortalWithAddTodoCmd { + private Map params; + + public SendPortalWithAddTodoCmd(Map params){ + this.params=params; + } + + public Map execute(CommandContext commandContext) { + + List> todolist = (List>)(params.get("TodoDatas")); + String requestid = Util.null2String(params.get("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"); + String username = PropBean.getUfPropValue("username"); + String passwd = PropBean.getUfPropValue("passwd"); + String center = PropBean.getUfPropValue("center"); + String bpm_workflowurl = PropBean.getUfPropValue("bpm_workflowurl"); + + sendTodoDataByNode(requestid,todolist,username,passwd,center,portal_todourl,bpm_workflowurl,bpm_app_workflowurl,bpm_app_requesturl); + + + return null; + } + + private String getShortMessageTitle(String messageTitle) { + if (messageTitle.length() > 20) { + messageTitle = messageTitle.substring(0, 17) + "..."; + } + return messageTitle; + } + + /** + * + * @param username + * @param passwd + * @param portal_todourl + * @param bpm_workflowurl + * @param bpm_app_workflowurl + * @param bpm_app_requesturl + */ + 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 mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); + + JSONObject requestObject = new JSONObject(); + RecordSet rs = new RecordSet(); + + BaseBean bb = new BaseBean(); + bb.writeLog("SendPortalQithRawRunnable--sendTodoDataByNode"); + + String terminal = "1" ; + String taskType = "0"; + String actionType = "0" ; + String objectAction = "0" ; + String objectType = "0"; + + try { + String sql = ""; + + String processTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss"); + + 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"); + } + bb.writeLog("urlDing", urlDing); + + + String requestname = "" ; + String workflowname = "" ; + String nodeId = "" ; + String nodeName = "" ; + String lastName = ""; + sql =" select t1.requestname,t1.currentnodeid as nodeid,d1.nodename,t3.workflowname,h2.lastname"+ + " 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("sendTodoDataByNode--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")) ; + nodeName = Util.null2String(rs.getString("nodeName")) ; + lastName = Util.null2String(rs.getString("lastname")) ; + } + + requestObject.put("center",center); + requestObject.put("title",requestname); + requestObject.put("creator",lastName); + requestObject.put("taskCode",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); + + + JSONArray taskObjectList = new JSONArray(); + String cus_staff = PropBean.getUfPropValue("cus_staff") ; + String scopeid = "-1"; + String scope = "HrmCustomFieldByInfoType" ; + + for (Map todoMap: todolist){ + String userSql = "select "+cus_staff+" as staffid from cus_fielddata where scopeid=-1 and scope='HrmCustomFieldByInfoType' and id=?"; + rs.executeQuery(userSql,todoMap.get("id")); + String loginid = Util.null2String(todoMap.get("loginid")); + if("sysadmin".equals(loginid)){ + loginid = "Admin"; + } + if (rs.next()){ + String staffid = Util.null2String(rs.getString("staffid")); + + JSONObject taskObject = new JSONObject(); + + taskObject.put("objectAction",objectAction); + taskObject.put("objectType",objectType); + taskObject.put("objectCode",loginid); + taskObject.put("objectId",staffid); + taskObject.put("operatorCode",loginid); + taskObjectList.add(taskObject); + } + } + + requestObject.put("taskObjectList",taskObjectList); + + String auth = username + ":" + passwd; + bb.writeLog("sendTodoDataByNode---requestObject:"+requestObject.toJSONString()); + String msgdata = httpRequestUtil.doPostByAuth(portal_todourl,requestObject.toJSONString(),auth); + bb.writeLog("msgdata:"+msgdata); + Map map = new HashMap<>(); + if(!"".equals(msgdata)){ + JSONObject msgObject = JSONObject.parseObject(msgdata); + //{"resultCode":"1","resultMsg":"No Result"} + if(msgObject.containsKey("resultCode")){ + String resultCode = msgObject.getString("resultCode"); + if("0".equals(resultCode)){ + map.put("resultCode","0"); + }else{ + bb.writeLog(msgObject.get("resultMsg")); + // sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo(); + map.put("resultCode",resultCode); + map.put("resultMsg",msgObject.get("resultMsg")); + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/com/customization/dito/sendtodo/SendPortalWithDeleteCmd.java b/src/com/customization/dito/sendtodo/SendPortalWithDeleteCmd.java index 5d8738ca..285f3ad3 100644 --- a/src/com/customization/dito/sendtodo/SendPortalWithDeleteCmd.java +++ b/src/com/customization/dito/sendtodo/SendPortalWithDeleteCmd.java @@ -21,6 +21,9 @@ import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; +/** + * 流程删除后给门户发送删除消息,进行同步 + */ public class SendPortalWithDeleteCmd { private Map params; @@ -62,7 +65,6 @@ public class SendPortalWithDeleteCmd { */ public void sendTodoDataByNode(String requestid,String username,String passwd,String center,String portal_todourl,String bpm_workflowurl,String bpm_app_workflowurl,String bpm_app_requesturl){ HttpRequestUtil httpRequestUtil = new HttpRequestUtil(); - SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil(); String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); @@ -166,7 +168,7 @@ public class SendPortalWithDeleteCmd { map.put("resultCode","0"); }else{ bb.writeLog(msgObject.get("resultMsg")); - sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo(); + // sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo(); map.put("resultCode",resultCode); map.put("resultMsg",msgObject.get("resultMsg")); } diff --git a/src/weaver/interfaces/dito/portal/SendRequestData2PortalInterfaces.java b/src/weaver/interfaces/dito/portal/SendRequestData2PortalInterfaces.java index 9d38f69d..17dfcfb8 100644 --- a/src/weaver/interfaces/dito/portal/SendRequestData2PortalInterfaces.java +++ b/src/weaver/interfaces/dito/portal/SendRequestData2PortalInterfaces.java @@ -1,6 +1,8 @@ package weaver.interfaces.dito.portal; +import com.customization.dito.sendtodo.SendPortalWithAddDoneCmd; +import com.customization.dito.sendtodo.SendPortalWithAddTodoCmd; import com.customization.dito.sendtodo.SendPortalWithDeleteCmd; import com.engine.core.context.Context; import org.apache.commons.lang.StringUtils; @@ -16,6 +18,7 @@ import net.sf.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class SendRequestData2PortalInterfaces implements SendRequestStatusDataInterfaces { @@ -75,42 +78,62 @@ public class SendRequestData2PortalInterfaces implements SendRequestStatusDataIn JSONObject deljson = new JSONObject(); ArrayList tododatas = dobj.getTododatas(); if(tododatas.size()>0){//处理推送的待办数据 - JSONArray todolist = new JSONArray(); + List> todolist = new ArrayList(); for(RequestStatusObj rso : tododatas){//遍历当前发送的待办数据 - JSONObject rsojson = new JSONObject(); + Map rsojson = new HashMap<>(); requestname = rso.getRequstname() ; bb.writeLog("tododatas-requestname:"+requestname); - rsojson.put("cid",rso.getCid()); + //rsojson.put("cid",rso.getCid()); + rsojson.put("requestname",requestname); + rsojson.put("requestid",rso.getRequestid()); rsojson.put("username",rso.getUser().getLastname()+"("+rso.getUser().getUID()+")"); - rsojson.put("isremark",rso.getIsremark()); - rsojson.put("viewtype",rso.getViewtype()); - rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); - rsojson.put("nodename",rso.getNodename()); + rsojson.put("id",rso.getUser().getUID()); + rsojson.put("loginid",rso.getUser().getLoginid()); + // rsojson.put("isremark",rso.getIsremark()); + // rsojson.put("viewtype",rso.getViewtype()); + // rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); + // rsojson.put("nodename",rso.getNodename()); todolist.add(rsojson); } + Map params = new HashMap<>(); + params.put("TodoDatas",todolist); + params.put("requestid",dobj.getRequestid()); + new SendPortalWithAddTodoCmd(params).execute(Context.getCommandComtext()); + todojson.put("TodoCount",tododatas.size()); todojson.put("TodoDatas",todolist); jsonArray.add(todojson); } ArrayList donedatas = dobj.getDonedatas(); if(donedatas.size()>0){//处理推送的已办数据 - JSONArray todolist = new JSONArray(); + List> donelist = new ArrayList(); for(RequestStatusObj rso : donedatas){//遍历当前发送的已办数据 - JSONObject rsojson = new JSONObject(); + Map rsojson = new HashMap<>(); requestname = rso.getRequstname() ; bb.writeLog("donedatas-requestname:"+requestname); - rsojson.put("cid",rso.getCid()); - rsojson.put("username",rso.getUser().getLastname()+"("+rso.getUser().getUID()+")"); - rsojson.put("isremark",rso.getIsremark()); - rsojson.put("viewtype",rso.getViewtype()); - rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); + rsojson.put("requestname",requestname); + rsojson.put("requestid",rso.getRequestid()); +// rsojson.put("cid",rso.getCid()); + rsojson.put("requestname",rso.getRequstname()); + rsojson.put("workflowname",rso.getWorkflowname()); + rsojson.put("username",rso.getUser().getLastname()); + rsojson.put("id",rso.getUser().getUID()); + rsojson.put("loginid",rso.getUser().getLoginid()); + rsojson.put("noedid",rso.getNodeid()); +// rsojson.put("viewtype",rso.getViewtype()); +// rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); rsojson.put("nodename",rso.getNodename()); - rsojson.put("iscomplete",rso.getIscomplete()); - todolist.add(rsojson); +// rsojson.put("iscomplete",rso.getIscomplete()); + donelist.add(rsojson); } + Map params = new HashMap<>(); + params.put("doneDatas",donelist); + params.put("requestid",dobj.getRequestid()); + new SendPortalWithAddDoneCmd(params).execute(Context.getCommandComtext()); + donejson.put("DoneCount",donedatas.size()); - donejson.put("DoneDatas",todolist); + donejson.put("DoneDatas",donelist); jsonArray.add(donejson); } ArrayList deldatas = dobj.getDeldatas();