学 赵 1 year ago
parent
commit
bb28945599
  1. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BeiSeSyncAppService.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HandSeSyncAppService.cs
  3. 56
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs
  4. 98
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs
  5. 114
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs
  6. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs
  7. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs
  8. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs
  9. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

16
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BeiSeSyncAppService.cs

@ -1,28 +1,23 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 备件发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
[ApiExplorerSettings(IgnoreApi = true)]
public class BeiSeSyncAppService : JitSeSyncAppService, IJobService
{
/// <summary>
/// 构造
/// </summary>
public BeiSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext) : base(wmsBJBMPTContext, settleAccountDbContext)
public BeiSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext, SeSyncExtendManager seSyncExtendManager) : base(wmsBJBMPTContext, settleAccountDbContext, seSyncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -36,8 +31,9 @@ public class BeiSeSyncAppService : JitSeSyncAppService, IJobService
};
}
public async Task Invoke(IServiceProvider serviceProvider)
[UnitOfWork(IsDisabled = true)]
public virtual async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke();
await this.Invoke().ConfigureAwait(false);
}
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HandSeSyncAppService.cs

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -27,7 +28,8 @@ public class HandSeSyncAppService : ApplicationService
/// 同步
/// </summary>
[HttpPost]
public async Task SyncAsync([FromBody] EnumBusinessType businessType)
[UnitOfWork(IsDisabled = true)]
public virtual async Task SyncAsync([FromBody] EnumBusinessType businessType)
{
using var scope = this._applicationServices.CreateScope();
IInvocable jitSeSyncAppService = businessType switch

56
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SettleAccount.Job.Services.Report;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 手动同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
[ApiExplorerSettings(IgnoreApi = true)]
public class HomeAppService : ApplicationService
{
private readonly IServiceProvider _applicationServices;
public HomeAppService(IHost host)
{
_applicationServices = host.Services;
}
/// <summary>
/// 同步
/// </summary>
[HttpPost]
public async Task<string> SyncAsync(JobRequestDto jobRequestDto)
{
await Task.CompletedTask.ConfigureAwait(false);
return "ddd";
//using var scope = this._applicationServices.CreateScope();
//IExportJob exportJob = jobDto.businessType switch
//{
// EnumBusinessType.JisBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.JisHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.MaiDanJianBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.MaiDanJianHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.ZhiGongJianBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.ZhiGongJianHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.BeiJian => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.YinDuJian => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// _ => throw new ArgumentOutOfRangeException(nameof(jobDto.businessType), $"Not expected direction value: {jobDto.businessType}"),
//};
//exportJob.ExportFile(jobDto.Id, jobDto.ExportName, jobDto.Propert);
}
}

98
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs

@ -7,10 +7,8 @@ using Coravel.Invocable;
using EFCore.BulkExtensions;
using LinqToDB;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
@ -31,14 +29,20 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
/// 数据上下文
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 发运同步扩展
/// </summary>
private readonly SeSyncExtendManager _syncExtendManager;
/// <summary>
/// 构造
/// </summary>
public JitSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext)
public JitSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext, SeSyncExtendManager seSyncExtendManager)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_settleAccountDbContext = settleAccountDbContext;
_syncExtendManager = seSyncExtendManager;
_syncExtendManager._settleAccountDbContext = settleAccountDbContext;
}
/// <summary>
@ -88,26 +92,6 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
}
#region 私有方法
/// <summary>
/// 添加零件关系
/// </summary>
private async Task AddNewMaterialRelationshipsAsync(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
}
}
/// <summary>
/// 发运数据入库
/// </summary>
@ -125,7 +109,7 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await this.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
}
}
@ -161,7 +145,7 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
_settleAccountDbContext.Add<SyncPositionFlag>(syncPositionFlag);
}
await _settleAccountDbContext.BulkInsertAsync(seDetails).ConfigureAwait(false);
await SaveVmiLogsAsync(seDetails).ConfigureAwait(false);
await _syncExtendManager.SaveVmiLogsAsync(seDetails).ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
}
@ -172,69 +156,5 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
}
}
}
/// <summary>
/// 保存寄售库Log
/// </summary>
private async Task SaveVmiLogsAsync(List<PUB_SE_DETAIL> seDetails)
{
var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.);
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退);
var dateTimeNow = DateTime.Now;
var vmiLogList = deliverSeDetails.Select(t => new VmiLog(Guid.NewGuid())
{
LogType = VmiLogType.Type100,
ChangedQty = t.Qty,
ChangedType = VmiType.In,
ChangedBy = "WMS",
ChangedNumber = t.PN,
ChangedTime = dateTimeNow,
AssembleData = t.AssembleData,
BillTime = t.BillTime,
CustPartCode = t.CustPartCode,
DeliverBillType = t.DeliverBillType,
DeliverSubBillType = t.DeliverSubBillType,
ErpToLoc = t.ToErpLocCode,
OrderNum = t.DnBillNum,
Qty = t.Qty,
ReMark = t.Remark,
RealCode = t.PartCode
}).ToList();
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog(Guid.NewGuid())
{
LogType = VmiLogType.Type400,
ChangedQty = t.Qty,
ChangedType = VmiType.In,
ChangedBy = "WMS",
ChangedNumber = t.PN,
ChangedTime = dateTimeNow,
AssembleData = t.AssembleData,
BillTime = t.BillTime,
CustPartCode = t.CustPartCode,
DeliverBillType = t.DeliverBillType,
DeliverSubBillType = t.DeliverSubBillType,
ErpToLoc = t.ToErpLocCode,
OrderNum = t.DnBillNum,
Qty = -t.Qty,
ReMark = t.Remark,
RealCode = t.PartCode
}).ToList();
vmiLogList.AddRange(returnVmiLogList);
await SaveVmiMessagesAsync(vmiLogList).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(vmiLogList).ConfigureAwait(false);
}
/// <summary>
/// 保存寄售库Message
/// </summary>
public async Task SaveVmiMessagesAsync(List<VmiLog> vmiLogs)
{
var vmiMessages = vmiLogs.Select(t => new VmiMessage(Guid.NewGuid())
{
Message = JsonConvert.SerializeObject(t)
}).ToList();
await _settleAccountDbContext.BulkInsertAsync(vmiMessages).ConfigureAwait(false);
}
#endregion
}

