增加升级 ,增加 新版本的日志推送

This commit is contained in:
2026-01-30 09:52:17 +08:00
parent 3a5ace4817
commit e4610f1ffa
11 changed files with 413 additions and 47 deletions

View File

@@ -357,6 +357,7 @@ namespace RCUHost.Implement
/// <param name="needPushCommandQueue">是否需要将命令放入队列</param>
public void Send(byte[] data, IPEndPoint endPoint, bool needPushCommandQueue)
{
if (udpClient != null)
{
#region lock
@@ -831,6 +832,30 @@ namespace RCUHost.Implement
reader.BaseStream.Position = originalPosition;
//logger.Error("device_count error");
}
try
{
//故障数量默认0
int faultNumber = reader.ReadByte();
for (int i = 0; i < faultNumber; i++)
{
string faultNo = new DeviceAddress(reader.ReadBytes(4)).ToString();//设备类型1、设备地址1、回路地址2
byte type = reader.ReadByte();
if (!roomStatus.Faults.ContainsKey(faultNo + type.ToString()))
{
roomStatus.Faults[faultNo + type.ToString()] = new FaultStaus();
}
roomStatus.Faults[faultNo + type.ToString()].FaultNo = faultNo;
roomStatus.Faults[faultNo + type.ToString()].Type = type;//类型1在线状态0在线1离线2电量0~100%3电流4 1901故障检测次数
roomStatus.Faults[faultNo + type.ToString()].Data = reader.ReadByte();//内容
}
}
catch (Exception)
{
}
return roomStatus;
}
}
@@ -1320,6 +1345,26 @@ namespace RCUHost.Implement
}
else
{
if (cmdType == 0x0F)
{
string RoomNUMBER = CSRedisCacheHelper.HMGet<string>(5, CacheKey.RoomNumber_HostNumber, HostNNN)[0];
if (!string.IsNullOrEmpty(RoomNUMBER))
{
//控制回复
DeviceActionData d1 = new DeviceActionData();
d1.ts_ms = Tools.GetUnixTime();
d1.hotel_id = hotelCode;
d1.room_id = RoomNUMBER;
d1.device_id = HostNNN;
d1.frame_id = MyFrameNO;
d1.cmd_word = "0F";
d1.udp_raw = Tools.ByteToString(OriginalByte);
d1.direction = "上报";
string sss = Newtonsoft.Json.JsonConvert.SerializeObject(d1);
CSRedisCacheHelper.Publish("redis-0X36-0X0F", sss);
}
}
#region 01
if (cmdType == 0x01)
{
@@ -1794,16 +1839,96 @@ namespace RCUHost.Implement
if (cmdType == 0x36)
{
//Reply(context111);
string hexdata = Tools.ByteToString(context111.Data);
NewVersionHexData ns = new NewVersionHexData();
ns.CmdType = 0x36;
ns.HotelCode = hotelCode;
ns.HostNumber = HostNNN;
ns.RemoteEndPoint = EndPoint;
ns.CurrentTime = DateTime.Now;
ns.HexData = Tools.ByteToString(context111.Data);
string RoomNUMBER = CSRedisCacheHelper.HMGet<string>(5, CacheKey.RoomNumber_HostNumber, HostNNN)[0];
if (string.IsNullOrEmpty(RoomNUMBER))
{
return;
}
byte[] OriginalByte = context111.Data;
int offset = StructConverter.SizeOf(context111.SystemHeader);
int length = context111.Data.Length - offset - 2;
DeviceActionData d1 = new DeviceActionData();
d1.ts_ms = Tools.GetUnixTime();
d1.hotel_id = hotelCode;
d1.room_id = RoomNUMBER;
d1.device_id = HostNNN;
d1.frame_id = MyFrameNO;
d1.cmd_word = "36";
d1.udp_raw = Tools.ByteToString(OriginalByte);
d1.direction = "上报";
List<ts_deviceitem> lll1 = new List<ts_deviceitem>();
List<ts_faultitem> lll2 = new List<ts_faultitem>();
using (MemoryStream stream = new MemoryStream(context111.Data, offset, length))
{
Status status = NewStatusParse(stream);
if (status.SysLock)
{
d1.sys_lock_status = 1;
}
else
{
d1.sys_lock_status = 2;
}
if (status != null && status.Devices.Count > 0)
{
foreach (var item in status.Devices)
{
string ItemKKK = item.Key;
Device VVV = item.Value;
ts_deviceitem t1 = new ts_deviceitem();
string dizhi = VVV.Address;
t1.dev_type = short.Parse(dizhi.Substring(0, 3));
t1.dev_addr = short.Parse(dizhi.Substring(3, 3));
t1.dev_loop = short.Parse(dizhi.Substring(6, 3));
t1.dev_data = VVV.StatusReceiver;
lll1.Add(t1);
}
}
if (status.Faults != null && status.Faults.Count > 0)
{
var F1 = status.Faults;
foreach (var item in F1)
{
string dizhi = item.Value.FaultNo;
ts_faultitem t1 = new ts_faultitem();
t1.dev_type = short.Parse(dizhi.Substring(0, 3));
t1.dev_addr = short.Parse(dizhi.Substring(3, 3));
t1.dev_loop = short.Parse(dizhi.Substring(6, 3));
t1.error_type = item.Value.Type;
t1.error_data = item.Value.Data;
lll2.Add(t1);
}
}
}
d1.device_list = lll1;
d1.fault_list = lll2;
d1.report_count = lll1.Count;
d1.fault_count = lll2.Count;
string sss = Newtonsoft.Json.JsonConvert.SerializeObject(d1);
CSRedisCacheHelper.Publish("redis-0X36-0X0F", sss);
//Reply(context111);
//string hexdata = Tools.ByteToString(context111.Data);
//NewVersionHexData ns = new NewVersionHexData();
//ns.CmdType = 0x36;
//ns.HotelCode = hotelCode;
//ns.HostNumber = HostNNN;
//ns.RemoteEndPoint = EndPoint;
//ns.CurrentTime = DateTime.Now;
//ns.HexData = Tools.ByteToString(context111.Data);
//CSRedisCacheHelper.Publish("redis-rcu-hexdata", Newtonsoft.Json.JsonConvert.SerializeObject(ns));
}
if (cmdType == 0x34)
@@ -1921,7 +2046,7 @@ namespace RCUHost.Implement
bool = false;
ushort _Int = 0;
int = 0;
if (Version == 0x02)
if (Version == 0x02 || Version == 0x03)
{
BitArray bit_a = new BitArray(new byte[] { TakeCardStatus });
bool b0 = bit_a.Get(0);
@@ -1930,16 +2055,24 @@ namespace RCUHost.Implement
bool b3 = bit_a.Get(3);
if (b0 == false && b1 == false)
{
= false;
//是否取电 = false;
_Int = 0;
}
else if (b0 == false && b1 == true)
{
_Int = 2;
}
else if (b0 == true && b1 == false)
{
= true;
//是否取电 = true;
_Int = 1;
}
if (b2 == false && b3 == false)
{
= 0;
}
else if (b2 == false && b3 == true)
{
= 2;
}
@@ -1977,11 +2110,10 @@ namespace RCUHost.Implement
}
//身份
var IdentityInfo = reader.ReadByte();
byte[] nocard_enum = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
byte[] nocard_enum = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A };
//无卡逻辑状态(对应事件状态)
//0x01开门进入事件
//0x02卡在人离事件
@@ -1991,6 +2123,8 @@ namespace RCUHost.Implement
//0x06室内按键触发
//0x07短暂人离事件
//0x08长时间人离事件
//0x09:短暂人离超时
//0x0A:长时间人离超时
var NOCardInfo = reader.ReadByte();
var NOCardInfo_NoFilter = NOCardInfo;
if (!nocard_enum.Contains(NOCardInfo))
@@ -2125,6 +2259,13 @@ namespace RCUHost.Implement
//碳达人
var CarbonVIP = reader.ReadByte();
int Bright_Va = -1;
if (Version == 0x03)
{
var LiangDu = reader.ReadBytes(4);
Bright_Va = (int)LiangDu[0];
}
var CarbonVIP_NoFilter = CarbonVIP;
byte[] carbon_enum = new byte[] { 0x01, 0x02 };
if (!carbon_enum.Contains(CarbonVIP))
@@ -2332,7 +2473,7 @@ namespace RCUHost.Implement
Mac = "",
EndPoint = EndPoint,
Version = ((int)Version).ToString(),
IsTakeCard = ,
IsTakeCard = _Int,
IsInsertCard = ,
CarbonVIP = CarbonVIP,
NengHaoList = nenghaoList,
@@ -2347,7 +2488,8 @@ namespace RCUHost.Implement
IdentityInfo = IdentityInfo,
//CardID = IdentityInfo,
CardEvent = NOCardInfo,
PMS_Status = PMS_CurrentStatus
PMS_Status = PMS_CurrentStatus,
Bright_G = Bright_Va
};
string mns = Newtonsoft.Json.JsonConvert.SerializeObject(ns2);
@@ -2358,11 +2500,14 @@ namespace RCUHost.Implement
#region TSlog
NewVersionLog tslog = new NewVersionLog()
{
version = (int)Version,
hotel_id = hotelCode,
room_id = RoomNUMBER,
device_id = HostNNN,
ip = EndPoint,
power_state = _Int,
insert_card = ,
bright_g = Bright_Va,
cardless_state = Convert.ToUInt16(NOCardInfo_NoFilter),
guest_type = Convert.ToUInt16(IdentityInfo),
service_mask = BitConverter.ToUInt64(N, 0),