添加 ETV语音电视的支持。另外修改一些BUG

This commit is contained in:
2026-01-08 08:38:29 +08:00
parent 599251d91b
commit 69baadd312
14 changed files with 497 additions and 13 deletions

Binary file not shown.

View File

@@ -85,6 +85,7 @@ namespace CommonEntity
/// </summary>
public static string XiaoDuYuYin = "XiaoDuYuYin";
public static string TCLYuYin = "TCLYuYin";
public static string ETV_YuYin = "ETV_YuYin";
public static string PublicKeyboard = "PublicKeyboard";

View File

@@ -17,6 +17,8 @@ namespace Dao
SysHotel GetByDomainUrl(string domainUrl);
SysHotel GetByETV_HotelId(string hotelid);
IList<SysHotel> GetByGroup(SysHotelGroup group);
List<KongQi> GetNeedData();

View File

@@ -201,5 +201,11 @@ namespace Dao.Implement
return list;
}
}
public SysHotel GetByETV_HotelId(string hotelid)
{
return LoadAll().Where(r => r.ETV_HotelID.Equals(hotelid) && r.IsDeleted != true).OrderBy(r => r.Sort).FirstOrDefault();
}
}
}

View File

@@ -439,5 +439,6 @@ namespace Domain
/////
///// </summary>
//public virtual string TCLAppSecret { get; set; }
public virtual string ETV_HotelID { get; set; }
}
}

View File

@@ -73,6 +73,7 @@
<property name="IsUseQianLiMa" column="IsUseQianLiMa" type="bool" />
<property name="IsPushPMSData" column="IsPushPMSData" type="bool" />
<property name="HeTongNumber" column="HeTongNumber" type="string" />
<property name="ETV_HotelID" column="ETV_HotelID" type="string" />
<!--<property name="TCLAppId" column="TCLAppId" type="string" />
<property name="TCLAppSecret" column="TCLAppSecret" type="string" />-->
</class>

View File

@@ -188,7 +188,7 @@ namespace RCUHost.Implement
{
logger.Error("Host Server启动失败端口3339");
Close();
throw ex;//不能去掉否则重启iis服务通讯服务不会再次启动
//throw ex;//不能去掉否则重启iis服务通讯服务不会再次启动
}
}
/// <summary>
@@ -1517,10 +1517,13 @@ namespace RCUHost.Implement
byte cmdTypeTTT = context.SystemHeader.Value.CmdType;
if (cmdTypeTTT == 0x36)
{
IReceiver receiver = receivers[(CommandType)0x36];
if (receiver != null)
if (receivers.ContainsKey((CommandType)0x36))
{
(receiver as GenericReceiverBase).Process(context);//处理业务逻辑
IReceiver receiver = receivers[((CommandType)0x36)];
if (receiver != null)
{
(receiver as GenericReceiverBase).Process(context);//处理业务逻辑
}
}
}
else

View File

@@ -19,6 +19,7 @@ namespace Service
SysHotel GetByAssociatedAccount(string associatedAccount);
SysHotel GetByDomainUrl(string domainUrl);
SysHotel GetByETV_HotelId(string ETVHotelID);
void UpdateDayTime(SysHotel entity);

View File

@@ -791,6 +791,16 @@ namespace Service.Implement
{
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节则发送命令给rcu设置空调
{
//System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
//foreach (HostModal hostModal in hostModals)
//{
// //host 只需要hostnumber和mac
// //hostmodal只需要 address //和type
// //device.Address = hostModal.Modal.ModalAddress;
// //device.Type = hostModal.Modal.Type;
// HostModalManager.SetDevice(host, hostModal, item.Status, 0, item.SettingTemp, item.FanSpeed, item.Mode, 0);//0表示不变
//}
var TTT = new Tuple<Host, HotelAirControl, List<HostModal>>(host, item, hostModals);
Task.Factory.StartNew((state) =>
{
@@ -810,8 +820,8 @@ namespace Service.Implement
HostModalManager.SetDevice(QQ0, hostModal, QQ1.Status, 0, QQ1.SettingTemp, QQ1.FanSpeed, QQ1.Mode, 0);//0表示不变
}
}, TTT);
try
{
//try
//{
//这段代码在生产环境中不管用,很奇怪
//string KeyMission = System.Guid.NewGuid().ToString("N");
@@ -835,12 +845,12 @@ namespace Service.Implement
//CSRedisCacheHelper.Set_Partition<MissonData>(MKey, m, 1);
//DelayExe_Task(host, item.DelayTime, KeyMission);
break;
}
catch (Exception)
{
// break;
//}
//catch (Exception)
//{
}
//}
}
}
}

