增加新的协议处理
This commit is contained in:
parent
1f39478f79
commit
e941901f8f
|
|
@ -113,6 +113,116 @@ namespace Waste.Application
|
|||
public bool IsWeight { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A8协议包内容
|
||||
/// </summary>
|
||||
public class A8Package
|
||||
{
|
||||
/// <summary>
|
||||
/// 垃圾类别小类
|
||||
/// </summary>
|
||||
public string WasteSType { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 消息ID
|
||||
/// </summary>
|
||||
public string UUID { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 上报时间
|
||||
/// </summary>
|
||||
public string UploadTime { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public string Price { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
public string Amount { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 操作员
|
||||
/// </summary>
|
||||
public string OpUser { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A8协议模块上传的数据包体
|
||||
/// </summary>
|
||||
public class A8MyPackage:A8Package
|
||||
{
|
||||
/// <summary>
|
||||
/// 固定头
|
||||
/// </summary>
|
||||
public string Key { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 数据体长度
|
||||
/// </summary>
|
||||
public int Len { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// IMEI
|
||||
/// </summary>
|
||||
public string IMEI { get; set; } = "";
|
||||
/// <summary>
|
||||
/// ICCID
|
||||
/// </summary>
|
||||
public string ICCID { get; set; } = "";
|
||||
/// <summary>
|
||||
/// IMSI
|
||||
/// </summary>
|
||||
public string IMSI { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 信号强度
|
||||
/// </summary>
|
||||
public string GSLQ { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public string Time { get; set; }
|
||||
/// <summary>
|
||||
/// 经度
|
||||
/// </summary>
|
||||
public string Longitude { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 纬度
|
||||
/// </summary>
|
||||
public string Latitude { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 桶大小
|
||||
/// </summary>
|
||||
public string size { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 垃圾桶编号
|
||||
/// </summary>
|
||||
public string trashcode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 垃圾类别
|
||||
/// </summary>
|
||||
public string WasteType { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 重量,KG
|
||||
/// </summary>
|
||||
public string Weight { get; set; } = "0";
|
||||
/// <summary>
|
||||
/// 内容
|
||||
/// </summary>
|
||||
public string Body { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 字符串结果
|
||||
/// </summary>
|
||||
public string Str { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 是否是否通过校检,true-是,false-否
|
||||
/// </summary>
|
||||
public bool IsChecked { get; set; } = true;
|
||||
/// <summary>
|
||||
/// 是否为心跳包数据
|
||||
/// </summary>
|
||||
public bool IsHeart { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 是否为有效测量
|
||||
/// </summary>
|
||||
public bool IsWeight { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新的4G模块上传的数据包体
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,13 @@ namespace Waste.Application
|
|||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
Task InsertResultBy4GAsync(nMyPackage myPackage);
|
||||
|
||||
/// <summary>
|
||||
/// 新的A8 4G模块测量结果增加
|
||||
/// </summary>
|
||||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
Task InsertResultByA84GAsync(A8MyPackage myPackage);
|
||||
/// <summary>
|
||||
/// wifi模块测量结果增加
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ namespace Waste.Application
|
|||
{
|
||||
it.PostStatus = res.Status;
|
||||
}
|
||||
var allext = cache.Get(list => {
|
||||
var ids = list.Select(e => e.Id).ToList();
|
||||
return dbClient.Queryable<W_MeasureResult>().Where(e => ids.Contains(e.ResultId)).ToList();
|
||||
});
|
||||
var ext = allext.FirstOrDefault(e => e.ResultId == it.Id);
|
||||
it.WasteType = ext != null && !ext.WasteSType.IsEmpty() ? $"{ext.WasteSType}【{it.WasteType}】" : it.WasteType;
|
||||
})
|
||||
.ToPageListAsync(param.offset, param.limit, totalnum);
|
||||
return new PageParms<ResultList>
|
||||
|
|
@ -170,7 +176,7 @@ namespace Waste.Application
|
|||
{
|
||||
isfrist = true;
|
||||
}
|
||||
decimal currentweight= data.Weight.IsEmpty() ? 0 : data.Weight.ToDecimal();
|
||||
decimal currentweight = data.Weight.IsEmpty() ? 0 : data.Weight.ToDecimal();
|
||||
//记录数据
|
||||
await dbClient.Ado.UseStoredProcedure().ExecuteCommandAsync("Proc_InsertResult", new
|
||||
{
|
||||
|
|
@ -280,13 +286,110 @@ namespace Waste.Application
|
|||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新的A8 4G模块测量结果增加
|
||||
/// </summary>
|
||||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
public async Task InsertResultByA84GAsync(A8MyPackage myPackage)
|
||||
{
|
||||
//如果uuid不为空,并且以存在记录,则忽略
|
||||
if (!myPackage.IsHeart && !myPackage.UUID.IsEmpty() && await dbClient.Queryable<W_MeasureResult>().AnyAsync(x => x.UUID == myPackage.UUID))
|
||||
{
|
||||
_loggerService.AddLogger($"A8记录重复,内容:{myPackage.ToJson()}", 1);
|
||||
return;
|
||||
}
|
||||
//查找设备
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => myPackage.IMEI == x.Ecode);
|
||||
// _loggerService.AddLogger($"接收到的数据,参数:{myPackage.ToJson()}", 3);
|
||||
if (device == null)
|
||||
{
|
||||
//记录日志
|
||||
_loggerService.AddLogger($"设备未找到,参数:{myPackage.ToJson()}", 3);
|
||||
return;
|
||||
}
|
||||
var devicedata = await dbClient.Queryable<W_DeviceData>().FirstAsync(x => x.DeviceId == device.Id);
|
||||
var resultid = IDGen.NextID();
|
||||
DateTime time = DateTime.Now;
|
||||
if (myPackage.IsHeart)
|
||||
{
|
||||
if (string.IsNullOrEmpty(myPackage.Longitude) || myPackage.Longitude.ToDecimal() == 0) myPackage.Longitude = devicedata != null ? devicedata.Longitude : "0";
|
||||
if (string.IsNullOrEmpty(myPackage.Latitude) || myPackage.Latitude.ToDecimal() == 0) myPackage.Latitude = devicedata != null ? devicedata.Latitude : "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(myPackage.IMSI)) myPackage.IMSI = devicedata != null ? devicedata.IMSI : "";
|
||||
if (string.IsNullOrEmpty(myPackage.IMEI)) myPackage.IMEI = devicedata != null ? devicedata.IMEI : "";
|
||||
if (string.IsNullOrEmpty(myPackage.ICCID)) myPackage.ICCID = devicedata != null ? devicedata.ICCID : "";
|
||||
if (!string.IsNullOrEmpty(myPackage.Time) && myPackage.Time.Length == 14)
|
||||
{
|
||||
time = $"{myPackage.Time.Substring(0, 4)}-{myPackage.Time.Substring(4, 2)}-{myPackage.Time.Substring(6, 2)} {myPackage.Time.Substring(8, 2)}:{myPackage.Time.Substring(10, 2)}:{myPackage.Time.Substring(12, 2)}".ToDate();
|
||||
}
|
||||
}
|
||||
//检查设备是否为今天第一次上报
|
||||
bool isfrist = false;
|
||||
if (device.LastHeartTime.HasValue && device.LastHeartTime.Value.Date != DateTime.Now.Date)
|
||||
{
|
||||
isfrist = true;
|
||||
}
|
||||
var Weight = myPackage.Weight.IsEmpty() ? 0 : myPackage.Weight.ToDecimal();
|
||||
decimal price = myPackage.Price.IsEmpty() ? 0 : myPackage.Price.ToDecimal();
|
||||
decimal amount = myPackage.Amount.IsEmpty() ? 0 : myPackage.Amount.ToDecimal();
|
||||
string wastestype = myPackage.WasteSType.ToStr();
|
||||
//记录数据
|
||||
await dbClient.Ado.UseStoredProcedure().ExecuteCommandAsync("Proc_InsertResult", new
|
||||
{
|
||||
deviceid = device.Id,
|
||||
businessid = device.Businessid,
|
||||
resultid = resultid,
|
||||
imei = myPackage.IMEI,
|
||||
iccid = myPackage.ICCID,
|
||||
imsi = myPackage.IMSI,
|
||||
time = time,
|
||||
latitude = myPackage.Latitude,
|
||||
longitude = myPackage.Longitude,
|
||||
sign = myPackage.GSLQ,
|
||||
city = "",
|
||||
area = myPackage.trashcode,
|
||||
wastetype = myPackage.WasteType,
|
||||
weigth = Weight,
|
||||
isheart = myPackage.IsHeart,
|
||||
tare = device.Tare,
|
||||
isfrist = isfrist
|
||||
});
|
||||
if (!myPackage.IsHeart)
|
||||
{
|
||||
//记录价格数据
|
||||
if (!myPackage.UUID.IsEmpty())
|
||||
{
|
||||
await dbClient.Insertable(new W_MeasureResult
|
||||
{
|
||||
ResultId = resultid,
|
||||
WasteSType = wastestype,
|
||||
Amount = amount,
|
||||
OpUser = myPackage.OpUser.ToStr(),
|
||||
Price = price,
|
||||
UUID = myPackage.UUID
|
||||
}).ExecuteCommandAsync();
|
||||
}
|
||||
await SendMessageToThird(new SendThirdMessageSubscribeS2SDto
|
||||
{
|
||||
DeviceId = device.Id,
|
||||
Time = time,
|
||||
TrashCode = myPackage.trashcode,
|
||||
WasteType = myPackage.WasteType,
|
||||
Weight = Weight,
|
||||
WasteSType = wastestype
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 给第三方推送消息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
private async Task SendMessageToThird(SendThirdMessageSubscribeS2SDto input)
|
||||
{
|
||||
if(input.Weight <= 0)
|
||||
if (input.Weight <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// </summary>
|
||||
public string WasteType { get; set; }
|
||||
/// <summary>
|
||||
/// 物品小类别
|
||||
/// </summary>
|
||||
public string WasteSType { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 重量,单位KG
|
||||
/// </summary>
|
||||
public decimal Weight { get; set; }
|
||||
|
|
@ -113,7 +117,7 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// <summary>
|
||||
/// 发送第三方消息
|
||||
/// </summary>
|
||||
public class SendThirdMessageSubscriDto: SendMessageToThirdS2CDto
|
||||
public class SendThirdMessageSubscriDto : SendMessageToThirdS2CDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 推送地址
|
||||
|
|
@ -129,6 +133,12 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// 垃圾类别
|
||||
/// </summary>
|
||||
public string WasteType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物品小类别
|
||||
/// </summary>
|
||||
public string WasteSType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 重量,单位KG
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
Task Insert4GResultAsync(nMyPackage myPackage);
|
||||
/// <summary>
|
||||
/// A8 4G模块传输的数据增加测量记录
|
||||
/// </summary>
|
||||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
void InsertA84GResultAsync(A8MyPackage myPackage);
|
||||
/// <summary>
|
||||
/// 测试,4G模块传输的数据增加测量记录
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -244,6 +244,8 @@ namespace Waste.Application.SubscribeInfo
|
|||
{
|
||||
await _resultService.InsertResultBy4GAsync(myPackage);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 测试,4G模块传输的数据增加测量记录
|
||||
/// </summary>
|
||||
|
|
@ -286,5 +288,16 @@ namespace Waste.Application.SubscribeInfo
|
|||
}
|
||||
_loggerService.AddLogger($"第三方设备消息发送成功,内容:{data.ToJson()},返回:{returnstr}", 3);
|
||||
}
|
||||
/// <summary>
|
||||
/// A8 4G模块传输的数据增加测量记录
|
||||
/// </summary>
|
||||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("result.service.inserta84g")]
|
||||
public async void InsertA84GResultAsync(A8MyPackage myPackage)
|
||||
{
|
||||
_loggerService.AddLogger($"A8记录,内容:{myPackage.ToJson()}", 1);
|
||||
await _resultService.InsertResultByA84GAsync(myPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1719,6 +1719,136 @@
|
|||
是否为有效测量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.A8Package">
|
||||
<summary>
|
||||
A8协议包内容
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.WasteSType">
|
||||
<summary>
|
||||
垃圾类别小类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.UUID">
|
||||
<summary>
|
||||
消息ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.UploadTime">
|
||||
<summary>
|
||||
上报时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.Price">
|
||||
<summary>
|
||||
价格
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.Amount">
|
||||
<summary>
|
||||
金额
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8Package.OpUser">
|
||||
<summary>
|
||||
操作员
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.A8MyPackage">
|
||||
<summary>
|
||||
A8协议模块上传的数据包体
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Key">
|
||||
<summary>
|
||||
固定头
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Len">
|
||||
<summary>
|
||||
数据体长度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.IMEI">
|
||||
<summary>
|
||||
IMEI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.ICCID">
|
||||
<summary>
|
||||
ICCID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.IMSI">
|
||||
<summary>
|
||||
IMSI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.GSLQ">
|
||||
<summary>
|
||||
信号强度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Time">
|
||||
<summary>
|
||||
时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Longitude">
|
||||
<summary>
|
||||
经度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Latitude">
|
||||
<summary>
|
||||
纬度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.size">
|
||||
<summary>
|
||||
桶大小
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.trashcode">
|
||||
<summary>
|
||||
垃圾桶编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.WasteType">
|
||||
<summary>
|
||||
垃圾类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Weight">
|
||||
<summary>
|
||||
重量,KG
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Body">
|
||||
<summary>
|
||||
内容
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.Str">
|
||||
<summary>
|
||||
字符串结果
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.IsChecked">
|
||||
<summary>
|
||||
是否是否通过校检,true-是,false-否
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.IsHeart">
|
||||
<summary>
|
||||
是否为心跳包数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.A8MyPackage.IsWeight">
|
||||
<summary>
|
||||
是否为有效测量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.nMyPackage">
|
||||
<summary>
|
||||
新的4G模块上传的数据包体
|
||||
|
|
@ -1875,6 +2005,13 @@
|
|||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.IResultService.InsertResultByA84GAsync(Waste.Application.A8MyPackage)">
|
||||
<summary>
|
||||
新的A8 4G模块测量结果增加
|
||||
</summary>
|
||||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.IResultService.InsertResultByWifiAsync(Waste.Application.WifiPackage)">
|
||||
<summary>
|
||||
wifi模块测量结果增加
|
||||
|
|
@ -1934,6 +2071,13 @@
|
|||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.ResultService.InsertResultByA84GAsync(Waste.Application.A8MyPackage)">
|
||||
<summary>
|
||||
新的A8 4G模块测量结果增加
|
||||
</summary>
|
||||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.ResultService.SendMessageToThird(Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto)">
|
||||
<summary>
|
||||
给第三方推送消息
|
||||
|
|
@ -2108,6 +2252,11 @@
|
|||
垃圾类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.WasteSType">
|
||||
<summary>
|
||||
物品小类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscribeS2SDto.Weight">
|
||||
<summary>
|
||||
重量,单位KG
|
||||
|
|
@ -2143,6 +2292,11 @@
|
|||
垃圾类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.WasteSType">
|
||||
<summary>
|
||||
物品小类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.Weight">
|
||||
<summary>
|
||||
重量,单位KG
|
||||
|
|
@ -2215,6 +2369,13 @@
|
|||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.InsertA84GResultAsync(Waste.Application.A8MyPackage)">
|
||||
<summary>
|
||||
A8 4G模块传输的数据增加测量记录
|
||||
</summary>
|
||||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.Test(Waste.Application.nMyPackage)">
|
||||
<summary>
|
||||
测试,4G模块传输的数据增加测量记录
|
||||
|
|
@ -2290,6 +2451,13 @@
|
|||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.InsertA84GResultAsync(Waste.Application.A8MyPackage)">
|
||||
<summary>
|
||||
A8 4G模块传输的数据增加测量记录
|
||||
</summary>
|
||||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.CityListModel">
|
||||
<summary>
|
||||
地址列表
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ namespace Waste.CreateDB
|
|||
Console.WriteLine("开始创建表!");
|
||||
var context = new CreateTable();
|
||||
context.Create(false, 50,
|
||||
typeof(W_DeviceConfig)
|
||||
typeof(W_DeviceConfig),
|
||||
typeof(W_MeasureResult)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Waste.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 更多测量记录
|
||||
/// </summary>
|
||||
[SugarTable("W_MeasureResult", TableDescription = "更多测量记录", IsDisabledUpdateAll = false, IsDisabledDelete = true)]
|
||||
public class W_MeasureResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "记录ID",IsPrimaryKey =true)]
|
||||
public Guid ResultId { get; set; }
|
||||
/// <summary>
|
||||
/// 物品小类
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "物品小类", ColumnDataType = "nvarchar(100)")]
|
||||
public string WasteSType { get; set; }
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "价格", ColumnDataType = "decimal(18,2)")]
|
||||
public decimal Price { get; set; }
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "金额", ColumnDataType = "decimal(18,2)")]
|
||||
public decimal Amount { get; set; }
|
||||
/// <summary>
|
||||
/// 操作员
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "操作员", ColumnDataType = "nvarchar(100)")]
|
||||
public string OpUser { get; set; }
|
||||
/// <summary>
|
||||
/// 唯一消息ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "唯一消息ID", ColumnDataType = "varchar(50)",IndexGroupNameList =new string[] { "index_uuid"})]
|
||||
public string UUID { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ namespace Waste.Domain
|
|||
/// </summary>
|
||||
public class W_ResultExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// 记录ID
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Waste.SocketService
|
|||
/// <summary>
|
||||
/// socket包内容
|
||||
/// </summary>
|
||||
public class MyPackage
|
||||
public class MyPackage: A8Package
|
||||
{
|
||||
/// <summary>
|
||||
/// 固定头
|
||||
|
|
@ -84,4 +84,35 @@ namespace Waste.SocketService
|
|||
/// </summary>
|
||||
public bool IsWeight { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A8协议包内容
|
||||
/// </summary>
|
||||
public class A8Package
|
||||
{
|
||||
/// <summary>
|
||||
/// 垃圾类别小类
|
||||
/// </summary>
|
||||
public string WasteSType { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 消息ID
|
||||
/// </summary>
|
||||
public string UUID { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 上报时间
|
||||
/// </summary>
|
||||
public string UploadTime { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public string Price { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
public string Amount { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 操作员
|
||||
/// </summary>
|
||||
public string OpUser { get; set; } = "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ namespace Waste.SocketService
|
|||
key = keys.BytesToString();
|
||||
}
|
||||
#endregion
|
||||
if (key != "A9")
|
||||
if (key != "A9" && key !="A8")
|
||||
{
|
||||
var len = reader.Length;
|
||||
string msg = "";
|
||||
|
|
@ -221,6 +221,90 @@ namespace Waste.SocketService
|
|||
package.IsChecked = false;
|
||||
package.Body = msg;
|
||||
}
|
||||
else if (key == "A8")
|
||||
{
|
||||
package.Key = key;
|
||||
package.Len = (int)reader.Length - 2;
|
||||
string body = "";
|
||||
byte[] bytes = new byte[package.Len];
|
||||
for (var i = 0; i < package.Len; i++)
|
||||
{
|
||||
reader.TryRead(out byte val);
|
||||
bytes[i] = val;
|
||||
}
|
||||
if (bytes.Length == 1 && bytes[0] == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
body = bytes.BytesToString().Replace("\r", "").Replace("\n", "");
|
||||
package.Body = bytes.BytesToHexStr();
|
||||
var arr = body.Split('|');
|
||||
#region 心跳包的处理,IMEI|GPS
|
||||
if (arr.Length == 2)
|
||||
{
|
||||
package.IsHeart = true;
|
||||
package.IMEI = arr[0];
|
||||
var gpsarr = arr[1].Split(',');
|
||||
if (gpsarr.Length == 2)
|
||||
{
|
||||
package.Longitude = gpsarr[0];
|
||||
package.Latitude = gpsarr[1];
|
||||
}
|
||||
}
|
||||
else if (arr.Length == 7 && string.IsNullOrEmpty(arr[6]))
|
||||
{
|
||||
package.IsHeart = true;
|
||||
package.ICCID = arr[0];
|
||||
package.IMEI = arr[1];
|
||||
package.IMSI = arr[2];
|
||||
var gslq = Encoding.GetEncoding("GB2312").GetBytes(arr[3]);
|
||||
if (gslq.Length == 2)
|
||||
{
|
||||
package.GSLQ = Convert.ToInt32(gslq[1]).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
package.GSLQ = gslq.BytesToHexStr();
|
||||
}
|
||||
package.Time = $"{arr[4]}{arr[5]}".Replace("-", "").Replace(":", "");
|
||||
}
|
||||
else if (arr.Length == 7)
|
||||
{
|
||||
package.ICCID = arr[0];
|
||||
package.IMEI = arr[1];
|
||||
package.IMSI = arr[2];
|
||||
var gslq = Encoding.GetEncoding("GB2312").GetBytes(arr[3]);
|
||||
if (gslq.Length == 2)
|
||||
{
|
||||
package.GSLQ = Convert.ToInt32(gslq[1]).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
package.GSLQ = gslq.BytesToHexStr();
|
||||
}
|
||||
package.Time = $"{arr[4]}{arr[5]}".Replace("-", "").Replace(":", "");
|
||||
//uuid@datetime@垃圾类型@子类@重量@价格@金额@操作员
|
||||
var measurearr =Encoding.UTF8.GetString(Encoding.GetEncoding("GB2312").GetBytes(arr[6])).Split('@');
|
||||
if (measurearr.Length == 8)
|
||||
{
|
||||
package.UUID = measurearr[0];
|
||||
package.UploadTime = measurearr[1];
|
||||
package.WasteType = measurearr[2];
|
||||
package.WasteSType = measurearr[3];
|
||||
package.Weight = measurearr[4];
|
||||
package.Price = measurearr[5];
|
||||
package.Amount = measurearr[6];
|
||||
package.OpUser = measurearr[7];
|
||||
package.IsWeight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
package.size = arr[6];
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
package.Key = key;
|
||||
|
|
@ -251,7 +335,7 @@ namespace Waste.SocketService
|
|||
package.Latitude = gpsarr[1];
|
||||
}
|
||||
}
|
||||
else if(arr.Length == 7 && string.IsNullOrEmpty(arr[6]))
|
||||
else if (arr.Length == 7 && string.IsNullOrEmpty(arr[6]))
|
||||
{
|
||||
package.IsHeart = true;
|
||||
package.ICCID = arr[0];
|
||||
|
|
|
|||
|
|
@ -115,23 +115,41 @@ namespace Waste.SocketService
|
|||
string msg = $"通过校检,十六进制:{package.Body},字符串:{package.Str}";
|
||||
if (package.IsHeart)
|
||||
{
|
||||
msg = $"{msg},心跳包数据,{(package == null?"":JsonConvert.SerializeObject(package))}";
|
||||
msg = $"{msg},心跳包数据,{(package == null ? "" : JsonConvert.SerializeObject(package))}";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = $"{msg},测量数据,{(package == null ? "" : JsonConvert.SerializeObject(package))}";
|
||||
if (package.IsWeight)
|
||||
{
|
||||
if (package.Key == "A8")
|
||||
{
|
||||
msg = $"{msg},uuid:{package.UUID},测量时间:{package.UploadTime},垃圾类别:{package.WasteType},小类:{package.WasteSType},重量:{package.Weight},价格:{package.Price},金额:{package.Amount},操作员:{package.OpUser}";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = $"{msg},桶大小:{package.size},垃圾桶编号:{package.trashcode},垃圾类别:{package.WasteType},重量:{package.Weight}KG";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = $"{msg},数据:{package.size}";
|
||||
}
|
||||
}
|
||||
//向rabbitmq队列发布消息
|
||||
await _capBus.PublishAsync("result.service.insert4g", package);
|
||||
_logger.Information(msg);
|
||||
if (package.Key == "A8")
|
||||
{
|
||||
await _capBus.PublishAsync("result.service.inserta84g", package);
|
||||
if (!session.Channel.IsClosed)
|
||||
{
|
||||
string returndata = $"STATUS,OK,{package.UUID}";
|
||||
await session.SendAsync(Encoding.GetEncoding("GB2312").GetBytes(returndata + "\r\n"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await _capBus.PublishAsync("result.service.insert4g", package);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<History>True|2022-05-17T09:19:03.8993888Z;True|2021-11-23T17:56:50.1140092+08:00;True|2021-11-23T17:47:15.3723334+08:00;True|2021-11-23T17:46:56.0953346+08:00;True|2021-11-23T15:39:30.7279293+08:00;True|2021-11-23T15:26:11.9749528+08:00;True|2021-11-23T15:19:15.3506970+08:00;True|2021-11-23T14:58:10.0460847+08:00;</History>
|
||||
<History>True|2022-06-18T03:30:52.8509064Z;True|2022-06-18T11:12:53.8211499+08:00;True|2022-06-18T11:11:56.6483268+08:00;True|2022-06-18T10:40:35.8822373+08:00;True|2022-05-17T17:19:03.8993888+08:00;True|2021-11-23T17:56:50.1140092+08:00;True|2021-11-23T17:47:15.3723334+08:00;True|2021-11-23T17:46:56.0953346+08:00;True|2021-11-23T15:39:30.7279293+08:00;True|2021-11-23T15:26:11.9749528+08:00;True|2021-11-23T15:19:15.3506970+08:00;True|2021-11-23T14:58:10.0460847+08:00;</History>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"logfile": "e:/errlog/wastesocket.jt-sky.com", //日志文件路径
|
||||
"logfile": "e:/errlog/wastesocket.jt-sky.com", //日志文件路径
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"serverOptions": { //supersocker配置
|
||||
"serverOptions": { //supersocker配置
|
||||
"name": "WasteService",
|
||||
"listeners": [
|
||||
{
|
||||
|
|
@ -20,11 +20,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"RabbitmqSetting": { //rabbitmq配置
|
||||
"RabbitmqSetting": { //rabbitmq配置
|
||||
"HostName": "localhost",
|
||||
"Port": 5672,
|
||||
"UserName": "liuzl",
|
||||
"Password": "liuzl",
|
||||
"DBConnection": "Server=123.60.2.99,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;" //数据保存库
|
||||
"DBConnection": "Server=123.60.2.99,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;" //数据保存库
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"logfile": "d:/errlog/wastesocket.jt-sky.com", //日志文件路径
|
||||
"logfile": "d:/errlog/wastesocket.jt-sky.com", //日志文件路径
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"serverOptions": { //supersocker配置
|
||||
"serverOptions": { //supersocker配置
|
||||
"name": "WasteService",
|
||||
"listeners": [
|
||||
{
|
||||
|
|
@ -20,11 +20,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"RabbitmqSetting": { //rabbitmq配置
|
||||
"RabbitmqSetting": { //rabbitmq配置
|
||||
"HostName": "localhost",
|
||||
"Port": 5672,
|
||||
"UserName": "liuzl",
|
||||
"Password": "liuzl",
|
||||
"DBConnection": "Server=localhost,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;" //数据保存库
|
||||
"DBConnection": "Server=localhost,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;" //数据保存库
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue