Browse Source

[fix]Event Sample(Part)

master
贾荣国 3 years ago
parent
commit
a8112c62cf
  1. 5
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Parts/ITaPartRepository.cs
  2. 26
      WebApiService/src/Win_in.Sfs.Scp.v1.EntityFrameworkCore/Repositories/TaPartRepository.cs
  3. 21
      WebApiService/src/Win_in.Sfs.Scp.v1.Event/PartEventHandler.cs
  4. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Event/PurchaseOrderEventHandler.cs
  5. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Event/ReceiptEventHandler.cs
  6. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Event/SupplierEventHandler.cs
  7. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Event/UnplannedReceiptEventHandler.cs

5
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Parts/ITaPartRepository.cs

@ -1,10 +1,11 @@
using Volo.Abp.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
namespace Win_in.Sfs.Scp.v1.Domain
{
public interface ITaPartRepository : IRepository<TA_PART>,ITransientDependency
{
Task<TA_PART> UpsertAsync(TA_PART taPart);
}
}

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

@ -1,4 +1,5 @@
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Win_in.Sfs.Scp.v1.Domain;
@ -10,5 +11,28 @@ namespace Win_in.Sfs.Scp.v1.EntityFrameworkCore
public TaPartRepository(IDbContextProvider<V1ScpDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<TA_PART> UpsertAsync( TA_PART taPart)
{
TA_PART ret;
var current = await GetAsync(p =>p.Site==taPart.Site
&& p.PartCode == taPart.PartCode);
if (current == null)
{
ret =await InsertAsync(taPart);
}
else
{
//使用直接赋值
current.PartDesc1 = taPart.PartDesc1;
current.PartDesc2 = taPart.PartDesc2;
//...
ret =await UpdateAsync(current);
}
return ret;
}
}
}

21
WebApiService/src/Win_in.Sfs.Scp.v1.Event/PartEventHandler.cs

@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus;
@ -27,24 +28,10 @@ namespace Win_in.Sfs.Scp.WebApi
var part = eventData.Entity;
Console.WriteLine("Local Event:" + part.Code);
//根据传入数据新增或修改TA_PART
//使用AutoMapper执行类型转换
var taPart = _objectMapper.Map<Part, TA_PART>(part);
var current = await _taPartRepository.GetAsync(p => p.PartCode == taPart.PartCode);
if (current == null)
{
await _taPartRepository.InsertAsync(taPart);
}
else
{
current = _objectMapper.Map<Part, TA_PART>(part);
// current.PartDesc1 = part.Desc1;
// current.PartDesc2 = part.Desc2;
//...
await _taPartRepository.UpdateAsync(current);
}
//根据传入数据新增或修改TA_PART
var ret = await _taPartRepository.UpsertAsync(taPart);
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Event/PurchaseOrderEventHandler.cs

@ -15,7 +15,7 @@ namespace Win_in.Sfs.Scp.WebApi
return Task.CompletedTask;
//TODO 新增或修改TB_PO
//TODO 新增或修改TB_PO,TB_PO_DETAIL
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Event/ReceiptEventHandler.cs

@ -16,7 +16,7 @@ namespace Win_in.Sfs.Scp.WebApi
return Task.CompletedTask;
//TODO 新增 TB_RECEIPT 或 TB_REJECT
//TODO 根据单据类型,新增 TB_RECEIPT 或 TB_REJECT
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Event/SupplierEventHandler.cs

@ -15,7 +15,7 @@ namespace Win_in.Sfs.Scp.WebApi
return Task.CompletedTask;
//TODO 根据传入数据新增或修改TA_VENDER
//TODO 新增或修改TA_VENDER
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.v1.Event/UnplannedReceiptEventHandler.cs

@ -16,7 +16,7 @@ namespace Win_in.Sfs.Scp.WebApi
return Task.CompletedTask;
//TODO 新增无订单的TB_RECEIPT
//TODO 新增或修改无订单的TB_RECEIPT
}
}
}
Loading…
Cancel
Save