114
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SettleAccount.Domain.BQ;
using Volo.Abp.Domain.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.MaterialRelationships;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 发运同步扩展
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class SeSyncExtendManager : DomainService
{
/// <summary>
/// DbContext
/// </summary>
public SettleAccountDbContext _settleAccountDbContext;
public SeSyncExtendManager(SettleAccountDbContext settleAccountDbContext)
{
_settleAccountDbContext = settleAccountDbContext;
}
/// <summary>
/// 添加零件关系
/// </summary>
public async Task AddNewMaterialRelationshipsAsync(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
}
}
/// <summary>
/// 保存寄售库Log
/// </summary>
public async Task SaveVmiLogsAsync(List<PUB_SE_DETAIL> seDetails)
{
var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.);
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退);
var dateTimeNow = DateTime.Now;
var vmiLogList = deliverSeDetails.Select(t => new VmiLog(Guid.NewGuid())
{
LogType = VmiLogType.Type100,
ChangedQty = t.Qty,
ChangedType = VmiType.In,
ChangedBy = "WMS",
ChangedNumber = t.PN,
ChangedTime = dateTimeNow,
AssembleData = t.AssembleData,
BillTime = t.BillTime,
CustPartCode = t.CustPartCode,
DeliverBillType = t.DeliverBillType,
DeliverSubBillType = t.DeliverSubBillType,
ErpToLoc = t.ToErpLocCode,
OrderNum = t.DnBillNum,
Qty = t.Qty,
ReMark = t.Remark,
RealCode = t.PartCode
}).ToList();
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog(Guid.NewGuid())
{
LogType = VmiLogType.Type400,
ChangedQty = t.Qty,
ChangedType = VmiType.In,
ChangedBy = "WMS",
ChangedNumber = t.PN,
ChangedTime = dateTimeNow,
AssembleData = t.AssembleData,
BillTime = t.BillTime,
CustPartCode = t.CustPartCode,
DeliverBillType = t.DeliverBillType,
DeliverSubBillType = t.DeliverSubBillType,
ErpToLoc = t.ToErpLocCode,
OrderNum = t.DnBillNum,
Qty = -t.Qty,
ReMark = t.Remark,
RealCode = t.PartCode
}).ToList();
vmiLogList.AddRange(returnVmiLogList);
await SaveVmiMessagesAsync(vmiLogList).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(vmiLogList).ConfigureAwait(false);
}
/// <summary>
/// 保存寄售库Message
/// </summary>
public async Task SaveVmiMessagesAsync(List<VmiLog> vmiLogs)
{
var vmiMessages = vmiLogs.Select(t => new VmiMessage(Guid.NewGuid())
{
Message = JsonConvert.SerializeObject(t)
}).ToList();
await _settleAccountDbContext.BulkInsertAsync(vmiMessages).ConfigureAwait(false);
}
}

