/// <summary> /// 跨天处理 /// </summary> private void CrossDay(DateTime nowTime, DateTime tomorrowTime) { try { //DateTime nowTime = time; //nowTime = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, 23, 59, 59); //DateTime tomorrowTime = nowTime.AddDays(1); //tomorrowTime = new DateTime(tomorrowTime.Year, tomorrowTime.Month, tomorrowTime.Day, 0, 0, 0); List <Jc_DefInfo> pointDefineItems; List <Jc_DevInfo> pointDevItems; Jc_DevInfo pointDevItem; IDriver driverObj = null; pointDefineItems = CacheDataHelper.GetAllSystemPointDefineItems(); pointDefineItems = pointDefineItems.Where(a => a.DevPropertyID == (int)DeviceProperty.Substation).ToList(); pointDevItems = CacheDataHelper.GetAllDevItems(); foreach (Jc_DefInfo station in pointDefineItems) { pointDevItem = pointDevItems.FirstOrDefault(a => a.Devid == station.Devid); if (pointDevItem != null) { if (GlobleStaticVariable.driverHandle.DriverItems.ContainsKey(pointDevItem.Sysid)) { driverObj = GlobleStaticVariable.driverHandle.DriverItems[pointDevItem.Sysid].DLLObj; DriverTransferInterface.Drv_CrossDayPro(driverObj, station.Fzh, nowTime, tomorrowTime); } } } //人员定位报警表跨天处理 20171206 KJ237CacheHelper.Drv_CrossDayPro(nowTime, tomorrowTime); } catch (Exception ex) { LogHelper.Error("CrossDay Error:" + ex.Message); } }
/// <summary> /// 跨天和五分钟处理方法 /// </summary> private void CrossDayAndFiveMinite() { DateTime fiveMiniteProcMinite = DateTime.Now; DateTime nowTime = DateTime.Now; List <Jc_DefInfo> pointDefineItems; List <Jc_DevInfo> pointDevItems; Jc_DevInfo pointDevItem; IDriver driverObj = null; int totalcount = 0; bool doFiveMinData = false; //是否要处理五分钟数据 2017.9.15 by for (; ;) { try { doFiveMinData = false; if (isStop) { LogHelper.Info("停止数据处理模块【跨天和五分钟处理方法处理完成】!"); break; } if (DateTime.Now.Day != nowTime.Day) { //2017.12.18 by 异常处理跨天(手动修改电脑时间) CrossDay(new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, 23, 59, 59), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0)); } nowTime = DateTime.Now; //if (nowTime.Hour == 0 && nowTime.Minute == 0) //{ // doFiveMinData = false; //刚跨天00:00:00 满足写记录条件,但不应该写记录 //} //else if (nowTime.Hour == 23 && nowTime.Minute == 59 && nowTime.Second > 40 && nowTime.Minute != fiveMiniteProcMinite.Minute) //2017.9.15 by //{ // doFiveMinData = true; //} //else if ((nowTime.Minute % 5 == 0) && (nowTime.Minute != fiveMiniteProcMinite.Minute)) { doFiveMinData = true; } //if ((nowTime.Minute % 5 == 0) && (nowTime.Minute != fiveMiniteProcMinite.Minute)) if (doFiveMinData) { fiveMiniteProcMinite = nowTime; #region ----五分钟数据处理---- pointDefineItems = CacheDataHelper.GetKJPointDefineItems(); pointDefineItems = pointDefineItems.Where(a => a.DevPropertyID == (int)DeviceProperty.Substation).ToList(); pointDevItems = CacheDataHelper.GetAllDevItems(); foreach (Jc_DefInfo station in pointDefineItems) { pointDevItem = pointDevItems.FirstOrDefault(a => a.Devid == station.Devid); if (pointDevItem != null) { if (GlobleStaticVariable.driverHandle.DriverItems.ContainsKey(pointDevItem.Sysid)) { driverObj = GlobleStaticVariable.driverHandle.DriverItems[pointDevItem.Sysid].DLLObj; DriverTransferInterface.Drv_FiveMinPro(driverObj, station.Fzh, nowTime); } } } #endregion } if (nowTime.Hour == 23 && nowTime.Minute == 59 && nowTime.Second > 50) { isCrossDay = true; #region ----跨天处理---- //判断数据处理线程数据是否处理完成,处理完成才继续进行跨天处理 20170703 while (DataProcHandle.Instance.GetArriveDataCount() > 0) { Thread.Sleep(200); } //处理时已跨天 输出日志 20170703 if (DateTime.Now.Day != nowTime.Day) { Basic.Framework.Logging.LogHelper.Error("处理跨天数据时,时间已到第二天!"); } //DateTime nowTime = time; //nowTime = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, 23, 59, 59); //DateTime tomorrowTime = nowTime.AddDays(1); //tomorrowTime = new DateTime(tomorrowTime.Year, tomorrowTime.Month, tomorrowTime.Day, 0, 0, 0); CrossDay(new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, 23, 59, 59), new DateTime(nowTime.AddDays(1).Year, nowTime.AddDays(1).Month, nowTime.AddDays(1).Day, 0, 0, 0)); //2017.12.18 by 增加手动修改电脑日期处理时增加 while (true) { Thread.Sleep(200); if (DateTime.Now.Hour != 23) { CreatDayTable(DateTime.Now); break; } } #endregion isCrossDay = false; nowTime = DateTime.Now; //正常跨天处理完成,将时间赋值到第二天 } totalcount++; if (totalcount >= 20)//每4秒记算一次馈电信息 { totalcount = 0; CheckAlarmFeeding(); } } catch (Exception ex) { LogHelper.Error("CrossDayAndFiveMinite Error:" + ex.Message); } Thread.Sleep(200); } }