代理同步门户

feature-LeeD-20221025
liuliang 2 years ago
parent 5e60af5715
commit 4e3db3732a

@ -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<String,Object> params;
public SendPortalWithAddDoneCmd(Map<String,Object> params){
this.params=params;
}
public Map<String, Object> execute(CommandContext commandContext) {
List<Map<String,Object>> donelist = (List<Map<String,Object>>)(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<Map<String,Object>> 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<String,Object> 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());
}
}
}

@ -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<String,Object> params;
public SendPortalWithAddTodoCmd(Map<String,Object> params){
this.params=params;
}
public Map<String, Object> execute(CommandContext commandContext) {
List<Map<String,Object>> todolist = (List<Map<String,Object>>)(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<Map<String,Object>> 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<String,Object> 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<String,Object> 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();
}
}
}

@ -21,6 +21,9 @@ import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/**
*
*/
public class SendPortalWithDeleteCmd { public class SendPortalWithDeleteCmd {
private Map<String,Object> params; private Map<String,Object> 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){ 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(); HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl"); String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
@ -166,7 +168,7 @@ public class SendPortalWithDeleteCmd {
map.put("resultCode","0"); map.put("resultCode","0");
}else{ }else{
bb.writeLog(msgObject.get("resultMsg")); bb.writeLog(msgObject.get("resultMsg"));
sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo(); // sendPortalErrorUtil.doCreateSendPortalTodoErrorInfo();
map.put("resultCode",resultCode); map.put("resultCode",resultCode);
map.put("resultMsg",msgObject.get("resultMsg")); map.put("resultMsg",msgObject.get("resultMsg"));
} }

@ -1,6 +1,8 @@
package weaver.interfaces.dito.portal; 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.customization.dito.sendtodo.SendPortalWithDeleteCmd;
import com.engine.core.context.Context; import com.engine.core.context.Context;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -16,6 +18,7 @@ import net.sf.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class SendRequestData2PortalInterfaces implements SendRequestStatusDataInterfaces { public class SendRequestData2PortalInterfaces implements SendRequestStatusDataInterfaces {
@ -75,42 +78,62 @@ public class SendRequestData2PortalInterfaces implements SendRequestStatusDataIn
JSONObject deljson = new JSONObject(); JSONObject deljson = new JSONObject();
ArrayList<RequestStatusObj> tododatas = dobj.getTododatas(); ArrayList<RequestStatusObj> tododatas = dobj.getTododatas();
if(tododatas.size()>0){//处理推送的待办数据 if(tododatas.size()>0){//处理推送的待办数据
JSONArray todolist = new JSONArray(); List<Map<String,Object>> todolist = new ArrayList();
for(RequestStatusObj rso : tododatas){//遍历当前发送的待办数据 for(RequestStatusObj rso : tododatas){//遍历当前发送的待办数据
JSONObject rsojson = new JSONObject(); Map<String,Object> rsojson = new HashMap<>();
requestname = rso.getRequstname() ; requestname = rso.getRequstname() ;
bb.writeLog("tododatas-requestname:"+requestname); 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("username",rso.getUser().getLastname()+"("+rso.getUser().getUID()+")");
rsojson.put("isremark",rso.getIsremark()); rsojson.put("id",rso.getUser().getUID());
rsojson.put("viewtype",rso.getViewtype()); rsojson.put("loginid",rso.getUser().getLoginid());
rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); // rsojson.put("isremark",rso.getIsremark());
rsojson.put("nodename",rso.getNodename()); // rsojson.put("viewtype",rso.getViewtype());
// rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime());
// rsojson.put("nodename",rso.getNodename());
todolist.add(rsojson); todolist.add(rsojson);
} }
Map<String,Object> 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("TodoCount",tododatas.size());
todojson.put("TodoDatas",todolist); todojson.put("TodoDatas",todolist);
jsonArray.add(todojson); jsonArray.add(todojson);
} }
ArrayList<RequestStatusObj> donedatas = dobj.getDonedatas(); ArrayList<RequestStatusObj> donedatas = dobj.getDonedatas();
if(donedatas.size()>0){//处理推送的已办数据 if(donedatas.size()>0){//处理推送的已办数据
JSONArray todolist = new JSONArray(); List<Map<String,Object>> donelist = new ArrayList();
for(RequestStatusObj rso : donedatas){//遍历当前发送的已办数据 for(RequestStatusObj rso : donedatas){//遍历当前发送的已办数据
JSONObject rsojson = new JSONObject(); Map<String,Object> rsojson = new HashMap<>();
requestname = rso.getRequstname() ; requestname = rso.getRequstname() ;
bb.writeLog("donedatas-requestname:"+requestname); bb.writeLog("donedatas-requestname:"+requestname);
rsojson.put("cid",rso.getCid()); rsojson.put("requestname",requestname);
rsojson.put("username",rso.getUser().getLastname()+"("+rso.getUser().getUID()+")"); rsojson.put("requestid",rso.getRequestid());
rsojson.put("isremark",rso.getIsremark()); // rsojson.put("cid",rso.getCid());
rsojson.put("viewtype",rso.getViewtype()); rsojson.put("requestname",rso.getRequstname());
rsojson.put("receivedatetime",rso.getReceivedate()+" "+rso.getReceivetime()+"/"+rso.getOperatedate()+" "+rso.getOperatetime()); 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("nodename",rso.getNodename());
rsojson.put("iscomplete",rso.getIscomplete()); // rsojson.put("iscomplete",rso.getIscomplete());
todolist.add(rsojson); donelist.add(rsojson);
} }
Map<String,Object> 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("DoneCount",donedatas.size());
donejson.put("DoneDatas",todolist); donejson.put("DoneDatas",donelist);
jsonArray.add(donejson); jsonArray.add(donejson);
} }
ArrayList<RequestStatusObj> deldatas = dobj.getDeldatas(); ArrayList<RequestStatusObj> deldatas = dobj.getDeldatas();

Loading…
Cancel
Save