From 136b9e2fc48249a5ff89874f1080ba94130e7a9e Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 19 五月 2020 11:12:29 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into dev-2020xm --- ZigbeeApp/Shared/Common/Device.cs | 122 +++++++++++++++++++++++++++------------- 1 files changed, 83 insertions(+), 39 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 0be27e0..f1bc1e4 100644 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -1954,26 +1954,10 @@ /// <param name="saveRoadDevice">濡傛灉鍙湁涓�涓洖璺�,鏄惁鎶婂洖璺殑鎴块棿涓�璧蜂慨鏀�</param> public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true) { - if (listDevice != null) + if (listDevice == null) { - if (roomId == string.Empty) - { - //閫夋嫨鐨勬槸鏈垎閰� - this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr); - } - else - { - this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; - } + return; } - - //淇濆瓨璁板綍 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); - UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); - - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); - //濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜� if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1) { @@ -1983,6 +1967,41 @@ return; } HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false); + } + bool save = false; + if (roomId == string.Empty) + { + //閫夋嫨鐨勬槸鏈垎閰� + this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr); + save = true; + } + else + { + if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false) + { + this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; + save = true; + } + else + { + //2020.05.18杩藉姞:濡傛灉璁板綍鐨勬埧闂碔D鏄笉瀛樺湪鐨勮瘽,鍒欓噸鏂拌鐩� + var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]); + if (room == null) + { + this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; + save = true; + } + } + } + + if (save == true) + { + //淇濆瓨璁板綍 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); + UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); + + //娣诲姞鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); } } @@ -2052,6 +2071,25 @@ //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); + } + + /// <summary> + /// 鏍规嵁鎴块棿ID,绉婚櫎鎸囧畾鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�灞炴埧闂磋褰� + /// </summary> + /// <param name="i_RoomId"></param> + public void DeleteRealDeviceByRoomId(string i_RoomId) + { + var listDeleteKey = new List<string>(); + foreach (var deviceAddr in this.dicDeviceRoomId.Keys) + { + if (this.dicDeviceRoomId[deviceAddr] == i_RoomId + && listDeleteKey.Contains(deviceAddr) == false) + { + listDeleteKey.Add(deviceAddr); + } + } + //灏嗙湡瀹炵墿鐞嗚澶囦粠鎴块棿涓Щ闄� + this.DeleteRealDeviceFromRoom(listDeleteKey); } #endregion @@ -2149,26 +2187,15 @@ listDevice = this.GetDeviceByGatewayID(gwId); } - var dicDevice = new Dictionary<string, CommonDevice>(); + var listCheck = new HashSet<string>(); + var listReturn = new List<CommonDevice>(); foreach (var device in listDevice) { - if (dicDevice.ContainsKey(device.DeviceAddr) == false) + if (listCheck.Contains(device.DeviceAddr) == false) { - dicDevice[device.DeviceAddr] = device; - continue; + listCheck.Add(device.DeviceAddr); + listReturn.Add(device); } - //璁惧鏄惁澶勪簬鍦ㄧ嚎鐘舵�� - bool online = this.CheckDeviceIsOnline(device); - if (online == true) - { - //濡傛灉璁惧鍥炶矾鍦ㄧ嚎,鍒欎紭鍏堜娇鐢ㄥ湪绾跨殑鍥炶矾,鍚庢潵鐨勭洿鎺ヨ鐩� - dicDevice[device.DeviceAddr] = device; - } - } - var listReturn = new List<CommonDevice>(); - foreach (var device in dicDevice.Values) - { - listReturn.Add(device); } return listReturn; } @@ -2184,8 +2211,18 @@ /// <returns></returns> public bool CheckDeviceIsOnline(CommonDevice i_device) { - //0:绂荤嚎 1:鍦ㄧ嚎 2:姝e湪鍒锋柊鐘舵�� - return i_device.IsOnline == 1 || i_device.IsOnline == 2; + var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false); + foreach (var device in listDevice) + { + //0:绂荤嚎 1:鍦ㄧ嚎 2:姝e湪鍒锋柊鐘舵�� + bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2; + if (statu == true) + { + //鏈変竴涓洖璺湪绾�,鍗冲湪绾� + return true; + } + } + return false; } /// <summary> @@ -2415,8 +2452,14 @@ if (listCheck.Contains(mainkeys) == false) { listDevice.Add(device); - listCheck.Add(mainkeys); + //鍒锋柊涓�涓嬫湰鍦扮紦瀛� + var localDevice = this.GetDevice(mainkeys); + if (localDevice != null) + { + //鍒锋柊灞炴�� + this.SetDeviceInfoToMain(localDevice, device); + } } } } @@ -2596,8 +2639,9 @@ //濡傛灉鏄笁璺户鐢靛櫒鐨勫洖璺殑璇�,榛樿涓虹伅鍏� else if (mainDevice.Type == DeviceType.OnOffOutput) { - var myType = this.GetHdlMyDeviceEnumInfo(mainDevice); - if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad) + //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏� + //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice); + //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad) { if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�) { -- Gitblit v1.8.0