wjc
2022-10-17 cd8cdf7eb281af3b7a5f2b61bd21f1aa0adf7524
2022年10月17日11:51:16

添加地理围栏
1个文件已添加
10个文件已修改
321 ■■■■■ 已修改文件
HDL-ON_Android/SplashActivity.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpServerRequest.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpUtil.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/ResponseEntity/CityInfo.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/HDL_ON.projitems 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/ChooseIocate.cs 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/SplashActivity.cs
@@ -229,6 +229,7 @@
            {
                try
                {
                    if (isfirst)
                    {
                        //只触发一次
HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -1373,6 +1373,9 @@
        /// </summary>
        public void GetCityWeatherInfo(string lon, string lat)
        {
            MainPage.cityInfo.lon = lon;
            MainPage.cityInfo.lat = lat;
            System.Threading.Tasks.Task.Run(() =>
            {
                while (true)
HDL_ON/DAL/Server/HttpUtil.cs
@@ -18,8 +18,8 @@
        /// 公共域名就近解析
        /// </summary>
        public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        /// <summary>
        /// RegionMark
        /// </summary>
HDL_ON/Entity/ResponseEntity/CityInfo.cs
@@ -7,6 +7,15 @@
        {
        }
        /// <summary>
        /// 手机GPS经度
        /// </summary>
        public string lon="0";
        /// <summary>
        /// 手机GPS纬度
        /// </summary>
        public string lat="0";
        /// <summary>
        /// 城市id
        /// </summary>
        public string cid = string.Empty;
HDL_ON/HDL_ON.projitems
@@ -515,6 +515,7 @@
    <Compile Include="$(MSBuildThisFileDirectory)DAL\DriverLayer\Control_Tcp.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)Entity\Function\InverterInfo.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\H5Page.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\ChooseIocate.cs" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" />
HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class AddInputType : FrameLayout
@@ -64,14 +65,14 @@
            likiadaodaView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png";
            int count = 3;//输入类型个数
            //2022年05月24日15:08:22 隐藏掉地理围栏
            //if (MainView.IsGatewayType)
            //{
            //    count = 4;
            //    viewLayout.AddChidren(likiadaodaView.FLayoutView());
            //}
            if (MainView.IsGatewayType)
            {
                count = 4;
                viewLayout.AddChidren(likiadaodaView.FLayoutView());
            }
            ////功能
            ///产品经理君焕要求,设备功能移到这里。<2022-3-7>
            new FunTpye(LogicMethod.condition_if).FunTypeView(viewLayout, shiwaiView.frameLayout.Bottom, count);
            new FunTpye(LogicMethod.condition_if).FunTypeView(viewLayout, likiadaodaView.frameLayout.Bottom, count);
            #endregion
@@ -80,13 +81,13 @@
            timeView.btnClick.MouseUpEventHandler += (sen, e) =>
             {
          TimeTpye timeTpye = new TimeTpye();
          MainPage.BasePageView.AddChidren(timeTpye);
          timeTpye.Show();
          MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                 TimeTpye timeTpye = new TimeTpye();
                 MainPage.BasePageView.AddChidren(timeTpye);
                 timeTpye.Show();
                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
             };
            //场景点击事件
            sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
            {
@@ -113,6 +114,7 @@
            #endregion
        }
        /// <summary>
        /// 添加场景
        /// </summary>
@@ -153,11 +155,14 @@
        /// <param name="edit">If set to <c>true</c> edit.</param>
        public void LocationView(FrameLayout flMain, bool edit)
        {
            string strname = "";
            ///通过调试宝给的经纬度<标准GPS>
            double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//纬度
            double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//经度
            LogicMethod.Current.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude);
            //double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//纬度
            //double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//经度
            /////如果是用当前手机位置作为中心的话;再次编辑ui界面显示是当前手机位置,还是之前的经纬呢?
            double latitude = Convert.ToDouble(MainPage.cityInfo.lat);//纬度
            double longitude = Convert.ToDouble(MainPage.cityInfo.lon);//经度
            int r = 500;//默认半径
            if (edit)
            {
@@ -253,6 +258,151 @@
                //按道理说不会出现
                r = 500;
            }
            ChooseIocate chooseIocate = new ChooseIocate();
            MainPage.BasePageView.AddChidren(chooseIocate);
            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            chooseIocate.Show(latitude, longitude, r, (value) =>
            {
                if (value.Contains("km"))
                {
                    value = value.Replace("km", "");
                }
                else {
                    value = value.Replace("m", "");
                }
                Input input = new Input();
                input.sid = LogicMethod.Current.NewSid();
                input.condition_type = "8";
                Dictionary<string, string> dic = new Dictionary<string, string>();
                LogicMethod.Current.dictionary(dic, "key", "direction");
                LogicMethod.Current.dictionary(dic, "comparator", "=");
                LogicMethod.Current.dictionary(dic, "data_type", "string");
                LogicMethod.Current.dictionary(dic, "value", valueStr);
                input.condition.Add(dic);
                //纬度
                input.geo_fence.latitude = latitude.ToString();
                //经度
                input.geo_fence.longitude = longitude.ToString();
                //半径<单位米>
                input.geo_fence.radius = value;
                AddCondition(input);
                LogicMethod.Current.RemoveAllView();
                AddLogic addLogic = new AddLogic();
                MainPage.BasePageView.AddChidren(addLogic);
                addLogic.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            });
        }
        /// <summary>
        /// 添加地理围栏(有高德地图,因为高德收费暂时弃用)
        /// </summary>
        /// <param name="flMain">Fl main.</param>
        /// <param name="edit">If set to <c>true</c> edit.</param>
        public void LocationView1(FrameLayout flMain, bool edit)
        {
            string strname = "";
            ///通过调试宝给的经纬度<标准GPS>
            double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//纬度
            double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//经度
            LogicMethod.Current.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude);
            int r = 500;//默认半径
            if (edit)
            {
                for (var i = 0; i < Logic.currlogic.input.Count; i++)
                {
                    var input = Logic.currlogic.input[i];
                    if (input.condition_type != "8")
                    {
                        continue;
                    }
                    if (input.condition[0]["value"] == "arrive")
                    {
                        //到达某地
                        strname = Language.StringByID(StringId.daoda);
                    }
                    else
                    {
                        //离开地点
                        strname = Language.StringByID(StringId.likai);
                    }
                    //再一次编辑地理围栏 <控件暂时不支持显示记录上一次的状态>
                    if (!string.IsNullOrEmpty(input.geo_fence.latitude) && !string.IsNullOrEmpty(input.geo_fence.longitude))
                    {
                        ////纬度
                        //var latitude1 = Convert.ToDouble(input.geo_fence.latitude);
                        ////经度
                        //var longitude1 = Convert.ToDouble(input.geo_fence.longitude);
                        //半径
                        r = int.Parse(input.geo_fence.radius);
                        //WGS84坐标转高德坐标
                        //LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(longitude1, latitude1, out longitude, out latitude);
                    }
                }
            }
            PublicInterface publicInterface = new PublicInterface();
            var list = publicInterface.GetViewList("地理围栏");
            publicInterface.SingleSelectionShow(flMain, list, Language.StringByID(StringId.likiadaoda), strname, (str) =>
            {
                string valueStr = "arrive";
                if (str == Language.StringByID(StringId.daoda))
                {
                    //到达某地
                    valueStr = "arrive";
                }
                else
                {
                    //离开
                    valueStr = "leave";
                }
#if __Android__
                       //申请定位权限
                       ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
                       {
                           if (result1 == false) { return; }
                        //申请允许程序写入外部存储,如SD卡上写文件
                        ((BaseActivity)Application.Activity).SetPermission((result2) =>
                        {
                            if (result2 == false) { return; }
                             //读取电话状态权限
                             ((BaseActivity)Application.Activity).SetPermission((result3) =>
                             {
                                 if (result3 == false) { return; }
                                 //调用方法,跳转页面
                                 Location(valueStr, strname, latitude, longitude, r);
                             }, "android.permission.READ_PHONE_STATE");
                        }, "android.permission.WRITE_EXTERNAL_STORAGE");
                       });
#endif
#if __IOS__
               //调用方法,跳转页面
                  Location(valueStr, strname, latitude, longitude, r);
#endif
            });
        }
        /// <summary>
        /// 地理围栏View
        /// </summary>
        /// <param name="valueStr">进入(arrive)或者离开(leave)</param>
        /// <param name="strname"></param>
        /// <param name="latitude">纬度</param>
        /// <param name="longitude">经度</param>
        /// <param name="r">半径(默认500米)</param>
        private void Location1(string valueStr, string strname, double latitude, double longitude, int r)
        {
            if (r == 0)
            {
                //按道理说不会出现
                r = 500;
            }
            //调用方法,跳转页面
            GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
            {
@@ -314,6 +464,6 @@
                Logic.currlogic.input.Add(input);
            }
        }
    }
}
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
@@ -14,6 +14,9 @@
        public void Show()
        {
            #region  界面布局
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            LogicView.TopView topView = new LogicView.TopView();
HDL_ON/UI/UI2/3-Intelligence/Automation/ChooseIocate.cs
New file
@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class ChooseIocate : FrameLayout
    {
        public ChooseIocate()
        {
            Tag = "Logic";
        }
        /// <summary>
        /// 地理围栏View
        /// </summary>
        /// <param name="valueStr">进入(arrive)或者离开(leave)</param>
        /// <param name="strname"></param>
        /// <param name="latitude">纬度</param>
        /// <param name="longitude">经度</param>
        /// <param name="r">半径(默认500米)</param>
        public void Show(double latitude, double longitude, int r, Action<string> action)
        {
            LogicView.TopView topView = new LogicView.TopView();
            this.AddChidren(topView.FLayoutView());
            topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
            {
                RemoveFromParent();
            };
            topView.topNameBtn.Text = "选择定位位置";
            FrameLayout viewLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(64),
                Width = Application.GetRealWidth(LogicView.TextSize.view375),
                Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64),
                BackgroundColor = CSS.CSS_Color.viewMiddle,
            };
            this.AddChidren(viewLayout);
            //当前的经纬度
            LogicView.SelectTypeView lonlatView = new LogicView.SelectTypeView();
            lonlatView.btnIcon.Visible = false;
            lonlatView.btnNextIcon.Visible = false;
            lonlatView.btnText.X = Application.GetRealWidth(16);
            lonlatView.btnLine.X = Application.GetRealWidth(16);
            lonlatView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16);
            lonlatView.btnText.Text = "当前的经纬度";
            lonlatView.btnState.Visible = true;
            lonlatView.btnState.IsMoreLines = true;
            lonlatView.btnState.Height = Application.GetRealHeight(25);
            lonlatView.btnState.Text =latitude.ToString() +"\r\n"+ longitude.ToString();
            viewLayout.AddChidren(lonlatView.FLayoutView());
            //在该位置范围时
            LogicView.SelectTypeView locateView = new LogicView.SelectTypeView();
            locateView.frameLayout.Y = lonlatView.frameLayout.Bottom;
            locateView.btnIcon.Visible = false;
            lonlatView.btnNextIcon.Visible = false;
            locateView.btnText.X = Application.GetRealWidth(16);
            locateView.btnLine.X = Application.GetRealWidth(16);
            locateView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16);
            locateView.btnText.Text = "在该位置范围时";
            locateView.btnState.Visible = true;
            locateView.btnState.Text = this.queryItem(r.ToString());
            viewLayout.AddChidren(locateView.FLayoutView());
            ///保存View
            LogicView.SaveView saveView = new LogicView.SaveView();
            saveView.frameLayout.Y = locateView.frameLayout.Bottom + Application.GetRealHeight(100);
            saveView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            viewLayout.AddChidren(saveView.FLayoutView());
            locateView.btnClick.MouseUpEventHandler += (sen, e) =>
            {
                PublicInterface weekView = new PublicInterface();
                weekView.SingleSelectionShow(this, this.getList(), Language.StringByID(StringId.cyclic), locateView.btnState.Text
                   , (value) =>
                   {
                       //显示选中数据
                       locateView.btnState.Text = value;
                   });
            };
            saveView.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                action(locateView.btnState.Text);
            };
        }
        private string queryItem(string value)
        {
            var item = this.getList().Find((o) => o.Contains(value));
            if (item == null)
            {
                return "";
            }
            return item;
        }
        private List<string> getList()
        {
            return new List<string> {
                    "100m",
                    "200m",
                     "500m",
                      "1000m",
                       "2000m",
                        "5000m",
                };
        }
    }
}
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -1044,7 +1044,7 @@
                            //定义一个局部变量
                            string direction = string.Empty;
                            //两点距离小于配置距离<既自动化配置输入条件地理围栏半径>,说明进入区域
                            if (r < radius)
                            if (r*1000< radius)
                            {
                                //到达某地
                                direction = "arrive";
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
@@ -197,6 +197,7 @@
                logicIfon.Add("pushConfigs", pushConfigsArray);
                logicjArray.Add(logicIfon);
                 var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId }, { "logics", logicjArray } };
                string str = jObject.ToString();
                responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add, "添加自动化", 5);
                //如果是token过期则刷新token
                if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
HDL_ON/UI/UI2/FuntionControlView/Music/MusicMain.cs
@@ -79,6 +79,7 @@
       
        public void Show()
        {
            #region 界面布局
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
@@ -429,6 +430,8 @@
                catch { }
            });
        }
    }
}