|
|
@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
package com.engine.workflow.biz.RobotNode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.api.system.language.service.LanguageService;
|
|
|
|
|
|
|
|
import com.engine.workflow.biz.newRule.RuleCompareBiz;
|
|
|
|
|
|
|
|
import com.engine.workflow.biz.requestFlow.RequestFlowBiz;
|
|
|
|
|
|
|
|
import com.engine.workflow.biz.requestForm.RequestRemindBiz;
|
|
|
|
|
|
|
|
import com.engine.workflow.entity.RobotNodeEntity;
|
|
|
|
|
|
|
|
import com.engine.workflow.entity.newRule.RuleCompareDetail;
|
|
|
|
|
|
|
|
import com.engine.workflow.entity.newRule.RuleCompareResult;
|
|
|
|
|
|
|
|
import com.weaver.general.TimeUtil;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
|
|
|
|
import weaver.workflow.logging.Logger;
|
|
|
|
|
|
|
|
import weaver.workflow.logging.LoggerFactory;
|
|
|
|
|
|
|
|
import weaver.workflow.request.RequestManager;
|
|
|
|
|
|
|
|
import weaver.workflow.request.SubWorkflowTriggerService;
|
|
|
|
|
|
|
|
import weaver.workflow.request.WFAutoApproveUtils;
|
|
|
|
|
|
|
|
import weaver.workflow.request.WorkflowRequestMessage;
|
|
|
|
|
|
|
|
import com.engine.workflow.biz.ConformCheckBiz;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class RobotNodeFlowBiz {
|
|
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(RobotNodeFlowBiz.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 机器人节点流转逻辑
|
|
|
|
|
|
|
|
* @param robotNodeEntity
|
|
|
|
|
|
|
|
* @param requestid
|
|
|
|
|
|
|
|
* @param workflowid
|
|
|
|
|
|
|
|
* @param nodeid
|
|
|
|
|
|
|
|
* @param belongTest
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Map<String, Object> robotNodeFlow(RobotNodeEntity robotNodeEntity, int requestid, int workflowid, int nodeid, boolean belongTest){
|
|
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
|
|
|
|
apidatas.put("flowResult", false);
|
|
|
|
|
|
|
|
robotNodeEntity.setRequestid(requestid);
|
|
|
|
|
|
|
|
robotNodeEntity.setWorkflowid(workflowid);
|
|
|
|
|
|
|
|
robotNodeEntity.setNodeid(nodeid);
|
|
|
|
|
|
|
|
boolean isAllSubWorkflowEnded = SubWorkflowTriggerService.isAllSubWorkflowEnded(requestid, workflowid, "" + nodeid);
|
|
|
|
|
|
|
|
if(!isAllSubWorkflowEnded){
|
|
|
|
|
|
|
|
//子流程没有全部归档,延迟时间
|
|
|
|
|
|
|
|
long waitMs = Util.getIntValue(robotNodeEntity.getWaitTimeValue(), 0) * 60 * 1000L;
|
|
|
|
|
|
|
|
if(waitMs == 0){
|
|
|
|
|
|
|
|
//去扫描频率
|
|
|
|
|
|
|
|
waitMs = getSentryScanRate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(waitMs == 0){
|
|
|
|
|
|
|
|
//默认30分钟
|
|
|
|
|
|
|
|
waitMs = 30 * 60 * 1000L;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!belongTest) {
|
|
|
|
|
|
|
|
robotNodeEntity.setRobotNodeHandleMs(new Date().getTime() + waitMs);
|
|
|
|
|
|
|
|
RobotNodeHandleTask handleTimerTask = new RobotNodeHandleTask(robotNodeEntity.getRobotNodeHandleMs());
|
|
|
|
|
|
|
|
handleTimerTask.setRobotNodeEntity(robotNodeEntity);
|
|
|
|
|
|
|
|
RobotNodeBiz.getInstance().addRobotNodeTask(handleTimerTask, requestid, nodeid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
log.info("添加机器人节点处理任务,子流程没有全部归档,不允许提交:requestid" + requestid + " nodeid:" + nodeid + " 延迟:"+waitMs+"毫秒 下一次处理时间点:" + sdf.format(new Date(robotNodeEntity.getRobotNodeHandleMs())));
|
|
|
|
|
|
|
|
apidatas.put("flowResult", false);
|
|
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestFlowBiz requestFlowBiz = new RequestFlowBiz();
|
|
|
|
|
|
|
|
requestFlowBiz.setNeedConformCheck(false);//不需要再次执行合规
|
|
|
|
|
|
|
|
User robotUser = null;
|
|
|
|
|
|
|
|
if ("success".equals(isCanSubmit(robotNodeEntity).get("result"))) {
|
|
|
|
|
|
|
|
String operateType = robotNodeEntity.getOperateType();
|
|
|
|
|
|
|
|
String remark = robotNodeEntity.getRemark();
|
|
|
|
|
|
|
|
String errorRemark = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//合规校验,校验失败是直接退回,如果没有退回出口则
|
|
|
|
|
|
|
|
robotUser = User.getUser(Util.getIntValue(RobotNodeBiz.operatorid, 0), Util.getIntValue(RobotNodeBiz.operatortype, 0));
|
|
|
|
|
|
|
|
RuleCompareResult ruleCompareResult = new ConformCheckBiz().compareRules4NodeCheck(requestid,workflowid, nodeid+"", robotUser);
|
|
|
|
|
|
|
|
boolean ruleFlag = true;
|
|
|
|
|
|
|
|
if(ruleCompareResult.getProcessType()==0 && !ruleCompareResult.isResult()){ //校验未通过
|
|
|
|
|
|
|
|
//需考虑这种情况:设置了多个规则,禁止提交的规则验证成功,其他类型的验证失败。
|
|
|
|
|
|
|
|
ruleFlag = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isOpenNodeCheckRemark = ruleCompareResult.isOpenNodeCheckRemark();
|
|
|
|
|
|
|
|
log.info("器人节点合规校验:requestid:" + requestid + " workflowid:" + workflowid + " nodeid:" + nodeid +" userid"+ robotUser.getUID() + " userlogintype"+robotUser.getLogintype()+" ruleFlag" + ruleFlag);
|
|
|
|
|
|
|
|
if(isOpenNodeCheckRemark && !ruleFlag){//开启了获取获取合规校验的意见,并且合规校验失败
|
|
|
|
|
|
|
|
errorRemark = ruleCompareResult.getCompareRemark();
|
|
|
|
|
|
|
|
log.info("机器人节点合规校验异常:requestid:" + requestid + " nodeid:" + nodeid + " 合规校验失败签字意见" + errorRemark);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean flowFlag = false;
|
|
|
|
|
|
|
|
if(ruleFlag) {//合规校验通过才进行流转
|
|
|
|
|
|
|
|
String src = "submit";
|
|
|
|
|
|
|
|
if ("2".equals(operateType)) {
|
|
|
|
|
|
|
|
src = "reject";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
flowFlag = requestFlowBiz.flowToNextNode(requestid, workflowid, nodeid, src, Util.formatMultiLang(remark), Util.getIntValue(RobotNodeBiz.operatorid, 0), Util.getIntValue(RobotNodeBiz.operatortype, 0), "1");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ruleFlag && !flowFlag) {//合规通过,并且流转失败,者获取流转失败的相关信息
|
|
|
|
|
|
|
|
errorRemark = getErrorRemark(requestFlowBiz.getMessageContent(), requestFlowBiz.getMessage(), requestFlowBiz.getUser().getLanguage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
apidatas.put("flowResult", flowFlag);
|
|
|
|
|
|
|
|
if (!flowFlag) {
|
|
|
|
|
|
|
|
//流转失败
|
|
|
|
|
|
|
|
// 启动异常处理
|
|
|
|
|
|
|
|
String logtype = "0";
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
String exceptionHandleType = robotNodeEntity.getExceptionHandleType();
|
|
|
|
|
|
|
|
String flowObjectids = robotNodeEntity.getFlowObjectids();
|
|
|
|
|
|
|
|
String interventionType = robotNodeEntity.getInterventionType();
|
|
|
|
|
|
|
|
String exceptionRemarkSettings = Util.formatMultiLang(Util.null2String(robotNodeEntity.getExceptionRemark()));
|
|
|
|
|
|
|
|
String exceptionRemark = errorRemark;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!"".equals(exceptionRemarkSettings)){//设置了异常处理签字意见
|
|
|
|
|
|
|
|
if(!ruleFlag){//如果是合规校验失败了,那么意见就是设置的异常意见+合规意见,否则取用户设置的异常处理意见
|
|
|
|
|
|
|
|
exceptionRemark = exceptionRemarkSettings + "<br/>" + errorRemark;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
exceptionRemark = exceptionRemarkSettings;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exceptionHandleType = "".equalsIgnoreCase(exceptionHandleType) ? "0" : exceptionHandleType;
|
|
|
|
|
|
|
|
boolean exceptionFlowFlag = true;
|
|
|
|
|
|
|
|
String exceptionFlowErrorRemark = "";
|
|
|
|
|
|
|
|
if ("0".equals(exceptionHandleType) || "1".equals(exceptionHandleType)) {//退回上一节点 || 退回到指定节点
|
|
|
|
|
|
|
|
logtype = "3";
|
|
|
|
|
|
|
|
int rejectToNodeid = Util.getIntValue(flowObjectids, -1);
|
|
|
|
|
|
|
|
if ("0".equals(exceptionHandleType)) {//退回上一节点
|
|
|
|
|
|
|
|
String sql = "select nodeid from workflow_requestoperatelog where requestid =? and operatecode in ('1','2','3','9','12') order by id desc";
|
|
|
|
|
|
|
|
rs.executeQuery(sql, requestid);
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
rejectToNodeid = rs.getInt("nodeid");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rejectToNodeid == -1) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理退回节点获取异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType);
|
|
|
|
|
|
|
|
exceptionFlowErrorRemark = "机器人节点异常处理退回节点获取异常";
|
|
|
|
|
|
|
|
exceptionFlowFlag = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(exceptionFlowFlag) {
|
|
|
|
|
|
|
|
exceptionFlowFlag = requestFlowBiz.rejectToNode(requestid, workflowid, nodeid, Util.formatMultiLang(exceptionRemark), rejectToNodeid, Util.getIntValue(RobotNodeBiz.operatorid, 0), Util.getIntValue(RobotNodeBiz.operatortype, 0), false);
|
|
|
|
|
|
|
|
if (!exceptionFlowFlag) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理退回至指定节点流转异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType + " rejectToNodeid:" + rejectToNodeid);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 流转成功
|
|
|
|
|
|
|
|
RequestRemindBiz remindBiz = new RequestRemindBiz(robotUser);
|
|
|
|
|
|
|
|
remindBiz.requestSubmitRemind4WebService(requestid,workflowid,-1,-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-requestid:"+requestid);
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-nodeid:"+nodeid);
|
|
|
|
|
|
|
|
String className = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil" ;
|
|
|
|
|
|
|
|
String methodName = "sendRobotReturnBy0_1" ;
|
|
|
|
|
|
|
|
Class<?> clazz = Class.forName(className);
|
|
|
|
|
|
|
|
Method method = clazz.getMethod(methodName,String.class,String.class);
|
|
|
|
|
|
|
|
Object newInstance = clazz.newInstance();
|
|
|
|
|
|
|
|
method.invoke(newInstance,requestid+"",nodeid+"");
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-result:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (ClassNotFoundException | NoSuchMethodException e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-ClassNotFoundException:"+e);
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-IllegalAccessException:"+e);
|
|
|
|
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InstantiationException:"+e);
|
|
|
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InvocationTargetException:"+e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ("2".equals(exceptionHandleType)) {//提交到指定节点
|
|
|
|
|
|
|
|
logtype = "2";
|
|
|
|
|
|
|
|
int submitToNodeid = Util.getIntValue(flowObjectids, -1);
|
|
|
|
|
|
|
|
if (submitToNodeid == -1) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理提交节点获取异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType);
|
|
|
|
|
|
|
|
exceptionFlowErrorRemark = "机器人节点异常处理提交节点获取异常";
|
|
|
|
|
|
|
|
exceptionFlowFlag = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(exceptionFlowFlag) {
|
|
|
|
|
|
|
|
exceptionFlowFlag = requestFlowBiz.submitToNode(requestid, workflowid, nodeid, Util.formatMultiLang(exceptionRemark), submitToNodeid, Util.getIntValue(RobotNodeBiz.operatorid, 0), Util.getIntValue(RobotNodeBiz.operatortype, 0), false);
|
|
|
|
|
|
|
|
if (!exceptionFlowFlag) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理提交到指定节点流转异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType + " rejectToNodeid:" + submitToNodeid);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
// 流转成功
|
|
|
|
|
|
|
|
RequestRemindBiz remindBiz = new RequestRemindBiz(robotUser);
|
|
|
|
|
|
|
|
remindBiz.requestSubmitRemind4WebService(requestid,workflowid,-1,-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-requestid:"+requestid);
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-nodeid:"+nodeid);
|
|
|
|
|
|
|
|
String className = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil" ;
|
|
|
|
|
|
|
|
String methodName = "sendRobotReturnBy2" ;
|
|
|
|
|
|
|
|
Class<?> clazz = Class.forName(className);
|
|
|
|
|
|
|
|
Method method = clazz.getMethod(methodName,String.class,String.class);
|
|
|
|
|
|
|
|
Object newInstance = clazz.newInstance();
|
|
|
|
|
|
|
|
method.invoke(newInstance,requestid+"",nodeid+"");
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-result:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (ClassNotFoundException | NoSuchMethodException e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-ClassNotFoundException:"+e);
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-IllegalAccessException:"+e);
|
|
|
|
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InstantiationException:"+e);
|
|
|
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InvocationTargetException:"+e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ("3".equals(exceptionHandleType)) {//指定干预对象
|
|
|
|
|
|
|
|
logtype = "7";
|
|
|
|
|
|
|
|
String interventionid = "";
|
|
|
|
|
|
|
|
if ("0".equals(interventionType)) {//指定干预对象给所选人员
|
|
|
|
|
|
|
|
interventionid = flowObjectids;
|
|
|
|
|
|
|
|
} else if ("1".equals(interventionType)) {//人力资源字段
|
|
|
|
|
|
|
|
interventionid = RequestFlowBiz.getMainFieldValue(requestid, workflowid, Util.null2String(flowObjectids));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("".equals(interventionid)) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理指定干预对象异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType);
|
|
|
|
|
|
|
|
exceptionFlowErrorRemark = "机器人节点异常处理指定干预对象异常";
|
|
|
|
|
|
|
|
exceptionFlowFlag = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//指定人干预
|
|
|
|
|
|
|
|
if(exceptionFlowFlag) {
|
|
|
|
|
|
|
|
exceptionFlowFlag = requestFlowBiz.designatedInterveners(requestid, workflowid, nodeid, exceptionRemark, interventionid, Util.getIntValue(RobotNodeBiz.operatorid, 0), Util.getIntValue(RobotNodeBiz.operatortype, 0));
|
|
|
|
|
|
|
|
if (!exceptionFlowFlag) {
|
|
|
|
|
|
|
|
log.info("机器人节点异常处理指定干预对象异常:requestid:" + requestid + " nodeid:" + nodeid + " exceptionHandleType:" + exceptionHandleType + " rejectToNodeid:" + interventionid);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 流转成功
|
|
|
|
|
|
|
|
RequestRemindBiz remindBiz = new RequestRemindBiz(robotUser);
|
|
|
|
|
|
|
|
remindBiz.remindInterventor(requestid,workflowid,nodeid,interventionid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-requestid:"+requestid);
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-return-nodeid:"+nodeid);
|
|
|
|
|
|
|
|
String className = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil" ;
|
|
|
|
|
|
|
|
String methodName = "sendRobotReturnBy3" ;
|
|
|
|
|
|
|
|
Class<?> clazz = Class.forName(className);
|
|
|
|
|
|
|
|
Method method = clazz.getMethod(methodName,String.class,String.class);
|
|
|
|
|
|
|
|
Object newInstance = clazz.newInstance();
|
|
|
|
|
|
|
|
method.invoke(newInstance,requestid+"",nodeid+"");
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-result:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (ClassNotFoundException | NoSuchMethodException e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-ClassNotFoundException:"+e);
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-IllegalAccessException:"+e);
|
|
|
|
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InstantiationException:"+e);
|
|
|
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InvocationTargetException:"+e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!exceptionFlowFlag || "3".equals(exceptionHandleType)){
|
|
|
|
|
|
|
|
rs.executeUpdate("update workflow_currentoperator set operatedate =?,operatetime = ? where requestid = ? and nodeid = ? and userid =? and usertype =? and isremark =0",
|
|
|
|
|
|
|
|
requestFlowBiz.getCurrentDate(), requestFlowBiz.getCurrentTime(), requestid, nodeid, RobotNodeBiz.operatorid, RobotNodeBiz.operatortype);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!exceptionFlowFlag){//流程流转失败并且异常处理也失败了,插入失败签字意见
|
|
|
|
|
|
|
|
char flag = Util.getSeparator();
|
|
|
|
|
|
|
|
if("".equals(exceptionFlowErrorRemark)) {
|
|
|
|
|
|
|
|
exceptionFlowErrorRemark = getErrorRemark(requestFlowBiz.getMessageContent(), requestFlowBiz.getMessage(), requestFlowBiz.getUser().getLanguage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
exceptionFlowErrorRemark = errorRemark +"<br/><br/>"+ SystemEnv.getHtmlLabelName(532229, requestFlowBiz.getUser().getLanguage())+":<br/>" +exceptionFlowErrorRemark;
|
|
|
|
|
|
|
|
String Procpara = "" + requestid + flag + workflowid + flag + nodeid + flag + logtype + flag + requestFlowBiz.getCurrentDate() + flag + requestFlowBiz.getCurrentTime() + flag + RobotNodeBiz.operatorid + flag + "127.0.0.1" + flag + RobotNodeBiz.operatortype + flag + nodeid + flag + new RobotNodeServiceBiz().getRobotNodeSet(nodeid).getOperatorName() + flag + -1 + flag + "0" + flag + -1 + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag +""+ flag + "" + flag + RobotNodeBiz.operatortype +flag+ "" + flag+""+flag+""+flag + "";
|
|
|
|
|
|
|
|
RequestManager rm = new RequestManager();
|
|
|
|
|
|
|
|
rm.setIsRobotNode("2");
|
|
|
|
|
|
|
|
rm.execRequestlog(Procpara, new RecordSet(), flag, exceptionFlowErrorRemark);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
apidatas.put("flowResult", exceptionFlowFlag);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 流转成功
|
|
|
|
|
|
|
|
Map<Integer, WFAutoApproveUtils.AutoApproveParams> nodeInfoCache = requestFlowBiz.getRequestManager().getNodeInfoCache();
|
|
|
|
|
|
|
|
if (nodeInfoCache !=null && nodeInfoCache.size() <=0) {
|
|
|
|
|
|
|
|
RequestRemindBiz remindBiz = new RequestRemindBiz(robotUser);
|
|
|
|
|
|
|
|
remindBiz.requestSubmitRemind4WebService(requestid,workflowid,-1,-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-requestid:"+requestid);
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-nodeid:"+nodeid);
|
|
|
|
|
|
|
|
String className = "weaver.interfaces.dito.robot.SendPortalRobotSubmitUtil" ;
|
|
|
|
|
|
|
|
String methodName = "sendRobotsubmit" ;
|
|
|
|
|
|
|
|
Class<?> clazz = Class.forName(className);
|
|
|
|
|
|
|
|
Method method = clazz.getMethod(methodName,String.class,String.class);
|
|
|
|
|
|
|
|
Object newInstance = clazz.newInstance();
|
|
|
|
|
|
|
|
method.invoke(newInstance,requestid+"",nodeid+"");
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-result:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (ClassNotFoundException | NoSuchMethodException e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-ClassNotFoundException:"+e);
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-IllegalAccessException:"+e);
|
|
|
|
|
|
|
|
} catch (InstantiationException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InstantiationException:"+e);
|
|
|
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
bb.writeLog("RobotNodeFlowBiz-InvocationTargetException:"+e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
apidatas.put("requestmanager", requestFlowBiz.getRequestManager());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断是否能提交
|
|
|
|
|
|
|
|
* @param robotNodeEntity
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Map<String, String> isCanSubmit(RobotNodeEntity robotNodeEntity){
|
|
|
|
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
|
|
|
|
|
int requestid = robotNodeEntity.getRequestid();
|
|
|
|
|
|
|
|
int nodeid = robotNodeEntity.getNodeid();
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "select 1 from workflow_currentoperator where requestid = ? and nodeid = ? and userid = ? and usertype = ? and isremark = 0";
|
|
|
|
|
|
|
|
rs.executeQuery(sql, requestid, nodeid, RobotNodeBiz.operatorid, RobotNodeBiz.operatortype);
|
|
|
|
|
|
|
|
if(!rs.next()){
|
|
|
|
|
|
|
|
result.put("result","false");
|
|
|
|
|
|
|
|
result.put("errorInfo","机器人节点流程已被处理requestid:"+requestid +" nodeid:"+nodeid);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.put("result","success");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
result.put("result","false");
|
|
|
|
|
|
|
|
result.put("errorInfo","机器人节点流程判断提交权限出错requestid:"+requestid +" nodeid:"+nodeid);
|
|
|
|
|
|
|
|
log.info(e);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 防止死循环,增加限制一个流程,同一个节点连续超时不得超过n分钟
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static void addTime(RobotNodeEntity robotNodeEntity, int minute){
|
|
|
|
|
|
|
|
int requestid = robotNodeEntity.getRequestid();
|
|
|
|
|
|
|
|
int nodeid = robotNodeEntity.getNodeid();
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
String sql = "select operatedate,operatetime from workflow_currentoperator where userid = '"+RobotNodeBiz.operatorid+"' and isremark in ('2','4') and preisremark = '0' and requestid = "+requestid+" and nodeid = "+nodeid+" order by id desc";
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
|
|
|
if(rs.next()){
|
|
|
|
|
|
|
|
long lastoperatetime = TimeUtil.getCalendar(rs.getString("operatedate") +" "+ rs.getString("operatetime")).getTime().getTime();
|
|
|
|
|
|
|
|
long minOperatetime = lastoperatetime + (1000*60*minute);
|
|
|
|
|
|
|
|
long robotnodetime = robotNodeEntity.getRobotNodeHandleMs();
|
|
|
|
|
|
|
|
if(robotnodetime < minOperatetime){
|
|
|
|
|
|
|
|
robotNodeEntity.setRobotNodeHandleMs(minOperatetime);
|
|
|
|
|
|
|
|
log.info("机器人节点执行时间校验requestid:" + requestid + "上一次超时处理:" + TimeUtil.getDateString(new Date(lastoperatetime)) + " 与此次处理时间:" + TimeUtil.getDateString(new Date(robotnodetime))+ "不足" + (minute) + "分钟,故延长超时处理时间到:" + TimeUtil.getDateString(new Date(minOperatetime)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取错误的签字意见
|
|
|
|
|
|
|
|
* @param messageContent
|
|
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
|
|
* @param language
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String getErrorRemark(String messageContent, String message, int language){
|
|
|
|
|
|
|
|
String title = "";
|
|
|
|
|
|
|
|
String details = "";
|
|
|
|
|
|
|
|
String errorRemark = "";
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
JSONObject jsoncontent = new JSONObject(messageContent);
|
|
|
|
|
|
|
|
if (jsoncontent.has("details")) {
|
|
|
|
|
|
|
|
details = Util.null2String(jsoncontent.getString("details"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(jsoncontent.has("bottomprefix")){
|
|
|
|
|
|
|
|
String bottomprefix = Util.null2String(jsoncontent.getString("bottomprefix"));
|
|
|
|
|
|
|
|
if(needBottomprefix(bottomprefix,language)) {
|
|
|
|
|
|
|
|
details += "".equals(details) ? "" : "<br/>";
|
|
|
|
|
|
|
|
details += Util.null2String(jsoncontent.getString("bottomprefix"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
title = WorkflowRequestMessage.getNewMessageId(message, LanguageService.getDefaultLang());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
details = messageContent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
errorRemark = title.equals("") ? details : title + "<br/>" + details;
|
|
|
|
|
|
|
|
return errorRemark;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean needBottomprefix(String bottomprefix, int languageid){
|
|
|
|
|
|
|
|
Set interceptWard = new HashSet();
|
|
|
|
|
|
|
|
interceptWard.add(SystemEnv.getHtmlLabelName(126540,languageid));
|
|
|
|
|
|
|
|
if(interceptWard.contains(bottomprefix)){
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private long getSentryScanRate() {
|
|
|
|
|
|
|
|
long scanRate = 30 * 60 * 1000;//默认30分钟
|
|
|
|
|
|
|
|
String sql = "select sentryScanRate from workflow_settings where id =1";
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
String sentryScanRate = rs.getString("sentryScanRate");
|
|
|
|
|
|
|
|
if (!"".equals(sentryScanRate)) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
scanRate = Long.parseLong((Util.getIntValue(sentryScanRate, 30) * 60 * 1000) + "");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.info("超时哨兵线程获取扫描时间异常!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return scanRate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|