10
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
@ -11,14 +11,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 印度件发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
[ApiExplorerSettings(IgnoreApi = true)]
public class YinDuSeSyncAppService : JitSeSyncAppService, IJobService
{
/// <summary>
/// 构造
/// </summary>
public YinDuSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext) : base(wmsBJBMPTContext, settleAccountDbContext)
public YinDuSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext, SeSyncExtendManager seSyncExtendManager) : base(wmsBJBMPTContext, settleAccountDbContext, seSyncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -32,7 +31,8 @@ public class YinDuSeSyncAppService : JitSeSyncAppService, IJobService
};
}
public async Task Invoke(IServiceProvider serviceProvider)
[UnitOfWork(IsDisabled = true)]
public virtual async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);
}

11
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
@ -11,14 +11,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 直供件BBAC发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ZhiGongBBACSeSyncAppService : JitSeSyncAppService, IJobService
{
/// <summary>
/// 构造
/// </summary>
public ZhiGongBBACSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext) : base(wmsBJBMPTContext, settleAccountDbContext)
public ZhiGongBBACSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext, SeSyncExtendManager seSyncExtendManager) : base(wmsBJBMPTContext, settleAccountDbContext, seSyncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -32,8 +31,8 @@ public class ZhiGongBBACSeSyncAppService : JitSeSyncAppService, IJobService
};
}
[HttpPost]
public async Task Invoke(IServiceProvider serviceProvider)
[UnitOfWork(IsDisabled = true)]
public virtual async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);
}

10
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
@ -11,14 +11,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 直供件HBPO发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
[ApiExplorerSettings(IgnoreApi = true)]
public class ZhiGongHBPOSeSyncAppService : JitSeSyncAppService, IJobService
{
/// <summary>
/// 构造
/// </summary>
public ZhiGongHBPOSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext) : base(wmsBJBMPTContext, settleAccountDbContext)
public ZhiGongHBPOSeSyncAppService(WMSBJBMPTDbContext wmsBJBMPTContext, SettleAccountDbContext settleAccountDbContext, SeSyncExtendManager seSyncExtendManager) : base(wmsBJBMPTContext, settleAccountDbContext, seSyncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -32,7 +31,8 @@ public class ZhiGongHBPOSeSyncAppService : JitSeSyncAppService, IJobService
};
}
public async Task Invoke(IServiceProvider serviceProvider)
[UnitOfWork(IsDisabled = true)]
public virtual async Task Invoke(IServiceProvider serviceProvider)
{
await base.Invoke().ConfigureAwait(false);
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -112,7 +112,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
}
else
{
throw new UserFriendlyException(import.Exception.Message.ToString(), "403");
throw new UserFriendlyException(import.Exception.Message.ToString(), "400");
//throw new BusinessException("8989", import.Exception.Message.ToString());
}
}

Loading…
Cancel
Save