给宝镜增加新的功能字段, PMS系统数据格式 更新
给宝镜推送 新功能,增加 RCU离 在线的功能
This commit is contained in:
@@ -63,6 +63,7 @@ namespace RCUHost.Implement
|
||||
|
||||
#endregion
|
||||
|
||||
//public System.Timers.Timer FaultReport = new System.Timers.Timer();
|
||||
#region Public Properies
|
||||
|
||||
/// <summary>
|
||||
@@ -155,6 +156,12 @@ namespace RCUHost.Implement
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
var DDD = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
|
||||
CSRedisCacheHelper.Forever<string>(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();
|
||||
///// <summary>
|
||||
///// 定时上报 错误
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
//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<XuanZhuResponse_Fault>(val);
|
||||
// TimeSpan span = DateTime.Now - v.updatetime;
|
||||
// if (span.TotalSeconds <= 20)
|
||||
// {
|
||||
// var fault_data = new Tuple<string, XuanZhuResponse>(v.url, v.data);
|
||||
// Task.Factory.StartNew((State) =>
|
||||
// {
|
||||
// var DDD = State as Tuple<string, XuanZhuResponse>;
|
||||
// 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();
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// 关闭 HostServer
|
||||
/// </summary>
|
||||
@@ -1180,22 +1235,37 @@ namespace RCUHost.Implement
|
||||
if (true)
|
||||
{
|
||||
#region 只要有数据包,就是心跳
|
||||
|
||||
string Key = context111.SystemHeader.Value.HostNumber.ToString();
|
||||
string EEE = CSRedisCacheHelper.Get<string>(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<string>(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<string>(EndPointStr);
|
||||
var dtstart = CSRedisCacheHelper.ForeverGet<string>(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<NewVersionDeviceStatus>(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);
|
||||
|
||||
@@ -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<string, XuanZhuResponse>(host.SysHotel.FaultPushURL, resp);
|
||||
|
||||
@@ -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<int>(NoKey, 1, expiredata);
|
||||
//var expiredata = new Random().Next(10, 50);
|
||||
CSRedisCacheHelper.Set_PartitionWithTime<int>(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<string, XuanZhuResponse>(host.SysHotel.FaultPushURL, resp);
|
||||
|
||||
Reference in New Issue
Block a user