发送第三方消息全部小写化

This commit is contained in:
Hinse 2022-07-06 09:07:42 +08:00
parent a9634a443b
commit dcc81ba6fc
9 changed files with 85 additions and 153 deletions

View File

@ -17,12 +17,16 @@ namespace Waste.Application
config.ForType<ApiReportBaseDataItem, ApiReportBaseData>() config.ForType<ApiReportBaseDataItem, ApiReportBaseData>()
.Map(dest => dest.weight, src => src.DayWeight.ToString("f2")) .Map(dest => dest.weight, src => src.DayWeight.ToString("f2"))
.Map(dest => dest.pweight, src => src.DayPureWeight.ToString("f2")) .Map(dest => dest.pweight, src => src.DayPureWeight.ToString("f2"))
.Map(dest=>dest.time,src=>src.CreateTime.ToString("yyyy-MM-dd")) .Map(dest => dest.time, src => src.CreateTime.ToString("yyyy-MM-dd"))
.Map(dest=>dest.type,src=>src.WasteType) .Map(dest => dest.type, src => src.WasteType)
; ;
config.ForType<SendThirdMessageSubscribeS2SDto, SendThirdMessageSubscriDto>() config.ForType<SendThirdMessageSubscribeS2SDto, SendThirdMessageSubscriDto>()
.Map(dest => dest.Time, src => src.Time.GetTimeStamp()) .Map(dest => dest.time, src => src.Time.GetTimeStamp())
; ;
config.ForType<SendThirdMessageSubscriDto, SendMessageToThirdS2CDto>()
.Map(dest => dest.trashcode, src => src.trashcode.ToStr())
.Map(dest => dest.wastestype, src => src.wastestype.ToStr())
;
} }
} }
} }

View File

@ -12,10 +12,12 @@ namespace Waste.Application.ResultInfos
public class ResultAppService : IDynamicApiController public class ResultAppService : IDynamicApiController
{ {
private readonly IResultService _resultService; private readonly IResultService _resultService;
public ResultAppService(IResultService resultService) public ResultAppService(IResultService resultService)
{ {
_resultService = resultService; _resultService = resultService;
} }
/// <summary> /// <summary>
/// 投放记录列表 /// 投放记录列表
/// </summary> /// </summary>
@ -26,6 +28,7 @@ namespace Waste.Application.ResultInfos
{ {
return await _resultService.GetListAsync(param); return await _resultService.GetListAsync(param);
} }
/// <summary> /// <summary>
/// 添加记录 /// 添加记录
/// </summary> /// </summary>
@ -45,11 +48,5 @@ namespace Waste.Application.ResultInfos
{ {
await _resultService.InsertResultByWifiAsync(data); await _resultService.InsertResultByWifiAsync(data);
} }
public async Task<string> RecvResult(SendMessageToThirdS2CDto data)
{
var getdata = data;
return await Task.FromResult("success");
}
} }
} }

View File

