diff --git a/CRICS_V3_1124.suo b/CRICS_V3_1124.suo index df7ac96..ceb19bf 100644 Binary files a/CRICS_V3_1124.suo and b/CRICS_V3_1124.suo differ diff --git a/CommonEntity/CommonEntity.csproj b/CommonEntity/CommonEntity.csproj index 96ffe9a..873c302 100644 --- a/CommonEntity/CommonEntity.csproj +++ b/CommonEntity/CommonEntity.csproj @@ -73,6 +73,7 @@ + diff --git a/CommonEntity/LMRegisterInfo.cs b/CommonEntity/LMRegisterInfo.cs new file mode 100644 index 0000000..5d0212f --- /dev/null +++ b/CommonEntity/LMRegisterInfo.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CommonEntity +{ + public class LMRegisterInfo + { + // 基础信息 + public string HotelCode { get; set; } + public string RoomNumber { get; set; } + public string HostNumber { get; set; } + public string MAC { get; set; } + + // 网络信息 + public string EndPoint { get; set; } + public byte[] Original_Data { get; set; } + public string CurrentDateTime { get; set; } + public long UnixTime { get; set; } + //public string ConfigVersion { get; set; } + //public string SubnetMask { get; set; } + //public string Gateway { get; set; } + //public string DNS { get; set; } + } +} diff --git a/CommonEntity/TCLToken.cs b/CommonEntity/TCLToken.cs index d948f95..bc10a32 100644 --- a/CommonEntity/TCLToken.cs +++ b/CommonEntity/TCLToken.cs @@ -21,6 +21,17 @@ namespace CommonEntity public long deadline { get; set; } public string refresh_token { get; set; } } + public class TCLBell + { + public string cuid { get; set; } + public string sceneCode { get; set; } + public string botId { get; set; } + public PPP @params { get; set; } + } + public class PPP + { + public string url { get; set; } + } public class TCLCommon { @@ -59,7 +70,7 @@ namespace CommonEntity /// /// /// - public static void SendData(string hotelcode, string roomnum, string CUID, string skillid, string sceneCode, int count = 0,Dictionary extra_params=null) + public static void SendData(string hotelcode, string roomnum, string CUID, string skillid, string sceneCode, int count = 0, Dictionary extra_params = null) { try { @@ -77,7 +88,7 @@ namespace CommonEntity dic1.Add("cuid", roomnum); dic1.Add("sceneCode", sceneCode); dic1.Add("botId", skillid); - dic1.Add("params",Newtonsoft.Json.JsonConvert.SerializeObject(extra_params)); + dic1.Add("params", Newtonsoft.Json.JsonConvert.SerializeObject(extra_params)); logger.Error("TCL send data"); @@ -108,12 +119,22 @@ namespace CommonEntity request1.AddHeader("Authorization", "Bearer " + T.data.access_token); - Dictionary dic = new Dictionary(); - dic.Add("cuid", CUID); - dic.Add("sceneCode", sceneCode); - dic.Add("botId", skillid); + //Dictionary dic = new Dictionary(); + //dic.Add("cuid", CUID); + //dic.Add("sceneCode", sceneCode); + //dic.Add("botId", skillid); + //dic.Add("params", Newtonsoft.Json.JsonConvert.SerializeObject(extra_params)); - request1.AddJsonBody(dic); + TCLBell tsa = new TCLBell(); + tsa.cuid = CUID; + tsa.sceneCode = sceneCode; + tsa.botId = skillid; + if (extra_params != null && extra_params.Count > 0) + { + tsa.@params = new PPP() { url = extra_params["url"] }; + } + + request1.AddJsonBody(tsa); var QQQ = client1.Execute(request1); string ddd = QQQ.Content; diff --git a/RCUHost/Implement/HostSearchReceiver.cs b/RCUHost/Implement/HostSearchReceiver.cs index c1d64d4..d5e7d7c 100644 --- a/RCUHost/Implement/HostSearchReceiver.cs +++ b/RCUHost/Implement/HostSearchReceiver.cs @@ -85,10 +85,10 @@ namespace RCUHost.Implement int startIndex = StructConverter.SizeOf(context.SystemHeader); SearchHostPacketReply? reply = DecodeSearchHostPacketReply(context.Data, startIndex); - SearchHostPacketReplyV2? reply2 = null; + SearchHostPacketReplyV2? C_Xilie_zhuji = null; if (context.Data.Length > 100)//V2版本新补充的内容 { - reply2 = DecodeSearchHostPacketReplyV2(context.Data, 58); + C_Xilie_zhuji = DecodeSearchHostPacketReplyV2(context.Data, 58); } if (reply.HasValue) { @@ -103,7 +103,7 @@ namespace RCUHost.Implement Host exitEntity = null; StringBuilder sbSQL = new StringBuilder(); sbSQL.Append("UPDATE tb_Hosts SET "); - if (reply2.HasValue)//C系列主机处理:只能靠后台手工添加 + if (C_Xilie_zhuji.HasValue)//C系列主机处理:只能靠后台手工添加 { #region C系列主要 if (string.IsNullOrEmpty(context.SystemHeader.Value.HostNumber.ToString())) @@ -140,7 +140,7 @@ namespace RCUHost.Implement MemoryCacheHelper.Set(KKK1, EEE); MemoryCacheHelper.SlideSet(KKK2, EEE); } - exitEntity.DNS = string.Join(".", reply2.Value.DNS); + exitEntity.DNS = string.Join(".", C_Xilie_zhuji.Value.DNS); sbSQL.Append("DNS='" + exitEntity.DNS + "'"); if (!version.ToUpper().StartsWith("C")) { diff --git a/RCUHost/Implement/HostServer.cs b/RCUHost/Implement/HostServer.cs index 667ac38..79e0239 100644 --- a/RCUHost/Implement/HostServer.cs +++ b/RCUHost/Implement/HostServer.cs @@ -1231,6 +1231,15 @@ namespace RCUHost.Implement }, TS); } + public static SearchHostPacketReply? DecodeSearchHostPacketReply(byte[] data, int startIndex) + { + return StructConverter.BytesToStruct(data, startIndex, typeof(SearchHostPacketReply)) as SearchHostPacketReply?; + } + + public static SearchHostPacketReplyV2? DecodeSearchHostPacketReplyV2(byte[] data, int startIndex) + { + return StructConverter.BytesToStruct(data, startIndex, typeof(SearchHostPacketReplyV2)) as SearchHostPacketReplyV2?; + } //private static readonly RecyclableMemoryStreamManager manager = new RecyclableMemoryStreamManager(); /// /// 处理数据 @@ -1335,6 +1344,45 @@ namespace RCUHost.Implement } #endregion + ///注册指令 也要推送 + if (cmdType == 0x01) + { + string RoomNUMBER = CSRedisCacheHelper.HMGet(5, CacheKey.RoomNumber_HostNumber, HostNNN)[0]; + if (string.IsNullOrEmpty(RoomNUMBER)) + { + return; + } + int startIndex = StructConverter.SizeOf(context111.SystemHeader); + SearchHostPacketReply? reply = DecodeSearchHostPacketReply(context111.Data, startIndex); + //SearchHostPacketReplyV2? C_Xilie_zhuji = null; + //if (context111.Data.Length > 100)//V2版本新补充的内容 + //{ + // C_Xilie_zhuji = DecodeSearchHostPacketReplyV2(context111.Data, 58); + //} + string MAC = ""; + if (reply.HasValue) + { + MAC = BitConverter.ToString(reply.Value.MAC); + //string version = reply.Value.Version; + //var ConfigVersion = String.Join(".", reply.Value.ConfigVersion); + //var SubnetMask = String.Join(".", reply.Value.SubnetMask); + //var Gateway = String.Join(".", reply.Value.Gateway); + } + + LMRegisterInfo lma = new LMRegisterInfo(); + lma.HotelCode = CODE; + lma.RoomNumber = RoomNUMBER; + lma.HostNumber = HostNNN; + lma.MAC = MAC; + lma.Original_Data = context111.Data; + + string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + lma.CurrentDateTime = ti; + lma.UnixTime = Tools.GetUnixTime(); + + string sss = Newtonsoft.Json.JsonConvert.SerializeObject(lma); + CSRedisCacheHelper.Publish("redis-0X01", sss); + } try { @@ -2286,7 +2334,7 @@ namespace RCUHost.Implement var CarbonVIP = reader.ReadByte(); int Bright_Va = -1; - if (Version == 0x03) + if (Version == 0x03 || Version == 0x04) { var LiangDu = reader.ReadBytes(4); Bright_Va = (int)LiangDu[0]; @@ -2298,6 +2346,40 @@ namespace RCUHost.Implement { CarbonVIP = 0x00; } + + ///碳达人状态更新 + if (!string.IsNullOrEmpty(HostID)) + { + string KKey = CacheKey.HostModalStatus_Prefix + "_" + HostID + "_" + "054000001"; + //var OldHostModal = CSRedisCacheHelper.Get_Partition(KKey); + //OldHostModal.Status = CarbonVIP; + + //CSRedisCacheHelper.Set_Partition(KKey,OldHostModal); + + + StringBuilder sb = new StringBuilder(); + sb.Append(CacheKey.CarbonVIP_Prefix); + sb.Append("_"); + sb.Append(HostID.ToString()); + string Key = sb.ToString(); + + string current_status_new = ""; + if (CarbonVIP == 0x01) + { + current_status_new = "open"; + } + else if (CarbonVIP == 0x02) + { + current_status_new = "close"; + } + else + { + current_status_new = "unknow"; + } + + CSRedisCacheHelper.Set(Key, current_status_new); + } + var DeviceCount = reader.ReadByte(); int DeviceCount_I = (int)DeviceCount; @@ -2307,7 +2389,11 @@ namespace RCUHost.Implement List kongtiaoList = new List(); for (int i = 0; i < DeviceCount_I; i++) { - var QA = reader.ReadBytes(4); + byte[] QA = reader.ReadBytes(4); + //if (Version == 0x04) + //{ + // QA = reader.ReadBytes(5); + //} //说明是能耗设备 #region 能耗 if (QA[0] == 0x39) @@ -2413,6 +2499,14 @@ namespace RCUHost.Implement ///ushort StatusReceiver = reader.ReadUInt16(); ushort StatusReceiver = BitConverter.ToUInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); + int XiaoShu_BuFen = 0; + float xiaoshu_l = 0.0f; + if (Version == 0x04) + { + var XiaoShu = reader.ReadByte(); + XiaoShu_BuFen = XiaoShu; + xiaoshu_l = XiaoShu_BuFen / 10; + } if (true) { @@ -2436,7 +2530,7 @@ namespace RCUHost.Implement kkk.address = address; kkk.model = mode; kkk.speed = fanspeed; - kkk.now_temp = currentTemp; + kkk.now_temp = Convert.ToInt32((currentTemp + xiaoshu_l) * 10); kkk.set_temp = temperature; kkk.solenoid_valve = valve; kongtiaoList.Add(kkk); @@ -2556,8 +2650,9 @@ namespace RCUHost.Implement } catch (Exception ex) { - logger.Error("定是上报出错:" + ex.Message); - logger.Error("定是上报出错:" + ex.StackTrace); + logger.Error("定时上报出错:" + Tools.ByteToString(context111.Data)); + logger.Error("定时上报出错:" + ex.Message); + logger.Error("定时上报出错:" + ex.StackTrace); } } #endregion diff --git a/RCUHost/Implement/New_RoomStatusReceiver.cs b/RCUHost/Implement/New_RoomStatusReceiver.cs index 4650c4d..6821c8e 100644 --- a/RCUHost/Implement/New_RoomStatusReceiver.cs +++ b/RCUHost/Implement/New_RoomStatusReceiver.cs @@ -583,7 +583,6 @@ namespace RCUHost.Implement if (!string.IsNullOrEmpty(ebell_rtsp)) { ddd.Add("url",ebell_rtsp); - ddd.Add("display_duration",du.ToString()); } TCLCommon.SendData(hotelcode, roomnum, TCLcuid, skillid, "DOORBELL",0,ddd); diff --git a/WebSite/Controllers/IoTController.cs b/WebSite/Controllers/IoTController.cs index a11ae87..f826636 100644 --- a/WebSite/Controllers/IoTController.cs +++ b/WebSite/Controllers/IoTController.cs @@ -475,15 +475,22 @@ namespace WebSite.Controllers actions.Add("setVolumeMute"); break; default: - if ((hostModal.Modal.Name != null && hostModal.Modal.Name.IndexOf("灯") > -1) || - (hostModal.Modal.EnglishName != null && hostModal.Modal.EnglishName.ToLower().IndexOf("light") > -1) || - (hostModal.Modal.TWName != null && hostModal.Modal.TWName.IndexOf("燈") > -1)) + if (hostModal.Modal.ModalAddress.Equals("004000010")) { - applianceTypes.Add("LIGHT"); + applianceTypes.Add("DOOR_LOCK"); } else { - applianceTypes.Add("SWITCH"); + if ((hostModal.Modal.Name != null && hostModal.Modal.Name.IndexOf("灯") > -1) || + (hostModal.Modal.EnglishName != null && hostModal.Modal.EnglishName.ToLower().IndexOf("light") > -1) || + (hostModal.Modal.TWName != null && hostModal.Modal.TWName.IndexOf("燈") > -1)) + { + applianceTypes.Add("LIGHT"); + } + else + { + applianceTypes.Add("SWITCH"); + } } actions.Add("turnOn"); actions.Add("turnOff");