| | |
| | | /// <summary> |
| | | /// APP上报GPS经纬度 |
| | | /// </summary> |
| | | public void AppLatAndLonEvent() |
| | | /// <param name="lon">APP GPS经度</param> |
| | | /// <param name="lat">APP GPS纬度</param> |
| | | public void AppLatAndLonEvent(double lon, double lat) |
| | | { |
| | | Application.LocationAction += (lon, lat) => |
| | | { |
| | | ////GPS坐标转成高德坐标 |
| | | //double out_lng, out_lat; |
| | | //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat); |
| | | //上报经纬度 |
| | | Console.WriteLine($"GPS经度===={lon} \nGPS纬度===={lat}"); |
| | | //Application.LocationAction += (lon, lat) => |
| | | //{ |
| | | // Console.WriteLine($"GPS经度===={lon}"); |
| | | // Console.WriteLine($"GPS纬度===={lat}"); |
| | | // ////GPS坐标转成高德坐标 |
| | | // //double out_lng, out_lat; |
| | | // //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat); |
| | | // //上报经纬度 |
| | | // this.AutomatedGeofenceStatusReporting(lon, lat); |
| | | //}; |
| | | //上报经纬度<gps 上报条件大于30秒且移动距离大于100米,上报经纬度> |
| | | this.AutomatedGeofenceStatusReporting(lon, lat); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="out_lat">APP GPS纬度</param> |
| | | private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat) |
| | | { |
| | | if (IsOthreShare) |
| | | { |
| | | //不是主账号直接返回 |
| | | return; |
| | | } |
| | | List<LogicData> logicDataList = new List<LogicData>(); |
| | | logicDataList.Clear(); |
| | | //获取逻辑ID列表 |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | //获取逻辑ID列表,目前针对所有<备注:如果只针对当前手机的话,可以直接拿缓存数据自动化列表遍历> |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | | { |
| | |
| | | logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); |
| | | } |
| | | ///有自动列表才处理 |
| | | if (logicDataList.Count>0) { |
| | | if (logicDataList.Count > 0) |
| | | { |
| | | ///遍历所有列表 |
| | | for (int i = 0; i < logicDataList.Count; i++) |
| | | { |
| | |
| | | //经纬度为空,认为自动化没有配置地理围栏,不处理; |
| | | 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); |
| | |
| | | //定义一个局部变量 |
| | | string direction = string.Empty; |
| | | //两点距离小于配置距离<既自动化配置输入条件地理围栏半径>,说明进入区域 |
| | | if (r<radius) { |
| | | if (r < radius) |
| | | { |
| | | //到达某地 |
| | | direction = "arrive"; |
| | | } else { |
| | | } |
| | | else |
| | | { |
| | | //离开 |
| | | direction = "leave"; |
| | | } |
| | | bool f= Send.GeoFenceStateReport(logicDate.userLogicId,logicDate.sid, direction); |
| | | //if () { } |
| | | //Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | ///遍历缓存列表<不为空说明数据已经推送过,不再推送> |
| | | var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction); |
| | | if (isPush == null) |
| | | { |
| | | //推送给云端是否成功 |
| | | bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction); |
| | | if (push) |
| | | { |
| | | ///添加到推送列表 |
| | | pushList.Add(new Push |
| | | { |
| | | homeId = HomeId, |
| | | userId = UserInfo.Current.ID, |
| | | userLogicId = logicDate.userLogicId, |
| | | sid = logicDate.sid, |
| | | arriveOnLeave = direction, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch { } |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// 推送列表<这里数据已经推送过> |
| | | /// </summary> |
| | | private static List<Push> pushList = new List<Push>(); |
| | | |
| | | } |
| | | public class Push |
| | | { |
| | | /// <summary> |
| | | /// 云端唯一id |
| | | /// </summary> |
| | | public string userLogicId = ""; |
| | | /// <summary> |
| | | /// 网关id |
| | | /// </summary> |
| | | public string gatewayId = ""; |
| | | /// <summary> |
| | | /// 逻辑唯一标识 |
| | | /// </summary> |
| | | public string sid = ""; |
| | | /// <summary> |
| | | /// 住宅id |
| | | /// </summary> |
| | | public string homeId = ""; |
| | | /// <summary> |
| | | /// 到达某地 离开 |
| | | /// </summary> |
| | | public string arriveOnLeave = ""; |
| | | /// <summary> |
| | | /// 用户id |
| | | /// </summary> |
| | | public string userId = ""; |
| | | |
| | | } |
| | | } |