@ -34,6 +34,7 @@ namespace Waste.Application
_loggerService = loggerService; _loggerService = loggerService;
_capBus = capPublisher; _capBus = capPublisher;
} }
/// <summary> /// <summary>
/// 获取投放记录 /// 获取投放记录
/// </summary> /// </summary>
@ -127,7 +128,8 @@ namespace Waste.Application
{ {
it.PostStatus = res.Status; it.PostStatus = res.Status;
} }
var allext = cache.Get(list => { var allext = cache.Get(list =>
{
var ids = list.Select(e => e.Id).ToList(); var ids = list.Select(e => e.Id).ToList();
return dbClient.Queryable<W_MeasureResult>().Where(e => ids.Contains(e.ResultId)).ToList(); return dbClient.Queryable<W_MeasureResult>().Where(e => ids.Contains(e.ResultId)).ToList();
}); });
@ -143,6 +145,7 @@ namespace Waste.Application
limit = param.limit limit = param.limit
}; };
} }
/// <summary> /// <summary>
/// wifi模块测量结果增加 /// wifi模块测量结果增加
/// </summary> /// </summary>
@ -285,6 +288,7 @@ namespace Waste.Application
}); });
} }
} }
/// <summary> /// <summary>
/// 新的A8 4G模块测量结果增加 /// 新的A8 4G模块测量结果增加
/// </summary> /// </summary>
@ -382,6 +386,7 @@ namespace Waste.Application
}); });
} }
} }
/// <summary> /// <summary>
/// 给第三方推送消息 /// 给第三方推送消息
/// </summary> /// </summary>
@ -401,11 +406,12 @@ namespace Waste.Application
if (configdata != null && !configdata.Url.IsEmpty()) if (configdata != null && !configdata.Url.IsEmpty())
{ {
var senddata = input.Adapt<SendThirdMessageSubscriDto>(); var senddata = input.Adapt<SendThirdMessageSubscriDto>();
senddata.Body = configdata.Body.ToStr(); senddata.body = configdata.Body.ToStr();
senddata.Url = configdata.Url.ToStr(); senddata.Url = configdata.Url.ToStr();
await _capBus.PublishAsync("third.service.sendmessage", senddata); await _capBus.PublishAsync("third.service.sendmessage", senddata);
} }
} }
/// <summary> /// <summary>
/// 增加测量记录 /// 增加测量记录
/// </summary> /// </summary>
@ -464,7 +470,6 @@ namespace Waste.Application
} }
//000F000002.16进制 //000F000002.16进制
// var areaHex = Convert.ToHexString(areaBytes); // var areaHex = Convert.ToHexString(areaBytes);
} }
decimal weight = myPackage.Weight.IsEmpty() ? 0 : myPackage.Weight.ToDecimal(); decimal weight = myPackage.Weight.IsEmpty() ? 0 : myPackage.Weight.ToDecimal();
//记录数据 //记录数据
@ -533,6 +538,7 @@ namespace Waste.Application
{ {
return Convert.ToInt32(((int)bt).ToString("X2"), 16); return Convert.ToInt32(((int)bt).ToString("X2"), 16);
} }
private static int GetTimestamp(DateTime time) private static int GetTimestamp(DateTime time)
{ {
DateTime dateTimeStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0)); DateTime dateTimeStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));
@ -549,4 +555,4 @@ namespace Waste.Application
else return 0; else return 0;
} }
} }
} }

View File

