Пример #1
0
        /// <summary>
        /// 其他清单判断流程
        /// </summary>
        /// <param name="row"></param>
        /// <param name="db"></param>
        /// <param name="ZYFL5"></param>
        /// <returns></returns>
        public IdentityResult ProcessOther(Excel row, RulesAdapter db, string ZYFL5)
        {
            var identity = new IdentityResult(row.ID);
            var columns  = new Queue <string>(new string[] { "ZYFL2", "ZYFL3", "ZYFL4" });
            var rules    = db.ZDBJ.Select("QDFL = '" + row.ZY + "' and ZYFL5 like '%" + ZYFL5 + "%'");
            var items    = new List <DataRow>();
            var name     = FormatNameUseGlobalRule(row.QDMC, row.ZY);

            if (rules.Length == 0)
            {
                return(identity);
            }

            while (columns.Count > 0)
            {
                items = new List <DataRow>();
                var column = columns.Dequeue();

                foreach (DataRow rule in rules)
                {
                    var express = rule.Field <string>(column);
                    if (string.IsNullOrEmpty(express))
                    {
                        items.Add(rule);
                    }
                    else
                    {
                        var pattern = Pattern.Parse(new Fields().Append("express", express));

                        if (pattern != null)
                        {
                            var newname = FormatNameUseQuotaRule(name, row.ZY, rule);
                            var fields  = new Fields().Append("sample", newname);
                            if (pattern.IsMatch(fields))
                            {
                                name = RemoveScopeUseRule(name, rule.Field <string>("ZYFL4"));
                                items.Add(rule);
                            }
                        }
                    }
                }

                rules = items.ToArray();
            }

            if (items.Count == 0)
            {
                return(identity);
            }

            items = new List <DataRow>();
            foreach (DataRow rule in rules)
            {
                var express = rule.Field <string>("DEBS");
                if (string.IsNullOrEmpty(express))
                {
                    items.Add(rule);
                }
                else
                {
                    var pattern = Pattern.Parse(new Fields("express", express));
                    if (pattern == null)
                    {
                        continue;
                    }

                    var newname = FormatNameUseQuotaRule(name, row.ZY, rule);
                    var fields  = new Fields("sample", newname);
                    if (pattern.IsMatch(fields))
                    {
                        name = RemoveScopeUseRule(name, rule.Field <string>("ZYFL4"));
                        items.Add(rule);
                    }
                }
            }

            if (items.Count == 0)
            {
                return(identity);
            }

            rules = items.ToArray();

            var builder = new StringBuilder();

            foreach (DataRow rule in rules)
            {
                var DEBH = string.Format("{0}|", rule.Field <string>("DEBH"));
                builder.AppendFormat(DEBH);
                identity.RulesMatched.Add(rule);

                row.Log("已录入定额,号码为:" + DEBH);
            }

            identity.State = IdentityResultStateEnum.Success;
            return(identity);
        }
Пример #2
0
        /// <summary>
        /// 其他清单判断流程
        /// </summary>
        /// <param name="row"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public IdentityResult ProcessOther(Excel row, RulesAdapter db)
        {
            var professional = row.ZY;
            var ID           = row.QDBH;

            row.QDBH = "其他";
            var identity = ProcessOther(row, db, "其他");
            var items    = new Dictionary <string, DataRow>();
            var name     = FormatNameUseGlobalRule(row.QDMC, row.ZY);

            row.QDBH = ID;

            if (identity.State == IdentityResultStateEnum.Success)
            {
                identity.State = IdentityResultStateEnum.Success;

                foreach (DataRow rule in identity.RulesMatched)
                {
                    var limit = rule.Field <string>("BZ2");
                    var unit  = rule.Field <string>("DEDW");

                    if (!string.IsNullOrEmpty(limit) && !string.IsNullOrEmpty(unit))
                    {
                        if (limit.Contains("1") && unit != row.DW.ToUpper() && unit != row.DW.ToLower())
                        {
                            continue;
                        }
                    }

                    var fields = new Fields("express", rule.Field <string>("DEBS"))
                                 .Append("unit", rule.Field <string>("YZJFS"));

                    var pattern = Pattern.Parse(fields);
                    if (pattern == null)
                    {
                        continue;
                    }

                    var newname = FormatNameUseQuotaRule(name, row.ZY, rule);
                    fields.Append("sample", newname);
                    if (pattern.IsMatch(fields) == false)
                    {
                        row.Log(row.QDMC + " 与 " + fields["express"] + " 不匹配");
                        continue;
                    }

                    var group = rule.Field <string>("FZ");

                    if (items.ContainsKey(group) == false)
                    {
                        items[group] = rule;
                        name         = RemoveScopeUseRule(name, rule.Field <string>("ZYFL4"));
                    }
                }
            }

            if (items.Count == 0)
            {
                identity.State = IdentityResultStateEnum.Unable;
                return(identity);
            }

            identity.RulesMatched.Clear();
            foreach (DataRow item in items.Values)
            {
                var DEBH = item.Field <string>("DEBH");
                identity.RulesMatched.Add(item);

                row.Log("已录入定额,号码为:" + DEBH);
            }

            return(identity);
        }
