private IList<EAreaAlertSetting> GetExistThisSetting(EAreaAlertSetting alertSetting)
 {
     using (IRepository repository = SessionManager.CreateRepository(typeof(EAreaAlertSetting)))
     {
         Expression expression = null;
         Query query = new Query(typeof(EAreaAlertSetting));
         ExpressionUtility<Guid>.AddExpression("VehicleCode", alertSetting.VehicleCode, BinaryOperatorType.EqualTo, ref expression);
         query.Expression = expression;
         return repository.List<EAreaAlertSetting>(query);
     }
 }
示例#2
0
        private bool IsInRange(EGPSCurrentInfo current, EAreaAlertSetting areaSet)
        {
            Polygon polygon = new Polygon(areaSet.Area.Points);
            double x = Convert.ToDouble(current.Latitude);
            double y = Convert.ToDouble(current.Longitude);
            Point point = new Point(x, y);

            return Polygon.PointInPolygon(point, polygon);
        }
示例#3
0
        private void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAreaAlert enumAreaAlert, EAreaAlertSetting areaSet, bool isAlert)
        {
            DateTime dt1 = DateTime.Now;
            EAreaAlertReport alertReport = this.CreateAlertReport(context, current, enumAreaAlert, areaSet);
            GPSServiceFacade.Report.Area.Add<EAreaAlertReport>(alertReport);
            Logger.Info(string.Format("Static_AreaAlertReportService.Add<EAreaAlertReport>(alertReport)共花销{0}毫秒", (DateTime.Now - dt1).TotalMilliseconds));

            if (isAlert)
            {
                if (areaSet.EnableSMS || areaSet.Enable)
                {
                    if (areaSet.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                    {
                        this.SendSMS(context, alertReport);
                    }
                    if (areaSet.Enable && this.IsInUserReceiveTime(alertReport))
                    {
                        this.SendWebSiteSMS(context, alertReport);
                    }
                }
            }
        }
示例#4
0
        public EAreaAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAreaAlert state, EAreaAlertSetting alertSetting)
        {
            EAreaAlertReport newReport = new EAreaAlertReport();

            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.EnumSMSInfoType = EnumSMSInfoType.Area;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.GPSCode = current.GPSCode;
            newReport.GPSReportTime = current.ReportTime;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.IntoRegion;
            newReport.IsInArea = state != EnumAreaAlert.OutArea ? true : false;
            newReport.Area = alertSetting.Area;

            if (state == EnumAreaAlert.OutArea)
            {
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.OutRegion;
                EAreaAlertReport inReport = GPSServiceFacade.Report.Area.GetRectInAreaEntity(newReport.Area.RecordID, newReport.VehicleCode, newReport.GPSReportTime);
                if (inReport != null)
                {
                    newReport.InAreaID = inReport.RecordID;
                    newReport.StayTime = newReport.GPSReportTime - inReport.GPSReportTime;
                }
            }
            else if (state == EnumAreaAlert.DelayStay)
            {
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.DelayOutRegion;
                EAreaAlertReport inReport = GPSServiceFacade.Report.Area.GetRectInAreaEntity(newReport.Area.RecordID, newReport.VehicleCode, newReport.GPSReportTime);
                if (inReport != null)
                {
                    newReport.InAreaID = inReport.RecordID;
                    newReport.StayTime = newReport.GPSReportTime - inReport.GPSReportTime;
                }
                newReport.IsDelayStay = true;
                newReport.DelayDuration = alertSetting.DelayDuration;
            }

            return newReport;
        }
