修改新版协议主机 协议触发的机制,新增 缓存机制

This commit is contained in:
2026-04-09 13:37:09 +08:00
parent c13ab0cb56
commit 36c2fa4061
22 changed files with 484 additions and 1897 deletions

4
.gitignore vendored
View File

@@ -43,3 +43,7 @@ ConsoleApplication4
RCUHost内存泄漏分析报告.md
CRICS_V3_1124.suo
ConsoleApplication5
ConsoleApplication1
ConsoleApplication666
ConsoleApplication666
ConsoleApplication1

View File

@@ -9,5 +9,8 @@ namespace CommonEntity
public class QuanJuVar
{
public static IList<RoomTypeModal> BaoJingUpLoad = new List<RoomTypeModal>();
public static IList<RoomTypeModal> RoomTypeDeviceModal = new List<RoomTypeModal>();
public static IList<HotelSeason> HotelSeaon = new List<HotelSeason>();
public static List<HotelAirControl> HotelAirControl = new List<HotelAirControl>();
}
}

View File

@@ -1,128 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BE0C3821-67F3-4FF5-B688-E727BD4C90AE}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="C5">
<HintPath>..\..\..\..\lib\Quart\quartznet-2.3.3\quartznet-2.3.3\build\4.0\Debug\Quartz\C5.dll</HintPath>
</Reference>
<Reference Include="CacheManager.Core, Version=0.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\CacheManager.Core.0.7.4\lib\net40\CacheManager.Core.dll</HintPath>
</Reference>
<Reference Include="CacheManager.Memcached">
<HintPath>..\lib\CacheManager.Memcached.0.7.4\lib\net40\CacheManager.Memcached.dll</HintPath>
</Reference>
<Reference Include="CacheManager.SystemRuntimeCaching">
<HintPath>..\lib\CacheManager.SystemRuntimeCaching.0.7.4\lib\net40\CacheManager.SystemRuntimeCaching.dll</HintPath>
</Reference>
<Reference Include="Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\Quart\quartznet-2.3.3\quartznet-2.3.3\build\4.0\Debug\Quartz\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Common.Logging.Core">
<HintPath>..\..\..\..\lib\Quart\quartznet-2.3.3\quartznet-2.3.3\build\4.0\Debug\Quartz\Common.Logging.Core.dll</HintPath>
</Reference>
<Reference Include="CSRedisCore, Version=3.8.670.0, Culture=neutral, PublicKeyToken=9aa6a3079358d437, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Redis\CSRedisCore.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Quartz">
<HintPath>..\..\..\..\lib\Quart\quartznet-2.3.3\quartznet-2.3.3\build\4.0\Debug\Quartz\Quartz.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>..\lib\RestSharp\RestSharp.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common">
<HintPath>..\lib\Redis\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
<HintPath>..\lib\Redis\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Redis">
<HintPath>..\lib\Redis\ServiceStack.Redis.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
<HintPath>..\lib\Redis\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple">
<HintPath>..\lib\Redis\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonEntity\CommonEntity.csproj">
<Project>{1D7073B2-4CC3-49F5-9F37-50A21D74A39D}</Project>
<Name>CommonEntity</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{B3F29715-E925-4E56-9248-580F06C3BC11}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\Domain\Domain.csproj">
<Project>{A42D287A-8EF4-48F6-B14C-7F9CA834F786}</Project>
<Name>Domain</Name>
</ProjectReference>
<ProjectReference Include="..\RCUHost\RCUHost.csproj">
<Project>{3AF4C628-0B47-412C-950A-DBC0161F2A7F}</Project>
<Name>RCUHost</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ConsoleApplication1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication1")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("294a52c2-b3d2-4af1-a63e-358eb085073d")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,18 +0,0 @@
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="TCLLoginUrl" value="https://ai.tclyun.cn/"/>
<add key="TCLAppId" value="3fc1fe5560bdf2efda50a8dc23521d8a"/>
<add key="TCLAppSecret" value="48c30d8fcca4e14ab4842e9bfd54c082"/>
<!-- redis Start -->
<add key="session_expire_minutes" value="5" />
<add key="redis_server_session" value="127.0.0.1:6379" />
<add key="redis_max_read_pool" value="1000" />
<add key="redis_max_write_pool" value="1000" />
<add key="monitor_log_expire_minutes" value="30" />
<!--redis end-->
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E5890D7A-EB40-4864-B6D8-5B74A443A3F2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication666</RootNamespace>
<AssemblyName>ConsoleApplication666</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,64 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Numerics;
using System.Collections;
namespace ConsoleApplication666
{
class Program
{
[DllImport("kernel32.dll")]
private static extern void GetSystemTimePreciseAsFileTime(out long fileTime);
// 将 FILETIME (long) 转换为 DateTime
public static DateTime GetNowPrecise()
{
long fileTime;
GetSystemTimePreciseAsFileTime(out fileTime);
DateTime localTime = DateTime.FromFileTimeUtc(fileTime).ToLocalTime();
return localTime;
}
static void Main(string[] args)
{
ushort abb=0x6440;
var gs1= BitConverter.GetBytes(abb);
var f1= gs1[0];
var f2= gs1[1];
bool NewResult = true || false;
BigInteger hugeNumber = BigInteger.Parse("1234567890123456789012345678901234567890");
var H= hugeNumber.ToByteArray();
BitArray bi = new BitArray(H);
// 从字节数组创建
byte[] bytes = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
BigInteger fromBytes = new BigInteger(bytes);
// 基本运算
BigInteger sum = hugeNumber + 1;
BigInteger product = hugeNumber * 2;
Console.WriteLine("大数字: {0}", hugeNumber);
Console.WriteLine("加1: {0}", sum);
Console.WriteLine("乘2: {0}", product);
// 比较操作
if (hugeNumber > BigInteger.Parse("100000000000000000000"))
{
Console.WriteLine("这是一个非常大的数字");
}
DateTime ddd = GetNowPrecise();
string tii = ddd.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
Console.WriteLine(tii);
Console.ReadLine();
}
}
}

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ConsoleApplication666")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication666")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("0182759e-6111-44df-967d-cf14ebab598e")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -178,6 +178,7 @@
<!--<property name="SysHotelRepository" ref="Repository.SysHotel" />-->
<property name="HostModalRepository" ref="Repository.HostModal" />
<property name="SysOauth2Repository" ref="Repository.SysOauth2" />
<property name="DeviceControlReceiver" ref="RCUHost.DeviceControlReceiver" />
</object>
<object id="RCUHost.TFTPReceiver" type="RCUHost.Implement.TFTPReceiver, RCUHost" parent="RCUHost.GenericReceiverBase" singleton="true">

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using Domain;
using RCUHost.Protocols;
using System.Net;
namespace RCUHost
{
@@ -15,6 +16,9 @@ namespace RCUHost
/// <param name="host"></param>
/// <param name="device"></param>
void Send(Host host, Device device);
void SendWithEndPoint( Device device,IPEndPoint endpoint);
void Send_Repeat(string Key,Host host, Device device);
/// <summary>

View File

@@ -7,6 +7,7 @@ using Common;
using Domain;
using RCUHost.Protocols;
using CommonEntity;
using System.Net;
namespace RCUHost.Implement
{
@@ -14,11 +15,21 @@ namespace RCUHost.Implement
{
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(DeviceControlReceiver));
public void SendWithEndPoint(Device device, IPEndPoint endpoint)
{
SendWithEndPoint(new List<Device> { device }, endpoint);
}
public void SendWithEndPoint(IList<Device> devices, IPEndPoint endpoint)
{
var data = CreateDeviceControlPacket(devices);
SendAndPushCommandQueueWithEndPoint(data, endpoint);// host.IP, host.Port);
}
public void Send(Host host, Device device)
{
Send(host, new List<Device> { device });
}
public void Send(Host host, IList<Device> devices)
{
var data = CreateDeviceControlPacket(devices);
@@ -33,9 +44,9 @@ namespace RCUHost.Implement
//string nnn = builder.ToString().Trim();
//logger.Error(string.Format("给酒店({0})客房({1})发送控制命令{2}", host.SysHotel.Code, host.RoomNumber,builder.ToString()));
}
public void Send_Repeat(string Key,Host host, Device device)
public void Send_Repeat(string Key, Host host, Device device)
{
Send_Repeat(Key,host, new List<Device> { device });
Send_Repeat(Key, host, new List<Device> { device });
}
public void Send_Repeat(string PrefixKey, Host host, IList<Device> devices)
{
@@ -223,5 +234,6 @@ namespace RCUHost.Implement
{
get { return CommandType.DeviceControl; }
}
}
}

View File

@@ -278,7 +278,7 @@ namespace RCUHost.Implement
}
catch (Exception ex)
{
logger.Error("发送:"+ex.Message);
logger.Error("发送:" + ex.Message);
logger.Error(ex.StackTrace);
}
}
@@ -304,6 +304,10 @@ namespace RCUHost.Implement
HostServer.SendAndPushCommandQueue(data, ipAndPort.ToString().Split(':')[0], Convert.ToInt32(ipAndPort.ToString().Split(':')[1]));
}
}
protected void SendAndPushCommandQueueWithEndPoint(byte[] data, IPEndPoint endpoint)
{
HostServer.SendAndPushCommandQueue(data, endpoint);
}
/// <summary>
/// 回复下位机命令
/// </summary>

View File

@@ -21,6 +21,7 @@ using System.Threading;
using System.Collections;
using Newtonsoft.Json;
using Microsoft.IO;
using System.Reflection;
namespace RCUHost.Implement
{
@@ -649,14 +650,15 @@ namespace RCUHost.Implement
//如果不存在就处理
else
{
//GaiXie g = new GaiXie();
//g.Data = receiveBuffer111;
//g.IPEndPoint = remoteEP111.ToString();
//var data = Newtonsoft.Json.JsonConvert.SerializeObject(g);
string s1 = Tools.ByteToString(receiveBuffer111);
string data = s1 + "#" + remoteEP111.ToString();
if (VVV.CmdType == 0x0E || VVV.CmdType == 0x01 || VVV.CmdType == 0x36)
{
ushort MyFrameNO = context.SystemHeader.Value.FrameNo;
byte[] framenolist = BitConverter.GetBytes(MyFrameNO);
Reply(context, framenolist);
}
//ProcessData(data);
CSRedisCacheHelper.StreamAdd(1, UDPAllDataKey, data);
@@ -676,15 +678,15 @@ namespace RCUHost.Implement
}
else
{
//GaiXie g = new GaiXie();
//g.Data = receiveBuffer111;
//g.IPEndPoint = remoteEP111.ToString();
//var data = Newtonsoft.Json.JsonConvert.SerializeObject(g);
string s1 = Tools.ByteToString_NoWhiteSpace(receiveBuffer111);
string data = s1 + "#" + remoteEP111.ToString();
//ProcessData(data);
if (VVV.CmdType == 0x0E || VVV.CmdType == 0x01 || VVV.CmdType == 0x36)
{
ushort MyFrameNO = context.SystemHeader.Value.FrameNo;
byte[] framenolist = BitConverter.GetBytes(MyFrameNO);
Reply(context, framenolist);
}
CSRedisCacheHelper.StreamAdd(1, UDPAllDataKey, data);
}
}
@@ -1221,8 +1223,6 @@ namespace RCUHost.Implement
/// 处理数据
/// </summary>
/// <param name="context"></param>
//private void ProcessData(ReceiverContext context111, string hotelCode)
//private void ProcessData(GaiXie gga)
private void ProcessData(string gga)
{
//GaiXie gga = new GaiXie();
@@ -1337,12 +1337,13 @@ namespace RCUHost.Implement
#region 0E 01
//36 就是新版本的0E
if (cmdType == 0x0E || cmdType == 0x01 || cmdType == 0x36)
{
StepTongJi.SendInfo(1.1, "0E 01指令回复开始", context111.MessageID, context111.IsMonitor);
Reply(context111, framenolist);
StepTongJi.SendInfo(1.2, "0E 01指令回复结束", context111.MessageID, context111.IsMonitor);
}
//回复放到上面
//if (cmdType == 0x0E || cmdType == 0x01 || cmdType == 0x36)
//{
//StepTongJi.SendInfo(1.1, "0E 01指令回复开始", context111.MessageID, context111.IsMonitor);
//Reply(context111, framenolist);
//StepTongJi.SendInfo(1.2, "0E 01指令回复结束", context111.MessageID, context111.IsMonitor);
//}
#endregion
///注册指令 也要推送
@@ -1743,7 +1744,8 @@ namespace RCUHost.Implement
}
}
public IDeviceControlReceiver DeviceControlReceiver { get; set; }
public static System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
public static byte[] nocard_enum = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
public static object oo = new object();
private void NewXieYi(ReceiverContext context_1, string hotelCode_1, string HostNNN_1, byte[] framenolist_1, byte cmdType_1, string EndPoint_1, ushort MyFrameNO)
@@ -1836,6 +1838,8 @@ namespace RCUHost.Implement
if (qudian == 0x01)
{
VoiceRobotTrigger(1, hotelCode, HostNNN);
}
else if (qudian == 0x02)
{
@@ -1846,6 +1850,18 @@ namespace RCUHost.Implement
}
#region
try
{
JiJieChuLi(hotelCode, HostNNN, EndPoint, qudian);
}
catch (Exception ex)
{
logger.Error("季节出错了:"+ex.Message);
}
#endregion
NewVersionHexData ns = new NewVersionHexData();
ns.CmdType = 0x35;
ns.HotelCode = hotelCode;
@@ -2029,7 +2045,7 @@ namespace RCUHost.Implement
//给宝镜发送完整的数据
string hexdata = Tools.ByteToString(context111.Data);
CSRedisCacheHelper.Publish("redis-baojing-powerdata", hexdata);
//CSRedisCacheHelper.Publish("redis-baojing-powerdata", hexdata);
try
@@ -2762,6 +2778,73 @@ namespace RCUHost.Implement
}, tuple);
}
/// <summary>
/// 季节处理
/// </summary>
/// <param name="hotelCode"></param>
/// <param name="HostNNN"></param>
/// <param name="EndPoint"></param>
/// <param name="qudian"></param>
private void JiJieChuLi(string hotelCode, string HostNNN, string EndPoint, byte qudian)
{
//3、取电或断电时季节空调处理
HotelSeason hotelSeason = QuanJuVar.HotelSeaon.FirstOrDefault(A => A.SysHotel.Code.Equals(hotelCode));
if (hotelSeason != null)
{
int conditonType = (qudian == 1 ? 2 : 3);
List<HotelAirControl> list = QuanJuVar.HotelAirControl.Where(A => A.SysHotel!=null&&!string.IsNullOrEmpty(A.SysHotel.Code)&& A.SysHotel.Code.Equals(hotelCode) && A.ConditionType == conditonType && A.ActiveIndicator).ToList();
string ttt = CSRedisCacheHelper.HMGet<string>(5, CacheKey.HostId_HostNumber, HostNNN)[0];
if (string.IsNullOrEmpty(ttt))
{
return;
}
string[] NNN111 = ttt.Split('#');
string HostID = NNN111[0];
string RoomTypeID = NNN111[1];
int room_type_id = int.Parse(RoomTypeID);
var hostModals = QuanJuVar.RoomTypeDeviceModal.Where(A => A.RoomType.ID == room_type_id && A.Type == DeviceType.AirConditioner && A.ActiveIndicator).ToList();
if (list.Count > 0 && hostModals.Count > 0)
{
//System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
foreach (HotelAirControl item in list)
{
foreach (PropertyInfo prop in properties)//遍历属性
{
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节则发送命令给rcu设置空调
{
var D2 = item;
Task.Factory.StartNew(() =>
{
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
foreach (RoomTypeModal hostModal1 in hostModals)
{
Device device1 = new Device();
device1.Address = hostModal1.ModalAddress;
device1.AddressType = AddressType.DeviceAddress;
device1.Type = DeviceType.AirConditioner;
device1.Status = (byte)D2.Status;
device1.Brightness = 0;
device1.Temperature = (byte)D2.SettingTemp;
device1.FanSpeed = (byte)D2.FanSpeed;
device1.Mode = (byte)D2.Mode;
device1.Valve = 0;
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
var span = EndPoint.Split(':');
string ip = span[0];
string port = span[1];
IPEndPoint eee = new IPEndPoint(IPAddress.Parse(ip), int.Parse(port));
DeviceControlReceiver.SendWithEndPoint(device1, eee);
}
});
break;
}
}
}
}
}
}
/// <summary>
/// 碳达人上报
/// </summary>

View File

@@ -418,21 +418,32 @@ namespace RCUHost.Implement
else
{
//这里有点问题如果一个Model删除了又更新了那它的ID就变了。但是内存中记录的没变所以这里会出问题
var hostModal_old = HostModalRepository.Get(host.ID, device.Value.Address);
//var hostModal_old = HostModalRepository.Get(host.ID, device.Value.Address);
string HostID_O = CSRedisCacheHelper.HMGet<string>(5, CacheKey.HostId_HostNumber, HOSTNUMBER)[0];
if (string.IsNullOrEmpty(HostID_O))
{
return;
}
string[] NNN111 = HostID_O.Split('#');
string HostID = NNN111[0];
string RoomTypeID = NNN111[1];
int room_type_id = int.Parse(RoomTypeID);
var hostModal_old = QuanJuVar.RoomTypeDeviceModal.FirstOrDefault(A => A.RoomType.ID == room_type_id && A.ModalAddress.Equals(device.Value.Address));
if (hostModal_old != null)
{
HostModal_Cache c = new HostModal_Cache();
c.HostID = hostModal_old.HostID;
c.ModalType = hostModal_old.Modal.Type;
c.HostID = host.ID;
c.ModalType = hostModal_old.Type;
c.AirConditionData = new AirConditionData();
c.Modal = new RoomTypeModalCache()
{
RoomTypeID = hostModal_old.Modal.RoomType.ID,
ID = hostModal_old.Modal.ID,
Name = hostModal_old.Modal.Name,
ModalAddress = hostModal_old.Modal.ModalAddress,
ActiveIndicator = hostModal_old.Modal.ActiveIndicator,
Sort = hostModal_old.Modal.Sort
RoomTypeID = hostModal_old.RoomType.ID,
ID = hostModal_old.ID,
Name = hostModal_old.Name,
ModalAddress = hostModal_old.ModalAddress,
ActiveIndicator = hostModal_old.ActiveIndicator,
Sort = hostModal_old.Sort
};
hostModal = c;
}
@@ -735,93 +746,6 @@ namespace RCUHost.Implement
{
}
#region
//3、取电或断电时季节空调处理
HotelSeason hotelSeason = null;
string KKKAAA = "Season_" + host.SysHotel.ID;
string KongZhi = "Season_WuKong" + host.SysHotel.ID;
object ShiFouWeiKong = MemoryCacheHelper.Get(KongZhi);
int bf = 1;
if (ShiFouWeiKong != null)
{
bf = (int)ShiFouWeiKong;
}
if (bf == 0)
{
var UIO = MemoryCacheHelper.Get(KKKAAA);
if (UIO != null)
{
hotelSeason = (HotelSeason)UIO;
}
else
{
hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
if (hotelSeason != null)
{
MemoryCacheHelper.Set(KongZhi, 0, DateTimeOffset.Now.AddMinutes(20));
MemoryCacheHelper.Set(KKKAAA, hotelSeason, DateTimeOffset.Now.AddMinutes(20));
}
else
{
MemoryCacheHelper.Set(KongZhi, 1, DateTimeOffset.Now.AddMinutes(20));
}
}
}
else
{
hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
if (hotelSeason != null)
{
MemoryCacheHelper.Set(KongZhi, 0, DateTimeOffset.Now.AddMinutes(20));
MemoryCacheHelper.Set(KKKAAA, hotelSeason, DateTimeOffset.Now.AddMinutes(20));
}
else
{
MemoryCacheHelper.Set(KongZhi, 1, DateTimeOffset.Now.AddMinutes(20));
}
}
if (hotelSeason != null)
{
int conditonType = (hostModal.Status == 1 ? 2 : 3);
List<HotelAirControl> list = HotelAirControlRepository.LoadAll(host.SysHotel.ID, conditonType, true);
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host.ID).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();//获取启用的空调回路
if (list.Count > 0 && hostModals.Count > 0)
{
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
foreach (HotelAirControl item in list)
{
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
{
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节则发送命令给rcu设置空调
{
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
var D2 = item;
foreach (HostModal hostModal1 in hostModals)
{
Device device1 = new Device();
device1.Address = hostModal1.Modal.ModalAddress;
device1.AddressType = AddressType.DeviceAddress;
device1.Type = DeviceType.AirConditioner;
device1.Status = (byte)D2.Status;
device1.Brightness = 0;
device1.Temperature = (byte)D2.SettingTemp;
device1.FanSpeed = (byte)D2.FanSpeed;
device1.Mode = (byte)D2.Mode;
device1.Valve = 0;
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
//这里只需要host的mac和number或者 ip
DeviceControlReceiver.Send(host, device1);
}
break;
}
}
}
}
}
#endregion
#endregion
break;
}
@@ -1187,7 +1111,7 @@ namespace RCUHost.Implement
//电量0-100
ushort dianliang = (ushort)f2;
string DLKey = CacheKey.DianLiang + "_" + HOSTNUMBER;
CSRedisCacheHelper.Set_PartitionWithForever(DLKey,dianliang.ToString(),5);
CSRedisCacheHelper.Set_PartitionWithForever(DLKey, dianliang.ToString(), 5);
}
//更新主机主表
if (hostModal.Modal.Sort == 1)//.ModalAddress == "020001000")
@@ -1230,123 +1154,129 @@ namespace RCUHost.Implement
if (hostModal.ModalType == DeviceType.ServiceInfo)
//if (isonly_serviceinfo)
{
int StatusFlag = hostModal.Status;
HostModal FinallyData = new HostModal();
FinallyData.HostID = hostModal.HostID;
FinallyData.Status = hostModal.Status;
FinallyData.Brightness = hostModal.Brightness;
FinallyData.CurrentTemp = hostModal.AirConditionData.CurrentTemp;
FinallyData.FanSpeed = hostModal.AirConditionData.FanSpeed;
FinallyData.Mode = hostModal.AirConditionData.Mode;
FinallyData.SettingTemp = hostModal.AirConditionData.SettingTemp;
FinallyData.UpdateTime = hostModal.UpdateTime;
FinallyData.Valve = hostModal.AirConditionData.Valve;
FinallyData.Modal = new RoomTypeModal()
if (!string.IsNullOrEmpty(hostModal.Modal.Name))
{
ID = hostModal.Modal.ID,
Name = hostModal.Modal.Name,
ModalAddress = hostModal.Modal.ModalAddress,
ActiveIndicator = hostModal.Modal.ActiveIndicator,
Sort = hostModal.Modal.Sort
};
FinallyData.Modal.RoomType = new RoomType()
{
ID = hostModal.Modal.RoomTypeID
};
FinallyData.Modal.ID = hostModal.Modal.ID;
FinallyData.UpdateTime = now;
#region
try
{
HostModalRecord hostModalRecord;
switch (StatusFlag)
bool bbbaaa = hostModal.Modal.Name.Contains("红外") || hostModal.Modal.Name.Contains("infrared") || hostModal.Modal.Name.Contains("雷达") || hostModal.Modal.Name.Contains("radar");
if (bbbaaa == false)
{
case 2://关闭设备
if (hostModal.UpdateTime.HasValue)
{
hostModal.Time += Convert.ToInt32((now - hostModal.UpdateTime.Value).TotalMinutes);
}
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝添加内存
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 2;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
int StatusFlag = hostModal.Status;
HostModal FinallyData = new HostModal();
FinallyData.HostID = hostModal.HostID;
FinallyData.Status = hostModal.Status;
FinallyData.Brightness = hostModal.Brightness;
FinallyData.CurrentTemp = hostModal.AirConditionData.CurrentTemp;
FinallyData.FanSpeed = hostModal.AirConditionData.FanSpeed;
FinallyData.Mode = hostModal.AirConditionData.Mode;
FinallyData.SettingTemp = hostModal.AirConditionData.SettingTemp;
FinallyData.UpdateTime = hostModal.UpdateTime;
FinallyData.Valve = hostModal.AirConditionData.Valve;
}
}
break;
case 1://1打开设备
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
FinallyData.Modal = new RoomTypeModal()
{
ID = hostModal.Modal.ID,
Name = hostModal.Modal.Name,
ModalAddress = hostModal.Modal.ModalAddress,
ActiveIndicator = hostModal.Modal.ActiveIndicator,
Sort = hostModal.Modal.Sort
};
FinallyData.Modal.RoomType = new RoomType()
{
ID = hostModal.Modal.RoomTypeID
};
FinallyData.Modal.ID = hostModal.Modal.ID;
FinallyData.UpdateTime = now;
//阿宝这里修改
try
#region
try
{
HostModalRecord hostModalRecord;
switch (StatusFlag)
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 1;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
case 2://关闭设备
if (hostModal.UpdateTime.HasValue)
{
hostModal.Time += Convert.ToInt32((now - hostModal.UpdateTime.Value).TotalMinutes);
}
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝添加内存
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 2;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
}
}
}
break;
case 1://1打开设备
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝这里修改
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 1;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
}
}
break;
default:
break;
}
break;
default:
break;
string StatusKey = "RoomStatus_ServerInfo";
RCUHost.RCUHostCommon.tools.LanJieData(StatusKey, HOTEL_CODE);
CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
}
catch (Exception ex)
{
logger.Error("数据处理error: " + ex.Message);
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
#endregion
}
string StatusKey = "RoomStatus_ServerInfo";
RCUHost.RCUHostCommon.tools.LanJieData(StatusKey, HOTEL_CODE);
CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
}
catch (Exception ex)
{
logger.Error("数据处理error: " + ex.Message);
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
#endregion
}
#region kafka队列

View File

@@ -402,26 +402,6 @@ namespace RCUHost.Implement
}
//int hostid = host.ID;
//StringBuilder sb = new StringBuilder();
//sb.Append(CacheKey.CarbonVIP_Prefix);
//sb.Append("_");
//sb.Append(hostid.ToString());
//string Key = sb.ToString();
//CSRedisCacheHelper.Set<string>(Key, current_status);
//var data = CSRedisCacheHelper.Get<string>(Key);
//if (!string.IsNullOrEmpty(data))
//{
// if (!current_status.Equals(data))
// {
// CarbonDataSend(host, hhhg1);
// }
//}
//else
//{
// CarbonDataSend(host, hhhg1);
//}
CarbonDataSend(host, hhhg1);
var nfc = CarbonScene_SetRepository.GetDataBy(host.ID);
@@ -465,8 +445,6 @@ namespace RCUHost.Implement
}
string KKey = CacheKey.HostModalStatus_Prefix + "_" + host.ID + "_" + device.Value.Address;
var hostModal = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
if (hostModal != null)
{
@@ -475,21 +453,33 @@ namespace RCUHost.Implement
else
{
//这里有点问题如果一个Model删除了又更新了那它的ID就变了。但是内存中记录的没变所以这里会出问题
var hostModal_old = HostModalRepository.Get(host.ID, device.Value.Address);
//var hostModal_old = HostModalRepository.Get(host.ID, device.Value.Address);
string HostID_O = CSRedisCacheHelper.HMGet<string>(5, CacheKey.HostId_HostNumber, HOSTNUMBER)[0];
if (string.IsNullOrEmpty(HostID_O))
{
return;
}
string[] NNN111 = HostID_O.Split('#');
string HostID = NNN111[0];
string RoomTypeID = NNN111[1];
int room_type_id = int.Parse(RoomTypeID);
var hostModal_old= QuanJuVar.RoomTypeDeviceModal.FirstOrDefault(A=>A.RoomType.ID==room_type_id&&A.ModalAddress.Equals(device.Value.Address));
if (hostModal_old != null)
{
HostModal_Cache c = new HostModal_Cache();
c.HostID = hostModal_old.HostID;
c.ModalType = hostModal_old.Modal.Type;
c.HostID = host.ID;
c.ModalType = hostModal_old.Type;
c.AirConditionData = new AirConditionData();
c.Modal = new RoomTypeModalCache()
{
RoomTypeID = hostModal_old.Modal.RoomType.ID,
ID = hostModal_old.Modal.ID,
Name = hostModal_old.Modal.Name,
ModalAddress = hostModal_old.Modal.ModalAddress,
ActiveIndicator = hostModal_old.Modal.ActiveIndicator,
Sort = hostModal_old.Modal.Sort
RoomTypeID = hostModal_old.RoomType.ID,
ID = hostModal_old.ID,
Name = hostModal_old.Name,
ModalAddress = hostModal_old.ModalAddress,
ActiveIndicator = hostModal_old.ActiveIndicator,
Sort = hostModal_old.Sort
};
hostModal = c;
}
@@ -694,6 +684,7 @@ namespace RCUHost.Implement
}
else//设备关
{
#region
if (hostModal.Status != status)//设备有变化时才去更改状态窗帘6是停其他是关
{
flag = 0;
@@ -712,6 +703,7 @@ namespace RCUHost.Implement
hostModal.Status = status;
hostModal.Brightness = 0;
#endregion
}
}
catch (Exception ex)
@@ -721,7 +713,7 @@ namespace RCUHost.Implement
CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
#endregion
#region
#region ,
switch (hostModal.Modal.ModalAddress)
{
case "004000013"://门磁
@@ -748,13 +740,13 @@ namespace RCUHost.Implement
case "004000001"://取电
#region
//拨卡操作
if (flag == 0 && host.RoomCard != null)
{
//if (flag == 0 && host.RoomCard != null)
//{
//host.RoomCard = null;
//HostRepository.SetRoomCard(host, null);//拔卡操作
}
else if (flag == 1 && host.RoomCard == null)
{
//}
//else if (flag == 1 && host.RoomCard == null)
//{
//CSRedisCacheHelper.HMSet(CacheKey.TakeCardOnLine,host.SysHotel.Code+"###"+ host.RoomNumber);
//RoomCardType roomCardType = null;
@@ -801,7 +793,7 @@ namespace RCUHost.Implement
//}
//host.RoomCard = roomCard;
//HostRepository.SetRoomCard(host, roomCard);//插卡操作
}
//}
#region
if (flag != 2)//取电或断电时处理
@@ -1699,138 +1691,143 @@ namespace RCUHost.Implement
//只有服务信息才会入库
//bool isonly_serviceinfo = true;
bool bbbaaa = hostModal.Modal.Name.Contains("红外") || hostModal.Modal.Name.Contains("infrared") || hostModal.Modal.Name.Contains("雷达") || hostModal.Modal.Name.Contains("radar");
if (hostModal.ModalType == DeviceType.ServiceInfo && bbbaaa == false)
if (hostModal.ModalType == DeviceType.ServiceInfo)
{
HostModal FinallyData = new HostModal();
FinallyData.HostID = hostModal.HostID;
FinallyData.Status = hostModal.Status;
FinallyData.Brightness = hostModal.Brightness;
FinallyData.CurrentTemp = hostModal.AirConditionData.CurrentTemp;
FinallyData.FanSpeed = hostModal.AirConditionData.FanSpeed;
FinallyData.Mode = hostModal.AirConditionData.Mode;
FinallyData.SettingTemp = hostModal.AirConditionData.SettingTemp;
FinallyData.UpdateTime = hostModal.UpdateTime;
FinallyData.Valve = hostModal.AirConditionData.Valve;
FinallyData.Modal = new RoomTypeModal()
if (!string.IsNullOrEmpty(hostModal.Modal.Name))
{
ID = hostModal.Modal.ID,
Name = hostModal.Modal.Name,
ModalAddress = hostModal.Modal.ModalAddress,
ActiveIndicator = hostModal.Modal.ActiveIndicator,
Sort = hostModal.Modal.Sort
};
FinallyData.Modal.RoomType = new RoomType()
{
ID = hostModal.Modal.RoomTypeID
};
FinallyData.Modal.ID = hostModal.Modal.ID;
FinallyData.UpdateTime = now;
#region
try
{
HostModalRecord hostModalRecord;
switch (flag)
bool bbbaaa = hostModal.Modal.Name.Contains("红外") || hostModal.Modal.Name.Contains("infrared") || hostModal.Modal.Name.Contains("雷达") || hostModal.Modal.Name.Contains("radar");
if (bbbaaa == false)
{
case 0://0关闭设备
if (hostModal.UpdateTime.HasValue)
{
hostModal.Time += Convert.ToInt32((now - hostModal.UpdateTime.Value).TotalMinutes);
}
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝添加内存
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 2;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
HostModal FinallyData = new HostModal();
FinallyData.HostID = hostModal.HostID;
FinallyData.Status = hostModal.Status;
FinallyData.Brightness = hostModal.Brightness;
FinallyData.CurrentTemp = hostModal.AirConditionData.CurrentTemp;
FinallyData.FanSpeed = hostModal.AirConditionData.FanSpeed;
FinallyData.Mode = hostModal.AirConditionData.Mode;
FinallyData.SettingTemp = hostModal.AirConditionData.SettingTemp;
FinallyData.UpdateTime = hostModal.UpdateTime;
FinallyData.Valve = hostModal.AirConditionData.Valve;
}
}
break;
case 1://1打开设备且当前设备处于关闭状态
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝这里修改
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 1;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
FinallyData.Modal = new RoomTypeModal()
{
ID = hostModal.Modal.ID,
Name = hostModal.Modal.Name,
ModalAddress = hostModal.Modal.ModalAddress,
ActiveIndicator = hostModal.Modal.ActiveIndicator,
Sort = hostModal.Modal.Sort
};
FinallyData.Modal.RoomType = new RoomType()
{
ID = hostModal.Modal.RoomTypeID
};
FinallyData.Modal.ID = hostModal.Modal.ID;
FinallyData.UpdateTime = now;
}
}
break;
case 2://2打开设备且当前设备处于打开状态
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
try
#region
try
{
HostModalRecord hostModalRecord;
switch (flag)
{
HostModalRepository.Update(FinallyData);
case 0://0关闭设备
if (hostModal.UpdateTime.HasValue)
{
hostModal.Time += Convert.ToInt32((now - hostModal.UpdateTime.Value).TotalMinutes);
}
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝添加内存
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 2;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
}
}
break;
case 1://1打开设备且当前设备处于关闭状态
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
//阿宝这里修改
try
{
HostModalRepository.Update(FinallyData);//sbSQL.ToString());
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
if (hostModal.Modal.ActiveIndicator)//处理回路状态记录,只记录启用的回路 add by wuzhuihui 20190918
{
hostModalRecord = new HostModalRecord();
hostModalRecord.HostID = host.ID;
hostModalRecord.RoomNumber = host.RoomNumber;
hostModalRecord.RoomTypeID = host.RoomType.ID;
hostModalRecord.RoomTypeModalID = hostModal.Modal.ID;
hostModalRecord.ModalAddress = hostModal.Modal.ModalAddress;
hostModalRecord.StartTime = now;
hostModalRecord.Status = 1;
try
{
HostModalRecordRepository.Save(hostModalRecord);
}
catch (Exception)
{
}
}
break;
case 2://2打开设备且当前设备处于打开状态
hostModal.UpdateTime = now;
FinallyData.UpdateTime = now;
try
{
HostModalRepository.Update(FinallyData);
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
break;
}
catch (Exception ex)
{
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
break;
string StatusKey = "RoomStatus_ServerInfo";
RCUHost.RCUHostCommon.tools.LanJieData(StatusKey, HOTEL_CODE);
CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
}
catch (Exception ex)
{
logger.Error("数据处理error: " + ex.Message);
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
#endregion
}
string StatusKey = "RoomStatus_ServerInfo";
RCUHost.RCUHostCommon.tools.LanJieData(StatusKey, HOTEL_CODE);
CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey, hostModal);
}
catch (Exception ex)
{
logger.Error("数据处理error: " + ex.Message);
logger.Error(FinallyData.HostID + ":" + host.SysHotel.Code + " " + hostModal.Modal.ModalAddress);
}
#endregion
}
else
{

View File

@@ -40,7 +40,8 @@ namespace Service.Implement
public IList<RoomTypeModal> LoadAllBaoJingUpload()
{
return CurrentRepository.LoadAll().Where(r => r.IsUploadBaoJing == true).ToList();
//return CurrentRepository.LoadAll().Where(r => r.IsUploadBaoJing == true).ToList();
return CurrentRepository.LoadAll().ToList();
}

View File

@@ -66,13 +66,13 @@ namespace WebSite.Controllers
var LLL = LieECOManager.LoadAll().Where(A => A.HotelID == CurrentHotelID).OrderBy(A => A.ID).ToList();
string GGG = CacheKey.KT_Timer_Controller + "_" + CurrentHotelCode;
var LLL1= CSRedisCacheHelper.Get_Partition<List<LingChenECO>>(GGG, 5);
var LLL1 = CSRedisCacheHelper.Get_Partition<List<LingChenECO>>(GGG, 5);
string LieKey = CacheKey.LieECOKey + "_" + CurrentHotelID;
if (LLL != null && LLL.Count > 0)
{
var LLLData = LieECOManager.LoadAll().Where(A => A.HotelID == CurrentHotelID && A.IsEnable).ToList();
CSRedisCacheHelper.Set_Partition<List<LieECO>>(LieKey,LLLData,1);
CSRedisCacheHelper.Set_Partition<List<LieECO>>(LieKey, LLLData, 1);
}
if (nn != null)
{
@@ -85,7 +85,7 @@ namespace WebSite.Controllers
RoomNoBodyHowTo = nn,
ECO_Setting = ECO,
LieECOList = LLL,
TimerECO=LLL1
TimerECO = LLL1
}, JsonRequestBehavior.AllowGet);
}
else
@@ -98,7 +98,7 @@ namespace WebSite.Controllers
HotelData = new { StartDayTime = hotelData.StartDayTime, EndDayTime = hotelData.EndDayTime },
ECO_Setting = ECO,
LieECOList = LLL,
TimerECO=LLL1
TimerECO = LLL1
}, JsonRequestBehavior.AllowGet);
}
}
@@ -251,6 +251,11 @@ namespace WebSite.Controllers
RoomNoBodyMananger.Update(no);
id4 = id;
}
QuanJuVar.HotelSeaon = HotelSeasonManager.LoadAll().Where(A => !A.IsDeleted).ToList();
QuanJuVar.HotelAirControl = HotelAirControlManager.LoadAll().ToList();
//string logDetail = "【" + String.Join(",", roomNumberList.ToArray()) + "】【" + HttpContext.InnerLanguage("AirProperty" + property.ToString()) + "】";
//SaveSystemLog(AUTHORITY_AirConditionControl, HttpContext.InnerLanguage("SetRoomAirProperty"), logDetail);
return Json(new { IsSuccess = true, Message = HttpContext.InnerLanguage("SaveSuccess"), ID1 = id1, ID2 = id2, ID3 = id3, ID4 = id4 });

