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

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

Binary file not shown.

View File

@@ -78,6 +78,7 @@
<Compile Include="MissionRequestData.cs" />
<Compile Include="MonitorLog.cs" />
<Compile Include="MyHttp.cs" />
<Compile Include="NengHao_Repeat.cs" />
<Compile Include="NewDataSQL.cs" />
<Compile Include="NewRoomStatusPush.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -238,32 +238,90 @@ namespace CommonEntity
/// </summary>
public bool IsTakeCard { get; set; }
/// <summary>
/// 是否插卡
/// </summary>
public int IsInsertCard { get; set; }
/// <summary>
///短离长离
///我们这里叫卡事件
/// </summary>
public ushort CardEvent { get; set; }
/// <summary>
/// 卡身份
/// </summary>
public ushort CardID { get; set; }
/// <summary>
/// PMS 状态
/// </summary>
public string PMS_Status { get; set; }
public int CarbonVIP { get; set; }
public double V { get; set; }
public double A { get; set; }
public double P { get; set; }
public double Energy_Consumption { get; set; }
public double Sum_Energy_Consumption { get; set; }
public List<NengHao_Repeat> NengHaoList { get; set; }
//public double V { get; set; }
//public double A { get; set; }
//public double P { get; set; }
//public double Energy_Consumption { get; set; }
//public double Sum_Energy_Consumption { get; set; }
public long CreateTime { get; set; }
public string ReportTime { get; set; }
public List<DingShiReportDate> AllDeviceData { get; set; }
public int IdentityInfo {get;set;}
/// <summary>
/// 卡身份
/// </summary>
public int IdentityInfo { get; set; }
}
/// <summary>
/// ts 日志
/// </summary>
public class NewVersionLog
{
public string hotel_id { get; set; }
public string room_id { get; set; }
public string device_id { get; set; }
public string ip { get; set; }
public ushort power_state { get; set; }
public ushort guest_type { get; set; }
public ushort cardless_state { get; set; }
public ulong service_mask { get; set; }
public ushort pms_state { get; set; }
public ushort carbon_state { get; set; }
public int device_count { get; set; }
public ushort comm_seq { get; set; }
public List<NengHaolog> electricity { get; set; }
public List<KongTiao> air_conditioner { get; set; }
public extra_data extra { get; set; }
}
public class NengHaolog
{
public string address { get; set; }
public double voltage { get; set; }
public double ampere { get; set; }
public double power { get; set; }
//public double watt { get; set; }
public double energy { get; set; }
public double sum_energy { get; set; }
public string phase { get; set; }
}
public class KongTiao
{
public string address { get; set; }
public int state { get; set; }
public int model { get; set; }
public int speed { get; set; }
public int set_temp { get; set; }
public int now_temp { get; set; }
public int solenoid_valve { get; set; }
}
public class extra_data
{
public byte[] original_byte { get; set; }
public string source { get; set; }
public string ver { get; set; }
public object ac { get; set; }
public object meter { get; set; }
}
public class Interface3Log

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommonEntity
{
public class NengHao_Repeat
{
public string address { get; set; }
public double dianya { get; set; }
public double dianliu { get; set; }
public double gonglv { get; set; }
public double nenghao { get; set; }
public double zongnenghao { get; set; }
}
}

View File

@@ -96,6 +96,12 @@ namespace ConsoleApplication2
static void JieXi()
{
NewVersionLog s = new NewVersionLog();
var nas= JsonConvert.SerializeObject(s);
var data= Encoding.UTF8.GetBytes(nas);
Encoding.UTF8.GetString(data);
string strnn1 = "AA 55 2F 00 54 33 53 41 02 34 80 EB 03 6B 24 34 D0 B8 11 6B 24 01 01 01 39 01 01 00 10 F0 55 E8 03 E8 03 00 00 E8 03 00 00 E8 03 00 00 9E 00";
@@ -249,6 +255,12 @@ namespace ConsoleApplication2
}
static void Main(string[] args)
{
BitArray bit_a = new BitArray(new byte[] { 0xAA});
bool bfa= bit_a.Get(0);
bool bfaa= bit_a.Get(1);
var DDD = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
Console.WriteLine(DDD);
var qqqhj = CSRedisCacheHelper.Get_Partition<HostModal_Cache>("HostModalStatusReceiver_13_000000001");

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
}
}
}

