Example #1
0
        /// <summary>
        /// 计算会签
        /// </summary>
        /// <param name="wfNodeInfo">节点信息</param>
        /// <param name="preNodeId">上一节点Id</param>
        /// <param name="isAgree">同意</param>
        /// <returns>0 不做处理 1 通过 -1 不通过</returns>
        private int CalcConfluence(NWFNodeInfo wfNodeInfo, string preNodeId, bool isAgree)
        {
            int           res         = 0;
            int           agreeNum    = config.GetAgreeNum(config.ParamConfig.ProcessId, wfNodeInfo.id);
            int           disAgreeNum = config.GetDisAgreeNum(config.ParamConfig.ProcessId, wfNodeInfo.id);
            List <string> preNodeList = GetPreNodes(wfNodeInfo.id);

            switch (wfNodeInfo.confluenceType) //会签策略1-所有步骤通过,2-一个步骤通过即可,3-按百分比计算
            {
            case 1:                            //所有步骤通过
                if (isAgree)
                {
                    if (preNodeList.Count == agreeNum + 1)
                    {
                        res = 1;
                    }
                }
                else
                {
                    res = -1;
                }
                break;

            case 2:
                if (isAgree)
                {
                    res = 1;
                }
                else if (preNodeList.Count == disAgreeNum + 1)
                {
                    res = -1;
                }
                break;

            case 3:
                if (isAgree)
                {
                    if ((agreeNum + 1) * 100 / preNodeList.Count >= Convert.ToDecimal(wfNodeInfo.confluenceRate))
                    {
                        res = 1;
                    }
                }
                else
                {
                    if ((preNodeList.Count - disAgreeNum - 1) * 100 / preNodeList.Count < Convert.ToDecimal(wfNodeInfo.confluenceRate))
                    {
                        res = -1;
                    }
                }
                break;
            }
            return(res);
        }
