@@ -117,7 +117,16 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto | |||||
{ | { | ||||
if (p.Name.ToLower() == name.ToLower()) | if (p.Name.ToLower() == name.ToLower()) | ||||
{ | { | ||||
retstr= p.GetValue(obj, null)?.ToString(); | |||||
if (p.GetValue(obj, null).GetType().FullName.Contains("System.Collections.Generic.List")) | |||||
{ | |||||
retstr = JsonConvert.SerializeObject(p.GetValue(obj, null)); | |||||
} | |||||
else | |||||
{ | |||||
retstr = p.GetValue(obj, null)?.ToString(); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
//输出字符串 | //输出字符串 | ||||
@@ -102,5 +102,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum | |||||
/// </summary> | /// </summary> | ||||
[ErrorCodeItemMetadata("配方不存在")] | [ErrorCodeItemMetadata("配方不存在")] | ||||
Code10015, | Code10015, | ||||
/// <summary> | |||||
/// 下发错误 | |||||
/// </summary> | |||||
[ErrorCodeItemMetadata("下发错误")] | |||||
Code10016, | |||||
} | } | ||||
} | } |
@@ -4,20 +4,28 @@ using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services; | |||||
using BPA.SAAS.Manage.Comm.Enum; | using BPA.SAAS.Manage.Comm.Enum; | ||||
using BPA.SAAS.Manage.Core; | using BPA.SAAS.Manage.Core; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.DataBase; | using BPA.SAAS.Manage.Core.DataBase; | ||||
using BPA.SAAS.Manage.Core.Device; | |||||
using BPA.SAAS.Manage.Core.Product; | |||||
using Microsoft.AspNetCore.Components.Forms; | using Microsoft.AspNetCore.Components.Forms; | ||||
using Newtonsoft.Json; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services | namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services | ||||
{ | { | ||||
public class MaterialService : IMaterialServices, ITransient | public class MaterialService : IMaterialServices, ITransient | ||||
{ | { | ||||
private readonly ICheckServices _checkServices; | private readonly ICheckServices _checkServices; | ||||
public MaterialService(ICheckServices checkServices) | |||||
private readonly IThirdpartyPushService _thirdpartyPushService; | |||||
public MaterialService(ICheckServices checkServices, IThirdpartyPushService thirdpartyPushService) | |||||
{ | { | ||||
_checkServices = checkServices; | _checkServices = checkServices; | ||||
_thirdpartyPushService = thirdpartyPushService; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -27,7 +35,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<PageUtil<List<MaterialDto>>> GetMaterialPageList(MaterialPageInputDto inputDto) | public async Task<PageUtil<List<MaterialDto>>> GetMaterialPageList(MaterialPageInputDto inputDto) | ||||
{ | { | ||||
int total = new RefAsync<int>(); | int total = new RefAsync<int>(); | ||||
var data = SqlSugarDb.Db.Queryable<BPA_Batching, BPA_BatchingType, BPA_BatchingUint>((a, b, c) => | var data = SqlSugarDb.Db.Queryable<BPA_Batching, BPA_BatchingType, BPA_BatchingUint>((a, b, c) => | ||||
@@ -37,12 +45,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
.WhereIF(!string.IsNullOrEmpty(inputDto.Name), (a, b, c) => a.Batching_Name.Contains(inputDto.Name)) | .WhereIF(!string.IsNullOrEmpty(inputDto.Name), (a, b, c) => a.Batching_Name.Contains(inputDto.Name)) | ||||
.Select((a, b, c) => new MaterialDto() | .Select((a, b, c) => new MaterialDto() | ||||
{ | { | ||||
Id= a.Id, | |||||
Id = a.Id, | |||||
Code = a.Code, | Code = a.Code, | ||||
Name = a.Batching_Name, | Name = a.Batching_Name, | ||||
//TypeId = b.Id, | //TypeId = b.Id, | ||||
TypeName = b.Name, | TypeName = b.Name, | ||||
// UintId = c.Id, | |||||
// UintId = c.Id, | |||||
UintName = c.Name, | UintName = c.Name, | ||||
}).ToPageList(inputDto.Current, inputDto.PageSize, ref total); | }).ToPageList(inputDto.Current, inputDto.PageSize, ref total); | ||||
@@ -64,7 +72,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
SqlSugarDb.Db.Ado.BeginTran(); | SqlSugarDb.Db.Ado.BeginTran(); | ||||
//1.物料单位查询 | //1.物料单位查询 | ||||
var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.DataInfo.TypeName); | var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.DataInfo.TypeName); | ||||
@@ -121,6 +129,64 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
throw Oops.Oh(ErrorCodeEnum.Code1002); | throw Oops.Oh(ErrorCodeEnum.Code1002); | ||||
} | } | ||||
var input = new List<PushDeviceDto>(); | |||||
if (inputDto.StoreIdList != null && inputDto.StoreIdList.Count > 0) | |||||
{ | |||||
input = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo, BPA_Product>((a, b) => new JoinQueryInfos( | |||||
JoinType.Left, a.ProductId == b.Id)) | |||||
.Where(x => inputDto.StoreIdList.Contains(x.StopId)) | |||||
.Select((a, b) => new PushDeviceDto | |||||
{ | |||||
deviceAutoKey = a.AutoKey, | |||||
deviceId = a.Id, | |||||
deviceName = a.DeviceName, | |||||
messageId = "", | |||||
productName = "" | |||||
}) | |||||
.ToListAsync(); | |||||
} | |||||
if (inputDto.DeviceIdList != null && inputDto.DeviceIdList.Count > 0) | |||||
{ | |||||
input = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo, BPA_Product>((a, b) => new JoinQueryInfos( | |||||
JoinType.Left, a.ProductId == b.Id)) | |||||
.Where(x => inputDto.StoreIdList.Contains(x.StopId)) | |||||
.Select((a, b) => new PushDeviceDto | |||||
{ | |||||
deviceAutoKey = a.AutoKey, | |||||
deviceId = a.Id, | |||||
deviceName = a.DeviceName, | |||||
messageId = "", | |||||
productKey = "", | |||||
productName = b.Name, | |||||
productVersion = a.ProductVersionId, | |||||
type = 2 | |||||
}) | |||||
.ToListAsync(); | |||||
} | |||||
//4.添加记录 | |||||
foreach (var item in input) | |||||
{ | |||||
await _thirdpartyPushService.AddThirdpartyPushRecord(new Core.System.BPA_ThirdpartyPushRecord() | |||||
{ | |||||
CallbackUrl = inputDto.CallbackUrl, | |||||
GroupId = CurrentUser.GroupId, | |||||
Id = Guid.NewGuid().ToString(), | |||||
IsPush = false, | |||||
MessageId = CurrentUser.MessageId, | |||||
PushDevice =item.deviceId, | |||||
PushData = JsonConvert.SerializeObject(item), | |||||
}); | |||||
} | |||||
//5.发送mq | |||||
await _thirdpartyPushService.PushDevice(input); | |||||
SqlSugarDb.Db.Ado.CommitTran(); | SqlSugarDb.Db.Ado.CommitTran(); | ||||
return true; | return true; | ||||
@@ -128,7 +194,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
SqlSugarDb.Db.Ado.RollbackTran(); | SqlSugarDb.Db.Ado.RollbackTran(); | ||||
throw Oops.Oh(ErrorCodeEnum.Code1001); | |||||
throw Oops.Oh(e.Message); | |||||
} | } | ||||
} | } | ||||
@@ -154,7 +220,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
throw Oops.Oh(e.Message); | throw Oops.Oh(e.Message); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -166,7 +232,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
SqlSugarDb.Db.Ado.BeginTran(); | SqlSugarDb.Db.Ado.BeginTran(); | ||||
//1.物料单位查询 | //1.物料单位查询 | ||||
@@ -0,0 +1,52 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos | |||||
{ | |||||
public class PushDeviceDto | |||||
{ | |||||
//messagesId | |||||
public string messageId { get; set; } | |||||
public string deviceId { get; set; } | |||||
public string productVersion { get; set; } | |||||
public string productKey { get; set; } | |||||
public string productName { get; set; } | |||||
public string deviceName { get; set; } | |||||
public int deviceAutoKey { get; set; } | |||||
public string data { get; set; } | |||||
/// <summary> | |||||
/// 1.商品 2.物料 3.配方 4.工艺 | |||||
/// </summary> | |||||
public int type { get; set; } | |||||
public List<TopicsDataItem> topicsData { get; set; } | |||||
} | |||||
public class TopicsDataItem | |||||
{ | |||||
public string id { get; set; } | |||||
public string topics { get; set; } | |||||
public int topicsType { get; set; } | |||||
public string description { get; set; } | |||||
public string productId { get; set; } | |||||
public string productVesionId { get; set; } | |||||
public string isDefault { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,30 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos | |||||
{ | |||||
public class ThirdpartyPushRecordDto | |||||
{ | |||||
/// <summary> | |||||
/// 消息Id | |||||
/// </summary> | |||||
public string MessageId { get; set; } | |||||
public string DeviceId { get; set; } | |||||
/// <summary> | |||||
/// 下发是否成功 | |||||
/// </summary> | |||||
public bool IsPush { get; set; } | |||||
/// <summary> | |||||
/// 下发时间 | |||||
/// </summary> | |||||
public DateTime? PushTime { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,45 @@ | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | |||||
using BPA.SAAS.Manage.Core.System; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services | |||||
{ | |||||
public interface IThirdpartyPushService | |||||
{ | |||||
#region 设备 回调级下发数据和记录 | |||||
/// <summary> | |||||
/// 下发到设备 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
Task<bool> PushDevice(List<PushDeviceDto> inputDto); | |||||
/// <summary> | |||||
/// 添加 三方 回调设备记录 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
Task<bool> AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto); | |||||
/// <summary> | |||||
/// 修改 第三方订单的回调 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
Task<bool> UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto); | |||||
/// <summary> | |||||
/// 更具店铺获取设备 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
Task<List<string>> GetDeviceByStoreId(List<string> inputDto); | |||||
#endregion | |||||
} | |||||
} |
@@ -0,0 +1,96 @@ | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.SAAS.KitChenManage.Core; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | |||||
using BPA.SAAS.Manage.Comm.Util; | |||||
using BPA.SAAS.Manage.Core.Device; | |||||
using BPA.SAAS.Manage.Core.System; | |||||
using Microsoft.AspNetCore.Mvc.ViewFeatures; | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services | |||||
{ | |||||
public class ThirdpartyPushService : IThirdpartyPushService, ITransient | |||||
{ | |||||
#region 设备 回调级下发数据和记录 | |||||
/// <summary> | |||||
/// 添加 三方 回调设备记录 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<bool> AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto) | |||||
{ | |||||
var res = await SqlSugarDb.Db.Insertable(inputDto).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
} | |||||
/// <summary> | |||||
/// 下发到设备 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<bool> PushDevice(List<PushDeviceDto> inputDto) | |||||
{ | |||||
Dictionary<string, string> dic = new Dictionary<string, string>(); | |||||
var url = App.Configuration["baseurl"] + "api/devicepushrecode/add_alm"; | |||||
var inputData = JsonConvert.SerializeObject(inputDto); | |||||
var jsonData = HttpHelper.PostData(url, inputData, Encoding.UTF8, "application/json", dic); | |||||
var data = JsonConvert.DeserializeObject<ResultSAASManageDto<ResultTenantDataItemDto>>(jsonData); | |||||
if (data.statusCode != 200) throw Oops.Oh(ErrorCodeEnum.Code10016); | |||||
if (data.data.data.Count <= 0) throw Oops.Oh(ErrorCodeEnum.Code10016); | |||||
return true; | |||||
} | |||||
/// <summary> | |||||
/// 修改 第三方订单的回调 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<bool> UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto) | |||||
{ | |||||
var data = await SqlSugarDb.Db.Queryable<BPA_ThirdpartyPushRecord>() | |||||
.ClearFilter() | |||||
.FirstAsync(x => x.MessageId == inputDto.MessageId&&x.PushDevice==inputDto.DeviceId); | |||||
if (data == null) | |||||
{ | |||||
throw Oops.Oh("没有查询到回调信息"); | |||||
} | |||||
data.IsPush = inputDto.IsPush; | |||||
data.CreateAt = DateTime.Now; | |||||
var res = await SqlSugarDb.Db.Updateable(data).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
} | |||||
/// <summary> | |||||
/// 更具店铺获取设备 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<List<string>> GetDeviceByStoreId(List<string> inputDto) | |||||
{ | |||||
var data = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo>() | |||||
.Where(x => inputDto.Contains(x.StopId)) | |||||
.Select(x => x.Id) | |||||
.ToListAsync(); | |||||
return data; | |||||
} | |||||
#endregion | |||||
} | |||||
} |
@@ -0,0 +1,57 @@ | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services; | |||||
using BPA.SAAS.Manage.Core.System; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush | |||||
{ | |||||
public class ThirdpartyPushServices: IDynamicApiController | |||||
{ | |||||
IThirdpartyPushService _thirdpartyPushService; | |||||
public ThirdpartyPushServices(IThirdpartyPushService thirdpartyPushService) | |||||
{ | |||||
_thirdpartyPushService = thirdpartyPushService; | |||||
} | |||||
#region 设备 回调级下发数据和记录 | |||||
/// <summary> | |||||
/// 添加 三方 回调设备记录 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<bool> AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto) | |||||
{ | |||||
return await _thirdpartyPushService.AddThirdpartyPushRecord(inputDto); | |||||
} | |||||
/// <summary> | |||||
/// 修改 第三方订单的回调 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
[HttpPost("/api/hirdpartypush/updatethirdpartypushrecord"), AllowAnonymous] | |||||
public async Task<bool> UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto) | |||||
{ | |||||
return await _thirdpartyPushService.UpdateThirdpartyPushRecord(inputDto); | |||||
} | |||||
/// <summary> | |||||
/// 更具店铺获取设备 | |||||
/// </summary> | |||||
/// <param name="inputDto"></param> | |||||
/// <returns></returns> | |||||
public async Task<List<string>> GetDeviceByStoreId(List<string> inputDto) | |||||
{ | |||||
return await _thirdpartyPushService.GetDeviceByStoreId(inputDto); | |||||
} | |||||
#endregion | |||||
} | |||||
} |
@@ -1,7 +1,9 @@ | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||||
using BPA.SAAS.Manage.Application.Device.Interface; | using BPA.SAAS.Manage.Application.Device.Interface; | ||||
using BPA.SAAS.Manage.Comm.Model; | using BPA.SAAS.Manage.Comm.Model; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.System; | |||||
using Microsoft.AspNetCore.Components.Forms; | using Microsoft.AspNetCore.Components.Forms; | ||||
using NPOI.Util; | using NPOI.Util; | ||||
using System; | using System; | ||||
@@ -93,5 +95,10 @@ namespace BPA.SAAS.Manage.Application.Device | |||||
{ | { | ||||
return await _deviceService.GetDeviceTypeList(); | return await _deviceService.GetDeviceTypeList(); | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||||
using BPA.SAAS.Manage.Comm.Model; | using BPA.SAAS.Manage.Comm.Model; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.System; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -19,5 +21,6 @@ namespace BPA.SAAS.Manage.Application.Device.Interface | |||||
Task<bool> DelDeviceInfo(List<string> inputList); | Task<bool> DelDeviceInfo(List<string> inputList); | ||||
Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto); | Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto); | ||||
Task<List<ListSelectQuery>> GetDeviceTypeList(); | Task<List<ListSelectQuery>> GetDeviceTypeList(); | ||||
} | } | ||||
} | } |
@@ -1,4 +1,5 @@ | |||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; | |||||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | using BPA.SAAS.Manage.Application.Device.Dtos.Device; | ||||
using BPA.SAAS.Manage.Application.Device.Interface; | using BPA.SAAS.Manage.Application.Device.Interface; | ||||
using BPA.SAAS.Manage.Comm.Const; | using BPA.SAAS.Manage.Comm.Const; | ||||
@@ -10,12 +11,14 @@ using BPA.SAAS.Manage.Core.Device; | |||||
using BPA.SAAS.Manage.Core.Org; | using BPA.SAAS.Manage.Core.Org; | ||||
using BPA.SAAS.Manage.Core.Product; | using BPA.SAAS.Manage.Core.Product; | ||||
using BPA.SAAS.Manage.Core.system; | using BPA.SAAS.Manage.Core.system; | ||||
using BPA.SAAS.Manage.Core.System; | |||||
using Dm; | using Dm; | ||||
using Furion.RemoteRequest.Extensions; | using Furion.RemoteRequest.Extensions; | ||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Security.Policy; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -229,5 +232,11 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
// BPALog.WriteLog($"调用订单服务:{url},调用成功"); | // BPALog.WriteLog($"调用订单服务:{url},调用成功"); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -0,0 +1,72 @@ | |||||
using System.Net; | |||||
using System.Text; | |||||
namespace BPA.SAAS.Manage.Comm.Util | |||||
{ | |||||
public static class HttpHelper | |||||
{ | |||||
private static readonly HttpClient client = new HttpClient(); | |||||
/// <summary> | |||||
/// Get 请求 | |||||
/// </summary> | |||||
/// <param name="url"></param> | |||||
/// <param name="postDataStr"></param> | |||||
/// <param name="headers"></param> | |||||
/// <param name="platform"></param> | |||||
/// <param name="contentType"></param> | |||||
/// <returns></returns> | |||||
public static string HttpGet(string url, string postDataStr, Dictionary<string, string> headers, string contentType = "") | |||||
{ | |||||
var result = string.Empty; | |||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + postDataStr); | |||||
request.ServicePoint.Expect100Continue = false; //加了这一行代码 就OK了 | |||||
request.Method = "GET"; | |||||
request.ContentType = contentType; | |||||
foreach (KeyValuePair<string, string> kv in headers) | |||||
{ | |||||
request.Headers.Add(kv.Key, kv.Value); | |||||
} | |||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | |||||
Stream myResponseStream = response.GetResponseStream(); | |||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); | |||||
result = myStreamReader.ReadToEnd(); | |||||
myStreamReader.Close(); | |||||
myResponseStream.Close(); | |||||
return result; | |||||
} | |||||
public static string PostData(string url, string postData, Encoding encoding, string ContentType, Dictionary<string, string> headers) | |||||
{ | |||||
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url); | |||||
myReq.Method = "POST"; | |||||
myReq.Timeout = 600 * 60; | |||||
byte[] byteArray = encoding.GetBytes(postData); | |||||
myReq.ContentType = ContentType; | |||||
//对键值对进行遍历 | |||||
foreach (KeyValuePair<string, string> kv in headers) | |||||
{ | |||||
myReq.Headers.Add(kv.Key, kv.Value); | |||||
} | |||||
Stream dataStream = myReq.GetRequestStream(); | |||||
dataStream.Write(byteArray, 0, byteArray.Length); | |||||
dataStream.Close(); | |||||
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); | |||||
dataStream = HttpWResp.GetResponseStream(); | |||||
string result = ""; | |||||
using (StreamReader myStreamReader = new StreamReader(dataStream, encoding)) | |||||
{ | |||||
result = myStreamReader.ReadToEnd(); | |||||
myStreamReader.Close(); | |||||
} | |||||
dataStream.Close(); | |||||
HttpWResp.Close(); | |||||
return result; | |||||
} | |||||
} | |||||
} |
@@ -8,6 +8,9 @@ namespace BPA.SAAS.KitChenManage.Core | |||||
{ | { | ||||
public static class CurrentUser | public static class CurrentUser | ||||
{ | { | ||||
public static string MessageId { get; set; } | |||||
public static string GroupId { get; set; } | public static string GroupId { get; set; } | ||||
public static string key { get; set; } | public static string key { get; set; } | ||||
@@ -31,6 +31,7 @@ namespace BPA.SAAS.Manage.Core.Device | |||||
/// 所属产品 | /// 所属产品 | ||||
/// </summary> | /// </summary> | ||||
public string ProductId { get; set; } | public string ProductId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 产品标签 | /// 产品标签 | ||||
/// </summary> | /// </summary> | ||||
@@ -0,0 +1,48 @@ | |||||
using BPA.SAAS.Manage.Core.Base; | |||||
using SqlSugar; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Core.System | |||||
{ | |||||
/// <summary> | |||||
/// 第三方日志 下发设备记录 | |||||
/// </summary> | |||||
[SugarTable("bpa_thirdpartypushrecord")] | |||||
public class BPA_ThirdpartyPushRecord : IBaseEntity, IGroupId | |||||
{ | |||||
public string GroupId { get; set; } | |||||
/// <summary> | |||||
/// 消息Id | |||||
/// </summary> | |||||
public string MessageId { get; set; } | |||||
/// <summary> | |||||
/// 下发是否成功 | |||||
/// </summary> | |||||
public bool IsPush { get; set; } | |||||
public string CallbackUrl { get; set; } | |||||
/// <summary> | |||||
/// 下发时间 | |||||
/// </summary> | |||||
public DateTime? PushTime{ get; set; } | |||||
/// <summary> | |||||
/// 下发设备 | |||||
/// </summary> | |||||
public string PushDevice { get; set; } | |||||
/// <summary> | |||||
/// 下发数据 | |||||
/// </summary> | |||||
public string PushData { get; set; } | |||||
} | |||||
} |
@@ -3,6 +3,8 @@ using BPA.SAAS.KitChenManage.Core; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services; | |||||
using BPA.SAAS.Manage.Core.System; | using BPA.SAAS.Manage.Core.System; | ||||
using Furion; | using Furion; | ||||
using Furion.EventBus; | using Furion.EventBus; | ||||
@@ -25,18 +27,21 @@ namespace BPA.SAAS.Manage.Web.Core | |||||
public class RequestAuditFiltercs : IAsyncActionFilter | public class RequestAuditFiltercs : IAsyncActionFilter | ||||
{ | { | ||||
private readonly ICheckServices _checkServices; | private readonly ICheckServices _checkServices; | ||||
public RequestAuditFiltercs(ICheckServices checkServices) | |||||
private readonly IThirdpartyPushService _thirdpartyPushService; | |||||
public RequestAuditFiltercs( ICheckServices checkServices, IThirdpartyPushService thirdpartyPushService) | |||||
{ | { | ||||
_checkServices = checkServices; | _checkServices = checkServices; | ||||
_thirdpartyPushService= thirdpartyPushService; | |||||
} | } | ||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) | public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) | ||||
{ | { | ||||
CurrentUser.MessageId=Guid.NewGuid().ToString(); | |||||
//============== 这里是执行方法之前获取数据 ==================== | |||||
// 获取 HttpContext 和 HttpRequest 对象 | |||||
//============== 这里是执行方法之前获取数据 ==================== | |||||
// 获取 HttpContext 和 HttpRequest 对象 | |||||
var httpContext = context.HttpContext; | var httpContext = context.HttpContext; | ||||
var httpRequest = httpContext.Request; | var httpRequest = httpContext.Request; | ||||
@@ -60,15 +65,15 @@ namespace BPA.SAAS.Manage.Web.Core | |||||
if (requestUrl.ToUpper().Contains("ExternalPlatform".ToUpper())) | if (requestUrl.ToUpper().Contains("ExternalPlatform".ToUpper())) | ||||
{ | { | ||||
var key= httpRequest.Headers["key"]; | |||||
var sign= httpRequest.Headers["sign"]; | |||||
var key = httpRequest.Headers["key"]; | |||||
var sign = httpRequest.Headers["sign"]; | |||||
List<PropertyInfo> proplist = new List<PropertyInfo>(); | List<PropertyInfo> proplist = new List<PropertyInfo>(); | ||||
foreach (var parameter in parameters) | foreach (var parameter in parameters) | ||||
{ | { | ||||
var stingA= DtoValidator.GetSign(parameter.Value); | |||||
//var sign = DtoValidator.GetAttributePrice(parameter.Value, "sign"); | |||||
await _checkServices.CheckSign(key, stingA, sign); | |||||
var stingA = DtoValidator.GetSign(parameter.Value); | |||||
//var sign = DtoValidator.GetAttributePrice(parameter.Value, "sign"); | |||||
await _checkServices.CheckSign(key, stingA, sign); | |||||
} | } | ||||
} | } | ||||
@@ -84,24 +89,64 @@ namespace BPA.SAAS.Manage.Web.Core | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
//记录日志 | |||||
await SqlSugarDb.Db.Insertable(new BPA_ThirdpartyRequestLog() | await SqlSugarDb.Db.Insertable(new BPA_ThirdpartyRequestLog() | ||||
{ | { | ||||
Id=Guid.NewGuid().ToString(), | |||||
Id = CurrentUser.MessageId, | |||||
CreateBy = DateTime.Now.ToString(), | CreateBy = DateTime.Now.ToString(), | ||||
GroupId = CurrentUser.GroupId, | GroupId = CurrentUser.GroupId, | ||||
RequestUrl = requestUrl, | RequestUrl = requestUrl, | ||||
ReauestMethod = httpRequest.Method, | ReauestMethod = httpRequest.Method, | ||||
ReauestParm= JsonConvert.SerializeObject(parameters), | |||||
ResultParm = !isRequestSucceed? actionContext.Exception.ToString() : JsonConvert.SerializeObject(returnResult), | |||||
ReauestParm = JsonConvert.SerializeObject(parameters), | |||||
ResultParm = !isRequestSucceed ? actionContext.Exception.ToString() : JsonConvert.SerializeObject(returnResult), | |||||
IP = remoteIPv4 | IP = remoteIPv4 | ||||
}).ExecuteCommandAsync(); | }).ExecuteCommandAsync(); | ||||
////记录下发记录 | |||||
//if (isRequestSucceed) | |||||
//{ | |||||
// foreach (var parameter in parameters) | |||||
// { | |||||
// var isPush = DtoValidator.GetAttributePrice(parameter.Value, "isPush"); | |||||
// var callbackUrl = DtoValidator.GetAttributePrice(parameter.Value, "callbackUrl"); | |||||
// var storeIdList = DtoValidator.GetAttributePrice(parameter.Value, "storeIdList"); | |||||
// var deviceIdList = DtoValidator.GetAttributePrice(parameter.Value, "deviceIdList"); | |||||
// if (isPush.ToUpper() == "true".ToUpper()) | |||||
// { | |||||
// var list = new List<string>(); | |||||
// if (!string.IsNullOrEmpty(deviceIdList)) | |||||
// { | |||||
// list = JsonConvert.DeserializeObject<List<string>>(deviceIdList); | |||||
// } | |||||
// if ( !string.IsNullOrEmpty(storeIdList)) | |||||
// { | |||||
// list = await _thirdpartyPushService.GetDeviceByStoreId(JsonConvert.DeserializeObject<List<string>>(storeIdList)); | |||||
// } | |||||
// await _thirdpartyPushService.AddThirdpartyPushRecord(new BPA_ThirdpartyPushRecord() | |||||
// { | |||||
// Id = Guid.NewGuid().ToString(), | |||||
// GroupId = CurrentUser.GroupId, | |||||
// IsPush = false, | |||||
// CallbackUrl = callbackUrl, | |||||
// MessageId = msgId, | |||||
// PushData = JsonConvert.SerializeObject(parameters), | |||||
// PushDevice = JsonConvert.SerializeObject(list) | |||||
// }); | |||||
// } | |||||
// break; | |||||
// } | |||||
//} | |||||
} | } | ||||
catch (Exception e) | catch (Exception e) | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |