|
@@ -104,7 +104,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
} |
|
|
} |
|
|
//3.物料查询 |
|
|
//3.物料查询 |
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Batching_Name == inputDto.DataInfo.Name); |
|
|
|
|
|
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Batching_Name == inputDto.DataInfo.Name || x.Code == inputDto.DataInfo.Code); |
|
|
if (materialData == null) |
|
|
if (materialData == null) |
|
|
{ |
|
|
{ |
|
|
materialData = new BPA_Batching() |
|
|
materialData = new BPA_Batching() |
|
@@ -157,7 +157,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
await _thirdpartyPushService.AddPushRecordAndPushDevice<MaterialCreateDto>(inputDto, 2, materialData.Id, |
|
|
await _thirdpartyPushService.AddPushRecordAndPushDevice<MaterialCreateDto>(inputDto, 2, materialData.Id, |
|
|
JsonConvert.SerializeObject(data)); |
|
|
JsonConvert.SerializeObject(data)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
@@ -175,11 +175,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <param name="MaterialId"></param> |
|
|
/// <param name="MaterialId"></param> |
|
|
/// <returns></returns> |
|
|
/// <returns></returns> |
|
|
public async Task<bool> DelMaterial(BaseRequestDto<DelMaterialDto> inputDto) |
|
|
|
|
|
|
|
|
public async Task<bool> DelMaterial(DelMaterialDto inputDto) |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Id == inputDto.DataInfo.MaterialId); |
|
|
|
|
|
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Id == inputDto.MaterialId); |
|
|
if (materialData == null) |
|
|
if (materialData == null) |
|
|
{ |
|
|
{ |
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
@@ -204,8 +204,6 @@ 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); |
|
@@ -235,13 +233,21 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
} |
|
|
} |
|
|
//3.物料查询 |
|
|
//3.物料查询 |
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Code == inputDto.DataInfo.Code); |
|
|
|
|
|
|
|
|
var material = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Code == inputDto.DataInfo.Code || x.Batching_Name == inputDto.DataInfo.Name); |
|
|
|
|
|
|
|
|
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Id == inputDto.DataInfo.Id); |
|
|
|
|
|
|
|
|
if (materialData == null) |
|
|
if (materialData == null) |
|
|
{ |
|
|
{ |
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (material != null && material.Id == materialData.Id) |
|
|
|
|
|
{ |
|
|
|
|
|
throw Oops.Oh(ErrorCodeEnum.Code10017); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
materialData = new BPA_Batching() |
|
|
materialData = new BPA_Batching() |
|
|
{ |
|
|
{ |
|
|
Id = Guid.NewGuid().ToString(), |
|
|
Id = Guid.NewGuid().ToString(), |
|
@@ -260,9 +266,34 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
}; |
|
|
}; |
|
|
SqlSugarDb.Db.Updateable(materialData).ExecuteCommand(); |
|
|
SqlSugarDb.Db.Updateable(materialData).ExecuteCommand(); |
|
|
} |
|
|
} |
|
|
|
|
|
SqlSugarDb.Db.Ado.CommitTran(); |
|
|
|
|
|
#region 下发数据到设备 |
|
|
|
|
|
|
|
|
|
|
|
var data = new PushDataBatchingDto() |
|
|
|
|
|
{ |
|
|
|
|
|
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, |
|
|
|
|
|
}; |
|
|
|
|
|
if (inputDto.IsPush) |
|
|
|
|
|
{ |
|
|
|
|
|
await _thirdpartyPushService.AddPushRecordAndPushDevice<MaterialUpdateDto>(inputDto, 2, materialData.Id, |
|
|
|
|
|
JsonConvert.SerializeObject(data)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
SqlSugarDb.Db.Ado.CommitTran(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
catch (Exception e) |
|
|
catch (Exception e) |
|
|