|
|
package weaver.interfaces.dito.robot;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.customization.dito.sendtodo.RequestBaseInfoUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import weaver.interfaces.dito.constant.Constants;
|
|
|
import com.customization.dito.sendtodo.HttpRequestUtil;
|
|
|
import com.customization.dito.sendtodo.SendPortalErrorUtil;
|
|
|
import com.time.util.DateUtil;
|
|
|
import weaver.conn.RecordSet;
|
|
|
import weaver.general.BaseBean;
|
|
|
import weaver.interfaces.dito.comInfo.PropBean;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
*/
|
|
|
public class SendPortalRobotSubmitUtil {
|
|
|
|
|
|
|
|
|
private RequestBaseInfoUtil requestBaseInfoUtil = new RequestBaseInfoUtil();
|
|
|
public void sendRobotsubmit(String requestid,String nodeid){
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil");
|
|
|
sendRobotSubmitByTodo(requestid,nodeid);
|
|
|
sendRobotSubmitByToRead(requestid,nodeid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param requestid
|
|
|
* @param nodeid
|
|
|
*/
|
|
|
public void sendRobotSubmitByTodo(String requestid,String nodeid){
|
|
|
|
|
|
String portal_todourl = Constants.portal_todourl;
|
|
|
String bpm_app_workflowurl = Constants.bpm_app_workflowurl;
|
|
|
String username = Constants.username;
|
|
|
String passwd = Constants.passwd;
|
|
|
String bpm_workflowurl = Constants.bpm_workflowurl;
|
|
|
String center = Constants.center;
|
|
|
String bpm_app_requesturl = Constants.bpm_app_requesturl;
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("sendRobotSubmitByTodo");
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
String zhjkbs = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil.sendRobotSubmitByTodo" ;
|
|
|
|
|
|
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil--sendRobotSubmitByTodo");
|
|
|
String terminal = "1" ;
|
|
|
String taskType = "0";
|
|
|
String actionType = "2" ;
|
|
|
String objectAction = "0";
|
|
|
String objectType = "0";
|
|
|
|
|
|
try {
|
|
|
|
|
|
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("sendRobotSubmitByTodo-urlDing", urlDing);
|
|
|
|
|
|
// int count = 0 ;
|
|
|
// String countSql=" select t2.userid \n" +
|
|
|
// " from workflow_requestbase t1\n" +
|
|
|
// " inner join workflow_currentoperator t2 on t1.requestid = t2.requestid\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 ('5','7','11')) \n" +
|
|
|
// " and t2.islasttimes = 1\n" +
|
|
|
// " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
// " and t2.requestid = "+requestid ;
|
|
|
|
|
|
int count = requestBaseInfoUtil.getTodoCountByRequestid(requestid+"");
|
|
|
// bb.writeLog("sendRobotSubmitByTodo--countSql:"+countSql);
|
|
|
// rs.executeQuery(countSql);
|
|
|
// while (rs.next()){
|
|
|
// count++;
|
|
|
// }
|
|
|
bb.writeLog("sendRobotSubmitByTodo--count:"+count);
|
|
|
if(count >0){
|
|
|
|
|
|
Map<String,String> baseMap = requestBaseInfoUtil.queryRequestBaseByRequestid(requestid);
|
|
|
|
|
|
String currentNodeId = baseMap.get("currentnodeid");
|
|
|
String currentNodeName = baseMap.get("currentnodeid");
|
|
|
String workflowname = baseMap.get("workflowname");
|
|
|
String createrLoginId = baseMap.get("createrloginid");
|
|
|
String createrLastName = baseMap.get("createrusername");
|
|
|
String requestname = baseMap.get("requestname");
|
|
|
|
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
requestObject.put("creator",createrLoginId);
|
|
|
requestObject.put("title",requestname);
|
|
|
requestObject.put("messageContent",requestname);
|
|
|
requestObject.put("nodeId",currentNodeId);
|
|
|
requestObject.put("nodeName",currentNodeName);
|
|
|
requestObject.put("ticketType",workflowname);
|
|
|
|
|
|
requestObject.put("center",center);
|
|
|
requestObject.put("taskCode","weaver"+requestid);
|
|
|
requestObject.put("taskType",taskType);
|
|
|
requestObject.put("actionType",actionType);
|
|
|
requestObject.put("createDate",processTime);
|
|
|
requestObject.put("messageTitle",getShortMessageTitle(requestname));
|
|
|
requestObject.put("terminal",terminal);
|
|
|
requestObject.put("urlPc",urlPc);
|
|
|
requestObject.put("urlApp",urlApp);
|
|
|
requestObject.put("urlDing",urlDing);
|
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
|
|
|
// String sql =" select t2.userid,h1.loginid,h1.lastname,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 ('5','7','11')) \n" +
|
|
|
// " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
// " and t2.requestid = "+requestid ;
|
|
|
|
|
|
String sql = requestBaseInfoUtil.getTodoSql(requestid);
|
|
|
rs.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
//归档节点抄送
|
|
|
String loginid = rs.getString("loginid");
|
|
|
String staffid = 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("sendRobotSubmitByTodo---requestObject:"+requestObject.toJSONString());
|
|
|
String 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)) {
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,currentNodeId,currentNodeName,"",requestObject.toJSONString(),resultCode,"",zhjkbs,"");
|
|
|
}else{
|
|
|
String resultmsg = msgObject.getString("resultMsg");
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,currentNodeId,currentNodeName,"",requestObject.toJSONString(),resultCode,resultmsg,zhjkbs,"");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param requestid
|
|
|
* @param nodeid
|
|
|
*/
|
|
|
public void sendRobotSubmitByToRead(String requestid,String nodeid){
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("sendRobotSubmitByToRead");
|
|
|
RecordSet rs = new RecordSet();
|
|
|
String portal_todourl = Constants.portal_todourl;
|
|
|
String bpm_app_workflowurl = Constants.bpm_app_workflowurl;
|
|
|
String username = Constants.username;
|
|
|
String passwd = Constants.passwd;
|
|
|
String bpm_workflowurl = Constants.bpm_workflowurl;
|
|
|
String center = Constants.center;
|
|
|
String bpm_app_requesturl = Constants.bpm_app_requesturl;
|
|
|
|
|
|
String zhjkbs = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil.sendRobotSubmitByToRead" ;
|
|
|
|
|
|
SendPortalErrorUtil sendPortalErrorUtil = new SendPortalErrorUtil();
|
|
|
HttpRequestUtil httpRequestUtil = new HttpRequestUtil();
|
|
|
String mobileJumpUrl = PropBean.getUfPropValue("mobileJumpUrl");
|
|
|
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil--sendRobotSubmitByToRead");
|
|
|
String terminal = "1" ;
|
|
|
String actionType = "0" ;
|
|
|
String taskType = "1";
|
|
|
String objectAction = "0" ;
|
|
|
String objectType = "0";
|
|
|
try {
|
|
|
|
|
|
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("sendRobotSubmitByToRead-urlDing"+ urlDing);
|
|
|
|
|
|
Map<String,String> baseMap = requestBaseInfoUtil.queryRequestBaseByRequestid(requestid);
|
|
|
|
|
|
String currentNodeId = baseMap.get("currentnodeid");
|
|
|
String currentNodeName = baseMap.get("currentnodeid");
|
|
|
String workflowname = baseMap.get("workflowname");
|
|
|
String createrLoginId = baseMap.get("createrloginid");
|
|
|
String createrLastName = baseMap.get("createrusername");
|
|
|
String requestname = baseMap.get("requestname");
|
|
|
|
|
|
|
|
|
JSONArray taskObjectList = new JSONArray();
|
|
|
// sql = " select t2.userid,h1.loginid,h1.email,t2.isremark,t1.requestid,t2.nodeid,d1.nodename,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" +
|
|
|
// " left join workflow_nodebase d1 on d1.id = t2.nodeid "+
|
|
|
// " where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '')\n" +
|
|
|
// " and t2.isremark in ('8','9')\n" +
|
|
|
// " and t2.islasttimes = 1\n" +
|
|
|
// " and (t2.isprocessing = '' or t2.isprocessing is null)\n" +
|
|
|
// " and t2.requestid = "+requestid +
|
|
|
// " ";
|
|
|
String sql = requestBaseInfoUtil.getRemark89Sql(requestid);
|
|
|
bb.writeLog("sendRobotSubmitByToRead--sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
//归档节点抄送
|
|
|
String loginid = rs.getString("loginid");
|
|
|
String staffid = rs.getString("staffid");
|
|
|
String userid = rs.getString("userid");
|
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
taskObject.put("creator", loginid);
|
|
|
taskObject.put("staffid", staffid);
|
|
|
taskObject.put("userid", userid);
|
|
|
taskObjectList.add(taskObject);
|
|
|
}
|
|
|
|
|
|
for(int i=0;i<taskObjectList.size();i++)
|
|
|
{
|
|
|
JSONObject dataObject = taskObjectList.getJSONObject(i);
|
|
|
String staffid = dataObject.getString("staffid");
|
|
|
String userid = dataObject.getString("userid");
|
|
|
String creator = dataObject.getString("creator");
|
|
|
|
|
|
JSONObject taskObject = new JSONObject();
|
|
|
taskObject.put("objectAction", objectAction);
|
|
|
taskObject.put("objectType", objectType);
|
|
|
taskObject.put("objectCode", creator);
|
|
|
taskObject.put("objectId", staffid);
|
|
|
taskObject.put("operatorCode", creator);
|
|
|
JSONArray taskArray = new JSONArray();
|
|
|
taskArray.add(taskObject);
|
|
|
|
|
|
JSONObject requestObject = new JSONObject();
|
|
|
requestObject.put("creator",createrLoginId);
|
|
|
requestObject.put("title",requestname);
|
|
|
requestObject.put("messageContent",requestname);
|
|
|
requestObject.put("nodeId",currentNodeId);
|
|
|
requestObject.put("nodeName",currentNodeName);
|
|
|
requestObject.put("ticketType",workflowname);
|
|
|
|
|
|
requestObject.put("center",center);
|
|
|
requestObject.put("taskCode", requestid+"_cs_"+userid);
|
|
|
requestObject.put("taskType",taskType);
|
|
|
requestObject.put("actionType",actionType);
|
|
|
requestObject.put("createDate",processTime);
|
|
|
requestObject.put("messageTitle",getShortMessageTitle(requestname));
|
|
|
requestObject.put("terminal",terminal);
|
|
|
requestObject.put("urlPc",urlPc);
|
|
|
requestObject.put("urlApp",urlApp);
|
|
|
requestObject.put("urlDing",urlDing);
|
|
|
|
|
|
requestObject.put("taskObjectList",taskArray);
|
|
|
String auth = username + ":" + passwd;
|
|
|
bb.writeLog("sendRobotSubmitByToRead---requestObject:"+requestObject.toJSONString());
|
|
|
String 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)) {
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,currentNodeId,currentNodeName,"",requestObject.toJSONString(),resultCode,"",zhjkbs,userid);
|
|
|
}else{
|
|
|
String resultmsg = msgObject.getString("resultMsg");
|
|
|
sendPortalErrorUtil.doRecordPortalErrorInfo4Phase2(requestid,currentNodeId,currentNodeName,"",requestObject.toJSONString(),resultCode,resultmsg,zhjkbs,userid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param messageTitle
|
|
|
* @return
|
|
|
*/
|
|
|
private String getShortMessageTitle(String messageTitle) {
|
|
|
if (messageTitle.length() > 20) {
|
|
|
messageTitle = messageTitle.substring(0, 17) + "...";
|
|
|
}
|
|
|
return messageTitle;
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
* 流程机器人自动处理,异常处理
|
|
|
* 0:退回上一节点 1:退回到指定节点
|
|
|
* @param requestid
|
|
|
* @param nodeid
|
|
|
*/
|
|
|
public void sendRobotReturnBy0_1(String requestid,String nodeid){
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil");
|
|
|
sendRobotSubmitByTodo(requestid,nodeid);
|
|
|
sendRobotSubmitByToRead(requestid,nodeid);
|
|
|
}
|
|
|
|
|
|
|
|
|
/***
|
|
|
* 流程机器人自动处理,异常处理
|
|
|
* 2:提交到指定节点
|
|
|
* @param requestid
|
|
|
* @param nodeid
|
|
|
*/
|
|
|
public void sendRobotReturnBy2(String requestid,String nodeid){
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil");
|
|
|
sendRobotSubmitByTodo(requestid,nodeid);
|
|
|
sendRobotSubmitByToRead(requestid,nodeid);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
* 流程机器人自动处理,异常处理
|
|
|
* 3:指定干预对象
|
|
|
* @param requestid
|
|
|
* @param nodeid
|
|
|
*/
|
|
|
public void sendRobotReturnBy3(String requestid,String nodeid){
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("SendPortalRobotSubmitUtil");
|
|
|
sendRobotSubmitByTodo(requestid,nodeid);
|
|
|
sendRobotSubmitByToRead(requestid,nodeid);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|