@ -15,59 +15,73 @@ namespace Waste.Application.SubscribeInfo
/// 设备ID /// 设备ID
/// </summary> /// </summary>
public Guid DeviceId { get; set; } public Guid DeviceId { get; set; }
/// <summary> /// <summary>
/// 最近使用时间 /// 最近使用时间
/// </summary> /// </summary>
public DateTime? LastHeartTime { get; set; } public DateTime? LastHeartTime { get; set; }
/// <summary> /// <summary>
/// 记录ID /// 记录ID
/// </summary> /// </summary>
public Guid ResultId { get; set; } public Guid ResultId { get; set; }
/// <summary> /// <summary>
/// 设备服务商ID /// 设备服务商ID
/// </summary> /// </summary>
public Guid BusinessId { get; set; } public Guid BusinessId { get; set; }
/// <summary> /// <summary>
/// 设备的IMEI /// 设备的IMEI
/// </summary> /// </summary>
public string imei { get; set; } public string imei { get; set; }
/// <summary> /// <summary>
/// ICCID /// ICCID
/// </summary> /// </summary>
public string iccid { get; set; } public string iccid { get; set; }
/// <summary> /// <summary>
/// IMSI /// IMSI
/// </summary> /// </summary>
public string imsi { get; set; } public string imsi { get; set; }
/// <summary> /// <summary>
/// 纬度 /// 纬度
/// </summary> /// </summary>
public decimal latitude { get; set; } public decimal latitude { get; set; }
/// <summary> /// <summary>
/// 经度 /// 经度
/// </summary> /// </summary>
public decimal longtitude { get; set; } public decimal longtitude { get; set; }
/// <summary> /// <summary>
/// 信号强度 /// 信号强度
/// </summary> /// </summary>
public int gslq { get; set; } public int gslq { get; set; }
/// <summary> /// <summary>
/// 垃圾类型 /// 垃圾类型
/// </summary> /// </summary>
public string wastetype { get; set; } public string wastetype { get; set; }
/// <summary> /// <summary>
/// 垃圾桶编号 /// 垃圾桶编号
/// </summary> /// </summary>
public string trash { get; set; } public string trash { get; set; }
/// <summary> /// <summary>
/// 毛重 /// 毛重
/// </summary> /// </summary>
public string weight { get; set; } public string weight { get; set; }
/// <summary> /// <summary>
/// 皮重 /// 皮重
/// </summary> /// </summary>
public decimal Tare { get; set; } public decimal Tare { get; set; }
} }
/// <summary> /// <summary>
/// 设备版本信息 /// 设备版本信息
/// </summary> /// </summary>
@ -77,11 +91,13 @@ namespace Waste.Application.SubscribeInfo
/// 设备机器码 /// 设备机器码
/// </summary> /// </summary>
public string ecode { get; set; } public string ecode { get; set; }
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>
public string ver { get; set; } public string ver { get; set; }
} }
/// <summary> /// <summary>
/// 发送第三方消息 /// 发送第三方消息
/// </summary> /// </summary>
@ -96,18 +112,22 @@ namespace Waste.Application.SubscribeInfo
/// 垃圾类别 /// 垃圾类别
/// </summary> /// </summary>
public string WasteType { get; set; } public string WasteType { get; set; }
/// <summary> /// <summary>
/// 物品小类别 /// 物品小类别
/// </summary> /// </summary>
public string WasteSType { get; set; } = ""; public string WasteSType { get; set; } = "";
/// <summary> /// <summary>
/// 重量,单位KG /// 重量,单位KG
/// </summary> /// </summary>
public decimal Weight { get; set; } public decimal Weight { get; set; }
/// <summary> /// <summary>
/// 垃圾桶编号 /// 垃圾桶编号
/// </summary>s /// </summary>s
public string TrashCode { get; set; } public string TrashCode { get; set; }
/// <summary> /// <summary>
/// 上报时间 /// 上报时间
/// </summary> /// </summary>
@ -124,6 +144,7 @@ namespace Waste.Application.SubscribeInfo
/// </summary> /// </summary>
public string Url { get; set; } public string Url { get; set; }
} }
/// <summary> /// <summary>
/// 推送给第三方的信息 /// 推送给第三方的信息
/// </summary> /// </summary>
@ -132,33 +153,36 @@ namespace Waste.Application.SubscribeInfo
/// <summary> /// <summary>
/// 垃圾类别 /// 垃圾类别
/// </summary> /// </summary>
public string WasteType { get; set; } public string wastetype { get; set; }
/// <summary> /// <summary>
/// 物品小类别 /// 物品小类别
/// </summary> /// </summary>
public string WasteSType { get; set; } = ""; public string wastestype { get; set; } = "";
/// <summary> /// <summary>
/// 重量,单位KG /// 重量,单位KG
/// </summary> /// </summary>
public string Weight { get; set; } public string weight { get; set; }
/// <summary> /// <summary>
/// 垃圾桶编号 /// 垃圾桶编号
/// </summary> /// </summary>
public string TrashCode { get; set; } public string trashcode { get; set; }
/// <summary> /// <summary>
/// 上报时间 /// 上报时间
/// </summary> /// </summary>
public long Time { get; set; } public long time { get; set; }
/// <summary> /// <summary>
/// 额外信息 /// 额外信息
/// </summary> /// </summary>
public string Body { get; set; } public string body { get; set; }
/// <summary> /// <summary>
/// 设备ID /// 设备ID
/// </summary> /// </summary>
public Guid DeviceId { get; set; } public Guid deviceid { get; set; }
} }
} }

