|
|
@@ -12,7 +12,7 @@ using Microsoft.AspNetCore.Components.Forms; |
|
|
|
|
|
|
|
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services |
|
|
|
{ |
|
|
|
public class MaterialService : UserAnalysis, IMaterialServices, ITransient |
|
|
|
public class MaterialService : IMaterialServices, ITransient |
|
|
|
{ |
|
|
|
private readonly ICheckServices _checkServices; |
|
|
|
public MaterialService(ICheckServices checkServices) |
|
|
@@ -60,15 +60,14 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
/// </summary> |
|
|
|
/// <param name="InputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> AddMaterial(MaterialCreateDto inputDto) |
|
|
|
public async Task<bool> AddMaterial(BaseRequestDto<MaterialCreateDto> inputDto) |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
SqlSugarDb.Db.Ado.BeginTran(); |
|
|
|
//1.物料单位查询 |
|
|
|
var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.TypeName); |
|
|
|
var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.DataInfo.TypeName); |
|
|
|
if (typeData == null) |
|
|
|
{ |
|
|
|
|
|
|
@@ -76,26 +75,26 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
{ |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
Name = string.IsNullOrEmpty(inputDto.TypeName) ? "默认分类" : inputDto.TypeName, |
|
|
|
Name = string.IsNullOrEmpty(inputDto.DataInfo.TypeName) ? "默认分类" : inputDto.DataInfo.TypeName, |
|
|
|
}; |
|
|
|
SqlSugarDb.Db.Insertable(typeData).ExecuteCommand(); |
|
|
|
} |
|
|
|
|
|
|
|
//2.单位查询 |
|
|
|
var uintData = await SqlSugarDb.Db.Queryable<BPA_BatchingUint>() |
|
|
|
.FirstAsync(x => x.Name == inputDto.UintName); |
|
|
|
.FirstAsync(x => x.Name == inputDto.DataInfo.UintName); |
|
|
|
if (uintData == null) |
|
|
|
{ |
|
|
|
uintData = new BPA_BatchingUint() |
|
|
|
{ |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
Name = string.IsNullOrEmpty(inputDto.UintName) ? "默认分类" : inputDto.UintName, |
|
|
|
Name = string.IsNullOrEmpty(inputDto.DataInfo.UintName) ? "默认分类" : inputDto.DataInfo.UintName, |
|
|
|
}; |
|
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
|
} |
|
|
|
//3.物料查询 |
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Batching_Name == inputDto.Name); |
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Batching_Name == inputDto.DataInfo.Name); |
|
|
|
if (materialData == null) |
|
|
|
{ |
|
|
|
materialData = new BPA_Batching() |
|
|
@@ -103,9 +102,9 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Aittribute = 0, |
|
|
|
Batching_Name = inputDto.Name, |
|
|
|
Batching_Name = inputDto.DataInfo.Name, |
|
|
|
Batching_Type = typeData.Id, |
|
|
|
Code = inputDto.Code, |
|
|
|
Code = inputDto.DataInfo.Code, |
|
|
|
Price = 0, |
|
|
|
Specs = "", |
|
|
|
outstockUint = uintData.Id, |
|
|
@@ -138,11 +137,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
/// </summary> |
|
|
|
/// <param name="MaterialId"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> DelMaterial(DelMaterialDto inputDto) |
|
|
|
public async Task<bool> DelMaterial(BaseRequestDto<DelMaterialDto> inputDto) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Id == inputDto.MaterialId); |
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Id == inputDto.DataInfo.MaterialId); |
|
|
|
if (materialData == null) |
|
|
|
{ |
|
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
|
@@ -156,7 +155,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
/// </summary> |
|
|
|
/// <param name="InputDto"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public async Task<bool> UpdateMateria(MaterialUpdateDto inputDto) |
|
|
|
public async Task<bool> UpdateMateria(BaseRequestDto<MaterialUpdateDto> inputDto) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@@ -164,7 +163,7 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
|
|
|
|
SqlSugarDb.Db.Ado.BeginTran(); |
|
|
|
//1.物料单位查询 |
|
|
|
var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.TypeName); |
|
|
|
var typeData = await SqlSugarDb.Db.Queryable<BPA_BatchingType>().FirstAsync(x => x.Name == inputDto.DataInfo.TypeName); |
|
|
|
if (typeData == null) |
|
|
|
{ |
|
|
|
|
|
|
@@ -172,26 +171,26 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
{ |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
Name = string.IsNullOrEmpty(inputDto.TypeName) ? "默认分类" : inputDto.TypeName, |
|
|
|
Name = string.IsNullOrEmpty(inputDto.DataInfo.TypeName) ? "默认分类" : inputDto.DataInfo.TypeName, |
|
|
|
}; |
|
|
|
SqlSugarDb.Db.Insertable(typeData).ExecuteCommand(); |
|
|
|
} |
|
|
|
|
|
|
|
//2.单位查询 |
|
|
|
var uintData = await SqlSugarDb.Db.Queryable<BPA_BatchingUint>() |
|
|
|
.FirstAsync(x => x.Name == inputDto.UintName); |
|
|
|
.FirstAsync(x => x.Name == inputDto.DataInfo.UintName); |
|
|
|
if (uintData == null) |
|
|
|
{ |
|
|
|
uintData = new BPA_BatchingUint() |
|
|
|
{ |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
Name = string.IsNullOrEmpty(inputDto.UintName) ? "默认分类" : inputDto.UintName, |
|
|
|
Name = string.IsNullOrEmpty(inputDto.DataInfo.UintName) ? "默认分类" : inputDto.DataInfo.UintName, |
|
|
|
}; |
|
|
|
SqlSugarDb.Db.Insertable(uintData).ExecuteCommand(); |
|
|
|
} |
|
|
|
//3.物料查询 |
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Batching_Name == inputDto.Name); |
|
|
|
var materialData = await SqlSugarDb.Db.Queryable<BPA_Batching>().FirstAsync(x => x.Code == inputDto.DataInfo.Code); |
|
|
|
if (materialData == null) |
|
|
|
{ |
|
|
|
throw Oops.Oh(ErrorCodeEnum.Code1003); |
|
|
@@ -205,9 +204,9 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Service |
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
GroupId = CurrentUser.GroupId, |
|
|
|
Aittribute = 0, |
|
|
|
Batching_Name = inputDto.Name, |
|
|
|
Batching_Name = inputDto.DataInfo.Name, |
|
|
|
Batching_Type = typeData.Id, |
|
|
|
Code = inputDto.Code, |
|
|
|
Code = inputDto.DataInfo.Code, |
|
|
|
Price = 0, |
|
|
|
Specs = "", |
|
|
|
outstockUint = uintData.Id, |
|
|
|