天猫精灵背景音乐 ,官方文档 上的设置接口不管用,经过询问使用 另一个接口,完美解决

This commit is contained in:
2025-12-26 10:17:50 +08:00
parent b575adb844
commit 1ec13289dc
10 changed files with 165 additions and 85 deletions

1
.gitignore vendored
View File

@@ -38,3 +38,4 @@
/ConsoleApplication666/bin
/WebSite/Logs
WebSite/welcomebgm
MvcApplication1

Binary file not shown.

View File

@@ -172,50 +172,23 @@ namespace RCUHost.Implement
CSRedisCacheHelper.redis1.Del(UDPAllDataKey);
CSRedisCacheHelper.redis1.XGroupCreate(UDPAllDataKey, "UDPData", "0", true);
Task.Factory.StartNew(() =>
{
while (true)
for (int i = 1; i <= 10; i++)
{
Task.Factory.StartNew((iii) =>
{
StreamConsume("UDPData", "Crics1", "task1");
}
}, TaskCreationOptions.LongRunning);
Task.Factory.StartNew(() =>
{
while (true)
{
StreamConsume("UDPData", "Crics2", "task2");
}
}, TaskCreationOptions.LongRunning);
Task.Factory.StartNew(() =>
{
while (true)
{
StreamConsume("UDPData", "Crics3", "task3");
}
}, TaskCreationOptions.LongRunning);
Task.Factory.StartNew(() =>
{
while (true)
{
StreamConsume("UDPData", "Crics4", "task4");
}
}, TaskCreationOptions.LongRunning);
Task.Factory.StartNew(() =>
{
while (true)
{
StreamConsume("UDPData", "Crics5", "task5");
}
}, TaskCreationOptions.LongRunning);
string osos = iii.ToString();
while (true)
{
StreamConsume("UDPData", "Crics" + osos, "task" + osos);
}
}, i, TaskCreationOptions.LongRunning);
}
}
catch (Exception ex)
{
logger.Error("Host Server启动失败端口3339");
Close();
//throw ex;//不能去掉否则重启iis服务通讯服务不会再次启动
throw ex;//不能去掉否则重启iis服务通讯服务不会再次启动
}
}
/// <summary>
@@ -1056,11 +1029,17 @@ namespace RCUHost.Implement
if (!string.IsNullOrEmpty(e))
{
string ffg = "https://www.boonlive-rcu.com/welcomebgm/" + e;
TianMaoOperation.PostWebRequestToTianMao("AddOrUpdateWelcomeText",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], MusicUrl = ffg, WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
//TianMaoOperation.PostWebRequestToTianMao("AddOrUpdateWelcomeText",
//Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], MusicUrl = ffg, WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b, WelcomeMusicUrl = ffg }), c, d);//通知天猫精灵播放欢迎词
}
else
{
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
}
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
Interface3Log w1 = new Interface3Log();
w1.HotelCode = c;

View File

@@ -991,12 +991,15 @@ namespace RCUHost.Implement
if (!string.IsNullOrEmpty(bb))
{
string ffg = "https://www.boonlive-rcu.com/welcomebgm/" + bb;
TianMaoOperation.PostWebRequestToTianMao("AddOrUpdateWelcomeText",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], MusicUrl = ffg, WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b, WelcomeMusicUrl = ffg }), c, d);//通知天猫精灵播放欢迎词
}
else
{
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
}
TianMaoOperation.PostWebRequestToTianMao("PushWelcome",
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1], WelcomeText = b }), c, d);//通知天猫精灵播放欢迎词
Interface3Log w1 = new Interface3Log();
w1.HotelCode = c;

View File

@@ -1286,10 +1286,11 @@ namespace Service.Implement
RoomNobodyHowTo nnn = RoomNoBodyMananger.LoadAll().FirstOrDefault(A => A.CurrentHotelID == hotel_id);
foreach (HostModal hostModal in hostModals)
{
if (nnn != null)
if (nnn != null)
{
foreach (HostModal hostModal in hostModals)
{
logger.Error("nnn.how " + nnn.How);
//close or monitor
@@ -1315,7 +1316,6 @@ namespace Service.Implement
{
}
}
}
logger.Error("Air Condition Controller");
@@ -1327,9 +1327,10 @@ namespace Service.Implement
}
}
}
catch (Exception)
catch (Exception ex)
{
logger.Error(ex.Message);
logger.Error(ex.StackTrace);
}
}

View File