Example #2
0
        /// <summary>
        /// 计算条件
        /// </summary>
        /// <param name="node">节点信息</param>
        /// <returns></returns>
        private bool CalcCondition(NWFNodeInfo node)
        {
            bool res = true;

            if (node.conditions.Count > 0)
            {
                #region 字段条件判断
                foreach (var condition in node.conditions)
                {
                    if (!string.IsNullOrEmpty(condition.dbId) && !string.IsNullOrEmpty(condition.table) && !string.IsNullOrEmpty(condition.field1) && !string.IsNullOrEmpty(condition.field2))
                    {
                        string    sql       = "select " + condition.field2 + " from " + condition.table + " where " + condition.field1 + " =@processId ";
                        DataTable dataTable = config.DbFindTable(condition.dbId, sql, new { processId = config.ParamConfig.ProcessId });
                        if (dataTable.Rows.Count > 0)
                        {
                            string value = dataTable.Rows[0][0].ToString();
                            if (string.IsNullOrEmpty(value))
                            {
                                return(false);
                            }

                            switch (condition.compareType) //比较类型1.等于2.不等于3.大于4.大于等于5.小于6.小于等于7.包含8.不包含9.包含于10.不包含于
                            {
                            case 1:                        // 等于
                                if (value != condition.value)
                                {
                                    res = false;
                                }
                                break;

                            case 2:    // 不等于
                                if (value == condition.value)
                                {
                                    res = false;
                                }
                                break;

                            case 3:    // 大于
                                if (Convert.ToDecimal(value) <= Convert.ToDecimal(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 4:    // 大于等于
                                if (Convert.ToDecimal(value) < Convert.ToDecimal(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 5:    // 小于
                                if (Convert.ToDecimal(value) >= Convert.ToDecimal(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 6:    // 小于等于
                                if (Convert.ToDecimal(value) > Convert.ToDecimal(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 7:    // 包含
                                if (!value.Contains(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 8:    // 不包含
                                if (value.Contains(condition.value))
                                {
                                    res = false;
                                }
                                break;

                            case 9:    // 包含于
                                if (!condition.value.Contains(value))
                                {
                                    res = false;
                                }
                                break;

                            case 10:    // 不包含于
                                if (condition.value.Contains(value))
                                {
                                    res = false;
                                }
                                break;
                            }
                        }
                        else
                        {
                            res = false;
                        }
                    }
                    if (!res)
                    {
                        break;
                    }
                }
                #endregion
            }
            else if (!string.IsNullOrEmpty(node.conditionSql))
            {
                res = false;
                // 流程进程ID
                string conditionSql = node.conditionSql.Replace("{processId}", "@processId");
                // 流程创建人用户
                conditionSql = conditionSql.Replace("{userId}", "@userId");
                conditionSql = conditionSql.Replace("{userAccount}", "@userAccount");
                conditionSql = conditionSql.Replace("{companyId}", "@companyId");
                conditionSql = conditionSql.Replace("{departmentId}", "@departmentId");

                var param = new
                {
                    processId    = config.ParamConfig.ProcessId,
                    userId       = config.ParamConfig.CreateUser.Id,
                    userAccount  = config.ParamConfig.CreateUser.Account,
                    companyId    = config.ParamConfig.CreateUser.CompanyId,
                    departmentId = config.ParamConfig.CreateUser.DepartmentId,
                };
                DataTable dataTable = config.DbFindTable(node.dbConditionId, conditionSql, param);
                if (dataTable.Rows.Count > 0)
                {
                    res = true;
                }
            }
            else
            {
                res = true;
            }
            return(res);
        }
Example #3
0
        /// <summary>
        /// 获取接下来的任务节点信息
        /// </summary>
        /// <param name="beginNode">起始节点</param>
        /// <param name="code">节点操作码 agree 同意 disagree 不同意 lrtimeout 超时</param>
        /// <param name="isGetAuditors">是否获取下一节点审核人</param>
        /// <param name="lineList">经过的线段需要执行操作的</param>
        /// <returns></returns>
        public List <NWFNodeInfo> GetNextTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List <NWFLineInfo> lineList)
        {
            List <NWFNodeInfo> list         = new List <NWFNodeInfo>();
            List <NWFNodeInfo> nextNodeList = GetNextNodes(beginNode.id, code, lineList);

            Dictionary <string, string> auditers = null;

            if (!string.IsNullOrEmpty(config.ParamConfig.Auditers))
            {
                auditers = config.ParamConfig.Auditers.ToObject <Dictionary <string, string> >();
            }


            foreach (var node in nextNodeList)
            {
                if (auditers != null && auditers.ContainsKey(node.id))
                {
                    node.auditors = new List <NWFAuditor>();
                    node.auditors.Add(new NWFAuditor()
                    {
                        type      = 3,
                        auditorId = auditers[node.id]
                    });
                }

                switch (node.type)
                {
                case "conditionnode":     // 条件节点
                    if (!isGetAuditors)
                    {
                        if (CalcCondition(node))
                        {
                            list.AddRange(GetNextTaskNode(node, "agree", isGetAuditors, lineList));
                        }
                        else
                        {
                            list.AddRange(GetNextTaskNode(node, "disagree", isGetAuditors, lineList));
                        }
                    }
                    else
                    {
                        list.AddRange(GetNextTaskNode(node, "agree", isGetAuditors, lineList));
                        list.AddRange(GetNextTaskNode(node, "disagree", isGetAuditors, lineList));
                    }
                    break;

                case "confluencenode":    // 会签节点
                    if (!isGetAuditors)
                    {
                        int confluenceRes;
                        if (code == "agree")
                        {
                            confluenceRes = CalcConfluence(node, beginNode.id, true);
                        }
                        else
                        {
                            confluenceRes = CalcConfluence(node, beginNode.id, false);
                        }
                        if (confluenceRes == 1)    // 会签审核通过
                        {
                            list.AddRange(GetNextTaskNode(node, "agree", false, lineList));
                        }
                        else if (confluenceRes == -1)    // 会签审核不通过
                        {
                            list.AddRange(GetNextTaskNode(node, "disagree", false, lineList));
                        }
                        node.confluenceRes = confluenceRes;
                        list.Add(node);
                    }
                    break;

                case "auditornode":    // 传阅节点
                    list.Add(node);
                    break;

                case "childwfnode":    // 子流程节点
                    list.Add(node);
                    if (node.childType == "2")
                    {     // 异步的情况下直接往下走
                        list.AddRange(GetNextTaskNode(node, "agree", isGetAuditors, lineList));
                    }
                    break;

                case "startround":    // 开始节点 需要重新审核
                    list.Add(node);
                    config.ParamConfig.State = 1;
                    break;

                case "endround":    // 结束节点
                    config.ParamConfig.State = 2;
                    break;

                default:             // 默认一般审核界定啊
                    list.Add(node);
                    break;
                }
            }

            return(list);
        }