Esempio n. 1
0
        public static List <ReservoirWarningRecord> ResGetByWarningList(List <WarningData> listWarning)
        {
            List <ReservoirWarningRecord> listRecord    = new List <ReservoirWarningRecord>();
            List <ReservoirWarningRecord> listRtnRecord = new List <ReservoirWarningRecord>();
            HydrologicReader dbReader = new HydrologicReader();

            foreach (WarningData warning in listWarning)
            {
                ReservoirWarningRecord record = new ReservoirWarningRecord();
                bool   isBeyond           = false;
                double OverWarningLevel   = 0;
                HydrologicEntityItem item = new HydrologicEntityItem();
                int t = dbReader.GetLastWarningData(DateTime.Now.AddDays(-2), DateTime.Now, warning.Uid, out item, out isBeyond, out OverWarningLevel);

                if (item.Basin != null || !item.Basin.Contains("其他"))
                {
                    int index = item.Basin.IndexOf("流域");
                    record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                }
                else
                {
                    record.Basin = item.Basin;
                }

                record.IsBeyond         = isBeyond;
                record.Level            = item.L;
                record.Name             = item.Name;
                record.OverWarningLevel = OverWarningLevel;
                record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                record.River            = item.River;
                record.Time             = item.Time;
                record.WarningLevel     = item.Wl1;

                if (t > 0)
                {
                    record.ComparedBefore = Trend.Rise;
                }
                else if (t == 0)
                {
                    record.ComparedBefore = Trend.Hold;
                }
                else
                {
                    record.ComparedBefore = Trend.Fall;
                }

                if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0))
                {
                    listRecord.Add(record);
                }
            }

            var groupedList = from info in listRecord
                              group info by info.Basin into g
                              select g;

            foreach (var group in groupedList)
            {
                List <ReservoirWarningRecord> toSortList = new List <ReservoirWarningRecord>();

                foreach (var item in group)
                {
                    toSortList.Add(item);
                }
                toSortList.Sort(delegate(ReservoirWarningRecord a, ReservoirWarningRecord b) { return(b.OverWarningLevel.CompareTo(a.OverWarningLevel)); });
                listRtnRecord.AddRange(toSortList);
            }

            return(listRtnRecord);
        }
Esempio n. 2
0
        public static List <ReservoirWarningRecord> GetKeyReservoirWarningInfo()
        {
            List <ReservoirWarningRecord> infoList = new List <ReservoirWarningRecord>();

            HydrologicReader dbReader = new HydrologicReader();
            HydrologicEntity entity   = dbReader.RetrieveEntity(DateTime.Now.AddDays(-1), DateTime.Now, "水库站");  //获取最近1天水库站最新水情

            foreach (var item in entity.Items)
            {
                if ((item.L - item.Wl1) > -20 && item.Issign == true)  //超过监测门限-20且为重点站
                {
                    ReservoirWarningRecord record = new ReservoirWarningRecord();

                    if (item.Basin != null)
                    {
                        int index = item.Basin.IndexOf("流域");
                        record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                    }
                    else
                    {
                        record.Basin = item.Basin;
                    }

                    if (item.L > item.Wl1)
                    {
                        record.IsBeyond = true;
                    }
                    else
                    {
                        record.IsBeyond = false;
                    }

                    record.Level            = item.L;
                    record.Name             = item.Name;
                    record.OverWarningLevel = item.L - item.Wl1;
                    record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                    record.River            = item.River;
                    record.Stationid        = item.Stationid;
                    record.Time             = item.Time;
                    record.WarningLevel     = item.Wl1;
                    int tr = dbReader.ComparedWithRecent(item, DateTime.Now.AddDays(-2), DateTime.Now);  //最近2天内的最新趋势
                    if (tr > 0)
                    {
                        record.ComparedBefore = Trend.Rise;
                    }
                    else if (tr == 0)
                    {
                        record.ComparedBefore = Trend.Hold;
                    }
                    else
                    {
                        record.ComparedBefore = Trend.Fall;
                    }

                    if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0))
                    {
                        infoList.Add(record);
                    }
                }
            }

            return(infoList);
        }