From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs |  308 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 194 insertions(+), 114 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index 803d84e..b2ebfb6 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -48,7 +48,7 @@
                 {
                     case "1":
                         {
-                           
+
                             inputView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
                             foreach (var dic in dicList)
                             {
@@ -130,7 +130,7 @@
                     case "2":
                         {
                             inputView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
-                            string value= this.GetKeyValue("timesection", dicList);
+                            string value = this.GetKeyValue("timesection", dicList);
                             inputView.btnText.Text = Language.StringByID(StringId.timeHorizon) + ": " + value;
                         }
                         break;
@@ -181,7 +181,7 @@
                                         }
                                     }
                                     break;
-                                //浼犳劅鍣�
+                                //绱ф�ユ眰鍔╀紶鎰熷櫒
                                 case SPK.SensorHelp:
                                     {
                                         string value = this.GetKeyValue("alarm_status", dicList);
@@ -218,9 +218,9 @@
                                 case SPK.SensorDryContact2:
                                     {
 
-                                        string value = this.GetKeyValue("on_off", dicList);
+                                        string value = this.GetKeyValue("contact_status", dicList);
                                         inputView.btnState.Text = Language.StringByID(StringId.offLogic);
-                                        if (value == "on")
+                                        if (value == "open")
                                         {
                                             inputView.btnState.Text = Language.StringByID(StringId.onLogic);
                                         }
@@ -418,7 +418,7 @@
                                     break;
                                 case SPK.VideoDoorLock:
                                     {
-                                        string s = string.Empty;
+                                        string userName = string.Empty;
                                         string tag = string.Empty;
                                         for (int b = 0; b < dicList.Count; b++)
                                         {
@@ -429,39 +429,50 @@
                                             //s += ",";
                                             //tag += FaceItem.userId;
                                             //tag += "_";
-                                            var userName = dic["value"].ToString();
-                                            s += userName;
-                                            s += ",";
+                                            userName = dic["value"].ToString();
                                         }
-                                        inputView.btnState.Text = s;
+                                        inputView.btnState.Text = RemoveLastStr(userName);
                                     }
                                     break;
                                 case SPK.doorgate:
                                     {
-                                        string s = string.Empty;
-                                        if (inputCondition.identifier == "door_call_cloud_event")
-                                        {
-                                            s = Language.StringByID(StringId.shipintonghuahujiao);
-                                        }
-                                        else
-                                        {
-                                            for (int b = 0; b < dicList.Count; b++)
-                                            {
-                                                var dic = dicList[b];
-                                                var key = dic["key"].ToString();
-                                                if (key != "user_id")
-                                                {
-                                                    continue;
-                                                }
-                                                var userId = dic["value"].ToString();
-                                                var FaceItem = this.GetFaceItem(userId, device.deviceId);
-                                                s += FaceItem.userName;
-                                                s += ",";
 
+                                        string s = string.Empty;
+                                        try
+                                        {
+                                            if (inputCondition.identifier == "door_call_cloud_event")
+                                            {
+                                                s = Language.StringByID(StringId.shipintonghuahujiao);
+                                            }
+                                            else
+                                            {
+                                                for (int b = 0; b < dicList.Count; b++)
+                                                {
+                                                    var dic = dicList[b];
+                                                    var key = dic["key"].ToString();
+                                                    if (key != "user_id")
+                                                    {
+                                                        continue;
+                                                    }
+                                                    var value = dic["value"].ToString();
+                                                    if (!string.IsNullOrEmpty(value))
+                                                    {
+                                                        var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(value);
+                                                        for (int a = 0; a < list.Count; a++)
+                                                        {
+
+                                                            var FaceItem = this.GetFaceItem(list[a], device.deviceId);
+                                                            s += FaceItem.userName;
+                                                            s += ",";
+
+                                                        }
+                                                    }
+
+                                                }
 
                                             }
-
                                         }
+                                        catch { }
                                         inputView.btnState.Text = s;
                                     }
                                     break;
@@ -475,7 +486,7 @@
                                     }
                                     break;
                                 case SPK.Ev_Ipcam:
-                                    if (inputCondition.identifier == "motiondetect_event")
+                                    if (inputCondition.identifier == Constant.intelligentDetection_event)
                                     {
                                         inputView.btnState.Text = Language.StringByID(StringId.shi);
                                     }
@@ -491,11 +502,11 @@
                                         string value = this.GetKeyValue("people_status", dicList);
                                         if (string.IsNullOrEmpty(value))
                                         {
-                                            inputView.btnState.Text = inputCondition.hold_time + "s";
+                                            inputView.btnState.Text = LogicMethod.Current.getTimeStr(inputCondition.hold_time).Replace("0s", "");
                                             break;
 
                                         }
-                  
+
                                         inputView.btnState.Text = Language.StringByID(StringId.wuren);
                                         if (value == "true")
                                         {
@@ -504,8 +515,19 @@
                                         }
                                         if (!string.IsNullOrEmpty(inputCondition.hold_time) && int.Parse(inputCondition.hold_time) > 0)
                                         {
-
-                                            inputView.btnState.Text += "鎸佺画" + inputCondition.hold_time + "s";
+                                            int time = int.Parse(inputCondition.hold_time);
+                                            inputView.btnState.Text += "鎸佺画" + LogicMethod.Current.getTimeStr(inputCondition.hold_time).Replace("0s", "");
+                                        }
+                                        if (!string.IsNullOrEmpty(inputCondition.detect_type))
+                                        {
+                                            if (inputCondition.detect_type == "1")
+                                            {
+                                                inputView.btnState.Text += "," + Language.StringByID(StringId.gaibiancaizhixing);
+                                            }
+                                            else
+                                            {
+                                                inputView.btnState.Text += "," + Language.StringByID(StringId.shoudaojiuzhixing);
+                                            }
                                         }
 
 
@@ -841,7 +863,7 @@
                                 else if (device.spk == SPK.SensorTemperature)
                                 {
 
-                                   this.SensorView(thisView, device, "temperature", indexVulae);
+                                    this.SensorView(thisView, device, "temperature", indexVulae);
 
                                 }
                                 else if (device.spk == SPK.SensorHumidity)
@@ -1057,6 +1079,7 @@
                                         }
                                     }
                                     break;
+                                case SPK.OtherCommon:
                                 case SPK.AirSwitch:
                                 case SPK.LightSwitch:
                                 //鎻掑骇
@@ -1496,23 +1519,10 @@
                                 case SPK.MusicStandard:
                                 case SPK.AvMusic:
                                     {
+                                        string on_off = GetKeyValue("on_off", dicList);
                                         string song_name = GetKeyValue("song_name", dicList);
                                         string volume = GetKeyValue("volume", dicList);
-                                        stateStr = song_name + ";" + Language.StringByID(StringId.volumeMusic) + volume;
-                                        if (stateStr.StartsWith(";"))
-                                        {
-                                            stateStr = stateStr.Substring(1, stateStr.Length - 1);
-                                        } else if (stateStr.EndsWith(Language.StringByID(StringId.volumeMusic)))
-                                        {
-                                            stateStr = stateStr.Substring(0, stateStr.Length - 3);
-                                        }
-                                    }
-                                    break;
-                                case SPK.ElectricalTvHisense:
-                                    {
-                                        string on_off = GetKeyValue("on_off", dicList);
-                                        string volumet = GetKeyValue("set_volume", dicList);
-                                        string signal = GetKeyValue("signal", dicList);
+
                                         if (!string.IsNullOrEmpty(on_off))
                                         {
                                             if (on_off == "on")
@@ -1522,10 +1532,38 @@
                                             else
                                             {
                                                 stateStr = Language.StringByID(StringId.offLogic);
-                                                //濡傛灉鍏充簡锛屽叾瀹冨睘鎬т笉鏄剧ず
-                                                break;
                                             }
+                                        }
 
+                                        if (!string.IsNullOrEmpty(song_name))
+                                        {
+                                            stateStr += "," + song_name;
+                                        }
+
+                                        if (!string.IsNullOrEmpty(volume))
+                                        {
+                                            stateStr += "," + volume;
+                                        }
+
+                                    }
+                                    break;
+                                case SPK.ElectricalTvHisense:
+                                    {
+                                        string on = GetKeyValue("wol", dicList);
+                                        string off = GetKeyValue("on_off", dicList);
+                                        string volumet = GetKeyValue("set_volume", dicList);
+                                        string signal = GetKeyValue("signal", dicList);
+
+                                        if (!string.IsNullOrEmpty(off))
+                                        {
+                                            stateStr = Language.StringByID(StringId.offLogic);
+                                            //濡傛灉鍏充簡锛屽叾瀹冨睘鎬т笉鏄剧ず
+                                            break;
+                                        }
+
+                                        if (!string.IsNullOrEmpty(on))
+                                        {
+                                            stateStr = Language.StringByID(StringId.onLogic);
                                         }
                                         if (!string.IsNullOrEmpty(stateStr))
                                         {
@@ -1717,6 +1755,7 @@
                     break;
                 case SPK.ElectricSocket:
                 //寮�鍏崇伅鍏�
+                case SPK.OtherCommon:
                 case SPK.AirSwitch:
                 case SPK.LightSwitch:
                 //鏈烘鎵�
@@ -2292,7 +2331,7 @@
                         foreach (var dic in dicList)
                         {
                             string value = dic["value"];
-                            if (value == "on")
+                            if (value == "on" || value == "open")
                             {
                                 button1.Text = Language.StringByID(StringId.onLogic);
                             }
@@ -2460,7 +2499,7 @@
                     break;
                 case SPK.VideoDoorLock:
                     {
-                        string s = string.Empty;
+                        string userName = string.Empty;
                         string tag = string.Empty;
                         for (int b = 0; b < dicList.Count; b++)
                         {
@@ -2471,11 +2510,10 @@
                             //s += ",";
                             //tag += FaceItem.userId;
                             //tag += "_";
-                            var userName = dic["value"].ToString();
-                            s += userName;
-                            s += ",";
+                            userName = dic["value"].ToString();
+
                         }
-                        button1.Text = s;
+                        button1.Text = RemoveLastStr(userName);
                         button1.Tag = tag;
                     }
                     break;
@@ -2484,38 +2522,61 @@
                     {
                         foreach (var dic in dicList)
                         {
-                            if (dic["key"] == "song_name")
+                            if (dic["key"] == "on_off")
                             {
-                                button1.Text = dic["value"]?.ToString();
+                                if (dic["value"] == "on")
+                                {
+                                    button1.Text = Language.StringByID(StringId.onLogic);
+                                }
+                                else
+                                {
+                                    button1.Text = Language.StringByID(StringId.offLogic);
+                                }
+                            }
+                            else if (dic["key"] == "song_name")
+                            {
+                                button2.Text = dic["value"]?.ToString();
                             }
                             else if (dic["key"] == "volume")
                             {
-                                button2.Text = dic["value"]?.ToString();
+                                button3.Text = dic["value"]?.ToString();
                             }
                         }
                     }
                     break;
                 case SPK.doorgate:
                     {
-                        string s = string.Empty;
-                        string tag = string.Empty;
-                        for (int b = 0; b < dicList.Count; b++)
+                        try
                         {
-                            var dic = dicList[b];
-                            var key = dic["key"].ToString();
-                            if (key != "user_id")
+                            string userNameStr = string.Empty; 
+                            string tag = string.Empty;
+                            for (int b = 0; b < dicList.Count; b++)
                             {
-                                continue;
+                                var dic = dicList[b];
+                                var key = dic["key"].ToString();
+                                if (key != "user_id")
+                                {
+                                    continue;
+                                }
+                                var value = dic["value"].ToString();
+                                if (!string.IsNullOrEmpty(value))
+                                {
+                                    var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(value);
+                                    for (int i = 0; i < list.Count; i++)
+                                    {
+
+                                        var FaceItem = this.GetFaceItem(list[i], device.deviceId);
+                                        userNameStr += FaceItem.userName;
+                                        userNameStr += ",";
+                                        tag += FaceItem.userId;
+                                        tag += "_";
+                                    }
+                                }
                             }
-                            var userId = dic["value"].ToString();
-                            var FaceItem = this.GetFaceItem(userId, device.deviceId);
-                            s += FaceItem.userName;
-                            s += ",";
-                            tag += FaceItem.userId;
-                            tag += "_";
+                            button2.Text = RemoveLastStr(userNameStr);
+                            button2.Tag = tag;
                         }
-                        button2.Text = s;
-                        button2.Tag = tag;
+                        catch { }
                     }
                     break;
                 case SPK.ElectricalTvHisense:
@@ -2527,22 +2588,25 @@
                             {
                                 case "on_off":
                                     {
-                                        switch (value)
+                                        if (value == "off")
                                         {
-                                            case "on":
-                                                {
-                                                    button1.Text = Language.StringByID(StringId.onLogic);
-                                                }
-                                                break;
-                                            case "off":
-                                                {
-                                                    button1.Text = Language.StringByID(StringId.offLogic);
-                                                }
-                                                break;
+                                            button1.Text = Language.StringByID(StringId.offLogic);
+
                                         }
+
                                     }
                                     break;
-                                   
+                                case "wol":
+                                    {
+                                        if (value == "on")
+                                        {
+                                            button1.Text = Language.StringByID(StringId.onLogic);
+
+                                        }
+
+                                    }
+                                    break;
+
                                 case "set_volume":
                                     {
                                         if (button2 == null)
@@ -2887,33 +2951,35 @@
         {
             //鍥犱负璋冭瘯杞欢涓婁紶涓虹┖杩�;
             string intTimeValue = string.IsNullOrEmpty(strTimeValue) ? "0" : strTimeValue;
-            var timeValue = int.Parse(intTimeValue);
+            int timeValue = 0;
+            int.TryParse(intTimeValue,out timeValue);
             string state = "";
             var minutes = timeValue / 60;
             var seconds = timeValue % 60;
-            if (minutes != 0)
-            {
-                if (seconds == 0)
-                {
-                    state = minutes.ToString() + Language.StringByID(StringId.minute);
-                }
-                else
-                {
-                    state = minutes.ToString() + Language.StringByID(StringId.minute) + seconds.ToString() + Language.StringByID(StringId.s);
-                }
-            }
-            else
-            {
-                if (seconds != 0)
-                {
-                    state = seconds.ToString() + Language.StringByID(StringId.s);
-                }
-            }
-            if (!string.IsNullOrEmpty(state))
-            {
-                state = Language.StringByID(StringId.delayLogic) + state;
-            }
-            return state;
+            return LogicMethod.Current.getTimeStr(strTimeValue).Replace("0s","");
+            //if (minutes != 0)
+            //{
+            //    if (seconds == 0)
+            //    {
+            //        state = minutes.ToString() + Language.StringByID(StringId.minute);
+            //    }
+            //    else
+            //    {
+            //        state = minutes.ToString() + Language.StringByID(StringId.minute) + seconds.ToString() + Language.StringByID(StringId.s);
+            //    }
+            //}
+            //else
+            //{
+            //    if (seconds != 0)
+            //    {
+            //        state = seconds.ToString() + Language.StringByID(StringId.s);
+            //    }
+            //}
+            //if (!string.IsNullOrEmpty(state))
+            //{
+            //    state = Language.StringByID(StringId.delayLogic) + state;
+            //}
+            //return state;
         }
         /// <summary>
         /// 鑾峰彇鏄剧ず闈㈢啛鏂囨湰
@@ -3005,7 +3071,7 @@
             Input inputedit = Logic.currlogic.input[indexVulae];
             ///鐘舵�佸��
             string stateValue = "";
-            for (int i=0;i<inputedit.condition.Count;i++)
+            for (int i = 0; i < inputedit.condition.Count; i++)
             {
                 var dic = inputedit.condition[i];
                 string comparator = dic["comparator"];
@@ -3106,6 +3172,20 @@
             return face;
         }
 
+        /// <summary>
+        /// 鍒犻櫎鏈�鍚庝竴涓� ","
+        /// </summary>
+        /// <param name="s">瀛楃涓�</param>
+        /// <returns></returns>
+        public string RemoveLastStr(string s)
+        {
+            if (string.IsNullOrEmpty(s))
+            {
+                return string.Empty;
+            }
+            return s.Replace("[","").Replace("]","").Replace("\"","").TrimEnd(',');
+        }
+
     }
 }
 

--
Gitblit v1.8.0