增加设备消息发送
This commit is contained in:
parent
f944936cf6
commit
c800ccb046
|
|
@ -14,7 +14,7 @@ namespace Waste.Application
|
|||
/// <summary>
|
||||
/// 设备接口
|
||||
/// </summary>
|
||||
public class DeviceAppService:IDynamicApiController
|
||||
public class DeviceAppService : IDynamicApiController
|
||||
{
|
||||
private readonly IDeviceService _deviceService;
|
||||
public DeviceAppService(IDeviceService deviceService)
|
||||
|
|
@ -61,5 +61,14 @@ namespace Waste.Application
|
|||
{
|
||||
return await _deviceService.SetStatusAsync(id, status);
|
||||
}
|
||||
/// <summary>
|
||||
/// 配置设备推送信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultInfo> SetConfigAsync(DeviceConfigC2SDto input)
|
||||
{
|
||||
return await _deviceService.SetConfigAsync(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Furion.DependencyInjection;
|
||||
using Furion.DistributedIDGenerator;
|
||||
using Furion.DynamicApiController;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nirvana.Common;
|
||||
using Nirvana.Common.ApiBase;
|
||||
|
|
@ -148,6 +149,20 @@ namespace Waste.Application.Device
|
|||
FacEcode = device.FacEcode
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取设备配置详情
|
||||
/// </summary>
|
||||
/// <param name="id">设备ID</param>
|
||||
/// <returns></returns>
|
||||
public async Task<W_DeviceConfig> GetConfigAsync(Guid id)
|
||||
{
|
||||
var data= await dbClient.Queryable<W_DeviceConfig>().FirstAsync(x => x.DeviceId == id);
|
||||
if(data == null)
|
||||
{
|
||||
data= new W_DeviceConfig();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备列表
|
||||
|
|
@ -185,7 +200,7 @@ namespace Waste.Application.Device
|
|||
temquery = temquery.Where(x => SqlFunc.Subqueryable<W_Business>().Where(sql).Any());
|
||||
}
|
||||
string sorts = string.Format("{0} {1}", param.sort, param.order);
|
||||
var query = await temquery.OrderBy(x=>x.LastHeartTime,OrderByType.Desc)
|
||||
var query = await temquery.OrderBy(x => x.LastHeartTime, OrderByType.Desc)
|
||||
.Select(x => new DeviceList
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -261,6 +276,36 @@ namespace Waste.Application.Device
|
|||
limit = param.limit
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 配置设备推送信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultInfo> SetConfigAsync(DeviceConfigC2SDto input)
|
||||
{
|
||||
if (!await dbClient.Queryable<W_Device>().AnyAsync(x => x.Id == input.Id))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
}
|
||||
input.Body = input.Body.ToStr();
|
||||
input.Url = input.Url.ToLower();
|
||||
if (!input.Id.IsEmpty() && await dbClient.Queryable<W_DeviceConfig>().AnyAsync(x => x.DeviceId == input.Id))
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceConfig>().SetColumns(x => new W_DeviceConfig
|
||||
{
|
||||
Url = input.Url,
|
||||
Body = input.Body
|
||||
}).Where(x => x.DeviceId == input.Id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = input.Adapt<W_DeviceConfig>();
|
||||
insertdata.DeviceId = input.Id;
|
||||
insertdata.CreateTime = DateTime.Now;
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
return new ResultInfo(ResultState.SUCCESS, "配置成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备状态修改
|
||||
|
|
@ -268,13 +313,14 @@ namespace Waste.Application.Device
|
|||
/// <param name="id">设备ID</param>
|
||||
/// <param name="status">设备状态,0-停用,1-正常,2-激活</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultInfo> SetStatusAsync(Guid id,int status)
|
||||
public async Task<ResultInfo> SetStatusAsync(Guid id, int status)
|
||||
{
|
||||
if(!await dbClient.Queryable<W_Device>().AnyAsync(x=>x.Id == id))
|
||||
if (!await dbClient.Queryable<W_Device>().AnyAsync(x => x.Id == id))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
}
|
||||
await dbClient.Updateable<W_Device>().SetColumns(x => new W_Device {
|
||||
await dbClient.Updateable<W_Device>().SetColumns(x => new W_Device
|
||||
{
|
||||
Status = status
|
||||
}).Where(x => x.Id == id).ExecuteCommandAsync();
|
||||
return new ResultInfo(ResultState.SUCCESS, "设备状态已更新");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
using System;
|
||||
using Furion.DataValidation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Domain;
|
||||
|
||||
|
|
@ -85,7 +88,7 @@ namespace Waste.Application
|
|||
/// <summary>
|
||||
/// 设备信息提交
|
||||
/// </summary>
|
||||
public class DeviceSubmit:W_Device
|
||||
public class DeviceSubmit : W_Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备对应的SecretHash
|
||||
|
|
@ -103,7 +106,7 @@ namespace Waste.Application
|
|||
/// <summary>
|
||||
/// 设备详情
|
||||
/// </summary>
|
||||
public class DeviceDetailS2Dto: W_Device
|
||||
public class DeviceDetailS2Dto : W_Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 最近心跳时间
|
||||
|
|
@ -126,4 +129,44 @@ namespace Waste.Application
|
|||
/// </summary>
|
||||
public string version { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备配置
|
||||
/// </summary>
|
||||
public class DeviceConfigC2SDto : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送地址,支持http/https
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "推送地址不可为空")]
|
||||
[MaxLength(200, ErrorMessage = "推送地址最多200个字")]
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 额外推送信息,推送时固定以body参数传递
|
||||
/// </summary>
|
||||
[DataValidation(AllowNullValue = true)]
|
||||
[MaxLength(100, ErrorMessage = "额外推送信息最多100个字")]
|
||||
public string Body { get; set; }
|
||||
/// <summary>
|
||||
/// 验证
|
||||
/// </summary>
|
||||
/// <param name="validationContext"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Body) && (Body.Contains("&") || Body.Contains("?")))
|
||||
{
|
||||
yield return new ValidationResult("额外推送信息不可包含特殊字符&、?", new[] { nameof(Body) });
|
||||
}
|
||||
if(!Regex.IsMatch(Url.ToLower(), @"[http][a-zA-z]+://[^\s]*"))
|
||||
{
|
||||
yield return new ValidationResult("推送地址格式不正确", new[] { nameof(Url) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,5 +51,17 @@ namespace Waste.Application
|
|||
/// <param name="status">设备状态,0-停用,1-正常,2-激活</param>
|
||||
/// <returns></returns>
|
||||
Task<ResultInfo> SetStatusAsync(Guid id,int status);
|
||||
/// <summary>
|
||||
/// 配置设备推送信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<ResultInfo> SetConfigAsync(DeviceConfigC2SDto input);
|
||||
/// <summary>
|
||||
/// 获取设备配置详情
|
||||
/// </summary>
|
||||
/// <param name="id">设备ID</param>
|
||||
/// <returns></returns>
|
||||
Task<W_DeviceConfig> GetConfigAsync(Guid id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,4 +82,34 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// </summary>
|
||||
public string ver { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送第三方消息
|
||||
/// </summary>
|
||||
public class SendThirdMessageSubscriDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 垃圾类别
|
||||
/// </summary>
|
||||
public string WasteType { get; set; }
|
||||
/// <summary>
|
||||
/// 重量,单位KG
|
||||
/// </summary>
|
||||
public string Weight { get; set; }
|
||||
/// <summary>
|
||||
/// 垃圾桶编号
|
||||
/// </summary>
|
||||
public string TrashCode { get; set; }
|
||||
/// <summary>
|
||||
/// 上报时间
|
||||
/// </summary>
|
||||
public long Time { get; set; }
|
||||
/// <summary>
|
||||
/// 推送地址
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
/// <summary>
|
||||
/// 额外信息
|
||||
/// </summary>
|
||||
public string Body { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,5 +55,11 @@ namespace Waste.Application.SubscribeInfo
|
|||
/// <param name="myPackage"></param>
|
||||
/// <returns></returns>
|
||||
void Test(nMyPackage myPackage);
|
||||
/// <summary>
|
||||
/// 第三方推送设备消息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task SeedThirdMessageAsync(SendThirdMessageSubscriDto data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
using Furion.DependencyInjection;
|
||||
using Furion.DistributedIDGenerator;
|
||||
using Furion.Logging.Extensions;
|
||||
using Furion.RemoteRequest.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Nirvana.Common;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -250,7 +252,37 @@ namespace Waste.Application.SubscribeInfo
|
|||
public void Test(nMyPackage myPackage)
|
||||
{
|
||||
var msg = JsonConvert.SerializeObject(myPackage);
|
||||
_loggerService.AddLogger(msg,1);
|
||||
_loggerService.AddLogger(msg, 1);
|
||||
}
|
||||
/// <summary>
|
||||
/// 第三方推送设备消息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("third.service.sendmessage")]
|
||||
public async Task SeedThirdMessageAsync(SendThirdMessageSubscriDto data)
|
||||
{
|
||||
string errmsg = string.Empty;
|
||||
var response = await data.Url
|
||||
.SetBody(data, "application/json", Encoding.UTF8)
|
||||
.OnException((res, errors) =>
|
||||
{
|
||||
errmsg = errors;
|
||||
}).PostAsync();
|
||||
if (errmsg != string.Empty)
|
||||
{
|
||||
_loggerService.AddLogger($"第三方设备消息发送失败,内容:{data.ToJson()},返回:{errmsg}", 1);
|
||||
}
|
||||
var returnstr = await response.Content.ReadAsStringAsync();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
_loggerService.AddLogger($"第三方设备消息发送失败,内容:{data.ToJson()},返回:{returnstr}", 1);
|
||||
}
|
||||
if(returnstr.ToLower() != "success")
|
||||
{
|
||||
_loggerService.AddLogger($"第三方设备消息发送失败,内容:{data.ToJson()},返回:{returnstr}", 1);
|
||||
}
|
||||
_loggerService.AddLogger($"第三方设备消息发送成功,内容:{data.ToJson()},返回:{returnstr}", 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,6 +253,31 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// 结果集
|
||||
/// </summary>
|
||||
public byte[] databyte { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 消息发送
|
||||
/// </summary>
|
||||
public class SendMessageS2SDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public Guid DeviceId { get; set; }
|
||||
/// <summary>
|
||||
/// 垃圾类别
|
||||
/// </summary>
|
||||
public string WasteType { get; set; }
|
||||
/// <summary>
|
||||
/// 重量,单位KG
|
||||
/// </summary>
|
||||
public string Weight { get; set; }
|
||||
/// <summary>
|
||||
/// 垃圾桶编号
|
||||
/// </summary>
|
||||
public string TrashCode { get; set; }
|
||||
/// <summary>
|
||||
/// 上报时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -582,6 +582,13 @@
|
|||
<param name="status">设备状态,0-停用,1-正常,2-激活</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.DeviceAppService.SetConfigAsync(Waste.Application.DeviceConfigC2SDto)">
|
||||
<summary>
|
||||
配置设备推送信息
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.Device.DeviceService">
|
||||
<summary>
|
||||
设备管理
|
||||
|
|
@ -608,6 +615,13 @@
|
|||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.Device.DeviceService.GetConfigAsync(System.Guid)">
|
||||
<summary>
|
||||
获取设备配置详情
|
||||
</summary>
|
||||
<param name="id">设备ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.Device.DeviceService.GetListAsync(Nirvana.Common.QueryParams)">
|
||||
<summary>
|
||||
设备列表
|
||||
|
|
@ -615,6 +629,13 @@
|
|||
<param name="param"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.Device.DeviceService.SetConfigAsync(Waste.Application.DeviceConfigC2SDto)">
|
||||
<summary>
|
||||
配置设备推送信息
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.Device.DeviceService.SetStatusAsync(System.Guid,System.Int32)">
|
||||
<summary>
|
||||
设备状态修改
|
||||
|
|
@ -765,6 +786,33 @@
|
|||
使用的版本号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.DeviceConfigC2SDto">
|
||||
<summary>
|
||||
设备配置
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.DeviceConfigC2SDto.Id">
|
||||
<summary>
|
||||
设备ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.DeviceConfigC2SDto.Url">
|
||||
<summary>
|
||||
推送地址,支持http/https
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.DeviceConfigC2SDto.Body">
|
||||
<summary>
|
||||
额外推送信息,推送时固定以body参数传递
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Waste.Application.DeviceConfigC2SDto.Validate(System.ComponentModel.DataAnnotations.ValidationContext)">
|
||||
<summary>
|
||||
验证
|
||||
</summary>
|
||||
<param name="validationContext"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.IDeviceService">
|
||||
<summary>
|
||||
设备管理
|
||||
|
|
@ -813,6 +861,20 @@
|
|||
<param name="status">设备状态,0-停用,1-正常,2-激活</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.IDeviceService.SetConfigAsync(Waste.Application.DeviceConfigC2SDto)">
|
||||
<summary>
|
||||
配置设备推送信息
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.IDeviceService.GetConfigAsync(System.Guid)">
|
||||
<summary>
|
||||
获取设备配置详情
|
||||
</summary>
|
||||
<param name="id">设备ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.JobWorkder">
|
||||
<summary>
|
||||
定时任务
|
||||
|
|
@ -2017,6 +2079,41 @@
|
|||
版本号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto">
|
||||
<summary>
|
||||
发送第三方消息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.WasteType">
|
||||
<summary>
|
||||
垃圾类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.Weight">
|
||||
<summary>
|
||||
重量,单位KG
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.TrashCode">
|
||||
<summary>
|
||||
垃圾桶编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.Time">
|
||||
<summary>
|
||||
上报时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.Url">
|
||||
<summary>
|
||||
推送地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto.Body">
|
||||
<summary>
|
||||
额外信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.ISubscribeService">
|
||||
<summary>
|
||||
CAP订阅相关接口
|
||||
|
|
@ -2071,6 +2168,13 @@
|
|||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.SeedThirdMessageAsync(Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto)">
|
||||
<summary>
|
||||
第三方推送设备消息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.SubscribeService">
|
||||
<summary>
|
||||
CAP订阅相关接口
|
||||
|
|
@ -2125,6 +2229,13 @@
|
|||
<param name="myPackage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.SeedThirdMessageAsync(Waste.Application.SubscribeInfo.SendThirdMessageSubscriDto)">
|
||||
<summary>
|
||||
第三方推送设备消息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.CityListModel">
|
||||
<summary>
|
||||
地址列表
|
||||
|
|
@ -2676,6 +2787,36 @@
|
|||
结果集
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.ThirdApiInfo.SendMessageS2SDto">
|
||||
<summary>
|
||||
消息发送
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ThirdApiInfo.SendMessageS2SDto.DeviceId">
|
||||
<summary>
|
||||
设备ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ThirdApiInfo.SendMessageS2SDto.WasteType">
|
||||
<summary>
|
||||
垃圾类别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ThirdApiInfo.SendMessageS2SDto.Weight">
|
||||
<summary>
|
||||
重量,单位KG
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ThirdApiInfo.SendMessageS2SDto.TrashCode">
|
||||
<summary>
|
||||
垃圾桶编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.ThirdApiInfo.SendMessageS2SDto.Time">
|
||||
<summary>
|
||||
上报时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.ThirdApiInfo.IOpenService">
|
||||
<summary>
|
||||
设备对接接口
|
||||
|
|
@ -2723,6 +2864,30 @@
|
|||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</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">
|
||||
<summary>
|
||||
开放数据
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ namespace Waste.CreateDB
|
|||
Console.WriteLine("开始创建表!");
|
||||
var context = new CreateTable();
|
||||
context.Create(false, 50,
|
||||
typeof(W_DeviceData),
|
||||
typeof(W_DeviceResult)
|
||||
typeof(W_DeviceConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
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_DeviceConfig", TableDescription = "设备第三方配置信息", IsDisabledUpdateAll = false, IsDisabledDelete = true)]
|
||||
|
||||
public class W_DeviceConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid DeviceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送地址,支持http/https
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(200)", ColumnDescription = "推送地址,支持http/https")]
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 额外推送信息,推送时固定以body参数传递
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(100)", ColumnDescription = "额外推送信息,推送时固定以body参数传递")]
|
||||
public string Body { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "创建时间")]
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -5,16 +5,13 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Nirvana.Common;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Core;
|
||||
|
||||
namespace Waste.Web.Core
|
||||
|
|
@ -31,7 +28,7 @@ namespace Waste.Web.Core
|
|||
//});
|
||||
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));
|
||||
services.AddCorsAccessor();
|
||||
// services.AddRemoteRequest();
|
||||
services.AddRemoteRequest();
|
||||
services.AddHttpClient();
|
||||
|
||||
//添加CAP
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
@page
|
||||
@model Waste.Web.Entry.Pages.Device.ConfigModel
|
||||
@{
|
||||
ViewData["Title"] = "设备配置";
|
||||
}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="form-horizontal layui-form">
|
||||
<div class="layui-form-item row">
|
||||
<label class="layui-form-label col-md-2" for="Url">推送地址</label>
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="layui-input" id="Url" name="Url" value="@Model.data.Url" placeholder="请输入推送地址" lay-verify="required" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item row">
|
||||
<label class="layui-form-label col-md-2" for="Body">额外参数</label>
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="layui-input" id="Body" name="Body" value="@Model.data.Body" placeholder="请输入额外参数信息" />
|
||||
<span class="tiptext">消息推送时会以body参数名原样传递此参数</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center col-md-7">
|
||||
<button class="btn btn-primary btn-lg" lay-submit lay-filter="submit" type="button">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts{
|
||||
<script type="text/javascript" src="~/js/ajaxCascader/ajaxCascader.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['form', 'common'], function () {
|
||||
var form = layui.form,
|
||||
common = layui.common;
|
||||
form.on("submit(submit)", function (data) {
|
||||
data.field['id'] = '@Model.data.DeviceId';
|
||||
common.ajax({
|
||||
url: "/api/device/setconfig",
|
||||
type: "post",
|
||||
data: data.field
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Nirvana.Common;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.Web.Entry.Pages.Device
|
||||
{
|
||||
public class ConfigModel : PageModel
|
||||
{
|
||||
private readonly IDeviceService _deviceService;
|
||||
public ConfigModel(IDeviceService deviceService)
|
||||
{
|
||||
_deviceService = deviceService;
|
||||
}
|
||||
public W_DeviceConfig data = new W_DeviceConfig();
|
||||
public async Task OnGet(Guid id)
|
||||
{
|
||||
data = await _deviceService.GetConfigAsync(id);
|
||||
data.DeviceId = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,10 +47,11 @@
|
|||
<a href="#" class="js-edit" title="编辑" data-id="{{d.id}}">编辑</a>
|
||||
@*<a href="#" class="js-detail" title="详情" data-id="{{d.id}}">详情</a> *@
|
||||
{{#if (d.status == 1){ }}
|
||||
<a href="#" class="js-stop" title="设备停用" data-id="{{d.id}}">停用</a>
|
||||
<a href="#" class="js-stop" title="设备停用" data-id="{{d.id}}">停用</a>
|
||||
{{# } else if (d.status == 0){ }}
|
||||
<a href="#" class="js-start" title="设备启用" data-id="{{d.id}}">启用</a>
|
||||
<a href="#" class="js-start" title="设备启用" data-id="{{d.id}}">启用</a>
|
||||
{{#} }}
|
||||
<a href="#" class="js-config" title="配置" data-id="{{d.id}}">配置</a>
|
||||
</script>
|
||||
<script type="text/html" id="lefttoolbar">
|
||||
<button class="btn btn-primary btn-lg" lay-event="js-fenpei">分配</button>
|
||||
|
|
@ -266,6 +267,13 @@
|
|||
title: '编辑设备',
|
||||
content: '/Device/Edit?id=' + id
|
||||
});
|
||||
});
|
||||
$("body").on("click", ".js-config", function () {
|
||||
var id = $(this).data('id');
|
||||
common.dialog({
|
||||
title: '推送配置',
|
||||
content: '/Device/Config?id=' + id
|
||||
});
|
||||
});
|
||||
$("body").on("click", ".js-delete", function () {
|
||||
var id = $(this).data('id');
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4、测试工具", "4、测
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasteHexTest", "WasteHexTest\WasteHexTest.csproj", "{13679A86-CE78-49A2-BD09-83A33642D9BF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Waste.SocketService", "Waste.SocketService.cs\Waste.SocketService.csproj", "{52B214DE-0AE6-4554-ABA6-1222175A6DEE}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Waste.SocketService", "Waste.SocketService.cs\Waste.SocketService.csproj", "{52B214DE-0AE6-4554-ABA6-1222175A6DEE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
"projectUniqueName": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\WasteHexTest.csproj",
|
||||
"projectName": "WasteHexTest",
|
||||
"projectPath": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\WasteHexTest.csproj",
|
||||
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
|
||||
"packagesPath": "D:\\nuget\\Package",
|
||||
"outputPath": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"D:\\nuget\\.nuget\\packages": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.101\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.202\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Administrator\.nuget\packages\</NuGetPackageFolders>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">D:\nuget\Package</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">D:\nuget\Package</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.0.1</NuGetToolVersion>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.1.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\Administrator\.nuget\packages\" />
|
||||
<SourceRoot Include="D:\nuget\Package\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
"net6.0": []
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\Administrator\\.nuget\\packages\\": {}
|
||||
"D:\\nuget\\Package": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
"projectUniqueName": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\WasteHexTest.csproj",
|
||||
"projectName": "WasteHexTest",
|
||||
"projectPath": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\WasteHexTest.csproj",
|
||||
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
|
||||
"packagesPath": "D:\\nuget\\Package",
|
||||
"outputPath": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"D:\\nuget\\.nuget\\packages": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.101\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.202\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "/i1boeyhGlP73OaHsTLDU+EcpQMD5lkJaOoK1RWxq6AelMtgIgMnUAk5xh9sroJ0UEXu+aKTxIfYSAsgYCC1AA==",
|
||||
"dgSpecHash": "LJk1lyUQZNYsD+j3J5yd0Ah/gG1gatGqcrmkN3n5CQnNv6B/RDcPXYHjRVzj5RHuiOSnRXLESvi2bmW7+ap3HA==",
|
||||
"success": true,
|
||||
"projectFilePath": "H:\\liuzl_ybhdmob\\Waste\\WasteHexTest\\WasteHexTest.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
|
|
|
|||
Loading…
Reference in New Issue