View File

@ -25,12 +25,14 @@ namespace Waste.Application
private readonly IHttpClientFactory _clientFactory; private readonly IHttpClientFactory _clientFactory;
private readonly ILoggerService _loggerService; private readonly ILoggerService _loggerService;
private readonly ISubscribeService _subscribeService; private readonly ISubscribeService _subscribeService;
public TestAppService(ILoggerService loggerService, IHttpClientFactory clientFactory, ISubscribeService subscribeService) public TestAppService(ILoggerService loggerService, IHttpClientFactory clientFactory, ISubscribeService subscribeService)
{ {
_loggerService = loggerService; _loggerService = loggerService;
_clientFactory = clientFactory; _clientFactory = clientFactory;
_subscribeService = subscribeService; _subscribeService = subscribeService;
} }
/// <summary> /// <summary>
/// 接收测试 /// 接收测试
/// </summary> /// </summary>
@ -48,23 +50,24 @@ namespace Waste.Application
[HttpGet] [HttpGet]
public void ConnectServer() public void ConnectServer()
{ {
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public async Task TestThirdSendAsync() public async Task TestThirdSendAsync()
{ {
await _subscribeService.SeedThirdMessageAsync(new SendThirdMessageSubscriDto { await _subscribeService.SeedThirdMessageAsync(new SendThirdMessageSubscriDto
Url= "https://localhost:44335/api/test/recv", {
WasteType= "\u0000\u0000\u0000\u0000纸壳", Url = "https://localhost:44335/api/test/recv",
Weight="20.9", wastetype = "\u0000\u0000\u0000\u0000纸壳",
TrashCode="0", weight = "20.9",
Time= 1653033312, trashcode = "0",
Body="", time = 1653033312,
DeviceId= Guid.Parse("39fcdce8-9e54-b87f-fc8e-616a9072c224") body = "",
deviceid = Guid.Parse("39fcdce8-9e54-b87f-fc8e-616a9072c224")
}); });
} }
@ -77,17 +80,18 @@ namespace Waste.Application
[HttpGet] [HttpGet]
public async Task TestSendAsync() public async Task TestSendAsync()
{ {
GarbagePltC2SDto garbageC2SDto = new GarbagePltC2SDto { GarbagePltC2SDto garbageC2SDto = new GarbagePltC2SDto
Weight=10.1, {
Weight = 10.1,
secret = "6Vxkfkg3kxqkkzgT", secret = "6Vxkfkg3kxqkkzgT",
secrethash = "51fb893bccc1395e", secrethash = "51fb893bccc1395e",
ScanningTime= 1627917492, ScanningTime = 1627917492,
DStatus=0, DStatus = 0,
deviceid = "08d954b6-df45-4de1-8fde-f5109798b855", deviceid = "08d954b6-df45-4de1-8fde-f5109798b855",
Trash = "000F000002", Trash = "000F000002",
Type = 4 Type = 4
}; };
if(garbageC2SDto.Weight == ((int)garbageC2SDto.Weight).ToDouble()) if (garbageC2SDto.Weight == ((int)garbageC2SDto.Weight).ToDouble())
{ {
garbageC2SDto.Weight = garbageC2SDto.Weight.ToDouble(0); garbageC2SDto.Weight = garbageC2SDto.Weight.ToDouble(0);
} }
@ -157,4 +161,4 @@ namespace Waste.Application
return sign; return sign;
} }
} }
} }

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Waste.Application.ThirdApiInfo.Message
{
/// <summary>
/// 设备消息推送给第三方处理
/// </summary>
public interface IMessageService
{
/// <summary>
/// 消息发送
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task SeedMessageAsync(SendMessageS2SDto input);
}
}

