给选住增加 设备变化 推送接口
This commit is contained in:
Binary file not shown.
@@ -72,6 +72,71 @@ namespace Common
|
||||
}
|
||||
}
|
||||
|
||||
public class XuanZhuHotelData
|
||||
{
|
||||
public static int[] dataArray = {
|
||||
1094, 1094, 1225, 1249, 1243, 1174, 1094, 1094, 1266, 1266,
|
||||
1094, 1237, 1317, 1317, 1325, 1329, 1001, 1333, 1283, 1371,
|
||||
1284, 1374, 1400, 1094, 3747, 1419, 1420, 1427, 1222, 1454,
|
||||
1489, 1989, 1515, 1527, 1524, 1557, 1337, 1332, 1490, 1672,
|
||||
1695, 1699, 1701, 1620, 1674};
|
||||
}
|
||||
public class XuanZhuRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 酒店编码
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 房号
|
||||
/// </summary>
|
||||
public string roomNumber { get; set; }
|
||||
public string devicetype { get; set; }
|
||||
/// <summary>
|
||||
/// 回路地址
|
||||
/// </summary>
|
||||
public string address { get; set; }
|
||||
/// <summary>
|
||||
/// 回路名称
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int status { get; set; }
|
||||
/// <summary>
|
||||
/// 异常类型
|
||||
/// </summary>
|
||||
public int faultType { get; set; }
|
||||
/// <summary>
|
||||
/// 异常值
|
||||
/// </summary>
|
||||
public int faultData { get; set; }
|
||||
/// <summary>
|
||||
/// 亮度
|
||||
/// </summary>
|
||||
public int brightness { get; set; }
|
||||
/// <summary>
|
||||
/// 当前温度
|
||||
/// </summary>
|
||||
public int currentTemp { get; set; }
|
||||
/// <summary>
|
||||
/// 设定温度
|
||||
/// </summary>
|
||||
public int settingTemp { get; set; }
|
||||
/// <summary>
|
||||
/// 风速
|
||||
/// </summary>
|
||||
public int fanSpeed { get; set; }
|
||||
/// <summary>
|
||||
/// 模式
|
||||
/// </summary>
|
||||
public int mode { get; set; }
|
||||
/// <summary>
|
||||
/// 阀门
|
||||
/// </summary>
|
||||
public int valve { get; set; }
|
||||
}
|
||||
public class XuanZhuResponse
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace CommonEntity
|
||||
|
||||
public static string WebChatDeviceFault = "WXFault";
|
||||
public static string DuOSToken = "DuOSToken";
|
||||
public static string XuanZhuKafka = "XZ_DeviceStatusChange";
|
||||
}
|
||||
public class ChangLiangValue
|
||||
{
|
||||
|
||||
@@ -1264,6 +1264,39 @@ namespace RCUHost.Implement
|
||||
|
||||
}
|
||||
|
||||
#region kafka队列
|
||||
var codesss = host.SysHotel.Code;
|
||||
if (XuanZhuHotelData.dataArray.Contains(int.Parse(codesss)))
|
||||
{
|
||||
XuanZhuRequest resp5 = new XuanZhuRequest();
|
||||
resp5.code = host.SysHotel.Code;
|
||||
resp5.roomNumber = host.RoomNumber;
|
||||
resp5.devicetype = hostModal.ModalType.ToString();
|
||||
resp5.address = hostModal.Modal.ModalAddress;
|
||||
resp5.name = hostModal.Modal.Name;
|
||||
resp5.status = hostModal.Status;
|
||||
if (resp5.status == 1)
|
||||
{
|
||||
resp5.brightness = hostModal.Brightness;
|
||||
resp5.currentTemp = hostModal.AirConditionData.CurrentTemp;
|
||||
resp5.settingTemp = hostModal.AirConditionData.SettingTemp;
|
||||
resp5.mode = hostModal.AirConditionData.Mode;
|
||||
resp5.fanSpeed = hostModal.AirConditionData.FanSpeed;
|
||||
resp5.valve = hostModal.AirConditionData.Valve;
|
||||
}
|
||||
else
|
||||
{
|
||||
resp5.brightness = 0;
|
||||
resp5.currentTemp = 0;
|
||||
resp5.settingTemp = 0;
|
||||
resp5.mode = 0;
|
||||
resp5.fanSpeed = 0;
|
||||
resp5.valve = 0;
|
||||
}
|
||||
var str111 = Newtonsoft.Json.JsonConvert.SerializeObject(resp5);
|
||||
CSRedisCacheHelper.Publish("Redis-XuanZhuKafka", str111);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 当设备或服务状态发生变化时,推送给指定的第三方接口
|
||||
if (!string.IsNullOrEmpty(host.SysHotel.DeviceStatusPushURL))
|
||||
|
||||
@@ -1899,6 +1899,41 @@ namespace RCUHost.Implement
|
||||
}, tup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
var codesss = host.SysHotel.Code;
|
||||
#region kafka队列
|
||||
if (XuanZhuHotelData.dataArray.Contains(int.Parse(codesss)))
|
||||
{
|
||||
XuanZhuRequest resp1 = new XuanZhuRequest();
|
||||
resp1.code = host.SysHotel.Code;
|
||||
resp1.roomNumber = host.RoomNumber;
|
||||
resp1.devicetype = hostModal.ModalType.ToString();
|
||||
resp1.address = hostModal.Modal.ModalAddress;
|
||||
resp1.name = hostModal.Modal.Name;
|
||||
resp1.status = hostModal.Status;
|
||||
if (resp1.status == 1)
|
||||
{
|
||||
resp1.brightness = hostModal.Brightness;
|
||||
resp1.currentTemp = hostModal.AirConditionData.CurrentTemp;
|
||||
resp1.settingTemp = hostModal.AirConditionData.SettingTemp;
|
||||
resp1.mode = hostModal.AirConditionData.Mode;
|
||||
resp1.fanSpeed = hostModal.AirConditionData.FanSpeed;
|
||||
resp1.valve = hostModal.AirConditionData.Valve;
|
||||
}
|
||||
else
|
||||
{
|
||||
resp1.brightness = 0;
|
||||
resp1.currentTemp = 0;
|
||||
resp1.settingTemp = 0;
|
||||
resp1.mode = 0;
|
||||
resp1.fanSpeed = 0;
|
||||
resp1.valve = 0;
|
||||
}
|
||||
var str111 = Newtonsoft.Json.JsonConvert.SerializeObject(resp1);
|
||||
CSRedisCacheHelper.Publish("Redis-XuanZhuKafka", str111);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace Service.Implement
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public IList<Host> LoadAll(string order, string sort, Group group, string roomNumber)
|
||||
{
|
||||
IList<Group> groups = GroupRepository.GetGroupList(group);
|
||||
@@ -575,7 +576,7 @@ namespace Service.Implement
|
||||
else
|
||||
{
|
||||
accessToken = SysOauth2Repository.GetXiaoDuToken();
|
||||
MemoryCacheHelper.Set(KKK,accessToken,DateTimeOffset.Now.AddMinutes(20));
|
||||
MemoryCacheHelper.Set(KKK, accessToken, DateTimeOffset.Now.AddMinutes(20));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(accessToken) && host.SysHotel.IsPowerOffResetXiaoDu)
|
||||
{
|
||||
@@ -769,7 +770,8 @@ namespace Service.Implement
|
||||
|
||||
request1.AddParameter("jsonData", jsstr);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) => { });
|
||||
//client1.ExecuteAsync(request1, (response) => { });
|
||||
client1.Execute(request1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1316,13 +1318,32 @@ namespace Service.Implement
|
||||
//1 为取电,2为没有取电
|
||||
if (mm.Status != 1)
|
||||
{
|
||||
List<HostModal> hostModals = new List<HostModal>();
|
||||
//获取启用的空调回路
|
||||
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host_id).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();
|
||||
|
||||
RoomNobodyHowTo nnn = RoomNoBodyMananger.LoadAll().FirstOrDefault(A => A.CurrentHotelID == hotel_id);
|
||||
|
||||
|
||||
string Hkey = "HostManagerHostModal_" + host_id;
|
||||
var ddd = MemoryCacheHelper.Get(Hkey);
|
||||
if (ddd != null)
|
||||
{
|
||||
hostModals = ddd as List<HostModal>;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostModals = HostModalRepository.LoadByHostID(host_id).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();
|
||||
MemoryCacheHelper.Set(Hkey, hostModals, DateTimeOffset.Now.AddMinutes(30));
|
||||
}
|
||||
|
||||
RoomNobodyHowTo nnn = null;
|
||||
string RKey = "RNO_" + hotel_id;
|
||||
var ooo = MemoryCacheHelper.Get(RKey);
|
||||
if (ooo != null)
|
||||
{
|
||||
nnn = ooo as RoomNobodyHowTo;
|
||||
}
|
||||
else
|
||||
{
|
||||
nnn = RoomNoBodyMananger.LoadAll().FirstOrDefault(A => A.CurrentHotelID == hotel_id);
|
||||
MemoryCacheHelper.Set(RKey, nnn, DateTimeOffset.Now.AddMinutes(30));
|
||||
}
|
||||
if (nnn != null)
|
||||
{
|
||||
foreach (HostModal hostModal in hostModals)
|
||||
|
||||
@@ -6741,7 +6741,18 @@ namespace WebSite.Controllers
|
||||
i.CommandDescription = sss;
|
||||
SendMQTTData.Send(i);
|
||||
}
|
||||
var hostModal = HostModalManager.GetByModalAddress(host.ID, modalAddress);//设备控制
|
||||
string MKey = "XiaoDuAddress_" + host.ID + "_" + modalAddress;
|
||||
var ddd = HttpContext.Cache.Get(MKey);
|
||||
HostModal hostModal = null;
|
||||
if (ddd != null)
|
||||
{
|
||||
hostModal = ddd as HostModal;
|
||||
}
|
||||
else
|
||||
{
|
||||
hostModal = HostModalManager.GetByModalAddress(host.ID, modalAddress);//设备控制
|
||||
HttpContext.Cache.Insert(MKey,hostModal,null,DateTime.Now.AddMinutes(30),Cache.NoSlidingExpiration);
|
||||
}
|
||||
if (hostModal == null)
|
||||
{
|
||||
logger.Error(string.Format("{3}(酒店:{0},房号:{1})未找到对应的回路,Address:{2}", host.SysHotel.Code + host.SysHotel.Name, host.RoomNumber, modalAddress, platformName));
|
||||
|
||||
Reference in New Issue
Block a user