@ -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.lang 3 .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,7 +61,6 @@ public class SendPortalWithAddDoneCmd {
RecordSet rs = new RecordSet ( ) ;
BaseBean bb = new BaseBean ( ) ;
List < String > userList = new ArrayList < String > ( ) ;
try {
if ( StringUtils . isNotBlank ( requestid ) )
{
@ -127,31 +121,27 @@ public class SendPortalWithAddDoneCmd {
* @param bpm_app_requesturl
* /
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 ) {
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 < String , Object > 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 < String , Object > 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 ) ;
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 ) ;
}
}
}
// 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");
}
if ( num = = 0 ) {
String workflowid = Util . null2String ( doneMap . get ( "workflowid" ) ) ;
String userid = Util . null2String ( doneMap . get ( "userid" ) ) ;
bb . writeLog ( "=============== SendPortalWithAddDoneCmd workflowid =================== " + workflowid ) ;
bb . writeLog ( "=============== SendPortalWithAddDoneCmd userid =================== " + userid ) ;
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 . doRecordPortalErrorInfo 4Phase2 ( 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 < String , String > getEmailTemplate ( String requestname , String operator , String operatorTime ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
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