View File

@ -1,58 +0,0 @@
using DotNetCore.CAP;
using Furion.DependencyInjection;
using Nirvana.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Waste.Application.SubscribeInfo;
using Waste.Domain;
namespace Waste.Application.ThirdApiInfo.Message
{
/// <summary>
/// 设备消息推送给第三方处理
/// </summary>
public class MessageService : IMessageService, ITransient
{
private readonly ISqlSugarRepository<W_DeviceConfig> repository;
private readonly ICapPublisher _capBus;
private readonly SqlSugarClient dbClient;
public MessageService(ISqlSugarRepository<W_DeviceConfig> sqlSugarRepository, ICapPublisher capBus)
{
repository = sqlSugarRepository;
dbClient = repository.Context;
_capBus = capBus;
}
/// <summary>
/// 消息发送
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task SeedMessageAsync(SendMessageS2SDto input)
{
if (!await dbClient.Queryable<W_DeviceConfig>().AnyAsync(x => x.DeviceId == input.DeviceId))
{
return;
}
var config = await dbClient.Queryable<W_DeviceConfig>().Where(x => x.DeviceId == input.DeviceId).Select(x => new W_DeviceConfig
{
Body = x.Body,
Url = x.Url
}).FirstAsync();
var time = input.Time.GetTimeStamp();
await _capBus.PublishAsync("third.service.sendmessage", new SendThirdMessageSubscriDto
{
WasteType = input.WasteType,
Body = config.Body,
Time = time,
TrashCode = input.TrashCode,
Url = config.Url,
Weight = input.Weight
});
}
}
}

View File

@ -2287,37 +2287,37 @@
推送给第三方的信息 推送给第三方的信息
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.WasteType"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.wastetype">
<summary> <summary>
垃圾类别 垃圾类别
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.WasteSType"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.wastestype">
<summary> <summary>
物品小类别 物品小类别
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.Weight"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.weight">
<summary> <summary>
重量,单位KG 重量,单位KG
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.TrashCode"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.trashcode">
<summary> <summary>
垃圾桶编号 垃圾桶编号
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.Time"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.time">
<summary> <summary>
上报时间 上报时间
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.Body"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.body">
<summary> <summary>
额外信息 额外信息
</summary> </summary>
</member> </member>
<member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.DeviceId"> <member name="P:Waste.Application.SubscribeInfo.SendMessageToThirdS2CDto.deviceid">
<summary> <summary>
设备ID 设备ID
</summary> </summary>
@ -2730,10 +2730,10 @@
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Waste.Application.TestAppService.TestThirdSendAsync"> <member name="M:Waste.Application.TestAppService.TestThirdSendAsync">
<summary> <summary>
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Waste.Application.ThirdApiInfo.DevHeartRequestDto"> <member name="T:Waste.Application.ThirdApiInfo.DevHeartRequestDto">
<summary> <summary>
@ -3092,30 +3092,6 @@
<param name="data"></param> <param name="data"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Waste.Application.ThirdApiInfo.Message.IMessageService">
<summary>
设备消息推送给第三方处理
</summary>
</member>
<member name="M:Waste.Application.ThirdApiInfo.Message.IMessageService.SeedMessageAsync(Waste.Application.ThirdApiInfo.SendMessageS2SDto)">
<summary>
消息发送
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Waste.Application.ThirdApiInfo.Message.MessageService">
<summary>
设备消息推送给第三方处理
</summary>
</member>
<member name="M:Waste.Application.ThirdApiInfo.Message.MessageService.SeedMessageAsync(Waste.Application.ThirdApiInfo.SendMessageS2SDto)">
<summary>
消息发送
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Waste.Application.ThirdApiInfo.OpenAppService"> <member name="T:Waste.Application.ThirdApiInfo.OpenAppService">
<summary> <summary>
开放数据 开放数据

File diff suppressed because one or more lines are too long