diff --git a/CRICS_V3_1124.suo b/CRICS_V3_1124.suo index fd26002..f464c84 100644 Binary files a/CRICS_V3_1124.suo and b/CRICS_V3_1124.suo differ diff --git a/Common/OnOffLineData.cs b/Common/OnOffLineData.cs index 55d34c8..8e96055 100644 --- a/Common/OnOffLineData.cs +++ b/Common/OnOffLineData.cs @@ -10,8 +10,10 @@ namespace Common public string HotelCode { get; set; } public string MAC { get; set; } public string HostNumber { get; set; } + public string RoomNumber { get; set; } public string EndPoint { get; set; } public string CurrentStatus { get; set; } public DateTime CurrentTime { get; set; } + } } diff --git a/Common/XuanZhuOperation.cs b/Common/XuanZhuOperation.cs index 96c628d..f276c63 100644 --- a/Common/XuanZhuOperation.cs +++ b/Common/XuanZhuOperation.cs @@ -137,6 +137,13 @@ namespace Common /// public int valve { get; set; } } + public class XuanZhuResponse_Fault + { + public XuanZhuResponse data { get; set; } + public DateTime updatetime { get; set; } + + public string url { get; set; } + } public class XuanZhuResponse { /// diff --git a/CommonEntity/CacheKey.cs b/CommonEntity/CacheKey.cs index 7fb01f8..57f2eda 100644 --- a/CommonEntity/CacheKey.cs +++ b/CommonEntity/CacheKey.cs @@ -125,6 +125,9 @@ namespace CommonEntity public static string WebChatDeviceFault = "WXFault"; public static string DuOSToken = "DuOSToken"; public static string XuanZhuKafka = "XZ_DeviceStatusChange"; + public static string FaultKey_ = "FaultKey_"; + + public static string ServerStartTime = "ServerStartTime"; } public class ChangLiangValue { diff --git a/CommonEntity/DataTongJi.cs b/CommonEntity/DataTongJi.cs index 1d531a2..208e72b 100644 --- a/CommonEntity/DataTongJi.cs +++ b/CommonEntity/DataTongJi.cs @@ -233,7 +233,27 @@ namespace CommonEntity public string Mac { get; set; } public string EndPoint { get; set; } public string Version { get; set; } + /// + /// 这个叫是否 取电 取断电状态 + /// public bool IsTakeCard { get; set; } + + /// + ///短离长离 + ///我们这里叫卡事件 + /// + public ushort CardEvent { get; set; } + + /// + /// 卡身份 + /// + public ushort CardID { get; set; } + + /// + /// PMS 状态 + /// + public string PMS_Status { get; set; } + public int CarbonVIP { get; set; } public double V { get; set; } public double A { get; set; } diff --git a/ConsoleApplication2/Program.cs b/ConsoleApplication2/Program.cs index b9280bf..3d50bf8 100644 --- a/ConsoleApplication2/Program.cs +++ b/ConsoleApplication2/Program.cs @@ -249,6 +249,8 @@ namespace ConsoleApplication2 } static void Main(string[] args) { + var DDD = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"); + Console.WriteLine(DDD); var qqqhj = CSRedisCacheHelper.Get_Partition("HostModalStatusReceiver_13_000000001"); var qq223= JsonConvert.DeserializeObject(File.ReadAllText("3.txt")); RedisTest(); diff --git a/RCUHost/Implement/HostServer.cs b/RCUHost/Implement/HostServer.cs index 46e61cf..dafae84 100644 --- a/RCUHost/Implement/HostServer.cs +++ b/RCUHost/Implement/HostServer.cs @@ -63,6 +63,7 @@ namespace RCUHost.Implement #endregion + //public System.Timers.Timer FaultReport = new System.Timers.Timer(); #region Public Properies /// @@ -155,6 +156,12 @@ namespace RCUHost.Implement /// public void Start() { + var DDD = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"); + CSRedisCacheHelper.Forever(CacheKey.ServerStartTime, DDD); + //FaultReport.Interval = 10000; + //FaultReport.Elapsed += new System.Timers.ElapsedEventHandler(FaultReport_Elapsed); + //FaultReport.Start(); + Close(); //CSRedisCacheHelper.StreamAdd(1,UDPAllDataKey, data); @@ -183,14 +190,62 @@ namespace RCUHost.Implement } }, i, TaskCreationOptions.LongRunning); } + } catch (Exception ex) { logger.Error("Host Server启动失败,端口:3339"); Close(); - //throw ex;//不能去掉,否则重启iis服务,通讯服务不会再次启动 + throw ex;//不能去掉,否则重启iis服务,通讯服务不会再次启动 } } + + + //public Random rs = new Random(); + ///// + ///// 定时上报 错误 + ///// + ///// + ///// + //void FaultReport_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + //{ + // try + // { + + // //FaultReport.Stop(); + // string FaultKey = CacheKey.FaultKey_; + // //string FFFFFKey = HotelCode + "_" + host.RoomNumber + "_" + hostModal.Modal.ModalAddress; + // var data = CSRedisCacheHelper.HMGetAll(5, FaultKey); + // foreach (var item in data) + // { + // var key = item.Key; + // var val = item.Value; + // var v = JsonConvert.DeserializeObject(val); + // TimeSpan span = DateTime.Now - v.updatetime; + // if (span.TotalSeconds <= 20) + // { + // var fault_data = new Tuple(v.url, v.data); + // Task.Factory.StartNew((State) => + // { + // var DDD = State as Tuple; + // string Res_P = MyHttp.SendHttpData(DDD.Item1, DDD.Item1); + // //XuanZhuOperation.ReportService(DDD.Item1, DDD.Item2); + // logger.Error("Fault Return:" + ""); + // }, fault_data); + // } + // } + // } + // catch (Exception) + // { + + // } + // finally + // { + // var ts = rs.Next(10000, 15000); + // FaultReport.Interval = ts; + // FaultReport.Start(); + // } + //} /// /// 关闭 HostServer /// @@ -1180,22 +1235,37 @@ namespace RCUHost.Implement if (true) { #region 只要有数据包,就是心跳 - - string Key = context111.SystemHeader.Value.HostNumber.ToString(); - string EEE = CSRedisCacheHelper.Get(Key); - if (string.IsNullOrEmpty(EEE)) - { - OnOffLineData o = new OnOffLineData(); - o.HostNumber = Key; - o.HotelCode = hotelCode; - o.CurrentStatus = "on"; - o.CurrentTime = DateTime.Now; - o.EndPoint = context111.RemoteEndPoint.ToString(); - //新来的数据 - var n = Newtonsoft.Json.JsonConvert.SerializeObject(o); - //CSRedisCacheHelper.Publish("redis-on_off_line", n); - } string EndPointStr = context111.RemoteEndPoint.ToString(); + + OnOffLineData o = new OnOffLineData(); + string RoomNUMBER = CSRedisCacheHelper.HMGet(5, CacheKey.RoomNumber_HostNumber, HostNNN)[0]; + if (!string.IsNullOrEmpty(RoomNUMBER)) + { + o.RoomNumber = RoomNUMBER; + } + o.HostNumber = HostNNN; + o.HotelCode = hotelCode; + o.CurrentStatus = "on"; + o.CurrentTime = DateTime.Now; + o.EndPoint = EndPointStr; + //新来的数据 + var n = Newtonsoft.Json.JsonConvert.SerializeObject(o); + CSRedisCacheHelper.Set_PartitionWithTime(EndPointStr, n, 5, 4); + + + //上线 + string EEE = CSRedisCacheHelper.Get(EndPointStr); + var dtstart = CSRedisCacheHelper.ForeverGet(CacheKey.ServerStartTime); + DateTime SSS = DateTime.Now; + DateTime.TryParse(dtstart, out SSS); + TimeSpan ssspan = DateTime.Now - SSS; + if (string.IsNullOrEmpty(EEE) && ssspan.TotalMinutes > 5) + { + CSRedisCacheHelper.Publish("redis-on_off_line", n); + } + + + CSRedisCacheHelper.Set(context111.SystemHeader.Value.HostNumber.ToString(), context111.RemoteEndPoint.Address.ToString() + ":" + context111.RemoteEndPoint.Port.ToString());//主机编码 string KKF = context111.SystemHeader.Value.HostNumber.ToString(); @@ -1830,27 +1900,18 @@ namespace RCUHost.Implement //取电 var TakeCardStatus = reader.ReadByte(); - //string QUDIANKey = CacheKey.NewVersionDeviceStatus + "_" + HostNNN; - //var hostModal = CSRedisCacheHelper.HMGet(1, QUDIANKey, "004000001"); - - //if (hostModal[0] != null) - //{ - // hostModal[0].Status = TakeCardStatus; - // CSRedisCacheHelper.HMSet(1, QUDIANKey, "004000001", hostModal); - //} - //else - //{ - // NewVersionDeviceStatus n = new NewVersionDeviceStatus(); - // n.Status = TakeCardStatus; - // n.HotelCode = CODE; - // n.HostNumber = HostNNN; - // n.ModalType = DeviceType.ServiceInfo; - // n.UpdateTime = DateTime.Now; - // CSRedisCacheHelper.HMSet(1, QUDIANKey, "004000001", n); - //} - //身份 var IdentityInfo = reader.ReadByte(); + + //无卡逻辑状态(对应事件状态) + //0x01:开门进入事件 + //0x02:卡在人离事件 + //0x03:无卡人离事件 + //0x04:室内雷达有人事件 + //0x05:室内雷达无人事件 + //0x06:室内按键触发 + //0x07:短暂人离事件 + //0x08:长时间人离事件 var NOCardInfo = reader.ReadByte(); //服务信息全部回路状态 1~64 64Bit 0 :关 1:开 @@ -1858,6 +1919,7 @@ namespace RCUHost.Implement var N = reader.ReadBytes(8); BitArray bitlist = new BitArray(N); + #region 服务信息 for (int i = 0; i < bitlist.Length; i++) { if (i == 1) @@ -1908,7 +1970,9 @@ namespace RCUHost.Implement // CSRedisCacheHelper.HMSet(1, QUDIANKey, "004000" + SerNo, n); //} } + #endregion + string PMS_CurrentStatus = ""; //PMS房态 //定时上报,之后要设置房态,要用0C //只会上报 01 出租,02退房 @@ -1923,6 +1987,10 @@ namespace RCUHost.Implement //IReceiver receiver1 = receivers[CommandType.RoomStatusChanged]; //(receiver1 as RoomStatusChangedReceiver).SendRoomStatusSelfWithFrameNo("111", "2222", new RoomStatus { ID = 10 }, framenolist);//处理业务逻辑 + if (Q != null) + { + PMS_CurrentStatus = Q.Status.Name; + } if (Q != null && PMS != Q.Status.ID) { IReceiver receiver = receivers[CommandType.RoomStatusChanged]; @@ -2027,7 +2095,10 @@ namespace RCUHost.Implement CreateTime = n.CreateTime, ReportTime = n.ReportTime.ToString("yyyy-MM-dd HH:mm:ss"), AllDeviceData = DeviceStatusList, - IdentityInfo = IdentityInfo + IdentityInfo = IdentityInfo, + CardID = IdentityInfo, + CardEvent = NOCardInfo, + PMS_Status = PMS_CurrentStatus }; string mns = Newtonsoft.Json.JsonConvert.SerializeObject(ns2); diff --git a/RCUHost/Implement/New_RoomStatusReceiver.cs b/RCUHost/Implement/New_RoomStatusReceiver.cs index 1198635..ad5c7b0 100644 --- a/RCUHost/Implement/New_RoomStatusReceiver.cs +++ b/RCUHost/Implement/New_RoomStatusReceiver.cs @@ -1269,7 +1269,8 @@ namespace RCUHost.Implement if (XuanZhuHotelData.dataArray.Contains(int.Parse(codesss))) { XuanZhuRequest resp5 = new XuanZhuRequest(); - resp5.code = host.SysHotel.Code; + //resp5.code = host.SysHotel.Code; + resp5.code = host.SysHotel.Code + "@" + host.SysHotel.CreatedDate.ToString("yyyy-MM-dd"); resp5.roomNumber = host.RoomNumber; resp5.devicetype = hostModal.ModalType.ToString(); resp5.address = hostModal.Modal.ModalAddress; @@ -1644,6 +1645,7 @@ namespace RCUHost.Implement }; string KKK = CacheKey.WebChatDeviceFault + "_" + resp1.code + "_" + resp1.roomNumber; CSRedisCacheHelper.redis_webchat.HMSet(KKK, resp1.address, resp1); + //出现异常信息时上报 if (!string.IsNullOrEmpty(host.SysHotel.FaultPushURL)) { @@ -1657,6 +1659,19 @@ namespace RCUHost.Implement faultType = fault.Value.Type, faultData = fault.Value.Data }; + + + //XuanZhuResponse_Fault hfault = new XuanZhuResponse_Fault() + //{ + // data = resp, + // updatetime = DateTime.Now, + // url = host.SysHotel.FaultPushURL + //}; + + //string FaultKey = CacheKey.FaultKey_; + //string FFFFFKey = HotelCode + "_" + host.RoomNumber + "_" + hostModal.Modal.ModalAddress; + //CSRedisCacheHelper.HMSet(5, 60, FaultKey, FFFFFKey, resp); + //var u = Newtonsoft.Json.JsonConvert.SerializeObject(resp); //logger.Error("logger report fault: "+u); var fault_data = new Tuple(host.SysHotel.FaultPushURL, resp); diff --git a/RCUHost/Implement/RoomStatusReceiver.cs b/RCUHost/Implement/RoomStatusReceiver.cs index 7139d04..e274273 100644 --- a/RCUHost/Implement/RoomStatusReceiver.cs +++ b/RCUHost/Implement/RoomStatusReceiver.cs @@ -1906,7 +1906,7 @@ namespace RCUHost.Implement if (XuanZhuHotelData.dataArray.Contains(int.Parse(codesss))) { XuanZhuRequest resp1 = new XuanZhuRequest(); - resp1.code = host.SysHotel.Code; + resp1.code = host.SysHotel.Code + "@" + host.SysHotel.CreatedDate.ToString("yyyy-MM-dd"); resp1.roomNumber = host.RoomNumber; resp1.devicetype = hostModal.ModalType.ToString(); resp1.address = hostModal.Modal.ModalAddress; @@ -1938,8 +1938,8 @@ namespace RCUHost.Implement else { string NoKey = CacheKey.HostModalStatus_BoolFilterPrefix + "_" + host.ID + "_" + device.Value.Address; - var expiredata = new Random().Next(10, 50); - CSRedisCacheHelper.Set_PartitionWithTime(NoKey, 1, expiredata); + //var expiredata = new Random().Next(10, 50); + CSRedisCacheHelper.Set_PartitionWithTime(NoKey, 1, 30); //logger.Error("内存和数据库都不见这条数据:" + KKey); } #endregion @@ -2202,6 +2202,17 @@ namespace RCUHost.Implement faultType = fault.Value.Type, faultData = fault.Value.Data }; + + //XuanZhuResponse_Fault hfault = new XuanZhuResponse_Fault() + // { + // data = resp, + // updatetime = DateTime.Now, + // url = host.SysHotel.FaultPushURL + // }; + + //string FaultKey = CacheKey.FaultKey_; + //string FFFFFKey = HotelCode + "_" + host.RoomNumber + "_" + hostModal.Modal.ModalAddress; + //CSRedisCacheHelper.HMSet(5, 60, FaultKey, FFFFFKey, resp); //var u = Newtonsoft.Json.JsonConvert.SerializeObject(resp); //logger.Error("logger report fault: "+u); var fault_data = new Tuple(host.SysHotel.FaultPushURL, resp); diff --git a/WebSite/Controllers/IoTController.cs b/WebSite/Controllers/IoTController.cs index 3645f9d..f4c2035 100644 --- a/WebSite/Controllers/IoTController.cs +++ b/WebSite/Controllers/IoTController.cs @@ -7238,6 +7238,11 @@ namespace WebSite.Controllers //艺龙酒店(绥化北林万达广场店) {"1668326697184","1213"} }; + public class GGG + { + public string DeviceName { get; set; } + public string Address { get; set; } + } [HttpPost()] public ActionResult ETV_Controller() @@ -7313,7 +7318,7 @@ namespace WebSite.Controllers IOTMonitorData i = new IOTMonitorData(); i.RemoteIP = IP; i.Step = 0; - string ti =DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"); + string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"); i.CreateTime = DateTime.Now; i.TriggerTime = ti; i.HotelId = hotelid; @@ -7417,6 +7422,8 @@ namespace WebSite.Controllers HttpContext.Cache.Insert(Hkey, hostModals, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration); } } + + List lla = new List(); // hostmodal只需要 address 和type // device.Address = hostModal.Modal.ModalAddress; // device.Type = hostModal.Modal.Type @@ -7433,7 +7440,7 @@ namespace WebSite.Controllers } else { - q1 = hostModals.Where(A => A.Modal.Name.Equals(name)||A.Modal.AliasName.Equals(name)).ToList(); + q1 = hostModals.Where(A => A.Modal.Name.Equals(name) || A.Modal.AliasName.Equals(name)).ToList(); } if (q1 != null && q1.Count > 0) { @@ -7452,6 +7459,9 @@ namespace WebSite.Controllers brightness = 0; } Thread.Sleep(50); + GGG vva = new GGG() { DeviceName = item_inter.Modal.Name, Address = item_inter.Modal.ModalAddress }; + + lla.Add(vva); HostModalManager.SetDevice(host, item_inter, status, brightness); } } @@ -7570,7 +7580,8 @@ namespace WebSite.Controllers i.RoomNumber = roomNo; i.RequestId = msgid; i.Platform = "ETV"; - i.CommandDescription = "success"; + + i.CommandDescription = "success: 控制设备"+JsonConvert.SerializeObject(lla); SendMQTTData.Send(i); } return Json(new { code = 200, msg = "控制成功" }, JsonRequestBehavior.AllowGet);