mahao
1 year ago
8 changed files with 148 additions and 172 deletions
@ -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);
|
|||
} |
|||
} |
@ -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 SyncExtendManager : DomainService |
|||
{ |
|||
/// <summary>
|
|||
/// DbContext
|
|||
/// </summary>
|
|||
public SettleAccountDbContext _settleAccountDbContext; |
|||
|
|||
public SyncExtendManager(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); |
|||
} |
|||
} |
Loading…
Reference in new issue