zhaoxinyu
5 months ago
10 changed files with 185 additions and 28 deletions
@ -0,0 +1,78 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using EFCore.BulkExtensions; |
||||
|
using Omu.ValueInjecter; |
||||
|
using SettleAccount.Bases; |
||||
|
using SettleAccount.Domain.BQ; |
||||
|
using TaskJob.EventArgs; |
||||
|
using TaskJob.Interfaces; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
||||
|
{ |
||||
|
public class ReturnCanSettlement : ApplicationService, ITransientDependency, IExportJob |
||||
|
{ |
||||
|
protected readonly SettleAccountDbContext _dbcontext; |
||||
|
public ReturnCanSettlement(SettleAccountDbContext dbcontext) |
||||
|
{ |
||||
|
_dbcontext = dbcontext; |
||||
|
} |
||||
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
||||
|
{ |
||||
|
var billNum = property.Where(p => p.Name == "BillNum").FirstOrDefault().Value; |
||||
|
var BussinessType = property.Where(p => p.Name == "BussinessType").FirstOrDefault().Value; |
||||
|
|
||||
|
if (BussinessType == "JisBBAC") |
||||
|
{ |
||||
|
var entites = _dbcontext.Set<BBAC_CAN_SA_DETAIL>().Where(p => p.BillNum == billNum).ToList(); |
||||
|
var main = _dbcontext.Set<BBAC_CAN_SA>().FirstOrDefault(p => p.BillNum == billNum); |
||||
|
Execute(main, entites); |
||||
|
|
||||
|
} |
||||
|
if (BussinessType == "JisHBPO") |
||||
|
{ |
||||
|
var entites = _dbcontext.Set<HBPO_CAN_SA_DETAIL>().Where(p => p.BillNum == billNum).ToList(); |
||||
|
var main = _dbcontext.Set<HBPO_CAN_SA>().FirstOrDefault(p => p.BillNum == billNum); |
||||
|
Execute(main, entites); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
return id.ToString(); |
||||
|
} |
||||
|
|
||||
|
public void Execute<TMain,TDetail>(TMain p_main,List<TDetail> p_detailList) where TMain : SA_CAN_BASE_MAIN, new() |
||||
|
where TDetail : SA_CAN_BASE, new() |
||||
|
{ |
||||
|
|
||||
|
List<TDetail> notList = new List<TDetail>(); |
||||
|
var entites = p_detailList; |
||||
|
var main = p_main; |
||||
|
|
||||
|
|
||||
|
foreach (var itm in entites) |
||||
|
{ |
||||
|
var detail = new TDetail(); |
||||
|
detail.InjectFrom(itm); |
||||
|
detail.SetId(detail.Id); |
||||
|
foreach (var extra in itm.ExtraProperties) |
||||
|
{ |
||||
|
detail.ExtraProperties.Add(extra.Key, extra.Value); |
||||
|
} |
||||
|
notList.Add(detail); |
||||
|
} |
||||
|
|
||||
|
_dbcontext.BulkDelete(new List<TMain>() { main }); |
||||
|
_dbcontext.BulkDelete(entites); |
||||
|
_dbcontext.BulkInsert(notList); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue