增加能耗推送和新的 那个日志数据推送

This commit is contained in:
2026-01-16 11:37:59 +08:00
parent a4b847ed80
commit 7a43c97047
9 changed files with 349 additions and 63 deletions

View File

@@ -1314,7 +1314,7 @@ namespace RCUHost.Implement
#region
if (cmdType == 0x32 || cmdType == 0x33 || cmdType == 0x34 || cmdType == 0x35 || cmdType == 0x36)
{
NewXieYi(context111, hotelCode, HostNNN, framenolist, cmdType, EndPoint);
NewXieYi(context111, hotelCode, HostNNN, framenolist, cmdType, EndPoint, MyFrameNO);
}
else
{
@@ -1632,8 +1632,10 @@ namespace RCUHost.Implement
}
}
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)
private void NewXieYi(ReceiverContext context_1, string hotelCode_1, string HostNNN_1, byte[] framenolist_1, byte cmdType_1, string EndPoint_1, ushort MyFrameNO)
{
var Tuple = new Tuple<ReceiverContext, string, string, byte[], byte, string>(context_1, hotelCode_1, HostNNN_1, framenolist_1, cmdType_1, EndPoint_1);
Task.Factory.StartNew((state) =>
@@ -1895,14 +1897,81 @@ namespace RCUHost.Implement
using (BinaryReader reader = new BinaryReader(stream))
{
//版本
//默认是02
var Version = reader.ReadByte();
//取电
//P1:插卡与取电状态设备类型(1Byte)
//bit0-bit1
//00 当前未取电
//01 当前已经取电
//bit2-bit3
//00 无插卡
//01 已经插卡
//下面的是是否取电
var TakeCardStatus = reader.ReadByte();
bool = false;
ushort _Int = 0;
int = 0;
if (Version == 0x02)
{
BitArray bit_a = new BitArray(new byte[] { TakeCardStatus });
bool b0 = bit_a.Get(0);
bool b1 = bit_a.Get(1);
bool b2 = bit_a.Get(2);
bool b3 = bit_a.Get(3);
if (b0 == false && b1 == false)
{
= false;
_Int = 2;
}
else if (b0 == true && b1 == false)
{
= true;
_Int = 1;
}
if (b2 == false && b3 == false)
{
= 2;
}
else if (b2 == true && b3 == false)
{
= 1;
}
}
//如果是01就只有取电
//从取电动作那里取数据
if (Version == 0x01)
{
string HostID_redis = CSRedisCacheHelper.HMGet<string>(5, CacheKey.HostId_HostNumber, HostNNN)[0];
if (!string.IsNullOrEmpty(HostID))
{
string KKey = CacheKey.HostModalStatus_Prefix + "_" + HostID + "_" + "004000001";
var OldHostModal = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
if (OldHostModal != null)
{
var aaa = OldHostModal.Status;
if (aaa == 01)
{
= true;
}
else if (aaa == 02)
{
= false;
}
}
}
}
//身份
var IdentityInfo = reader.ReadByte();
byte[] nocard_enum = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
//无卡逻辑状态(对应事件状态)
//0x01开门进入事件
//0x02卡在人离事件
@@ -1914,6 +1983,21 @@ namespace RCUHost.Implement
//0x08长时间人离事件
var NOCardInfo = reader.ReadByte();
if (!nocard_enum.Contains(NOCardInfo))
{
NOCardInfo = 0x00;
}
#region BUG处理
//只有同派酒店做这个处理
if (hotelCode.Equals("2144"))
{
if (NOCardInfo == 0x03)
{
= 2;
}
}
#endregion
//服务信息全部回路状态 1~64 64Bit 0 :关 1
//把8个字节转换成64个二进制位
var N = reader.ReadBytes(8);
@@ -2010,9 +2094,19 @@ namespace RCUHost.Implement
//碳达人
var CarbonVIP = reader.ReadByte();
byte[] carbon_enum = new byte[] { 0x01, 0x02 };
if (!carbon_enum.Contains(CarbonVIP))
{
CarbonVIP = 0x00;
}
var DeviceCount = reader.ReadByte();
int DeviceCount_I = (int)DeviceCount;
List<NengHao_Repeat> nenghaoList = new List<NengHao_Repeat>();
List<NengHaolog> nenghaoList1 = new List<NengHaolog>();
List<KongTiao> kongtiaoList = new List<KongTiao>();
for (int i = 0; i < DeviceCount_I; i++)
{
var QA = reader.ReadBytes(4);
@@ -2020,6 +2114,8 @@ namespace RCUHost.Implement
#region
if (QA[0] == 0x39)
{
NengHao_Repeat nr = new NengHao_Repeat();
NengHaolog nr1 = new NengHaolog();
string address = new DeviceAddress(QA).ToString();
//设备数据长度
var DeviceInfoLen = reader.ReadByte();
@@ -2055,14 +2151,15 @@ namespace RCUHost.Implement
n.Mac = "";
n.EndPoint = EndPoint;
n.Version = ((int)Version).ToString();
if (TakeCardStatus == 0x01)
{
n.IsTakeCard = true;
}
else
{
n.IsTakeCard = false;
}
//if (TakeCardStatus == 0x01)
//{
// n.IsTakeCard = true;
//}
//else
//{
// n.IsTakeCard = false;
//}
n.IsTakeCard = ;
n.V = Math.Round(V, 2);
n.A = Math.Round(A, 2);
n.P = Math.Round(P, 2);
@@ -2077,33 +2174,21 @@ namespace RCUHost.Implement
//这里不再发送这个了,改发送全部的数据
NengHao4BaoJing ns2 = new NengHao4BaoJing()
{
HotelCode = n.HotelCode,
HostNumber = n.HostNumber,
RoomNumber = n.RoomNumber,
Mac = n.Mac,
EndPoint = n.EndPoint,
Version = n.Version,
IsTakeCard = n.IsTakeCard,
CarbonVIP = n.CarbonVIP,
V = dianya,
A = dianliu,
P = gonglv,
Energy_Consumption = nenghao,
Sum_Energy_Consumption = zongnenghao,
CreateTime = n.CreateTime,
ReportTime = n.ReportTime.ToString("yyyy-MM-dd HH:mm:ss"),
AllDeviceData = DeviceStatusList,
IdentityInfo = IdentityInfo,
CardID = IdentityInfo,
CardEvent = NOCardInfo,
PMS_Status = PMS_CurrentStatus
};
string mns = Newtonsoft.Json.JsonConvert.SerializeObject(ns2);
CSRedisCacheHelper.Publish("redis-power", mns);
nr.address = address;
nr.dianya = n.V;
nr.dianliu = n.A;
nr.gonglv = n.P;
nr.nenghao = n.KW_H;
nr.zongnenghao = n.Sum_KW_H;
nenghaoList.Add(nr);
nr1.address = address;
nr1.voltage = n.V;
nr1.ampere = n.A;
nr1.power = n.P;
nr1.energy = n.KW_H;
nr1.sum_energy = n.Sum_KW_H;
nenghaoList1.Add(nr1);
string KeyFilter = "能耗";
RCUHost.RCUHostCommon.tools.LanJieData(KeyFilter, hotelCode.ToString());
@@ -2147,6 +2232,16 @@ namespace RCUHost.Implement
int temperature = 0;//设定温度
int currentTemp = 0;//当前温度(室内温度)
KongTiaoReport(StatusReceiver, out status, out temperature, out mode, out fanspeed, out currentTemp);
KongTiao kkk = new KongTiao();
kkk.state = status;
kkk.address = address;
kkk.model = mode;
kkk.speed = fanspeed;
kkk.now_temp = currentTemp;
kkk.set_temp = temperature;
kkk.solenoid_valve = valve;
kongtiaoList.Add(kkk);
if (!string.IsNullOrEmpty(HostID))
{
string KKey = CacheKey.HostModalStatus_Prefix + "_" + HostID + "_" + address;
@@ -2195,6 +2290,63 @@ namespace RCUHost.Implement
}
#endregion
}
long tf0 = Tools.GetUnixTime();
NengHao4BaoJing ns2 = new NengHao4BaoJing()
{
HotelCode = long.Parse(hotelCode),
HostNumber = HostNNN,
RoomNumber = RoomNUMBER,
Mac = "",
EndPoint = EndPoint,
Version = ((int)Version).ToString(),
IsTakeCard = ,
IsInsertCard = ,
CarbonVIP = CarbonVIP,
NengHaoList = nenghaoList,
//V = dianya,
//A = dianliu,
//P = gonglv,
//Energy_Consumption = nenghao,
//Sum_Energy_Consumption = zongnenghao,
CreateTime = tf0,
ReportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
AllDeviceData = DeviceStatusList,
IdentityInfo = IdentityInfo,
//CardID = IdentityInfo,
CardEvent = NOCardInfo,
PMS_Status = PMS_CurrentStatus
};
string mns = Newtonsoft.Json.JsonConvert.SerializeObject(ns2);
CSRedisCacheHelper.Publish("redis-power", mns);
#region TSlog
NewVersionLog tslog = new NewVersionLog()
{
hotel_id = hotelCode,
room_id = RoomNUMBER,
device_id = HostNNN,
ip = EndPoint,
power_state = _Int,
cardless_state = Convert.ToUInt16(NOCardInfo),
guest_type = Convert.ToUInt16(IdentityInfo),
service_mask = BitConverter.ToUInt64(N, 0),
pms_state = Convert.ToUInt16(PMS),
carbon_state = Convert.ToUInt16(CarbonVIP),
device_count = DeviceCount_I,
comm_seq = MyFrameNO,
electricity=nenghaoList1,
air_conditioner=kongtiaoList,
extra = new extra_data()
{
original_byte = OriginalByte
}
};
string mns111 = Newtonsoft.Json.JsonConvert.SerializeObject(tslog);
CSRedisCacheHelper.Publish("redis-tslog", mns111);
#endregion
}
}
}