View File

@@ -5337,6 +5337,23 @@ namespace WebSite.Controllers
var hostServer = (IHostServer)MvcApplication.cxt.GetObject("RCUHost.HostServer");
hostServer.Start();
}
try
{
var len = CSRedisCacheHelper.redis1.XLen("All_UDPPackage_Data");
if (len >= 20)
{
logger.Error("Redis积压数据太多要重启一下");
var hostServer = (IHostServer)MvcApplication.cxt.GetObject("RCUHost.HostServer");
hostServer.Start();
}
}
catch (Exception ex)
{
}
var TotalKey = "UDPPackage_TotalRecvPackage";
UDPPackageCount LLL_T = null;
DataTongJi.TotalCount.TryGetValue(TotalKey, out LLL_T);
@@ -6491,6 +6508,7 @@ namespace WebSite.Controllers
}
}
QuanJuVar.BaoJingUpLoad = RoomTypeModalManager.LoadAllBaoJingUpload();
QuanJuVar.BaoJingUpLoad = QuanJuVar.RoomTypeDeviceModal.Where(A => A.IsUploadBaoJing == true).ToList();
return true;
}
#endregion
@@ -6834,6 +6852,20 @@ namespace WebSite.Controllers
}
}
[HttpPost()]
public ActionResult NewServerTest()
{
try
{
return Json(new { IsSuccess = true, Result = "success" }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
logger.Error(ex.Message);
return Json(new { IsSuccess = false, Result = "操作异常:" + ex.Message }, JsonRequestBehavior.AllowGet);
}
}
}
public class NReturnInfo
{

View File

@@ -133,7 +133,7 @@ namespace WebSite.Controllers
return Redirect("/");//Request.UrlReferrer.ToString());
}
[Authorize()]
//[Authorize()]
public ActionResult LogOn()
{
string result = "";

View File

@@ -51,6 +51,9 @@ namespace WebSite
public static IHostServer hostServer { get; set; }
public IRoomTypeModalManager RoomTypeModalManager { get; set; }
public IHotelSeasonManager HotelSeasonRepository { get; set; }
public IHotelAirControlManager HotelAirControlRepository { get; set; }
//private IGroupManager GroupManager;
//private IHostRoomCardManager HostRoomCardManager;
private syncstatus.syncstatusSoapClient _client = null;//房态同步接口
@@ -139,8 +142,10 @@ namespace WebSite
}
//HeartBeat();
QuanJuVar.BaoJingUpLoad = RoomTypeModalManager.LoadAllBaoJingUpload();
QuanJuVar.RoomTypeDeviceModal = RoomTypeModalManager.LoadAllBaoJingUpload();
QuanJuVar.BaoJingUpLoad = QuanJuVar.RoomTypeDeviceModal.Where(A => A.IsUploadBaoJing == true).ToList();
QuanJuVar.HotelSeaon = HotelSeasonRepository.LoadAll().Where(A => A.IsDeleted==false).ToList();
QuanJuVar.HotelAirControl= HotelAirControlRepository.LoadAll().ToList();
StartHostServer();
BLWMQTT.StartMqtt();
@@ -526,6 +531,8 @@ namespace WebSite
OverviewManager = (IOverviewManager)cxt.GetObject("Manager.Overview");
HostModalManager = (IHostModalManager)cxt.GetObject("Manager.HostModal");
RoomTypeModalManager = (IRoomTypeModalManager)cxt.GetObject("Manager.RoomTypeModal");
HotelSeasonRepository = (IHotelSeasonManager)cxt.GetObject("Manager.HotelSeason");
HotelAirControlRepository = (IHotelAirControlManager)cxt.GetObject("Manager.HotelAirControl");
_client = new syncstatus.syncstatusSoapClient();
Timer timer2 = new Timer(20000);//每20秒扫描一次

View File

@@ -218,8 +218,8 @@
</assemblies>
</compilation>
<authentication mode="Forms">
<!--<forms name="MyAuth" cookieless="UseCookies" loginUrl="~/LogOn" timeout="2880"/>-->
<forms name="MyAuth" cookieless="UseCookies" loginUrl="/Home/III" timeout="2880"/>
<forms name="MyAuth" cookieless="UseCookies" loginUrl="~/LogOn" timeout="2880"/>
<!--<forms name="MyAuth" cookieless="UseCookies" loginUrl="/Home/III" timeout="2880"/>-->
</authentication>
<pages validateRequest="false">
<namespaces>