Browse Source

[fix]忽略多租户过滤

master
贾荣国 2 years ago
parent
commit
3e1ffddd0e
  1. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs
  2. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs
  3. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  4. 7
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/ScpV1AutoMapperProfile.cs
  5. 7
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs
  6. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs
  7. 3
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TaPartRepository.cs
  8. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TaVenderRepository.cs

8
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs

@ -16,6 +16,7 @@ using Volo.Abp.Uow;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Volo.Abp.Clients; using Volo.Abp.Clients;
using Volo.Abp.Data;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration; using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
@ -36,18 +37,21 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly ITenantRepository _tenantRepository; private readonly ITenantRepository _tenantRepository;
private readonly IDataFilter _dataFilter;
public PartAppService( public PartAppService(
IPartRepository repository IPartRepository repository
, ITaPartRepository taPartRepository , ITaPartRepository taPartRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, ITenantRepository tenantRepository , ITenantRepository tenantRepository
, IDataFilter dataFilter
) : base(repository) ) : base(repository)
{ {
_partRepository = repository; _partRepository = repository;
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_tenantRepository = tenantRepository; _tenantRepository = tenantRepository;
_dataFilter = dataFilter;
} }
/// <summary> /// <summary>
@ -96,10 +100,14 @@ namespace Win_in.Sfs.Scp.WebApi
var tenant = await _tenantStore.FindAsync(entity.Site); var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{ {
using (_dataFilter.Disable<IMultiTenant>())
{
await UpsertTaPartAsync(entity, tenant.Id); await UpsertTaPartAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();

8
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs

@ -12,6 +12,7 @@ using Volo.Abp.TenantManagement;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
using System.Security.Policy; using System.Security.Policy;
using Volo.Abp.Data;
namespace Win_in.Sfs.Scp.WebApi namespace Win_in.Sfs.Scp.WebApi
{ {
@ -29,6 +30,7 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly ITenantRepository _tenantRepository; private readonly ITenantRepository _tenantRepository;
private readonly IDataFilter _dataFilter;
public PurchaseOrderAppService( public PurchaseOrderAppService(
IPurchaseOrderRepository repository IPurchaseOrderRepository repository
@ -37,6 +39,7 @@ namespace Win_in.Sfs.Scp.WebApi
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, ITenantRepository tenantRepository , ITenantRepository tenantRepository
, IDataFilter dataFilter
) : base(repository) ) : base(repository)
{ {
_purchaseOrderRepository = repository; _purchaseOrderRepository = repository;
@ -45,6 +48,7 @@ namespace Win_in.Sfs.Scp.WebApi
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_tenantRepository = tenantRepository; _tenantRepository = tenantRepository;
_dataFilter = dataFilter;
} }
@ -104,6 +108,9 @@ namespace Win_in.Sfs.Scp.WebApi
var tenant = await _tenantStore.FindAsync(entity.Site); var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{ {
using (_dataFilter.Disable<IMultiTenant>())
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode);
@ -111,6 +118,7 @@ namespace Win_in.Sfs.Scp.WebApi
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();

8
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Data;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -29,6 +30,7 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly ITenantRepository _tenantRepository; private readonly ITenantRepository _tenantRepository;
private readonly IDataFilter _dataFilter;
public ReceiptAppService( public ReceiptAppService(
IReceiptRepository repository IReceiptRepository repository
@ -37,6 +39,7 @@ namespace Win_in.Sfs.Scp.WebApi
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, ITenantRepository tenantRepository , ITenantRepository tenantRepository
, IDataFilter dataFilter
) : base(repository) ) : base(repository)
{ {
_receiptRepository = repository; _receiptRepository = repository;
@ -45,6 +48,7 @@ namespace Win_in.Sfs.Scp.WebApi
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_tenantRepository = tenantRepository; _tenantRepository = tenantRepository;
_dataFilter = dataFilter;
} }
@ -95,12 +99,16 @@ namespace Win_in.Sfs.Scp.WebApi
var tenant = await _tenantStore.FindAsync(entity.Site); var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{ {
using (_dataFilter.Disable<IMultiTenant>())
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id); await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();

7
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/ScpV1AutoMapperProfile.cs

@ -31,7 +31,7 @@ namespace Win_in.Sfs.Scp.WebApi
.ForMember(p => p.Site, p => p.MapFrom(q => q.Site)) .ForMember(p => p.Site, p => p.MapFrom(q => q.Site))
.ForMember(p => p.PartCode, p => p.MapFrom(q => q.Code)) .ForMember(p => p.PartCode, p => p.MapFrom(q => q.Code))
.ForMember(p => p.ErpPartCode, p => p.MapFrom(q => q.Code)) .ForMember(p => p.ErpPartCode, p => p.MapFrom(q => q.Code))
.ForMember(p => p.PartDesc1, p => p.MapFrom(q =>string.IsNullOrEmpty(q.Desc2)?"":q.Desc2)) // .ForMember(p => p.PartDesc1, p => p.MapFrom(q => ""))//中文描述不要覆盖
.ForMember(p => p.PartDesc2, p => p.MapFrom(q => string.IsNullOrEmpty(q.Desc1) ? "" : q.Desc1)) .ForMember(p => p.PartDesc2, p => p.MapFrom(q => string.IsNullOrEmpty(q.Desc1) ? "" : q.Desc1))
.ForMember(p => p.ProjectId, p => p.MapFrom(q => q.ProductLine)) .ForMember(p => p.ProjectId, p => p.MapFrom(q => q.ProductLine))
.ForMember(p => p.Unit, p => p.MapFrom(q => q.Uom)) .ForMember(p => p.Unit, p => p.MapFrom(q => q.Uom))
@ -55,16 +55,15 @@ namespace Win_in.Sfs.Scp.WebApi
{ {
CreateMap<Supplier, TA_VENDER>() CreateMap<Supplier, TA_VENDER>()
.Ignore(p => p.Id) .Ignore(p => p.Id)
.ForMember(p => p.Site, p => p.MapFrom(q => q.Company))//TODO 接口没有传入Site .ForMember(p => p.Site, p => p.MapFrom(q => q.Company))//接口没有传入Site
.ForMember(p => p.VendId, p => p.MapFrom(q => q.Code)) .ForMember(p => p.VendId, p => p.MapFrom(q => q.Code))
.ForMember(p => p.VendName, p => p.MapFrom(q => q.Desc)) .ForMember(p => p.ZipCode, p => p.MapFrom(q => q.Desc)) //英文描述放到ZipCode中
.ForMember(p => p.VendAbbCode, p => p.MapFrom(q => "0"))//未使用 .ForMember(p => p.VendAbbCode, p => p.MapFrom(q => "0"))//未使用
.ForMember(p => p.VendType, p => p.MapFrom(q => ""))//默认值未空 .ForMember(p => p.VendType, p => p.MapFrom(q => ""))//默认值未空
.ForMember(p => p.Country, p => p.MapFrom(q => q.Country)) .ForMember(p => p.Country, p => p.MapFrom(q => q.Country))
.ForMember(p => p.City, p => p.MapFrom(q => q.City)) .ForMember(p => p.City, p => p.MapFrom(q => q.City))
.ForMember(p => p.Currency, p => p.MapFrom(q => q.Currency)) .ForMember(p => p.Currency, p => p.MapFrom(q => q.Currency))
.ForMember(p => p.Address, p => p.MapFrom(q => q.Address)) .ForMember(p => p.Address, p => p.MapFrom(q => q.Address))
.ForMember(p => p.ZipCode, p => p.MapFrom(q => q.PostId))
.ForMember(p => p.Contacter, p => p.MapFrom(q => q.ContactName)) .ForMember(p => p.Contacter, p => p.MapFrom(q => q.ContactName))
.ForMember(p => p.Phone, p => p.MapFrom(q => q.Phone)) .ForMember(p => p.Phone, p => p.MapFrom(q => q.Phone))
.ForMember(p => p.Fax, p => p.MapFrom(q => q.Fax)) .ForMember(p => p.Fax, p => p.MapFrom(q => q.Fax))

7
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs

@ -13,6 +13,7 @@ using Volo.Abp.TenantManagement;
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.Data;
namespace Win_in.Sfs.Scp.WebApi namespace Win_in.Sfs.Scp.WebApi
@ -29,18 +30,21 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly ITenantRepository _tenantRepository; private readonly ITenantRepository _tenantRepository;
private readonly IDataFilter _dataFilter;
public SuppliersAppService( public SuppliersAppService(
ISupplierRepository repository ISupplierRepository repository
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, ITenantRepository tenantRepository , ITenantRepository tenantRepository
, IDataFilter dataFilter
) : base(repository) ) : base(repository)
{ {
_supplierRepository = repository; _supplierRepository = repository;
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_tenantRepository = tenantRepository; _tenantRepository = tenantRepository;
_dataFilter = dataFilter;
} }
@ -88,11 +92,14 @@ namespace Win_in.Sfs.Scp.WebApi
Validator.CheckSite(_tenantRepository, entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
var tenant = await _tenantStore.FindAsync(entity.Company); var tenant = await _tenantStore.FindAsync(entity.Company);
using (CurrentTenant.Change(tenant.Id, tenant.Name)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
using (_dataFilter.Disable<IMultiTenant>())
{ {
await UpsertTaVenderAsync(entity, tenant.Id); await UpsertTaVenderAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();

8
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs

@ -8,6 +8,7 @@ using FluentValidation;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Data;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -31,6 +32,7 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly ITenantRepository _tenantRepository; private readonly ITenantRepository _tenantRepository;
private readonly IDataFilter _dataFilter;
public UnplannedReceiptAppService( public UnplannedReceiptAppService(
IUnplannedReceiptRepository repository IUnplannedReceiptRepository repository
@ -39,6 +41,7 @@ namespace Win_in.Sfs.Scp.WebApi
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, ITenantRepository tenantRepository , ITenantRepository tenantRepository
, IDataFilter dataFilter
) : base(repository) ) : base(repository)
{ {
_unplannedReceiptRepository = repository; _unplannedReceiptRepository = repository;
@ -47,6 +50,7 @@ namespace Win_in.Sfs.Scp.WebApi
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_tenantRepository = tenantRepository; _tenantRepository = tenantRepository;
_dataFilter = dataFilter;
} }
@ -97,12 +101,16 @@ namespace Win_in.Sfs.Scp.WebApi
var tenant = await _tenantStore.FindAsync(entity.Site); var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{ {
using (_dataFilter.Disable<IMultiTenant>())
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.Address); Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.Address);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id); await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();

3
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TaPartRepository.cs

@ -28,13 +28,14 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{ {
//使用直接赋值 //使用直接赋值
current.PartDesc1 = taPart.PartDesc1; // current.PartDesc1 = taPart.PartDesc1;//中文描述不要覆盖
current.PartDesc2 = taPart.PartDesc2; current.PartDesc2 = taPart.PartDesc2;
current.ProjectId = taPart.ProjectId; current.ProjectId = taPart.ProjectId;
current.Unit = taPart.Unit; current.Unit = taPart.Unit;
current.PartGroup = taPart.PartGroup; current.PartGroup = taPart.PartGroup;
current.State = taPart.State; current.State = taPart.State;
current.Configuration = taPart.Configuration; current.Configuration = taPart.Configuration;
current.Qlevel = taPart.Qlevel;
current.Remark = taPart.Remark; current.Remark = taPart.Remark;
ret = await UpdateAsync(current); ret = await UpdateAsync(current);

2
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TaVenderRepository.cs

@ -29,7 +29,7 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
{ {
//使用直接赋值 //使用直接赋值
current.VendName = taVender.VendName; // current.VendName = taVender.VendName;//不要覆盖中文名称
current.VendAbbCode = taVender.VendAbbCode; current.VendAbbCode = taVender.VendAbbCode;
current.Country = taVender.Country; current.Country = taVender.Country;
current.City = taVender.City; current.City = taVender.City;

Loading…
Cancel
Save