From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 01 十二月 2021 16:32:57 +0800
Subject: [PATCH] 2021-12-01-01
---
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 142 +++++++++++++++++++++++++++--------------------
1 files changed, 82 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..9b788f2 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>
@@ -846,71 +853,86 @@
/// <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鍒楄〃
- 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