@@ -608,33 +608,45 @@ namespace WebSite.Controllers
string start_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
JObject jData = (JObject)JsonConvert.DeserializeObject(jsonData);
string roomNumber = jData["roomNumber"].ToString();
Host host = CheckRoomNumber(jData["code"].ToString(), jData["creatDate"].ToString(), ref msg, ref hotelID, roomNumber);
if (host == null)
{
return Json(new { IsSuccess = false, Result = msg }, JsonRequestBehavior.AllowGet);
}
IList<HostModal> hostModals = HostModalManager.Load(host.ID, DeviceType.AirConditioner).Where(r => r.Modal.WXActiveIndicator).ToList();
if (hostModals == null || hostModals.Count < 1)
{
return Json(new { IsSuccess = false, Result = "房号[" + roomNumber + "]未配置空调" }, JsonRequestBehavior.AllowGet);
}
string code = jData["code"].ToString();
string cd = jData["creatDate"].ToString();
string KKK = "GetRoomAirList_" + roomNumber + "_" + code + "_" + cd;
List<Air> list = new List<Air>();
foreach (HostModal item in hostModals)
var dbdata = HttpContext.Cache.Get(KKK);
if (dbdata != null)
{
Air air = new Air
list = dbdata as List<Air>;
}
else
{
Host host = CheckRoomNumber(code, cd, ref msg, ref hotelID, roomNumber);
if (host == null)
{
HostID = item.HostID,
ModalAddress = item.Modal.ModalAddress,
Name = item.Modal.Name,
RoomTypeAirID = item.Modal.ID,
Status = item.Status,
SettingTemp = item.SettingTemp,
CurrentTemp = item.CurrentTemp,
Mode = item.Mode,
FanSpeed = item.FanSpeed,
Valve = item.Valve
};
list.Add(air);
return Json(new { IsSuccess = false, Result = msg }, JsonRequestBehavior.AllowGet);
}
IList<HostModal> hostModals = HostModalManager.Load(host.ID, DeviceType.AirConditioner).Where(r => r.Modal.WXActiveIndicator).ToList();
if (hostModals == null || hostModals.Count < 1)
{
return Json(new { IsSuccess = false, Result = "房号[" + roomNumber + "]未配置空调" }, JsonRequestBehavior.AllowGet);
}
foreach (HostModal item in hostModals)
{
Air air = new Air
{
HostID = item.HostID,
ModalAddress = item.Modal.ModalAddress,
Name = item.Modal.Name,
RoomTypeAirID = item.Modal.ID,
Status = item.Status,
SettingTemp = item.SettingTemp,
CurrentTemp = item.CurrentTemp,
Mode = item.Mode,
FanSpeed = item.FanSpeed,
Valve = item.Valve
};
list.Add(air);
}
HttpContext.Cache.Insert(KKK, list, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration);
}
string end_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

View File

