diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/BaseDto/DtoValidator.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/BaseDto/DtoValidator.cs
index b2de84c..a9d5282 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/BaseDto/DtoValidator.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/BaseDto/DtoValidator.cs
@@ -117,7 +117,16 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto
{
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();
+ }
+
+
}
});
//输出字符串
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
index 4733d50..a060d82 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
@@ -102,5 +102,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum
///
[ErrorCodeItemMetadata("配方不存在")]
Code10015,
+
+ ///
+ /// 下发错误
+ ///
+ [ErrorCodeItemMetadata("下发错误")]
+ Code10016,
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs
index 567a00c..5ca4eef 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Material/Services/MaterialService.cs
@@ -4,20 +4,28 @@ using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
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.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.Core;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.DataBase;
+using BPA.SAAS.Manage.Core.Device;
+using BPA.SAAS.Manage.Core.Product;
using Microsoft.AspNetCore.Components.Forms;
+using Newtonsoft.Json;
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services
{
public class MaterialService : IMaterialServices, ITransient
{
private readonly ICheckServices _checkServices;
- public MaterialService(ICheckServices checkServices)
+ private readonly IThirdpartyPushService _thirdpartyPushService;
+ public MaterialService(ICheckServices checkServices, IThirdpartyPushService thirdpartyPushService)
{
_checkServices = checkServices;
+ _thirdpartyPushService = thirdpartyPushService;
}
///
@@ -27,7 +35,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service
///
public async Task>> GetMaterialPageList(MaterialPageInputDto inputDto)
{
-
+
int total = new RefAsync();
var data = SqlSugarDb.Db.Queryable((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))
.Select((a, b, c) => new MaterialDto()
{
- Id= a.Id,
+ Id = a.Id,
Code = a.Code,
Name = a.Batching_Name,
//TypeId = b.Id,
TypeName = b.Name,
- // UintId = c.Id,
+ // UintId = c.Id,
UintName = c.Name,
}).ToPageList(inputDto.Current, inputDto.PageSize, ref total);
@@ -64,7 +72,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service
{
try
{
-
+
SqlSugarDb.Db.Ado.BeginTran();
//1.物料单位查询
var typeData = await SqlSugarDb.Db.Queryable().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);
}
+ var input = new List();
+
+
+ if (inputDto.StoreIdList != null && inputDto.StoreIdList.Count > 0)
+ {
+ input = await SqlSugarDb.Db.Queryable((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((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();
return true;
@@ -128,7 +194,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service
catch (Exception e)
{
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);
}
-
+
}
///
@@ -166,7 +232,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service
{
try
{
-
+
SqlSugarDb.Db.Ado.BeginTran();
//1.物料单位查询
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/PushDeviceDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/PushDeviceDto.cs
new file mode 100644
index 0000000..60e1f98
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/PushDeviceDto.cs
@@ -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; }
+
+ ///
+ /// 1.商品 2.物料 3.配方 4.工艺
+ ///
+ public int type { get; set; }
+
+ public List 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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/ThirdpartyPushRecordDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/ThirdpartyPushRecordDto.cs
new file mode 100644
index 0000000..46415c2
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Dtos/ThirdpartyPushRecordDto.cs
@@ -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
+ {
+ ///
+ /// 消息Id
+ ///
+ public string MessageId { get; set; }
+
+ public string DeviceId { get; set; }
+
+
+ ///
+ /// 下发是否成功
+ ///
+ public bool IsPush { get; set; }
+
+ ///
+ /// 下发时间
+ ///
+ public DateTime? PushTime { get; set; }
+
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/IThirdpartyPushService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/IThirdpartyPushService.cs
new file mode 100644
index 0000000..63a67ad
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/IThirdpartyPushService.cs
@@ -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 设备 回调级下发数据和记录
+
+ ///
+ /// 下发到设备
+ ///
+ ///
+ ///
+ Task PushDevice(List inputDto);
+
+ ///
+ /// 添加 三方 回调设备记录
+ ///
+ ///
+ ///
+ Task AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto);
+
+ ///
+ /// 修改 第三方订单的回调
+ ///
+ ///
+ ///
+ Task UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto);
+
+ ///
+ /// 更具店铺获取设备
+ ///
+ ///
+ ///
+ Task> GetDeviceByStoreId(List inputDto);
+
+ #endregion
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/ThirdpartyPushService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/ThirdpartyPushService.cs
new file mode 100644
index 0000000..571e80a
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/Services/ThirdpartyPushService.cs
@@ -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 设备 回调级下发数据和记录
+
+ ///
+ /// 添加 三方 回调设备记录
+ ///
+ ///
+ ///
+ public async Task AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto)
+ {
+ var res = await SqlSugarDb.Db.Insertable(inputDto).ExecuteCommandAsync();
+
+ return res > 0;
+
+ }
+
+
+ ///
+ /// 下发到设备
+ ///
+ ///
+ ///
+ public async Task PushDevice(List inputDto)
+ {
+
+ Dictionary dic = new Dictionary();
+ 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>(jsonData);
+ if (data.statusCode != 200) throw Oops.Oh(ErrorCodeEnum.Code10016);
+ if (data.data.data.Count <= 0) throw Oops.Oh(ErrorCodeEnum.Code10016);
+ return true;
+ }
+
+
+ ///
+ /// 修改 第三方订单的回调
+ ///
+ ///
+ ///
+ public async Task UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto)
+ {
+ var data = await SqlSugarDb.Db.Queryable()
+ .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;
+
+ }
+
+ ///
+ /// 更具店铺获取设备
+ ///
+ ///
+ ///
+ public async Task> GetDeviceByStoreId(List inputDto)
+ {
+ var data = await SqlSugarDb.Db.Queryable()
+ .Where(x => inputDto.Contains(x.StopId))
+ .Select(x => x.Id)
+ .ToListAsync();
+ return data;
+ }
+
+
+
+ #endregion
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/ThirdpartyPushServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/ThirdpartyPushServices.cs
new file mode 100644
index 0000000..f919e38
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/ThirdpartyPush/ThirdpartyPushServices.cs
@@ -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 设备 回调级下发数据和记录
+
+ ///
+ /// 添加 三方 回调设备记录
+ ///
+ ///
+ ///
+ public async Task AddThirdpartyPushRecord(BPA_ThirdpartyPushRecord inputDto)
+ {
+ return await _thirdpartyPushService.AddThirdpartyPushRecord(inputDto);
+
+ }
+
+
+ ///
+ /// 修改 第三方订单的回调
+ ///
+ ///
+ ///
+ [HttpPost("/api/hirdpartypush/updatethirdpartypushrecord"), AllowAnonymous]
+ public async Task UpdateThirdpartyPushRecord(ThirdpartyPushRecordDto inputDto)
+ {
+ return await _thirdpartyPushService.UpdateThirdpartyPushRecord(inputDto);
+
+ }
+
+ ///
+ /// 更具店铺获取设备
+ ///
+ ///
+ ///
+ public async Task> GetDeviceByStoreId(List inputDto)
+ {
+ return await _thirdpartyPushService.GetDeviceByStoreId(inputDto);
+ }
+ #endregion
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
index 7c9d430..c73fa73 100644
--- a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
+++ b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
@@ -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.Comm.Model;
using BPA.SAAS.Manage.Core.Base;
+using BPA.SAAS.Manage.Core.System;
using Microsoft.AspNetCore.Components.Forms;
using NPOI.Util;
using System;
@@ -93,5 +95,10 @@ namespace BPA.SAAS.Manage.Application.Device
{
return await _deviceService.GetDeviceTypeList();
}
+
+
+
+
+
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs b/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
index 5ba87ce..73e0a81 100644
--- a/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
@@ -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.Core.Base;
+using BPA.SAAS.Manage.Core.System;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -19,5 +21,6 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
Task DelDeviceInfo(List inputList);
Task AddDeviceTypeAsync(DeviceTypeBaseDto inputDto);
Task> GetDeviceTypeList();
+
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
index 2fd27d4..e078d08 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
@@ -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.Interface;
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.Product;
using BPA.SAAS.Manage.Core.system;
+using BPA.SAAS.Manage.Core.System;
using Dm;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
@@ -229,5 +232,11 @@ namespace BPA.SAAS.Manage.Application.Device.Services
// BPALog.WriteLog($"调用订单服务:{url},调用成功");
return true;
}
+
+
+
+
+
+
}
}
diff --git a/BPA.SAAS.Manage.Comm/Util/HttpHelper.cs b/BPA.SAAS.Manage.Comm/Util/HttpHelper.cs
new file mode 100644
index 0000000..b569faa
--- /dev/null
+++ b/BPA.SAAS.Manage.Comm/Util/HttpHelper.cs
@@ -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();
+
+ ///
+ /// Get 请求
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string HttpGet(string url, string postDataStr, Dictionary 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 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 headers)
+ {
+
+ HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url);
+
+ myReq.Method = "POST";
+ myReq.Timeout = 600 * 60;
+ byte[] byteArray = encoding.GetBytes(postData);
+ myReq.ContentType = ContentType;
+ //对键值对进行遍历
+ foreach (KeyValuePair 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;
+ }
+ }
+}
diff --git a/BPA.SAAS.Manage.Core/CurrentUser.cs b/BPA.SAAS.Manage.Core/CurrentUser.cs
index 0be2e66..6acadb0 100644
--- a/BPA.SAAS.Manage.Core/CurrentUser.cs
+++ b/BPA.SAAS.Manage.Core/CurrentUser.cs
@@ -8,6 +8,9 @@ namespace BPA.SAAS.KitChenManage.Core
{
public static class CurrentUser
{
+
+ public static string MessageId { get; set; }
+
public static string GroupId { get; set; }
public static string key { get; set; }
diff --git a/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs b/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs
index 4adb298..fd99008 100644
--- a/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs
+++ b/BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs
@@ -31,6 +31,7 @@ namespace BPA.SAAS.Manage.Core.Device
/// 所属产品
///
public string ProductId { get; set; }
+
///
/// 产品标签
///
diff --git a/BPA.SAAS.Manage.Core/System/BPA_ThirdpartyPushRecord.cs b/BPA.SAAS.Manage.Core/System/BPA_ThirdpartyPushRecord.cs
new file mode 100644
index 0000000..cf94666
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/System/BPA_ThirdpartyPushRecord.cs
@@ -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
+{
+
+ ///
+ /// 第三方日志 下发设备记录
+ ///
+ [SugarTable("bpa_thirdpartypushrecord")]
+ public class BPA_ThirdpartyPushRecord : IBaseEntity, IGroupId
+ {
+ public string GroupId { get; set; }
+
+ ///
+ /// 消息Id
+ ///
+ public string MessageId { get; set; }
+
+ ///
+ /// 下发是否成功
+ ///
+ public bool IsPush { get; set; }
+
+ public string CallbackUrl { get; set; }
+
+ ///
+ /// 下发时间
+ ///
+ public DateTime? PushTime{ get; set; }
+
+ ///
+ /// 下发设备
+ ///
+ public string PushDevice { get; set; }
+
+ ///
+ /// 下发数据
+ ///
+ public string PushData { get; set; }
+
+ }
+}
diff --git a/BPA.SAAS.Manage.Web.Core/Handlers/RequestAuditFiltercs.cs b/BPA.SAAS.Manage.Web.Core/Handlers/RequestAuditFiltercs.cs
index 7cd7278..5842fcd 100644
--- a/BPA.SAAS.Manage.Web.Core/Handlers/RequestAuditFiltercs.cs
+++ b/BPA.SAAS.Manage.Web.Core/Handlers/RequestAuditFiltercs.cs
@@ -3,6 +3,8 @@ 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.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 Furion;
using Furion.EventBus;
@@ -25,18 +27,21 @@ namespace BPA.SAAS.Manage.Web.Core
public class RequestAuditFiltercs : IAsyncActionFilter
{
private readonly ICheckServices _checkServices;
- public RequestAuditFiltercs(ICheckServices checkServices)
+ private readonly IThirdpartyPushService _thirdpartyPushService;
+
+ public RequestAuditFiltercs( ICheckServices checkServices, IThirdpartyPushService thirdpartyPushService)
{
_checkServices = checkServices;
+ _thirdpartyPushService= thirdpartyPushService;
}
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
-
+ CurrentUser.MessageId=Guid.NewGuid().ToString();
- //============== 这里是执行方法之前获取数据 ====================
- // 获取 HttpContext 和 HttpRequest 对象
+ //============== 这里是执行方法之前获取数据 ====================
+ // 获取 HttpContext 和 HttpRequest 对象
var httpContext = context.HttpContext;
var httpRequest = httpContext.Request;
@@ -60,15 +65,15 @@ namespace BPA.SAAS.Manage.Web.Core
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 proplist = new List();
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
{
+ //记录日志
await SqlSugarDb.Db.Insertable(new BPA_ThirdpartyRequestLog()
{
- Id=Guid.NewGuid().ToString(),
+ Id = CurrentUser.MessageId,
CreateBy = DateTime.Now.ToString(),
GroupId = CurrentUser.GroupId,
RequestUrl = requestUrl,
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
}).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();
+ // if (!string.IsNullOrEmpty(deviceIdList))
+ // {
+ // list = JsonConvert.DeserializeObject>(deviceIdList);
+ // }
+ // if ( !string.IsNullOrEmpty(storeIdList))
+ // {
+ // list = await _thirdpartyPushService.GetDeviceByStoreId(JsonConvert.DeserializeObject>(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)
{
}
}
-
+
}
}
}