|
@ -11,6 +11,7 @@ using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Validation; |
|
|
using Volo.Abp.Validation; |
|
|
using Win_in.Sfs.Scp.v1.Domain; |
|
|
using Win_in.Sfs.Scp.v1.Domain; |
|
|
|
|
|
using Volo.Abp.TenantManagement; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
{ |
|
|
{ |
|
@ -20,22 +21,22 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
[Authorize] |
|
|
[Authorize] |
|
|
[Route(RouteConsts.Receipt)] |
|
|
[Route(RouteConsts.Receipt)] |
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)] |
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)] |
|
|
public class ReceiptAppService : ReadOnlyAppService<Receipt, ReceiptDTO, Guid,RequestDTO>, IReceiptAppService |
|
|
public class ReceiptAppService : ReadOnlyAppService<Receipt, ReceiptDTO, Guid, RequestDTO>, IReceiptAppService |
|
|
{ |
|
|
{ |
|
|
private readonly IReceiptRepository _receiptRepository; |
|
|
private readonly IReceiptRepository _receiptRepository; |
|
|
private readonly ITbReceiptRepository _tbReceiptRepository; |
|
|
private readonly ITbReceiptRepository _tbReceiptRepository; |
|
|
private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository; |
|
|
private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository; |
|
|
private readonly ITaVenderRepository _taVenderRepository; |
|
|
private readonly ITaVenderRepository _taVenderRepository; |
|
|
private readonly ITenantStore _tenantStore; |
|
|
private readonly ITenantStore _tenantStore; |
|
|
private readonly string _validSites = Validator.VALID_SITES; |
|
|
private readonly ITenantRepository _tenantRepository; |
|
|
|
|
|
|
|
|
public ReceiptAppService( |
|
|
public ReceiptAppService( |
|
|
IReceiptRepository repository |
|
|
IReceiptRepository repository |
|
|
,ITbReceiptRepository tbReceiptRepository |
|
|
, ITbReceiptRepository tbReceiptRepository |
|
|
,ITbReceiptDetailRepository tbReceiptDetailRepository |
|
|
, ITbReceiptDetailRepository tbReceiptDetailRepository |
|
|
,ITaVenderRepository taVenderRepository |
|
|
, ITaVenderRepository taVenderRepository |
|
|
, ITenantStore tenantStore |
|
|
, ITenantStore tenantStore |
|
|
, IConfiguration configuration |
|
|
, ITenantRepository tenantRepository |
|
|
) : base(repository) |
|
|
) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_receiptRepository = repository; |
|
|
_receiptRepository = repository; |
|
@ -43,8 +44,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
_tbReceiptDetailRepository = tbReceiptDetailRepository; |
|
|
_tbReceiptDetailRepository = tbReceiptDetailRepository; |
|
|
_taVenderRepository = taVenderRepository; |
|
|
_taVenderRepository = taVenderRepository; |
|
|
_tenantStore = tenantStore; |
|
|
_tenantStore = tenantStore; |
|
|
_validSites = configuration["ValidSites"]; |
|
|
_tenantRepository = tenantRepository; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -88,12 +88,16 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
Validator.CheckSite(_validSites,entity.Site); |
|
|
Validator.CheckSite(_tenantRepository, entity.Site); |
|
|
Validator.CheckSite(_validSites,entity.Company); |
|
|
Validator.CheckSite(_tenantRepository, entity.Company); |
|
|
Validator.CheckSupplierCode(_taVenderRepository,entity.Site, entity.SupplierCode); |
|
|
var tenant = await _tenantStore.FindAsync(entity.Site); |
|
|
await UpsertTbReceiptAndTbReceiptDetailAsync(entity); |
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name)) |
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
{ |
|
|
|
|
|
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); |
|
|
|
|
|
|
|
|
|
|
|
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id); |
|
|
|
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -119,21 +123,18 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity) |
|
|
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId) |
|
|
{ |
|
|
{ |
|
|
//使用AutoMapper执行类型转换
|
|
|
//使用AutoMapper执行类型转换
|
|
|
var tbReceipt = ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity); |
|
|
var tbReceipt = ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity); |
|
|
var tbReceiveDetail = ObjectMapper.Map<Receipt, TB_RECEIVE_DETAIL_QAD>(entity); |
|
|
var tbReceiveDetail = ObjectMapper.Map<Receipt, TB_RECEIVE_DETAIL_QAD>(entity); |
|
|
|
|
|
|
|
|
var tenant = await _tenantStore.FindAsync(tbReceipt.Site); |
|
|
tbReceipt.TenantId = tenantId; |
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name)) |
|
|
|
|
|
{ |
|
|
|
|
|
//根据传入数据新增或修改SCP数据
|
|
|
//根据传入数据新增或修改SCP数据
|
|
|
await _tbReceiptRepository.UpsertAsync(tbReceipt); |
|
|
await _tbReceiptRepository.UpsertAsync(tbReceipt); |
|
|
|
|
|
tbReceiveDetail.TenantId = tenantId; |
|
|
//根据传入数据新增或修改SCP数据
|
|
|
//根据传入数据新增或修改SCP数据
|
|
|
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); |
|
|
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} |