Пример #3
0
        /// <summary>
        /// 开始标识
        /// </summary>
        //public void StartIdentity(DataTable table)
        //{
        //    var excels = Excel.Parse(table);
        //    StartIdentity(excels);
        //}

        //public void StartIdentity(string fileName)
        //{
        //    var excels = Excel.Parse(new ExcelAdapter(fileName).QueryDatatable("SELECT * FROM [Sheet1$]", "sheet1"));
        //    StartIdentity(excels);
        //}



        public IdentityResult Process(ProfessionalEnum professional, Excel excels)
        {
            excels.Log("开始标识" + excels.QDMC);

            //通过专业匹配数据
            var matchedProfessional = Rules.QDFLB.Select("QDFL = '" + excels.ZY + "'");

            //通过编码匹配数据
            var QDFLBs_BM = matchedProfessional.Where(delegate(DataRow row)
            {
                var value = row.Pick("QDBM")["QDBM"];

                if (string.IsNullOrEmpty(value))
                {
                    return(false);
                }

                var QDBMs = value.Split(',');
                foreach (var QDBM in QDBMs)
                {
                    if (excels.QDBH.StartsWith(QDBM))
                    {
                        return(true);
                    }
                }

                return(false);
            }).ToList();

            //通过ZYFL5匹配数据
            var QDFLBs_ZYFL5 = matchedProfessional.Where(delegate(DataRow row)
            {
                var profession = row.Pick("ZYFL5")["ZYFL5"];

                if (string.IsNullOrEmpty(profession))
                {
                    return(true);
                }

                var express = new Fields("express", profession);
                var pattern = Pattern.Parse(express);
                if (pattern == null)
                {
                    return(false);
                }

                var name   = FormatNameUseGlobalRule(excels.QDMC, excels.ZY);
                var sample = new Fields("sample", name);
                return(pattern.IsMatch(sample));
            }).ToList();

            var QDFLBs_BZ1 = QDFLBs_ZYFL5.Where(delegate(DataRow row)
            {
                var value = row.Pick("BZ1")["BZ1"];
                if (string.IsNullOrEmpty(value))
                {
                    return(true);
                }

                return(excels.QDMC.Contains(value));
            }).ToList();

            if (excels.QDBH.Length < 9 || QDFLBs_BM.Count == 0)
            {
                return(ProcessOther(excels, Rules));
            }

            var            index     = -1;
            IdentityResult identityA = new IdentityResult(excels.ID);
            IdentityResult identityB = new IdentityResult(excels.ID);
            IdentityResult identityC = new IdentityResult(excels.ID);

            //A环节
            while (++index < QDFLBs_BM.Count)
            {
                var QDFLB = QDFLBs_BM[index];
                var BZ1   = QDFLB.Field <string>("BZ1");
                var ZYFL5 = QDFLB.Field <string>("ZYFL5");

                if (ZYFL5 == "图集")
                {
                    var identity = ProcessImages(excels, Rules, BZ1);
                    if (identity.State == IdentityResultStateEnum.Success)
                    {
                        identityA.State = IdentityResultStateEnum.Success;
                        identityA.RulesMatched.AddRange(identity.RulesMatched);
                    }
                }
                else
                {
                    excels.Log(ZYFL5 + "非图集");
                }
            }

            if (identityA.State == IdentityResultStateEnum.Success)
            {
                return(identityA);
            }

            index = 0;
            excels.Log("进入 B 流程");

            //B环节
            {
                var identity = ProcessDefault(excels, Rules);
                if (identity.State == IdentityResultStateEnum.Success)
                {
                    identityB.State = IdentityResultStateEnum.Success;
                    identityB.RulesMatched.AddRange(identity.RulesMatched);
                }
            }

            if (identityB.State != IdentityResultStateEnum.Success)
            {
                excels.Log("进入 D 流程");
                return(ProcessOther(excels, Rules));
            }
            else
            {
                return(identityB);
            }
        }