From e7385e16297cc9659d0cc0eaf3cdf0786a3d35ce Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期三, 24 十一月 2021 15:49:53 +0800 Subject: [PATCH] 2021-11-24-01 --- HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 136 +++++++++++++++++++++++++-------------------- 1 files changed, 76 insertions(+), 60 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs index c6f3113..6c1e70f 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs @@ -827,16 +827,23 @@ /// <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); - //涓婃姤缁忕含搴� - this.AutomatedGeofenceStatusReporting(lon, 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> @@ -848,69 +855,78 @@ { List<LogicData> logicDataList = new List<LogicData>(); logicDataList.Clear(); - //鑾峰彇閫昏緫ID鍒楄〃 - var idStr = Send.GetLogicIdList(); - if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") + System.Threading.Tasks.Task.Run(() => { - var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); - logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); - } - ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊 - if (logicDataList.Count > 0) - { - ///閬嶅巻鎵�鏈夊垪琛� - for (int i = 0; i < logicDataList.Count; i++) + try { - var logicDate = logicDataList[i]; - ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊 - if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude)) + //鑾峰彇閫昏緫ID鍒楄〃<澶囨敞:濡傛灉鍙拡瀵瑰綋鍓嶆墜鏈虹殑璇濓紝鍙互鐩存帴鎷跨紦瀛樻暟鎹嚜鍔ㄥ寲鍒楄〃閬嶅巻> + var idStr = Send.GetLogicIdList(); + if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") { - //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�; - continue; + var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); + logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); } - //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴� - 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) + ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊 + if (logicDataList.Count > 0) { - //鍒拌揪鏌愬湴 - direction = "arrive"; - } - else - { - //绂诲紑 - direction = "leave"; - } - 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) + ///閬嶅巻鎵�鏈夊垪琛� + for (int i = 0; i < logicDataList.Count; i++) { - pushList.Add(new Push + var logicDate = logicDataList[i]; + ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊 + if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude)) { - homeId = HomeId, - userId = UserInfo.Current.ID, - userLogicId = logicDate.userLogicId, - arriveOnLeave = direction, - }); + //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�; + 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"; + } + 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>(); -- Gitblit v1.8.0