View File

@@ -162,5 +162,11 @@ namespace Service.Implement
{
return ((ISysHotelRepository)(this.CurrentRepository)).LoadAll().Where(A=>!A.IsDeleted&&A.FCSPushEnable).ToList();
}
public SysHotel GetByETV_HotelId(string hotelid)
{
return ((ISysHotelRepository)(this.CurrentRepository)).GetByETV_HotelId(hotelid);
}
}
}

View File

@@ -6751,7 +6751,7 @@ namespace WebSite.Controllers
else
{
hostModal = HostModalManager.GetByModalAddress(host.ID, modalAddress);//设备控制
HttpContext.Cache.Insert(MKey,hostModal,null,DateTime.Now.AddMinutes(30),Cache.NoSlidingExpiration);
HttpContext.Cache.Insert(MKey, hostModal, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration);
}
if (hostModal == null)
{
@@ -7177,6 +7177,444 @@ namespace WebSite.Controllers
// return Json(ex.Message, JsonRequestBehavior.AllowGet);
// }
//}
/// <summary>
/// ETV-艺龙酒店(绥化北林店)728893
/// 授权接口
/// </summary>
/// <returns></returns>
[HttpPost()]
public ActionResult ETV_Auth()
{
Request.InputStream.Position = 0;
byte[] reqBody = new byte[Request.InputStream.Length];
Request.InputStream.Read(reqBody, 0, reqBody.Length);
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
var ttt = JsonConvert.DeserializeObject<TV_AuthData>(reqData);
//clientId a6f3270f77b545a087daa1caed816b3b
//clientSecret8854e0b8261b49d6989b5b2f39bd157a
if (ttt.clientId.Equals("a6f3270f77b545a087daa1caed816b3b") && ttt.clientSecret.Equals("8854e0b8261b49d6989b5b2f39bd157a"))
{
var token = Guid.NewGuid().ToString("N");
string kkk = "ETVKey";
CSRedisCacheHelper.Set_PartitionWithTime(kkk, token, 7 * 24 * 60, 5);
TV_ResponseData c = new TV_ResponseData();
c.code = 200;
c.msg = null;
c.data = new TTT_Data()
{
token = token,
expiresIn = 7 * 24 * 60 * 60
};
//{
// "code": 200,
// "msg": null,
// "data": {
// "token": "74b87337454200d4d33f80c4663dc5e5",
// "expiresIn": 154589
// }
//}
return Json(c, JsonRequestBehavior.AllowGet);
}
else
{
TV_ResponseData c = new TV_ResponseData();
c.code = 500;
c.msg = "鉴权数据错误";
c.data = null;
return Json(c, JsonRequestBehavior.AllowGet);
}
}
/// <summary>
/// 两天时间要对接完,时间紧迫,数据先写死
/// </summary>
public static Dictionary<string, string> ETVDic = new Dictionary<string, string>()
{
//艺龙酒店(绥化北林万达广场店)
{"1668326697184","1213"}
};
[HttpPost()]
public ActionResult ETV_Controller()
{
try
{
string IP = "";
string PPP = Request.UserHostAddress;
string III = Request.ServerVariables["REMOTE_ADDR"];
if (string.IsNullOrEmpty(III))
{
IP = PPP;
}
else
{
IP = III;
}
var token = Request.Headers["Authorization"];
string kkk = "ETVKey";
var t_take = CSRedisCacheHelper.Get_Partition<string>(kkk, 5);
//t_take = "abc";
if (t_take == null || !t_take.Equals(token))
{
return Json(new { code = 500, msg = "token已经过期" }, JsonRequestBehavior.AllowGet);
}
Request.InputStream.Position = 0;
byte[] reqBody = new byte[Request.InputStream.Length];
Request.InputStream.Read(reqBody, 0, reqBody.Length);
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
var ttt = JsonConvert.DeserializeObject<ETV_ControllerData>(reqData);
string hotelid_WANBU = ttt.hotelId;
//var hotelid = ETVDic[hotelid_WANBU];
string hotelid = "";
int hotelid_int = 0;
//int.TryParse(hotelid, out hotelid_int);
SysHotel hotel_sys = null;
string KKKHotel = "HotelInfoETV_" + hotelid_WANBU;
var hotel_ooo = HttpContext.Cache.Get(KKKHotel);
if (hotel_ooo != null)
{
hotel_sys = hotel_ooo as SysHotel;
}
else
{
hotel_sys = SysHotelManager.GetByETV_HotelId(hotelid_WANBU);
HttpContext.Cache.Insert(KKKHotel, hotel_sys, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0));
}
if (hotel_sys != null)
{
hotelid_int = hotel_sys.ID;
hotelid = hotel_sys.ID.ToString();
}
else
{
return Json(new { code = 500, msg = "找不到此酒店" }, JsonRequestBehavior.AllowGet);//"小度音箱(" + request.payload.cuid + ")尚未绑定客房主机"
}
string msgid = Guid.NewGuid().ToString("N");
string roomNo = ttt.roomNo;
string traceId = ttt.traceId;
string domain = ttt.domain;
string intent = ttt.intent;
List<ETV_CanShu> slots = ttt.slots;
bool is_monitor = true;
if (is_monitor)
{
IOTMonitorData i = new IOTMonitorData();
i.RemoteIP = IP;
i.Step = 0;
string ti =DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
i.CreateTime = DateTime.Now;
i.TriggerTime = ti;
i.HotelId = hotelid;
i.HotelCode = int.Parse(hotel_sys.Code);
i.RoomNumber = roomNo;
i.RequestId = msgid;
i.Platform = "ETV";
i.CommandDescription = reqData;
SendMQTTData.Send(i);
}
Host host = null;
string ETVKongZhiKey = CacheKey.ETV_YuYin + "_" + hotelid + "_" + roomNo;
var UXV = HttpContext.Cache.Get(ETVKongZhiKey);
if (UXV != null)
{
host = UXV as Host;
}
else
{
// host = HostManager.GetByXiaoDuCUID(XiaoDuCUID);//根据小度音箱序列号获取对应RCU主机
host = HostManager.GetByRoomNumber(roomNo, hotelid_int);
if (host != null)
{
string code = host.SysHotel.Code;
string roomno = host.RoomNumber;
HttpContext.Cache.Insert(ETVKongZhiKey, host, null, DateTime.Now.AddMinutes(20), Cache.NoSlidingExpiration);
}
}
if (host == null)
{
return Json(new { code = 500, msg = "找不到此房间" }, JsonRequestBehavior.AllowGet);//"小度音箱(" + request.payload.cuid + ")尚未绑定客房主机"
}
int hotelcode = 0;
int.TryParse(host.SysHotel.Code, out hotelcode);
bool is_online = Common.CSRedisCacheHelper.Contains(host.HostNumber, host.MAC);
if (true)
{
string sss = "酒店(" + host.SysHotel.Name + host.SysHotel.Code + ")房间号:(" + host.RoomNumber + ") is_online: " + is_online.ToString();
IOTMonitorData i = new IOTMonitorData();
i.ControlClass = ControlClass_KongZhiSheBei;
i.Step = 1;
i.CreateTime = DateTime.Now;
string ti = CPUData.GetNowPrecise().ToString("yyyy-MM-dd HH:mm:ss.ffffff");
i.TriggerTime = ti;
i.HotelId = hotelid;
i.HotelCode = int.Parse(host.SysHotel.Code);
i.RoomNumber = roomNo;
i.RequestId = msgid;
i.Platform = "ETV";
i.CommandDescription = sss;
SendMQTTData.Send(i);
}
if (!is_online)
{
logger.Error("ETV当前访问酒店(" + host.SysHotel.Name + host.SysHotel.Code + ")客房rcu(" + host.RoomNumber + ")不在线");
return Json(new { code = 500, msg = "当前客户已经离线" }, JsonRequestBehavior.AllowGet);
}
bool is_take_card = CheckGetPower(host);
if (true)
{
string sss = "酒店(" + host.SysHotel.Name + host.SysHotel.Code + ")房间号:(" + host.RoomNumber + ") 取电: " + is_take_card.ToString();
IOTMonitorData i = new IOTMonitorData();
i.Step = 2;
i.CreateTime = DateTime.Now;
string ti = CPUData.GetNowPrecise().ToString("yyyy-MM-dd HH:mm:ss.ffffff");
i.TriggerTime = ti;
i.HotelId = hotelid;
i.HotelCode = hotelcode;
i.RoomNumber = roomNo;
i.RequestId = msgid;
i.Platform = "ETV";
i.CommandDescription = sss;
SendMQTTData.Send(i);
}
if (!is_take_card)
{
logger.Error("ETV当前访问酒店(" + host.SysHotel.Name + host.SysHotel.Code + ")客房rcu(" + host.RoomNumber + ")尚未取电");
return Json(new { code = 500, msg = "只有取电后才能控制" }, JsonRequestBehavior.AllowGet);
}
IList<HostModal> hostModals = null;
string Hkey = "ETVIOT_" + host.ID;
var dataH = HttpContext.Cache.Get(Hkey);
if (dataH != null)
{
hostModals = dataH as IList<HostModal>;
}
else
{
hostModals = HostModalManager.LoadByHostID(host.ID).Where(r => r.Modal.WXActiveIndicator).ToList();
if (hostModals != null && hostModals.Count > 0)
{
HttpContext.Cache.Insert(Hkey, hostModals, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration);
}
}
// hostmodal只需要 address 和type
// device.Address = hostModal.Modal.ModalAddress;
// device.Type = hostModal.Modal.Type
if (intent.Equals("IOT.Light") || intent.Equals("IOT.Switch") || intent.Equals("IOT.Curtain"))
{
foreach (var item in slots)
{
var action = item.action;
var name = item.applianceName;
List<HostModal> q1 = new List<HostModal>();
if (name.Equals("灯"))
{
q1 = hostModals.Where(A => A.Modal.Name.Contains("灯")).ToList();
}
else
{
q1 = hostModals.Where(A => A.Modal.Name.Equals(name)||A.Modal.AliasName.Equals(name)).ToList();
}
if (q1 != null && q1.Count > 0)
{
foreach (var item_inter in q1)
{
int status = 0;
int brightness = 0;
if (action.Equals("TurnOnRequest"))
{
status = 1;
brightness = 100;
}
else if (action.Equals("TurnOffRequest"))
{
status = 2;
brightness = 0;
}
Thread.Sleep(50);
HostModalManager.SetDevice(host, item_inter, status, brightness);
}
}
}
}
if (intent.Equals("IOT.AirCondition"))
{
foreach (var item in slots)
{
var action = item.action;
var name = item.applianceName;
var value = item.value;
var q1 = hostModals.Where(A => A.Modal.Type == DeviceType.AirConditioner && A.Modal.Name.Equals(name));
foreach (var item_inter in q1)
{
int status = 0;
int temperature = 25;
int fanSpeed = 0;
int mode = 0;
int dianci_famen = 0;
int brightness = 0;
if (action.Equals("TurnOnRequest"))
{
status = 1;
}
if (action.Equals("TurnOffRequest"))
{
status = 2;
}
if (action.Equals("setTemperature"))
{
int v = 25;
int.TryParse(value, out v);
temperature = v;
}
if (action.Equals("setFanSpeed"))
{
//value=highmiddlelowauto自动
//空调风速自动0,低1,中2,高3
if (value.Equals("high"))
{
fanSpeed = 3;
}
else if (value.Equals("middle"))
{
fanSpeed = 2;
}
else if (value.Equals("low"))
{
fanSpeed = 1;
}
else if (value.Equals("auto"))
{
fanSpeed = 0;
}
}
if (action.Equals("setMode"))
{
//value=cool制冷heat制热fan=通风auto自动
//自动0制冷1制热2送风3
if (value.Equals("cool"))
{
mode = 1;
}
else if (value.Equals("heat"))
{
mode = 2;
}
else if (value.Equals("fan"))
{
mode = 3;
}
else if (value.Equals("auto"))
{
mode = 0;
}
}
HostModalManager.SetDevice(host, item_inter, status, brightness, temperature, fanSpeed, mode);
}
if (q1 != null)
{
}
}
}
if (intent.Equals("IOT.SceneTrigger"))
{
foreach (var item in slots)
{
var action = item.action;
var name = item.applianceName;
int hid = int.Parse(hotelid);
var scene = RoomTypeSceneManager.LoadAll().Where(A => A.HotelID == hid && A.Name.Equals(name)).FirstOrDefault();
if (scene != null)
{
if (action.Equals("TurnOnRequest"))
{
LightControlManager.ApplyScene(host, scene);
}
if (action.Equals("TurnOffRequest"))
{
LightControlManager.ApplyScene(host, scene);
}
}
}
}
if (is_monitor)
{
IOTMonitorData i = new IOTMonitorData();
i.Step = 4;
string ti = CPUData.GetNowPrecise().ToString("yyyy-MM-dd HH:mm:ss.ffffff");
i.CreateTime = DateTime.Now;
i.TriggerTime = ti;
i.HotelId = hotelid;
i.HotelCode = hotelcode;
i.RoomNumber = roomNo;
i.RequestId = msgid;
i.Platform = "ETV";
i.CommandDescription = "success";
SendMQTTData.Send(i);
}
return Json(new { code = 200, msg = "控制成功" }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { code = 500, msg = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
}
public class ETV_ControllerData
{
public string hotelId { get; set; }
public string roomNo { get; set; }
public string traceId { get; set; }
public string domain { get; set; }
public string intent { get; set; }
public List<ETV_CanShu> slots { get; set; }
}
public class ETV_CanShu
{
public string applianceType { get; set; }
public string action { get; set; }
public string applianceName { get; set; }
public string value { get; set; }
}
public class TV_ResponseData
{
public int code { get; set; }
public object msg { get; set; }
public TTT_Data data { get; set; }
}
public class TTT_Data
{
public string token { get; set; }
/// <summary>
/// 时间为秒
/// </summary>
public long expiresIn { get; set; }
}
public class TV_AuthData
{
public string clientId { get; set; }
public string clientSecret { get; set; }
}
public class HiWeiToken
{

View File

@@ -305,6 +305,7 @@ namespace WebSite.Controllers
sysHotel.IsUseQianLiMa = entity.IsUseQianLiMa;
sysHotel.IsPushPMSData = entity.IsPushPMSData;
sysHotel.HeTongNumber = entity.HeTongNumber;
sysHotel.ETV_HotelID = entity.ETV_HotelID;
//sysHotel.TCLAppId = entity.TCLAppId;
//sysHotel.TCLAppSecret = entity.TCLAppSecret;
SysHotelManager.Update(sysHotel);
@@ -388,6 +389,7 @@ namespace WebSite.Controllers
TakeOut.SysHotel.IsUseQianLiMa = entity.IsUseQianLiMa;//断电重置小度
TakeOut.SysHotel.IsPushPMSData = entity.IsPushPMSData;
TakeOut.SysHotel.HeTongNumber = entity.HeTongNumber;
TakeOut.SysHotel.ETV_HotelID = entity.ETV_HotelID;
//TakeOut.SysHotel.TCLAppId = entity.TCLAppId;
//TakeOut.SysHotel.TCLAppSecret = entity.TCLAppSecret;

View File

@@ -474,7 +474,8 @@ namespace WebSite
hostServer.AddReceiver(new RCUHost.Implement.UpgradeProgressBar());
hostServer.AddReceiver(new RCUHost.Implement.RoomStatusChangedReceiver());
hostServer.AddReceiver(new RCUHost.Implement.AskRoomStatusChangedReceiver());
hostServer.AddReceiver((IReceiver)new RCUHost.Implement.New_RoomStatusReceiver());
//hostServer.AddReceiver((IReceiver)new RCUHost.Implement.New_RoomStatusReceiver());
hostServer.AddReceiver(new RCUHost.Implement.New_RoomStatusReceiver());
}
/// <summary>

View File

@@ -319,6 +319,18 @@
value="true" <%: Model.IsUseTCLTV ? "checked='checked'" : "" %> />
</td>
</tr>
<!--ETV-->
<tr>
<th align="right">
<label for="Text2"> ETV HotelID</label>
</th>
<td colspan="3">
<input id="Text2" name="ETV_HotelID" class="easyui-validatebox textbox text"
style="width: 416px;" value="<%: Model.ETV_HotelID %>" />
</td>
</tr>
<!--投诉反馈语音-->
<tr>
<th align="right">