| | |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报云端 |
| | | /// </summary> |
| | | /// <param name="out_lng">APP经度</param> |
| | | /// <param name="out_lat">APP纬度</param> |
| | | /// <param name="out_lng">APP GPS经度</param> |
| | | /// <param name="out_lat">APP GPS纬度</param> |
| | | private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat) |
| | | { |
| | | List<LogicData> logicDataList = new List<LogicData>(); |
| | | logicDataList.Clear(); |
| | | //获取逻辑ID列表 |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | |
| | | ///自动化没有配置地理围栏不处理 |
| | | if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude)) |
| | | { |
| | | //经纬度为空,不处理 |
| | | //经纬度为空,认为自动化没有配置地理围栏,不处理; |
| | | continue; |
| | | } |
| | | //自动化纬度 |
| | | double lat = Convert.ToDouble(logicDate.geo_fence.latitude); |
| | | //自动化经度 |
| | | double lon = Convert.ToDouble(logicDate.geo_fence.longitude); |
| | | //自动化半径<单位米> |
| | | //自动化配置输入条件<地理围栏半径><单位,公里、千米.米> |
| | | int radius = int.Parse(logicDate.geo_fence.radius); |
| | | //计算2个经纬度之间的距离 |
| | | int r =Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon); |
| | | //定义一个局部变量 |
| | | string direction = string.Empty; |
| | | //两点距离小于配置距离<既自动化配置输入条件地理围栏半径>,说明进入区域 |
| | | if (r<radius) { |
| | | //到达某地 |
| | | direction = "arrive"; |
| | | } else { |
| | | //离开 |
| | | direction = "leave"; |
| | | } |
| | | bool f= Send.GeoFenceStateReport(logicDate.userLogicId,logicDate.sid, direction); |
| | | //if () { } |
| | | |
| | | //Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | |
| | | } |