示例#5
0
        // 之间在区域内而且停留时间超过设置中的最大停留时间。
        private bool IsInRangeBeforeAndDelayStayNow(EGPSCurrentInfo current, EAreaAlertSetting areaSet, bool isInRangeNow)
        {
            bool isReachCondition = false;

            VTempAreaWarning tempAreaWarning = AlarmLastStatusService.Singleton.GetLastAreaWarning(current, areaSet);
            if (tempAreaWarning != null)
            {
                if (tempAreaWarning.IsInArea == (int)EnumAreaAlert.InArea)
                {
                    // 如果当前停留时间大于区域延时设置最大停留时间
                    TimeSpan stayTime = current.ReportTime - tempAreaWarning.FirstInAreaTime;
                    if (stayTime.TotalMinutes > (double)areaSet.DelayDuration)
                    {
                        string logs = string.Format("stayTime:{0}秒,current reportTime:{1},firstInAreaTime:{2}", stayTime.TotalSeconds, current.ReportTime, tempAreaWarning.FirstInAreaTime);
                        Logger.Info(logs);
                        if (tempAreaWarning.LastWarnTime == null)//如果上一次报警时间为空,则表示第一次报警
                        {
                            isReachCondition = true;
                        }
                        //else//如果第二次报警时间和上一次报警时间相减速的间隔大于5分钟则符合条件。
                        //{
                        //    TimeSpan alarmTimespan = _gpsCurrentInfo.ReportTime - tempAreaWarning.LastWarnTime.Value;
                        //    if (alarmTimespan.TotalMinutes > DealyGoOutAlarmInterval)
                        //    {
                        //        isReachCondition = true;
                        //    }
                        //}
                    }
                }
            }

            if (isReachCondition)
            {
                tempAreaWarning.LastWarnTime = current.ReportTime;
                AlarmLastStatusService.Singleton.SaveLastAreaWarning(current, areaSet, tempAreaWarning);   //更新上一次报警时间
            }
            return isReachCondition;
        }
示例#6
0
        private bool IsInRangeBefore(EGPSCurrentInfo current, EAreaAlertSetting areaSet, bool isInRangeNow)
        {
            VTempAreaWarning tempAreaWarning = AlarmLastStatusService.Singleton.GetLastAreaWarning(current, areaSet);
            if (tempAreaWarning == null)
            {
                tempAreaWarning = new VTempAreaWarning();
                tempAreaWarning.AreaCode = areaSet.Area.RecordID;
                tempAreaWarning.GPSCode = current.GPSCode;
                tempAreaWarning.IsInArea = isInRangeNow ? 1 : 0;
                tempAreaWarning.ReportTime = current.ReportTime;
                tempAreaWarning.VehicleCode = current.VehicleCode.Value;

                AlarmLastStatusService.Singleton.SaveLastAreaWarning(current, areaSet, tempAreaWarning);
                return false;
            }

            bool isIn = (tempAreaWarning.IsInArea == (int)EnumAreaAlert.InArea);
            tempAreaWarning.IsInArea = isInRangeNow ? 1 : 0;
            tempAreaWarning.ReportTime = current.ReportTime;
            AlarmLastStatusService.Singleton.SaveLastAreaWarning(current, areaSet, tempAreaWarning);

            return isIn;
        }
        public void RemoveLastAreaWarning(EGPSCurrentInfo current, EAreaAlertSetting areaSet)
        {
            string key = CONST_KEY_LAST_AREA_STATUS + areaSet.Area.RecordID.ToString() + "_" + current.VehicleCode.Value.ToString();

            this.CachedService.Remove(key);
        }
        public void SaveLastAreaWarning(EGPSCurrentInfo current, EAreaAlertSetting areaSet, VTempAreaWarning status)
        {
            if (status == null) return;

            string key = CONST_KEY_LAST_AREA_STATUS + areaSet.Area.RecordID.ToString() + "_" + current.VehicleCode.Value.ToString();

            this.CachedService.Add(key, status, DateTime.Now.AddDays(1));
        }
        public VTempAreaWarning GetLastAreaWarning(EGPSCurrentInfo current, EAreaAlertSetting areaSet)
        {
            if (!current.VehicleCode.HasValue) return null;

            string key = CONST_KEY_LAST_AREA_STATUS + areaSet.Area.RecordID.ToString() + "_" + current.VehicleCode.Value.ToString();

            return this.CachedService.Get(key) as VTempAreaWarning;
        }