@@ -4346,10 +4346,20 @@ namespace WebSite.Controllers
string KKey = CacheKey.HostModalStatus_Prefix + "_" + host.ID.ToString() + "_" + device.Address;
var hostModal_T = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
bool JumpBrightcontrol = true;
var is_100 = devicesItem.value.HasValue;
if (is_100)
{
if (devicesItem.value == 100)
{
JumpBrightcontrol = false;
}
}
if (co == 1085 || co == 1001 || co == 1003 || co > 2000)
{
//logger.Error("查询的Key值:"+KKey);
if (hostModal_T != null && hostModal_T.Status == 2) { continue; }
if (hostModal_T != null && hostModal_T.Status == 2 && JumpBrightcontrol == true) { continue; }
}
if (devicesItem.value.HasValue)
{

View File

@@ -184,7 +184,7 @@ namespace WebSite.Controllers
Abnormal4Date = Convert.ToDateTime(r[15]).Year < 1900 ? "" : Convert.ToDateTime(r[15]).ToString("yyyy-MM-dd HH:mm:ss"),
Abnormal5 = Convert.ToDateTime(r[17]).Year < 1900 ? "" : r[16],
Abnormal5Date = Convert.ToDateTime(r[17]).Year < 1900 ? "" : Convert.ToDateTime(r[17]).ToString("yyyy-MM-dd HH:mm:ss")
}).Where(A=>!string.IsNullOrEmpty(A.Name));
}).Where(A => !string.IsNullOrEmpty(A.Name));
return Json(restult, JsonRequestBehavior.AllowGet);
}
@@ -408,10 +408,10 @@ namespace WebSite.Controllers
//string nenghaoKey = CacheKey.NengHao + "_" + mac;
string nenghaoKey = CacheKey.NengHao + "_" + host_number;
//var NNNHHH = CSRedisCacheHelper.ForeverGet<NengHao>(nenghaoKey);
var NNNHHH = CSRedisCacheHelper.Get_Partition<NengHao>(nenghaoKey,1);
var NNNHHH = CSRedisCacheHelper.Get_Partition<NengHao>(nenghaoKey, 1);
if (NNNHHH != null)
{
roomModel.Power = NNNHHH.P.ToString()+"w";
roomModel.Power = NNNHHH.P.ToString() + "w";
}
else
{
@@ -581,7 +581,18 @@ namespace WebSite.Controllers
//}
//②获取服务信息
//var services = HostModalManager.Load(room.HostID, DeviceType.ServiceInfo).Where(r => r.Modal.ActiveIndicator && r.Status == 1);
var services = HostModalManager.Load(room.HostID, DeviceType.ServiceInfo).Where(r => r.Modal.ActiveIndicator);
string KKServiceInfo = "ServiceInfo_" + room.HostID;
var oobsc = HttpContext.Cache.Get(KKServiceInfo);
IList<HostModal> services = null;
if (oobsc != null)
{
services = oobsc as IList<HostModal>;
}
else
{
services = HostModalManager.Load(room.HostID, DeviceType.ServiceInfo).Where(r => r.Modal.ActiveIndicator).ToList();
HttpContext.Cache.Insert(KKServiceInfo,services,null,DateTime.Now.AddMinutes(30),Cache.NoSlidingExpiration);
}
roomModel.Services = new List<ServiceModel>();
foreach (var service in services)
{
@@ -739,7 +750,7 @@ namespace WebSite.Controllers
if (string.IsNullOrEmpty(roomModel.Power))
{
roomModel.Power = "";
roomModel.Power = "";
}
floor.Sort = room.GroupSort;
rooms.Add(roomModel);

View File

@@ -98,6 +98,29 @@ namespace WebSite
// 在应用程序启动时调用
PreHot();
log4net.Config.XmlConfigurator.Configure();//初始化log4net
// 全局异常捕获,避免未处理异常导致进程崩溃
AppDomain.CurrentDomain.UnhandledException += (s, args) =>
{
try
{
var ex = args.ExceptionObject as Exception;
if (ex != null)
{
logger.Error("UnhandledException:" + ex.Message);
logger.Error(ex.StackTrace);
}
}
catch { }
};
TaskScheduler.UnobservedTaskException += (s, args) =>
{
try
{
logger.Error("UnobservedTaskException:" + args.Exception.ToString());
args.SetObserved();
}
catch { }
};
SetInitAccount();
StartHostServer();
//StartHostServerNew();
@@ -201,10 +224,15 @@ namespace WebSite
var T = sender as Timer;
try
{
// 防止重入
T.Stop();
double d = CPUData.GetCPU();
DataTongJi.CPU_Data.Add(d);
T.Start();
// 简单的上限保护,避免长期积累导致内存膨胀
//if (DataTongJi.CPU_Data.Count > 1000)
//{
// DataTongJi.CPU_Data = new System.Collections.Concurrent.ConcurrentBag<double>();
//}
}
catch (Exception ex)
{
@@ -212,6 +240,7 @@ namespace WebSite
}
finally
{
// 恢复计时器
T.Start();
}
}
@@ -773,6 +802,10 @@ namespace WebSite
var ip = Request.UserHostAddress;
var url = Request.Url.AbsolutePath.ToLower();
// 定期清理恶意IP记录避免字典无限增长
var nowUtc = DateTime.UtcNow;
CleanupIpRecordIfNeeded(nowUtc);
// 定义要拦截的路径模式
var maliciousPatterns = new[]
{
@@ -837,10 +870,40 @@ namespace WebSite
{
return true;
}
// 超过统计窗口则重置计数窗口
if ((now - info.FirstRequest).TotalMinutes >= 1)
{
info.FirstRequest = now;
info.RequestCount = 1;
}
}
return false;
}
// 恶意IP记录清理节流控制
private static DateTime _lastIpCleanup = DateTime.MinValue;
private static readonly TimeSpan _ipCleanupInterval = TimeSpan.FromMinutes(1);
private static readonly TimeSpan _ipRetention = TimeSpan.FromMinutes(10);
private static void CleanupIpRecordIfNeeded(DateTime nowUtc)
{
if ((nowUtc - _lastIpCleanup) < _ipCleanupInterval) return;
_lastIpCleanup = nowUtc;
try
{
foreach (var kv in _ipRequests.ToArray())
{
var info = kv.Value;
if ((nowUtc - info.LastRequest) > _ipRetention)
{
RequestInfo removed;
_ipRequests.TryRemove(kv.Key, out removed);
}
}
}
catch { }
}
private class RequestInfo
{
public RequestInfo()

View File

@@ -200,7 +200,7 @@
<databaseSettings>
<add key="provider" value="System.Data.SqlClient" />
<add key="connectionString" value="Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;Persist Security Info=True;User ID=sa;Password=123456;" />
<add key="connectionString" value="Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;Persist Security Info=True;User ID=sa;Password=123456;Max Pool Size=300;" />
<add key="dialect" value="NHibernate.Dialect.MsSql2008Dialect" />
<add key="driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="show_sql" value="true" />
@@ -231,7 +231,7 @@
<httpRuntime maxRequestLength="5000" requestValidationMode="2.0" />
<compilation debug="true" targetFramework="4.0">
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />