Example #1
0
 public SampleItemsIqcRecordManager()
 {
     irep         = new SampleItemsIpqcRecordReposity();
     SampleManger = new SampleManger();
 }
        /// <summary>
        ///  得到放宽加严重规划
        /// </summary>
        /// <param name="sampleMaterial">抽检的料号</param>
        /// <param name="theclass">类别</param>
        /// <returns></returns>
        public string GetCheckWayBy(string sampleMaterial, string theclass)
        {
            Dictionary <string, string> Paramter = GetAllParamterDictionaryBy(theclass);
            string JudgeWay = Paramter["JudgeWay"].Trim();

            //如果没有设置限制
            if (JudgeWay == "False")
            {
                return("正常");
            }
            int    AB          = Paramter["AB"].ToInt();
            int    AC          = Paramter["AC"].ToInt();
            int    BA          = Paramter["BA"].ToInt();
            int    CA          = Paramter["CA"].ToInt();
            int    ABI         = Paramter["ABI"].ToInt();
            int    ACI         = Paramter["ACI"].ToInt();
            int    BAI         = Paramter["BAI"].ToInt();
            int    CAI         = Paramter["CAI"].ToInt();
            string OldCheckWay = string.Empty;

            var SampleRecord = new SampleManger().SampleIqcRecordManager.GetIQCSampleRecordModelsBy(sampleMaterial).OrderByDescending(e => e.Id_key);
            var chekWay      = from r in SampleRecord.Take(1)
                               select r.CheckWay;

            foreach (var r in chekWay)
            {
                OldCheckWay = (r != null ? r.ToString() : string.Empty);
            }

            if (OldCheckWay == string.Empty)
            {
                return("正常");
            }
            if (OldCheckWay == "正常")
            {
                int A  = (AB > AC) ? AB : AC;      // 得到最大的检验批次
                int B  = (AB <= AC) ? AB : AC;     // 得到最小的检验批次
                int C  = (ABI > ACI) ? ACI : ABI;  // 按理说ABI必须小于ACI
                int D  = (ABI <= ACI) ? ACI : ABI; // 取最大值
                var mm = SampleRecord.Take(A);
                if (mm.Count() < B | mm == null)
                {
                    return("正常");                            //实得到实体数小于最小的抽样批次
                }
                //下面是 实得到实体数大于等于 最小的缺抽样批次
                var n = from r in mm
                        where r.SampleResult == "FAIL"
                        orderby r.FinishDate descending
                        select r;
                if (n.Count() <= C | n == null)
                {
                    return("放宽");                           //实得到FAIL实体数小于最小的
                }
                //下面是 实体数FAIL数 大于等于 最小的
                if (n.Count() >= D)
                {
                    return("加严");                 // 排除 FAIL数 大于等于 最大数时
                }
                var mmm = mm.Take(B);
                var nn  = from r in mmm
                          where r.SampleResult == "FAIL"
                          orderby r.FinishDate descending
                          select r;
                if (nn.Count() <= C | n == null)
                {
                    return("放宽");
                }
                else
                {
                    return("正常");
                }
            }
            if (OldCheckWay == "放宽")
            {
                var mm = SampleRecord.Take(BA);
                var n  = from r in mm
                         where r.SampleResult == "FAIL"
                         orderby r.FinishDate descending
                         select r;
                return((n.Count() <= BAI | mm == null) ? "放宽" : "正常");
            }
            if (OldCheckWay == "加严")
            {
                var mm = SampleRecord.Take(CA);
                var n  = from r in mm
                         where r.SampleResult == "FAIL"
                         orderby r.FinishDate descending
                         select r;
                return((n.Count() > CAI | mm == null) ? "加严" : "正常");
            }
            return("正常");
        }