首页 > 学院 > 开发设计 > 正文

计算断面达标情况

2019-11-06 08:48:19
字体:
来源:转载
供稿:网友
public string LoadControlRate(int year, int month, string PRovince, string stationType = "省份")        {            var monidata = efhelper.FindAll<T_DATA_RiverMonitorMonth>().Where(t => t.Year == year && t.Month == month);//t.SectionCode == "110000_0001".OrderByDescending(t => t.Month)            var target=efhelper.FindAll<T_BAS_WaterTarget>().Where(t=>t.Year==year);            var data=(from m in monidata                     join t in target on m.SectionCode equals t.Sectioncode                     select new                     {                         m.SectionCode,                         m.Province,                         m.Year,                         m.DissolutionO,                         KMn =  m.KMn,                         m.ChemistryO,                         m.BOD5,                         m.NH4N,                         m.P,                         m.N,                         m.Cu,                         m.Zn,                         m.Fluoride,                         m.Se,                         m.AsAs,                         m.Hg,                         m.Cd,                         m.Cr6,                         m.Pb,                         m.Cyanide,                         m.Volatilization,                         m.Petroleum,                         m.AnSurfactant,                         m.SX,                         m.EscherichiaColi,                         WaterType=t.TargetLevel,                         specialOne=t.SpecialItem,                         specialTwo=t.SpecialItem2,                         valueOne = t.SpecialValue,                         valueTwo = t.SpecialValue2                     }).ToList();            var s1 = data;            var datas = from m in data                        select new                         {                            m.SectionCode,                            m.Province,                            m.Year,                            DissolutionO = Convert.ToDecimal((m.DissolutionO.IndexOf("L") > -1 || m.DissolutionO.IndexOf("#") > -1 || m.DissolutionO.IndexOf("E") > -1) ? "0" : m.DissolutionO),                            KMn = Convert.ToDecimal((m.KMn.IndexOf("L") > -1 || m.KMn.IndexOf("#") > -1 || m.KMn.IndexOf("E") > -1) ? "0" : m.KMn),                            ChemistryO = Convert.ToDecimal((m.ChemistryO.IndexOf("L") > -1 || m.ChemistryO.IndexOf("#") > -1 || m.ChemistryO.IndexOf("E") > -1) ? "0" : m.ChemistryO),                            BOD5 = Convert.ToDecimal((m.BOD5.IndexOf("L") > -1 || m.BOD5.IndexOf("#") > -1 || m.BOD5.IndexOf("E") > -1) ? "0" : m.BOD5),                            NH4N = Convert.ToDecimal((m.NH4N.IndexOf("L") > -1 || m.NH4N.IndexOf("#") > -1 || m.NH4N.IndexOf("E") > -1) ? "0" : m.NH4N),                            P = Convert.ToDecimal((m.P.IndexOf("L") > -1 || m.P.IndexOf("#") > -1 || m.P.IndexOf("E") > -1) ? "0" : m.P),                            N = Convert.ToDecimal((m.N.IndexOf("L") > -1 || m.N.IndexOf("#") > -1 || m.N.IndexOf("E") > -1) ? "0" : m.N),                            Cu = Convert.ToDecimal((m.Cu.IndexOf("L") > -1 || m.Cu.IndexOf("#") > -1 || m.Cu.IndexOf("E") > -1) ? "0" : m.Cu),                            Zn = Convert.ToDecimal((m.Zn.IndexOf("L") > -1 || m.Zn.IndexOf("#") > -1 || m.Zn.IndexOf("E") > -1) ? "0" : m.Zn),                            Fluoride = Convert.ToDecimal((m.Fluoride.IndexOf("L") > -1 || m.Fluoride.IndexOf("#") > -1 || m.Fluoride.IndexOf("E") > -1) ? "0" : m.Fluoride),                            Se = Convert.ToDecimal((m.Se.IndexOf("L") > -1 || m.Se.IndexOf("#") > -1 || m.Se.IndexOf("#") > -1 || m.Se.IndexOf("E") > -1) ? "0" : m.Se),                            AsAs = Convert.ToDecimal((m.AsAs.IndexOf("L") > -1 || m.AsAs.IndexOf("#") > -1 || m.AsAs.IndexOf("E") > -1) ? "0" : m.AsAs),                            Hg = Convert.ToDecimal((m.Hg.IndexOf("L") > -1 || m.Hg.IndexOf("#") > -1 || m.Hg.IndexOf("E") > -1) ? "0" : m.Hg),                            Cd = Convert.ToDecimal((m.Cd.IndexOf("L") > -1 || m.Cd.IndexOf("#") > -1 || m.Cd.IndexOf("E") > -1) ? "0" : m.Cd),                            Cr6 = Convert.ToDecimal((m.Cr6.IndexOf("L") > -1 || m.Cr6.IndexOf("#") > -1 || m.Cr6.IndexOf("E") > -1) ? "0" : m.Cr6),                            Pb = Convert.ToDecimal((m.Pb.IndexOf("L") > -1 || m.Pb.IndexOf("#") > -1 || m.Pb.IndexOf("E") > -1) ? "0" : m.Pb),                            Cyanide = Convert.ToDecimal((m.Cyanide.IndexOf("L") > -1 || m.Cyanide.IndexOf("#") > -1 || m.Cyanide.IndexOf("E") > -1) ? "0" : m.Cyanide),                            Volatilization = Convert.ToDecimal((m.Volatilization.IndexOf("L") > -1 || m.Volatilization.IndexOf("#") > -1 || m.Volatilization.IndexOf("E") > -1) ? "0" : m.Volatilization),                            Petroleum = Convert.ToDecimal((m.Petroleum.IndexOf("L") > -1 || m.Petroleum.IndexOf("#") > -1 || m.Petroleum.IndexOf("E") > -1) ? "0" : m.Petroleum),                            AnSurfactant = Convert.ToDecimal((m.AnSurfactant.IndexOf("L") > -1 || m.AnSurfactant.IndexOf("#") > -1 || m.AnSurfactant.IndexOf("E") > -1) ? "0" : m.AnSurfactant),                            SX = Convert.ToDecimal((m.SX.IndexOf("L") > -1 || m.SX.IndexOf("#") > -1 || m.SX.IndexOf("E") > -1) ? "0" : m.SX),                            EscherichiaColi = Convert.ToDecimal((m.EscherichiaColi.IndexOf("L") > -1 || m.EscherichiaColi.IndexOf("#") > -1 || m.EscherichiaColi.IndexOf("E") > -1) ? "0" : m.EscherichiaColi),                            m.WaterType,                            m.specialOne,                            m.specialTwo,                            m.valueOne,                            m.valueTwo                                                };            var d1 = datas.ToList();            var dd=0;            List<WaterQualityType> list = new List<WaterQualityType>();            //达标            foreach (var item in datas)            {                list.Add(new WaterQualityType                {                    SectionCode = item.SectionCode,                    Province=item.Province,                    Type = WaterQualityType.GetSectionStandard(item.DissolutionO, item.KMn, item.ChemistryO, item.BOD5, item.NH4N, item.P                    , item.N, item.Cu, item.Zn, item.Fluoride, item.Se, item.AsAs, item.Hg, item.Cd, item.Cr6, item.Pb, item.Cyanide                    , item.Volatilization, item.Petroleum, item.AnSurfactant, item.SX, item.EscherichiaColi, 1, item.WaterType.Value                    , item.specialOne, item.specialTwo, item.valueOne, item.valueTwo)                });            }            List<ControlRate> ctrl = new List<ControlRate>();            var ll = list.GroupBy(t =>t.Province).Select(t => new ControlRate            {                code=t.Key,                upStd=t.Where(x=>x.Type==0).Count(),                subStd = t.Where(x => x.Type == 1).Count(),                upsub=t.Count(),                rate = Convert.ToDecimal(t.Where(x => x.Type == 0).Count()) / Convert.ToDecimal(t.Count())            }).ToList();            return ll.ToJson();        }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表