View File

@@ -550,6 +550,13 @@ namespace RCUHost.Implement
{
TCLCommon.SendData(hotelcode, roomnum, TCLcuid, skillid, "SIP");
}
if (hotelcode.Equals("1085"))
{
if (hostModal.Modal.ModalAddress.Equals("004000021"))
{
TCLCommon.SendData(hotelcode, roomnum, TCLcuid, skillid, "ROMANTIC");
}
}
}
#endregion

View File

@@ -628,7 +628,13 @@ namespace RCUHost.Implement
{
TCLCommon.SendData(hotelcode, roomnum, TCLcuid, skillid, "SIP");
}
if (hotelcode.Equals("1085"))
{
if (hostModal.Modal.ModalAddress.Equals("004000023"))
{
TCLCommon.SendData(hotelcode, roomnum, TCLcuid, skillid, "ROMANTIC");
}
}
}
#endregion
@@ -2221,7 +2227,7 @@ namespace RCUHost.Implement
var DDD = State as Tuple<string, XuanZhuResponse>;
string Res_P = MyHttp.SendHttpData(DDD.Item1, DDD.Item1);
//XuanZhuOperation.ReportService(DDD.Item1, DDD.Item2);
logger.Error("Fault Return:" + "");
//logger.Error("Fault Return:" + "");
}, fault_data);
}
}

View File

@@ -3819,20 +3819,7 @@ namespace WebSite.Controllers
{
return Json(new { IsSuccess = false, Data = "hostid_lists不能为空" });
}
int roomTypeID = 0;
int.TryParse(b, out roomTypeID);
logger.Error("微信端开始升级: " + fileName + " " + roomTypeID + " host_list: " + host_list_str);
var host_list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(host_list_str);
//让服务器获取升级文件
HostUpdateController.GetUpdateFileByRoomTypeID(roomTypeID);
string lll = JsonConvert.SerializeObject(host_list);
HostUpdateController hh = new HostUpdateController();
logger.Error("开始升级: " + fileName + " host_list: " + lll);
//升级
hh.ShengJI_NEW(host_list, fileName, HostManager);
ReallyUpgrade(b, host_list_str, fileName);
return Json(new { IsSuccess = true, Data = "正在升级,请等待……" });
}
catch (Exception ex)
@@ -3841,6 +3828,52 @@ namespace WebSite.Controllers
}
}
[HttpPost()]
public ActionResult WebChatUpgradeTimer()
{
try
{
string b = Request.Form["roomTypeID"].ToString();
if (string.IsNullOrEmpty(b))
{
return Json(new { IsSuccess = false, Data = "roomTypeID不能为空" });
}
string host_list_str = Request.Form["hostid_lists"].ToString();
string fileName = Request.Form["upgradefileName"].ToString();
if (string.IsNullOrEmpty(host_list_str))
{
return Json(new { IsSuccess = false, Data = "hostid_lists不能为空" });
}
ReallyUpgrade(b, host_list_str, fileName);
return Json(new { IsSuccess = true, Data = "正在升级,请等待……" });
}
catch (Exception ex)
{
return Json(new { IsSuccess = false, Data = ex.Message });
}
}
private void ReallyUpgrade(string ID, string host_list_str, string fileName)
{
int roomTypeID = 0;
int.TryParse(ID, out roomTypeID);
logger.Error("微信端开始升级: " + fileName + " " + roomTypeID + " host_list: " + host_list_str);
var host_list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(host_list_str);
//让服务器获取升级文件
HostUpdateController.GetUpdateFileByRoomTypeID(roomTypeID);
string lll = JsonConvert.SerializeObject(host_list);
HostUpdateController hh = new HostUpdateController();
logger.Error("开始升级: " + fileName + " host_list: " + lll);
//升级
hh.ShengJI_NEW(host_list, fileName, HostManager);
}
[HttpPost()]
public ActionResult QueryUpdateHostProgressBar(string HostIDList)
{