package weaver.workflow.request;

/*
 * Created on 2006-05-18
 * Copyright (c) 2001-2006 泛微软件
 * 泛微协同商务系统，版权所有。
 *
 */

import com.alibaba.fastjson.JSON;
import com.engine.common.service.HrmCommonService;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import com.engine.hrm.biz.HrmClassifiedProtectionBiz;
import com.engine.workflow.biz.SelectNextFlowBiz;
import com.engine.workflow.biz.freeNode.FreeNodeBiz;
import com.engine.workflow.biz.RobotNode.RobotNodeBiz;
import com.engine.workflow.biz.freeNode.RequestFreeNodeFlowBiz;
import com.engine.workflow.biz.nodeOperator.NodeOperatorConfigBiz;
import com.engine.workflow.biz.requestForm.RequestSecLevelBiz;
import com.engine.workflow.biz.workflowCore.WorkflowBaseBiz;
import com.engine.workflow.constant.ReqFlowFailMsgType;
import com.engine.workflow.constant.SelectNextFlowMode;
import com.engine.workflow.constant.node.NodeType;
import com.engine.workflow.entity.RequestFlowLogEntity;
import com.engine.workflow.entity.core.NodeInfoEntity;
import com.engine.workflow.entity.core.RequestFlowInfoEntity;
import com.engine.workflow.entity.freeNode.FreeNodeEntity;
import com.engine.workflow.entity.node.OperatorEntity;
import com.engine.workflow.entity.node.OperatorInfoEntity;
import com.engine.workflow.entity.freeNode.FreeNodeGroupEntity;
import com.engine.workflow.entity.requestForm.ReqFlowFailMsgEntity;
import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
import weaver.common.StringUtil;
import weaver.conn.ConnStatement;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.crm.Maint.CustomerInfoComInfo;
import weaver.crm.Maint.CustomerStatusComInfo;
import weaver.crm.Maint.CustomerTypeComInfo;
import weaver.docs.senddoc.DocReceiveUnitComInfo;
import weaver.general.*;
import weaver.hrm.User;
import weaver.hrm.check.JobComInfo;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.AllSubordinate;
import weaver.hrm.resource.ResourceComInfo;
import weaver.hrm.roles.RolesComInfo;
import weaver.interfaces.workflow.browser.Browser;
import weaver.interfaces.workflow.browser.BrowserBean;
import weaver.matrix.MatrixUtil;
import weaver.meeting.Maint.MeetingComInfo;
import weaver.proj.Maint.ProjectInfoComInfo;
import weaver.system.code.CodeBuild;
import weaver.systeminfo.SystemEnv;
import weaver.workflow.form.FormFieldlabelMainManager;
import weaver.workflow.logging.submit.Logger;
import weaver.workflow.logging.submit.LoggerFactory;
import weaver.workflow.ruleDesign.RuleBusiness;
import weaver.workflow.ruleDesign.RuleInterface;
import weaver.workflow.workflow.*;

import java.util.*;

/**
 * Description: 取得流程的下一节点及操作者<br>
 *
 * @author ben
 * @version 1.0
 */

public class RequestNodeFlow extends BaseBean {
    private boolean orderflag = false;
    private ArrayList passNodes = new ArrayList();
    private int nodeid = -1;
    private int nextnodeid = -1;
    private int tempnextnodeid = -1;
    private int linkid = -1;
    private String linkname = "";
    private int nextlinkid = -1;
    private String nextlinkname = "";
    private String nodetype = "";
    private String nextnodetype = "";
    private int requestid = -1;
    private int userid = -1;
    private int usertype = -1;
    private int languageid = 7;
    private int creater = -1;
    private int creatertype = -1;
    private int workflowid = -1;
    private int formid = -1;
    private int isbill = -1;
    private int billid = -1;
    private String billtablename = "";
    private String isintervenor = "";
    private int isreject = -1;
    private int isreopen = -1;
    private boolean hasedititem = false;
    private Hashtable operatorsht = new Hashtable(); // xwj for td2162 20050623
    private RecordSet rs;
    private String sql = "";
    private String Procpara = "";
    private char flag = Util.getSeparator();
    /**
     * 操作组ID
     */
    int tempGroupId = 0; //xwj for td2104 on 20050802
    private int hasright;
    private ArrayList nextnodeids = new ArrayList();
    private ArrayList nextlinkids = new ArrayList();
    private ArrayList nextlinknames = new ArrayList();
    private ArrayList nextnodetypes = new ArrayList();
    private ArrayList nextnodeattrs = new ArrayList();
    private ArrayList operatorshts = new ArrayList();
    private ArrayList occurnodeids = new ArrayList();
    private ArrayList nextnodepassnums = new ArrayList();
    private ArrayList linkismustpasss = new ArrayList();
    private WorkflowOperator wfoper = new WorkflowOperator();
    private String ismustpasss = "";
    private String nodeattribute = "0";
    private String nextnodeattribute = "0";
    private int passnum = 0;
    private boolean isGetFlowCodeStr = true;//是否获取流程编号，true:获取  false:不获取   默认为true:获取
    private String IsFreeNode = "0";
    private int FreeSigntype = 0;
    private String Freeoperators = "";
    private int isFromRequestManager = 0;
    private int RejectToNodeid = 0;//td30785
    private int RejectToType = 0;
    private int SubmitToNodeid = 0;
    private String newRejectNodeids;
    private int forceOverNodeId = 0; //强制归档指定的归档节点id
    private boolean isForceOver = false; //是否是强制归档

    private String penetrateId = ""; //是否包含穿透的操作//add by liaodong for qc76119,76120,54194,64652 start
    private String lastNodeId = ""; //最后一个出口 add by liaodong for qc76119,76120,54194,64652 start
    private boolean isfixbill = false; //是否为固定单据 //add by liaodong for qc48451 in 2013年10月21日 start

    private RecordSetTrans rst;
    // add by liaodong for qc86096 in 2013-11-19 start
    private String currentdate = "";       // 当前日期
    private String currenttime = "";       // 当前时间
    //end
    // add by liuzy for QC146873,流转异常对象
    FlowExceptionHandle flowExceptionHandle = new FlowExceptionHandle();
    private boolean eh_callAgainNextNodes = false;
    private boolean eh_unAppendNextNodes = false;
    private Map<String, Object> eh_operatorMap = new HashMap();
    private boolean isNeedChooseOperator = false;
    private Map<String, String> eh_original_nodeinfo = new HashMap<String, String>();
    private ArrayList requestexceptiontypes = new ArrayList();
    private int requestexceptiontype = 0;

    private String messageid = "";      //流程消息ID
    private String messagecontent = ""; //流程消息内容
    private String cachefieldvalue = "";
    private User user;
    private StringBuffer errorInfoMsgBuffer = new StringBuffer();
    private int index = 0;

    private ArrayList tempmutinodeids = new ArrayList();

    private boolean tonextnode = false;   //是否是往下一个节点流转，用于依次逐个处理取用户时使用，为true时，不从workflow_agentpersons取操作者，而按照第一次流转到某一节点时取操作者

    private boolean hasEflowToAssignNode = false; //是否是异常处理跳转指定节点

    private int lastFreeNodeId = 0;
    private ReqFlowFailMsgEntity reqFailMsg;

    private int isFromSubmitConfirm = 0;//判断是否是流程提交确认调用

    /**
     * 操作者中是否包含协办人
     */
    private boolean hasCoadjutant = false;
    private RequestFreeNodeFlowBiz freeNodeFlowBiz;
    private static String closeAgentPenetrate = "";//流程代理情况下，是否关闭流程穿透
    private static String closeAgentPenetrateWorkflowId = "";//流程代理情况下，关闭流程穿透的路径id

    private int assemMsgContentCount = 0;

    //指定流转
    private boolean isSelectNextFlow;
    //指定流转模式
    private SelectNextFlowMode selectNextFlowMode;//指定流转模式
    //指定流转设置节点
    private List<Integer> selectNextFlowNodeList = new ArrayList<>();

    //流程图智能预测
    private boolean autoForecast;
    //流程预测时，manager字段的信息
    private Map<String, String> forecastManagerInfo;
	
	private String clientIp = "";

	//流程流转日志对象
	private RequestFlowLogEntity requestFlowLogEntity = new RequestFlowLogEntity();

    public RequestFlowLogEntity getRequestFlowLogEntity() {
        return requestFlowLogEntity;
    }

    public void setRequestFlowLogEntity(RequestFlowLogEntity requestFlowLogEntity) {
        this.requestFlowLogEntity = requestFlowLogEntity;
    }

    private boolean fromSubWfTrigger=false;//来自子流程
    /**
     * 是否来自子流程，为了记录日志
     * @return
     */
    public boolean isFromSubWfTrigger() {
        return fromSubWfTrigger;
    }

    public void setFromSubWfTrigger(boolean fromSubWfTrigger) {
        this.fromSubWfTrigger = fromSubWfTrigger;
    }

    private final static Logger log = LoggerFactory.getLogger(RequestNodeFlow.class);

    /**
     * 重置参数
     */
    public void resetParameter() {
        this.tempGroupId = 0; //xwj for td2104 on 20050802
        this.nodeid = -1;
        this.nextnodeid = -1;
        this.linkid = -1;
        this.linkname = "";
        this.nextlinkid = -1;
        this.nextlinkname = "";
        this.nodetype = "";
        this.nextnodetype = "";
        this.requestid = -1;
        this.userid = -1;
        this.usertype = -1;
        this.creater = -1;
        this.creatertype = -1;
        this.workflowid = -1;
        this.formid = -1;
        this.isbill = -1;
        this.billid = -1;
        this.billtablename = "";
        this.isintervenor = "";
        this.isreject = -1;
        this.isreopen = -1;
        this.hasedititem = false;
        this.operatorsht = new Hashtable();
        this.sql = "";
        this.rs = null;
        this.rst = null;
        this.nextlinkids = new ArrayList();
        this.nextlinknames = new ArrayList();
        this.nextnodeids = new ArrayList();
        this.nextnodetypes = new ArrayList();
        this.nextnodeattrs = new ArrayList();
        this.operatorshts = new ArrayList();
        this.occurnodeids = new ArrayList();
        this.nextnodepassnums = new ArrayList();
        this.linkismustpasss = new ArrayList();
        this.ismustpasss = "";
        this.nodeattribute = "0";
        this.nextnodeattribute = "0";
        this.passnum = 0;
        this.isGetFlowCodeStr = true;
        this.IsFreeNode = "0";
        this.FreeSigntype = 0;
        this.Freeoperators = "";
        this.isFromRequestManager = 0;
        this.RejectToNodeid = 0;
        this.RejectToType = 0;
        this.tempmutinodeids = new ArrayList();

        this.SubmitToNodeid = 0;
        errorInfoMsgBuffer.setLength(0);
        index = 0;

        this.tonextnode = false;
        assemMsgContentCount = 0;
    }

    public ReqFlowFailMsgEntity getReqFailMsg() {
        return reqFailMsg;
    }

    public void setReqFailMsg(ReqFlowFailMsgEntity reqFailMsg) {
        this.reqFailMsg = reqFailMsg;
    }

    /**
     * @return the tonextnode
     */
    public boolean isTonextnode() {
        return tonextnode;
    }

    /**
     * @param tonextnode the tonextnode to set
     */
    public void setTonextnode(boolean tonextnode) {
        this.tonextnode = tonextnode;
    }

    public void setIsFromRequestManager(int isFromRequestManager) {
        this.isFromRequestManager = isFromRequestManager;
    }

    public void setRejectToNodeid(int RejectToNodeid) {
        this.RejectToNodeid = RejectToNodeid;
    }

    public int getRejectToNodeid() {
        return this.RejectToNodeid;
    }

    public int getRejectToType() {
        return RejectToType;
    }

    public void setRejectToType(int rejectToType) {
        this.RejectToType = rejectToType;
    }

    public ArrayList getTempmutinodeids() {
        return tempmutinodeids;
    }

    public void setTempmutinodeids(ArrayList tempmutinodeids) {
        this.tempmutinodeids = tempmutinodeids;
    }

    public void setSubmitToNodeid(int SubmitToNodeid) {
        this.SubmitToNodeid = SubmitToNodeid;
    }

    public int getSubmitToNodeid() {
        return this.SubmitToNodeid;
    }

    public int getIsFromRequestManager() {
        return this.isFromRequestManager;
    }


    /**
     * 设置请求ID
     *
     * @param requestid 请求ID
     */
    public void setRequestid(int requestid) {
        this.requestid = requestid;
    }

    /**
     * 设置节点ID
     *
     * @param nodeid 节点ID
     */
    public void setNodeid(int nodeid) {
        this.nodeid = nodeid;
    }

    /**
     * 设置节点类型
     *
     * @param nodetype 节点类型（0/1/2/3）
     */
    public void setNodetype(String nodetype) {
        this.nodetype = nodetype;
    }

    /**
     * 设置流程ID
     *
     * @param workflowid 流程ID
     */
    public void setWorkflowid(int workflowid) {
        this.workflowid = workflowid;
    }

    /**
     * 设置当前用户
     *
     * @param userid 当前用户
     */
    public void setUserid(int userid) {
        if (user == null) {
            user = new User(userid);
        }
        this.userid = userid;
    }

    /**
     * 设置当前用户类型
     *
     * @param usertype 当前用户类型
     */
    public void setUsertype(int usertype) {
        this.usertype = usertype;
    }

    public void setLanguageid(int languageid) {
        this.languageid = languageid;
    }

    /**
     * 设置流程创建者
     *
     * @param creater 流程创建者
     */
    public void setCreaterid(int creater) {
        this.creater = creater;
    }

    /**
     * 设置流程创建者类型
     *
     * @param creatertype 流程创建者类型（0:内部/1:外部）
     */
    public void setCreatertype(int creatertype) {
        this.creatertype = creatertype;
    }

    /**
     * 设置表单或单据id
     *
     * @param formid 表单或单据id
     */
    public void setFormid(int formid) {
        this.formid = formid;
    }

    /**
     * 设置是否为单据（0/1）
     *
     * @param isbill 是否为单据（0:否/1：是）
     */
    public void setIsbill(int isbill) {
        this.isbill = isbill;
    }

    /**
     * 如果是单据，设置单据ID
     *
     * @param billid 单据ID
     */
    public void setBillid(int billid) {
        this.billid = billid;
    }

    /**
     * 如果是单据，设置单据应用的表
     *
     * @param billtablename 单据表
     */
    public void setBilltablename(String billtablename) {
        this.billtablename = billtablename;
    }

    /**
     * 是否干预
     *
     * @param isintervenor 是否干预
     */
    public void setIsintervenor(String isintervenor) {
        this.isintervenor = isintervenor;
    }

    /**
     * 设置是否是被退回节点
     *
     * @param isreject 是否被退回（0/1）
     */
    public void setIsreject(int isreject) {
        this.isreject = isreject;
    }

    /**
     * 设置是否是被重新打开节点
     *
     * @param isreopen 是否重新打开（0/1）
     */
    public void setIsreopen(int isreopen) {
        this.isreopen = isreopen;
    }

    /**
     * 设置数据连接
     *
     * @param rs 数据连接 @see  RecordSet
     */
    public void setRecordSet(RecordSet rs) {
        this.rs = rs;
    }

    public void setRecordSetTrans(RecordSetTrans rst) {
        this.rst = rst;
    }

    /**
     * 设置下一个节点
     *
     * @param nextnodeid 下一个节点
     */
    public void setNextnodeid(int nextnodeid) {
        this.nextnodeid = nextnodeid;
    }

    /**
     * 得到下一个节点
     *
     * @return 下一个节点
     */
    public int getNextNodeid() {
        return this.nextnodeid;
    }

    /**
     * 得到下一个出口
     *
     * @return 下一个出口
     */
    public int getNextLinkid() {
        return this.nextlinkid;
    }

    /**
     * 得到下一个出口名称
     *
     * @return 下一个出口名称
     */
    public String getNextLinkname() {
        return this.nextlinkname;
    }

    /**
     * 得到下一个节点类型
     *
     * @return 下一个节点类型
     */
    public String getNextNodetype() {
        return this.nextnodetype;
    }

    /**
     * 得到流程下一节点的操作者
     *
     * @return 下一节点的操作者
     */
    public Hashtable getOperators() {
        return this.operatorsht;
    }

    public void setOperatorsht(Hashtable operatorsht) {
        this.operatorsht = operatorsht;
    }

    public ArrayList getNextnodeids() {
        return nextnodeids;
    }

    public ArrayList getNextlinkids() {
        return nextlinkids;
    }

    public ArrayList getNextlinknames() {
        return nextlinknames;
    }

    public ArrayList getNextnodetypes() {
        return nextnodetypes;
    }

    public ArrayList getNextnodeattrs() {
        return nextnodeattrs;
    }

    public ArrayList getOperatorshts() {
        return operatorshts;
    }

    public ArrayList getOccurnodeids() {
        return occurnodeids;
    }

    public ArrayList getNextnodepassnums() {
        return nextnodepassnums;
    }

    public ArrayList getLinkismustpasss() {
        return linkismustpasss;
    }

    public String getNodeattribute() {
        return nodeattribute;
    }

    public void setNodeattribute(String nodeattribute) {
        this.nodeattribute = nodeattribute;
    }

    public String getNextnodeattribute() {
        return nextnodeattribute;
    }

    public void setNextnodeattribute(String nextnodeattribute) {
        this.nextnodeattribute = nextnodeattribute;
    }

    public int getPassnum() {
        return passnum;
    }

    public void setPassnum(int passnum) {
        this.passnum = passnum;
    }

    public boolean getIsGetFlowCodeStr() {
        return isGetFlowCodeStr;
    }

    public void setIsGetFlowCodeStr(boolean isGetFlowCodeStr) {
        this.isGetFlowCodeStr = isGetFlowCodeStr;
    }

    public SelectNextFlowMode getSelectNextFlowMode() {
        return selectNextFlowMode;
    }

    public void setSelectNextFlowMode(SelectNextFlowMode selectNextFlowMode) {
        this.selectNextFlowMode = selectNextFlowMode;
    }

    public List<Integer> getSelectNextFlowNodeList() {
        return selectNextFlowNodeList;
    }

    public void setSelectNextFlowNodeList(List<Integer> selectNextFlowNodeList) {
        this.selectNextFlowNodeList = selectNextFlowNodeList;
    }

    /**
     * 获得是否为自由流程节点
     *
     * @return
     */
    public String getIsFreeNode() {
        return IsFreeNode;
    }

    /**
     * 设置是否为自由流程节点
     *
     * @param isFreeNode
     */
    public void setIsFreeNode(String isFreeNode) {
        IsFreeNode = isFreeNode;
    }

    /**
     * 获得自由流程会签类型
     *
     * @return
     */
    public int getFreeSigntype() {
        return FreeSigntype;
    }

    /**
     * 设置自由流程会签类型
     *
     * @param freeSigntype
     */
    public void setFreeSigntype(int freeSigntype) {
        FreeSigntype = freeSigntype;
    }

    /**
     * 获得自由流程操作者
     *
     * @return
     */
    public String getFreeoperators() {
        return Freeoperators;
    }

    public boolean isHasEflowToAssignNode() {
        return hasEflowToAssignNode;
    }

    public void setHasEflowToAssignNode(boolean hasEflowToAssignNode) {
        this.hasEflowToAssignNode = hasEflowToAssignNode;
    }

    /**
     * 设置自由流程操作者
     *
     * @param freeoperators
     */
    public void setFreeoperators(String freeoperators) {
        Freeoperators = freeoperators;
    }

    public void setTempGroupId(int tempGroupId) {
        this.tempGroupId = tempGroupId;
    }

    public int getTempGroupId() {
        return tempGroupId;
    }

    public void setFreeNodeFlowBiz(RequestFreeNodeFlowBiz freeNodeFlowBiz) {
        this.freeNodeFlowBiz = freeNodeFlowBiz;
    }

    public String getNewRejectNodeids() {
        return newRejectNodeids;
    }

    public void setNewRejectNodeids(String newRejectNodeids) {
        this.newRejectNodeids = newRejectNodeids;
    }

    public Map<String, String> getForecastManagerInfo() {
        return forecastManagerInfo;
    }

    public void setForecastManagerInfo(Map<String, String> forecastManagerInfo) {
        this.forecastManagerInfo = forecastManagerInfo;
    }
	
	public String getClientIp() {
        return clientIp;
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public void getNextNodes() {
        initTempGroupId();
        //处理自由流程节点操作者
        if (!isSelectNextFlow && !isAutoForecast() && addFreeNodeOperator()) {
            return;
        }
        rs.executeSql("select nodeattribute from workflow_nodebase where id=" + nodeid);
        if (rs.next()) {
            nodeattribute = Util.null2String(rs.getString("nodeattribute"));
        }
        int nextnodecount = 1;
        ArrayList mustpassnodeids = new ArrayList();
        if (nodeattribute.equals("1")) {
            rs.executeSql("select destnodeid from workflow_NodeLink where wfrequestid is null and (isreject is null or isreject<>'1') and nodeid=" + nodeid + " and workflowid=" + workflowid);
            nextnodecount = rs.getCounts();
            mustpassnodeids = new WFLinkInfo().getMustPassStartBrancheNode(workflowid, requestid, nodeid);
        }

        //指定流转，用户选择节点模式
        if(isSelectNextFlow && this.selectNextFlowNodeList.size() > 0 && this.SubmitToNodeid <= 0) {
            nextnodecount = this.selectNextFlowNodeList.size();
        }

        this.tempmutinodeids.clear();
        log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"this.RejectToType = " + this.RejectToType + " this.RejectToNodeid=" + this.RejectToNodeid);
        //System.out.println("this.RejectToType = " + this.RejectToType + " this.RejectToNodeid=" + this.RejectToNodeid);

        //指定节点退回，退回到分叉分叉起始节点，选择的是 重新分叉
        if (this.RejectToType == 1 && this.RejectToNodeid > 0) {
            int rejectnodeattribute = 0;//下一节点类型
            rs.executeSql("select nodeattribute from workflow_nodebase where id=" + this.RejectToNodeid);
            if (rs.next()) {
                rejectnodeattribute = Util.getIntValue(rs.getString("nodeattribute"), 0);
            }
            if (rejectnodeattribute == 1) {
                rs.executeSql("select destnodeid from workflow_NodeLink where wfrequestid is null and (isreject is null or isreject<>'1') and nodeid=" + this.RejectToNodeid + " and workflowid=" + workflowid);
                nextnodecount = rs.getCounts();
                mustpassnodeids = new WFLinkInfo().getMustPassStartBrancheNode(workflowid, requestid, nodeid);
            }
            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"nextnodecount = " + nextnodecount + " nextnodeid:{" + nextnodeid + "==" + this.RejectToNodeid + "} nextnodeattribute=" + rejectnodeattribute);
            //System.out.println("nextnodecount = " + nextnodecount + " nextnodeid:{" + nextnodeid + "==" + this.RejectToNodeid + "} nextnodeattribute=" + rejectnodeattribute);
        } else if (this.RejectToType == 2 && this.RejectToNodeid > 0) {
            int rejectnodeattribute = 0;//下一节点类型
            rs.executeSql("select nodeattribute from workflow_nodebase where id=" + this.RejectToNodeid);
            if (rs.next()) {
                rejectnodeattribute = Util.getIntValue(rs.getString("nodeattribute"), 0);
            }
            if (rejectnodeattribute == 3 || rejectnodeattribute == 4 || rejectnodeattribute == 5) {
                nextnodecount = new WFLinkInfo().getBrancheLastNode(requestid, workflowid, this.RejectToNodeid).size();
                //mustpassnodeids=new WFLinkInfo().getMustPassStartBrancheNode(workflowid,requestid);
            }
        }

        if(isreject == 1 && !FreeNodeBiz.isFreeNode(nodeid)) {
            int rejectType = 0;//退回类型
            int rejectToCreateNode = 1;//未设置退回出口时退至创建节
            rs.executeQuery("select isselectrejectnode, rejectToCreateNode from workflow_flownode where workflowid = ? and nodeid = ?", workflowid, nodeid);
            if (rs.next()) {//机器人节点不取此配置
                rejectType = Util.getIntValue(rs.getString("isselectrejectnode"), 0);
                rejectToCreateNode = Util.getIntValue(rs.getString("rejectToCreateNode"), 1);
            }
            if(RobotNodeBiz.isRobotNode(nodetype)) {//机器人节点按出口退回，未设置退回出口时退回失败
                rejectType = 0;
                rejectToCreateNode = 0;
            }
            //按出口退回，且开启节点未设置退回出口时退至创建节
            if(rejectType == 0 && rejectToCreateNode == 1 && this.RejectToNodeid <= 0) {
                RecordSet rsInner = new RecordSet();
                rs.executeQuery("select 1 from workflow_nodelink where workflowid = ? and nodeid = ? and isreject = '1'", workflowid, nodeid);
                if (!rs.next()) {//当前节点未设置退回出口，退回到创建节点
                    rsInner.executeQuery("select nodeid from workflow_flownode where workflowid = ? and nodetype = '0'", workflowid);
                    if (rsInner.next()) {
                        this.RejectToNodeid = rsInner.getInt(1);
                    }
                }
            }
        }

        if (this.SubmitToNodeid > 0 && this.IsTrunkSubmitToBranch(rs, nodeid, SubmitToNodeid)) {
            String tempsql = "select * from workflow_nodelink where wfrequestid is null and (isreject is null or isreject <> '1') and nodeid=" + nodeid + " and destnodeid=" + SubmitToNodeid + " and workflowid=" + workflowid + " order by linkorder, id";
            //if(this.IsTrunkSubmitToBranch(rs, nodeid, SubmitToNodeid)){//主干退回到分叉中间节点
            if(rs.getDBType().equalsIgnoreCase("postgresql")) {
                tempsql = "select l.* from workflow_nodelink l,workflow_nodebase n where (l.isreject is null or l.isreject <> '1') and l.destnodeid in (" + StringUtils.join(new WFLinkInfo().getLastOperateNode(requestid, workflowid, SubmitToNodeid), ",") + ") and l.workflowid=" + workflowid + " and l.wfrequestid is null and n.id=l.nodeid and (n.isfreenode is null or n.isfreenode =''  or n.isfreenode =' ') order by linkorder,l.id";
            }else{
                tempsql = "select l.* from workflow_nodelink l,workflow_nodebase n where (l.isreject is null or l.isreject <> '1') and l.destnodeid in (" + StringUtils.join(new WFLinkInfo().getLastOperateNode(requestid, workflowid, SubmitToNodeid), ",") + ") and l.workflowid=" + workflowid + " and (l.wfrequestid is null or l.wfrequestid='' or l.wfrequestid=' ')  and n.id=l.nodeid and (n.isfreenode is null or n.isfreenode =''  or n.isfreenode =' ') order by linkorder,l.id";
            }
            //}
            rs.executeSql(tempsql);
            nextnodecount = rs.getCounts();
        }

        //节点错误消息缓存
        List<String> cacheBuffers = new ArrayList<String>();
        errorInfoMsgBuffer.setLength(0);
        for (int i = 0; i < nextnodecount; i++) {
            if (nextnodecount > 20) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"----RequestNodeFlow---line610--userid:" + userid + ",nodeid:" + nodeid + ",nextnodecount:" + nextnodecount);
            }
            boolean havenext = getNextNodeOperator();
            this.occurnodeids.add("" + nextnodeid);
            if (eh_unAppendNextNodes) {
                eh_unAppendNextNodes = false;
                continue;
            }
            if (havenext || (isSelectNextFlow && selectNextFlowMode == SelectNextFlowMode.NODE_AND_OPERATOR)) {
                if (this.nextnodeids.indexOf("" + nextnodeid) == -1) {
                    this.nextnodeids.add("" + nextnodeid);
                    this.nextlinkids.add("" + nextlinkid);
                    this.nextnodetypes.add(nextnodetype);
                    this.nextlinknames.add(nextlinkname);
                    this.operatorshts.add(operatorsht);
                    this.linkismustpasss.add(ismustpasss);
                    this.nextnodeattrs.add(nextnodeattribute);
                    this.nextnodepassnums.add("" + passnum);
                    this.requestexceptiontypes.add("" + requestexceptiontype);
                }
                cacheBuffers.add(0, errorInfoMsgBuffer.toString());
            } else {
                int _nextnodeid = nextnodeid;
                if (this.nextnodeids.indexOf("" + nextnodeid) != -1 && this.nextnodeid != this.tempnextnodeid) {
                    _nextnodeid = this.tempnextnodeid;
                }
                if (mustpassnodeids.indexOf(_nextnodeid + "") != -1 || (isSelectNextFlow && new SelectNextFlowBiz().isInMustPassBranchAllNodeIds(workflowid, requestid, nodeid +"", _nextnodeid))) {
                    hasmustpassnodeClearMsg(cacheBuffers);
                    this.nextnodeids.clear();
                    this.nextlinkids.clear();
                    this.nextnodetypes.clear();
                    this.nextlinknames.clear();
                    this.operatorshts.clear();
                    this.linkismustpasss.clear();
                    this.nextnodeattrs.clear();
                    this.nextnodepassnums.clear();
                    break;
                }
                cacheBuffers.add(0, errorInfoMsgBuffer.toString());
                errorInfoMsgBuffer.setLength(0);
            }
        }

        //根据密级过滤不符合条件的操作者
        this.operatorshts = deleteOperateBySecLevel2(operatorshts, requestid);
    }

    private boolean addFreeNodeOperator() {
        if (freeNodeFlowBiz == null) {
            freeNodeFlowBiz = new RequestFreeNodeFlowBiz(user, requestid, nodeid);
        }
        if (!freeNodeFlowBiz.canFreeFlow(workflowid, SubmitToNodeid)) {
            return false;
        }
        if (isreject == 1) {
            if (RejectToNodeid > 0 && RejectToType < 3) {
                return false;
            }
        }
        boolean freeNodeOperator = false;
        if (freeNodeFlowBiz != null) {
            FreeNodeGroupEntity rootNodeGroup = freeNodeFlowBiz.getRootNodeGroup();
            if (rootNodeGroup != null || FreeNodeBiz.isFreeNode(this.SubmitToNodeid)) {
                List<FreeNodeEntity> freeNodeEntityList = new ArrayList<>();
                if (1 == isreject) {
                    if (RejectToType <= 0) {
                        if ("".equals(Util.null2String(newRejectNodeids).trim()))
                            newRejectNodeids = RejectToNodeid + "";
                        freeNodeEntityList.addAll(FreeNodeBiz.getFreeNodeByNodeIds(requestid, newRejectNodeids));
                    } else if (RejectToType == 3) {
                        FreeNodeGroupEntity nextGroup = null;
                        if (!FreeNodeBiz.isFreeNode(RejectToNodeid)) {
                            nextGroup = freeNodeFlowBiz.getRootNodeGroup();
                        } else {
                            FreeNodeEntity nodeEntity = FreeNodeBiz.getCurrentFreeNodeEntity(requestid, RejectToNodeid);
                            if (nodeEntity != null) {
                                FreeNodeGroupEntity groupEntity = FreeNodeBiz.getNodeGroupByID(freeNodeFlowBiz.getRootNodeGroup(), nodeEntity.getGroupid());
                                if (groupEntity != null && groupEntity.isHasNext()) {
                                    nextGroup = groupEntity.getNext();
                                }
                            }
                        }
                        if (nextGroup != null && nextGroup.getParallelNodeGroupDatas().size() > 0) {
                            List<FreeNodeGroupEntity> parallGroups = nextGroup.getParallelNodeGroupDatas();
                            for (FreeNodeGroupEntity parallGroup : parallGroups) {
                                freeNodeEntityList.add(parallGroup.getNodeEntity());
                            }
                        }
                    }
                } else {
                    //提交至退回节点
                    if (FreeNodeBiz.isFreeNode(this.SubmitToNodeid)) {
                        FreeNodeEntity targetNodeEntity = FreeNodeBiz.getCurrentFreeNodeEntity(requestid, this.SubmitToNodeid);
                        if (targetNodeEntity != null) {
                            freeNodeEntityList.add(targetNodeEntity);
                        }
                        RequestFlowInfoEntity flowInfoEntity = FreeNodeBiz.getLastRejectInfo(requestid, nodeid);
                        if (flowInfoEntity != null) {
                            String rejectNodeIds = flowInfoEntity.getRejectnodeids();
                            if (!"".equals(rejectNodeIds)) {
                                List<String> rejectNodeIdList = Util.splitString2List(rejectNodeIds, ",");
                                for (String rejectnodeid : rejectNodeIdList) {
                                    int __rejectnodeid = Util.getIntValue(rejectnodeid);
                                    if (FreeNodeBiz.isFreeNode(__rejectnodeid)) {
                                        FreeNodeEntity nodeEntity = FreeNodeBiz.getCurrentFreeNodeEntity(requestid, __rejectnodeid);
                                        if (nodeEntity != null) {
                                            freeNodeEntityList.add(nodeEntity);
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        freeNodeEntityList.addAll(freeNodeFlowBiz.getNextFreeNodes(requestid, nodeid));
                    }
                }
                if (freeNodeEntityList != null && freeNodeEntityList.size() > 0) {
                    freeNodeOperator = true;
                    boolean nextNodeHasOperator = false;
                    for (FreeNodeEntity nodeEntity : freeNodeEntityList) {
                        boolean havenext = freeNodeFlowBiz.getNextNodeOperators(nodeEntity, this, requestid);
                        if (havenext) {
                            if (this.nextnodeids.indexOf("" + nextnodeid) == -1) {
                                this.nextnodeids.add("" + nextnodeid);
                                this.nextlinkids.add("" + nextlinkid);
                                this.nextnodetypes.add(nextnodetype);
                                this.nextlinknames.add(nodeEntity.getNodename());
                                this.operatorshts.add(operatorsht);
                                this.linkismustpasss.add(ismustpasss);
                                this.nextnodeattrs.add(nextnodeattribute);
                                this.nextnodepassnums.add("" + passnum);
                            }
                            nextNodeHasOperator = true;
                        } else {
                            //节点 ... 未设置节点操作
                            if (nodeEntity.isMustPass()) errorInfoMsgBuffer.setLength(0);
                            errorInfoMsgBuffer.append(freeNodeFlowBiz.getFreeNodeMsgContent(nodeEntity, languageid));
                            //分支必须通过
                            if (nodeEntity.isMustPass()) {
                                nextNodeHasOperator = false;
                                this.nextnodeids.clear();
                                break;
                            }
                        }
                    }
                    if (!nextNodeHasOperator) {
                        JSONObject msgInfo = new JSONObject();
                        try {
                            msgInfo.put("details", errorInfoMsgBuffer.toString());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        this.setMessagecontent(msgInfo.toString());
                    }
                } else {
                    //未找到下一节点，表示是从自由节点到下一节点则
                    if (nodeid < 0) {
                        int freeStartNodeId = rootNodeGroup.getFreeStartNodeid();
                        String freeEndNodeId = Util.null2String(rootNodeGroup.getFreeEndNodeid());

                        if (!freeEndNodeId.equals(Util.null2String(freeStartNodeId))) {
                            this.lastFreeNodeId = nodeid;
                            this.nodeid = freeStartNodeId;
                        } else {
                            this.nextnodeid = freeStartNodeId;
                            rs.executeProc("workflow_NodeType_Select", "" + workflowid + flag + nextnodeid);
                            if (rs.next()) {
                                nextnodetype = Util.null2String(rs.getString(1));
                            }
                            NodeInfoEntity nodeInfo = WorkflowBaseBiz.getNodeInfo(nextnodeid);
                            nextnodeattribute = nodeInfo.getNodeAttribute();
                            nextlinkname = nodeInfo.getNodename();
                            boolean hasOperator = getNextOperator();
                            if (hasOperator) {
                                if (this.nextnodeids.indexOf("" + nextnodeid) == -1) {
                                    this.nextnodeids.add("" + nextnodeid);
                                    this.nextlinkids.add("" + nextlinkid);
                                    this.nextnodetypes.add(nextnodetype);
                                    this.nextlinknames.add(nextlinkname);
                                    this.operatorshts.add(operatorsht);
                                    this.linkismustpasss.add(ismustpasss);
                                    this.nextnodeattrs.add(nextnodeattribute);
                                    this.nextnodepassnums.add("" + passnum);
                                    this.requestexceptiontypes.add("" + requestexceptiontype);
                                }
                                freeNodeOperator = true;
                            }
                        }
                    }
                }
            }
        }
        return freeNodeOperator;
    }


    private void initTempGroupId() {
        rs.executeSql("select max(groupid) from workflow_currentoperator where requestid=" + this.requestid);
        if (rs.next()) {
            tempGroupId = rs.getInt(1);
        }
    }

    /**
     * 取得流程下一节点的操作者
     *
     * @return 是否取得成功
     */
    public boolean getNextNodeOperator() {
        passNodes.clear();
        int flowcount = 0;                         // 是否有跳过节点的操作

		/*  单独处理逐个操作 by ben 2006-04-08

	    boolean isorderbyorder = getCurrentNodeType();     // 当前节点是否是逐个操作节点
		if (isorderbyorder) {                              // 当前节点为逐个操作节点
			nextnodeid = nodeid;
			nextlinkid = 0;
			nextlinkname = linkname;
			nextnodetype = nodetype;
            if(isreject!=1){
			boolean hasoperator = getNextOperator();      // 获得当前节点的剩余操作人
			if (hasoperator) return true;                // 如果有剩余操作人，返回，否则，进入下一个节点
            }
        }
        */
        //自由流程开始节点的处理，下一个节点为自定义节点顺序最小的节点    add by mackjoe at 20080825 TD8897

        sql = "select id,Signtype,operators from workflow_nodebase where IsFreeNode='1' and requestid=" + requestid + " and startnodeid=" + nodeid;
        if (this.SubmitToNodeid > 0) {
            sql += " and id=" + this.SubmitToNodeid;
        }
        sql += " order by floworder,id";
        rs.executeSql(sql);
//        boolean hasData = rs.next();
//        int tempNextnodeid = rs.getInt("id");
//        RecordSet rs2 = new RecordSet();
//        rs2.executeSql("select * from workflow_currentoperator where nodeid='"+tempNextnodeid+"' and requestid="+requestid);
//        boolean hasData2 = rs2.next();
        //流程退回的话，不应该走入只有流程设置的路径 isreject = 1 代表流程退回
        if (rs.next() && isreject != 1) {
            IsFreeNode = "1";
            nextnodeid = rs.getInt("id");
            FreeSigntype = Util.getIntValue(rs.getString("Signtype"), 0);
            Freeoperators = Util.null2String(rs.getString("operators"));
            return FreeWorkflowNextoperator();
        }
        //自由流程退回
//        if(isreject==1){
//            //退回到的结点还是自由流程节点
//            sql = "select a.id,a.Signtype,a.operators from workflow_nodebase a,workflow_nodebase b where a.id = b.startnodeid and b.IsFreeNode = a.IsFreeNode and b.IsFreeNode='1' and a.requestid = b.requestid and b.requestid = " + requestid + " and b.id = " + nodeid;
//            rs.executeSql(sql);
//            //writeLog("判断自由流程 sql:"+sql);
//            if(rs.next()){
//                IsFreeNode = "1";
//                nextnodeid = rs.getInt("id");
//                FreeSigntype = Util.getIntValue(rs.getString("Signtype"), 0);
//                Freeoperators = Util.null2String(rs.getString("operators"));
//                //writeLog("判断自由流程 IsFreeNode:"+IsFreeNode+"	nextnodeid:"+nextnodeid+"	FreeSigntype:"+FreeSigntype+"	Freeoperators:"+Freeoperators);
//                return FreeWorkflowNextoperator();
//            }
//        }
        WFLinkInfo wfLinkInfo = new WFLinkInfo();
        ArrayList lastBrancheNodeList = wfLinkInfo.getLastBrancheNodes(this.workflowid, this.requestid);
        boolean eh_againJudge = false;
        if (!eh_callAgainNextNodes) requestexceptiontype = 0;
        int whileCount = 0;
        while (true) {
            if (whileCount > 20) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"line727-userid:" + userid + ",nodeid:" + nodeid);
            }
            if (whileCount > 100) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"流程设置可能存在死循环，请检查流程设置userid:" + userid + ",nodeid:" + nodeid);
                return false;
            }
            whileCount++;
            String nextNodeId = "";//add by liaodong for qc76119,76120,54194,64652 start
            String NodeId = "";//add by liaodong for qc76119,76120,54194,64652 start
            passNodes.add("" + nodeid);
            boolean hasnextnode = getNextNode();
            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+ ",getNextNode() hasnextnode = " + hasnextnode + " nextnodeid=" + nextnodeid);
            //add by liaodong for qc76119,76120,54194,64652 start
            nextNodeId = nextnodeid + "";
            NodeId = nodeid + "";
            //end
            if (!hasnextnode) {
                this.SubmitToNodeid = 0;
                if (flowcount == 0)
                    return false;
                else {
                    //已穿透，到下一节点节点错误，删除最后个穿透节点workflow_currentoperator已办数据
                    String delPenetrateSql = "delete from workflow_currentoperator where requestid=" + requestid + " and nodeid=" + nodeid + " and userid=" + userid + " and isremark=2 and preisremark=0 and receivedate='" + getCurrentdate() + "' and receivetime='" + getCurrenttime() + "'";
                    new RecordSet().executeSql(delPenetrateSql);
                    return true;
                }
            }
            //自由流程中间节点
            if (this.IsFreeNode.equals("1")) {
                return FreeWorkflowNextoperator();
            } else {

                if (!eh_againJudge) {        //保留第一次流转的节点信息，异常处理前节点信息
                    eh_original_nodeinfo.put("nodeid", "" + nodeid);
                    eh_original_nodeinfo.put("nextnodeid", "" + nextnodeid);
                }
                boolean hasoperator = getNextOperator();
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+ "getNextOperator() hasoperator = " + hasoperator + " nextnodeid=" + nextnodeid+"---operatorsht==="+this.operatorsht);
                if (!hasoperator) {
                    if (flowcount == 0) {
                        try {

                            //指定流转退回和提交至指定节点判定
                            if ((isreject == 1 || SubmitToNodeid > 0) && SelectNextFlowBiz.buildRejectOperatorMap(eh_operatorMap, requestid, nextnodeid)) {
                                return getNextOperatorByAssignUser(Util.null2String(eh_operatorMap.get("eh_relationship")), Util.null2String(eh_operatorMap.get("eh_operators")));
                            }

                            //liuzy 流转异常设置判定
                            Map<String, String> settingMap = flowExceptionHandle.getExceptionHandleSetting(workflowid, nextnodeid);
                            if (!"1".equals(Util.null2String(settingMap.get("useExceptionHandle"))))        //未启用异常设置
                                return false;
                            int handleway = Util.getIntValue(settingMap.get("exceptionHandleWay"));
                            /*以下几种情况忽略异常处理设置*/
                            /*退回,异常前两种方式不处理*/
                            /*分叉合并点*/
                            /*分支第一个分叉中间点设置无效*/
                            /*归档节点 且 设置的跳转下一节点或跳转指定节点*/
                            /*异常跳转一次后，只针对跳转下一节点选项做递归处理*/
                            /*分叉起始点找不到操作者，下一节点找分叉中间点时，分叉中间点设置无效*/
                            /*分叉起始点提交到分叉中间点，分叉中间点设置由用户指定操作者无效*/
                            JSONObject msgInfo = new JSONObject();
                            if (isreject == 1 && handleway != 3) {
                                return false;
                            }

                            // 提交到退回节点时，不进行流程异常处理
                            if (SubmitToNodeid > 0) {
                                //return false;
                            }
                            if ("3".equals(nextnodeattribute) || "4".equals(nextnodeattribute) || "5".equals(nextnodeattribute)) {
                                return false;
                            }

                            if (("1".equals(nodeattribute) || "0".equals(nodeattribute)) && "2".equals(nextnodeattribute)) {
                                return false;
                            }
                            if ("3".equals(nextnodetype) && handleway != 3) {
                                return false;
                            }
                            if (eh_againJudge && handleway != 1) {
                                return false;
                            }
                            if (eh_callAgainNextNodes)
                                return false;
                            if ("1".equals(nodeattribute) && handleway == 3)
                                return false;

                            eh_againJudge = true;
                            requestexceptiontype = handleway;
                            if (handleway == 1) {//异常处理跳过节点时，记录跳过的节点，插入数据库。 在流程图中显示跳过的节点
                                String passedNodes = Util.null2String(eh_operatorMap.get("passedNodes"));
                                if ("".equals(passedNodes)) {
                                    passedNodes = nextnodeid + "";
                                } else {
                                    passedNodes += "," + nextnodeid;
                                }
                                eh_operatorMap.put("passedNodes", passedNodes);
                            }
                            if (handleway == 1) {        //设置找不到操作者时流转至下一节点
                                if ("1".equals(nextnodeattribute)) {
                                    nodeid = nextnodeid;
                                    eh_callAgainNextNodes = true;    //模拟分叉起始点调用getNextNodes()方法算分叉中间点
                                    this.isSelectNextFlow = false;
                                    freeNodeFlowBiz = null;
                                    getNextNodes();
                                    eh_unAppendNextNodes = true;    //控制不进行原getNextNodes()方法的后续拼接节点操作
                                    return false;
                                } else {
                                    if (nodeid == nextnodeid) {
                                        Map<String, Object> messagecontentMap = JSON.parseObject(messagecontent);
                                        messagecontentMap.put("details", messagecontentMap.get("details") + "<span>" + WorkflowRequestMessage.getBoldInfo(WorkflowRequestMessage.getWorkflowNodename(nextnodeid)) + SystemEnv.getHtmlLabelName(507499, languageid) + "</span><br/>");
                                        messagecontent = JSON.toJSONString(messagecontentMap);
                                        errorInfoMsgBuffer.insert(0, "<span>" + WorkflowRequestMessage.getBoldInfo(WorkflowRequestMessage.getWorkflowNodename(nextnodeid)) + SystemEnv.getHtmlLabelName(507499, languageid) + "</span><br/>");
                                        //writeLog("RequestNodeFlow----节点异常处理出现死循环，请检查流程设置是否存在死循环！----requestid:" + requestid + ",userid:" + userid + ",nodeid:" + nodeid);
                                        log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+ "节点异常处理出现死循环，请检查流程设置是否存在死循环！,userid:" + userid + ",nodeid:" + nodeid);
                                        return false;
                                    }
                                    nodeid = nextnodeid;
                                    linkid = nextlinkid;
                                    linkname = nextlinkname;
                                    nodetype = nextnodetype;
                                    this.SubmitToNodeid = 0;
                                    continue;
                                }
                            } else if (handleway == 2) {    //设置找不到操作者时跳转至指定节点
                                int jumpAssignNode = Util.getIntValue(settingMap.get("flowToAssignNode"));
                                if (jumpAssignNode == -1 || nodeid == jumpAssignNode || nextnodeid == jumpAssignNode)
                                    return false;
                                if (flowExceptionHandle.judgeCanFlowAssignNode(workflowid, nodeid, jumpAssignNode)) {
                                    nextnodeid = jumpAssignNode;
                                    rs.executeSql("SELECT nb.nodeattribute,fn.nodetype,nb.passnum FROM workflow_nodebase nb,workflow_flownode fn WHERE nb.id = fn.nodeid AND fn.nodeid=" + nextnodeid);
                                    if (rs.next()) {
                                        nextlinkid = -1;
                                        nextlinkname = SystemEnv.getHtmlLabelName(125951, languageid);
                                        ismustpasss = "0";
                                        nextnodetype = Util.null2String(rs.getString("nodetype"));
                                        nextnodeattribute = Util.null2String(rs.getString("nodeattribute"));
                                        passnum = Util.getIntValue(rs.getString("passnum"));
                                        boolean hasoperator_next = getNextOperator();
                                        if (hasoperator_next) {
                                            setHasEflowToAssignNode(true);
                                            return true;
                                        }
                                    }
                                }
                            } else if (handleway == 3) {    //设置由用户指定操作者
                                this.setMessagecontent("");
                                String eh_setoperator = Util.null2String(eh_operatorMap.get("eh_setoperator"));
                                if (isreject == 1) {                //退回时，找节点异常处理时人员,按提交至指定人员处理
                                    eh_setoperator = "y";
                                    flowExceptionHandle.buildRejectOperatorMap(eh_operatorMap, requestid, nextnodeid);
                                }
                                if ("y".equals(eh_setoperator)) {        //流程提交至选择的人员
                                    boolean setOperatorFlag = getNextOperatorByAssignUser(Util.null2String(eh_operatorMap.get("eh_relationship")), Util.null2String(eh_operatorMap.get("eh_operators")));
                                    return setOperatorFlag;
                                } else if ("n".equals(eh_setoperator)) {
                                    return false;
                                } else {
                                    isNeedChooseOperator = true;
                                    return false;
                                }
                            }
                        } catch (Exception e) {
                            this.recordErrMsgBySubNodeReqId("ReqManager==Exception="+e.getMessage(), requestid);
                            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=Exception="+e.getMessage());
                            //writeLog(e);
                        }
                        return false;
                    } else {
                        //已穿透，到下一节点操作者异常，删除最后个穿透节点workflow_currentoperator已办数据
                        String delPenetrateSql = "delete from workflow_currentoperator where requestid=" + requestid + " and nodeid=" + nodeid + " and userid=" + userid + " and isremark=2 and preisremark=0 and receivedate='" + getCurrentdate() + "' and receivetime='" + getCurrenttime() + "'";
                        new RecordSet().executeSql(delPenetrateSql);
                        nextnodeid = nodeid;
                        nextlinkid = linkid;
                        nextlinkname = linkname;
                        nextnodetype = nodetype;
                        return true;
                    }
                }

                // 增加配置文件：workflowNotPenetrate.properties,
                // 在此文件中配置的流程ID，或者表单ID，均不会执行穿透操作
                /*int failedFlag = 0;
                //是否关闭流程自动流转日志
                boolean wfAutoFlowLogisclose = Util.getIntValue(this.getPropValue("wfAutoFlowLog", "wfAutoFlowLogisclose")) == 1;
                try {
                    //是否关闭了穿透功能
                    boolean isclose = Util.getIntValue(this.getPropValue("workflowNotPenetrate", "close")) == 1;
                    //开启自动批准
                    String isAutoApprove = Util.null2s(new WorkflowAllComInfo().getIsAutoApprove(workflowid + ""), "0");
                    if(!"0".equals(isAutoApprove)){
                        return true;
                    }
                    if (failedFlag==0 && isclose ) {
                        return true;     //failedFlag="1";
                    }
                    //开启指定流转
                    boolean selectNextFlow = SelectNextFlowBiz.hasSelectNextFlow(nextnodeid);
                    if (failedFlag==0 && selectNextFlow) {
                        failedFlag=2;
                    }
                    //不穿透的流程ID
                    String notPenetratewfids = Util.null2String(this.getPropValue("workflowNotPenetrate", "workflowids"));
                    //不穿透的系统表单ID
                    String notPenetratesysformids = Util.null2String(this.getPropValue("workflowNotPenetrate", "sysformids"));
                    //不穿透的自定义表单ID
                    String notPenetrateformids = Util.null2String(this.getPropValue("workflowNotPenetrate", "formids"));
                    //流程代理是否穿透
//				if ("".equals(closeAgentPenetrate)) {
                    closeAgentPenetrate = Util.null2String(this.getPropValue("workflowAgentNotPenetrate", "closeAgentPenetrate"));
                    closeAgentPenetrateWorkflowId = Util.null2String(this.getPropValue("workflowAgentNotPenetrate", "closeAgentPenetrateWorkflowId"));
                    closeAgentPenetrateWorkflowId = "," + closeAgentPenetrateWorkflowId + ",";
//				}
                    //在配置文件中找到对应的ID则不穿透
                    if (failedFlag==0 && ("," + notPenetratewfids + ",").indexOf("," + workflowid + ",") != -1) {
                          return true;   //failedFlag="1";
                    }
                    //在配置文件中找到对应的系统表单ID则不穿透
                    if (failedFlag==0 && isbill == 1 && formid > 0 && ("," + notPenetratesysformids + ",").indexOf("," + formid + ",") != -1) {
                        return true;  //failedFlag="1";
                    } else if (failedFlag==0 && ((isbill == 1 && formid < 0) || (isbill != 1 && formid > 0))
                            && ("," + notPenetrateformids + ",").indexOf("," + formid + ",") != -1) {
                        return true;    //failedFlag="1";
                    }

                } catch (Exception e) {
                    //writeLog("unable to get through the configuration.!");
                    e.printStackTrace();
                }

                // 如果是退回或者重新打开操作,不作跳过,
                // 如果是提及操作,下一个节点不是审批节点,不作跳过判定
                // 如果下一个节点是审批节点并有可以编辑的项目,也不作跳过判定,如果依次逐个递交也不做跳过判定
                // 如果下一个节点的所有组中,有一个没有包含当前操作者,不作跳过
                // 分叉起始节点、合并点不作跳过
                // 分叉合并点前的最后一个分叉中间点，也不跳过
                boolean isLastBrancheNode = lastBrancheNodeList.contains("" + this.nextnodeid);
                if (failedFlag==0 && this.SubmitToNodeid > 0) {//提交到退回节点 不进行穿透
                    failedFlag=3;
                }
                //System.out.println("nextnodetype="+nextnodetype+" this.SubmitToNodeid = "+this.SubmitToNodeid);
                String userIdStr = "-1";//被代理人ID记录
                if (failedFlag==0 && (isreopen == 1 || isreject == 1))
                    failedFlag=4;
                else if (failedFlag==0 && !nextnodetype.equals("1") && this.SubmitToNodeid <= 0) {
                    if("3".equals(nextnodetype)){
                        return true;
                    }else{
                        failedFlag=5;
                    }
                } else if (failedFlag==0 && (nextnodetype.equals("1") || nextnodetype.equals("0")) && hasedititem && this.SubmitToNodeid <= 0) {
                    failedFlag=6;
                } else if (failedFlag==0 && orderflag)
                    failedFlag=7;
                else if (failedFlag==0 && (nextnodeattribute.equals("1") || nextnodeattribute.equals("3") || nextnodeattribute.equals("4") || nextnodeattribute.equals("5")))
                    failedFlag=8;
                else if (failedFlag==0 && isLastBrancheNode == true) {
                    failedFlag=9;
                } else if (failedFlag==0 && nodeattribute.equals("1") && nextnodeattribute.equals("2")) {   //如果当前节点是分叉起始节点并且下一个节点是分叉中间节点，不允许穿透
                    failedFlag=10;
                }
                if(failedFlag==0) {
                    if (flowcount > 0 && nextnodeid == nodeid) {//如果设置了流程出口返回本节点，并且已经穿透了一次，那第2次不再穿透
                        failedFlag = 11;
                    } else {
                        Enumeration operatorgroups = operatorsht.keys();
                        while (operatorgroups.hasMoreElements()) {
                            String operatorgroup = (String) operatorgroups.nextElement();
                            ArrayList operators = (ArrayList) operatorsht.get(operatorgroup);
                            //operators的内容构成改变为"userid_usertype_groupdetailid"，故修改是否为相同操作者的判断方法
                            boolean isUserRepeat = false;
                            for (int i = 0; i < operators.size(); i++) {
                                String userStr = (String) operators.get(i);
                                userStr = userStr.substring(0, userStr.lastIndexOf("_"));
                                userStr = userStr.substring(0, userStr.lastIndexOf("_"));
                                //add by liao dong for qc56835 in 2013年10月21日 start
                                userIdStr = userStr.substring(0, userStr.lastIndexOf("_"));
                                String usertypeStr = userStr.substring(userStr.lastIndexOf("_"));

                                String agentId = getAgentTypeByUserId(userIdStr, workflowid + "");
                                if ("".equals(agentId)) {
                                    if (userStr.equals("" + userid + "_" + usertype)) {
                                        isUserRepeat = true;
                                        updateAgentManagerByUserId(userIdStr, isbill, formid, requestid);
                                        break;
                                    }
                                } else { //设置了代理a-b-c-d的时候c-b需要穿透
                                    //查询代理人的usertype
                                    if ((agentId + usertypeStr).equals("" + userid + "_" + usertype) && !"1".equals(closeAgentPenetrate.trim()) && closeAgentPenetrateWorkflowId.indexOf("," + workflowid + ",") == -1) {
                                        isUserRepeat = true;
                                        updateAgentManagerByUserId(userIdStr, isbill, formid, requestid);
                                        break;
                                    }
                                }
                                //end
                            }
                            if (failedFlag==0 && !isUserRepeat) return true;   //failedFlag="12";
                        }
                    }
                }
                if(wfAutoFlowLogisclose){
                    if(failedFlag!=0) return true;
                }else{
                    if (failedFlag!=0) {
                        if(workflowid != 1 && currentdate!=null && !"".equals(currentdate) && requestid>0){
                        List params = WfAutoflowLogUtil.initParams(requestid, 0, this.nodeid, this.nextnodeid, "1", failedFlag, this.userid, currentdate, currenttime);
                        WfAutoflowLogUtil.putWfautoParamList(params);
                        }
                        return true;
                    }
                    if (failedFlag==0 && workflowid != 1 && currentdate!=null && !"".equals(currentdate) && requestid>0) {
                        List params = WfAutoflowLogUtil.initParams(requestid, 1, this.nodeid, this.nextnodeid, "1", failedFlag, this.userid, currentdate, currenttime);
                        WfAutoflowLogUtil.putWfautoParamList(params);
                    }
                }
                nodeid = nextnodeid;
                linkid = nextlinkid;
                linkname = nextlinkname;
                nodetype = nextnodetype;
                hasedititem = false;
                flowcount++;
                //TD25811 chujun
                //程序到了这里，已经是满足流程穿透了。在workflow_currentoperator表插入一条记录，为了在流程退回的时候能找到操作者。isremark=2
                if (this.isFromRequestManager == 1) {//如果是提交确认，进这个方法的入口不是RequestManager，就不做这个操作。
                    try {
                        WorkflowComInfo wfComInfo = new WorkflowComInfo();
                        int workflowtype = Util.getIntValue(wfComInfo.getWorkflowtype("" + workflowid), 0);
                        String Procpara_tmp = "" + requestid + flag + userid + flag + "0" + flag + workflowid + flag
                                + workflowtype + flag + usertype + flag + "2" + flag + nodeid + flag + userIdStr
                                + flag + "2" + flag + -1 + flag + "0";
                        if (userIdStr.equals("" + userid)) {
                            Procpara_tmp = "" + requestid + flag + userid + flag + "0" + flag + workflowid + flag
                                    + workflowtype + flag + usertype + flag + "2" + flag + nodeid + flag + -1
                                    + flag + "0" + flag + -1 + flag + "0";
                        }
                        RecordSet rs_tmp = new RecordSet();
                        rs_tmp.executeProc("workflow_CurrentOperator_I", Procpara_tmp);
                        rs_tmp.execute("update workflow_currentoperator set preisremark='0' where userid=" + userid + " and requestid=" + requestid + " and usertype=" + usertype + " and nodeid=" + nodeid + " and islasttimes=1");
                        // add by liaodong for qc86096 in 2013-11-19 start
                        rs_tmp.executeSql("update workflow_currentoperator set  receivedate='" + getCurrentdate() + "',receivetime='" + getCurrenttime() + "'  where  userid=" + userid + " and requestid=" + requestid + " and usertype=" + usertype + " and nodeid=" + nodeid + " and islasttimes=1  ");
                        //end
                    } catch (Exception e) {

                    }
                }
                //add by liaodong for qc76119,76120,54194,64652 start
                //由于未插入workflow_requestLog插入新的表workflow_penetrateLog中作为穿透表的原因 start
                if ("".equals(nextNodeId)) {
                    nextNodeId = nodeid + "";
                }
                try {
                    //取数据库服务器的当前时间 start
                    if (!isintervenor.equals("1")) {//如果是流程干预，则不往workflow_penetrateLog表中插数据
                        String penetrateSql = "insert into workflow_penetrateLog(requestid,workflowid,nodeid,operator,operatortype,destnodeid,logtype, linkid)"
                                + "values ('" + requestid + "','" + workflowid + "','" + NodeId + "','" + userid + "','" + usertype + "','" + nextNodeId + "','2', "+linkid+")";
                        if ("oracle".equals(rs.getDBType())) {
                            penetrateSql = "insert into workflow_penetrateLog(id,requestid,workflowid,nodeid,operator,operatortype,destnodeid,logtype, linkid)"
                                    + "values (workflowpenetratelog_Id.nextval,'" + requestid + "','" + workflowid + "','" + NodeId + "','" + userid + "','" + usertype + "','" + nextNodeId + "','2', "+linkid+")";
                        }
                        rs.executeSql(penetrateSql);
                    }

                    String maxpenetrateIdSql = "select max(id) maxId from  workflow_penetrateLog where requestid= " + requestid + "";
                    rs.executeSql(maxpenetrateIdSql);
                    if (rs.next()) {
                        this.setPenetrateId(this.getPenetrateId() + "," + rs.getString("maxId"));
                    }
                    this.setLastNodeId(nextNodeId);
                } catch (Exception e) {
                }*/
                //end
                return true;
            }
        }
    }

    /**
     * 取得流程下一节点
     *
     * @return 是否取得成功
     */
    public boolean getNextNode() {
        if (isreopen == 1) {
            rs.executeProc("workflow_CreateNode_Select", workflowid + "");
            if (rs.next()) {
                nextnodeid = Util.getIntValue(rs.getString(1), 0);
                nextnodetype = "0";   // 创建节点类型
                nextlinkid = -1;
                nextlinkname = "Reopen";
            } else
                return false;
        }    //td30785
        else if ((isreject == 1 && RejectToNodeid > 0) || (this.SubmitToNodeid > 0 && this.IsTrunkSubmitToBranch(rs, nodeid, SubmitToNodeid))) {    //退回到指定节点 或者提交到指定节点
            ArrayList whereclauses = new ArrayList();                   //  出口条件
            ArrayList newrules = new ArrayList();                        // 新规则
            ArrayList linkids = new ArrayList();                        //  出口id
            ArrayList linknames = new ArrayList();                      //  出口名称
            ArrayList nextnodeids = new ArrayList();
            ArrayList mustpassnodeids = new ArrayList();
            mustpassnodeids = new WFLinkInfo().getMustPassStartBrancheNode(workflowid, requestid, nodeid);
            //System.out.println("this.RejectToType = "+this.RejectToType+" RejectToNodeid:"+RejectToNodeid+"");
            boolean temp_nextnodeid = false;
            if (isreject == 1) {
                if (this.RejectToType == 1) {//重新分叉
                    if (rs.getDBType().equals("mysql")) {
                        rs.executeSql("select id,linkname,`condition`,newrule,destnodeid from workflow_nodelink where wfrequestid is null and nodeid=" + this.RejectToNodeid + " and workflowid=" + workflowid + " and (isreject is null or isreject<>'1') order by linkorder,id");
                    } else {
                        rs.executeSql("select id,linkname,condition,newrule,destnodeid from workflow_nodelink where wfrequestid is null and nodeid=" + this.RejectToNodeid + " and workflowid=" + workflowid + " and (isreject is null or isreject<>'1') order by linkorder,id");
                    }
                    //writeLog("select id,linkname,condition,newrule,destnodeid from workflow_nodelink where wfrequestid is null and nodeid="+this.RejectToNodeid+" and workflowid="+workflowid+" and (isreject is null or isreject<>'1') order by linkorder,id");
                    while (rs.next()) {
                        whereclauses.add(Util.null2String(rs.getString("condition")));
                        newrules.add(Util.null2String(rs.getString("newrule")));
                        linkids.add(Util.null2String(rs.getString("id")));
                        linknames.add(Util.null2String(rs.getString("linkname")));
                        nextnodeids.add(Util.null2String(rs.getString("destnodeid")));
                    }
                } else if (this.RejectToType == 2) {//取消合并
                    if (rs.getDBType().equals("mysql")) {
                        rs.executeSql("select id,linkname,`condition`,newrule,destnodeid from workflow_nodelink where wfrequestid is null and destnodeid in (" + StringUtils.join(new WFLinkInfo().getBrancheLastNode(requestid, workflowid, RejectToNodeid), ",") + ") and workflowid=" + workflowid + " order by linkorder,id");
                    } else {
                        rs.executeSql("select id,linkname,condition,newrule,destnodeid from workflow_nodelink where wfrequestid is null and destnodeid in (" + StringUtils.join(new WFLinkInfo().getBrancheLastNode(requestid, workflowid, RejectToNodeid), ",") + ") and workflowid=" + workflowid + " order by linkorder,id");
                    }
                    //writeLog("select id,linkname,condition,newrule,destnodeid from workflow_nodelink where wfrequestid is null and destnodeid in ("+StringUtils.join(new WFLinkInfo().getBrancheLastNode(requestid, workflowid, RejectToNodeid),",")+") and workflowid="+workflowid+" order by linkorder,id");
                    while (rs.next()) {
                        //whereclauses.add(Util.null2String(rs.getString("condition")));
                        //newrules.add(Util.null2String(rs.getString("newrule")));
                        whereclauses.add("");
                        newrules.add("");
                        linkids.add(Util.null2String(rs.getString("id")));
                        linknames.add(Util.null2String(rs.getString("linkname")));
                        nextnodeids.add(Util.null2String(rs.getString("destnodeid")));
                    }
                } else {
                    nextnodeid = RejectToNodeid;
				/*
            	rs.executeSql("select id,linkname,condition,newrule from workflow_nodelink where wfrequestid is null and isreject='1' and nodeid="+nodeid+" and destnodeid="+nextnodeid+" and workflowid="+workflowid+" order by linkorder,id");
                while(rs.next()){
    				whereclauses.add(Util.null2String(rs.getString("condition")));
    				newrules.add(Util.null2String(rs.getString("newrule")));
    				linkids.add(Util.null2String(rs.getString("id")));
    				linknames.add(Util.null2String(rs.getString("linkname")));
    				nextnodeids.add("" + nextnodeid);
                }
				*/
                }
            } else if (this.SubmitToNodeid > 0) {

                String tempsql = "";//"select * from workflow_nodelink where wfrequestid is null and (isreject is null or isreject <> '1') and nodeid=" + nodeid + " and destnodeid=" + SubmitToNodeid + " and workflowid=" + workflowid + " order by linkorder, id";
                //if(this.IsTrunkSubmitToBranch(rs, nodeid, SubmitToNodeid)){//主干退回到分叉中间节点
                if(rs.getDBType().equalsIgnoreCase("postgresql")) {
                    tempsql = "select l.* from workflow_nodelink l,workflow_nodebase n where (l.isreject is null or l.isreject <> '1') and l.destnodeid in (" + StringUtils.join(new WFLinkInfo().getLastOperateNode(requestid, workflowid, SubmitToNodeid), ",") + ") and l.workflowid=" + workflowid + " and l.wfrequestid is null and n.id=l.nodeid and (n.isfreenode is null or n.isfreenode ='' or n.isfreenode =' ') order by linkorder,l.id";
                }else{
                    tempsql = "select l.* from workflow_nodelink l,workflow_nodebase n where (l.isreject is null or l.isreject <> '1') and l.destnodeid in (" + StringUtils.join(new WFLinkInfo().getLastOperateNode(requestid, workflowid, SubmitToNodeid), ",") + ") and l.workflowid=" + workflowid + " and (l.wfrequestid is null or l.wfrequestid='' or l.wfrequestid=' ')  and n.id=l.nodeid and (n.isfreenode is null or n.isfreenode ='' or n.isfreenode =' ') order by linkorder,l.id";
                }
                //}
                rs.executeSql(tempsql);
                while (rs.next()) {
                    //whereclauses.add(Util.null2String(rs.getString("condition")));
                    //newrules.add(Util.null2String(rs.getString("newrule")));
                    whereclauses.add("");
                    newrules.add("");
                    linkids.add(Util.null2String(rs.getString("id")));
                    linknames.add(Util.null2String(rs.getString("linkname")));
                    nextnodeids.add(Util.null2String(rs.getString("destnodeid")));
                }
            }
            // System.out.println("linkids.size()="+linkids.size());
            if (linkids.size() > 0) {
                int linkindex = 0;
                for (linkindex = 0; linkindex < linkids.size(); linkindex++) {
                    nextlinkid = Util.getIntValue((String) linkids.get(linkindex));
                    nextlinkname = (String) linknames.get(linkindex);
                    int nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
                    String whereclause = (String) whereclauses.get(linkindex);
                    String newrule = (String) newrules.get(linkindex);
                    this.tempnextnodeid = nextnodeid;
                    rs.executeProc("workflow_NodeType_Select", "" + workflowid + flag + nextnodeid);
                    if (rs.next()) {
                        nextnodetype = Util.null2String(rs.getString(1));
                    }
                    if (tempmutinodeids.contains(nextnodeid)) {
                        continue;
                    }

                    boolean oldcop = false;
                    boolean newcop = false;
                    if (whereclause.trim().equals("") && newrule.trim().equals("")) {
                        tempmutinodeids.add(nextnodeid);
                        break;
                    } else {
                        //查询规则间的关系
                        RecordSet rrs = new RecordSet();
                        int ruleRelationship = 1;
                        if (!"".equals(nextlinkid)) {
                            String rulesql = "select ruleRelationship from workflow_nodelink where id = " + linkid;
                            rrs.executeSql(rulesql);
                            if (rrs.next()) {
                                ruleRelationship = Util.getIntValue(Util.null2String(rrs.getString("ruleRelationship")), 1);
                            }
                        }
                        if (!whereclause.trim().equals("")) //兼容老条件
                        {
                            if (isbill == 1)
                                sql = "select count(id) from " + billtablename + " where id=" + billid + " and " + whereclause;
                            else
                                sql = "select count(requestid) from workflow_form where requestid=" + requestid + " and " + whereclause;
                            rs.executeSql(sql);

                            if (rs.next() && rs.getInt(1) > 0) {
                                oldcop = true;
                                tempmutinodeids.add(nextnodeid);
                            }
                            //规则间关系为或者关系时，如果老的条件已经满足，则不再去计算新规则
                            if (ruleRelationship == 2 && oldcop) {
                                tempmutinodeids.add(nextnodeid);
                                break;
                            }

                            //规则间关系为并且是， 如果老的条件不满足，则不再去计算新规则，直接计算下一条出口
                            if (ruleRelationship == 1 && !oldcop) {
                                tempmutinodeids.add(nextnodeid);
                                continue;
                            }
                        } else {
                            //规则间关系是“并且”， 且老的规则又不存在时，将老条件结果置为true
                            if (ruleRelationship == 1) {
                                tempmutinodeids.add(nextnodeid);
                                oldcop = true;
                            }
                        }


                        if (!newrule.trim().equals("")) {
                            RuleInterface rif = new RuleInterface();
                            rif.setUserid(this.userid + "");
                            rif.setAutoForecast(this.autoForecast);
                            rif.setForecastManagerInfo(this.forecastManagerInfo);
                            newcop = rif.compareRuleforWF(newrule, requestid + "", nextlinkid + "", RuleInterface.RULESRC_CK);
                        } else {
                            if (ruleRelationship == 1) {
                                newcop = true;
                            }
                        }
                        if (ruleRelationship == 1) {
                            if (oldcop && newcop) {
                                tempmutinodeids.add(nextnodeid);
                                break;
                            }
                        } else {
                            if (oldcop || newcop) {
                                tempmutinodeids.add(nextnodeid);
                                break;
                            }
                        }
                    }
                }
                try {
                    nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
                    this.tempnextnodeid = nextnodeid;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                nextlinkid = -1;
                rs.executeSql("select nodename,nodetype from workflow_flownode f,workflow_nodebase n WHERE n.id=f.nodeid and workflowid=" + workflowid + " and nodeid=" + nextnodeid);
                if (rs.next()) {
                    nextlinkname = Util.null2String(rs.getString("nodename"));
                    nextnodetype = Util.null2String(rs.getString("nodetype"));
                }

            }
        } else if (isForceOver && forceOverNodeId > 0) {  //强制归档到指定归档节点
            nextnodeid = forceOverNodeId;
            rs.executeProc("workflow_NodeType_Select", "" + workflowid + flag + nextnodeid);
            if (rs.next()) {
                nextnodetype = Util.null2String(rs.getString(1));
            }

            ArrayList whereclauses = new ArrayList();                   //  出口条件
            ArrayList newrules = new ArrayList();                        //	新出口条件
            ArrayList linkids = new ArrayList();                        //  出口id
            ArrayList linknames = new ArrayList();                      //  出口名称
            if (rs.getDBType().equals("mysql")) {
                rs.executeSql("select id,linkname,`condition`,newrule from workflow_nodelink where wfrequestid is null and (isreject is null or isreject<>'1') and nodeid=" + nodeid + " and destnodeid=" + nextnodeid + " and workflowid=" + workflowid + " order by linkorder, id");
            } else {
                rs.executeSql("select id,linkname,condition,newrule from workflow_nodelink where wfrequestid is null and (isreject is null or isreject<>'1') and nodeid=" + nodeid + " and destnodeid=" + nextnodeid + " and workflowid=" + workflowid + " order by linkorder, id");
            }
            while (rs.next()) {
                whereclauses.add(Util.null2String(rs.getString("condition")));
                newrules.add(Util.null2String(rs.getString("newrule")));
                linkids.add(Util.null2String(rs.getString("id")));
                linknames.add(Util.null2String(rs.getString("linkname")));
            }

            if (linkids.size() > 0) {
                for (int linkindex = 0; linkindex < linkids.size(); linkindex++) {
                    nextlinkid = Util.getIntValue((String) linkids.get(linkindex));
                    nextlinkname = (String) linknames.get(linkindex);
                    String whereclause = (String) whereclauses.get(linkindex);
                    String newrule = (String) newrules.get(linkindex);
                    boolean oldcop = false;
                    boolean newcop = false;
                    if (whereclause.trim().equals("") && newrule.trim().equals("")) {
                        break;
                    } else {

                        //查询规则间的关系
                        RecordSet rrs = new RecordSet();
                        int ruleRelationship = 1;
                        if (!"".equals(nextlinkid)) {
                            String rulesql = "select ruleRelationship from workflow_nodelink where id = " + linkid;
                            rrs.executeSql(rulesql);
                            if (rrs.next()) {
                                ruleRelationship = Util.getIntValue(Util.null2String(rrs.getString("ruleRelationship")), 1);
                            }
                        }

                        //兼容老条件
                        if (!whereclause.trim().equals("")) {
                            if (isbill == 1)
                                sql = "select count(id) from " + billtablename + " where id=" + billid + " and " + whereclause;
                            else
                                sql = "select count(requestid) from workflow_form where requestid=" + requestid + " and " + whereclause;
                            rs.executeSql(sql);

                            if (rs.next() && rs.getInt(1) > 0) {
                                oldcop = true;
                            }

                            //规则间关系为或者关系时，如果老的条件已经满足，则不再去计算新规则
                            if (ruleRelationship == 2 && oldcop) {
                                break;
                            }

                            //规则间关系为并且是， 如果老的条件不满足，则不再去计算新规则，直接计算下一条出口
                            if (ruleRelationship == 1 && !oldcop) {
                                continue;
                            }
                        } else {
                            //规则间关系是“并且”， 且老的规则又不存在时，将老条件结果置为true
                            if (ruleRelationship == 1) {
                                oldcop = true;
                            }
                        }

                        if (!newrule.trim().equals("")) {
                            RuleInterface rif = new RuleInterface();
                            rif.setUserid(this.userid + "");
                            rif.setAutoForecast(this.autoForecast);
                            rif.setForecastManagerInfo(this.forecastManagerInfo);
                            newcop = rif.compareRuleforWF(newrule, requestid + "", nextlinkid + "", RuleInterface.RULESRC_CK);
                        } else {
                            if (ruleRelationship == 1) {
                                newcop = true;
                            }
                        }
                        if (ruleRelationship == 1) {
                            if (oldcop && newcop)
                                break;
                        } else {
                            if (oldcop || newcop)
                                break;
                        }
                    }
                }
            } else {
                nextlinkid = -1;
                rs.executeSql("select nodename from workflow_nodebase where id=" + nextnodeid);
                if (rs.next()) {
                    nextlinkname = Util.null2String(rs.getString("nodename"));
                }
            }
        } else {
            ArrayList whereclauses = new ArrayList();                   //  出口条件
            ArrayList newrules = new ArrayList();                        //	新规则
            ArrayList linkids = new ArrayList();                        //  出口id
            ArrayList linknames = new ArrayList();                      //  出口名称
            ArrayList nextnodeids = new ArrayList();                    //  目标节点
            ArrayList ismustpassss = new ArrayList();                    // 是否必须通过
            String isBulidCode = null;                    //  是否生成编号
            ArrayList isBulidCodeList = new ArrayList();                    //  是否生成编号列表
            ArrayList mustpassnodeids = new ArrayList();
            ArrayList conditions = new ArrayList();              //出口规则文本
            mustpassnodeids = new WFLinkInfo().getMustPassStartBrancheNode(workflowid, requestid, nodeid);
            //System.out.println("mustpassnodeids.size = "+mustpassnodeids.size()+" SubmitToNodeid="+SubmitToNodeid);
            boolean executesuccess = true;//rs.executeProc("workflow_NodeLink_Select", nodeid + "" + flag + isreject+flag+""+requestid);
            //按照设置顺序进行排序
            rs = WFPathUtil.getNodeLinkrs(workflowid, requestid, nodeid, isreject, rs);
            if (rs.getCounts() == 0 && SubmitToNodeid <= 0 && selectNextFlowNodeList.size() <= 0) {
                //出口未设置
                JSONObject msgInfo = null;
                msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126539, languageid), workflowid, WorkflowRequestMessage.WF_LINK_SET);
                String sql = "select * from workflow_nodelink where workflowid=" + workflowid + " and nodeid=" + nodeid + " and isreject='1' order by linkorder ,id";
                rs.executeQuery(sql);
                if(rs.getCounts()>0) {
                    msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(520317, languageid), workflowid, WorkflowRequestMessage.WF_LINK_SET);
                }
                this.setMessagecontent(msgInfo.toString());
                if(reqFailMsg != null) reqFailMsg.setMsgType(ReqFlowFailMsgType.LINK_NOE_SET);
                return false;
            }
            if (SubmitToNodeid <= 0 && selectNextFlowNodeList.size() <= 0) {
                while (rs.next()) {
                    if (this.occurnodeids.indexOf(rs.getString("destnodeid")) != -1) continue;

                    int destnodeid = Util.getIntValue(rs.getString("destnodeid"), 0);
                    RecordSet rs2 = new RecordSet();
                    RecordSet rs3 = new RecordSet();
                    rs2.executeSql("select * from workflow_nodebase where requestid='" + requestid + "' and startnodeid=" + nodeid);
                    int freeNodeid = 0;
                    boolean hasData = rs2.next();
                    if (hasData) freeNodeid = Util.getIntValue(rs2.getString("id"), 0);
                    rs3.executeSql("select * from workflow_currentoperator where nodeid='" + freeNodeid + "' and requestid=" + requestid);
                    if (hasData && rs3.next() && destnodeid == freeNodeid) {
                        continue;
                    }
                    whereclauses.add(Util.null2String(rs.getString("condition")));
                    newrules.add(Util.null2String(rs.getString("newrule")));
                    linkids.add(Util.null2String(rs.getString("id")));
                    linknames.add(Util.null2String(rs.getString("linkname")));
                    nextnodeids.add(Util.null2String(rs.getString("destnodeid")));
                    isBulidCodeList.add(Util.null2String(rs.getString("isBulidCode")));
                    ismustpassss.add(Util.null2String(rs.getString("ismustpass")));
                    conditions.add(Util.null2String(rs.getString("newconditioncn")));
                }
            } else { // 提交至退回节点
				/*
  				rs.executeSql("select * from workflow_nodelink where wfrequestid is null and (isreject is null or isreject <> '1') and nodeid=" + nodeid + " and destnodeid=" + SubmitToNodeid + " and workflowid=" + workflowid + " order by linkorder, id");
 				while(rs.next()) {
 	                whereclauses.add(Util.null2String(rs.getString("condition")));
 	                newrules.add(Util.null2String(rs.getString("newrule")));
 					linkids.add(Util.null2String(rs.getString("id")));
 					linknames.add(Util.null2String(rs.getString("linkname")));
 					nextnodeids.add(Util.null2String(rs.getString("destnodeid")));
 					isBulidCodeList.add(Util.null2String(rs.getString("isBulidCode")));
 	                ismustpassss.add(Util.null2String(rs.getString("ismustpass")));
 				}
				*/
                if (linkids.size() == 0 && SubmitToNodeid > 0) {
                    String SubmitToNodename = "";
                    rs.executeSql("select nodename from workflow_nodebase where id=" + SubmitToNodeid);
                    if (rs.next()) {
                        SubmitToNodename = Util.null2String(rs.getString("nodename"));
                    }
                    whereclauses.add("");
                    newrules.add("");
                    linkids.add("-1");
                    linknames.add(SubmitToNodename);
                    nextnodeids.add("" + SubmitToNodeid);
                    isBulidCodeList.add("");
                    ismustpassss.add("");
                }

                //指定流转的节点
                if (selectNextFlowNodeList.size() > 0) {
                    String SubmitToNodename = "";
                    int selectNodeId =  selectNextFlowNodeList.get(0);
                    rs.executeSql("select nodename from workflow_nodebase where id= " + selectNodeId);
                    if (rs.next()) {
                        SubmitToNodename = Util.null2String(rs.getString("nodename"));
                    }
                    String selectLinkId = SelectNextFlowBiz.findSelectFlowLinkInfo(requestid, workflowid, nodeid, selectNodeId, user);
                    String selectLink_whereClause = "";
                    String selectLink_newrule = "";
                    String selectLink_linkNames = "";
                    String selectLink_isBulidCode = "";
                    String selectLink_isMustPassss = "";
                    rs.executeQuery("select * from workflow_nodelink where workflowid = ? and id = ? and id <> '-1' ", workflowid, selectLinkId);
                    if (rs.next()) {
                        selectLink_whereClause = Util.null2String(rs.getString("condition"));
                        selectLink_newrule = Util.null2String(rs.getString("newrule"));
                        selectLink_linkNames = Util.null2String(rs.getString("linkname"));
                        selectLink_isBulidCode = Util.null2String(rs.getString("isBulidCode"));
                        selectLink_isMustPassss = Util.null2String(rs.getString("ismustpass"));
                    }
                    whereclauses.add(selectLink_whereClause);
                    newrules.add(selectLink_newrule);
                    linkids.add(selectLinkId);
                    linknames.add(SubmitToNodename);
                    nextnodeids.add("" + selectNextFlowNodeList.get(0));
                    isBulidCodeList.add(selectLink_isBulidCode);
                    ismustpassss.add(selectLink_isMustPassss);
                    selectNextFlowNodeList.remove(0);
                }
            }
            //自由流程退回
            if (isreject == 1 && this.RejectToType == 0) {
                //退回到的结点是正常流程节点
                sql = "select startnodeid from workflow_nodebase where IsFreeNode='1' and requestid = " + requestid + " and id = " + nodeid;
                rs.executeSql(sql);
                //writeLog("判断自由流程退回到的结点是正常流程节点 sql:"+sql);
                if (rs.next()) {
                    nextnodeid = rs.getInt("startnodeid");
                    //insert into workflow_nodelink(workflowid,nodeid,isreject,condition,linkname,destnodeid)
                    //values(41,221,1,'','退回',162)
                    whereclauses.add("");
                    newrules.add("");
                    linkids.add("0");
                    linknames.add("退回");
                    nextnodeids.add(String.valueOf(nextnodeid));
                    isBulidCodeList.add("");
                    ismustpassss.add("-100");
                    executesuccess = true;
                    //writeLog("判断自由流程退回到的结点是正常流程节点 nextnodeid:"+nextnodeid);
                }
            }

            if (!executesuccess) return false;
            int linkindex = 0;
            boolean temp_nextnodeid = false;

            for (linkindex = 0; linkindex < nextnodeids.size(); linkindex++) {

                //指定流转，不再计算出口条件
                if (isSelectNextFlow) {
                    break;
                }

                String whereclause = (String) whereclauses.get(linkindex);
                String newrule = (String) newrules.get(linkindex);
                String linkid = (String) linkids.get(linkindex);
                int nextnodeid = Util.getIntValue(nextnodeids.get(linkindex).toString(), 0);
                String linkname = (String) linknames.get(linkindex);
                String conditioncn = "";
                if(conditions != null && conditions.size()-1 >= linkindex){
                    conditioncn = (String)conditions.get(linkindex);
                }
                //记录出口条件判断日志
                Map linkRuleLogInfo = new HashMap();
                linkRuleLogInfo.put("linkid",linkid);
                linkRuleLogInfo.put("nextnodeid",nextnodeid);
                linkRuleLogInfo.put("linkname",linkname);
                linkRuleLogInfo.put("newrule",newrule);
                linkRuleLogInfo.put("whereclause",whereclause);
                Map rulesInfo = new HashMap();
                linkRuleLogInfo.put("rulesInfo",rulesInfo);
                linkRuleLogInfo.put("conditioncn",conditioncn);
                requestFlowLogEntity.getLinkLog().put(linkname+"("+linkid+")",linkRuleLogInfo);

                this.tempnextnodeid = nextnodeid;
                //System.out.println("requestid = "+requestid+" nextnodeid="+nextnodeid+" linkname="+linkname+"  newrule="+newrule);
                boolean oldcop = false;
                boolean newcop = false;
                if (whereclause.trim().equals("") && newrule.trim().equals("")) {
                    break;
                } else {
                    //查询规则间的关系
                    RecordSet rrs = new RecordSet();
                    int ruleRelationship = 1;
                    if (!"".equals(nextlinkid)) {
                        String rulesql = "select ruleRelationship from workflow_nodelink where id = " + linkid;
                        rrs.executeSql(rulesql);
                        if (rrs.next()) {
                            ruleRelationship = Util.getIntValue(Util.null2String(rrs.getString("ruleRelationship")), 1);
                        }
                    }
                    linkRuleLogInfo.put("ruleRelationship",ruleRelationship);
                    if (!whereclause.trim().equals("")) //兼容老条件
                    {
                        if (isbill == 1)
                            sql = "select count(id) from " + billtablename + " where id=" + billid + " and " + whereclause;
                        else
                            sql = "select count(requestid) from workflow_form where requestid=" + requestid + " and " + whereclause;
                        rs.executeSql(sql);

                        if (rs.next() && rs.getInt(1) > 0) {
                            oldcop = true;
                        }

                        //规则间关系为或者关系时，如果老的条件已经满足，则不再去计算新规则
                        if (ruleRelationship == 2 && oldcop) {
                            break;
                        } else {
                            if(!oldcop) {
                                nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
                                if (mustpassnodeids.indexOf("" + nextnodeid) > -1) {
                                    temp_nextnodeid = true;
                                    break;
                                }
                            }
                        }

                        //规则间关系为并且是， 如果老的条件不满足，则不再去计算新规则，直接计算下一条出口
                        if (ruleRelationship == 1 && !oldcop) {
                            continue;
                        }

                    } else {
                        //规则间关系是“并且”， 且老的规则又不存在时，将老条件结果置为true
                        if (ruleRelationship == 1) {
                            oldcop = true;
                        }
                    }


                    if (!newrule.trim().equals("")) {
                        RuleInterface rif = new RuleInterface();
                        rif.setUserid(this.userid + "");
                        rif.setAutoForecast(this.autoForecast);
                        rif.setForecastManagerInfo(this.forecastManagerInfo);
                        rif.setRulesInfo(rulesInfo);
                        newcop = rif.compareRuleforWF(newrule, requestid + "", linkid, RuleInterface.RULESRC_CK);
                        linkRuleLogInfo.put("result",newcop);
                    } else {
                        if (ruleRelationship == 1) {
                            newcop = true;
                        }
                    }
                    if (ruleRelationship == 1) {
                        if (oldcop && newcop) {
                            break;
                        } else {
                            nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
                            if (mustpassnodeids.indexOf("" + nextnodeid) > -1) {
                                temp_nextnodeid = true;
                                break;
                            }
                        }
                    } else {
                        if (oldcop || newcop) {
                            break;
                        } else {
                            nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
                            if (mustpassnodeids.indexOf("" + nextnodeid) > -1) {
                                temp_nextnodeid = true;
                                break;
                            }
                        }
                    }
                }

            }
            if (temp_nextnodeid) {
                if(reqFailMsg != null) reqFailMsg.setMsgType(ReqFlowFailMsgType.LINK_CONDITION_NOT_MET);
                //条件不满足
                this.setMessagecontent(WorkflowRequestMessage.linkConditionNSInfo(newrules, nextnodeids, linkids, rs, FreeNodeBiz.isFreeNode(lastFreeNodeId) ? lastFreeNodeId : nodeid, workflowid, languageid, errorInfoMsgBuffer, index, mustpassnodeids));
                return false;
            }
            if (nextnodeids.size() == 0 || linkindex == nextnodeids.size()) {
                if(reqFailMsg != null) reqFailMsg.setMsgType(ReqFlowFailMsgType.LINK_CONDITION_NOT_MET);
                this.setMessagecontent(WorkflowRequestMessage.linkConditionNSInfo(newrules, nextnodeids, linkids, rs, FreeNodeBiz.isFreeNode(lastFreeNodeId) ? lastFreeNodeId : nodeid, workflowid, languageid, errorInfoMsgBuffer, index, mustpassnodeids));
                return false;
            }

            nextnodeid = Util.getIntValue((String) nextnodeids.get(linkindex), 0);
            nextlinkid = Util.getIntValue((String) linkids.get(linkindex), 0);
            nextlinkname = (String) linknames.get(linkindex);
            isBulidCode = (String) isBulidCodeList.get(linkindex);
            ismustpasss = (String) ismustpassss.get(linkindex);
            this.tempnextnodeid = nextnodeid;
            rs.executeProc("workflow_NodeType_Select", "" + workflowid + flag + nextnodeid);
            if (rs.next()) {
                nextnodetype = Util.null2String(rs.getString(1));
            } else {
                JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126539, languageid), workflowid, WorkflowRequestMessage.WF_LINK_SET);
                this.setMessagecontent(msgInfo.toString());
                return false;
            }

            if (isreject != 1) {
                //rs.executeSql("select count(nodeid) from workflow_nodeform where isedit = '1' and nodeid = " + nextnodeid);
                WFModeNodeFieldManager wFModeNodeFieldManager = new WFModeNodeFieldManager();
                boolean isMode = wFModeNodeFieldManager.getIsModeByWorkflowIdAndNodeId(workflowid, nextnodeid);
                if (isMode) {
                    rs.executeSql("select count(nodeid) from workflow_modeview where isedit = '1' and nodeid = " + nextnodeid + " and formid=" + formid);
                } else {
                    rs.executeSql("select count(nodeid) from workflow_nodeform where isedit = '1' and nodeid = " + nextnodeid +" and fieldid != -3");
                }
                if (rs.next()) {
                    if (Util.getIntValue(rs.getString(1), 0) > 0) hasedititem = true;
                }
            }
            //if("1".equals(isBulidCode)){
            if ("1".equals(isBulidCode) && this.isGetFlowCodeStr) {
                //CodeBuild cbuild = new CodeBuild(formid,String.valueOf(isbill));
                //CodeBuild cbuild = new CodeBuild(formid,String.valueOf(isbill),this.workflowid);
                CodeBuild cbuild = new CodeBuild(formid, String.valueOf(isbill), this.workflowid, this.creater, this.creatertype);
                //String  codeFields=cbuild.haveCode();
                String codeFields = cbuild.haveCode(this.workflowid, formid, String.valueOf(isbill));
                if (!codeFields.equals("")) {
                    Map<String, Object> formLogParams = new HashMap<>();
                    formLogParams.put("user", user);
                    formLogParams.put("nodeId", nodeid);
                    formLogParams.put("clientIp", clientIp);
                    cbuild.getFlowCodeStr(requestid, isbill, formid, this.workflowid, this.creater, this.creatertype, formLogParams);
                }
            }
        }

        rs.executeSql("select nodeattribute,passnum,IsFreeNode,Signtype,operators from workflow_nodebase where id=" + nextnodeid);
        if (rs.next()) {
            this.nextnodeattribute = Util.null2String(rs.getString("nodeattribute"));
            this.passnum = rs.getInt("passnum");
            this.IsFreeNode = Util.null2String(rs.getString("IsFreeNode"));
            this.FreeSigntype = Util.getIntValue(rs.getString("Signtype"), 0);
            this.Freeoperators = Util.null2String(rs.getString("operators"));
        } else {
            JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
            errorInfoMsgBuffer.insert(0, "<span>" + WorkflowRequestMessage.getBoldInfo(SystemEnv.getHtmlLabelName(10004310, languageid)) + "</span><br/>"
                    + "<span>" + SystemEnv.getHtmlLabelName(126551, languageid) + "nextnodeid:" + nextnodeid + "</span>" + "<br/>");
            try {
                msgInfo.put("details", errorInfoMsgBuffer.toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            this.setMessagecontent(msgInfo.toString());
            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"----流转报错--workflow_nodebase--nextnodeid:" + nextnodeid);
            return false;
        }
        return true;
    }

    /**
     * 取得流程当前节点状态
     *
     * @return 当前节点linkname
     * @throws Exception
     */
    public String getLinkName(int nodeid, int billid, int requestid, int isbill, String billtablename) throws Exception {
        String linkname = "";
        String linknodeid="";
        RecordSet rs1 = new RecordSet();
        RecordSet rs2 = new RecordSet();
        RecordSet rs3 = new RecordSet();
        ConnStatement statement = null;
        try {
            statement = new ConnStatement();
            //rs1.executeSql("select condition,linkname from workflow_nodelink where wfrequestid is null and destnodeid="+nodeid+" and (isreject='' or isreject is null) order by nodepasstime,id");
            if (rs1.getDBType().equals("mysql")) {
                statement.setStatementSql("select `condition`,linkname,newrule,nodeid from workflow_nodelink where wfrequestid is null and destnodeid=" + nodeid + " and (isreject='' or isreject is null) order by nodepasstime,id");
            } else {
                statement.setStatementSql("select condition,linkname,newrule,nodeid from workflow_nodelink where wfrequestid is null and destnodeid=" + nodeid + " and (isreject='' or isreject is null) order by nodepasstime,id");
            }
            statement.executeQuery();
            while (statement.next()) {
                String whereclause = "";
                String newrule = "";
                String tmpnodeid = "";
                rs3.executeQuery("select nodeid from workflow_requestflowinfo where requestid = ? and destnodeid = ? order by id desc",requestid,nodeid);
                if(rs3.next()){
                    tmpnodeid = Util.null2String(rs3.getString("nodeid"));
                }
                linknodeid = Util.null2String(statement.getString("nodeid"));
                if(!tmpnodeid.equals(linknodeid)){
                    continue;
                }
                if (statement.getDBType().equals("oracle") && Util.null2String(statement.getOrgindbtype()).equals("oracle")) {
                    oracle.sql.CLOB theclob = statement.getClob("condition");
                    if (theclob != null) {
                        String readline = "";
                        StringBuffer clobStrBuff = new StringBuffer("");
                        java.io.BufferedReader clobin = new java.io.BufferedReader(theclob.getCharacterStream());
                        while ((readline = clobin.readLine()) != null) clobStrBuff = clobStrBuff.append(readline);
                        clobin.close();
                        whereclause = clobStrBuff.toString();
                    }
                } else {
                    whereclause = Util.null2String(statement.getString("condition"));
                }
                newrule = Util.null2String(statement.getString("newrule"));
                boolean oldcop = false;
                boolean newcop = false;
                if (whereclause.trim().equals("") && newrule.trim().equals("")) {
                    linkname = Util.null2String(statement.getString("linkname"));
                    break;
                } else {
                    if (!whereclause.trim().equals("")) {
                        if (isbill == 1)
                            sql = "select count(id) from " + billtablename + " where id=" + billid + " and " + whereclause;
                        else
                            sql = "select count(requestid) from workflow_form where requestid=" + requestid + " and " + whereclause;
                        rs2.executeSql(sql);

                        if (rs2.next() && rs2.getInt(1) > 0) {
                            oldcop = true;
                        }
                    } else oldcop = true;
                    if (!newrule.trim().equals("")) {
                        RuleInterface rif = new RuleInterface();
                        rif.setUserid(this.userid + "");
                        rif.setAutoForecast(this.autoForecast);
                        rif.setForecastManagerInfo(this.forecastManagerInfo);
                        newcop = rif.compareRuleforWF(newrule, requestid + "", nodeid + "", RuleInterface.RULESRC_CK);
                    } else newcop = true;
                    if (oldcop && newcop) {
                        linkname = Util.null2String(statement.getString("linkname"));
                        break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (statement != null)
                statement.close();
        }
        return linkname;
    }

    /**
     * 得到依次逐个递交情况，上个操作人操作后的情况
     *
     * @return 是否取得成功
     */
    public boolean getNextOrderOperator(String groupdetails) {
        return this.getNextOrderOperator(groupdetails, true);
    }

    public boolean getNextOrderOperator(String groupdetails, boolean needUpdate) {
        ArrayList operators = null;
        Hashtable tempoperatorsht = new Hashtable();
        String theorderbyordervalue = "";
        RecordSet rs1 = new RecordSet();
        RecordSet rs2 = new RecordSet();

        RecordSet rsTemps = new RecordSet();
        String statustr = "";
        String thedepartmentid = "0";
        String thesubcompanyid = "0";
        String supsubcompanyid = "0";
        String src = "";
        if (this.isreject == 1) {
            src = "reject";
        } else if (this.isintervenor.equals("1")) {
            src = "intervenor";
        }

        String crmmanager = "";
        if (creatertype == 0) {
            try {
                ResourceComInfo rc = new ResourceComInfo();
                DepartmentComInfo dc = new DepartmentComInfo();
                SubCompanyComInfo sc = new SubCompanyComInfo();

                if (nodetype.equals("0")) {
                    thedepartmentid = rc.getDepartmentID("" + creater);
                } else {
                    if (null != rst) {
                        rst.executeSql("select agentorbyagentid from workflow_currentoperator where agenttype='2' and requestid=" + requestid + " and userid=" + creater + " and usertype=" + creatertype + " and nodeid=" + nodeid);
                        if (rst.next()) {
                            thedepartmentid = rc.getDepartmentID(rst.getString("agentorbyagentid"));
                        } else {
                            thedepartmentid = rc.getDepartmentID("" + creater);
                        }
                    } else {
                        rs.executeSql("select agentorbyagentid from workflow_currentoperator where agenttype='2' and requestid=" + requestid + " and userid=" + creater + " and usertype=" + creatertype + " and nodeid=" + nodeid);
                        if (rs.next()) {
                            thedepartmentid = rc.getDepartmentID(rs.getString("agentorbyagentid"));
                        } else {
                            thedepartmentid = rc.getDepartmentID("" + creater);
                        }
                    }

                }
                if ("".equals(thedepartmentid)) {
                    thedepartmentid = "0";
                }
                thesubcompanyid = dc.getSubcompanyid1(thedepartmentid);
                if ("".equals(thesubcompanyid)) {
                    thesubcompanyid = "0";
                }
                supsubcompanyid = sc.getSupsubcomid(thesubcompanyid);
                if ("".equals(supsubcompanyid)) {
                    supsubcompanyid = "0";
                }

            } catch (Exception rcdc) {
                rcdc.printStackTrace();
            }
        } else {
            try {
                CustomerInfoComInfo cc = new CustomerInfoComInfo();
                ResourceComInfo rc = new ResourceComInfo();
                DepartmentComInfo dc = new DepartmentComInfo();
                SubCompanyComInfo sc = new SubCompanyComInfo();

                crmmanager = cc.getCustomerInfomanager("" + creater);
                thedepartmentid = rc.getDepartmentID(crmmanager);
                if ("".equals(thedepartmentid)) {
                    thedepartmentid = "0";
                }
                thesubcompanyid = dc.getSubcompanyid1(thedepartmentid);
                if ("".equals(thesubcompanyid)) {
                    thesubcompanyid = "0";
                }
                supsubcompanyid = sc.getSupsubcomid(thesubcompanyid);
                if ("".equals(supsubcompanyid)) {
                    supsubcompanyid = "0";
                }

            } catch (Exception rcdc) {
                rcdc.printStackTrace();
            }
        }
        if (nextnodetype.equals("3"))
            statustr = "0,1,2,3,5";//如果是归档节点，操作者包括为离职人员
        else
            statustr = "0,1,2,3";

        int groupnum = 0;
        int groupid = 0;
        int tempgroupid = 0;
        String[] groupids = Util.TokenizerString2(groupdetails, ",");
        for (int m = 0; m < groupids.length; m++) {
            String groups = Util.null2String(groupids[m]);
            if (!groups.equals("")) {
                String[] groupidArray = Util.TokenizerString2(groups, "_");
                groupid = Util.getIntValue(groupidArray[0]);
                tempgroupid = Util.getIntValue(groupidArray[1]);
            }
            operators = new ArrayList();

            //自由流程逐个处理
            FreeSigntype = 0;
            rs1.executeSql("select Signtype from workflow_nodebase where id = " + nodeid + " and requestid=" + requestid);
            if (rs1.next()) {
                    FreeSigntype = Util.getIntValue(rs1.getString("Signtype"), 0);
            }
            if (FreeSigntype == 2) {
                rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupid);
                boolean flags = false;
                boolean flago = false;  //考虑老的数据
                if (rs.next()) flags = true;
                if (!flags) {
                    rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                    if (rs.next()) flago = true;
                }
                if (flags || flago) {
                    String receivePersions = rs.getString("receivedPersons");
                    String coadjutants = Util.null2String(rs.getString("coadjutants"));
                    if (!"".equals(receivePersions)) {
                        String nextoperator = receivePersions.substring(0, receivePersions.indexOf(","));
                        addWfInterventionMsg(nextoperator);
                        operators.add("" + nextoperator + "_0" + "_" + groupid + "_0");
                        int idx = coadjutants.indexOf(",");
                        if (idx > 0) {
                            int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                            if (tempcoadjutant > 0 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupid + "_-5") == -1 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupid + "_0") == -1) {
                                operators.add("" + tempcoadjutant + "_0" + "_" + groupid + "_-5");
                                hasCoadjutant = true;
                            }
                        }
                        try {
                            if (needUpdate) {
                                if (flago)
                                    rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                else if (flags)
                                    rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupid);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        tempoperatorsht.put("" + tempgroupid, operators);
                        break;
                    }
                }
            } else {
                rs1.executeSql("select * from workflow_groupdetail where id = " + groupid + " order by id asc"); //必然是依次逐个递交
                if (rs1.next()) {                  // 某一个操作组中的多个操作者细项
                    int type = rs1.getInt("type");
                    int virtualid = Util.getIntValue(rs1.getString("virtualid"), -1);
                    int objid = rs1.getInt("objid");
                    int level = rs1.getInt("level_n");
                    int level2 = rs1.getInt("level2_n");
                    String jobobj = rs1.getString("jobobj");//岗位对象
                    String jobfield = rs1.getString("jobfield");//岗位级别
                    int groupdetailid = rs1.getInt("id");
                    int signorder = rs1.getInt("signorder");
                    int t_groupid = rs1.getInt("groupid");
                    String conditions = rs1.getString("conditions");
                    String deptField = rs1.getString("deptField");//部门自定义字段 deptField该字段存储值个格式id_fieldname_fieldlabel
                    String subcompanyField = rs1.getString("subcompanyField");//分部自定义字段subcompanyField该字段存储值个格式id_fieldname_fieldlabel
                    String zdysqlName = Util.null2String(rs1.getString("zdysqlname"));

                    int bhxj = rs1.getInt("bhxj");
                    String orders = rs1.getString("orders");
                    int IsCoadjutant = Util.getIntValue(rs1.getString("IsCoadjutant"));
                    int issyscoadjutant = Util.getIntValue(rs1.getString("issyscoadjutant"));
                    int coadjutant = Util.getIntValue(rs1.getString("coadjutants"));

                    boolean isConform = false;


                    //依次逐个处理批次条件日志暂时不记录
                    if (this.isConformConditions(conditions, rs2, groupdetailid + "",new HashMap<>())) {
                        isConform = true;
                    }

					isConform = true;//依次逐个处理不再校验批次条件
                    if (isConform && WFPathUtil.isContinuousProcessing(type) && signorder == 2) {
                        //流程干预的操作人为“逐个处理”时的特殊处理
                        if (t_groupid == -2) {
                            rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                            boolean flags = false;
                            boolean flago = false;  //考虑老的数据
                            if (rs.next()) flags = true;
                            if (!flags) {
                                rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                                if (rs.next()) flago = true;
                            }
                            if (flags || flago) {
                                String receivePersions = rs.getString("receivedPersons");
                                String coadjutants = Util.null2String(rs.getString("coadjutants"));
                                if (!"".equals(receivePersions)) {
                                    String nextoperator = receivePersions.substring(0, receivePersions.indexOf(","));
                                    addWfInterventionMsg(nextoperator);
                                    operators.add("" + nextoperator + "_0" + "_" + groupdetailid + "_0");
                                    int idx = coadjutants.indexOf(",");
                                    if (idx > 0) {
                                        int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                                        if (tempcoadjutant > 0 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5") == -1 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_0") == -1) {
                                            operators.add("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5");
                                            hasCoadjutant = true;
                                        }
                                    }
                                    try {
                                        if (needUpdate) {
                                            if (flago)
                                                rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                            else if (flags)
                                                rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        } else {
                            if (level2 == -1) {
                                level2 = Integer.MAX_VALUE;
                            }

                            OperatorEntity operatorInfo = new OperatorEntity();
                            operatorInfo.setGroupdetailId(groupdetailid);
                            operatorInfo.setType(type);
                            operatorInfo.setSignOrder(signorder + "");
                            operatorInfo.setOrder(Util.getDoubleValue(orders, 0.00));
                            operatorInfo.setLevel(level);
                            operatorInfo.setMaxLevel(level2);
                            operatorInfo.setCondition(conditions);
                            operatorInfo.setJobObj(jobobj);
                            operatorInfo.setJobField(jobfield);
                            operatorInfo.setBhxj(bhxj + "");
                            operatorInfo.setVirtual(virtualid + "");
                            List<String> operatorTemps = new ArrayList<String>();
                            String objectId = objid + "";
                            if (objectId.indexOf(",") == -1) {
                                operatorInfo.setObjectId(Util.getIntValue(objectId));
                                operatorTemps.add(objectId);
                            } else {
                                operatorTemps.addAll(Util.TokenizerString(objectId, ","));
                            }
                            operatorInfo.setOperators(operatorTemps);
                            operatorInfo.setIsCoadjutant(IsCoadjutant);
                            operatorInfo.setIssyscoadjutant(issyscoadjutant);
                            operatorInfo.setCoadjutant(coadjutant + "");
                            operatorInfo.setNodeId(this.nodeid);
                            operatorInfo.setNextnodeid(nextnodeid);
                            operatorInfo.setPassNodes(passNodes);
                            operatorInfo.setZdysqlName(zdysqlName);


                            NodeOperatorConfigBiz.getInstance().getOperatorEntity(operatorInfo, requestid, user, src, "1");


                            List<OperatorInfoEntity> operatorInfos = operatorInfo.getOperatorInfos();//操作者
                            List<OperatorInfoEntity> coadjutantInfos = operatorInfo.getCoadjutants();//协办人

                            //非归档节点所有类型均过滤离职人员，归档节点只有指定人不过滤离职人员，其他均过滤
                            boolean isFilter = getIsDimissionByProp(nextnodetype, type);
                            Iterator<OperatorInfoEntity> iterator = operatorInfos.iterator();
                            while (iterator.hasNext()) {
                                OperatorInfoEntity operatorEntity = iterator.next();
                                if (isFilter) {
                                    boolean isDimission = isDimissionPerson(operatorEntity,type);
                                    if (isDimission) {
                                        iterator.remove();
                                    }
                                }
                            }
                            //协办人离职过滤
                            Iterator<OperatorInfoEntity> iterator2 = coadjutantInfos.iterator();
                            while (iterator2.hasNext()) {
                                OperatorInfoEntity operatorEntity = iterator2.next();
                                if (isFilter) {
                                    boolean isDimission = isDimissionPerson(operatorEntity,type);
                                    if (isDimission) {
                                        iterator2.remove();
                                    }
                                }
                            }
                            RecordSet rs = new RecordSet(); //added by xwj on 20050617 for td2075
                            boolean hastheoperator = false;
                            /*if (operatorInfos.size() > 0) {
                                for (OperatorInfoEntity operatorEntity : operatorInfos) {//没看懂这个地方为什么需要一个for循环
                                    if (hastheoperator) break;
                                    int tepoperatorid = Util.getIntValue(operatorEntity.getUserId(), 0);
                                    if (tepoperatorid != 0) {*/
								/*--
								if (userid == tepoperatorid) {
									for (int j = i + 1; j < theorderbyordervalues.length; j++) {
										if (hastheoperator) break;
										tepoperatorid = Util.getIntValue(theorderbyordervalues[j], 0);
										if (tepoperatorid != 0) {
											operators.add("" + tepoperatorid + "_0");
											hastheoperator = true;
										}
										i++;
									}
								}
								--*/
                                        rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                        boolean flags = false;
                                        boolean flago = false;  //考虑老的数据
                                        if (rs.next()) flags = true;
                                        if (!flags) {
                                            rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                                            if (rs.next()) flago = true;
                                        }
                                        if (flags || flago) {
                                            String receivePersions = rs.getString("receivedPersons");
                                            String coadjutants = Util.null2String(rs.getString("coadjutants"));
                                            if (!"".equals(receivePersions)) {
                                                String nextoperator = receivePersions.substring(0, receivePersions.indexOf(","));
                                                addWfInterventionMsg(nextoperator);
                                                operators.add("" + nextoperator + "_0" + "_" + groupdetailid + "_0");

                                                int idx = coadjutants.indexOf(",");
                                                if (idx > 0) {
                                                    int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                                                    if (tempcoadjutant > 0 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5") == -1 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_0") == -1) {
                                                        operators.add("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5");
                                                        hasCoadjutant = true;
                                                    }
                                                    hastheoperator = true;
                                                    try {
                                                        if (needUpdate) {
                                                            if (flago)
                                                                rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                                            else if (flags)
                                                                rst.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                                        }
                                                    } catch (Exception e) {
                                                        e.printStackTrace();
                                                    }
                                                }
                                            }

                                        }

                                   // }

                               // }
                           // }
                        }


                    }

                }
                if (operators.size() > 0) tempoperatorsht.put("" + tempgroupid, operators);
            }
        }

        //依次逐个处理，过滤掉不符合密级的后续人员
        StringBuilder messageContent = new StringBuilder();
        tempoperatorsht = this.deleteOperateBySecLevel2(tempoperatorsht, requestid, messageContent);
        if (messageContent.length() > 0) {
            this.generateErrorMsg4SecLevel(messageContent);
        }

        if (tempoperatorsht.isEmpty())
            return false;
        else {
            operatorsht = tempoperatorsht;
            return true;
        }

    }

    private void addWfInterventionMsg(String nextoperator) {
        try {
            ResourceComInfo rc = new ResourceComInfo();
            String tempstatus = rc.getStatus(String.valueOf(nextoperator));
            if ("4".equals(tempstatus) || "5".equals(tempstatus) || "6".equals(tempstatus)) {
                JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126544, languageid) + WorkflowRequestMessage.getBoldDetailInfo(rc.getLastname(nextoperator)) + SystemEnv.getHtmlLabelName(126527, languageid), requestid, WorkflowRequestMessage.WF_INVERVENTION);
                this.setMessagecontent(msgInfo.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 判断是否为离职人员
     *
     * @return
     */
    private boolean isDimissionPerson(OperatorInfoEntity operatorEntity,int type) {
        RecordSet rs = new RecordSet();
        String opertor = operatorEntity.getUserId();
        String opertortype = operatorEntity.getUserType() + "";
        String hrmstatusSql = "";
        String tempStatus = "";
        if (!opertortype.equals("0")) {
            return false;
        }
        //在非归档节点，如果下一节点操作者为离职人员，且没有代理，则流程不流转（针对type为：3， 8， 17，18的情况）
        //根据用户类型来查询不同的表（员工表和客户信息表）。
        ResourceComInfo resourceComInfo = null;
        try{
            resourceComInfo = new ResourceComInfo();
        }catch (Exception e){

        }
        if (opertortype.equals("0")) {
            try {
                tempStatus = resourceComInfo.getStatus(opertor);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if ("".equals(tempStatus)) {
                hrmstatusSql = "select status from hrmresource where id=" + opertor;
            }
        } else {
            hrmstatusSql = "select status from CRM_CustomerInfo where id=" + opertor;
        }
        if (!"".equals(hrmstatusSql)) {
            rs.execute(hrmstatusSql);
            //获取人员状态
            if (rs.next()) {
                tempStatus = rs.getString("status");
            }
        }

        /**
         * 下一节点操作者是否过滤人员，只区分在职不在职，不在职的都需要过滤（归档需要根据配置进行判断）；人员“退休”状态按不在职处理 --徐如晶
         * 0：试用<br>1：正式<br>2：临时<br>3：试用延期<br>4：解聘<br>5：离职<br>6：退休<br>7：无效
         */
        if (!"".equals(tempStatus) && !"5".equals(tempStatus) && !"4".equals(tempStatus) && !"7".equals(tempStatus) && !"6".equals(tempStatus)) {
            return false;
        }

        //workflow_config表中name=operator_angent_typed的value值；操作者为离职人员时，不需要走代理的类型(类型说明:1部门、2角色、3指定人  workflow_groupdetail表的type字段)
        WorkflowConfigComInfo workflowConfigComInfo = new WorkflowConfigComInfo();
        String agentTypes = workflowConfigComInfo.getValue("operator_angent_type");
        if (agentTypes!=null&&(!"".equals(agentTypes))){
            String[] split = agentTypes.split(",");
            for (String agentType : split) {
                if (agentType.equals(type+""))
                return true;
            }
        }




        //查找当前人员是否设置了代理
        boolean isbeAgent = false;
        String agenterId = "";
        String workflowidAll = WorkflowVersion.getVersionStringByWfid(workflowid + "");
        String agentCheckSql = " select agentuid from workflow_agentConditionSet where workflowId in(" + workflowidAll + ") and bagentuid=" + opertor +
                " and agenttype = '1' and isproxydeal='1' " +
                " and ( ( (endDate = '" + TimeUtil.getCurrentDateString() + "' and (endTime='' or endTime is null))" +
                " or (endDate = '" + TimeUtil.getCurrentDateString() + "' and endTime > '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or endDate > '" + TimeUtil.getCurrentDateString() + "' or endDate = '' or endDate is null)" +
                " and ( ( (beginDate = '" + TimeUtil.getCurrentDateString() + "' and (beginTime='' or beginTime is null))" +
                " or (beginDate = '" + TimeUtil.getCurrentDateString() + "' and beginTime < '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or beginDate < '" + TimeUtil.getCurrentDateString() + "' or beginDate = '' or beginDate is null) order by agentbatch asc  ,id asc";
        rs.execute(agentCheckSql);
        //当前人员设置了代理，不再查找下一批次（离职人员设置了代理，不再向下寻找）
        if (rs.next()) {
            agenterId = Util.null2String(rs.getString("agentuid"));
            tempStatus = resourceComInfo.getStatus(agenterId);
            if("".equals(tempStatus)){
                rs.execute( "select status from hrmresource where id=" + agenterId);
                //获取人员状态
                if (rs.next()) {
                    tempStatus = rs.getString("status");
                }
            }
            if (!"".equals(tempStatus) && !"5".equals(tempStatus) && !"4".equals(tempStatus) && !"7".equals(tempStatus) && !"6".equals(tempStatus)) {
                return false;
            }
            return true;
        }

        return true;
    }


    /**
     * 是否是为空或者全部是离职人员<br>
     */
    private boolean isEmptyOrAllDimissionPerson(List<String> operators, RecordSet rs) {
        if (operators == null || operators.isEmpty()) {
            return true;
        }

        //归档节点，不检测离职人员
        if ("3".equals(nextnodetype)) {
            return false;
        }

        //迭代本批次操作者
        for (int i = 0; i < operators.size(); i++) {
            String operatorinfo = operators.get(i);
            String[] operatorandtypes = Util.TokenizerString2(operatorinfo, "_");
            String opertor = operatorandtypes[0];
            String opertortype = operatorandtypes[1];

            String hrmstatusSql = "";
            String tempStatus = "";
            //在非归档节点，如果下一节点操作者为离职人员，且没有代理，则流程不流转（针对type为：3， 8， 17，18的情况）
            //根据用户类型来查询不同的表（员工表和客户信息表）。
            if (opertortype.equals("0")) {
                hrmstatusSql = "select status from hrmresource where id=" + opertor;
            } else {
                hrmstatusSql = "select status from CRM_CustomerInfo where id=" + opertor;
            }
            rs.execute(hrmstatusSql);
            //获取人员状态
            if (rs.next()) {
                tempStatus = rs.getString("status");
            }

            //包含一个非内部员工，不再查找下一批次（本批次操作者找到了）
            if (!opertortype.equals("0")) {
                return false;
            }
            //包含一个非离职人员(或系统管理员)，不再继续查找下一批次（本批次操作者找到了）
            if ("".equals(tempStatus) || (!"5".equals(tempStatus) && !"4".equals(tempStatus))) {
                return false;
            }

            //查找当前人员是否设置了代理
            boolean isbeAgent = false;
            String agenterId = "";
            String agentCheckSql = " select agentuid from workflow_agentConditionSet where workflowId=" + workflowid + " and bagentuid=" + opertor +
                    " and agenttype = '1' and isproxydeal='1' " +
                    " and ( ( (endDate = '" + TimeUtil.getCurrentDateString() + "' and (endTime='' or endTime is null))" +
                    " or (endDate = '" + TimeUtil.getCurrentDateString() + "' and endTime > '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                    " or endDate > '" + TimeUtil.getCurrentDateString() + "' or endDate = '' or endDate is null)" +
                    " and ( ( (beginDate = '" + TimeUtil.getCurrentDateString() + "' and (beginTime='' or beginTime is null))" +
                    " or (beginDate = '" + TimeUtil.getCurrentDateString() + "' and beginTime < '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                    " or beginDate < '" + TimeUtil.getCurrentDateString() + "' or beginDate = '' or beginDate is null) order by agentbatch asc  ,id asc";
            rs.execute(agentCheckSql);
            //当前人员设置了代理，不再查找下一批次（离职人员设置了代理，不再向下寻找）
            if (rs.next()) {
                return false;
            }
        }
        return true;
    }

    /**
     * 检查指定人员是否设置了代理<br>
     */
    private boolean hasAgent4Operator(int operator, RecordSet rs) {
        if (operator < 0) {
            return false;
        }
        //查找当前人员是否设置了代理
        boolean isbeAgent = false;
        String agentCheckSql = " select agentuid from workflow_agentConditionSet where workflowId=" + workflowid + " and bagentuid=" + operator +
                " and agenttype = '1' and isproxydeal='1' " +
                " and ( ( (endDate = '" + TimeUtil.getCurrentDateString() + "' and (endTime='' or endTime is null))" +
                " or (endDate = '" + TimeUtil.getCurrentDateString() + "' and endTime > '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or endDate > '" + TimeUtil.getCurrentDateString() + "' or endDate = '' or endDate is null)" +
                " and ( ( (beginDate = '" + TimeUtil.getCurrentDateString() + "' and (beginTime='' or beginTime is null))" +
                " or (beginDate = '" + TimeUtil.getCurrentDateString() + "' and beginTime < '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or beginDate < '" + TimeUtil.getCurrentDateString() + "' or beginDate = '' or beginDate is null) order by agentbatch asc  ,id asc";
        rs.execute(agentCheckSql);
        //当前人员设置了代理，不再查找下一批次（离职人员设置了代理，不再向下寻找）
        if (rs.next()) {
            return true;
        }
        return false;
    }

    /**
     * 取得流程下一节点的操作者
     * 流程的操作组和批次条件判断
     * 在操作者中加入批次和条件，按批次取得操作者，上一批次无操作者则寻找下一批次操作者，上一批次有操作者则退出
     * 在每一批次取得操作者是根据设置的条件取得
     *
     * @return 是否取得成功r
     */
    public boolean getNextOperator() {
        orderflag = false;
        ArrayList operators = null;
        Hashtable tempoperatorsht = new Hashtable();
        String theorderbyordervalue = "";
        String statustr = "";
        String allUsers = "";//所有操作者id集
        Set<String> operators4e9 = new HashSet<String>();//存储所有操作者
        String src = "";
        ResourceComInfo resourceComInfo = null;
        try {
            resourceComInfo = new ResourceComInfo();
        } catch (Exception e) {
            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=resourceComInfo="+e.getMessage());
            this.recordErrMsgBySubNodeReqId("ReqNodeFlow==resourceComInfo="+e.getMessage(), requestid);
        }
        if (this.isreject == 1) {
            src = "reject";
        } else if (this.isintervenor.equals("1")) {
            src = "intervenor";
        }

        RecordSet rsTemps = new RecordSet();
        WFCoadjutantManager coadjutantmanager = new WFCoadjutantManager();
        if (nextnodetype.equals("3"))
            statustr = "0,1,2,3,5";//如果是归档节点，操作者包括为离职人员
        else
            statustr = "0,1,2,3";

        RecordSet rs1 = new RecordSet();
        RecordSet rs2 = new RecordSet();

        String thedepartmentid = "0";
        String thesubcompanyid = "0";
        String supsubcompanyid = "0";

        String crmmanager = "";

        if (creatertype == 0) {
            try {
                ResourceComInfo rc = new ResourceComInfo();
                DepartmentComInfo dc = new DepartmentComInfo();
                SubCompanyComInfo sc = new SubCompanyComInfo();
                thedepartmentid = rc.getDepartmentID("" + creater);
                if (nodetype.equals("0")) {
                    rs1.executeSql("select agentorbyagentid from workflow_currentoperator where agenttype='2' and requestid=" + requestid + " and userid=" + creater + " and usertype=" + creatertype + " and nodeid=" + nodeid);
                    if (rs1.next()) {
                        thedepartmentid = rc.getDepartmentID(rs1.getString("agentorbyagentid"));
                    }
                }
                if ("".equals(thedepartmentid)) {
                    thedepartmentid = "0";
                }
                thesubcompanyid = dc.getSubcompanyid1(thedepartmentid);

                if ("".equals(thesubcompanyid)) {
                    thesubcompanyid = "0";
                }
                supsubcompanyid = sc.getSupsubcomid(thesubcompanyid);
                if ("".equals(supsubcompanyid)) {
                    supsubcompanyid = "0";
                }

            } catch (Exception rcdc) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=creatertype="+rcdc.getMessage());
                this.recordErrMsgBySubNodeReqId("ReqNodeFlow==creatertype="+rcdc.getMessage(), requestid);
            }
        } else {
            try {
                CustomerInfoComInfo cc = new CustomerInfoComInfo();
                ResourceComInfo rc = new ResourceComInfo();
                DepartmentComInfo dc = new DepartmentComInfo();
                SubCompanyComInfo sc = new SubCompanyComInfo();

                crmmanager = cc.getCustomerInfomanager("" + creater);
                thedepartmentid = rc.getDepartmentID(crmmanager);
                if ("".equals(thedepartmentid)) {
                    thedepartmentid = "0";
                }
                thesubcompanyid = dc.getSubcompanyid1(thedepartmentid);
                if ("".equals(thesubcompanyid)) {
                    thesubcompanyid = "0";
                }
                supsubcompanyid = sc.getSupsubcomid(thesubcompanyid);
                if ("".equals(supsubcompanyid)) {
                    supsubcompanyid = "0";
                }

            } catch (Exception rcdc) {
            }
        }
        if (nextnodetype.equals("0")) {   // 回到创建节点
            OperatorInfoEntity operatorEntity = new OperatorInfoEntity();
            operatorEntity.setUserId(String.valueOf(creater));
            operatorEntity.setUserType(creatertype);
            operators = new ArrayList();
            operators.add("" + creater + "_" + creatertype + "_" + "0" + "_0");
            boolean isDimission = isDimissionPerson(operatorEntity,-1);
            tempGroupId = tempGroupId + 1;    //xwj for td3215 20051205
            tempoperatorsht.put("" + tempGroupId, operators); // xwj for td3215 20051205
            if(isDimission){
                String lastname = getLastnameByUserStatus(String.valueOf(creater));
                WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, "", "", lastname + " " + SystemEnv.getHtmlLabelName(126527, languageid), "", index, languageid);
                JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);

                try {
                    msgInfo.put("details", errorInfoMsgBuffer.toString());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                this.setMessagecontent(msgInfo.toString());
                return false;
            }
        } else if (nextnodetype.equals(NodeType.AUTOPROCESS.getValue()) || nextnodetype.equals(NodeType.WAIT.getValue())){//机器人节点
            operators = new ArrayList();
            operators.add("" + RobotNodeBiz.operatorid + "_" + RobotNodeBiz.operatortype + "_" + "0" + "_0");
            tempGroupId = tempGroupId + 1;    //xwj for td3215 20051205
            tempoperatorsht.put("" + tempGroupId, operators); // xwj for td3215 20051205
        } else {

            if (nodeattribute.equals("2") && nextnodeattribute.equals("2")) {
                rs.executeSql("select max(groupid) from workflow_currentoperator where requestid=" + this.requestid + " and nodeid=" + nodeid);
                if (rs.next()) {
                    tempGroupId = rs.getInt(1);
                }
            }
            //下一节点名称
            String nextnodename = WorkflowRequestMessage.getWorkflowNodename(nextnodeid);
            rs.executeSql("select * from workflow_nodegroup where nodeid = " + this.nextnodeid + " order by id asc"); //xwj for td2104 on 20050802
            //下一节点未设置操作组 并且非指定流转
            if (rs.getCounts() == 0 && !isSelectNextFlow) {
                WorkflowRequestMessage.getNodeErrorMsgTitle(errorInfoMsgBuffer, nextnodename, languageid);
                WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, "", "", SystemEnv.getHtmlLabelName(126545, languageid), "", index, languageid);
                JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
                try {
                    msgInfo.put("details", errorInfoMsgBuffer.toString());
                } catch (JSONException e) {
                    log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=count=e="+e.getMessage());
                    this.recordErrMsgBySubNodeReqId("ReqNodeFlow==count="+e.getMessage(), requestid);
                    //e.printStackTrace();
                }
                this.recordErrMsgBySubNodeReqId("ReqNodeFlow==节点未设置节点操作组=count="+errorInfoMsgBuffer.toString(), requestid);
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=节点未设置节点操作组=counts0="+errorInfoMsgBuffer.toString());
                this.setMessagecontent(msgInfo.toString());
                return false;
            }

            int groupnum = 0;

            //流程流转操作组日志
            Map groupsLog = new HashMap();
            requestFlowLogEntity.getOperatorLog().put("groupsLog",groupsLog);

            WorkflowRequestMessage.getNodeErrorMsgTitle(errorInfoMsgBuffer, nextnodename, languageid);
            while (rs.next()) {                       // 操作组循环
                int groupid = Util.getIntValue(rs.getString("id"), 0);
                String groupname = Util.null2String(rs.getString("groupname"));
                operators = new ArrayList();
                ArrayList tempoperators = new ArrayList();
                String orders = "-1";
                String ordernew = "-1";
                boolean hasTmpOperators = false;//同一操作组会签是否已找到操作人
                //抄送排除在外 2008.3.25 myq
                rs1.executeSql("select * from workflow_groupdetail where (signorder=0 or signorder=1 or signorder=2 or signorder='' or signorder is null) and groupid = " + groupid + " order by orders, id asc");//xwj for td2104 on 20050802
                if (rs1.getCounts() == 0) {
                    //如果有操作组未设置操作者，则先记录信息
                    WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, groupname, "", WorkflowRequestMessage.assemMsgInfo("{15808}{124955}", languageid), "", index, languageid);
                    JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
                    try {
                        msgInfo.put("details", errorInfoMsgBuffer.toString());
                    } catch (JSONException e) {
                        log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=节点未设置节点操作者=errorInfoMsg="+e.getMessage());
                        this.recordErrMsgBySubNodeReqId("ReqNodeFlow==errorInfoMsgBuffer=e="+e.getMessage(), requestid);
                        e.printStackTrace();
                    }
                    this.recordErrMsgBySubNodeReqId("ReqNodeFlow==节点未设置节点操作者=count1="+errorInfoMsgBuffer.toString(), requestid);
                    log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=节点未设置节点操作者=count10="+errorInfoMsgBuffer.toString());
                    this.setMessagecontent(msgInfo.toString());
                }

                List<Map> groupDetailLogList = new ArrayList();
                groupsLog.put("操作组:"+groupname+"("+groupid+")",groupDetailLogList);
                //消息内容
                while (rs1.next()) {                  // 某一个操作组中的多个操作者细项

                    int type = rs1.getInt("type");
                    int virtualid = Util.getIntValue(rs1.getString("virtualid"), -1);//组织维度id
                    int objid = rs1.getInt("objid");
                    int level = rs1.getInt("level_n");
                    int level2 = rs1.getInt("level2_n");
                    String jobobj = rs1.getString("jobobj");//岗位对象
                    String jobfield = rs1.getString("jobfield");//岗位级别
                    String deptField = rs1.getString("deptField");//部门自定义字段 deptField该字段存储值个格式id_fieldname_fieldlabel
                    String deptFieldFlag = "1";//1-表示是选择了'安全级别' 2-表示是选择了'部门自定义字段值'
                    String subcompanyField = rs1.getString("subcompanyField");//分部自定义字段subcompanyField该字段存储值个格式id_fieldname_fieldlabel
                    String subcompanyFieldFlag = "1";//1-表示是选择了'安全级别' 2-表示是选择了分部自定义字段值'
                    int groupdetailid = rs1.getInt("id");
                    int signorder = rs1.getInt("signorder");
                    int bhxj = rs1.getInt("bhxj");
                    String zdysqlName = Util.null2String(rs1.getString("zdysqlname"));

                    //节点操作者为人力资源字段-部门，设定安全级别条件，会签关系选择[非会签]，
                    //并且设置协办人条件，勾选"抄送协办人"，会签关系选择[会签]，协办人选择"系统设定协办人"(TD30441)
                    int signtypetmp = rs1.getInt("signtype");
                    if (signtypetmp == 1 && signorder == 0 && type == 42) signorder = 1;

                    orders = rs1.getString("orders");
                    int IsCoadjutant = Util.getIntValue(rs1.getString("IsCoadjutant"));
                    int issyscoadjutant = Util.getIntValue(rs1.getString("issyscoadjutant"));
                    int coadjutant = Util.getIntValue(rs1.getString("coadjutants"));
                    if (!isEmptyOrAllDimissionPerson(tempoperators, rs2)) {
                        hasTmpOperators = true;
                    }


                    //if ((!ordernew.equals("-1")&&!orders.equals(ordernew))&&(operators.size()>0||tempoperators.size()>0))   //在同一批次下找不到操作者才进入下一批次
                    //if ((!ordernew.equals("-1")&&!orders.equals(ordernew))&&(operators.size()>0||tempoperators.size()>0 || hasTmpOperators))   //在同一批次下找不到操作者才进入下一批次
                    if ((!ordernew.equals("-1") && !orders.equals(ordernew)) && (!isEmptyOrAllDimissionPerson(operators, rs2))) {
                        break;
                    }
                    //在每一批次必须符合条件才能取得操作者
                    String conditions = rs1.getString("conditions");
                    String conditioncn = Util.null2String(rs1.getString("conditioncn"));
                    //select * from workflow_groupdetail order by id desc(获得最新的操作批次条件)
                    //select * from formtable_main_314 where requestid=31141 and (formtable_main_314.asdfa ='E-1100 001 B' )
                    //System.out.println("流程批次条件判断的sql条件"+conditions);
                    String tempSql = "";
                    conditions = Util.StringReplace(conditions, "’", "'");
                    //-----------------------------------------------
                    // 批次条件不为空,且操作为“退回”，且操作者为：
                    // 人力资源字段本人、人力资源字段经理、人力资源字段下属、
                    // 人力资源字段本分部、人力资源字段本部门、人力资源字段上级部门
                    // 其中之一时，才进行查询Manager字段在退回节点前一个节点的值
                    // START
                    //-----------------------------------------------
                    if (!"".equals(conditions) && conditions.toLowerCase().indexOf(".manager ") != -1 && this.isreject == 1 && (type == 5 || type == 6 || type == 31 || type == 32 || type == 7 || type == 38 || type == 41)) {
                        String tmpFieldName = "";
                        String tmpFieldValue = "";
                        if (isbill == 0) {
                            rs2.executeSql("select fieldname from workflow_formdict where id =" + objid);
                        } else {
                            rs2.executeSql("select fieldname from workflow_billfield where id =" + objid);
                        }

                        if (rs2.next()) {
                            tmpFieldName = rs2.getString("fieldname");
                        }

                        if ("manager".equals(tmpFieldName)) {
                            String tempFieldValue = tmpFieldValue;
                            //当退回时，manager字段不能直接取当前的manager的值，应取退回节点之前的节点的操作人的manager
                            String tempsql = "SELECT userid FROM workflow_currentoperator " +
                                    "WHERE nodeid IN (SELECT nodeid FROM workflow_nodelink nl ,workflow_nodebase nd WHERE nd.id = nl.nodeid AND destnodeid = " + nextnodeid + " AND (nl.isreject is null or nl.isreject <> '1') and nodeid <> " + nextnodeid + ") " +
                                    "AND requestid=" + requestid + " AND preisremark=0 AND isremark=2 AND operatedate IS NOT NULL AND operatetime IS NOT NULL ORDER BY groupid DESC ";

                            RecordSet rs_manager = new RecordSet();

                            rs_manager.executeSql(tempsql);
                            int tempUserid = -1;
                            int tempManagerid = -1;
                            if (rs_manager.next()) {
                                tempUserid = Util.getIntValue(rs_manager.getString("userid"), -1);
                            }

                            if (tempUserid != -1) {
                                rs_manager.executeSql("SELECT managerid FROM HrmResource WHERE id=" + tempUserid);
                                if (rs_manager.next()) {
                                    tempManagerid = Util.getIntValue(rs_manager.getString("managerid"), -1);
                                }
                            }
                            if (tempManagerid != -1) {
                                tmpFieldValue = String.valueOf(tempManagerid);
                            }
                        }
                        //  System.out.println("***************tmpFieldValue:  "+tmpFieldValue+"******************");
                        if (type == 41) {
                            //case 41:  节点操作者经理，这边只修改了 非会签。
                            RecordSet rsTemp = new RecordSet();
                            rsTemp.execute(" select operator from workflow_requestlog where nodeid = " + nextnodeid + " and operatortype=0 and (logtype='0' or logtype='2' or logtype='3') and requestid = " + requestid);
                            if (rsTemp.next()) {
                                tmpFieldValue = rsTemp.getString("operator");
                            }

                        }
                        if (!"".equals(tmpFieldValue)) {
                            if (isbill == 0) {
                                conditions = conditions.toLowerCase().replaceAll("workflow_form.manager ", tmpFieldValue + " ");
                            } else {
                                conditions = conditions.toLowerCase().replaceAll(billtablename + ".manager ", tmpFieldValue + " ");
                            }
                        }
                    }
                    //-----------------
                    // END
                    //-----------------
                    //记录操作者批次条件日志
                    Map<String,Object> groupDetailLog = new HashMap();
                    Map ruleInfo = new HashMap();
                    groupDetailLog.put("ruleInfo",ruleInfo);
                    groupDetailLog.put("conditions",conditions);
                    groupDetailLog.put("conditioncn",conditioncn);
                    groupDetailLog.put("groupdetailid",groupdetailid);
                    groupDetailLogList.add(groupDetailLog);


                    if (this.isConformConditions(conditions, rsTemps, groupdetailid + "",ruleInfo)) {
                        if (level2 == -1) {
                            level2 = Integer.MAX_VALUE;
                        }


                        OperatorEntity operatorInfo = new OperatorEntity();
                        operatorInfo.setGroupdetailId(groupdetailid);
                        operatorInfo.setType(type);
                        operatorInfo.setSignOrder(signorder + "");
                        operatorInfo.setOrder(Util.getDoubleValue(orders, 0.00));
                        operatorInfo.setLevel(level);
                        operatorInfo.setMaxLevel(level2);
                        operatorInfo.setCondition(conditions);
                        operatorInfo.setJobObj(jobobj);
                        operatorInfo.setJobField(jobfield);
                        operatorInfo.setBhxj(bhxj + "");
                        operatorInfo.setVirtual(virtualid + "");
                        List<String> operatorTemps = new ArrayList<String>();
                        String objectId = objid + "";
                        if (objectId.indexOf(",") == -1) {
                            operatorInfo.setObjectId(Util.getIntValue(objectId));
                            operatorTemps.add(objectId);
                        } else {
                            operatorTemps.addAll(Util.TokenizerString(objectId, ","));
                        }
                        operatorInfo.setOperators(operatorTemps);
                        operatorInfo.setIsCoadjutant(IsCoadjutant);
                        operatorInfo.setIssyscoadjutant(issyscoadjutant);
                        operatorInfo.setCoadjutant(coadjutant + "");
                        operatorInfo.setNodeId(this.nodeid);
                        operatorInfo.setNextnodeid(nextnodeid);
                        operatorInfo.setPassNodes(passNodes);
                        operatorInfo.setZdysqlName(zdysqlName);
                        operatorInfo.setAutoForecast(this.autoForecast);
                        operatorInfo.setForecastManagerInfo(this.forecastManagerInfo);

                        NodeOperatorConfigBiz.getInstance().getOperatorEntity(operatorInfo, requestid, user, src, "1");

                        List<OperatorInfoEntity> operatorInfos = operatorInfo.getOperatorInfos();//操作者
                        List<OperatorInfoEntity> coadjutantInfos = operatorInfo.getCoadjutants();//协办人


                        String lastnames = "";
                        //非归档节点所有类型均过滤离职人员，归档节点只有指定人不过滤离职人员，其他均过滤
                        boolean isFilter = getIsDimissionByProp(nextnodetype, type);
                        Iterator<OperatorInfoEntity> iterator = operatorInfos.iterator();
                        while (iterator.hasNext()) {
                            OperatorInfoEntity operatorEntity = iterator.next();
                            if (isFilter) {
                                boolean isDimission = isDimissionPerson(operatorEntity,type);
                                if (isDimission) {
                                    iterator.remove();
                                }
                            }
                        }
                        //协办人离职过滤
                        Iterator<OperatorInfoEntity> iterator2 = coadjutantInfos.iterator();
                        while (iterator2.hasNext()) {
                            OperatorInfoEntity operatorEntity = iterator2.next();
                            if (isFilter) {
                                boolean isDimission = isDimissionPerson(operatorEntity,type);
                                if (isDimission) {
                                    iterator2.remove();
                                }
                            }
                        }

                        //错误消息
                        String msgcontent = "";
                        if (operatorInfos.size() == 0) {
                            msgcontent = NodeOperatorConfigBiz.getInstance().getErrorMessageContent(operatorInfo, requestid, user, isintervenor);
                            assemMsgContent4E9(groupname, orders, msgcontent);
                            continue;
                        }

                        //根据密级过滤操作者
                        this.deleteOperateBySecLevel(operatorInfos, requestid);
                        this.deleteOperateBySecLevel(coadjutantInfos, requestid);

                        //由密级过滤后无操作者的错误消息
                        if (operatorInfos.size() == 0) {
                            operatorInfo.setPassBySecLevel(true);
                            msgcontent = NodeOperatorConfigBiz.getInstance().getErrorMessageContent(operatorInfo, requestid, user, isintervenor);
                            if ("".equals(msgcontent)) {
                                msgcontent = "{500968}";
                            }
                            assemMsgContent4E9(groupname, orders, msgcontent);
                            continue;
                        }

                        if ("1".equals(operatorInfo.getSignOrder())) {//会签
                            operators = new ArrayList();
                            for (OperatorInfoEntity operatorEntity : operatorInfos) {
                                tempGroupId = tempGroupId + 1;
                                tempoperators = new ArrayList();
                                tempoperators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                operators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                operators4e9.add(operatorEntity.getUserId() + ":" + operatorEntity.getUserType());

                                //处理协办人，放在操作者之后 实际设置是只有一个协办人，当前代码兼容后续扩展多个协办人
                                if (coadjutantInfos.size() > 0 && operatorInfo.getType() == 42) {
                                    for (OperatorInfoEntity coadjutantEntrty : coadjutantInfos) {
                                        if (tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5") == -1
                                                && tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_0") == -1) {
                                            tempoperators.add("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5");
                                            operators4e9.add(coadjutantEntrty.getUserId() + ":" + coadjutantEntrty.getUserType());
                                            hasCoadjutant = true;
                                        }
                                    }
                                }

                                if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                                    tempoperatorsht.put("" + tempGroupId, tempoperators);
                                } else {
                                    tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
                                }
                            }
                        } else if ("2".equals(operatorInfo.getSignOrder()) && WFPathUtil.isContinuousProcessing(operatorInfo.getType())) {//依次逐个处理
                            tempGroupId = tempGroupId + 1;
                            tempoperators = new ArrayList();
                            orderflag = true;
                            String coadjutants = "";
                            String receivedpersons = "";
                            operators = new ArrayList();
                            if (nextnodeid != nodeid || tonextnode) {
                                if (tonextnode) {
                                    tonextnode = false;
                                }
                                Set<String> operatorSets = new HashSet<>();
                                boolean hastheoperator = false;
                                for (OperatorInfoEntity operatorEntity : operatorInfos) {
                                    if (hastheoperator) {
                                        break;
                                    }

                                    tempoperators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                    operators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                    operators4e9.add(operatorEntity.getUserId() + ":" + operatorEntity.getUserType());
                                    operatorSets.add(operatorEntity.getUserId() + ":" + operatorEntity.getUserType());


                                    //处理协办人，放在操作者之后 实际设置是只有一个协办人，当前代码兼容后续扩展多个协办人
                                    if (coadjutantInfos.size() > 0 && operatorInfo.getType() == 42) {
                                        for (OperatorInfoEntity coadjutantEntrty : coadjutantInfos) {
                                            if (tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5") == -1
                                                    && tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_0") == -1) {
                                                tempoperators.add("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5");
                                                operators4e9.add(coadjutantEntrty.getUserId() + ":" + coadjutantEntrty.getUserType());
                                                hasCoadjutant = true;
                                            }
                                        }
                                    }
                                    if (!isintervenor.equals("1")) {
                                        hastheoperator = true;
                                    }
                                }

                                if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                                    tempoperatorsht.put("" + tempGroupId, tempoperators);
                                } else {
                                    tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
                                }


                                for (OperatorInfoEntity operatorEntity : operatorInfos) {
                                    if (operatorSets.contains(operatorEntity.getUserId() + ":" + operatorEntity.getUserType())) {
                                        continue;
                                    }
                                    receivedpersons += operatorEntity.getUserId() + ",";
                                    if (coadjutantInfos.size() > 0) {//存在协办人时协办人已经被抄送过，这里不需要在保存协办人
                                        coadjutants = "";
                                    } else {
                                        coadjutants += "-1" + ",";
                                    }
                                }

                                if (!isintervenor.equals("1") && isFromSubmitConfirm != 1) {
                                    rs.executeSql("delete from workflow_agentpersons where requestid=" + requestid + " and  (groupdetailid=" + operatorInfo.getGroupdetailId() + " or groupdetailid is null)");//groupdetailid is null主要为了兼容老的数据
                                    rs.executeSql("insert into workflow_agentpersons (requestid, receivedpersons, groupdetailid,coadjutants) values (" + requestid + ",'" + receivedpersons + "'," + operatorInfo.getGroupdetailId() + ",'" + coadjutants + "')");
                                }
                            } else {//根据逻辑，不知道什么时候调用else
                                rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                boolean flags = false;
                                boolean flago = false;  //考虑老的数据
                                if (rs.next()) flags = true;
                                if (!flags) {
                                    rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                                    if (rs.next()) flago = true;
                                }
                                if (flags || flago) {
                                    receivedpersons = rs.getString("receivedPersons");
                                    coadjutants = Util.null2String(rs.getString("coadjutants"));
                                    if (!"".equals(receivedpersons)) {
                                        tempoperators.add("" + receivedpersons.substring(0, receivedpersons.indexOf(",")) + "_0" + "_" + groupdetailid + "_0");
                                        int idx = coadjutants.indexOf(",");
                                        if (idx > 0) {
                                            int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                                            if (tempcoadjutant > 0 && tempoperators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5") == -1 && tempoperators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_0") == -1) {
                                                tempoperators.add("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5");
                                                hasCoadjutant = true;
                                            }
                                        }
                                        if (flago)
                                            rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivedpersons.substring(receivedpersons.indexOf(",") + 1, receivedpersons.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                        else if (flags)
                                            rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivedpersons.substring(receivedpersons.indexOf(",") + 1, receivedpersons.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                    }

                                }
                            }
                        } else {//非会签
                            tempGroupId = tempGroupId + 1;
                            tempoperators = new ArrayList();
                            operators = new ArrayList();
                            for (OperatorInfoEntity operatorEntity : operatorInfos) {
                                tempoperators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                operators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_0");
                                operators4e9.add(operatorEntity.getUserId() + ":" + operatorEntity.getUserType());
                            }

                            //处理协办人，放在操作者之后 实际设置是只有一个协办人，当前代码兼容后续扩展多个协办人
                            if (coadjutantInfos.size() > 0 && operatorInfo.getType() == 42) {
                                for (OperatorInfoEntity coadjutantEntrty : coadjutantInfos) {
                                    if (tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5") == -1
                                            && tempoperators.indexOf("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_0") == -1) {
                                        tempoperators.add("" + coadjutantEntrty.getUserId() + "_" + coadjutantEntrty.getUserType() + "_" + groupdetailid + "_-5");
                                        operators4e9.add(coadjutantEntrty.getUserId() + ":" + coadjutantEntrty.getUserType());
                                        hasCoadjutant = true;
                                    }
                                }
                            }
                            //if(!nextnodeattribute.equals("2")||!nodeattribute.equals("2"))  这一块排除了当前节点和下一个节点都是分叉中间点的情况。xwz qc50563
                            if (tempoperators.size() > 0) {
                                if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                                    tempoperatorsht.put("" + tempGroupId, tempoperators);
                                } else {
                                    tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
                                }
                            }
                        }


                        if (StringUtil.isNotNull(lastnames)) {
                            msgcontent = getOperatorNotWorkingInfo(type, objid, lastnames, groupdetailid);
                            if (StringUtil.isNotNull(msgcontent)) {
                                WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, groupname, orders, msgcontent, "", index, languageid);
                                JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
                                try {
                                    msgInfo.put("details", errorInfoMsgBuffer.toString());
                                } catch (JSONException e) {
                                    log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=操作者不在职=3323e="+e.getMessage());
                                    this.recordErrMsgBySubNodeReqId("ReqNodeFlow==操作者不在职=e="+e.getMessage(), requestid);
                                    //e.printStackTrace();
                                }
                                this.recordErrMsgBySubNodeReqId("ReqNodeFlow==操作者不在职=="+ errorInfoMsgBuffer.toString(), requestid);
                                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=操作者不在职=status5="+ errorInfoMsgBuffer.toString());
                                this.setMessagecontent(msgInfo.toString());
                            }
                        }
                    } else {
                        //如果条件不合格把条件列出来
                        JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);

                        //if("".equals(conditioncn)) {
                        conditioncn = RuleBusiness.getConditionCn(groupdetailid, 2, user);
                        //}

                        WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, groupname, orders, "", conditioncn, index, languageid);
                        index++;
                        try {
                            msgInfo.put("details", errorInfoMsgBuffer.toString());
                        } catch (JSONException e) {
                            this.recordErrMsgBySubNodeReqId("ReqNodeFlow==条件不满足=e="+e.getMessage(), requestid);
                            log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=条件不满足=e="+e.getMessage());
                            e.printStackTrace();
                        }
                        this.recordErrMsgBySubNodeReqId("ReqNodeFlow==条件不满足=condition="+errorInfoMsgBuffer.toString(), requestid);
                        log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=条件不满足=condition="+errorInfoMsgBuffer.toString());
                        this.setMessagecontent(msgInfo.toString());

                    }
                    ordernew = orders;
                }       // 每一个操作组中的细项结束循环
                //if(!nextnodeattribute.equals("2")||!nodeattribute.equals("2"))  这一块排除了当前节点和下一个节点都是分叉中间点的情况。xwz qc50563
            }           // 操作组讯息结束

        }

        /*---- xwj for td2104 on 20050802   E N D---*/
        //全部为离职人员且开启异常处理，则去掉离职人员操作者,走异常处理
        //if(flowExceptionHandle.hasSettingException(workflowid, nextnodeid)){
//			Iterator<Map.Entry<String, Object>> tempit = tempoperatorsht.entrySet().iterator();
//			while(tempit.hasNext()){
//				Map.Entry<String, Object> entry = tempit.next();
//				if(isEmptyOrAllDimissionPerson((List<String>) entry.getValue(), rs2))
//					tempit.remove();
//			}
        //}
        log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"operator tempoperatorsht"+tempoperatorsht);
        // 指定流转，不需要计算操作者
        //如果是开启了指定流转且是提交至退回节点的情况，操作组为空的话也返回false，直接走指定流转的异常处理
        if (tempoperatorsht.isEmpty() && (!isSelectNextFlow || SubmitToNodeid > 0))
            return false;
        else {
            //已经匹配的操作者，删除错误信息
            if (!"".equals(this.getMessageid())) {
                this.setMessageid("");
                this.setMessagecontent("");
            }

            if (!nextnodetype.equals("0")&&!(nextnodetype.equals(NodeType.AUTOPROCESS.getValue()) || nextnodetype.equals(NodeType.WAIT.getValue()))) {
                RecordSet rs3 = new RecordSet();
                RecordSet rs4 = new RecordSet();

                rs.executeSql("select * from workflow_nodegroup where nodeid = " + this.nextnodeid + " order by id asc");
                while (rs.next()) {//操作组循环
                    int groupid = Util.getIntValue(rs.getString("id"), 0);
                    //抄送处理
                    rs3.executeSql("select * from workflow_groupdetail where (signorder=4 or signorder=3) and groupid = " + groupid + " order by signorder desc,id asc");
                    while (rs3.next()) {//操作组中的多个操作者细项
                        int type = rs3.getInt("type");
                        int virtualid = Util.getIntValue(rs3.getString("virtualid"), -1);
                        int objid = rs3.getInt("objid");
                        int groupdetailid = rs3.getInt("id");
                        int level = rs3.getInt("level_n");
                        int level2 = rs3.getInt("level2_n");
                        String jobobj = rs3.getString("jobobj");//岗位对象
                        String jobfield = rs3.getString("jobfield");//岗位级别
                        String deptField = rs3.getString("deptField");//部门自定义字段 deptField该字段存储值个格式id_fieldname_fieldlabel
                        String subcompanyField = rs3.getString("subcompanyField");//分部自定义字段subcompanyField该字段存储值个格式id_fieldname_fieldlabel
                        int signorder = rs3.getInt("signorder");
                        int bhxj = rs3.getInt("bhxj");
                        int IsCoadjutant = Util.getIntValue(rs3.getString("IsCoadjutant"));
                        int issyscoadjutant = Util.getIntValue(rs3.getString("issyscoadjutant"));
                        int coadjutant = Util.getIntValue(rs3.getString("coadjutants"));
                        String zdysqlName = Util.null2String(rs3.getString("zdysqlname"));

                        //必须符合条件才能取得操作者
                        String conditions = rs3.getString("conditions");
                        String tempSql = "";
                        conditions = Util.StringReplace(conditions, "’", "'");
                        //抄送批次条件暂时不记录。
                        if (this.isConformConditions(conditions, rs4, groupdetailid + "",new HashMap<>())) {
                            if (level2 == -1) {
                                level2 = Integer.MAX_VALUE;
                            }

                            OperatorEntity operatorInfo = new OperatorEntity();
                            operatorInfo.setGroupdetailId(groupdetailid);
                            operatorInfo.setType(type);
                            operatorInfo.setSignOrder(signorder + "");
//							operatorInfo.setOrder(Util.getDoubleValue(orders,0.00));
                            operatorInfo.setLevel(level);
                            operatorInfo.setMaxLevel(level2);
                            operatorInfo.setCondition(conditions);
                            operatorInfo.setJobObj(jobobj);
                            operatorInfo.setJobField(jobfield);
                            operatorInfo.setBhxj(bhxj + "");
                            operatorInfo.setVirtual(virtualid + "");
                            List<String> operatorTemps = new ArrayList<String>();
                            String objectId = objid + "";
                            if (objectId.indexOf(",") == -1) {
                                operatorInfo.setObjectId(Util.getIntValue(objectId));
                                operatorTemps.add(objectId);
                            } else {
                                operatorTemps.addAll(Util.TokenizerString(objectId, ","));
                            }
                            operatorInfo.setOperators(operatorTemps);
                            operatorInfo.setIsCoadjutant(IsCoadjutant);
                            operatorInfo.setIssyscoadjutant(issyscoadjutant);
                            operatorInfo.setCoadjutant(coadjutant + "");
                            operatorInfo.setNodeId(this.nodeid);
                            operatorInfo.setNextnodeid(nextnodeid);
                            operatorInfo.setPassNodes(passNodes);
                            operatorInfo.setZdysqlName(zdysqlName);

                            NodeOperatorConfigBiz.getInstance().getOperatorEntity(operatorInfo, requestid, user, src, "1");

                            List<OperatorInfoEntity> operatorInfos = operatorInfo.getOperatorInfos();


                            //非归档节点所有类型均过滤离职人员，归档节点只有指定人不过滤离职人员，其他均过滤
                            boolean isFilter = getIsDimissionByProp(nextnodetype, type);
                            Iterator<OperatorInfoEntity> iterator = operatorInfos.iterator();
                            while (iterator.hasNext()) {
                                OperatorInfoEntity operatorEntity = iterator.next();
                                if (isFilter) {
                                    boolean isDimission = isDimissionPerson(operatorEntity,type);
                                    if (isDimission) {
                                        iterator.remove();
                                    }
                                }
                            }

                            //根据密级过滤操作者
                            this.deleteOperateBySecLevel(operatorInfos, requestid);

                            for (OperatorInfoEntity operatorEntity : operatorInfos) {
                                if (operators4e9.contains(operatorEntity.getUserId() + ":" + operatorEntity.getUserType())) {
                                    continue;
                                }
                                tempGroupId = tempGroupId + 1;
                                ArrayList tempoperators = new ArrayList();
                                tempoperators.add("" + operatorEntity.getUserId() + "_" + operatorEntity.getUserType() + "_" + operatorInfo.getGroupdetailId() + "_-" + operatorInfo.getSignOrder());
                                if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                                    tempoperatorsht.put("" + tempGroupId, tempoperators);
                                } else {
                                    tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
                                }
                            }
                        }
                    }
                }
            }
            operatorsht = tempoperatorsht;
            return true;
        }
    }

    private String assemMsgContent(String groupname, String orders, int type, int virtualid, int objid, int level, int level2, String deptField, String subcompanyField, int groupdetailid, int signorder, int bhxj, String msgcontent) {
        try {
            msgcontent = this.getErrorMessageContent(type, nextnodetype, signorder, virtualid, languageid, objid, bhxj, level, groupdetailid, level2, deptField, subcompanyField);
            WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, groupname, orders, msgcontent, "", index, languageid);
            JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
            msgInfo.put("details", errorInfoMsgBuffer.toString());
            this.setMessagecontent(msgInfo.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return msgcontent;
    }

    /**
     * 操作组错误提示消息 E9
     *
     * @param groupname
     * @param orders
     * @param msgcontent
     * @return
     */
    private String assemMsgContent4E9(String groupname, String orders, String msgcontent) {
        if ("".equals(msgcontent)) {
            msgcontent = "{127306}";
        }

        msgcontent = WorkflowRequestMessage.assemMsgInfo(msgcontent, languageid);
        try {
            if (assemMsgContentCount > 100) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+" ---line2892--userid:" + userid + ",nodeid:" + nodeid + ",groupname:" + groupname);
                return "";
            }
            assemMsgContentCount++;

            WorkflowRequestMessage.getDetailInfomx(errorInfoMsgBuffer, groupname, orders, msgcontent, "", index, languageid);
            JSONObject msgInfo = WorkflowRequestMessage.getBottomInfo(SystemEnv.getHtmlLabelName(126540, languageid), workflowid, WorkflowRequestMessage.WF_NODE_SET);
            msgInfo.put("details", errorInfoMsgBuffer.toString());
            this.setMessagecontent(msgInfo.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return msgcontent;
    }

    /**
     * 流转异常处理，由用户指定操作者，计算下一节点操作者
     * 参考getNextOperator(),模拟表单多人力资源字段type=5，非会签/会签/依次逐个处理
     */
    public boolean getNextOperatorByAssignUser(String eh_relationship, String eh_operators) throws Exception {
        if ("".equals(eh_relationship) || "".equals(eh_operators))
            return false;

        try {//记录下会签关系，以便转办多人时取到会签关系
            String insertsql = "insert into workflow_requestselectnextflow(requestid,nodeid,destnodeid,signtype,flowoperator)values(?,?,?,?,?)";
            rst.executeUpdate(insertsql, requestid, nodeid, nextnodeid, eh_relationship, eh_operators);
        }catch (Exception e ){
            e.printStackTrace();
        }

        int temp_groupdetailid = 0;    //模拟生成groupid,不能<0，WfForceDrawBack.java强制收回需要判断groupdetailid>-1
        ArrayList operators = new ArrayList();
        Hashtable tempoperatorsht = new Hashtable();
        if (nodeattribute.equals("2") && nextnodeattribute.equals("2")) {
            rs.executeSql("select max(abs(groupid)) from workflow_currentoperator where requestid=" + this.requestid + " and nodeid=" + nodeid);
            if (rs.next()) {
                tempGroupId = rs.getInt(1);
            }
        }
        String statustr = "";
        if (nextnodetype.equals("3")) {
            statustr = "0,1,2,3,5";//如果是归档节点，操作者包括为离职人员
        } else {
            statustr = "0,1,2,3";
        }
        String strSubClause = Util.getSubINClause(eh_operators, "id", "IN");
        String sql = " select loginid,id from HrmResource where " + strSubClause + " and status in (" + statustr + ") " +
                "union select loginid,id from HrmResourceManager where " + strSubClause + " and status in (" + statustr + ") ";
        RecordSet rs2 = new RecordSet();
        rs2.executeSql(sql);
        if ("0".equals(eh_relationship)) {        //非会签
            while (rs2.next()) {
                int tepoperatorid = Util.getIntValue(rs2.getString("id"), 0);
                operators.add("" + tepoperatorid + "_0" + "_" + temp_groupdetailid + "_0");
            }
        } else if ("1".equals(eh_relationship)) {    //会签
            MultiHrmCompositorOrderBean orderBean = null;
            ArrayList tempoperators = new ArrayList();
            ArrayList orderList = new ArrayList();
            String[] hrmStrs = getHrmStrs(5, 1, eh_operators);
            while (rs2.next()) {
                int tepoperatorid = Util.getIntValue(rs2.getString("id"), 0);
                for (int i = 0; i < hrmStrs.length; i++) {
                    if (tepoperatorid == Integer.parseInt(hrmStrs[i])) {
                        orderBean = new MultiHrmCompositorOrderBean();
                        orderBean.setCompositorOrder(i);
                        orderBean.setHrmId(String.valueOf(tepoperatorid));
                        orderList.add(orderBean);
                    }
                }
            }
            Collections.sort(orderList, new MultiHrmCompositorOrderComparator());
            for (int i = 0; i < orderList.size(); i++) {
                orderBean = (MultiHrmCompositorOrderBean) orderList.get(i);
                tempGroupId = tempGroupId + 1;
                tempoperators = new ArrayList();
                tempoperators.add("" + orderBean.getHrmId() + "_0" + "_" + temp_groupdetailid + "_0");
                if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                    tempoperatorsht.put("" + tempGroupId, tempoperators);
                } else {
                    tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
                }
            }
        } else if ("2".equals(eh_relationship)) {    //依次逐个处理
            tempGroupId = tempGroupId + 1;
            ArrayList tempoperators = new ArrayList();
            orderflag = true;
            RecordSet rs = new RecordSet();
            boolean hastheoperator = false;
            String theorderbyordervalues[] = Util.TokenizerString2(eh_operators, ",");
            //协办人coadjutants统一插入空
            if (theorderbyordervalues != null) {
                for (int i = 0; i < theorderbyordervalues.length; i++) {
                    if (hastheoperator) break;
                    int tepoperatorid = Util.getIntValue(theorderbyordervalues[i], 0);
                    if (tepoperatorid != 0) {
                        if (nextnodeid != nodeid) {
                            //模拟插入workflow_groupdetail
                            int temp_operatorgroup = -2;
                            rst.executeProc("workflow_groupdetail_Insert", "" + temp_operatorgroup + flag + 5 + flag + temp_operatorgroup + flag + 0 + flag + -1 + flag + "" + flag + "" + flag + 0 + flag + 2 + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "" + flag + "");
                            if (rst.next()) {
                                temp_groupdetailid = rst.getInt(1);
                            }

                            tempoperators.add("" + tepoperatorid + "_0" + "_" + temp_groupdetailid + "_0");
                            hastheoperator = true;
                            String tempStr = "";
                            for (int k = i + 1; k < theorderbyordervalues.length; k++) {
                                tempStr += theorderbyordervalues[k] + ",";
                            }
                            rs.executeSql("delete from workflow_agentpersons where requestid=" + requestid + " and  (groupdetailid=" + temp_groupdetailid + " or groupdetailid is null)");//groupdetailid is null主要为了兼容老的数据
                            rs.executeSql("insert into workflow_agentpersons (requestid, receivedpersons, groupdetailid,coadjutants) values (" + requestid + ",'" + tempStr.trim() + "'," + temp_groupdetailid + ",'')");
                        } /*else {		//liuzy先注释，不清楚什么时候调用else
							rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid+" and groupdetailid="+temp_groupdetailid);
							boolean flags=false;
							boolean flago=false;  //考虑老的数据
							if (rs.next())
								flags=true;
							if (!flags){
								rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
							    if (rs.next())
							    	flago=true;
							}
							if(flags||flago){
								String receivePersions = rs.getString("receivedPersons");
								if(!"".equals(receivePersions)){
									tempoperators.add("" + receivePersions.substring(0,receivePersions.indexOf(",")) + "_0"+"_"+temp_groupdetailid+ "_0");
									hastheoperator = true;
									if (flago)
										rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",")+1,receivePersions.length()) + "',coadjutants='' where requestid = " + requestid);
									else if (flags)
										rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",")+1,receivePersions.length()) + "',coadjutants='' where requestid = " + requestid+" and groupdetailid="+temp_groupdetailid);
								}
							}
						}*/
                    }
                }
            }
            if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                tempoperatorsht.put("" + tempGroupId, tempoperators);
            } else {
                tempoperatorsht.put("" + tempGroupId * -1, tempoperators);
            }
        }
        if (operators.size() > 0) {
            tempGroupId = tempGroupId + 1;
            tempoperatorsht.put("" + tempGroupId, operators);
        }
        if (tempoperatorsht.isEmpty())
            return false;
        else {
            operatorsht = tempoperatorsht;
            return true;
        }
    }

    private boolean getCurrentNodeType() {
        rs.executeSql("select a.* from workflow_groupdetail a , workflow_nodegroup b " +
                " where a.groupid = b.id and b.nodeid = " + this.nodeid);
        while (rs.next()) {                       // 操作组循环
            int type = rs.getInt("type");
            int level = rs.getInt("level_n");
            int signorder = rs.getInt("signorder");

            if (WFPathUtil.isContinuousProcessing(type) && signorder == 2) {
                rs.executeSql("select status from workflow_requestbase where requestid = " + requestid);
                if (rs.next()) linkname = Util.null2String(rs.getString("status"));
                return true;
            }
        }

        return false;
    }

    /*------added by xwj for td2104 on 20050801  B E G I N -------*/
    private String[] getHrmStrs(int type, int level, String str) {
        String[] tempStrs = null;
        if ((type == 5 || type == 43) && (level == 1 || level == 3 || level == 4)) {
            tempStrs = Util.TokenizerString2(str, ",");
        }
        return tempStrs;
    }

    /**
     * 定义按orderKey排序人员
     *
     * @param sql      取得人员的SQL
     * @param orderKey 排序依据
     * @return
     */
    private ArrayList roleOrderOperate(String sql, String orderKey) {
        MultiHrmCompositorOrderBean orderBean = null;
        ArrayList orderList = new ArrayList();
        ArrayList orderList_ = null;
        String[] roleidStrs = getHrmStrs(43, 1, orderKey);
        RecordSet rs = new RecordSet();
        rs.executeSql(sql);
        if (rs.getCounts() != 0) {
            while (rs.next()) {
                int roleid = Util.getIntValue(rs.getString("roleid"), 0);
                for (int i = 0; i < roleidStrs.length; i++) {
                    if (roleid == Integer.parseInt(roleidStrs[i])) {
                        orderBean = new MultiHrmCompositorOrderBean();
                        orderBean.setCompositorOrder(i);
                        orderBean.setHrmId(rs.getString("id"));
                        orderList.add(orderBean);
                    }
                }
            }
            Collections.sort(orderList, new MultiHrmCompositorOrderComparator());
            orderList_ = orderList;
        } else {
            orderList_ = new ArrayList();
        }
        return orderList_;

    }

    //定义按姓名拼音首字符排序

    //deleted by xwj for td2461 20051111

    /*------added by xwj for td2104 on 20050801  E N D -------*/

    /**
     * 获取自由流程的下一节点操作人
     *
     * @return
     */
    public boolean FreeWorkflowNextoperator() {
        ArrayList Freeoperatorlist = Util.TokenizerString(Freeoperators, ",");
        Hashtable tempoperatorsht = new Hashtable();
        if (Freeoperatorlist.size() > 0) {
            rs.executeProc("workflow_NodeType_Select", "" + workflowid + flag + nextnodeid);
            if (rs.next())
                nextnodetype = Util.null2String(rs.getString(1));
            else {
                JSONObject msgjson = new JSONObject();
                try {
                    msgjson.put("details", SystemEnv.getHtmlLabelName(126551, languageid));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                this.setMessagecontent(msgjson.toString());
                return false;
            }

            WFManager wfManager = new WFManager();
            wfManager.setWfid(workflowid);

            try {
                wfManager.getWfInfo();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            String isFree = wfManager.getIsFree();
            String freewftype = wfManager.getFreewftype();   //自由流程的模式，1：简易模式，2：高级模式

            rs.executeSql("select nodeattribute,passnum from workflow_nodebase where id=" + nextnodeid);
            if (rs.next()) {
                this.nextnodeattribute = Util.null2String(rs.getString("nodeattribute"));
                this.passnum = rs.getInt("passnum");
            }
            if (nodeattribute.equals("2") && nextnodeattribute.equals("2")) {
                rs.executeSql("select max(groupid) from workflow_currentoperator where requestid=" + this.requestid + " and nodeid=" + nodeid);
                if (rs.next()) {
                    tempGroupId = rs.getInt(1);
                }
            }
            int groupdetailid = 0;
            sql = "select id from workflow_groupdetail where groupid in(select id from workflow_nodegroup where nodeid=" + nextnodeid + ") order by orders, id";
            rs.executeSql(sql);
            if (rs.next()) {
                groupdetailid = rs.getInt(1);
            }
            sql = "select * from workflow_NodeLink where nodeid=" + nodeid + " and destnodeid=" + nextnodeid + " order by nodepasstime ,id";
            rs.executeSql(sql);
            String lastnames = "";
            if (rs.getCounts() > 0 || this.SubmitToNodeid > 0) {
                if (rs.next()) {
                    nextlinkid = rs.getInt("id");
                    nextlinkname = Util.null2String(rs.getString("linkname"));
                    ismustpasss = Util.null2String(rs.getString("ismustpass"));
                } else {
                    nextlinkid = -1;
                    ismustpasss = "";
                    rs.executeSql("select nodename from workflow_nodebase where id=" + SubmitToNodeid);
                    if (rs.next()) {
                        nextlinkname = Util.null2String(rs.getString("nodename"));
                    } else {
                        nextlinkname = "";
                    }
                }
                if (FreeSigntype == 0) {//非会签
                    tempGroupId = tempGroupId + 1;
                    ArrayList operators = new ArrayList();
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        //验证用户是否离职
                        String lastname = getLastnameByUserStatus(String.valueOf(Freeoperatorlist.get(i)));
                        if (StringUtil.isNotNull(lastname)) {
                            lastnames += lastname + "，";
                        }
                        operators.add(Freeoperatorlist.get(i) + "_0_" + groupdetailid + "_0");
                    }
                    if (operators.size() > 0) {
                        tempoperatorsht.put("" + tempGroupId, operators);
                    }
                } else if (FreeSigntype == 1) {//会签
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        ArrayList operators = new ArrayList();
                        //验证用户是否离职
                        String lastname = getLastnameByUserStatus(String.valueOf(Freeoperatorlist.get(i)));
                        if (StringUtil.isNotNull(lastname)) {
                            lastnames += lastname + "，";
                        }

                        operators.add(Freeoperatorlist.get(i) + "_0_" + groupdetailid + "_0");
                        tempGroupId = tempGroupId + 1;
                        if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                            tempoperatorsht.put("" + tempGroupId, operators);
                        } else {
                            tempoperatorsht.put("" + tempGroupId * -1, operators);
                        }
                    }
                } else if (FreeSigntype == 2) {//逐个处理
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        ArrayList operators = new ArrayList();
                        if (nextnodeid != nodeid) {
                            //验证用户是否离职
                            String lastname = getLastnameByUserStatus(String.valueOf(Freeoperatorlist.get(i)));
                            if (StringUtil.isNotNull(lastname)) {
                                lastnames += lastname + "，";
                            }

                            operators.add("" + Freeoperatorlist.get(i) + "_0" + "_" + groupdetailid + "_0");
                            String tempStr = "";
                            for (int k = i + 1; k < Freeoperatorlist.size(); k++) {
                                tempStr += Freeoperatorlist.get(k) + ",";
                            }
                            rs.executeSql("delete from workflow_agentpersons where requestid=" + requestid + " and  (groupdetailid=" + groupdetailid + " or groupdetailid is null)");//groupdetailid is null主要为了兼容老的数据
                            rs.executeSql("insert into workflow_agentpersons (requestid, receivedpersons, groupdetailid,coadjutants) values (" + requestid + ",'" + tempStr.trim() + "'," + groupdetailid + ",'')");
                            if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2"))
                                tempGroupId = tempGroupId + 1;
                            tempoperatorsht.put("" + tempGroupId, operators);
                            break;
                        } else {
                            rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                            boolean flags = false;
                            boolean flago = false;  //考虑老的数据
                            if (rs.next()) flags = true;
                            if (!flags) {
                                rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                                if (rs.next()) flago = true;
                            }
                            if (flags || flago) {
                                String receivePersions = rs.getString("receivedPersons");
                                String coadjutants = Util.null2String(rs.getString("coadjutants"));
                                if (!"".equals(receivePersions)) {
                                    String nextoperator = receivePersions.substring(0, receivePersions.indexOf(","));
                                    String lastname = getLastnameByUserStatus(nextoperator);
                                    addWfInterventionMsg(nextoperator);

                                    operators.add("" + nextoperator + "_0" + "_" + groupdetailid + "_0");
                                    int idx = coadjutants.indexOf(",");
                                    if (idx > 0) {
                                        int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                                        if (tempcoadjutant > 0 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5") == -1 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_0") == -1) {
                                            operators.add("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5");
                                            hasCoadjutant = true;
                                        }
                                    }
                                    if (flago)
                                        rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                    else if (flags)
                                        rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                    if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2"))
                                        tempGroupId = tempGroupId + 1;
                                    tempoperatorsht.put("" + tempGroupId, operators);
                                    break;
                                }
                            }
                        }
                    }
                }
                if (tempoperatorsht.isEmpty()) {
                    int isroutedit = getFreeNodeIsroutedit();
                    if ("0".equals(nodetype)) {
                        isroutedit = 2;
                    }
                    String attr = "";
                    if (isroutedit > 1) {
                        attr = "，" + SystemEnv.getHtmlLabelName(126549, languageid) + WorkflowRequestMessage.getBoldDetailInfo(SystemEnv.getHtmlLabelName(21781, languageid)) + SystemEnv.getHtmlLabelName(126550, languageid);
                    }
                    String messageInfo = SystemEnv.getHtmlLabelName(126548, languageid) + attr;
                    if (StringUtil.isNotNull(lastnames)) {
                        lastnames = lastnames.substring(0, lastnames.length() - 1);
                        messageInfo = SystemEnv.getHtmlLabelName(124958, languageid) + WorkflowRequestMessage.getBoldDetailInfo(lastnames) + SystemEnv.getHtmlLabelName(126527, languageid) + attr;
                    }
                    JSONObject msgInfo = null;
                    if ("0".equals(nodetype) || isroutedit > 1) {
                        msgInfo = new JSONObject();
                        try {
                            msgInfo.put("details", messageInfo);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    } else {
                        msgInfo = WorkflowRequestMessage.getBottomInfo(messageInfo, requestid, WorkflowRequestMessage.WF_INVERVENTION);
                    }
                    this.setMessagecontent(msgInfo.toString());
                    return false;
                }

                operatorsht = tempoperatorsht;
                return true;
            }
            if (isreject == 1) {//自由流程退回
                nextlinkid = 0;
                nextlinkname = "退回";
                ismustpasss = "";
                if (FreeSigntype == 0) {//非会签
                    tempGroupId = tempGroupId + 1;
                    ArrayList operators = new ArrayList();
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        operators.add(Freeoperatorlist.get(i) + "_0_" + groupdetailid + "_0");
                    }
                    tempoperatorsht.put("" + tempGroupId, operators);
                } else if (FreeSigntype == 1) {//会签
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        ArrayList operators = new ArrayList();
                        operators.add(Freeoperatorlist.get(i) + "_0_" + groupdetailid + "_0");
                        tempGroupId = tempGroupId + 1;
                        if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                            tempoperatorsht.put("" + tempGroupId, operators);
                        } else {
                            tempoperatorsht.put("" + tempGroupId * -1, operators);
                        }
                    }
                } else if (FreeSigntype == 2) {//逐个处理
                    for (int i = 0; i < Freeoperatorlist.size(); i++) {
                        ArrayList operators = new ArrayList();
                        if (nextnodeid != nodeid) {
                            operators.add("" + Freeoperatorlist.get(i) + "_0" + "_" + groupdetailid + "_0");
                            String tempStr = "";
                            for (int k = i + 1; k < Freeoperatorlist.size(); k++) {
                                tempStr += Freeoperatorlist.get(k) + ",";
                            }
                            rs.executeSql("delete from workflow_agentpersons where requestid=" + requestid + " and  (groupdetailid=" + groupdetailid + " or groupdetailid is null)");//groupdetailid is null主要为了兼容老的数据
                            rs.executeSql("insert into workflow_agentpersons (requestid, receivedpersons, groupdetailid,coadjutants) values (" + requestid + ",'" + tempStr.trim() + "'," + groupdetailid + ",'')");
                            if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2"))
                                tempGroupId = tempGroupId + 1;
                            tempoperatorsht.put("" + tempGroupId, operators);
                            break;
                        } else {
                            rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                            boolean flags = false;
                            boolean flago = false;  //考虑老的数据
                            if (rs.next()) flags = true;
                            if (!flags) {
                                rs.executeSql("select * from workflow_agentpersons where requestid = " + requestid);  //考虑以前的数据加上该判断
                                if (rs.next()) flago = true;
                            }
                            if (flags || flago) {
                                String receivePersions = rs.getString("receivedPersons");
                                String coadjutants = Util.null2String(rs.getString("coadjutants"));
                                if ("1".equals(isFree) && "1".equals(freewftype)) {   //简易模式，退回到同一节点的上一操作者
                                    FreeWorkflowSimple freeWorkflowSimple = new FreeWorkflowSimple();
                                    String tempuser = freeWorkflowSimple.getRejectUserId(requestid, nextnodeid, userid, usertype);
                                    operators.add(tempuser + "_0_" + groupdetailid + "_0");

                                    String receivePersions2 = "";
                                    if (!"".equals(receivePersions)) {
                                        receivePersions2 = userid + "," + receivePersions + ",";
                                    } else {
                                        receivePersions2 = String.valueOf(userid) + ",";
                                    }

                                    String coadjutants2 = "";
                                    if (!"".equals(coadjutants)) {
                                        coadjutants2 = "-1," + coadjutants;
                                    } else {
                                        coadjutants2 = "-1";
                                    }

                                    if (flago) {
                                        rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions2 + "',coadjutants='" + coadjutants2 + "' where requestid = " + requestid);
                                    } else if (flags) {
                                        rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions2 + "',coadjutants='" + coadjutants2 + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                    }
                                    if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2")) {
                                        tempGroupId = tempGroupId + 1;
                                    }
                                    tempoperatorsht.put("" + tempGroupId, operators);
                                    break;
                                } else {
                                    //自由流程，高级模式
                                    if (!"".equals(receivePersions)) {
                                        operators.add("" + receivePersions.substring(0, receivePersions.indexOf(",")) + "_0" + "_" + groupdetailid + "_0");
                                        int idx = coadjutants.indexOf(",");
                                        if (idx > 0) {
                                            int tempcoadjutant = Util.getIntValue(coadjutants.substring(0, idx));
                                            if (tempcoadjutant > 0 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5") == -1 && operators.indexOf("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_0") == -1) {
                                                operators.add("" + tempcoadjutant + "_0" + "_" + groupdetailid + "_-5");
                                            }
                                        }
                                        if (flago)
                                            rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid);
                                        else if (flags)
                                            rs.executeSql("update workflow_agentpersons set receivedPersons = '" + receivePersions.substring(receivePersions.indexOf(",") + 1, receivePersions.length()) + "',coadjutants='" + coadjutants.substring(idx + 1, coadjutants.length()) + "' where requestid = " + requestid + " and groupdetailid=" + groupdetailid);
                                        if (!nextnodeattribute.equals("2") || !nodeattribute.equals("2"))
                                            tempGroupId = tempGroupId + 1;
                                        tempoperatorsht.put("" + tempGroupId, operators);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                operatorsht = tempoperatorsht;
                return true;
            }
        }
        return false;
    }

    private int getFreeNodeIsroutedit() {
        RecordSet temprs = new RecordSet();
        temprs.executeQuery("select isroutedit from workflow_freeright where nodeid = ?", nodeid);
        if (temprs.next()) {
            return Util.getIntValue(temprs.getString("isroutedit"), 0);
        }
        return 0;
    }

    /**
     * 获取退回节点Manager的值
     *
     * @param requestid  流程id
     * @param nextnodeid 退回的节点
     * @return
     */
    private String getRjtNodeMgrVal(int requestid, int nextnodeid) {
        String mgrVal = "-1";
        //操作日期
        String tempoperatedate = "";
        //操作时间
        String tempoperatetime = "";
        //操作者id
        int tempUserid = -1;
        //操作者上级
        int tempManagerid = -1;
        //操作组（会签不相同，飞会签相同）
        int tempGroupId = -1;
        //查询退回节点的前一个节点的操作人
        String tempsql = "select userid, operatedate, operatetime from workflow_currentoperator " +
                "where nodeid in (select nodeid from workflow_nodelink nl ,workflow_nodebase nd where nd.id = nl.nodeid and destnodeid = " + nextnodeid + " AND (nl.isreject is null or nl.isreject <> '1') and nodeid <> " + nextnodeid + ") " +
                "and requestid=" + requestid + " and preisremark=0 AND isremark=2 and operatedate is not null and operatetime is not null order by operatedate, operatetime, groupid desc ";

        RecordSet rs_manager = new RecordSet();

        rs_manager.executeSql(tempsql);

        if (rs_manager.next()) {
            tempUserid = Util.getIntValue(rs_manager.getString("userid"), -1);
            tempoperatedate = Util.null2String(rs_manager.getString("operatedate"));
            tempoperatetime = Util.null2String(rs_manager.getString("operatetime"));
        }

        if (tempUserid != -1) {
            rs_manager.executeSql("SELECT managerid FROM HrmResource WHERE id=" + tempUserid);
            if (rs_manager.next()) {
                tempManagerid = Util.getIntValue(rs_manager.getString("managerid"), -1);
            }
        }
        if (tempManagerid != -1) {
            mgrVal = String.valueOf(tempManagerid);
        }

        //出口为本节点（不为退回出口）
        tempsql = "select nodeid from workflow_nodelink nl ,workflow_nodebase nd where nd.id=nl.nodeid and destnodeid=" + nextnodeid + " and (nl.isreject is null or nl.isreject <> '1') and nodeid=" + nextnodeid;
        rs_manager.executeSql(tempsql);
        //不存在循环节点的情况，此manager为最终manager
        if (!rs_manager.next()) {
            return mgrVal;
        }

        while (true) {
            tempsql = "select userid, groupid, operatedate, operatetime from workflow_currentoperator where requestid=" + requestid
                    + " AND preisremark = '0' "
                    + " AND isremark = '2' "
                    + " AND nodeid=" + nextnodeid
                    + " AND userid=" + tempManagerid
                    + " AND receivedate >= '" + tempoperatedate + "' "
                    + " AND receivetime >= '" + tempoperatetime + "'"
                    + " and groupid>" + tempGroupId
                    + " order by operatedate, operatetime, groupid desc";

            rs_manager.executeSql(tempsql);

            if (rs_manager.next()) {
                tempUserid = Util.getIntValue(rs_manager.getString("userid"), -1);
                tempGroupId = Util.getIntValue(rs_manager.getString("groupid"), -1);
                tempoperatedate = Util.null2String(rs_manager.getString("operatedate"));
                tempoperatetime = Util.null2String(rs_manager.getString("operatetime"));

                if (tempUserid != -1) {
                    rs_manager.executeSql("select managerid from hrmresource where id=" + tempUserid);
                    if (rs_manager.next()) {
                        tempManagerid = Util.getIntValue(rs_manager.getString("managerid"), -1);
                    }
                }
            } else {
                mgrVal = String.valueOf(tempUserid);
                break;
            }
        }

        return mgrVal;
    }

    /**
     * 根据被代理人与流程编号查询代理人编号
     * add by liao dong for qc56835 in 2013年10月21日
     *
     * @param userId 被代理人
     * @param wfid   流程编号
     * @return
     */
    public String getAgentTypeByUserId(String userId, String wfid) {
        String agenterId = "";
        wfAgentCondition wfAgentCondition = new wfAgentCondition();
        String versionsIds = WorkflowVersion.getAllVersionStringByWFIDs(wfid);
        versionsIds = "'" + StringUtils.replace(versionsIds, ",", "','") + "'";
        String agentCheckSql = " select * from workflow_agentConditionSet where workflowId in (" + versionsIds + ") and bagentuid=" + userId +
                " and agenttype = '1'   and isproxydeal='1' " +
                " and ( ( (endDate = '" + TimeUtil.getCurrentDateString() + "' and (endTime='' or endTime is null))" +
                " or (endDate = '" + TimeUtil.getCurrentDateString() + "' and endTime > '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or endDate > '" + TimeUtil.getCurrentDateString() + "' or endDate = '' or endDate is null)" +
                " and ( ( (beginDate = '" + TimeUtil.getCurrentDateString() + "' and (beginTime='' or beginTime is null))" +
                " or (beginDate = '" + TimeUtil.getCurrentDateString() + "' and beginTime < '" + (TimeUtil.getCurrentTimeString()).substring(11, 19) + "' ) ) " +
                " or beginDate < '" + TimeUtil.getCurrentDateString() + "' or beginDate = '' or beginDate is null)  order by agentbatch asc ";
        rs.execute(agentCheckSql);
        while (rs.next()) {
            String agentid = rs.getString("agentid");
            String conditionkeyid = rs.getString("conditionkeyid");
            //检查当前流程下的代理是否支持批次条件【开启流程中的代理、已经是流转中的、批次条件满足】
            boolean isagentcond = wfAgentCondition.isagentcondite("" + requestid, "" + workflowid, "" + userId, "" + agentid, "" + conditionkeyid);
            if (isagentcond) {
                agenterId = rs.getString("agentuid");
                break;
            }
        }
        return agenterId;
    }

    /**
     * 使用代理的时候，穿透的manager节点应该去穿透节点的manager值
     * add by liao dong for qc56835 in 2013年10月23日
     *
     * @param nodeUserId     被穿透的节点操作编号
     * @param isbillParam    表单类型
     * @param formIdParam    表单编号
     * @param requestidParam 请求编号
     */
    public void updateAgentManagerByUserId(String nodeUserId, int isbillParam, int formIdParam, int requestidParam) {
        String billtablename = "";
        String oldManager = "";
        try {
            ResourceComInfo resource = new ResourceComInfo();
            int _manager = Util.getIntValue(resource.getManagerID(nodeUserId), -1);

            if (isbillParam == 1) {
                rs.executeSql("select tablename from workflow_bill where id=" + formIdParam);
                if (rs.next()) {
                    billtablename = rs.getString("tablename");
                }
                rs.executeSql("select 1 from workflow_billfield where fieldname='manager' and  billid=" + formIdParam);
                if (rs.next()) {
                    if (!billtablename.trim().equals("")) {
                        rs.executeSql("select manager from " + billtablename + " where requestid=" + requestid);
                        if (rs.next()) {
                            oldManager = rs.getString("manager");
                        }
                        if ("bill_approveproj".equals(billtablename.toLowerCase())) {
                            rs.executeSql("update " + billtablename + " set manager = " + oldManager + " where requestid=" + requestidParam);
                        } else {
                            rs.executeSql("update " + billtablename + " set manager = " + _manager + " where requestid=" + requestidParam);
                        }
                    }
                }
            } else {
                rs.executeSql("select 1 from workflow_formfield  a   join  workflow_formdict b  on   a.fieldid = b.id   where   b.fieldname='manager'  and a.formid = '" + formIdParam + "' ");
                if (rs.next()) {
                    rs.executeSql("select * from workflow_form where requestid=" + requestid);
                    if (rs.next()) {
                        oldManager = rs.getString("manager");
                    }
                    rs.executeSql("update workflow_form set manager = " + _manager + " where requestid=" + requestidParam);
                }
            }
        } catch (Exception e) {
            try {
                if (isbillParam == 1) {
                    if (!billtablename.trim().equals("")) {
                        rs.executeSql("update " + billtablename + " set manager = " + oldManager + " where requestid=" + requestidParam);
                    }
                } else {
                    rs.executeSql("update workflow_form set manager = " + oldManager + " where requestid=" + requestidParam);
                }
            } catch (Exception ex) {
                // System.out.println("使用代理的时候，穿透的manager节点应该去穿透节点的manager值有误"+ex.getMessage());
            }

        }
    }

    /**
     * 获取各类型拼装的sql
     *
     * @param type
     * @param signorder
     * @param level
     * @param level2
     * @param theorderbyordervalue
     * @param fieldvalue
     * @param statustr
     * @param subcompanyField
     * @param deptField
     * @return returnStrs[0] = sql;
     * returnStrs[1] = subcompanyFieldFlag;
     * returnStrs[2] = deptFieldFlag;
     * returnStrs[3] = theorderbyordervalue;
     */
    protected String[] getHrmSqlByType(RecordSet rs2, RecordSet rsTemps, int objid, int type, int signorder, int level, int level2, String supsubcompanyid, String thesubcompanyid, String thedepartmentid, String statustr, String subcompanyField, String deptField, String groupdetailid, int virtualid, String jobobj, String jobfield) {
        String returnStrs[] = new String[4];
        String sql = "";
        String subcompanyFieldFlag = "";
        String deptFieldFlag = "";
        String theorderbyordervalue = "";
        String sqlfrom = "HrmResource";
        String sqlfromdepart = "HrmDepartment";
        String sqlfromSubCompany = "HrmSubCompany";
        String sqlwhere = "";
        HrmCommonService hrmCommonService = null;

        if (virtualid < -1) {//如果是虚拟维度，则初始化相应查询表
            sqlfrom = "HrmResourceVirtualView";//虚拟维度人力资源视图
            sqlfromdepart = "HrmDepartmentAllView";//虚拟维度部门视图
            sqlfromSubCompany = "HrmSubCompanyAllView";//虚拟维度分部视图
            thedepartmentid = "-1";//初始默认部门-1，表示为空
            thesubcompanyid = "-1";//初始默认分部-1，表示为空
            RecordSet rsvirtual = new RecordSet();
            rsvirtual.executeSql("select departmentid,subcompanyid1 from HrmResourceVirtualView where id =" + creater);
            while (rsvirtual.next()) {
                if ("-1".equals(thedepartmentid)) {
                    thedepartmentid = rsvirtual.getString("departmentid");
                    thesubcompanyid = rsvirtual.getString("subcompanyid1");
                } else {
                    thedepartmentid += "," + rsvirtual.getString("departmentid");
                    thesubcompanyid += "," + rsvirtual.getString("subcompanyid1");
                }
            }
            sqlwhere = " and virtualtype = " + virtualid;
        }
        switch (type) {
            case 30:               //分部
                sql = "select id,0 as customerid from " + sqlfrom + " where subcompanyid1 = " + objid + " and seclevel >= " + level + " and seclevel <= " + level2 + " and status in ( " + statustr + " )  order by seclevel asc, dsporder  asc ";
                break;
            case 1:                 // 部门
                sql = "select id,0 as customerid from " + sqlfrom + " where departmentid = " + objid + " and seclevel >= " + level + " and seclevel <= " + level2 + " and status in ( " + statustr + "  )  order by seclevel asc, dsporder  asc ";
                break;
            case 2:                 // 角色
				/*
				sql = "SELECT a.resourceid as id,0 as customerid FROM HrmRoleMembers a, hrmresource b where a.roleid = " + objid + " and a.rolelevel = " + level
						+ " and a.resourceid = b.id and (a.rolelevel=2 or ( a.rolelevel=1 and b.subcompanyid1=" + thesubcompanyid
						+ " ) or ( a.rolelevel=0 and b.departmentid =" + thedepartmentid + ") )  and b.status in ( "+statustr+"  ) ";
				*/
                //TD10029 chujun
                hrmCommonService = new HrmCommonServiceImpl();
                String roleMemberQuerySql = hrmCommonService.getHrmRoleMemeberSqlByRoleIds(Util.null2String(objid));
                if (level == 1) {//分部
                    sql = " select a.resourceid as id,0 as customerid,a.id as idorder,dsporder from (" + roleMemberQuerySql + ") a,hrmresource b where a.resourceid = b.id and  b.subcompanyid1=" + thesubcompanyid + " and b.status in ( " + statustr + " ) and a.rolelevel = 1 order by idorder asc,dsporder asc,id asc ";
                } else if (level == 2) {//总部
                    sql += " select a.resourceid as id,0 as customerid,dsporder,a.id as idorder  from (" + roleMemberQuerySql + ") a,hrmresource b where a.resourceid = b.id and b.status in ( " + statustr + "  ) and a.rolelevel = 2 ";
                    sql += " union all ";
                    sql += " select a.resourceid as id,0 as customerid,0 as dsporder,a.id as idorder from (" + roleMemberQuerySql + ") a, hrmresourcemanager b where a.resourceid = b.id and b.status in ( " + statustr + " ) and a.rolelevel = 2 order by  idorder asc,dsporder asc,id asc";
                } else if (level == 3) {//上级分部
                    sql = " select a.resourceid as id,0 as customerid,a.id as idorder,dsporder from (" + roleMemberQuerySql + ") a, hrmresource b where a.resourceid = b.id and b.subcompanyid1=" + supsubcompanyid + " and b.status in ( " + statustr + "  ) and a.rolelevel = 1 order by  idorder asc,dsporder asc,id asc ";
                } else {//部门
                    sql = " select a.resourceid as id,0 as customerid,a.id as idorder,dsporder from (" + roleMemberQuerySql + ") a, hrmresource b where a.resourceid = b.id and b.departmentid =" + thedepartmentid + " and b.status in ( " + statustr + "  ) and a.rolelevel = 0 order by  idorder asc,dsporder asc,id asc ";
                }
                break;
            case 3:                 // 人力资源
                //sql = "select id,0 as customerid from "+sqlfrom+" where id  in (" + wfoper.getHrmOperator(groupdetailid) + ") and status in ( "+statustr+"  ) ";
                sql = " select t2.objid as id,0 as customerid from Workflow_HrmOperator t2 where  t2.groupdetailid='" + groupdetailid + "'  and exists(select 1 from HrmResource t where t.id=t2.objid and    t.status in ( " + statustr + "  )  ) order by t2.orders asc ";

                break;
            case 4:                 // 所有人
                sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and status in ( " + statustr + "  )  order by  dsporder  asc ";
                break;
            case 58:                 // 岗位
                if (level == 0) {
                    //sql = "select id,0 as customerid from HrmResourceVirtualView where jobtitle in("+jobobj+") and (departmentid in("+jobfield+") or hrmdepartmentid in ("+jobfield+")) and status in ( "+statustr+" )  order by  dsporder  asc ";
                    if (rs.getDBType().equals("oracle")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (departmentid in(" + jobfield + ") " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfield + ") )) and status in ( " + statustr + " )  " +
                                " order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc ";
                    }
                     else if (rs.getDBType().equals("postgresql")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (departmentid in(" + jobfield + ") " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfield + ") )) and status in ( " + statustr + " )  " +
                                " order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc ";
                    }
                    else if (rs.getDBType().equals("mysql")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (departmentid in(" + jobfield + ") " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfield + ") )) and status in ( " + statustr + " )  " +
                                " order by  instr(CONCAT(',',CONCAT(jobtitle,''), ','),'," + jobobj + ",'),dsporder  asc ";
                    } else {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (departmentid in(" + jobfield + ") " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfield + ") )) and status in ( " + statustr + " )  " +
                                " order by  charindex(','+ cast(jobtitle AS varchar(4000)) +',', '," + jobobj + ",'),dsporder  asc ";
                    }

                } else if (level == 1) {
                    //sql = "select id,0 as customerid from HrmResourceVirtualView where jobtitle in("+jobobj+") and (subcompanyid1 in("+jobfield+") or hrmsubcompanyid1 in ("+jobfield+")) and status in ( "+statustr+" )  order by  dsporder  asc ";
                    if (rs.getDBType().equals("oracle")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (subcompanyid1 in(" + jobfield + ")   " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfield + ") )) and status in ( " + statustr + " )" +
                                " order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc ";
                    }
                    else if (rs.getDBType().equals("postgresql")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (subcompanyid1 in(" + jobfield + ")   " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfield + ") )) and status in ( " + statustr + " )" +
                                " order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc ";
                    }
                    else if (rs.getDBType().equals("mysql")) {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (subcompanyid1 in(" + jobfield + ")   " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfield + ") )) and status in ( " + statustr + " )" +
                                " order by  instr(CONCAT(',',CONCAT(jobtitle,''), ','),'," + jobobj + ",'),dsporder  asc ";
                    } else {
                        sql = "select id,0 as customerid from HrmResource  where jobtitle in(" + jobobj + ") and (subcompanyid1 in(" + jobfield + ")   " +
                                " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfield + ") )) and status in ( " + statustr + " )" +
                                " order by  charindex(','+ cast(jobtitle AS varchar(4000)) +',', '," + jobobj + ",'),dsporder  asc ";
                    }
                } else {
                    if (rs.getDBType().equals("oracle")) {
                        sql = "select id,0 as customerid from HrmResource where jobtitle in(" + jobobj + ") and status in ( " + statustr + "  )  order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc  ";
                    }
                    else if (rs.getDBType().equals("postgresql")) {
                        sql = "select id,0 as customerid from HrmResource where jobtitle in(" + jobobj + ") and status in ( " + statustr + "  )  order by instr(cast(" + jobobj + " AS varchar(4000)),jobtitle),dsporder  asc  ";
                    }
                    else if (rs.getDBType().equals("mysql")) {
                        sql = "select id,0 as customerid from HrmResource where jobtitle in(" + jobobj + ") and status in ( " + statustr + "  )  order by  instr(CONCAT(',',CONCAT(jobtitle,''), ','),'," + jobobj + ",'),dsporder  asc ";
                    } else {
                        sql = "select id,0 as customerid from HrmResource where jobtitle in(" + jobobj + ") and status in ( " + statustr + "  )  order by  charindex(','+ cast(jobtitle AS varchar(4000)) +',', '," + jobobj + ",'),dsporder  asc ";
                    }
                }
                break;
            case 5:
            case 49:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 23:
            case 24:
            case 31:
            case 32:
            case 33:
            case 34:
            case 35:
            case 38:
            case 42:
            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            case 48:
            case 50:
            case 52:
            case 53:
            case 54:
            case 55:
            case 56:
            case 57:
            case 51:
            case 59://人力资源字段所属岗位
            case 60://人力资源字段 岗位浏览按钮
                String fieldname = "";
                String fieldvalue = "";
                String tablename = "";
                String sql1 = "";
                if (isbill == 0)
                    rs2.executeSql("select fieldname,0 viewtype,0 groupid from workflow_formdict where id = " + objid + " union select fieldname,1 viewtype,groupid from  workflow_formdictdetail a,workflow_formfield b where a.id = b.fieldid and b.formid = " + formid + " and a.id = " + objid);
                else
                    rs2.executeSql("select fieldname,viewtype,detailtable from workflow_billfield where id =" + objid);

                String viewtype = "";
                if (rs2.next()) {
                    fieldname = rs2.getString("fieldname");
                    viewtype = rs2.getString("viewtype");
                }

                if (isbill == 0) {
                    if ("1".equals(viewtype)) {
                        String groupid = rs2.getString(3);
                        rs2.executeSql("select " + fieldname + " from workflow_formdetail where requestid=" + requestid + " and groupid = " + groupid + " order by id asc");
                    } else {
                        rs2.executeSql("select " + fieldname + " from workflow_form where requestid=" + requestid);
                    }
                } else {
                    if ("1".equals(viewtype)) {
                        String detailtable = rs2.getString(3);
                        rs2.execute("select " + fieldname + " from " + detailtable + " where mainid = " + billid + " order by id asc");
                    } else
                        rs2.executeSql("select " + fieldname + " from " + billtablename + " where id = " + billid);
                }
                cachefieldvalue = "";
                List<String> resultList = new ArrayList<String>();
                while (rs2.next()) {
                    String tempValue = Util.null2String(rs2.getString(fieldname));
                    List temp_list = Util.TokenizerString(tempValue, ",");
                    for (Object o : temp_list) {
                        String tempo = (String) o;
                        if (!resultList.contains(tempo)) {
                            resultList.add(tempo);
                            fieldvalue += "," + tempo;
                        }
                    }
                }
                if (!"".equals(fieldvalue))
                    fieldvalue = fieldvalue.substring(1);


                cachefieldvalue = fieldvalue;
                /*----------  xwj for td1966 begin---------*/
                if ("manager".equals(fieldname) && this.isreject == 1) {
                    String tempFieldValue = fieldvalue;

                    RecordSet rs_new = new RecordSet();
                    ArrayList arr = new ArrayList();
                    rs_new.executeSql("select  distinct userid from workflow_currentoperator where requestid =" + requestid + " and nodeid=" + this.nextnodeid + " and isremark = '2'");

                    while (rs_new.next()) {

                        arr.add(rs_new.getString("userid"));

                    }

                    for (int i = 0; i < arr.size(); i++) {
                        rs_new.executeSql("select managerid from hrmresource where id = " + (String) arr.get(i));
                        rs_new.next();
                        if (tempFieldValue.equals(rs_new.getString("managerid"))) {
                            fieldvalue = (String) arr.get(i);
                        }
                    }
                    String tempsql = "SELECT userid,agentorbyagentid,agenttype FROM workflow_currentoperator " +
                            "WHERE nodeid IN (SELECT nodeid FROM workflow_nodelink nl ,workflow_nodebase nd WHERE nd.id = nl.nodeid AND destnodeid = " + nextnodeid + " AND (nl.isreject is null or nl.isreject <> '1') and nodeid <> " + nextnodeid + ") " +
                            "AND requestid=" + requestid + " AND preisremark=0 AND isremark=2 AND operatedate IS NOT NULL AND operatetime IS NOT NULL ORDER BY groupid DESC ";

                    RecordSet rs_manager = new RecordSet();

                    rs_manager.executeSql(tempsql);
                    int tempUserid = -1;
                    int tempManagerid = -1;
                    int agentorbyagentid = -1;
                    int agenttype = -1;
                    if (rs_manager.next()) {
                        tempUserid = Util.getIntValue(rs_manager.getString("userid"), -1);
                        agentorbyagentid = Util.getIntValue(rs_manager.getString("agentorbyagentid"), -1);
                        agenttype = Util.getIntValue(rs_manager.getString("agenttype"), -1);
                    }

                    if (agenttype == 2) {
                        if (agentorbyagentid != -1) {
                            rs_manager.executeSql("SELECT managerid FROM HrmResource WHERE id=" + agentorbyagentid);
                            if (rs_manager.next()) {
                                tempManagerid = Util.getIntValue(rs_manager.getString("managerid"), -1);
                            }
                        }
                    } else {
                        if (tempUserid != -1) {
                            rs_manager.executeSql("SELECT managerid FROM HrmResource WHERE id=" + tempUserid);
                            if (rs_manager.next()) {
                                tempManagerid = Util.getIntValue(rs_manager.getString("managerid"), -1);
                            }
                        }
                    }
                    if (tempManagerid != -1) {
                        fieldvalue = String.valueOf(tempManagerid);
                    }

                }
                /*----------  xwj for td1966 end---------*/
                if (fieldvalue.equals("")) fieldvalue = "0";

                switch (type) {
                    case 51:                         //分部

                        if (subcompanyField == null || "0".equals(subcompanyField) || "".equals(subcompanyField)) {//说明下拉框中选择的是安全级别

                            sql = "select id,0 as customerid,subcompanyid1,seclevel,dsporder from HrmResource where  seclevel >= " + level + " and seclevel <= " + level2 + "  and subcompanyid1 in(" + fieldvalue + ")  and status in ( " + statustr + "  )";
                            sql += " union select id,0 as customerid,subcompanyid1,seclevel,dsporder from HrmResourceVirtualView where  seclevel >= " + level + " and seclevel <= " + level2 + "  and subcompanyid1 in(" + fieldvalue + ")  and status in ( " + statustr + "  )";
                            if (signorder == 2) {
                                sql += " order by seclevel asc, dsporder  asc ";
                            }
                            subcompanyFieldFlag = "1";
                            theorderbyordervalue = fieldvalue;
                        } else {//说明下拉框中选择的是分部自定义字段 subcompanyField该字段存储值个格式id_fieldname_fieldlabel
                            if (subcompanyField != null && !"".equals(subcompanyField)) {
                                String[] tempStr = Util.TokenizerString2(subcompanyField, "[_]");
                                if (tempStr != null && tempStr.length > 2) {
                                    String subcompanyFieldId = tempStr[0];
                                    String subcompanyFieldName = tempStr[1];
                                    if (subcompanyFieldName != null && !"".equals(subcompanyFieldName)) {
                                        sql = "select " + subcompanyFieldName + " as id,0 as customerid from HrmSubCompanyAllView where id in (" + fieldvalue + ")";
                                        subcompanyFieldFlag = "2";
                                    }
                                }
                            }
                        }
                        break;
                    case 42:                         //部门

                        if (deptField == null || "0".equals(deptField) || "".equals(deptField)) {//说明下拉框中选择的是安全级别
                            sql = "select id,0 as customerid,departmentid,seclevel,dsporder from HrmResource where  seclevel >= " + level + " and seclevel <= " + level2 + "  and departmentid in(" + fieldvalue + ")  and status in ( " + statustr + "  ) and status<>5";
                            sql += " union select id,0 as customerid,departmentid,seclevel,dsporder from HrmResourceVirtualView where  seclevel >= " + level + " and seclevel <= " + level2 + "  and departmentid in(" + fieldvalue + ")  and status in ( " + statustr + "  ) and status<>5";
                            if (signorder == 2) {
                                sql += " order by seclevel asc, dsporder  asc ";
                            }
                            deptFieldFlag = "1";
                            theorderbyordervalue = fieldvalue;
                        } else {//说明下拉框中选择的是部门自定义字段 deptField该字段存储值个格式id_fieldname_fieldlabel
                            if (deptField != null && !"".equals(deptField)) {
                                String[] tempStr = Util.TokenizerString2(deptField, "[_]");
                                if (tempStr != null && tempStr.length > 2) {
                                    String deptFieldId = tempStr[0];
                                    String deptFieldName = tempStr[1];
                                    if (deptFieldName != null && !"".equals(deptFieldName)) {
                                        sql = "select " + deptFieldName + " as id,0 as customerid from HrmDepartmentAllView where id in (" + fieldvalue + ")";
                                        deptFieldFlag = "2";
                                    }
                                }
                            }
                        }
                        break;
                    case 43:                         //角色
                        hrmCommonService = new HrmCommonServiceImpl();
                        String roleMemberQuerySQl = hrmCommonService.getHrmRoleMemeberSqlByRoleIds(fieldvalue);
                        sql = "SELECT b.id as id,0 as customerid,a.rolelevel as rolelevel, a.roleid as roleid, a.id as idorder FROM (" + roleMemberQuerySQl + ") a, hrmresource b where a.resourceid = b.id and b.status in ( " + statustr + "  ) ";//xwj for td2104 on 20050802
                        theorderbyordervalue = fieldvalue; //xwj for td2104 on 20050802
                        break;
                    case 44:                         //客户字段经理的经理
                        sql = "SELECT c.id as id,0 as customerid FROM CRM_CustomerInfo a, hrmresource b,hrmresource c where a.manager = b.id and b.managerid=c.id and a.id in (" + fieldvalue + ") and b.status in ( " + statustr + "  ) and c.status in ( " + statustr + "  )";
                        break;
                    case 45:                         //客户字段分部
                        sql = "select a.id,0 as customerid from HrmResource a,CRM_CustomerInfo b,HrmResource c where a.subcompanyid1=c.subcompanyid1 and b.manager=c.id and b.id=" + fieldvalue + " and a.status in ( " + statustr + "  ) and c.status in ( " + statustr + "  )";
                        break;
                    case 46:                         //客户字段部门
                        sql = "select a.id,0 as customerid from HrmResource a,CRM_CustomerInfo b,HrmResource c where a.departmentid=c.departmentid and b.manager=c.id and b.id=" + fieldvalue + " and a.status in ( " + statustr + "  ) and c.status in ( " + statustr + "  )";
                        break;
                    case 47:                         //项目字段经理的经理
                        sql = "SELECT c.id as id,0 as customerid FROM Prj_ProjectInfo a, hrmresource b,hrmresource c where a.manager = b.id and b.managerid=c.id and a.id in (" + fieldvalue + ") and b.status in ( " + statustr + "  ) and c.status in ( " + statustr + "  )";
                        break;
                    case 48:                         //会议室的管理员
                        RecordSet rs_48 = new RecordSet();
                        rs_48.execute("SELECT hrmids FROM MeetingRoom where id in (" + fieldvalue + ")");
                        String hrmids = "";
                        while (rs_48.next()) {
                            String id = Util.null2String(rs_48.getString("hrmids"));
                            if (id.startsWith(",")) {
                                id = id.substring(1);
                            }
                            if (id.endsWith(",")) {
                                id = id.substring(0, id.length() - 1);
                            }
                            id = id.trim();
                            if (!"".equals(id)) {
                                if (hrmids.equals("")) {
                                    hrmids = id;
                                } else {
                                    hrmids += "," + id;
                                }
                            }
                        }

                        if (hrmids.equals(""))
                            hrmids = "0";
                        sql = "select id,0 as customerid from HrmResource where id in( " + hrmids + ")";
                        break;
                    case 5:                         // 人力资源字段本人
                    case 50:
                        //sql = "select id,0 as customerid from HrmResource where id in( " + fieldvalue + ") union select id,0 as customerid from HrmResourceManager where id in("+ fieldvalue + ")";
                        String strsqlClause = Util.getSubINClause(fieldvalue, "id", "IN");
                        sql = "select id,0 as customerid from HrmResource where " + strsqlClause + " union select id,0 as customerid from HrmResourceManager where " + strsqlClause;
                        theorderbyordervalue = fieldvalue;
                        break;
                    case 6:                         // 人力资源字段经理
                        strsqlClause = Util.getSubINClause(fieldvalue, "id", "IN");
                        sql = "select managerid as id,0 as customerid from " + sqlfrom + " where " + strsqlClause + sqlwhere;
                        break;
                    case 59:                         // 人力资源字段所属岗位
                        //--
                        ArrayList<String> joblist = null;
                        ResourceComInfo rc = null;
                        DepartmentComInfo dc = null;
                        String jobtitleid = "";//岗位id
                        sqlwhere = "";
                        try {
                            rc = new ResourceComInfo();
                            dc = new DepartmentComInfo();

                            joblist = Util.TokenizerString(fieldvalue, ",");
                            String subdeptids = "";//本部门及下级部门
                            String surdept = "";//本部门及上级部门
                            String subcomid = "";//本分部及下级分部
                            String surcomid = "";//本分部及上级分部
                            for (int job = 0; job < joblist.size(); job++) {
                                //本部门
                                String jobdepartmentid = "" + Util.getIntValue(rc.getDepartmentID(joblist.get(job)), 0);
                                //本分部
                                String jobsubcompanyid = "" + Util.getIntValue(dc.getSubcompanyid1(jobdepartmentid), 0);
                                if (!"0".equals(jobdepartmentid) && !"0".equals(jobsubcompanyid)) {
                                    jobtitleid = "" + Util.getIntValue(rc.getJobTitle(joblist.get(job)), 0);

                                    //本部门及下级部门
                                    subdeptids = "";
                                    subdeptids = DepartmentComInfo.getAllChildDepartId(jobdepartmentid, subdeptids);
                                    if (!"".equals(subdeptids)) {
                                        subdeptids = jobdepartmentid + subdeptids;
                                    } else {
                                        subdeptids = jobdepartmentid;
                                    }
                                    //本部门及上级部门
                                    surdept = "";
                                    surdept = DepartmentComInfo.getAllParentDepartId(jobdepartmentid, surdept);
                                    if (!"".equals(surdept)) {
                                        surdept = jobdepartmentid + surdept;
                                    } else {
                                        surdept = jobdepartmentid;
                                    }
                                    //本分部及下级分部
                                    subcomid = "";
                                    subcomid = SubCompanyComInfo.getAllChildSubcompanyId(jobsubcompanyid, subcomid);
                                    if (!"".equals(subcomid)) {
                                        subcomid = jobsubcompanyid + subcomid;
                                    } else {
                                        subcomid = jobsubcompanyid;
                                    }
                                    //本分部及上级分部
                                    surcomid = "";
                                    surcomid = SubCompanyComInfo.getAllParentSubcompanyId(jobsubcompanyid, surcomid);
                                    if (!"".equals(surcomid)) {
                                        surcomid = jobsubcompanyid + surcomid;
                                    } else {
                                        surcomid = jobsubcompanyid;
                                    }
                                    //strsqlClause = Util.getSubINClause(jobtitleid, "jobtitle", "IN");

                                    String subdeptidsClause = Util.getSubINClause(subdeptids, "departmentid", "IN");
                                    String surdeptClause = Util.getSubINClause(surdept, "departmentid", "IN");
                                    String subcomidClause = Util.getSubINClause(subcomid, "subcompanyid1", "IN");
                                    String surcomidClause = Util.getSubINClause(surcomid, "subcompanyid1", "IN");

                                    if (level == 0) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " (jobtitle = " + jobtitleid + " )";
                                        } else {
                                            sqlwhere += " or (jobtitle = " + jobtitleid + " )";
                                        }
                                    } else if (level == 1) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and (departmentid in (" + jobdepartmentid + ") ))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and (departmentid in (" + jobdepartmentid + ") ))";
                                        }
                                    } else if (level == 2) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and ( " + subdeptidsClause + "))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and ( " + subdeptidsClause + "))";
                                        }
                                    } else if (level == 3) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and ( " + surdeptClause + "))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and ( " + surdeptClause + "))";
                                        }
                                    } else if (level == 4) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and (subcompanyid1 in (" + jobsubcompanyid + ") ))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and (subcompanyid1 in (" + jobsubcompanyid + ") ))";
                                        }
                                    } else if (level == 5) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and ( " + subcomidClause + "))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and ( " + subcomidClause + "))";
                                        }
                                    } else if (level == 6) {
                                        if ("".equals(sqlwhere)) {
                                            sqlwhere = " ( jobtitle = " + jobtitleid + " and ( " + surcomidClause + "))";
                                        } else {
                                            sqlwhere += " or ( jobtitle = " + jobtitleid + " and ( " + surcomidClause + "))";
                                        }
                                    }
                                }
                            }
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        if ("".equals(sqlwhere)) {
                            sqlwhere += " id = -99999 ";
                        } else {
                            sqlwhere += " and status in ( " + statustr + " ) order by dsporder asc ";
                        }
                        if (!"".equals(jobtitleid) && !"0".equals(jobtitleid)) {
                            sql = "select id,0 as customerid from HrmResource where " + sqlwhere;
                        } else {
                            sql = "select id,0 as customerid from HrmResource where id = -99999";
                        }
                        //----
                        break;
                    case 60:                         // 人力资源字段 岗位
                        //----
                        strsqlClause = Util.getSubINClause(fieldvalue, "jobtitle", "IN");
                        if (level == 0) {
                            sqlwhere = " and (departmentid in (" + jobfield + ") " +
                                    " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfield + ") )) and status in ( " + statustr + " ) order by dsporder asc ";
                        } else if (level == 1) {
                            sqlwhere = " and (subcompanyid1 in (" + jobfield + ") " +
                                    " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfield + ") )) and status in ( " + statustr + " ) order by dsporder asc ";
                        } else if (level == 3) {
                            String jobfiledtype = "";
                            String jobviewtype = "";
                            String jobformname = fieldname;

                            if (isbill == 0)
                                rs2.executeSql("select fieldname,0 viewtype,0 groupid,type from workflow_formdict where id = " + jobfield + " union select fieldname,1 viewtype,groupid,type from  workflow_formdictdetail a,workflow_formfield b where a.id = b.fieldid and b.formid = " + formid + " and a.id = " + jobfield);
                            else
                                rs2.executeSql("select fieldname,viewtype,detailtable,type from workflow_billfield where id =" + jobfield);

                            if (rs2.next()) {
                                fieldname = Util.null2String(rs2.getString("fieldname"));
                                jobfiledtype = Util.null2String(rs2.getString("type"));
                                jobviewtype = rs2.getString("viewtype");
                            }
                            if (fieldname.equals(""))
                                break;

                            //===============================================
                            if ("1".equals(viewtype)) {//对明细做特殊处理，明细每一行岗位所属部门分部
                                if (isbill == 0) {
                                    String groupid = rs2.getString(3);
                                    rs2.executeSql("select " + fieldname + "," + jobformname + " from workflow_formdetail where requestid=" + requestid + " and groupid = " + groupid + " order by id asc");
                                } else {
                                    String detailtable = rs2.getString(3);
                                    rs2.execute("select " + fieldname + "," + jobformname + " from " + detailtable + " where mainid = " + billid + " order by id asc");
                                }
                                strsqlClause = "";
                                String jobformdvalue = "";
                                String jobfieldvalue = "";
                                while (rs2.next()) {
                                    jobformdvalue = Util.null2String(rs2.getString(jobformname));
                                    jobfieldvalue = Util.null2String(rs2.getString(fieldname));
                                    if (!"".equals(jobformdvalue) && !"".equals(jobfieldvalue)) {
                                        if ("4".equals(jobfiledtype) || "57".equals(jobfiledtype) || "167".equals(jobfiledtype) || "168".equals(jobfiledtype)) {
                                            if ("".equals(sqlwhere)) {
                                                sqlwhere = " ( jobtitle in (" + jobformdvalue + ") and (departmentid in (" + jobfieldvalue + ") " +
                                                        " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfieldvalue + ") ))) ";
                                            } else {
                                                sqlwhere += " or ( jobtitle in (" + jobformdvalue + ") and (departmentid in (" + jobfieldvalue + ") " +
                                                        " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfieldvalue + ") ))) ";
                                            }
                                        } else {
                                            if ("".equals(sqlwhere)) {
                                                sqlwhere = " ( jobtitle in (" + jobformdvalue + ") and (subcompanyid1 in (" + jobfieldvalue + ") " +
                                                        " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfieldvalue + ") ))) ";
                                            } else {
                                                sqlwhere += " or ( jobtitle in (" + jobformdvalue + ") and (subcompanyid1 in (" + jobfieldvalue + ") " +
                                                        " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfieldvalue + ") ))) ";
                                            }
                                        }
                                    }
                                }
                                sqlwhere += " and status in ( " + statustr + " ) order by dsporder asc ";
                            } else {
                                if (isbill == 0) {
                                    rs2.executeSql("select " + fieldname + " from workflow_form where requestid=" + requestid);
                                } else {
                                    rs2.executeSql("select " + fieldname + " from " + billtablename + " where id = " + billid);
                                }

                                String jobfieldvalue = "";
                                while (rs2.next()) {
                                    if ("".equals(jobfieldvalue)) {
                                        jobfieldvalue = Util.null2String(rs2.getString(fieldname));
                                    } else {
                                        jobfieldvalue += "," + Util.null2String(rs2.getString(fieldname));
                                    }
                                }
                                if ("4".equals(jobfiledtype) || "57".equals(jobfiledtype) || "167".equals(jobfiledtype) || "168".equals(jobfiledtype)) {
                                    sqlwhere = " and (departmentid in (" + jobfieldvalue + ") " +
                                            " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.departmentid in(" + jobfieldvalue + ") )) and status in ( " + statustr + " ) order by dsporder asc ";
                                } else {
                                    sqlwhere = " and (subcompanyid1 in (" + jobfieldvalue + ") " +
                                            " or exists( select 1 from HrmResourceVirtual where HrmResource.ID = HrmResourceVirtual.RESOURCEID AND HrmResourceVirtual.subcompanyid in(" + jobfieldvalue + ") )) and status in ( " + statustr + " ) order by dsporder asc ";
                                }
                            }
                            //===============================================
                        } else {
                            sqlwhere = " and status in ( " + statustr + " ) order by dsporder asc ";
                        }
                        //----
                        sql = "select id,0 as customerid from " + sqlfrom + " where " + strsqlClause + sqlwhere;
                        break;
                    case 7:                         // 人力资源字段本部门
                        strsqlClause = Util.getSubINClause(fieldvalue, "id", "IN");
                        sql = "select id,0 as customerid from " + sqlfrom + " where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in (select departmentid from " + sqlfrom + " where " + strsqlClause + ") and status in ( " + statustr + "  ) " + sqlwhere;
                        if (signorder == 2) {
                            sql = sql + " order by seclevel asc, dsporder  asc ";
                        }

                        break;
                    case 8:                         // 文档字段所有者
                        sql = "select ownerid as id,0 as customerid,usertype as usertypenew from DocDetail where id =" + fieldvalue;
                        break;
                    case 9:                         // 文档字段部门
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in (select docdepartmentid from DocDetail where id = " + fieldvalue + ") and status in ( " + statustr + "  ) ";
                        break;
                    case 10:                        // 项目字段经理
                        sql = "SELECT manager AS id,0 as customerid FROM Prj_ProjectInfo WHERE id =" + fieldvalue;
                        break;
                    case 11:                        // 项目字段本部门
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in (SELECT department FROM Prj_ProjectInfo WHERE id = " + fieldvalue + ") and status in ( " + statustr + "  ) ";
                        break;
                    case 12: {                        // 项目字段成员
                        //原来的程序用到表Prj_Member，但由于表字段被改以及现在该表不再使用，故使用Prj_ProjectInfo表的members字段 TD9074
                        RecordSet rs_new = new RecordSet();
                        rs_new.execute("SELECT members FROM Prj_ProjectInfo WHERE id =" + fieldvalue);
                        String members = "0";
                        if (rs_new.next()) {
                            members = Util.null2String(rs_new.getString("members"));
                        }
                        if ("".equals(members) || "null".equalsIgnoreCase(members)) {
                            members = "0";
                        }
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and id in (" + members + ") and status in ( " + statustr + "  ) ";
                        break;
                    }
                    case 13:                        // 资产字段所有者
                        sql = "SELECT resourceid AS id,0 as customerid FROM CptCapital WHERE id =" + fieldvalue;
                        break;
                    case 14:                        // 资产字段部门
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in (select departmentid from CptCapital where id = " + fieldvalue + ") and status in ( " + statustr + "  ) ";
                        break;
                    case 15:                        // 客户字段经理
                        sql = "select manager as id,0 as customerid from CRM_CustomerInfo where id = " + fieldvalue;
                        break;
                    case 16:                        // 客户联系人经理
                        sql = "select manager as id,0 as customerid from CRM_CustomerContacter where customerid = " + fieldvalue;
                        break;
                    case 23:
                        sql = "select id as customerid,0 as id from CRM_CustomerInfo where  seclevel >= " + level + " and seclevel <= " + level2 + " and manager in ( " + fieldvalue + ")";
                        break;
                    case 24:
                        sql = "select id as customerid,0 as id from CRM_CustomerInfo where id in( " + fieldvalue + ")";
                        break;
                    case 31:                        // 所有下级
                        String allsubstr = "0";
                        List<String> tempList = Util.TokenizerString(fieldvalue, ",");
                        for (String fieldvalue_temp : tempList) {
                            if (virtualid < -1) {//如果是虚拟维度，则初始化相应查询表
                                RecordSet lowerrs = new RecordSet();
                                lowerrs.executeSql("select id from HrmResourceVirtualView where managerid =" + fieldvalue_temp + sqlwhere);
                                while (lowerrs.next()) {
                                    allsubstr += "," + lowerrs.getString("id");
                                }
                            } else {
                                AllSubordinate asub = new AllSubordinate();
                                try {
                                    if ("0".equals(fieldvalue_temp)) {
                                        continue;
                                    }
                                    asub.getAll(fieldvalue_temp);
                                } catch (Exception asube) {
                                }
                                while (asub.next()) {
                                    if (!(asub.getSubordinateID()).equals(""))
                                        allsubstr += "," + asub.getSubordinateID();
                                }
                            }
                        }
                        strsqlClause = Util.getSubINClause(allsubstr, "id", "IN");
                        sql = "select id,0 as customerid from " + sqlfrom + " where " + strsqlClause + " and seclevel >= " + level + " and seclevel <= " + level2 + " and status in ( " + statustr + "  ) ";
                        break;
                    case 32:                        // 人力资源字段本分部
                        strsqlClause = Util.getSubINClause(fieldvalue, "id", "IN");
                        sql = "select id,0 as customerid from " + sqlfrom + " where seclevel >= " + level + " and seclevel <= " + level2 + " and subcompanyid1 in (select subcompanyid1 from " + sqlfrom + " where " + strsqlClause + ") and status in ( " + statustr + "  ) " + sqlwhere;
                        if (signorder == 2) {
                            sql = sql + " order by seclevel asc, dsporder  asc ";
                        }

                        break;
                    case 33:                        // 文档字段本分部
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and subcompanyid1 in (select subcompanyid1 from HrmDepartment where id in (select docdepartmentid from DocDetail where id = " + fieldvalue + ") ) and status in ( " + statustr + "  ) ";
                        break;
                    case 34:                        // 项目字段本分部
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and subcompanyid1 in (select subcompanyid1 from HrmDepartment where id in (SELECT department FROM Prj_ProjectInfo WHERE id = " + fieldvalue + ") ) and status in ( " + statustr + "  ) ";
                        break;
                    case 35:                        // 资产字段本分部
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and subcompanyid1 in (select subcompanyid1 from HrmDepartment where id in (select departmentid from CptCapital where id = " + fieldvalue + ") ) and status in ( " + statustr + "  ) ";
                        break;
                    case 38:                        // 上级部门
                        strsqlClause = Util.getSubINClause(fieldvalue, "b.id", "IN");
                        sql = "select id,0 as customerid from " + sqlfrom + " where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in (select supdepid from " + sqlfromdepart + " a , " + sqlfrom + " b where a.id = b.departmentid and " + strsqlClause + ") and status in ( " + statustr + "  ) " + sqlwhere;
                        if (signorder == 2) {
                            sql = sql + " order by seclevel asc, dsporder  asc ";
                        }

                        break;
                    case 49:                        // 收发文单位
                        String unitReceiver = "";
                        RecordSet rs_new = new RecordSet();
                        //					rs_new.executeSql("select receiverids from DocReceiveUnit where id in("+fieldvalue+")");
                        //					while(rs_new.next()){
                        //						String id = rs_new.getString("receiverids");
                        //						if(!"".equals(id)){
                        //							if(unitReceiver.equals("")){
                        //								if(id.indexOf(",") > -1 && id.indexOf(",") == 0){
                        //									unitReceiver=id.substring(1, id.length());
                        //								}else{
                        //									unitReceiver=id;
                        //								}
                        //							}else{
                        //								if(id.indexOf(",") > -1){
                        //									unitReceiver+=id;
                        //								}else{
                        //									unitReceiver+=","+id;
                        //								}
                        //							}
                        //						}
                        //					}
                        fieldvalue = Util.null2String(fieldvalue);
                        if (fieldvalue.startsWith(",")) {
                            fieldvalue = fieldvalue.substring(1);
                        }
                        if (fieldvalue.endsWith(",")) {
                            fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1);
                        }
                        Set<String> unitIdsSet = new HashSet<String>();
                        unitIdsSet.addAll(Arrays.asList(StringUtils.split(fieldvalue, ",")));
                        if (!"".equals(fieldvalue)) {
                            rs_new.executeSql("select receiverids from DocReceiveUnit where id in(" + StringUtils.join(unitIdsSet, ",") + ")");
                            unitIdsSet = new HashSet<String>();
                            while (rs_new.next()) {
                                String id = Util.null2String(rs_new.getString("receiverids"));
                                if (id.startsWith(",")) {
                                    id = id.substring(1);
                                }
                                if (id.endsWith(",")) {
                                    id = id.substring(0, id.length() - 1);
                                }
                                id = id.trim();
                                unitIdsSet.addAll(Arrays.asList(StringUtils.split(id, ",")));
                                unitReceiver = StringUtils.join(unitIdsSet, ",");
                            }
                        }
                        if (unitReceiver.equals(""))
                            unitReceiver = "0";
                        sql = "select id,0 as customerid from HrmResource where id in( " + unitReceiver + ")";
                        break;
                    case 52:                        // 组织架构部门负责人
                        sql = "select zzjgbmfzr as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                    case 53:                        // 组织架构部门分管领导
                        sql = "select zzjgbmfgld as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                    case 54:                        // 矩阵管理部门负责人
                        sql = "select jzglbmfzr as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                    case 55:                        // 矩阵管理部门分管领导
                        sql = "select jzglbmfgld as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                    case 56:                        // 部门负责人
                        sql = "select bmfzr as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                    case 57:                        // 部门分管领导
                        sql = "select bmfgld as id,0 as customerid from HrmDepartment where id in (" + fieldvalue + ")";
                        break;
                }
                break;
            case 17:                                // 创建人
                sql = "select creatertype*creater as customerid,(1-creatertype)*creater as id from workflow_requestbase where requestid = " + requestid;
                break;
            case 18:
            case 19:
            case 36:
            case 37:
            case 39:
            case 61:
                if (creatertype == 0) {
                    if (type == 18)                  // 创建人经理
                        sql = " select managerid as id,0 as customerid from " + sqlfrom + " where id = " + creater + sqlwhere;
                    if (type == 19) {                // 创建人本部门
                        sql = " select id,0 as customerid from " + sqlfrom + " where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid in( " + thedepartmentid + ") and status in ( " + statustr + "  ) " + sqlwhere;
                        if (signorder == 2) {
                            String sql_orderby = "";
                            int sqlOrderbyIndex = sql.lastIndexOf(" order by ");
                            if (sqlOrderbyIndex != -1) {
                                sql_orderby = sql.substring(sqlOrderbyIndex);
                                sql = sql.substring(0, sqlOrderbyIndex);
                            }
                            sql += " order by seclevel asc,dsporder  asc ";
                        }
                    }
                    if (type == 37) {                 // 创建人本分部
                        sql = " select id,0 as customerid from " + sqlfrom + " where seclevel >= " + level + " and seclevel <= " + level2 + " and subcompanyid1 in(" + thesubcompanyid + ") and status in ( " + statustr + "  ) " + sqlwhere;
                        if (signorder == 2) {
                            String sql_orderby = "";
                            int sqlOrderbyIndex = sql.lastIndexOf(" order by ");
                            if (sqlOrderbyIndex != -1) {
                                sql_orderby = sql.substring(sqlOrderbyIndex);
                                sql = sql.substring(0, sqlOrderbyIndex);
                            }
                            sql += " order by seclevel asc,dsporder  asc ";
                        }
                    }
                    if (type == 36) {               // 创建人下级
                        String allsubstr = "0";
                        if (virtualid < -1) {//如果是虚拟维度，则初始化相应查询表
                            RecordSet crs = new RecordSet();
                            crs.executeSql("select id from HrmResourceVirtualView where managerid =" + creater + sqlwhere);
                            while (crs.next()) {
                                allsubstr += "," + crs.getString("id");
                            }
                        } else {
                            AllSubordinate asub = new AllSubordinate();
                            try {
                                asub.getAll("" + creater);
                            } catch (Exception asube) {
                            }
                            while (asub.next()) {
                                if (!(asub.getSubordinateID()).equals(""))
                                    allsubstr += "," + asub.getSubordinateID();
                            }
                        }
                        sql = "select id,0 as customerid from " + sqlfrom + " where id in( " + allsubstr + ") and seclevel >= " + level + " and seclevel <= " + level2 + " and status in ( " + statustr + "  ) ";
                    }
                    if (type == 39) {                 // 创建人上级部门
                        sql = " select a.id as id ,0 as customerid from " + sqlfrom + " a , " + sqlfromdepart + " b where a.seclevel >= " + level + " and a.seclevel <= " + level2 + " and a.departmentid = b.supdepid and b.id in( " + thedepartmentid + ") and a.status in ( " + statustr + "  ) ";
                        if (signorder == 2) {
                            String sql_orderby = "";
                            int sqlOrderbyIndex = sql.lastIndexOf(" order by ");
                            if (sqlOrderbyIndex != -1) {
                                sql_orderby = sql.substring(sqlOrderbyIndex);
                                sql = sql.substring(0, sqlOrderbyIndex);
                            }
                            sql += " order by seclevel asc,dsporder  asc ";
                        }
                    }
                    if (type == 61) {               // 创建人岗位
                        //--
                        ResourceComInfo rc = null;
                        DepartmentComInfo dc = null;
                        String jobtitleid = "";//岗位id
                        try {
                            rc = new ResourceComInfo();
                            dc = new DepartmentComInfo();

                            String subdeptids = "";//本部门及下级部门
                            String surdept = "";//本部门及上级部门
                            String subcomid = "";//本分部及下级分部
                            String surcomid = "";//本分部及上级分部
                            String jobdepartmentid = "" + Util.getIntValue(rc.getDepartmentID("" + creater), 0);
                            String jobsubcompanyid = "" + Util.getIntValue(dc.getSubcompanyid1(jobdepartmentid), 0);

                            if (!"0".equals(jobdepartmentid) && !"0".equals(jobsubcompanyid)) {
                                jobtitleid = rc.getJobTitle("" + creater);

                                //本部门及下级部门
                                subdeptids = "";
                                subdeptids = DepartmentComInfo.getAllChildDepartId(jobdepartmentid, subdeptids);
                                if (!"".equals(subdeptids)) {
                                    subdeptids = jobdepartmentid + subdeptids;
                                } else {
                                    subdeptids = jobdepartmentid;
                                }
                                //本部门及上级部门
                                surdept = "";
                                surdept = DepartmentComInfo.getAllParentDepartId(jobdepartmentid, surdept);
                                if (!"".equals(surdept)) {
                                    surdept = jobdepartmentid + surdept;
                                } else {
                                    surdept = jobdepartmentid;
                                }
                                //本分部及下级分部
                                subcomid = "";
                                subcomid = SubCompanyComInfo.getAllChildSubcompanyId(jobsubcompanyid, subcomid);
                                if (!"".equals(subcomid)) {
                                    subcomid = jobsubcompanyid + subcomid;
                                } else {
                                    subcomid = jobsubcompanyid;
                                }
                                //本分部及上级分部
                                surcomid = "";
                                surcomid = SubCompanyComInfo.getAllParentSubcompanyId(jobsubcompanyid, surcomid);
                                if (!"".equals(surcomid)) {
                                    surcomid = jobsubcompanyid + surcomid;
                                } else {
                                    surcomid = jobsubcompanyid;
                                }
                            }

                            //----
                            if (!"".equals(jobtitleid)) {
                                if (level == 0) {
                                    sqlwhere = " and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 1) {
                                    sqlwhere = " and departmentid in (" + jobdepartmentid + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 2) {
                                    sqlwhere = " and departmentid in (" + subdeptids + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 3) {
                                    sqlwhere = " and departmentid in (" + surdept + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 4) {
                                    sqlwhere = " and subcompanyid1 in (" + jobsubcompanyid + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 5) {
                                    sqlwhere = " and subcompanyid1 in (" + subcomid + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                } else if (level == 6) {
                                    sqlwhere = " and subcompanyid1 in (" + surcomid + ") and status in ( " + statustr + " ) order by dsporder asc ";
                                }
                                sql = "select id,0 as customerid from HrmResource where jobtitle = " + jobtitleid + sqlwhere;
                            } else {
                                sql = "select id,0 as customerid from HrmResource where jobtitle = -99999 ";
                            }
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        //sql = " select id,0 as customerid from "+sqlfrom+" where id = " + creater +sqlwhere;
                    }
                }
                if (creatertype == 1) {
                    if (type == 18) {                 // 客户经理
                        sql = "select manager as id,0 as customerid from CRM_CustomerInfo where id = " + creater;
                    }
                    if (type == 19) {                 // 客户部门
                        sql = "select id,0 as customerid from HrmResource where seclevel >= " + level + " and seclevel <= " + level2 + " and departmentid = " + thedepartmentid + " and status in ( " + statustr + "  ) ";
                        if (signorder == 2) {
                            sql = sql + " order by seclevel asc, dsporder  asc ";
                        }
                    }
                    if (type == 37 || type == 36) {
                        sql = " select 0 as id,0 as customerid from HrmResource where id = 0 ";
                    }
                    if (type == 39) {
                        sql = "select a.id as id,0 as customerid from HrmResource a , HrmDepartment b where a.seclevel >= " + level + " and a.seclevel <= " + level2 + " and a.departmentid = b.supdepid and b.id = " + thedepartmentid + " and a.status in ( " + statustr + "  ) ";
                    }
                }
                break;
            case 20:
                sql = "select id as customerid,0 as id from CRM_CustomerInfo where  seclevel >= " + level + " and seclevel <= " + level2 + " and type = " + objid;
                break;
            case 21:
                sql = "select id as customerid,0 as id from CRM_CustomerInfo where  seclevel >= " + level + " and seclevel <= " + level2 + " and status = " + objid;
                break;
            case 22:
                sql = "select id as customerid,0 as id from CRM_CustomerInfo where  seclevel >= " + level + " and seclevel <= " + level2 + " and department = " + objid;
                break;
            case 25:
                sql = "select id as customerid,0 as id from CRM_CustomerInfo where  seclevel >= " + level + " and seclevel <= " + level2;
                break;
            /*-----xwj for td1965 20050825 begin----*/
            case 40:            //节点操作者本人，只对人力资源进行了考虑
                //sql = "select 0 as customerid , userid as id from workflow_currentoperator where nodeid = " + objid + " and usertype = 0 and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid+" and (groupdetailid>-1 or groupdetailid is null )";
                //TD9784 chujun 增加对客户为操作者的情况下的判断
                //sql = "select 0 as customerid , userid as id from workflow_currentoperator where nodeid = " + objid + " and usertype = 0 and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid+" and (groupdetailid>-1 or groupdetailid is null )";
                //sql += " union select userid as customerid, 0 as id from workflow_currentoperator where nodeid = " + objid + " and usertype = 1 and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid+" and (groupdetailid>-1 or groupdetailid is null )";
                //TD20827
                //logtype：0，批准；2，提交；3，退回
                sql = "select 0 as customerid, case agenttype  when '2'  then agentorbyagentid else operator end as id from workflow_requestlog where requestid=" + requestid + " and nodeid=" + objid + " and operatortype=0 and (logtype='0' or logtype='2' or logtype='3')";
                sql += " union select operator as customerid, 0 as id from workflow_requestlog where requestid=" + requestid + " and nodeid=" + objid + " and operatortype=1 and (logtype='0' or logtype='2' or logtype='3')";
                //QC151617
                //if(objid == this.nodeid || passNodes.contains(""+objid)){//如果就是当前节点的后续节点使用节点操作者本人，要考虑workflow_requestlog可能还没有被插入数据，所以要加上当前操作人
                if (objid == this.nodeid || passNodes.contains("" + objid) || this.usertype == 1) {//如果就是当前节点的后续节点使用节点操作者本人，要考虑workflow_requestlog可能还没有被插入数据，所以要加上当前操作人
                    if (this.usertype == 0) {//hrm
                        //使用objid兼容异常处理情况，不可用nodeid过滤
                        sql += " union select  0 as customerid ,case agenttype  when '2'  then agentorbyagentid else userid end as id from workflow_currentoperator where nodeid=" + objid + " and userid=" + this.userid + " and usertype = 0 and islasttimes=1 and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid + " and (groupdetailid>-1 or groupdetailid is null ) ";
                    } else {//crm
                        sql += " union select id as customerid,0 as id from CRM_CustomerInfo where id=" + this.userid;
                    }
                }
                //add by liaodong for qc76119,76120,54194,64652 start
                sql += " union select 0 as customerid, case agenttype  when '2'  then agentorbyagentid else operator end as id from workflow_penetrateLog where requestid=" + requestid + " and nodeid=" + objid + " and operatortype=0 and (logtype='0' or logtype='2' or logtype='3' or logtype='z') ";
                //end
                break;
            case 41:
                String userids = getNodeUserIds(rsTemps, objid);
                sql = "select 0 as customerid , managerid as id from " + sqlfrom + " where id in ( " + userids + " ) " + sqlwhere;//xwj for td1965 20050823
                break;

            case 99:
                //相关责任人
                String matrixUserids = getUseridsByMatrix(rs2, groupdetailid);

                if ("".equals(matrixUserids)) {
                    matrixUserids = "-1";
                } else {
                    matrixUserids = matrixUserids.replaceAll(" ", "");
                }

                String matrixUseridsin = Util.getSubINClause(matrixUserids, "id", "in");
                sql = "SELECT 0 as customerid,HrmResource.* FROM HrmResource WHERE ( " + matrixUseridsin + ") and status in(0,1,2,3,5)";
                if ("2".equals(Util.null2String(eh_operatorMap.get("eh_relationship")))) {
                    if (rs.getDBType().equals("oracle")) {
                        sql += " order by instr('," + matrixUserids + ",', ','||id||',')";
                    }
                    else if (rs.getDBType().equals("postgresql")) {
                        sql += " order by instr('," + matrixUserids + ",', ','||id||',')";
                    }
                    else if (rs.getDBType().equals("mysql")) {
                        sql += " order by instr('," + matrixUserids + ",', concat(',',id,','))";
                    } else {
                        sql += " order by charindex(','+ rtrim(id) +',', '," + matrixUserids + ",')";
                    }
                }
                break;
            /*-----xwj for td1965 20050825 end----*/
        }
        returnStrs[0] = sql;
        returnStrs[1] = subcompanyFieldFlag;
        returnStrs[2] = deptFieldFlag;
        returnStrs[3] = theorderbyordervalue;
        return returnStrs;
    }

    private String getNodeUserIds(RecordSet rsTemps, int objid) {
        //节点操作者经理，只对人力资源进行了考虑
        //TD20827，由于已经定义，当初节点是谁操作的，现在就找到谁，如果有代理关系，找被代理人（授权人）
        String userids = "-1";
        //add by liaodong for qc76119,76120,54194,64652 start
        String managerSql = " select operator,agenttype,agentorbyagentid from workflow_requestlog where nodeid = " + objid + " and operatortype=0 and (logtype='0' or logtype='2' or logtype='3') and requestid = " + requestid;
        managerSql += " union select operator,agenttype,agentorbyagentid from workflow_penetrateLog where nodeid = " + objid + " and operatortype=0 and (logtype='0' or logtype='2' or logtype='3' or logtype='z') and requestid = " + requestid;
        rsTemps.execute(managerSql);
        //end
        while (rsTemps.next()) {
            if (!(rsTemps.getString("agenttype")).equals("2") && !(rsTemps.getString("agenttype")).equals(""))
                userids += "," + rsTemps.getString("operator");
            else
                userids += "," + rsTemps.getString("agentorbyagentid");
        }
        // 如果就是当前节点的后续节点使用节点操作者本人，要考虑workflow_requestlog可能还没有被插入数据，所以要加上当前操作人
        if (objid == this.nodeid || passNodes.contains("" + objid)) {
            // 考虑代理
            String execsql = "";
            if (isintervenor.equals("1")) {
                execsql = " select agentorbyagentid,userid,agenttype from workflow_currentoperator where nodeid = " + objid + " and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid + " and (groupdetailid>-1 or groupdetailid is null ) ";
            } else {
                execsql = " select agentorbyagentid,userid,agenttype from workflow_currentoperator where nodeid = " + objid + " and userid=" + this.userid + " and usertype = 0 and (preisremark is null or (preisremark<>'1' and preisremark<>'5' and preisremark<>'8' and preisremark<>'9')) and requestid = " + requestid + " and (groupdetailid>-1 or groupdetailid is null ) ";
            }
            rsTemps.execute(execsql);
            while (rsTemps.next()) {
                if (!(rsTemps.getString("agenttype")).equals("2"))
                    userids += "," + rsTemps.getString("userid");
                else
                    userids += "," + rsTemps.getString("agentorbyagentid");
            }
        } else {
            if ("-1".equals(userids)) {
                String sltNodeOptSql = "";
                if (isintervenor.equals("1")) {
                    sltNodeOptSql = "select userid,agenttype,agentorbyagentid from workflow_currentoperator where nodeid = " + objid + " and usertype=0 and requestid = " + requestid + " and islasttimes=1 and preisremark='0' and isremark in (0,2) order by operatedate desc,operatetime desc, id desc";
                } else {
                    sltNodeOptSql = "select userid,agenttype,agentorbyagentid from workflow_currentoperator where nodeid = " + objid + " and usertype=0 and requestid = " + requestid + " and islasttimes=1 and preisremark='0' and isremark=2 order by operatedate desc,operatetime desc, id desc";
                }
                rsTemps.execute(sltNodeOptSql);
                if (rsTemps.next()) {
                    if (!(rsTemps.getString("agenttype")).equals("2")) {
                        userids += "," + rsTemps.getString("userid");
                    } else {
                        userids += "," + rsTemps.getString("agentorbyagentid");
                    }
                }
            }
        }
        return userids;
    }

    /**
     * 从矩阵取得userid
     *
     * @param rs2
     * @param groupdetailid
     * @return
     */
    public String getUseridsByMatrix(RecordSet rs2, String groupdetailid) {
        GroupDetailMatrix matrix = GroupDetailMatrix.read(rs2, groupdetailid);
        List<GroupDetailMatrixDetail> matrixDetails = GroupDetailMatrixDetail.readAll(rs2, groupdetailid);
        Map<String, String> matchs = new HashMap<String, String>();
        for (GroupDetailMatrixDetail matrixDetail : matrixDetails) {
            String fieldId = matrixDetail.getWorkflow_field();
            String fieldName = "";
            String fieldValue = "";

            //创建人部门
            if ("-12".equals(fieldId)) {
                ResourceComInfo rc = null;
                try {
                    rc = new ResourceComInfo();
                    fieldValue = rc.getDepartmentID("" + creater);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if ("-13".equals(fieldId)) {              //创建人分部
                ResourceComInfo rc = null;
                try {
                    rc = new ResourceComInfo();
                    fieldValue = rc.getSubCompanyID("" + creater);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                if (isbill == 0) {
                    rs2.executeSql("select fieldname from workflow_formdict where id =" + fieldId);
                } else {
                    rs2.executeSql("select fieldname from workflow_billfield where id =" + fieldId);
                }

                if (rs2.next()) {
                    fieldName = rs2.getString("fieldname");
                }

                if (isbill == 0)
                    rs2.executeSql("select " + fieldName + " from workflow_form where requestid=" + requestid);
                else
                    rs2.executeSql("select " + fieldName + " from " + billtablename + " where id = " + billid);

                if (rs2.next()) {
                    fieldValue = Util.null2String(rs2.getString(fieldName));
                }

            }
            matchs.put(matrixDetail.getCondition_field(), fieldValue);
        }
        MatrixUtil matrixUtil = new MatrixUtil();
        String userids = matrixUtil.getMatrixUsers(matrix.getMatrix(), matrix.getValue_field(), matchs);
        if (userids.endsWith(",")) {
            userids = userids.substring(0, userids.length() - 1);
        }

        if (userids.startsWith(",")) {
            userids = userids.substring(1);
        }
        return userids;
    }


    /**
     * 矩阵无符合条件的操作者查询
     *
     * @param rs2
     * @param groupdetailid
     * @return
     */
    private String checkUseridsByMatrix(String groupdetailid) {
        RecordSet temprs = new RecordSet();
        RecordSet rs2 = new RecordSet();
        GroupDetailMatrix matrix = GroupDetailMatrix.read(rs2, groupdetailid);
        List<GroupDetailMatrixDetail> matrixDetails = GroupDetailMatrixDetail.readAll(rs2, groupdetailid);
        String descs = "";
        String msgcontent = "";
        boolean hasvalue = false;
        MatrixUtil mu = new MatrixUtil();
        String dbType = rs2.getDBType();
        String muname = matrix.getMatrixName(mu);
        String fielddesc = matrix.getValueFieldName(mu);
        // 获取 selectValueField 对应的 fieldname
        String selectFieldName = mu.getFieldName(matrix.getValue_field(), rs2);
        StringBuffer condition = new StringBuffer();
        StringBuffer conditions = new StringBuffer();
        String conditionstr = "";
        FormFieldlabelMainManager ffmm = new FormFieldlabelMainManager();
        for (GroupDetailMatrixDetail matrixDetail : matrixDetails) {
            String fieldId = matrixDetail.getWorkflow_field();
            String fieldName = "";
            String fieldValue = "";
            String desc = "";

            //创建人部门
            if ("-12".equals(fieldId)) {
                ResourceComInfo rc = null;
                try {
                    rc = new ResourceComInfo();
                    fieldValue = rc.getDepartmentID("" + creater);
                    fieldValue = ("0".equals(fieldValue)) ? "" : fieldValue;
                    desc = "{126493}{126029}";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if ("-13".equals(fieldId)) {              //创建人分部
                ResourceComInfo rc = null;
                try {
                    rc = new ResourceComInfo();
                    fieldValue = rc.getSubCompanyID("" + creater);
                    fieldValue = ("0".equals(fieldValue)) ? "" : fieldValue;
                    desc = "{126493}{33553}";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                if (isbill == 0) {
                    rs2.executeSql("select fieldname, description from workflow_formdict where id =" + fieldId);
                } else {
                    rs2.executeSql("select fieldname, fieldlabel  from workflow_billfield where id =" + fieldId);
                }

                if (rs2.next()) {
                    fieldName = rs2.getString("fieldname");
                    desc = Util.null2String(rs2.getString(2));
                }

                if (isbill == 0)
                    rs2.executeSql("select " + fieldName + " from workflow_form where requestid=" + requestid);
                else
                    rs2.executeSql("select " + fieldName + " from " + billtablename + " where id = " + billid);

                if (rs2.next()) {
                    fieldValue = Util.null2String(rs2.getString(fieldName));
                }


            }

            if (StringUtil.isNull(fieldValue)) {
                if (isbill == 1) {
                    rs2.execute("select indexdesc from Htmllabelindex where id =" + desc);
                    if (rs2.next()) {
                        desc = Util.null2String(rs2.getString("indexdesc"));
                    }
                } else {
                    ffmm.resetParameter();
                    ffmm.setFormid(formid);
                    ffmm.setFieldid(Util.getIntValue(fieldId, 0));
                    ffmm.setLanguageid(languageid);
                    try {
                        ffmm.selectSingleFormField();
                        desc = ffmm.getFieldlabel();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                descs += desc + "，";
            } else {
                hasvalue = true;
                String matrixfieldid = matrixDetail.getCondition_field();

                Map<String, Map<String, String>> fieldDetail = mu.getFieldDetail(matrix.getMatrix());
                String matrixfieldname = mu.getFieldName(matrixfieldid, rs2);
                Map<String, String> fieldInfo = fieldDetail.get(matrixfieldname);
                String fieldDisplayname = "";
                if (fieldInfo != null) {
                    fieldDisplayname = Util.null2String(fieldInfo.get("namelabel"));
                }

                String selectFieldType = mu.getFieldType(matrixfieldid, rs2);
                String browservalue = "";

                if ("161".equals(selectFieldType) || "162".equals(selectFieldType)) {
                    rs2.execute("select browservalue from MatrixFieldInfo where id=" + matrixfieldid);
                    if (rs2.next()) {
                        browservalue = rs2.getString(1);
                    }
                }


                if ("162".equals(selectFieldType)) {
                    if ("oracle".equals(dbType)) {
                        condition.append(" and ','||").append(matrixfieldname).append("||',' like ").append("'%,").append(fieldValue).append(",%' ");
                    }
                    else if ("postgresql".equals(dbType)) {
                        condition.append(" and ','||").append(matrixfieldname).append("||',' like ").append("'%,").append(fieldValue).append(",%' ");
                    }
                    else if (dbType.equals("mysql")) {
                        condition.append(" and concat(',',").append(matrixfieldname).append(",',') like ").append("'%,").append(fieldValue).append(",%' ");
                    } else if ("sqlserver".equals(dbType)) {
                        condition.append(" and ','+").append(matrixfieldname).append("+',' like ").append("'%,").append(fieldValue).append(",%' ");
                    }
                } else {
                    String[] values = fieldValue.split(",");
                    String valueStr = "";
                    int j = 0;
                    for (int i = 0; i < values.length; i++) {
                        if ("".equals(values[i].trim())) {
                            continue;
                        }
                        if (j > 0) {
                            valueStr += ",";
                        }
                        valueStr += "'" + values[i] + "'";
                        j++;
                    }
                    condition.append(" and ").append(matrixfieldname).append(" in ").append("(").append(valueStr).append(")");
                }

                rs2.execute("select " + selectFieldName + " from " + mu.MATRIXPREFIX + matrix.getMatrix() + " where 1=1 " + condition.toString());
                if (!rs2.next()) {
                    String fieldvaluedesc = getFieldValueDesc(fieldValue, selectFieldType, browservalue);
                    conditionstr += WorkflowRequestMessage.getBoldDetailInfo(fieldDisplayname) + "{15808}" + WorkflowRequestMessage.getBoldDetailInfo(fieldvaluedesc);
                }
                conditions.append(condition);
            }

        }
        if (!hasvalue) {
            if (descs.length() > 0) {
                descs = descs.substring(0, descs.length() - 1);
            }
            msgcontent = "{21740}" + WorkflowRequestMessage.getBoldDetailInfo(descs) + "{126520}";
        } else {
            boolean hasUser = false;
            String sql = "select " + selectFieldName + " from " + mu.MATRIXPREFIX + matrix.getMatrix() + " where 1=1 " + conditions.toString();
            rs2.execute(sql);
            String lastnames = "";
            while (rs2.next()) {
                String id = rs2.getString(1);
                if (checkidvalid(Util.null2String(id))) {
                    hasUser = true;
                    String lastname = getLastnameByUserStatus(id);
                    if (StringUtil.isNotNull(lastname)) {
                        lastnames += lastname + "，";
                    }
                }
            }

            if (!hasUser) {
                if (rs2.getCounts() == 0) {
                    if (conditionstr.length() > 1) {
                        msgcontent = "{34066}" + WorkflowRequestMessage.getBoldDetailInfo(muname) + "{126530}" + conditionstr;
                    }
                } else {
                    msgcontent = "{34066}" + WorkflowRequestMessage.getBoldDetailInfo(muname) + "{126530}" + WorkflowRequestMessage.getBoldDetailInfo(fielddesc) + "{15808}{125212}";
                }
            } else {
                if (lastnames.length() > 0) {
                    lastnames = lastnames.substring(0, lastnames.length() - 1);
                    msgcontent = "{34066}" + WorkflowRequestMessage.getBoldDetailInfo(muname) + "{126526}" + WorkflowRequestMessage.getBoldDetailInfo(fielddesc) + WorkflowRequestMessage.getBoldInfo(lastnames) + "{126527}";
                }
            }
        }
        return msgcontent;

    }

    /**
     * 矩阵-获取表单值对应中文名称
     *
     * @param fieldValue
     * @param selectFieldType
     * @return
     */
    private String getFieldValueDesc(String fieldValue, String selectFieldType, String browservalue) {
        String fieldvaluedesc = "";
        if ("4".equals(selectFieldType)) {//部门
            try {
                DepartmentComInfo dci = new DepartmentComInfo();
                fieldvaluedesc = dci.getDepartmentname(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if ("164".equals(selectFieldType)) {//分部
            try {
                SubCompanyComInfo sci = new SubCompanyComInfo();
                fieldvaluedesc = sci.getSubCompanyname(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }

        } else if ("1".equals(selectFieldType)) {//人力资源
            try {
                ResourceComInfo rci = new ResourceComInfo();
                fieldvaluedesc = rci.getLastname(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }

        } else if ("7".equals(selectFieldType)) {//客户
            try {
                CustomerInfoComInfo cici = new CustomerInfoComInfo();
                fieldvaluedesc = cici.getCustomerInfoname(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if ("8".equals(selectFieldType)) {//项目
            try {
                ProjectInfoComInfo pici = new ProjectInfoComInfo();
                fieldvaluedesc = pici.getProjectInfoname(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if ("161".equals(selectFieldType) || "162".equals(selectFieldType)) {//自定义单选
            Browser browser = (Browser) StaticObj.getServiceByFullname(browservalue, Browser.class);
            for (String _v : fieldValue.split(",")) {
                BrowserBean bb = browser.searchById(_v);
                fieldvaluedesc += bb.getName() + "，";
            }
            if (fieldvaluedesc.length() > 0) {
                fieldvaluedesc = fieldvaluedesc.substring(0, fieldvaluedesc.length() - 1);
            }
        } else if ("24".equals(selectFieldType)) {//岗位
            try {
                JobComInfo jci = new JobComInfo();
                fieldvaluedesc = jci.getJobName(fieldValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return fieldvaluedesc;
    }

    /**
     * 判断是否符合条件
     *
     * @param conditions
     * @param rs
     * @param gourpid
     * @return
     */
    protected boolean isConformConditions(String conditions, RecordSet rs, String groupdetailid,Map<String,Object> groupDetailLog) {
        boolean isConform = false;
        //在每一批次必须符合条件才能取得操作者
        String tempSql = "";
        conditions = Util.StringReplace(conditions, "’", "'");
        if (conditions.indexOf(".") >= 0 || conditions.indexOf("(") >= 0) {
            if (isbill == 0) {
                if (!conditions.trim().equals(""))
                    tempSql = "select requestid from workflow_form where requestid=" + requestid + " and " + conditions;
                else
                    tempSql = "select requestid from workflow_form where requestid=" + requestid;
            } else {
                if (!conditions.trim().equals(""))
                    tempSql = "select requestid from " + billtablename + " where requestid=" + requestid + " and " + conditions;
                else
                    tempSql = "select requestid from " + billtablename + " where requestid=" + requestid;
            }
            if (conditions.equals("")) {
                isConform = true;
            } else {
                rs.execute(tempSql);
                if (rs.next()) {
                    isConform = true;
                }
            }
        } else {
            RuleInterface rif = new RuleInterface();
            rif.setUserid(this.userid + "");
            rif.setAutoForecast(this.autoForecast);
            rif.setForecastManagerInfo(this.forecastManagerInfo);
            rif.setRulesInfo(groupDetailLog);
            boolean cop = rif.compareRuleforWF(conditions, requestid + "", groupdetailid + "", RuleInterface.RULESRC_PC);
            isConform = cop;
        }
        return isConform;
    }


    /**
     * 获取依次逐个提交操作人
     *
     * @param type
     * @param rs2
     * @param theorderbyordervalue
     * @return
     */
    private String getOperatoridByType(int type, RecordSet rs2, String theorderbyordervalue, String subcompanyFieldFlag, String deptFieldFlag) {
        if (type == 42 && "1".equals(deptFieldFlag)) {
            String tempoperatorid = "";
            ArrayList tempdeptids = Util.TokenizerString(theorderbyordervalue, ",");
            for (int i = 0; i < tempdeptids.size(); i++) {
                rs2.beforFirst();
                while (rs2.next()) {
                    if (Util.null2String(rs2.getString("departmentid")).equals(tempdeptids.get(i))) {
                        if (tempoperatorid.equals("")) {
                            tempoperatorid = rs2.getString("id");
                        } else {
                            tempoperatorid += "," + rs2.getString("id");
                        }
                    }
                }
            }
            theorderbyordervalue = tempoperatorid;
        }
        if (type == 42 && "2".equals(deptFieldFlag)) {//部门自定义字段,类似之前组织架构部门负责人 功能
            String tempoperatorid = "";
            rs2.beforFirst();
            ResourceComInfo rc = null;
            try {
                rc = new ResourceComInfo();
            } catch (Exception e) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"type=42=resourceConinfo=e="+e);
                //writeLog(e);
            }
            while (rs2.next()) {
                String bmczr = Util.null2String(rs2.getString("id"));//部门操作人
                String bmczrs[] = Util.TokenizerString2(bmczr, ",");
                for (int i = 0; i < bmczrs.length; i++) {
                    int tempbmoperator = Util.getIntValue(bmczrs[i], 0);//单个操作人
                    String tempstatus = Util.null2String(rc.getStatus(String.valueOf(tempbmoperator)));//操作人状态
                    if (!tempstatus.equals("0") && !tempstatus.equals("1") && !tempstatus.equals("2") && !tempstatus.equals("3")) {
                        continue;
                    }
                    if (tempbmoperator == 0 || ("," + tempoperatorid + ",").indexOf("," + tempbmoperator + ",") >= 0) {//已经添加的人，不再添加
                        continue;
                    }
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = String.valueOf(tempbmoperator);
                    } else {
                        tempoperatorid += "," + tempbmoperator;
                    }
                }
            }
            theorderbyordervalue = tempoperatorid;
        }
        if (type == 51 && "1".equals(subcompanyFieldFlag)) {
            String tempoperatorid = "";
            ArrayList tempdeptids = Util.TokenizerString(theorderbyordervalue, ",");
            for (int i = 0; i < tempdeptids.size(); i++) {
                rs2.beforFirst();
                while (rs2.next()) {
                    if (Util.null2String(rs2.getString("subcompanyid1")).equals(tempdeptids.get(i))) {
                        if (tempoperatorid.equals("")) {
                            tempoperatorid = rs2.getString("id");
                        } else {
                            tempoperatorid += "," + rs2.getString("id");
                        }
                    }
                }
            }
            theorderbyordervalue = tempoperatorid;
        }
        if (type == 51 && "2".equals(subcompanyFieldFlag)) {//分部自定义字段,类似之前组织架构部门负责人 功能
            String tempoperatorid = "";
            rs2.beforFirst();
            ResourceComInfo rc = null;
            try {
                rc = new ResourceComInfo();
            } catch (Exception e) {
                //writeLog(e);
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"=type51=resourceConinfo=e="+e);
            }
            while (rs2.next()) {
                String bmczr = Util.null2String(rs2.getString("id"));//分部操作人
                String bmczrs[] = Util.TokenizerString2(bmczr, ",");
                for (int i = 0; i < bmczrs.length; i++) {
                    int tempbmoperator = Util.getIntValue(bmczrs[i], 0);//单个操作人
                    String tempstatus = Util.null2String(rc.getStatus(String.valueOf(tempbmoperator)));//操作人状态
                    if (!tempstatus.equals("0") && !tempstatus.equals("1") && !tempstatus.equals("2") && !tempstatus.equals("3")) {
                        continue;
                    }
                    if (tempbmoperator == 0 || ("," + tempoperatorid + ",").indexOf("," + tempbmoperator + ",") >= 0) {//已经添加的人，不再添加
                        continue;
                    }
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = String.valueOf(tempbmoperator);
                    } else {
                        tempoperatorid += "," + tempbmoperator;
                    }
                }
            }
            theorderbyordervalue = tempoperatorid;
        }
        if (type == 52 || type == 53 || type == 54 || type == 55 || type == 56 || type == 57) {//组织架构部门负责人,组织架构部门分管领导,矩阵管理部门负责人,矩阵管理部门分管领导,部门负责人,部门分管领导
            String tempoperatorid = "";
            rs2.beforFirst();
            ResourceComInfo rc = null;
            try {
                rc = new ResourceComInfo();
            } catch (Exception e) {
                log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestid+"type=resourceConinfo=e="+e);
                //writeLog(e);
            }
            while (rs2.next()) {
                String bmczr = Util.null2String(rs2.getString("id"));//部门操作人
                String bmczrs[] = Util.TokenizerString2(bmczr, ",");
                for (int i = 0; i < bmczrs.length; i++) {
                    int tempbmoperator = Util.getIntValue(bmczrs[i], 0);//单个操作人
                    String tempstatus = Util.null2String(rc.getStatus(String.valueOf(tempbmoperator)));//操作人状态
                    if (!tempstatus.equals("0") && !tempstatus.equals("1") && !tempstatus.equals("2") && !tempstatus.equals("3")) {
                        continue;
                    }
                    if (tempbmoperator == 0 || ("," + tempoperatorid + ",").indexOf("," + tempbmoperator + ",") >= 0) {//已经添加的人，不再添加
                        continue;
                    }
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = String.valueOf(tempbmoperator);
                    } else {
                        tempoperatorid += "," + tempbmoperator;
                    }
                }
            }
            theorderbyordervalue = tempoperatorid;
        } else if (type == 49 || type == 6 || type == 31 || type == 32 || type == 7 || type == 38 || type == 30 || type == 1 || type == 2 || type == 3 || type == 4 || type == 58 || type == 59 || type == 60 || type == 61) {
            String tempoperatorid = "";
            rs2.beforFirst();
            List<String> list = new ArrayList<String>();
            while (rs2.next()) {
                String tempid = rs2.getString("id");
                if (!list.contains(tempid)) {
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = tempid;
                    } else {
                        tempoperatorid += "," + tempid;
                    }
                }
                list.add(tempid);
            }
            theorderbyordervalue = tempoperatorid;
        } else if (type == 43) { // 人力资源字段 > 角色(条件)
            String tempSQL = "";
            ArrayList byOrderList = new ArrayList();
            MultiHrmCompositorOrderBean orderBean = null;
            String tempoperatorid = "";
            //总部
            tempSQL = sql + " and a.rolelevel = 2 order by  idorder  asc";

            byOrderList = roleOrderOperate(tempSQL, theorderbyordervalue);
            for (int i = 0; i < byOrderList.size(); i++) {
                orderBean = (MultiHrmCompositorOrderBean) byOrderList.get(i);
                if (tempoperatorid.equals("")) {
                    tempoperatorid = orderBean.getHrmId();
                } else {
                    tempoperatorid += "," + orderBean.getHrmId();
                }
            }

            //分部
            tempSQL = sql + " and a.rolelevel = 1 order by  idorder  asc";

            byOrderList = roleOrderOperate(tempSQL, theorderbyordervalue);
            for (int i = 0; i < byOrderList.size(); i++) {
                orderBean = (MultiHrmCompositorOrderBean) byOrderList.get(i);
                if (tempoperatorid.equals("")) {
                    tempoperatorid = orderBean.getHrmId();
                } else {
                    tempoperatorid += "," + orderBean.getHrmId();
                }
            }

            //部门
            tempSQL = sql + " and a.rolelevel = 0 order by  idorder  asc";

            byOrderList = roleOrderOperate(tempSQL, theorderbyordervalue);
            for (int i = 0; i < byOrderList.size(); i++) {
                orderBean = (MultiHrmCompositorOrderBean) byOrderList.get(i);
                if (tempoperatorid.equals("")) {
                    tempoperatorid = orderBean.getHrmId();
                } else {
                    tempoperatorid += "," + orderBean.getHrmId();
                }
            }
            theorderbyordervalue = tempoperatorid;
        } else if (type == 40 || type == 41 || type == 17 || type == 18 || type == 36 || type == 37 || type == 19 || type == 39 || type == 48 || type == 99) {
            String tempoperatorid = "";
            while (rs2.next()) {
                int tepoperatorid = Util.getIntValue(rs2.getString("id"), 0);
                int tepoperatorcrmid = Util.getIntValue(rs2.getString("customerid"), 0);
                if (tepoperatorid != 0) {
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = "" + tepoperatorid;
                    } else {
                        tempoperatorid += "," + tepoperatorid;
                    }
                } else if (tepoperatorcrmid != 0) {
                    if (tempoperatorid.equals("")) {
                        tempoperatorid = "" + tepoperatorcrmid;
                    } else {
                        tempoperatorid += "," + tepoperatorcrmid;
                    }
                } else {
                    continue;
                }
            }

            theorderbyordervalue = tempoperatorid;
        }
        return theorderbyordervalue;
    }


    //获取操作者
    public String getObjName(int type, int objid, int bhxj, int language, int virtualid, int level, int detailid, boolean addvirtualname) {
        String objname = "";
        if (type == 1 || type == 22) {
            try {
                DepartmentComInfo dc = new DepartmentComInfo();
                objname = dc.getDepartmentname("" + objid);
                if (bhxj == 1) {
                    objname += "[" + SystemEnv.getHtmlLabelName(125943, language) + "]";
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } else if (type == 2) {
            RecordSet _rs = new RecordSet();
            _rs.executeSql("select rolesmark from hrmroles where id = " + objid);
            if (_rs.next()) {
                objname = _rs.getString(1);
            }
        } else if (type == 3) {
            //人力资源缓存 不好使，部分人员根据id获取不到。本次先查询一下，后续缓存类好使了在缓存缓存获取
            RecordSet _rs = new RecordSet();
            _rs.executeSql(" select lastname,id from  hrmresource where   id in(select objid from Workflow_HrmOperator where groupdetailid='" + detailid + "' ) ");
            if (_rs.next()) {
                objname = Util.null2String(_rs.getString("lastname"));
            }
        } else if (type == 5 || type == 49 || type == 6 || type == 7 || type == 8 || type == 9 || type == 10 ||
                type == 11 || type == 12 || type == 13 || type == 14 || type == 15 || type == 16 || type == 23 ||
                type == 24 || type == 31 || type == 32 || type == 33 || type == 34 || type == 35 || type == 38 ||
                type == 42 || type == 52 || type == 53 || type == 54 || type == 55 || type == 56 || type == 57 ||
                type == 43 || type == 44 || type == 45 || type == 46 || type == 47 || type == 48 || type == 51) {
            objname = getGroupDetailObjName(objid, language);
            if (addvirtualname) {
                String virtualname = WorkflowRequestMessage.getVirtualname(virtualid, language);
                if (!"".equals(objname) && !"".equals(virtualname)) {
                    objname += ("".equals(virtualname) ? virtualname : "(" + virtualname + ")");
                }
            }
        } else if (type == 20) {
            try {
                CustomerTypeComInfo ctc = new CustomerTypeComInfo();
                objname = Util.toScreen(ctc.getCustomerTypename("" + objid), language);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (type == 21) {
            try {
                CustomerStatusComInfo csc = new CustomerStatusComInfo();
                objname = Util.toScreen(csc.getCustomerStatusname("" + objid), language);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (type == 30) {
            try {
                SubCompanyComInfo scc = new SubCompanyComInfo();
                objname = scc.getSubCompanyname("" + objid);
                if (bhxj == 1) {
                    objname += "[" + SystemEnv.getHtmlLabelName(84674, language) + "]";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (type == 40 || type == 41) {
            RecordSet _rs = new RecordSet();
            _rs.executeQuery("select b.nodename from workflow_flownode a,workflow_nodebase b where a.nodeid = b.id and b.id = ?", objid);
            if (_rs.next()) {
                String nodename = _rs.getString(1);
                if (!"".equals(nodename)) {
                    String nodevirtualname = WorkflowRequestMessage.getVirtualname(virtualid, language);
                    objname = nodename + (nodevirtualname == "" ? nodevirtualname : "(" + nodevirtualname + ")");
                }
            }
        } else if (type == 50) {
            objname = getGroupDetailObjName(objid, language);
            if (!"".equals(objname)) {
                try {
                    RolesComInfo rc = new RolesComInfo();
                    objname += "/" + rc.getRolesRemark("" + level);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else if (type == 99) {
            RecordSet _rs = new RecordSet();
            GroupDetailMatrix matrix = GroupDetailMatrix.read(_rs, String.valueOf(detailid));
            if (matrix != null) {
                MatrixUtil matrixUtil = new MatrixUtil();
                objname = matrix.getMatrixName(matrixUtil) + "(" + matrix.getValueFieldName(matrixUtil) + ")";
            }
        }
        return objname;

    }

    /**
     * 或缺操作级别
     *
     * @param type
     * @param level
     * @param level2
     * @param deptField
     * @param subcompanyField
     * @return
     */
    private String getLevelStr(int type, int level, int level2, String deptField, String subcompanyField) {
        String _levelstr = "";
        if (type == 1 || type == 4 || type == 7 || type == 9 || type == 11 || type == 12 ||
                type == 14 || type == 19 || type == 20 || type == 21 || type == 22 ||
                type == 23 || type == 25 || type == 30 || type == 31 || type == 32 ||
                type == 33 || type == 34 || type == 35 || type == 36 || type == 37 ||
                type == 38 || type == 39 || type == 45 || type == 46) {
            if (level2 > 0) {
                _levelstr = level + "-" + level2;
            } else {
                _levelstr = ">=" + level;
            }
        } else if (type == 2) {
            if (level == 0) {
                _levelstr = SystemEnv.getHtmlLabelName(124, languageid);
            } else if (level == 1) {
                _levelstr = SystemEnv.getHtmlLabelName(141, languageid);
            } else if (level == 2) {
                _levelstr = SystemEnv.getHtmlLabelName(140, languageid);
            } else if (level == 3) {
                _levelstr = SystemEnv.getHtmlLabelName(22753, languageid);
            }
        } else if (type == 50) {
            if (level2 == 1) {
                _levelstr = SystemEnv.getHtmlLabelName(22689, languageid);
            } else if (level2 == 2) {
                _levelstr = SystemEnv.getHtmlLabelName(22690, languageid);
            } else if (level2 == 3) {
                _levelstr = SystemEnv.getHtmlLabelName(22667, languageid);
            } else {
                _levelstr = SystemEnv.getHtmlLabelName(140, languageid);
            }
        } else if (type == 42) {
            if ("0".equals(deptField) || "".equals(deptField)) {//说明下拉框中选择的是安全级别
                if (level2 != -1) {
                    _levelstr = level + "-" + level2;
                } else {
                    _levelstr = ">=" + level;
                }
            } else {//说明下拉框中选择的是部门自定义字段 deptField该字段存储值个格式id_fieldname_fieldlabel
                if (deptField != null && !"".equals(deptField)) {
                    String[] tempStr = Util.TokenizerString2(deptField, "[_]");
                    if (tempStr != null && tempStr.length > 2) {
                        String fieldlabelStr = tempStr[2];
                        int fieldlabel = Util.getIntValue(fieldlabelStr, 0);
                        _levelstr = SystemEnv.getHtmlLabelName(fieldlabel, languageid);
                    }
                }
            }
        } else if (type == 51) {
            if ("0".equals(subcompanyField) || "".equals(subcompanyField)) {//说明下拉框中选择的是安全级别
                if (level2 != -1) {
                    _levelstr = level + "-" + level2;
                } else {
                    _levelstr = ">=" + level;
                }
            } else {//说明下拉框中选择的是分部自定义字段subcompanyField该字段存储值个格式id_fieldname_fieldlabel
                if (subcompanyField != null && !"".equals(subcompanyField)) {
                    String[] tempStr = Util.TokenizerString2(subcompanyField, "[_]");
                    if (tempStr != null && tempStr.length > 2) {
                        String fieldlabelStr = tempStr[2];
                        int fieldlabel = Util.getIntValue(fieldlabelStr, 0);
                        _levelstr = SystemEnv.getHtmlLabelName(fieldlabel, languageid);
                    }
                }
            }
        }

        return _levelstr;
    }

    /**
     * 返回流程操作者查询不到的具体原因
     *
     * @param type
     * @param nodetype
     * @param signorder
     * @param virtualid
     * @param language
     * @param objid
     * @param bhxj
     * @param level
     * @param detailid
     * @param level2
     * @param deptField
     * @param subcompanyField
     * @return
     * @throws Exception
     */
    private String getErrorMessageContent(int type, String nodetype, int signorder, int virtualid, int language, int objid, int bhxj, int level, int detailid, int level2, String deptField, String subcompanyField) throws Exception {
        String typename = WorkflowRequestMessage.getTypeName(type, nodetype, signorder, virtualid, language);
        String objname = WorkflowRequestMessage.getBoldDetailInfo(this.getObjName(type, objid, bhxj, language, virtualid, level, detailid, true));
        String levelstr = WorkflowRequestMessage.getBoldDetailInfo(this.getLevelStr(type, level, level2, deptField, subcompanyField));
        String virtualname = WorkflowRequestMessage.getVirtualname(virtualid, language);
        String msgcontent = "";
        String objnameisnullmsg = typename + "{23084}";
        StringBuffer sb = new StringBuffer();
        ResourceComInfo rci = null; //人员缓存
        SubCompanyComInfo scci = null; //分部缓存
        DepartmentComInfo dci = null;    //部门缓存
        RolesComInfo roleci = null;//角色缓存类
        DocReceiveUnitComInfo druci = null; //收发单位缓存
        MeetingComInfo mci = null;//会议室缓存
        ProjectInfoComInfo pici = null;//项目缓存
        CustomerInfoComInfo cici = null;//客户缓存

        RecordSet msgrs;
        switch (type) {
            case 30: //分部
            case 1:  //部门
                msgcontent = (StringUtil.isNotNull(objname)) ? typename + objname + "{83230}{683}" + levelstr + "{126522}" : objnameisnullmsg;
                break;
            case 2:  //角色
                HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
                String roleMemberids = hrmCommonService.getRoleMemberIds(objid, level == 2 ? "2" : (level == 1 || level == 3) ? "1" : "0");
                if (!"".equals(roleMemberids)) {
                    String levelname = "";
                    if (level == 0) {
                        levelname = "{126523}";
                    } else if (level == 1) {
                        levelname = "{126524}";
                    } else if (level == 2) {
                        levelname = "{140}";
                    } else if (level == 3) {
                        levelname = "{126525}";
                    }
                    msgcontent = "{122}" + objname + "{83230}" + levelname + "{139}{126526}{18936}";
                } else {
                    msgcontent = "{122}" + objname + "{15808}{18936}";
                }
                break;
            case 3: //人力资源
                rci = new ResourceComInfo();
                msgcontent = WorkflowRequestMessage.getBoldInfo(rci.getLastname(String.valueOf(objid))) + "{126527}";
                break;
            case 4: //所有人
                msgcontent = "{83230}{683}" + levelstr + "{126522}";
                break;
            case 51:
            case 42:
            case 31:
            case 32:
            case 7:
            case 38:
            case 9:
            case 33:
            case 34:
            case 11:
            case 12:
            case 14:
            case 35:
            case 45:
            case 46:
            case 43:
            case 49:
            case 48:
            case 6:
            case 5:
            case 8:
            case 10:
            case 47:
            case 13:
            case 15:
            case 44:
            case 16:
            case 50:
                if (StringUtil.isNull(cachefieldvalue)) {
                    objname = WorkflowRequestMessage.getBoldDetailInfo(this.getObjName(type, objid, bhxj, language, virtualid, level, detailid, false));
                    msgcontent = "{21740}" + objname + "{126520}";
                } else {
                    String filedvaluename = "";
                    switch (type) {
                        case 51: //人力资源字段-分部
                            String subcomname = getSubCompanyName(virtualid, cachefieldvalue);
                            msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(addVirturalname(virtualname, subcomname)) + "{83230}{683}" + levelstr + "{126522}";
                            break;
                        case 42: //人力资源字段-部门
                            String depname = getDepartVirtualName(virtualid, cachefieldvalue);
                            depname = addVirturalname(virtualname, depname);
                            msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(depname) + "{83230}{683}" + levelstr + "{126522}";
                            break;
                        case 31: //人力资源字段下属
                            rci = new ResourceComInfo();
                            filedvaluename = rci.getLastnames(cachefieldvalue);
                            msgcontent = WorkflowRequestMessage.getBoldInfo(addVirturalname(virtualname, filedvaluename)) + "{126528}" + levelstr + "{126522}";
                            break;
                        case 32: //人力资源字段本分部
                            String subcompanyid = "";
                            rci = new ResourceComInfo();
                            if (virtualid < -1) {
                                String[] reInfo = getResourceVirtualInfos(virtualid, cachefieldvalue);
                                subcompanyid = reInfo[2];
                            } else {
                                subcompanyid = rci.getSubCompanyID(cachefieldvalue);
                            }
                            filedvaluename = rci.getLastname(cachefieldvalue);
                            if (checkidvalid(subcompanyid)) {
                                String subcompanyname = getSubCompanyName(virtualid, subcompanyid);
                                subcompanyname = addVirturalname(virtualname, subcompanyname);
                                msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(subcompanyname) + "{83230}{683}" + levelstr + "{126522}";
                            } else {
                                filedvaluename = addVirturalname(virtualname, filedvaluename);
                                msgcontent = WorkflowRequestMessage.getBoldInfo(filedvaluename) + "{83230}{19799}";
                            }
                            break;
                        case 7:  //人力资源字段本部门
                            rci = new ResourceComInfo();
                            filedvaluename = rci.getLastname(cachefieldvalue);
                            String decid = "";
                            if (virtualid < -1) {
                                String[] reInfo = getResourceVirtualInfos(virtualid, cachefieldvalue);
                                decid = reInfo[1];
                            } else {
                                decid = rci.getDepartmentID(cachefieldvalue);
                            }
                            if (checkidvalid(decid)) {
                                String dciname = getDepartVirtualName(virtualid, decid);
                                filedvaluename = addVirturalname(virtualname, dciname);
                                msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(dciname) + "{83230}{683}" + levelstr + "{126522}";
                            } else {
                                filedvaluename = addVirturalname(virtualname, filedvaluename);
                                msgcontent = WorkflowRequestMessage.getBoldInfo(filedvaluename) + "{83230}{15393}";
                            }
                            break;
                        case 38: //人力资源字段上级部门
                            rci = new ResourceComInfo();
                            filedvaluename = rci.getLastname(cachefieldvalue);
                            String decid1 = "";
                            if (virtualid < -1) {
                                String[] reInfo = getResourceVirtualInfos(virtualid, cachefieldvalue);
                                decid1 = reInfo[1];
                            } else {
                                decid1 = rci.getDepartmentID(cachefieldvalue);
                            }
                            if (checkidvalid(decid1)) {
                                String supdciid = getSupdepartmentID(virtualid, decid1);
                                if (checkidvalid(supdciid)) {
                                    String supdciname = getDepartVirtualName(virtualid, supdciid);
                                    filedvaluename = addVirturalname(virtualname, supdciname);
                                    msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(supdciname) + "{83230}{683}" + levelstr + "{126522}";
                                } else {
                                    String decid1name = getDepartVirtualName(virtualid, decid1);
                                    filedvaluename = addVirturalname(virtualname, decid1name);
                                    msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(decid1name) + "{83230}{15772}";
                                }
                            } else {
                                filedvaluename = addVirturalname(virtualname, filedvaluename);
                                msgcontent = WorkflowRequestMessage.getBoldInfo(filedvaluename) + "{83230}{15393}";
                            }
                            break;
                        case 9:  //文档字段部门
                            msgrs = new RecordSet();
                            msgrs.execute("select docdepartmentid,docsubject from DocDetail where id = " + cachefieldvalue);
                            String docdepartmentiddp = "";
                            String docsubjectdp = "";
                            if (msgrs.next()) {
                                docdepartmentiddp = msgrs.getString(1);
                                docsubjectdp = msgrs.getString(2);
                            }

                            if (checkidvalid(docdepartmentiddp)) {
                                dci = new DepartmentComInfo();
                                String dpname = dci.getDepartmentname(docdepartmentiddp);
                                msgcontent = "{126529}{15393}" + WorkflowRequestMessage.getBoldDetailInfo(dpname) + "{83230}{683}" + levelstr + "{126522}";
                            } else {
                                msgcontent = "{126529}" + WorkflowRequestMessage.getBoldDetailInfo(docsubjectdp) + "{83230}{15393}";
                            }
                            break;
                        case 33:
                            msgrs = new RecordSet();
                            msgrs.execute("select docdepartmentid,docsubject from DocDetail where id = " + cachefieldvalue);
                            String docdepartmentid = "";
                            String docsubject = "";
                            if (msgrs.next()) {
                                docdepartmentid = msgrs.getString(1);
                                docsubject = msgrs.getString(2);
                            }
                            dci = new DepartmentComInfo();
                            String docsubcompanyid1 = dci.getSubcompanyid1(docdepartmentid);
                            if (checkidvalid(docsubcompanyid1)) {
                                scci = new SubCompanyComInfo();
                                msgcontent = "{126529}{83562}{19799}" + WorkflowRequestMessage.getBoldDetailInfo(scci.getSubcompanyname(docsubcompanyid1)) + "{83230}{683}" + levelstr + "{126522}";
                            } else {
                                msgcontent = "{126529}" + WorkflowRequestMessage.getBoldDetailInfo(docsubject) + "{83230}{19799}";
                            }
                            break;
                        case 34: //项目字段分部
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT department,manager FROM Prj_ProjectInfo WHERE id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String xmfbdepart = Util.null2String(msgrs.getString(1));
                                String xmfbmanager = Util.null2String(msgrs.getString(2));
                                if (checkidvalid(xmfbdepart)) {
                                    dci = new DepartmentComInfo();
                                    String xmfbspid = dci.getSubcompanyid1(xmfbdepart);
                                    if (checkidvalid(xmfbspid)) {
                                        scci = new SubCompanyComInfo();
                                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(scci.getSubcompanyname(xmfbspid)) + "{83230}{683}" + levelstr + "{126522}";
                                    } else {
                                        rci = new ResourceComInfo();
                                        msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(xmfbmanager)) + "{83230}{19799}";
                                    }
                                } else {
                                    rci = new ResourceComInfo();
                                    msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(xmfbmanager)) + "{83230}{19799}";
                                }
                            }
                            break;
                        case 11: //项目字段部门
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT department,manager FROM Prj_ProjectInfo WHERE id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String xmbmdepart = Util.null2String(msgrs.getString(1));
                                String xmbmmanager = Util.null2String(msgrs.getString(2));
                                rci = new ResourceComInfo();
                                if (checkidvalid(xmbmdepart)) {
                                    dci = new DepartmentComInfo();
                                    msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(dci.getDepartmentname(xmbmdepart)) + "{83230}{683}" + levelstr + "{126522}";
                                } else {
                                    rci = new ResourceComInfo();
                                    msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(xmbmmanager)) + "{83230}{15393}";
                                }
                            }
                            break;
                        case 12: //项目字段成员
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT members FROM Prj_ProjectInfo WHERE id =" + cachefieldvalue);
                            if (msgrs.next()) {
                                String members = Util.null2String(msgrs.getString(1));
                                pici = new ProjectInfoComInfo();
                                String projectname = pici.getProjectInfoname(cachefieldvalue);
                                if (checkidvalid(members)) {
                                    msgcontent = "{30046}" + WorkflowRequestMessage.getBoldDetailInfo(projectname) + "{126526}{30046}{125212}{126530}{83230}{683}" + levelstr + "{126522}";
                                } else {
                                    msgcontent = "{30046}" + WorkflowRequestMessage.getBoldDetailInfo(projectname) + "{83230}{30046}{125212}";
                                }
                            }
                            break;
                        case 14: //资产字段部门
                            msgrs = new RecordSet();
                            msgrs.execute("select departmentid,name from CptCapital where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String zcbm = Util.null2String(msgrs.getString(1));
                                String zcmc = Util.null2String(msgrs.getString(2));
                                rci = new ResourceComInfo();
                                if (checkidvalid(zcbm)) {
                                    dci = new DepartmentComInfo();
                                    msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(dci.getDepartmentname(zcbm)) + "{83230}{683}" + levelstr + "{126522}";
                                } else {
                                    msgcontent = "{30044}" + WorkflowRequestMessage.getBoldDetailInfo(zcmc) + "{83230}{15393}";
                                }
                            }
                            break;
                        case 35: //资产字段分部
                            msgrs = new RecordSet();
                            msgrs.execute("select departmentid,name from CptCapital where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String zcbm = Util.null2String(msgrs.getString(1));
                                String zcmc = Util.null2String(msgrs.getString(2));
                                if (checkidvalid(zcbm)) {
                                    dci = new DepartmentComInfo();
                                    String zcfb = dci.getSubcompanyid1(zcbm);
                                    if (checkidvalid(zcfb)) {
                                        scci = new SubCompanyComInfo();
                                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(scci.getSubcompanyname(zcfb)) + "{83230}{683}" + levelstr + "{126522}";
                                    } else {
                                        msgcontent = "{30044}" + WorkflowRequestMessage.getBoldDetailInfo(zcmc) + "{83230}{19799}";
                                    }
                                } else {
                                    rci = new ResourceComInfo();
                                    msgcontent = "{30044}" + WorkflowRequestMessage.getBoldDetailInfo(zcmc) + "{83230}{15393}";
                                }
                            }
                            break;
                        case 45: //客户字段分部
                            //客户管理员所属分部
                            msgrs = new RecordSet();
                            msgrs.execute("select manager from CRM_CustomerInfo where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String crmmanager = Util.null2String(msgrs.getString(1));
                                if (checkidvalid(crmmanager)) {
                                    rci = new ResourceComInfo();
                                    String crmscciid = rci.getSubCompanyID(crmmanager);
                                    if (checkidvalid(crmscciid)) {
                                        scci = new SubCompanyComInfo();
                                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(scci.getSubcompanyname(crmscciid)) + "{83230}{683}" + levelstr + "{126522}";
                                    } else {
                                        msgcontent = "{84236}{144}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(crmmanager)) + "{83230}{19799}";
                                    }
                                } else {
                                    msgcontent = "{84236}{144}{126531}";
                                }
                            }
                            break;
                        case 46: //客户字段部门
                            msgrs = new RecordSet();
                            msgrs.execute("select manager from CRM_CustomerInfo where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String crmmanager = Util.null2String(msgrs.getString(1));
                                if (checkidvalid(crmmanager)) {
                                    rci = new ResourceComInfo();
                                    String crmdpid = rci.getDepartmentID(crmmanager);
                                    if (checkidvalid(crmdpid)) {
                                        dci = new DepartmentComInfo();
                                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(dci.getDepartmentname(crmdpid)) + "{83230}{683}" + levelstr + "{126522}";
                                    } else {
                                        msgcontent = "{84236}{144}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(crmmanager)) + "{83230}{15393}";
                                    }
                                } else {
                                    msgcontent = "{84236}{144}{126531}";
                                }
                            }
                            break;
                        case 43: //人力资源字段-角色
                            roleci = new RolesComInfo();
                            String rolenames = "";
                            for (String roleid : cachefieldvalue.split(",")) {
                                rolenames += roleci.getRolesRemark(roleid) + ",";
                            }
                            if (rolenames.length() > 0) {
                                rolenames = rolenames.substring(0, rolenames.length() - 1);
                            }
                            msgcontent = "{122}" + WorkflowRequestMessage.getBoldDetailInfo(rolenames) + "{15808}{18936}";
                            break;
                        case 49: //人力资源字段-收（发）文单位
                            druci = new DocReceiveUnitComInfo();
                            String drucinames = "";
                            for (String druciid : cachefieldvalue.split(",")) {
                                drucinames += druci.getReceiveUnitName(druciid) + ",";
                            }
                            if (drucinames.length() > 0) {
                                drucinames = drucinames.substring(0, drucinames.length() - 1);
                            }
                            msgcontent = "{19309}" + WorkflowRequestMessage.getBoldDetailInfo(drucinames) + "{15808}{126532}";
                            break;
                        case 48: //人力资源字段-会议室的管理员
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT hrmid,name FROM MeetingRoom where id=" + cachefieldvalue);
                            if (msgrs.next()) {
                                String hrmid = msgrs.getString(1);
                                if (!checkidvalid(hrmid)) {
                                    msgcontent = "{780}" + WorkflowRequestMessage.getBoldDetailInfo(Util.null2String(msgrs.getString(2))) + "{6}{1507}";
                                }
                            }
                            break;
                        case 6:  //人力资源字段经理
                            rci = new ResourceComInfo();
                            filedvaluename = rci.getLastnames(cachefieldvalue);
                            filedvaluename = addVirturalname(virtualname, filedvaluename);
                            msgcontent = WorkflowRequestMessage.getBoldInfo(filedvaluename) + "{83230}{15709}";
                            break;
                        case 5:  //人力资源字段本人
                        case 8:  //文档字段所有者
                        case 10: //项目字段经理
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT manager FROM Prj_ProjectInfo WHERE id =" + cachefieldvalue);
                            String pm = "";
                            if (msgrs.next()) {
                                pm = Util.null2String(msgrs.getString(1));
                                msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(getTurnoverHrmname(pm, msgrs)) + "{126527}";
                            }
                            break;
                        case 47: //项目字段经理的经理
                            msgrs = new RecordSet();
                            msgrs.execute("SELECT manager FROM Prj_ProjectInfo WHERE id =" + cachefieldvalue);
                            String promanager = "";
                            if (msgrs.next()) {
                                promanager = Util.null2String(msgrs.getString(1));
                                if (checkidvalid(promanager)) {
                                    rci = new ResourceComInfo();
                                    String _managerid = rci.getManagerID(promanager);
                                    if (checkidvalid(_managerid)) {
                                        msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(promanager)) + "{126526}{15709}{126527}";
                                    } else {
                                        msgcontent = "{16573}" + WorkflowRequestMessage.getBoldDetailInfo(rci.getLastname(promanager)) + "{83230}{15709}";
                                    }
                                } else {
                                    msgcontent = "{16573}{6}";
                                }
                            }
                            break;
                        case 13: //资产字段管理员
                        case 15: //客户字段经理
                            msgrs = new RecordSet();
                            msgrs.execute("select manager from CRM_CustomerInfo where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String crm = Util.null2String(msgrs.getString(1));
                                rci = new ResourceComInfo();
                                msgcontent = Util.null2String(rci.getLastname(crm)) + "{126527}";
                            }
                            break;
                        case 44: //客户字段经理的经理
                            msgrs = new RecordSet();
                            msgrs.execute("select manager from CRM_CustomerInfo where id = " + cachefieldvalue);
                            if (msgrs.next()) {
                                String crmmanager = Util.null2String(msgrs.getString(1));
                                if (checkidvalid(crmmanager)) {
                                    rci = new ResourceComInfo();
                                    String crmparentmanager = rci.getManagerID(crmmanager);
                                    String crmmanagername = rci.getLastname(crmmanager);
                                    if (checkidvalid(crmparentmanager)) {
                                        msgcontent = "{84236}{144}" + WorkflowRequestMessage.getBoldDetailInfo(crmmanagername) + "{126526}{15709}{126527}";
                                    } else {
                                        msgcontent = "{84236}{144}" + WorkflowRequestMessage.getBoldDetailInfo(crmmanagername) + "{83230}{15709}";
                                    }
                                } else {
                                    msgcontent = "{84236}{144}{6}";
                                }
                            }
                            break;
                        case 16: //客户字段联系人经理
                            msgrs = new RecordSet();
                            msgrs.execute("select manager,fullname from CRM_CustomerContacter where customerid = " + cachefieldvalue);
                            if (msgrs.getCounts() > 0) {
                                String lxrnames = "";
                                boolean haslxrmanager = false;
                                while (msgrs.next()) {
                                    String lxrmanager = Util.null2String(msgrs.getString(1));
                                    String lxrfullname = Util.null2String(msgrs.getString(2));
                                    if (StringUtil.isNotNull(lxrmanager)) {
                                        haslxrmanager = true;
                                    } else {
                                        lxrnames += lxrfullname + ",";
                                    }
                                }
                                if (!haslxrmanager) {
                                    if (lxrnames.length() > 0) {
                                        lxrnames = lxrnames.substring(0, lxrnames.length() - 1);
                                    }
                                    msgcontent = "{84236}{572}" + WorkflowRequestMessage.getBoldDetailInfo(lxrnames) + "{6}{144}";
                                }
                            } else {
                                msgrs.execute("select name from CRM_CustomerInfo where id = " + cachefieldvalue);
                                if (msgrs.next()) {
                                    msgcontent = "{84236}" + WorkflowRequestMessage.getBoldDetailInfo(Util.null2String(msgrs.getString(1))) + "{6}{572}";
                                }
                            }
                            break;
                        case 50: //人力资源字段-角色人员
                            break;
                    }
                }
                break;
            case 17://创建人本人
            case 18://创建人经理
                String creatermanagerid = "";
                rci = new ResourceComInfo();
                if (virtualid < -1) {
                    String[] reInfo = getResourceVirtualInfos(virtualid, String.valueOf(creater));
                    creatermanagerid = reInfo[0];
                } else {
                    creatermanagerid = rci.getManagerID(String.valueOf(creater));
                }
                if (!checkidvalid(creatermanagerid)) {
                    String createrlastname = rci.getLastname(String.valueOf(creater));
                    createrlastname = addVirturalname(virtualname, createrlastname);
                    msgcontent = WorkflowRequestMessage.getBoldInfo(createrlastname) + "{83230}{15709}";
                }
                break;
            case 36: //创建人下属
                String allsubstr = "";
                if (virtualid < -1) {//如果是虚拟维度，则初始化相应查询表
                    RecordSet crs = new RecordSet();
                    crs.executeSql("select id from HrmResourceVirtualView where managerid =" + creater + " and virtualtype = " + virtualid);
                    while (crs.next()) {
                        allsubstr += "," + crs.getString("id");
                    }
                } else {
                    AllSubordinate asub = new AllSubordinate();
                    try {
                        asub.getAll("" + creater);
                    } catch (Exception asube) {
                    }
                    while (asub.next()) {
                        if (!(asub.getSubordinateID()).equals(""))
                            allsubstr += "," + asub.getSubordinateID();
                    }
                }
                rci = new ResourceComInfo();
                String creatername = rci.getLastname(String.valueOf(creater));
                creatername = addVirturalname(virtualname, creatername);
                if (checkidvalid(allsubstr)) {
                    msgcontent = WorkflowRequestMessage.getBoldInfo(creatername) + "{126526}{442}{126530}{83230}{683}" + levelstr + "{126522}";
                } else {
                    msgcontent = WorkflowRequestMessage.getBoldInfo(creatername) + "{83230}{442}";
                }
                break;
            case 37: //创建人本分部
                if (creatertype == 0) {
                    rci = new ResourceComInfo();
                    String cjrfb = "";
                    if (virtualid < -1) {
                        String[] reInfo = getResourceVirtualInfos(virtualid, String.valueOf(creater));
                        cjrfb = reInfo[2];
                    } else {
                        cjrfb = rci.getSubCompanyID(String.valueOf(creater));
                    }
                    String cjrname = rci.getLastname(String.valueOf(creater));
                    if (checkidvalid(cjrfb)) {
                        String cjrfbname = getSubCompanyName(virtualid, cjrfb);
                        cjrfbname = addVirturalname(virtualname, cjrfbname);
                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(cjrfbname) + "{83230}{683}" + levelstr + "{126522}";
                    } else {
                        cjrname = addVirturalname(virtualname, cjrname);
                        msgcontent = WorkflowRequestMessage.getBoldInfo(cjrname) + "{83230}{19799}";
                    }
                }
                break;
            case 19: //创建人本部门
                if (creatertype == 0) {
                    rci = new ResourceComInfo();
                    String cjrbm = "";
                    if (virtualid < -1) {
                        String[] reInfo = getResourceVirtualInfos(virtualid, String.valueOf(creater));
                        cjrbm = reInfo[1];
                    } else {
                        cjrbm = rci.getDepartmentID(String.valueOf(creater));
                    }
                    String cjrname = rci.getLastname(String.valueOf(creater));
                    if (checkidvalid(cjrbm)) {
                        String cjrbmname = getDepartVirtualName(virtualid, cjrbm);
                        cjrbmname = addVirturalname(virtualname, cjrbmname);
                        msgcontent = "{33553}" + WorkflowRequestMessage.getBoldDetailInfo(cjrbmname) + "{83230}{683}" + levelstr + "{126522}";
                    } else {
                        cjrname = addVirturalname(virtualname, cjrname);
                        msgcontent = WorkflowRequestMessage.getBoldInfo(cjrname) + "{83230}{15393}";
                    }
                }
                break;
            case 39: //创建人上级部门
                rci = new ResourceComInfo();
                String cjrbm = "";
                if (virtualid < -1) {
                    String[] reInfo = getResourceVirtualInfos(virtualid, String.valueOf(creater));
                    cjrbm = reInfo[1];
                } else {
                    cjrbm = rci.getDepartmentID(String.valueOf(creater));
                }
                String cjrname = rci.getLastname(String.valueOf(creater));
                if (checkidvalid(cjrbm)) {
                    String supdciid = getSupdepartmentID(virtualid, cjrbm);
                    if (checkidvalid(supdciid)) {
                        String supdciname = addVirturalname(virtualname, getDepartVirtualName(virtualid, supdciid));
                        msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(supdciname) + "{83230}{683}" + levelstr + "{126522}";
                    } else {
                        String decid1name = addVirturalname(virtualname, getDepartVirtualName(virtualid, cjrbm));
                        msgcontent = "{126029}" + WorkflowRequestMessage.getBoldDetailInfo(decid1name) + "{83230}{15772}";
                    }
                } else {
                    cjrname = addVirturalname(virtualname, cjrname);
                    msgcontent = WorkflowRequestMessage.getBoldInfo(cjrname) + "{83230}{15393}";
                }
                break;
            case 40: //节点操作者本人
                String nodename = WorkflowRequestMessage.getWorkflowNodename(objid);
                msgcontent = "{33417}" + WorkflowRequestMessage.getBoldDetailInfo(nodename) + "{126521}";
                break;
            case 41: //节点操作者经理
                msgrs = new RecordSet();
                nodename = WorkflowRequestMessage.getWorkflowNodename(objid);
                String userids = getNodeUserIds(msgrs, objid);
                if (checkidvalid(userids)) {
                    rci = new ResourceComInfo();
                    String nodeusernames = "";
                    for (String userid : userids.split(",")) {
                        if (checkidvalid(userid)) {
                            nodeusernames += rci.getLastname(userid) + ",";
                        }
                    }
                    if (nodeusernames.length() > 0) {
                        nodeusernames = nodeusernames.substring(0, nodeusernames.length() - 1);
                    }
                    nodeusernames = addVirturalname(virtualname, nodeusernames);
                    msgcontent = "{33417}{99}" + WorkflowRequestMessage.getBoldDetailInfo(nodeusernames) + "{83230}{15709}";
                } else {
                    nodename = addVirturalname(virtualname, nodename);
                    msgcontent = "{33417}" + WorkflowRequestMessage.getBoldDetailInfo(nodename) + "{126533}，{83230}{99}";
                }
                break;
            case 99: //矩阵相关
                msgcontent = checkUseridsByMatrix(String.valueOf(detailid));
                break;
            case 20://门户相关-客户类型
                msgcontent = "{126537}" + objname + "{126538}{83230}{683}" + levelstr + "{126526}{84236}";
                break;
            case 21://门户相关-客户状态
                msgcontent = "{126535}" + objname + "{126538}{83230}{683}" + levelstr + "{126526}{84236}";
                break;
            case 22://门户相关-客户部门
                msgcontent = "{126536}" + objname + "{126538}{83230}{683}" + levelstr + "{126526}{84236}";
                break;
            case 23://门户相关-客户经理
                if (StringUtil.isNull(cachefieldvalue)) {
                    objname = WorkflowRequestMessage.getBoldDetailInfo(this.getObjName(type, objid, bhxj, language, virtualid, level, detailid, false));
                    msgcontent = "{21740}" + objname + "{126520}";
                } else {
                    rci = new ResourceComInfo();
                    String crmmanagernames = "";
                    for (String crmmanager : cachefieldvalue.split(",")) {
                        crmmanagernames = rci.getLastname(crmmanager) + "，";
                    }
                    if (crmmanagernames.length() > 0) {
                        crmmanagernames = crmmanagernames.substring(0, crmmanagernames.length() - 1);
                    }
                    msgcontent = "{84236}{144}{126151}" + WorkflowRequestMessage.getBoldDetailInfo(crmmanagernames) + "{126526}{84236}{126530}{83230}{683}" + levelstr + "{126526}{84236}";
                }
                break;
            case 24://门户相关-客户字段本人
                if (StringUtil.isNull(cachefieldvalue)) {
                    objname = WorkflowRequestMessage.getBoldDetailInfo(this.getObjName(type, objid, bhxj, language, virtualid, level, detailid, false));
                    msgcontent = "{21740}" + objname + "{126520}";
                } else {
                    cici = new CustomerInfoComInfo();
                    String crmname = Util.null2String(cici.getCustomerInfoname(cachefieldvalue));
                    msgcontent = "{84236}" + WorkflowRequestMessage.getBoldDetailInfo(crmname) + "{126534}";
                }
                break;
            case 25:////门户相关-所有客户
                msgcontent = "{83230}{683}" + levelstr + "{126526}{84236}";
                break;
            default:
                msgcontent = "{127306}";
        }
        return WorkflowRequestMessage.assemMsgInfo(msgcontent, languageid);
    }

    private String getResourceVirtualManageId(int virtualid, int userid) throws Exception {
        RecordSet rs = new RecordSet();
        rs.executeQuery(" select * from HrmResourceVirtualView where id = ? and virtualtype = ?", userid, virtualid);
        if (rs.next()) {
            return rs.getString("managerid");
        }
        return "";
    }


    /**
     * 查询虚拟维度用户部门
     *
     * @param virtualname
     * @param desc
     * @return
     */
    private String[] getResourceVirtualInfos(int virtualid, String resourceid) {
        String[] rsInfo = new String[]{"", "", ""};
        RecordSet rs = new RecordSet();
        rs.executeQuery("select managerid,departmentid,subcompanyid1  from HrmResourceVirtualView where id = ? and virtualtype = ?", resourceid, virtualid);
        if (rs.next()) {
            rsInfo[0] = rs.getString("managerid");
            rsInfo[1] = rs.getString("departmentid");
            rsInfo[2] = rs.getString("subcompanyid1");
        }
        return rsInfo;
    }

    /**
     * 查询部门名称
     *
     * @param virtualid
     * @param departmentid
     * @return
     */
    private String getDepartVirtualName(int virtualid, String departmentid) {
        if (virtualid < -1) {
            RecordSet rs = new RecordSet();
            rs.executeQuery("select departmentname from HrmDepartmentAllView where id = ? and virtualtype = ?", departmentid, virtualid);
            if (rs.next()) {
                return rs.getString("departmentname");
            }
        } else {
            DepartmentComInfo dci;
            try {
                dci = new DepartmentComInfo();
                return dci.getDepartmentname(departmentid);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "";
    }

    /**
     * 查询分部名称
     *
     * @param virtualid
     * @param subcompanyid1
     * @return
     */
    private String getSubCompanyName(int virtualid, String subcompanyid1) {
        if (virtualid < -1) {
            RecordSet rs = new RecordSet();
            rs.executeQuery("select subcompanyname from HrmSubCompanyAllView where id = ? and virtualtype = ?", subcompanyid1, virtualid);
            if (rs.next()) {
                return rs.getString("subcompanyname");
            }
        } else {
            try {
                SubCompanyComInfo scci = new SubCompanyComInfo();
                return scci.getSubCompanyname(subcompanyid1);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "";
    }

    /**
     * 查询上级部门ID
     *
     * @param virtualid
     * @param departmentid
     * @return
     */
    private String getSupdepartmentID(int virtualid, String departmentid) {
        if (virtualid < -1) {
            RecordSet rs = new RecordSet();
            rs.executeQuery("select supdepid from HrmDepartmentAllView  where id = ? and virtualtype = ?", departmentid, virtualid);
            if (rs.next()) {
                return rs.getString("supdepid");
            }
        } else {
            DepartmentComInfo dci;
            try {
                dci = new DepartmentComInfo();
                return dci.getDepartmentsupdepid(departmentid);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "";

    }


    private String addVirturalname(String virtualname, String desc) {
        if (StringUtil.isNotNull(virtualname)) {
            desc = desc + "（" + virtualname + "）";
        }
        return desc;
    }

    /**
     * 操作者不在职提示
     *
     * @param type       在查询操作者sql中未加人员状态条件的类型
     * @param operatorid
     * @param objid
     * @return
     */
    private String getOperatorNotWorkingInfo(int type, int objid, String lastnames, int groupdetailid) {
        String msg = "";
        ResourceComInfo rci = null;
        try {
            rci = new ResourceComInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (lastnames.length() > 0) {
            lastnames = lastnames.substring(0, lastnames.length() - 1);
        } else {
            return msg;
        }

        String lastnametemp = WorkflowRequestMessage.getBoldDetailInfo(lastnames);

        switch (type) {
            case 48:                        //人力资源字段-会议室的管理员
                msg = "{780}{1507}" + lastnametemp + "{126527}";
                break;
            case 6:                         // 人力资源字段经理
                msg = WorkflowRequestMessage.getBoldInfo(rci.getLastname(cachefieldvalue)) + "{126526}{15709}" + lastnames + "{126527}";
                break;
            case 8:                         // 文档字段所有者
                msg = "{126529}{83562}" + lastnametemp + "{126527}";
                break;
            case 10:                        // 项目字段经理
                msg = "{16573}" + lastnametemp + "{126527}";
                break;
            case 13:                        // 资产字段所有者
                msg = "{30044}{1507}" + lastnametemp + "{126527}";
                break;
            case 15:                        // 客户字段经理
                msg = "{84236}{144}" + lastnametemp + "{126527}";
                break;
            case 16:                        // 客户联系人经理
                msg = "{572}{144}" + lastnametemp + "{126527}";
                break;
            case 18:                              //创建人经理
                msg = WorkflowRequestMessage.getBoldInfo(Util.null2String(rci.getLastname(String.valueOf(creater)))) + "{126526}{15709}{126527}";
                break;
            case 40:                        //节点操作者本人
                String nodename = WorkflowRequestMessage.getWorkflowNodename(objid);
                msg = "{33417}" + WorkflowRequestMessage.getBoldDetailInfo(nodename) + "{126526}{99}" + lastnametemp + "{126527}";
                break;
            case 41:                        //节点操作者经理
                RecordSet msgrs = new RecordSet();
                nodename = WorkflowRequestMessage.getWorkflowNodename(objid);
                String userids = getNodeUserIds(msgrs, objid);
                if (checkidvalid(userids)) {
                    String nodeusernames = "";
                    for (String userid : userids.split(",")) {
                        if (checkidvalid(userid)) {
                            nodeusernames += rci.getLastname(userid) + ",";
                        }
                    }
                    if (nodeusernames.length() > 0) {
                        nodeusernames = nodeusernames.substring(0, nodeusernames.length() - 1);
                    }
                    msg = "{33417}{99}" + WorkflowRequestMessage.getBoldDetailInfo(nodeusernames) + "{126526}{15709}" + lastnametemp + "{126527}";
                }
                break;
            case 99:
                msg = checkUseridsByMatrix(String.valueOf(groupdetailid));
                break;
            default:
                msg = WorkflowRequestMessage.getBoldInfo(lastnames) + "{126527}";
                break;
        }
        return WorkflowRequestMessage.assemMsgInfo(msg, languageid);
    }

    private static String getLastnameByUserStatus(String operatorid) {
        ResourceComInfo rci = null;
        try {
            rci = new ResourceComInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (checkidvalid(operatorid) && Util.getIntValue(rci.getStatus(operatorid), 7) > 3) {
            String lastname = Util.null2String(getTurnoverHrmname(operatorid, new RecordSet()));
            if (StringUtil.isNotNull(lastname)) {
                return lastname;
            }
        }
        return "";
    }

    /**
     * 检测ID是否有效即 ID 不为空不为0
     *
     * @param id
     * @return
     */
    private static boolean checkidvalid(String id) {
        return StringUtil.isNotNull(id) && !"0".equals(id) && !"-1".equals(id);
    }


    private String getGroupDetailObjName(int objid, int language) {
        String name = "";
        String _sql = "";
        RecordSet _rs = new RecordSet();
        if (isbill == 0) {
            _sql = "select * from (";
            _sql += " select workflow_formdict.id as id,workflow_fieldlable.fieldlable as name,0 viewtype,0 groupid from workflow_formdict,workflow_formfield,workflow_fieldlable where  workflow_fieldlable.isdefault=1 and workflow_fieldlable.formid = workflow_formfield.formid and workflow_fieldlable.fieldid = workflow_formfield.fieldid and  workflow_formfield.fieldid= workflow_formdict.id and (workflow_formfield.isdetail<>'1' or workflow_formfield.isdetail is null) and workflow_formfield.formid=" + formid + " and workflow_formdict.id = " + objid;      // 包括多人力资源字段
            _sql += " union all ";
            _sql += " SELECT workflow_formdictdetail.id AS id,workflow_fieldlable.fieldlable AS name,1 viewtype,workflow_formfield.groupId + 1 FROM workflow_formdictdetail,workflow_formfield,workflow_fieldlable WHERE workflow_fieldlable.isdefault = 1 AND workflow_fieldlable.formid = workflow_formfield.formid AND workflow_fieldlable.fieldid = workflow_formfield.fieldid AND workflow_formfield.fieldid = workflow_formdictdetail.id AND workflow_formfield.isdetail = '1' AND workflow_formfield.formid = " + formid + " and workflow_formdictdetail.id = " + objid;
            _sql += " )t order by viewtype asc,groupid asc,id asc";
        } else {
            _sql = "select * from (";
            _sql += " select id as id , fieldlabel as name,0 viewtype,0 groupid from workflow_billfield where billid=" + formid + " and id = " + objid + " and viewtype = 0";
            _sql += " union all";
            _sql += " select a.id, fieldlabel as name,1 viewtype,b.orderid groupid from workflow_billfield a,Workflow_billdetailtable b where a.billid = b.billid and a.detailtable = b.tablename and a.billid=" + formid + " and viewtype = 1 and a.id = " + objid;
            _sql += " )t order by viewtype asc,groupid asc,id asc";
        }
        _rs.execute(_sql);
        if (_rs.next()) {
            String viewtype = _rs.getString("viewtype");
            String groupid = _rs.getString("groupid");
            if (isbill == 0) {
                name = _rs.getString("name");
            } else {
                name = SystemEnv.getHtmlLabelName(Util.getIntValue(_rs.getString("name")), language);
            }
            if ("1".equals(viewtype)) {
                name += "（" + SystemEnv.getHtmlLabelName(17463, language) + groupid + "）";
            }
        }
        return name;
    }

    /**
     * 非归档节点：所有类型设置均不找离职人员
     * 归档节点：
     * 1、节点操作者(40)、指定人员(3) 类型 读取配置文件判断是否过滤离职人员
     * 2、创建人本人(17) 类型不过滤离职
     *
     * @param nodetype 节点类型
     * @param type     操作者类型
     * @return true : 过滤离职人员  false : 不过滤离职人员
     */
    private boolean getIsDimissionByProp(String nodetype, int type) {
        boolean isFilter = true;
        if ("3".equals(nodetype)) {
            String filterType = Util.null2String(getPropValue("workflow_isDimission", "filterType")).trim();
            String isDimission = Util.null2String(getPropValue("workflow_isDimission", "isDimission")).trim();
            if ("0".equals(isDimission) && "".equals(filterType)) {
                filterType = "3";
            }
            if (!"".equals(filterType)) {
                if ("all".equalsIgnoreCase(filterType)) {
                    isFilter = false;
                } else {
                    if (Util.splitString2List(filterType, ",").contains(type + "")) {
                        isFilter = false;
                    }
                }
            }
        }
        return isFilter;
    }

    /**
     * 查询不在职员工名称
     *
     * @param id
     * @param rs
     * @return
     */
    private static String getTurnoverHrmname(String id, RecordSet rs) {
        rs.executeQuery("select lastname,status from hrmresource where id = ?", id);
        if (rs.next()) {
            int status = rs.getInt(2);
            if (status > 3) {
                return rs.getString(1);
            }
        }
        return "";
    }

    /**
     * 如果下一节点是必须通过，则清除别的节点错误消息
     *
     * @param cacheBuffers
     */
    private void hasmustpassnodeClearMsg(List<String> cacheBuffers) {
        if (cacheBuffers.size() > 0) {
            String messagecontent = this.getMessagecontent();
            JSONObject json;
            try {
                json = new JSONObject(messagecontent);
                json.put("details", errorInfoMsgBuffer.toString().replaceFirst(cacheBuffers.get(0), ""));
                this.setMessagecontent(json.toString());
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private Hashtable deleteOperateBySecLevel2(Hashtable operatorsht, int requestId, StringBuilder messageContent) {
        RequestSecLevelBiz secLevelBiz = new RequestSecLevelBiz();
        HrmClassifiedProtectionBiz hrmSecBiz = new HrmClassifiedProtectionBiz();
        boolean isOpenSecLevel = HrmClassifiedProtectionBiz.isOpenClassification();//是否开启涉密系统

        if (isOpenSecLevel) {
            try {
                int requestSecLevel = secLevelBiz.getSecLevelByRequestId(requestId + "");
                ResourceComInfo rci = new ResourceComInfo();
                Iterator operatorIterator = operatorsht.keySet().iterator();
                Hashtable newOperatorsht = new Hashtable();
                while (operatorIterator.hasNext()) {
                    String key = (String) operatorIterator.next();
                    List<String> operators = (List<String>) operatorsht.get(key);
                    List<String> newOperators = new ArrayList<>();
                    for (String operator : operators) {
                        String[] operatorStr = Util.null2String(operator).split("_");
                        if (operatorStr != null && operatorStr.length > 0) {
                            int hrmSecLevel = Util.getIntValue(hrmSecBiz.getMaxResourceSecLevel(new User(Util.getIntValue(operatorStr[0]))));
                            if (hrmSecLevel > requestSecLevel) {
                                messageContent.append("，" + rci.getLastname(operatorStr[0]));

                                 log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestId
                                        + " requestLevel= " + requestSecLevel + " 过滤操作者 id = " + operatorStr[0] + " userSecLevel = " + hrmSecLevel);
                                continue;
                            }
                        }
                        newOperators.add(operator);
                    }
                    if (newOperators.size() > 0) {
                        newOperatorsht.put(key, newOperators);
                    }
                }
                return newOperatorsht;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return operatorsht;
    }

    /**
     * 根据密级过滤不符合条件的操作者
     *
     * @return
     */
    private ArrayList deleteOperateBySecLevel2(ArrayList operatorshts, int requestId) {
        if (HrmClassifiedProtectionBiz.isOpenClassification()) {//是否开启涉密系统

            boolean filterMark = false;//过滤标识

            ArrayList newOperatorshts = new ArrayList();
            StringBuilder messageContent = new StringBuilder();
            for (Hashtable operatorsht : (ArrayList<Hashtable>) operatorshts) {
                if(operatorsht.size() == 0) continue;//没有找到操作者，不进行过滤

                Hashtable newOperatorsht = deleteOperateBySecLevel2(operatorsht, requestId, messageContent);
                filterMark = true;
                if (newOperatorsht.size() > 0) {
                    newOperatorshts.add(newOperatorsht);
                }
            }
            //拼接错误消息
            if (filterMark && operatorshts.size() > 0 && newOperatorshts.size() == 0) {
                generateErrorMsg4SecLevel(messageContent);
                return newOperatorshts;
            }
        }

        return operatorshts;
    }

    /**
     * 根据密级过滤不符合条件的操作者
     *
     * @param operatorInfos
     * @return
     */
    private List<OperatorInfoEntity> deleteOperateBySecLevel(List<OperatorInfoEntity> operatorInfos, int requestId) {
        RequestSecLevelBiz secLevelBiz = new RequestSecLevelBiz();
        HrmClassifiedProtectionBiz hrmSecBiz = new HrmClassifiedProtectionBiz();
        boolean isOpenSecLevel = HrmClassifiedProtectionBiz.isOpenClassification();//是否开启涉密系统
        //开启涉密系统后，操作者找人，需要过滤密级低于当前流程的操作者
        if (isOpenSecLevel) {
            int requestSecLevel = secLevelBiz.getSecLevelByRequestId(requestId + "");
            Iterator<OperatorInfoEntity> iterator = operatorInfos.iterator();
            while (iterator.hasNext()) {
                OperatorInfoEntity operatorEntity = iterator.next();
                int hrmSecLevel = Util.getIntValue(hrmSecBiz.getMaxResourceSecLevel(new User(Util.getIntValue(operatorEntity.getUserId()))));
                if (hrmSecLevel > requestSecLevel) {
                    iterator.remove();
                    log.info("=workflowSubmit=ReqNodeFlow=requestid"+requestId
                            + " requestLevel= " + requestSecLevel + " 过滤操作者 id = " + operatorEntity.getUserId() + " userSecLevel = " + hrmSecLevel);
                    continue;
                }
            }
        }
        return operatorInfos;
    }

    /**
     * 密级过滤掉操作者之后生成错误消息
     */
    private void generateErrorMsg4SecLevel(StringBuilder messageContent) {
        String nextnodename = WorkflowRequestMessage.getWorkflowNodename(nextnodeid);
        errorInfoMsgBuffer = new StringBuffer();
        WorkflowRequestMessage.getNodeErrorMsgTitle(errorInfoMsgBuffer, nextnodename, languageid);

        if (!"".equals(messageContent.toString())) {
            messageContent = new StringBuilder(messageContent.substring(1));
        }

        assemMsgContent4E9("", "", WorkflowRequestMessage.getBoldInfo(messageContent.toString()) + "{501273}");
        this.nextnodeids.clear();
    }


    public void setForceOverNodeId(int forceOverNodeId) {
        this.forceOverNodeId = forceOverNodeId;
    }

    public boolean isForceOver() {
        return isForceOver;
    }

    public void setForceOver(boolean isForceOver) {
        this.isForceOver = isForceOver;
    }

    //add by liaodong for qc76119,76120,54194,64652 start
    public String getPenetrateId() {
        return penetrateId;
    }

    public void setPenetrateId(String penetrateId) {
        this.penetrateId = penetrateId;
    }

    public String getLastNodeId() {
        return lastNodeId;
    }

    public void setLastNodeId(String lastNodeId) {
        this.lastNodeId = lastNodeId;
    }

    //end
    //add by liaodong for qc48451 in 2013年10月21日 start
    public boolean isIsfixbill() {
        return isfixbill;
    }

    public void setIsfixbill(boolean isfixbill) {
        this.isfixbill = isfixbill;
    }
    //end

    //add by liaodong for qc86096 in 2013-11-19 start
    public String getCurrentdate() {
        return currentdate;
    }

    public void setCurrentdate(String currentdate) {
        this.currentdate = currentdate;
    }

    public String getCurrenttime() {
        return currenttime;
    }

    public void setCurrenttime(String currenttime) {
        this.currenttime = currenttime;
    }

    //end
    public Map<String, Object> getEh_operatorMap() {
        return eh_operatorMap;
    }

    public void setEh_operatorMap(Map<String, Object> eh_operatorMap) {
        this.eh_operatorMap = eh_operatorMap;
    }

    public boolean isNeedChooseOperator() {
        return isNeedChooseOperator;
    }

    public ArrayList getRequestexceptiontypes() {
        return requestexceptiontypes;
    }

    public String getMessageid() {
        return messageid;
    }

    public void setMessageid(String messageid) {
        this.messageid = messageid;
    }

    public String getMessagecontent() {
        return messagecontent;
    }

    public void setMessagecontent(String messagecontent) {
        this.messagecontent = messagecontent;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    /**
     * 用于检查是否分叉中间节点退回到普通节点后，普通节点提交直接到退回节点
     *
     * @param nodeid   提交节点id
     * @param tonodeid 提交到节点id
     * @return
     */
    public boolean IsTrunkSubmitToBranch(RecordSet rs, int nodeid, int tonodeid) {
        boolean iscansubmit = false;
        // 0,1,2,3,4,5
        int nodeattr = 0;
        int tonodeattr = 0;
        rs.executeSql("SELECT nodeattribute FROM workflow_nodebase WHERE id=" + nodeid);
        if (rs.next()) {
            nodeattr = Util.getIntValue(rs.getString("nodeattribute"), 0);
        }
        rs.executeSql("SELECT nodeattribute FROM workflow_nodebase WHERE id=" + tonodeid);
        if (rs.next()) {
            tonodeattr = Util.getIntValue(rs.getString("nodeattribute"), 0);
        }
        if (nodeattr != 2 && tonodeattr == 2) {
            iscansubmit = true;
        }
        return iscansubmit;
    }

    public boolean isEquals(ArrayList mustpassnodeids, ArrayList nodeids) {
        boolean ispass = true;
        for (int i = 0; i < mustpassnodeids.size(); i++) {
            if (!nodeids.contains(mustpassnodeids.get(i).toString())) {
                ispass = false;
                break;
            }
        }
        return ispass;
    }

    public int getTempnextnodeid() {
        return tempnextnodeid;
    }

    public void setTempnextnodeid(int tempnextnodeid) {
        this.tempnextnodeid = tempnextnodeid;
    }

    public String getNextnodetype() {
        return nextnodetype;
    }

    public void setNextnodetype(String nextnodetype) {
        this.nextnodetype = nextnodetype;
    }

    public boolean isHasCoadjutant() {
        return hasCoadjutant;
    }

    public int getWorkflowid() {
        return workflowid;
    }

    public void setSelectNextFlow(boolean selectNextFlow) {
        isSelectNextFlow = selectNextFlow;
    }

    public boolean isAutoForecast() {
        return autoForecast;
    }
    public void setIsFromSubmitConfirm(int isFromSubmitConfirm) {
        this.isFromSubmitConfirm = isFromSubmitConfirm;
    }

    public void setAutoForecast(boolean autoForecast) {
        this.autoForecast = autoForecast;
    }

    /**
     *
     * @param requestId
     * @param errMsg
     * @return
     */
    public boolean recordErrMsgBySubNodeReqId(String errMsg, int requestId){
        RecordSet recordSet = new RecordSet();
        RecordSet rssel = new RecordSet();
        boolean success = false;
        String eflowmsg = "";
        if(fromSubWfTrigger){
            String selsql = "select flowErrMsg from Workflow_SubwfRequest where subrequestid=?";
            rssel.executeQuery(selsql,requestId);
            if(rssel.next()){
                eflowmsg = Util.null2String(rssel.getString("flowErrMsg"));
            }
            new weaver.general.BaseBean().writeLog("=ReqManager=subrequestid="+requestId+"eflowmsg"+eflowmsg);
            if(!"".equals(eflowmsg)){
                errMsg = errMsg +":"+eflowmsg;
            }
            success = recordSet.executeUpdate("update Workflow_SubwfRequest set flowErrMsg = ? where subrequestid = ? ",errMsg, requestId);
        }
        return success;
    }
}