Browse Source

判断TB_RECEIVE_QAD存在不存在 存在打印插入子表 不存在正常生成TB_RECEIVE_DETAIL_QAD

master
qian 4 months ago
parent
commit
6af68a914b
  1. 15
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  2. 4
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/ITbReceiptRepository.cs
  3. 21
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbReceiptRepository.cs

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

@ -97,14 +97,15 @@ namespace Win_in.Sfs.Scp.WebApi
Validator.CheckSite(_tenantRepository, entity.Site);
Validator.CheckSite(_tenantRepository, entity.Company);
var tenant = await _tenantStore.FindAsync(entity.Site);
bool flag = true;
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
using (_dataFilter.Disable<IMultiTenant>())
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id);
flag = await _tbReceiptRepository.GetCountAsync(ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity));
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id, flag);
await CurrentUnitOfWork.SaveChangesAsync();
}
}
@ -133,15 +134,17 @@ namespace Win_in.Sfs.Scp.WebApi
}
}
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId)
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId,bool flag)
{
//使用AutoMapper执行类型转换
var tbReceipt = ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity);
var tbReceiveDetail = ObjectMapper.Map<Receipt, TB_RECEIVE_DETAIL_QAD>(entity);
tbReceipt.TenantId = tenantId;
//根据传入数据新增或修改SCP数据
await _tbReceiptRepository.UpsertAsync(tbReceipt);
if (flag)
{
//根据传入数据新增或修改SCP数据
await _tbReceiptRepository.UpsertAsync(tbReceipt);
}
tbReceiveDetail.TenantId = tenantId;
//根据传入数据新增或修改SCP数据
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail);

4
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/ITbReceiptRepository.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
@ -7,6 +8,7 @@ namespace Win_in.Sfs.Scp.v1.Domain
public interface ITbReceiptRepository : IRepository<TB_RECEIVE_QAD>, ITransientDependency
{
Task<TB_RECEIVE_QAD> UpsertAsync(TB_RECEIVE_QAD taPart);
Task<bool> GetCountAsync(TB_RECEIVE_QAD taPart);
}
}

21
WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TbReceiptRepository.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
@ -24,7 +25,6 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
}
else
{
//使用直接赋值
current.VendId = tbReceipt.VendId;
current.PoBillNum = tbReceipt.PoBillNum;
@ -39,5 +39,22 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
return ret;
}
public async Task<bool> GetCountAsync(TB_RECEIVE_QAD tbReceipt)
{
bool flag = true;
int count = 0;
var dbSet = await GetDbSetAsync();
count = await dbSet
.CountAsync(p => p.Site == tbReceipt.Site && p.ErpRecvBillNum == tbReceipt.ErpRecvBillNum);
if (count>0)
{
flag = false;
Console.WriteLine("TB_RECEIVE_QAD存在!Site = " + tbReceipt.Site + " ErpRecvBillNum = " + tbReceipt.ErpRecvBillNum);
}
return flag;
}
}
}
Loading…
Cancel
Save