Exemple #1
0
        /// <summary>
        /// 获取终端某个回路上绑定的时间表名称
        /// </summary>
        /// <param name="rtuIdorGrpId">特殊终端地址或分组地址</param>
        /// <param name="loopId">回路地址 1~6</param>
        /// <returns>绑定到此回路的时间表名称  无绑定则为 ""</returns>
        public static string GetTmlLoopBandTimeTableNamex(int areaid, int rtuIdorGrpId, int loopId)
        {
            int timetableid = RtuOrGprBandingTimeTableInfoService.GetBandingInfo(areaid, rtuIdorGrpId, loopId);

            if (timetableid == -1)
            {
                return("");
            }
            //int areaid = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoRtuBelong[rtuIdorGrpId].Item1;
            var timetable = WeekTimeTableInfoService.GeteekTimeTableInfo(areaid, timetableid);

            if (timetable == null)
            {
                return("");
            }
            return(timetable.TimeName);
        }
Exemple #2
0
        /// <summary>
        /// 获取绑定到此时间表今天的开关灯时间
        /// </summary>
        /// <param name="rtuIdorGrpId">特殊终端地址或分组地址</param>
        /// <param name="switchoutloopid"></param>
        /// <param name="yesterday">昨天开关灯时间 </param>
        public static TodayOpenCloseTime GetTmlLoopBandTimeTableTodayOpenCloseTimex(int areaid, int rtuIdorGrpId, int switchoutloopid)
        {
            //新协议更改到绑定到终端上  不需要判断分组id   lvf  2019年7月11日09:20:37

            ////int RtuGrpId = 0;
            ////if (Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoRtuBelong.ContainsKey(rtuIdorGrpId))
            ////{
            ////    RtuGrpId =
            ////        Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoRtuBelong[rtuIdorGrpId].Item2;
            ////}
            ////else
            ////{
            ////    RtuGrpId = rtuIdorGrpId;
            ////}

            //采用新协议 细化到终端
            int timetableid = RtuOrGprBandingTimeTableInfoService.GetBandingInfoNew(areaid, rtuIdorGrpId, switchoutloopid);

            //int timetableid = RtuOrGprBandingTimeTableInfoService.GetBandingInfo(areaid,RtuGrpId, switchoutloopid);
            if (timetableid == -1)
            {
                return(null);
            }

            //绑定该时间表的临时方案 2018/4/20
            var plans = (from tt in TimeTabletemporaryHold.Myself.Info
                         where tt.Key.Item1 == areaid
                         orderby tt.Key.Item2 ascending
                         select tt.Value).ToList();
            bool istemporary    = false;
            var  temporarytable = new TempTimePlanWithTimeTableBandingInfo.TimeTablePlan();

            foreach (var t in plans)
            {
                foreach (var tt in t.TimetablesUseThisPlan)
                {
                    foreach (var ttt in t.ItemsPlan)
                    {
                        if (tt == timetableid && ttt.Date.ToString().Substring(6, 2) == DateTime.Now.Day.ToString().PadLeft(2, '0') && ttt.Date.ToString().Substring(4, 2) == DateTime.Now.Month.ToString().PadLeft(2, '0'))
                        {
                            temporarytable = t;
                            istemporary    = true;
                        }
                    }
                }
            }


            var timetable = WeekTimeTableInfoService.GeteekTimeTableInfo(areaid, timetableid);

            if (timetable == null)
            {
                return(null);
            }

            int todayweek = (int)DateTime.Now.DayOfWeek;
            //int yesterdayweek = todayweek - 1;

            //if (yesterdayweek == -1) yesterdayweek = 6;

            //int yesterdaylasttimeoff = 1500;

            // List<Tuple<int, int>> todaytime = new List<Tuple<int, int>>();
            List <Tuple <int, int> > returntime = new List <Tuple <int, int> >();

            if (istemporary)
            {
                foreach (var t in temporarytable.ItemsPlan)
                {
                    var timelight = SunRiseSetInfoServices.GetSunRiseItemInfo(DateTime.Now.Month, DateTime.Now.Day);
                    if (t.Date.ToString().Substring(6, 2) == DateTime.Now.Day.ToString().PadLeft(2, '0') && t.Date.ToString().Substring(4, 2) == DateTime.Now.Month.ToString().PadLeft(2, '0'))
                    {
                        Tuple <int, int> tu = new Tuple <int, int>(t.TimeOn, t.TimeOff);
                        if (t.TypeOn == 3 && t.TypeOff == 3)
                        {
                            tu = new Tuple <int, int>(t.TimeOn, t.TimeOff);
                        }
                        else if (t.TypeOn == 3 && t.TypeOff != 3)
                        {
                            tu = new Tuple <int, int>(t.TimeOn, timelight.time_sunrise + temporarytable.LightOffOffset);
                        }
                        else if (t.TypeOn != 3 && t.TypeOff == 3)
                        {
                            tu = new Tuple <int, int>(timelight.time_sunset + temporarytable.LightOnOffset, t.TimeOff);
                        }
                        else
                        {
                            tu = new Tuple <int, int>(timelight.time_sunset + temporarytable.LightOnOffset,
                                                      timelight.time_sunrise + temporarytable.LightOffOffset);
                        }

                        returntime.Add(tu);
                    }
                }
            }
            else
            {
                foreach (var t in timetable.RuleItems)
                {
                    //if (t.DayOfWeekUsed.Contains(yesterdayweek))
                    //{
                    //    if (t.TimeOn>t.TimeOff)
                    //    {
                    //        if (t.TypeOff == 3) yesterdaylasttimeoff = t.TimeOff;
                    //        else{
                    //            var timelightoff = SunRiseSetInfoServices.GetSunRiseItemInfo(DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day).time_sunrise;
                    //            yesterdaylasttimeoff = timelightoff + timetable.LightOffOffset;
                    //        }

                    //    }
                    //}

                    //if (t.DayOfWeekUsed.Contains(todayweek))
                    //{
                    //    var timelight = SunRiseSetInfoServices.GetSunRiseItemInfo(DateTime.Now.Month, DateTime.Now.Day);
                    //if (t.TimeOn < t.TimeOff)
                    //{
                    //    Tuple<int, int> tu = new Tuple<int, int>(t.TimeOn, t.TimeOff);
                    //    if (t.TypeOn == 3 && t.TypeOff == 3)
                    //    {
                    //        tu = new Tuple<int, int>(t.TimeOn, t.TimeOff);
                    //    }
                    //    else if (t.TypeOn == 3 && t.TypeOff != 3)
                    //    {
                    //        tu = new Tuple<int, int>(t.TimeOn, timelight.time_sunrise + timetable.LightOffOffset);
                    //    }
                    //    else if (t.TypeOn != 3 && t.TypeOff == 3)
                    //    {
                    //        tu = new Tuple<int, int>(timelight.time_sunset + timetable.LightOnOffset, t.TimeOff);
                    //    }
                    //    else
                    //    {
                    //        tu = new Tuple<int, int>(timelight.time_sunset + timetable.LightOnOffset, timelight.time_sunrise + timetable.LightOffOffset);
                    //    }

                    //    todaytime.Add(tu);
                    //}
                    //else
                    //{
                    //    Tuple<int, int> tu = new Tuple<int, int>(t.TimeOn, t.TimeOff);
                    //    if (t.TypeOn == 3)
                    //    {
                    //        tu = new Tuple<int, int>(t.TimeOn, 1500);
                    //    }
                    //    else
                    //    {
                    //        tu = new Tuple<int, int>(timelight.time_sunset + timetable.LightOnOffset, 1500);
                    //    }
                    //    todaytime.Add(tu);
                    //}


                    //   }

                    var timelight = SunRiseSetInfoServices.GetSunRiseItemInfo(DateTime.Now.Month, DateTime.Now.Day);

                    if (t.DayOfWeekUsed.Contains(todayweek))
                    {
                        Tuple <int, int> tu = new Tuple <int, int>(t.TimeOn, t.TimeOff);
                        if (t.TypeOn == 3 && t.TypeOff == 3)
                        {
                            tu = new Tuple <int, int>(t.TimeOn, t.TimeOff);
                        }
                        else if (t.TypeOn == 3 && t.TypeOff != 3)
                        {
                            tu = new Tuple <int, int>(t.TimeOn, timelight.time_sunrise + timetable.LightOffOffset);
                        }
                        else if (t.TypeOn != 3 && t.TypeOff == 3)
                        {
                            tu = new Tuple <int, int>(timelight.time_sunset + timetable.LightOnOffset, t.TimeOff);
                        }
                        else
                        {
                            tu = new Tuple <int, int>(timelight.time_sunset + timetable.LightOnOffset,
                                                      timelight.time_sunrise + timetable.LightOffOffset);
                        }

                        returntime.Add(tu);
                    }
                }
            }


            //var todaytimeitem = (from t in todaytime orderby t.Item1 select t).ToList();

            //if (yesterdaylasttimeoff != 1500)
            //{
            //    if (todaytimeitem.Count > 0)
            //    {
            //        if (todaytimeitem.Last().Item2 == 1500)
            //        {
            //            Tuple<int, int> tu = new Tuple<int, int>(todaytimeitem.Last().Item1, yesterdaylasttimeoff);
            //            todaytimeitem.Remove(todaytimeitem.Last());
            //            todaytimeitem.Add(tu);
            //        }
            //        else
            //        {
            //            Tuple<int, int> tu = new Tuple<int, int>(1500, yesterdaylasttimeoff);
            //            returntime.Add(tu);
            //        }
            //    }

            //}

            //if (todaytimeitem.Count > 0)
            //{
            //    foreach (var tu in todaytimeitem)
            //    {
            //        returntime.Add(tu);
            //    }
            //}

            var today = new TodayOpenCloseTime()
            {
                TimeTableId   = timetable.TimeId,
                TimeTableName = timetable.TimeName,
                TimeOnOff     = returntime
            };

            return(today);

            #region
            //    public static TodayOpenCloseTime GetTmlLoopBandTimeTableTodayOpenCloseTimex(int areaid, int rtuIdorGrpId,int switchoutloopid)
            //{
            //yesterday = null;
            //int timetableid = RtuOrGprBandingTimeTableInfoService.GetBandingInfo(rtuIdorGrpId, switchoutloopid);
            //if (timetableid == -1) return null;
            //var timetable = WeekTimeTableInfoService.GeteekTimeTableInfo(areaid, timetableid);
            //if (timetable == null) return null;

            //var today = new TodayOpenCloseTime()
            //                {
            //                    TimeTableId = timetable.TimeId,
            //                    TimeTableName = timetable.TimeName
            //                };

            //yesterday = new TodayOpenCloseTime()
            //                {
            //                    TimeTableId = timetable.TimeId,
            //                    TimeTableName = timetable.TimeName,
            //                    CloseLightTime = 0,
            //                    OpenLightTime = 0,
            //                };

            //bool find = false;
            //if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday )
            //{


            //    yesterday = new TodayOpenCloseTime()
            //    {
            //        TimeTableId = timetable.TimeId,
            //        TimeTableName = timetable.TimeName,
            //        CloseLightTime = timetable.LastSaturdayOpenCloseControl.TimeOff,
            //        OpenLightTime = timetable.LastSaturdayOpenCloseControl.TimeOn,
            //    };
            //}

            //foreach (var t in timetable.LstOneWeekOpenCloseControl)
            //{
            //    if (t.DateDay == DateTime.Now.Day && t.DateMonth == DateTime.Now.Month)
            //    {
            //        today.CloseLightTime = t.TimeOff;
            //        today.OpenLightTime = t.TimeOn;
            //        find = true;
            //        //  break;
            //    }
            //    if (t.DateMonth == DateTime.Now.AddDays(-1).Month && t.DateDay == DateTime.Now.AddDays(-1).Day)
            //    {


            //        yesterday = new TodayOpenCloseTime()
            //                        {
            //                            TimeTableId = timetable.TimeId,
            //                            TimeTableName = timetable.TimeName,
            //                            CloseLightTime = t.TimeOff,
            //                            OpenLightTime = t.TimeOn,
            //                        };
            //    }
            //}
            //if (find)
            //    return today;
            //CantfindTodayOpenCloseTime(areaid, timetable.TimeId);
            #endregion


            return(null);
        }