|
|
@@ -68,7 +68,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
/// </summary> |
|
|
|
/// <param name="InputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> AddMaterial(BaseRequestDto<MaterialCreateDto> inputDto) |
|
|
|
public async Task<string> AddMaterial(BaseRequestDto<MaterialCreateDto> inputDto) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@@ -129,93 +129,103 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
throw Oops.Oh(ErrorCodeEnum.Code1002); |
|
|
|
} |
|
|
|
|
|
|
|
var input = new List<PushDeviceDto>(); |
|
|
|
#region 下发数据到设备 |
|
|
|
|
|
|
|
|
|
|
|
if (inputDto.StoreIdList != null && inputDto.StoreIdList.Count > 0) |
|
|
|
if (inputDto.IsPush) |
|
|
|
{ |
|
|
|
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 = CurrentUser.MessageId, |
|
|
|
productKey = b.Key, |
|
|
|
productName = b.Name, |
|
|
|
productVersion = c.Vesion, |
|
|
|
type = 2 |
|
|
|
var input = new List<PushDeviceDto>(); |
|
|
|
|
|
|
|
}) |
|
|
|
.ToListAsync(); |
|
|
|
if (inputDto.StoreIdList != null && inputDto.StoreIdList.Count > 0) |
|
|
|
{ |
|
|
|
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 = CurrentUser.MessageId, |
|
|
|
productKey = b.Key, |
|
|
|
productName = b.Name, |
|
|
|
productVersion = c.Vesion, |
|
|
|
type = 2 |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
if (inputDto.DeviceIdList != null && inputDto.DeviceIdList.Count > 0) |
|
|
|
{ |
|
|
|
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 = CurrentUser.MessageId, |
|
|
|
productKey = b.Key, |
|
|
|
productName = b.Name, |
|
|
|
productVersion =c.Vesion, |
|
|
|
type = 2, |
|
|
|
}) |
|
|
|
.ToListAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//4.添加记录 |
|
|
|
foreach (var item in input) |
|
|
|
{ |
|
|
|
await _thirdpartyPushService.AddThirdpartyPushRecord(new Core.System.BPA_ThirdpartyPushRecord() |
|
|
|
if (inputDto.DeviceIdList != null && inputDto.DeviceIdList.Count > 0) |
|
|
|
{ |
|
|
|
CallbackUrl = inputDto.CallbackUrl, |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
IsPush = false, |
|
|
|
MessageId = CurrentUser.MessageId, |
|
|
|
PushDevice =item.deviceId, |
|
|
|
PushData = materialData.Id, |
|
|
|
Status=1, |
|
|
|
Type = 2, |
|
|
|
}); |
|
|
|
item.data = JsonConvert.SerializeObject(new List<PushDataBatchingDto>() |
|
|
|
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 = CurrentUser.MessageId, |
|
|
|
productKey = b.Key, |
|
|
|
productName = b.Name, |
|
|
|
productVersion = c.Vesion, |
|
|
|
type = 2, |
|
|
|
}) |
|
|
|
.ToListAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
//4.添加记录 |
|
|
|
foreach (var item in input) |
|
|
|
{ |
|
|
|
new() |
|
|
|
await _thirdpartyPushService.AddThirdpartyPushRecord(new Core.System.BPA_ThirdpartyPushRecord() |
|
|
|
{ |
|
|
|
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, |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
CallbackUrl = inputDto.CallbackUrl, |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
IsPush = false, |
|
|
|
MessageId = CurrentUser.MessageId, |
|
|
|
PushDevice = item.deviceId, |
|
|
|
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(); |
|
|
|
//5.发送mq |
|
|
|
await _thirdpartyPushService.PushDevice(input); |
|
|
|
return true; |
|
|
|
else |
|
|
|
{ |
|
|
|
SqlSugarDb.Db.Ado.CommitTran(); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
return materialData.Id; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|