@@ -10,7 +10,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto | |||
{ | |||
public int statusCode { get; set; } | |||
public ResultSAASManageDataDto<T> data { get; set; } | |||
public T data { get; set; } | |||
public string succeeded { get; set; } | |||
@@ -19,6 +19,8 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto | |||
public string extras { get; set; } | |||
public int timestamp { get; set; } | |||
} | |||
public class ResultSAASManageDataDto<T> | |||
@@ -106,7 +106,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Enum | |||
/// <summary> | |||
/// 下发错误 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("下发错误")] | |||
[ErrorCodeItemMetadata("操作成功,下发错误")] | |||
Code10016, | |||
} | |||
} |
@@ -134,16 +134,21 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||
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 | |||
input = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo, BPA_Product,BPA_ProductVesion>((a, b,c) => new JoinQueryInfos( | |||
JoinType.Left, a.ProductId == b.Id, | |||
JoinType.Left,a.ProductVersionId==c.Id | |||
)) | |||
.Where((a, b, c) => inputDto.StoreIdList.Contains(a.StopId)) | |||
.Select((a, b,c) => new PushDeviceDto | |||
{ | |||
deviceAutoKey = a.AutoKey, | |||
deviceId = a.Id, | |||
deviceName = a.DeviceName, | |||
messageId = "", | |||
productName = "" | |||
messageId = CurrentUser.MessageId, | |||
productKey = b.Key, | |||
productName = b.Name, | |||
productVersion = c.Vesion, | |||
type = 2 | |||
}) | |||
.ToListAsync(); | |||
@@ -152,19 +157,20 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||
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 | |||
input = await SqlSugarDb.Db.Queryable<BPA_DeviceInfo, BPA_Product, BPA_ProductVesion>((a, b,c) => new JoinQueryInfos( | |||
JoinType.Left, a.ProductId == b.Id, | |||
JoinType.Left,a.ProductVersionId==c.Id)) | |||
.Where((a, b,c) => inputDto.DeviceIdList.Contains(a.Id)) | |||
.Select((a, b,c) => new PushDeviceDto | |||
{ | |||
deviceAutoKey = a.AutoKey, | |||
deviceId = a.Id, | |||
deviceName = a.DeviceName, | |||
messageId = "", | |||
productKey = "", | |||
messageId = CurrentUser.MessageId, | |||
productKey = b.Key, | |||
productName = b.Name, | |||
productVersion = a.ProductVersionId, | |||
type = 2 | |||
productVersion =c.Vesion, | |||
type = 2, | |||
}) | |||
.ToListAsync(); | |||
} | |||
@@ -180,15 +186,35 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service | |||
IsPush = false, | |||
MessageId = CurrentUser.MessageId, | |||
PushDevice =item.deviceId, | |||
PushData = JsonConvert.SerializeObject(item), | |||
PushData = materialData.Id, | |||
Status=1, | |||
Type = 2, | |||
}); | |||
item.data = JsonConvert.SerializeObject(new List<PushDataBatchingDto>() | |||
{ | |||
new() | |||
{ | |||
Aittribute= materialData.Aittribute, | |||
AutoKey= materialData.AutoKey, | |||
Code=materialData.Code, | |||
ForeignKeyRe= materialData.ForeignKeyRe, | |||
Id=materialData.Id, | |||
Name= materialData.Batching_Name, | |||
netrecovery= materialData.netrecovery, | |||
outstockUint= materialData.outstockUint, | |||
Price= materialData.Price, | |||
proportion= materialData.proportion, | |||
Specs= materialData.Specs, | |||
StockUint= materialData.StockUint, | |||
StockUintName= materialData.StockUint, | |||
TypeID= materialData.TypeID, | |||
} | |||
}); | |||
} | |||
SqlSugarDb.Db.Ado.CommitTran(); | |||
//5.发送mq | |||
await _thirdpartyPushService.PushDevice(input); | |||
SqlSugarDb.Db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception e) | |||
@@ -0,0 +1,71 @@ | |||
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 PushDataBatchingDto | |||
{ | |||
public string Id { get; set; } | |||
/// <summary> | |||
/// 原料编码 | |||
/// </summary> | |||
public string Code { get; set; } | |||
/// <summary> | |||
/// 商品属性 (0成品,1半成品,2,易耗品) | |||
/// </summary> | |||
public int Aittribute { get; set; } = 0; | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 配料类型 | |||
/// </summary> | |||
public string TypeName { get; set; } | |||
/// <summary> | |||
/// 原料类型 | |||
/// </summary> | |||
public string TypeID { get; set; } | |||
/// <summary> | |||
/// 库存单位 | |||
/// </summary> | |||
public string StockUintName { get; set; } | |||
public string StockUint { get; set; } | |||
/// <summary> | |||
/// 规格属性 | |||
/// </summary> | |||
public string Specs { get; set; } | |||
/// <summary> | |||
/// 成本价 | |||
/// </summary> | |||
public decimal Price { get; set; } | |||
/// <summary> | |||
/// 净料率 | |||
/// </summary> | |||
public decimal netrecovery { get; set; } | |||
/// <summary> | |||
/// 出库单位 | |||
/// </summary> | |||
public string outstockUint { get; set; } | |||
/// <summary> | |||
/// 换算比例 | |||
/// </summary> | |||
public decimal proportion { get; set; } | |||
public int AutoKey { get; set; } | |||
public string ForeignKeyRe { get; set; } | |||
public string CreateAt { get; set; } | |||
} | |||
} |
@@ -49,4 +49,5 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.D | |||
public string isDefault { get; set; } | |||
} | |||
} |
@@ -44,12 +44,13 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.S | |||
{ | |||
Dictionary<string, string> dic = new Dictionary<string, string>(); | |||
dic.Add("groupId", CurrentUser.GroupId); | |||
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); | |||
var data = JsonConvert.DeserializeObject<ResultSAASManageDto<bool>>(jsonData); | |||
if (data.statusCode != 200) throw Oops.Oh(ErrorCodeEnum.Code10016); | |||
if (data.data.data.Count <= 0) throw Oops.Oh(ErrorCodeEnum.Code10016); | |||
if (!data.data) throw Oops.Oh(ErrorCodeEnum.Code10016); | |||
return true; | |||
} | |||
@@ -70,7 +71,22 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.S | |||
} | |||
data.IsPush = inputDto.IsPush; | |||
data.CreateAt = DateTime.Now; | |||
data.Status = 0; | |||
var res = await SqlSugarDb.Db.Updateable(data).ExecuteCommandAsync(); | |||
//回调 | |||
var urlstr = ""; | |||
if (data.Type==2) | |||
{ | |||
urlstr = $@"?materialId={data.PushData}&Device={inputDto.DeviceId}"; | |||
Dictionary<string, string> dic = new Dictionary<string, string>(); | |||
var inputData =""; | |||
HttpHelper.PostData(urlstr, inputData, Encoding.UTF8, "application/json", dic); | |||
} | |||
return res > 0; | |||
} | |||
@@ -44,5 +44,9 @@ namespace BPA.SAAS.Manage.Core.System | |||
/// </summary> | |||
public string PushData { get; set; } | |||
public int Status { get; set; } | |||
public int Type { get; set; } | |||
} | |||
} |
@@ -14,7 +14,7 @@ | |||
"ASPNETCORE_ENVIRONMENT": "Development" | |||
}, | |||
"dotnetRunMessages": true, | |||
"applicationUrl": "http://localhost:5006" | |||
"applicationUrl": "http://192.168.1.17:5006" | |||
}, | |||
"Docker": { | |||
"commandName": "Docker", | |||
@@ -8,7 +8,7 @@ | |||
} | |||
}, | |||
"AllowedHosts": "*", | |||
"baseurl": "http://localhost:5008/", | |||
"baseurl": "http://192.168.1.19:5007/", | |||
"ConnectionConfigs": [ | |||
{ | |||
"ConnectionString": "server=10.2.1.21;Database=bpa_kitchen_kitchenbasemanage;Uid=root;Pwd=cygadmin;Allow Zero Datetime=True;Convert Zero Datetime=True;", | |||