From b84da728f303439dee9962f624afa472dabc93f4 Mon Sep 17 00:00:00 2001 From: mahao Date: Thu, 17 Aug 2023 16:06:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=91=E8=BF=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Syncs/BBACSeSyncAppService.cs | 195 --------------- .../Entities/BQ/Syncs/HBPOSeSyncAppService.cs | 225 ------------------ .../BQ/Syncs/JisBBACSeSyncBaseAppService.cs | 6 +- .../BQ/Syncs/JisHBPOSeSyncBaseAppService.cs | 9 +- .../Entities/BQ/Syncs/JitSeSyncAppService.cs | 4 +- 5 files changed, 7 insertions(+), 432 deletions(-) delete mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs delete mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs deleted file mode 100644 index 99792617..00000000 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; -using Coravel.Invocable; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using SettleAccount.Domain.BQ; -using Volo.Abp.Application.Services; -using Win.Sfs.SettleAccount.Entities.BQ.Managers; -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; - -/// -/// HBPO发运数据同步 -/// -[AllowAnonymous] -[Route("api/settleaccount/[controller]/[action]")] -public class BBACSeSyncAppService : ApplicationService, IInvocable, IJobService -{ - /// - /// WMS数据上下文 - /// - private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; - - /// - /// 同步位置标记 - /// - private readonly INormalEfCoreRepository _syncPositionFlagRepository; - - /// - /// HBPO发运数据仓储 - /// - private readonly INormalEfCoreRepository _bbacSeDetailRepository; - - /// - /// 客户零件关系领域 - /// - private readonly MaterialRelationshipManager _materialRelationshipManager; - - /// - /// 客户零件关系集合 - /// - private List _addMaterialRelationships; - - /// - /// 构造 - /// - public BBACSeSyncAppService( - WMSBJBMPTDbContext wmsBJBMPTContext, - INormalEfCoreRepository syncPositionFlagRepository, - INormalEfCoreRepository bbacSeDetailRepository, - MaterialRelationshipManager materialRelationshipManager) - { - _wmsBJBMPTContext = wmsBJBMPTContext; - _syncPositionFlagRepository = syncPositionFlagRepository; - _bbacSeDetailRepository = bbacSeDetailRepository; - _materialRelationshipManager = materialRelationshipManager; - _addMaterialRelationships = new List(); - } - - [ApiExplorerSettings(IgnoreApi = true)] - public async Task Invoke(IServiceProvider serviceProvider) - { - await this.Invoke().ConfigureAwait(false); - } - - [HttpPost] - public async Task Invoke() - { - await SyncJitRecordAsync().ConfigureAwait(false); - await SyncJisRecordAsync().ConfigureAwait(false); - if (_addMaterialRelationships.Any()) - { - _addMaterialRelationships = _addMaterialRelationships.Where(t => !string.IsNullOrEmpty(t.ErpMaterialCode)).GroupBy(t => new { t.ErpMaterialCode }).Select(t => t.First()).ToList(); - await _materialRelationshipManager.AddNewMaterialRelationships(_addMaterialRelationships).ConfigureAwait(false); - } - } - - /// - /// 同步JitRecord - /// - private async Task SyncJitRecordAsync() - { - //同步表名称 - var syncTableName = "JisBBACSeSync_Jit"; - //BBAC类型集合 - var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); - - Expression> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); - if (syncPositionFlag != null) - { - predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - } - - //WMS发运记录 - var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); - - var bbacSeDetails = ObjectMapper.Map, List>(wmsSeRecords); - if (bbacSeDetails.Any()) - { - //客户零件号和厂内零件号 - var materialRelationships = bbacSeDetails.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); - _addMaterialRelationships.AddRange(materialRelationships); - - bbacSeDetails.ForEach(bbacSeDetail => - { - bbacSeDetail.KeyCode = bbacSeDetail.PN + bbacSeDetail.LU; - bbacSeDetail.BusinessType = EnumBusinessType.JisBBAC; - }); - await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails); - - if (syncPositionFlag != null) - { - syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); - await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); - } - else - { - syncPositionFlag = new SyncPositionFlag() - { - TableName = syncTableName, - Position = wmsSeRecords.Last().UID.ToString() - }; - await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); - } - } - } - - /// - /// 同步JisRecord - /// - private async Task SyncJisRecordAsync() - { - //同步表名称 - var syncTableName = "JisBBACSeSync_Jis"; - //BBAC类型集合 - var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); - Expression> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); - if (syncPositionFlag != null) - { - predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - } - - //WMS发运数据 - var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); - - var bbacSeDetails = ObjectMapper.Map, List>(wmsRecords); - if (bbacSeDetails.Any()) - { - //客户零件号和厂内零件号 - var materialRelationships = bbacSeDetails.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); - _addMaterialRelationships.AddRange(materialRelationships); - - bbacSeDetails.ForEach(bbacSeDetail => bbacSeDetail.KeyCode = bbacSeDetail.PN + bbacSeDetail.LU); - await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails); - - if (syncPositionFlag != null) - { - syncPositionFlag.Position = wmsRecords.Last().UID.ToString(); - await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); - } - else - { - syncPositionFlag = new SyncPositionFlag() - { - TableName = syncTableName, - Position = wmsRecords.Last().UID.ToString() - }; - await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); - } - } - } - - /// - /// 获取BBAC类型集合 - /// - private List GetDeliverSubBillTypes() - { - return new List - { - EnumDeliverSubBillType.保险杠BBAC, - EnumDeliverSubBillType.买单件保险杠BBAC, - EnumDeliverSubBillType.买单件小件BBAC, - EnumDeliverSubBillType.小件BBAC - }; - } -} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs deleted file mode 100644 index 70c6f1b7..00000000 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Dynamic.Core; -using System.Linq.Expressions; -using System.Threading.Tasks; -using Coravel.Invocable; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using SettleAccount.Domain.BQ; -using Volo.Abp.Application.Services; -using Win.Sfs.SettleAccount.Entities.BQ.Managers; -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; - -/// -/// HBPO发运数据同步 -/// -[AllowAnonymous] -[Route("api/settleaccount/[controller]/[action]")] -public class HBPOSeSyncAppService : ApplicationService, IInvocable, IJobService -{ - /// - /// WMS数据上下文 - /// - private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; - - /// - /// 同步位置标记 - /// - private readonly INormalEfCoreRepository _syncPositionFlagRepository; - - /// - /// HBPO发运数据仓储 - /// - private readonly INormalEfCoreRepository _hbpoSeDetailRepository; - - /// - /// PUB发运数据仓储 - /// - private readonly INormalEfCoreRepository _pubSeDetailRepository; - - /// - /// 客户零件关系领域 - /// - private readonly MaterialRelationshipManager _materialRelationshipManager; - - /// - /// 客户零件关系集合 - /// - private List _addMaterialRelationships; - - /// - /// 构造 - /// - public HBPOSeSyncAppService( - WMSBJBMPTDbContext wmsBJBMPTContext, - INormalEfCoreRepository syncPositionFlagRepository, - INormalEfCoreRepository hbpoSeDetailRepository, - INormalEfCoreRepository pubSeDetailRepository, - MaterialRelationshipManager materialRelationshipManager) - { - _wmsBJBMPTContext = wmsBJBMPTContext; - _syncPositionFlagRepository = syncPositionFlagRepository; - _hbpoSeDetailRepository = hbpoSeDetailRepository; - _pubSeDetailRepository = pubSeDetailRepository; - _materialRelationshipManager = materialRelationshipManager; - _addMaterialRelationships = new List(); - } - - [ApiExplorerSettings(IgnoreApi = true)] - public async Task Invoke(IServiceProvider serviceProvider) - { - await this.Invoke().ConfigureAwait(false); - } - - /// - /// 执行 - /// - [HttpPost] - public async Task Invoke() - { - await SyncJitRecordAsync().ConfigureAwait(false); - await SyncJisRecordAsync().ConfigureAwait(false); - if (_addMaterialRelationships.Any()) - { - _addMaterialRelationships = _addMaterialRelationships.Where(t => !string.IsNullOrEmpty(t.ErpMaterialCode)).GroupBy(t => new { t.ErpMaterialCode }).Select(t => t.First()).ToList(); - await _materialRelationshipManager.AddNewMaterialRelationships(_addMaterialRelationships).ConfigureAwait(false); - } - } - - /// - /// 同步JitRecord - /// - private async Task SyncJitRecordAsync() - { - //同步表名称 - var syncTableName = "JisHBPOSeSync_Jit"; - //HBPO类型集合 - var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); - Expression> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); - if (syncPositionFlag != null) - { - predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - } - - //WMS发运数据 - var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); - if (wmsSeRecords.Any()) - { - //JisHBPO发运 - var hbpoWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.小件HBPO); - //买单件HBPO发运 - var maiDanHBPOWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.买单件保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.买单件小件HBPO); - - var hbpoSeDetails = ObjectMapper.Map, List>(hbpoWmsSeRecords); - var maiDanHBPOSeDetails = ObjectMapper.Map, List>(maiDanHBPOWmsSeRecords); - - await SaveSeDataAsync(hbpoSeDetails, maiDanHBPOSeDetails).ConfigureAwait(false); - - if (syncPositionFlag != null) - { - syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); - await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false); - } - else - { - syncPositionFlag = new SyncPositionFlag() - { - TableName = syncTableName, - Position = wmsSeRecords.Last().UID.ToString() - }; - await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); ; - } - } - } - - /// - /// 同步JisRecord - /// - private async Task SyncJisRecordAsync() - { - //同步表名称 - var syncTableName = "JisHBPOSeSync_Jis"; - //BBAC类型集合 - var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); - Expression> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); - if (syncPositionFlag != null) - { - predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); - } - - //WMS发运数据 - var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); - if (wmsSeRecords.Any()) - { - //JisHBPO发运 - var hbpoWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.小件HBPO); - //买单件HBPO发运 - var maiDanHBPOWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.买单件保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.买单件小件HBPO); - - var hbpoSeDetails = ObjectMapper.Map, List>(hbpoWmsSeRecords); - var maiDanHBPOSeDetails = ObjectMapper.Map, List>(maiDanHBPOWmsSeRecords); - - await SaveSeDataAsync(hbpoSeDetails, maiDanHBPOSeDetails).ConfigureAwait(false); - - if (syncPositionFlag != null) - { - syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); - await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false); - } - else - { - syncPositionFlag = new SyncPositionFlag() - { - TableName = syncTableName, - Position = wmsSeRecords.Last().UID.ToString() - }; - await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); - } - } - } - - /// - /// 获取HBPO类型集合 - /// - private List GetDeliverSubBillTypes() - { - return new List - { - EnumDeliverSubBillType.保险杠HBPO, - EnumDeliverSubBillType.买单件保险杠HBPO, - EnumDeliverSubBillType.买单件小件HBPO, - EnumDeliverSubBillType.小件HBPO - }; - } - - /// - /// 保存发运树 - /// - private async Task SaveSeDataAsync(List hbpoSeDetails, List maiDanHBPOSeDetails) - { - //客户零件号和厂内零件号 - var hbpoSeLuRePartCodes = hbpoSeDetails.Select(t => new { t.LU, t.PartCode }); - var maiDanHBPOSeLuRePartCodes = maiDanHBPOSeDetails.Select(t => new { t.LU, t.PartCode }); - var luRePartCodes = hbpoSeLuRePartCodes.Union(maiDanHBPOSeLuRePartCodes); - var materialRelationships = luRePartCodes.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); - _addMaterialRelationships.AddRange(materialRelationships); - - hbpoSeDetails.ForEach(hbpoSeDetail => hbpoSeDetail.KeyCode = hbpoSeDetail.PN + hbpoSeDetail.LU); - maiDanHBPOSeDetails.ForEach(maiDanHBPOSeDetail => - { - maiDanHBPOSeDetail.KeyCode = maiDanHBPOSeDetail.PN + maiDanHBPOSeDetail.LU; - maiDanHBPOSeDetail.BusinessType = EnumBusinessType.MaiDanJianHBPO; - }); - await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails).ConfigureAwait(false); - await _pubSeDetailRepository.InsertManyAsync(maiDanHBPOSeDetails).ConfigureAwait(false); - } -} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs index 531d06a4..bcc55d54 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs @@ -101,11 +101,10 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable //WMS发运记录 var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); - jisSeDetails.RemoveAll(t => string.IsNullOrEmpty(t.LU) || string.IsNullOrEmpty(t.FactoryPartCode)); if (jisSeDetails.Any()) { //客户零件号和厂内零件号 - var luRePartCodes = jisSeDetails.Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); + var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); if (luRePartCodes.Any()) { var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString())); @@ -161,11 +160,10 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable //WMS发运数据 var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsRecords); - jisSeDetails.RemoveAll(t => string.IsNullOrEmpty(t.LU) || string.IsNullOrEmpty(t.FactoryPartCode)); if (jisSeDetails.Any()) { //客户零件号和厂内零件号 - var luRePartCodes = jisSeDetails.Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); + var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); if (luRePartCodes.Any()) { var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString())); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs index 9eb57708..a1724a51 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs @@ -103,11 +103,10 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable //WMS发运记录 var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsSeRecords); - jisSeDetails.RemoveAll(t => string.IsNullOrEmpty(t.LU) || string.IsNullOrEmpty(t.FactoryPartCode)); if (jisSeDetails.Any()) { //客户零件号和厂内零件号 - var luRePartCodes = jisSeDetails.Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); + var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); if (luRePartCodes.Any()) { var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString())); @@ -164,11 +163,10 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable //WMS发运数据 var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); var jisSeDetails = ObjectMapper.Map, List>(wmsRecords); - jisSeDetails.RemoveAll(t => string.IsNullOrEmpty(t.LU) || string.IsNullOrEmpty(t.FactoryPartCode)); if (jisSeDetails.Any()) { //客户零件号和厂内零件号 - var luRePartCodes = jisSeDetails.Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); + var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); if (luRePartCodes.Any()) { var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString())); @@ -177,7 +175,8 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable jisSeDetails.ForEach(t => { - //t.BusinessType = businessType; + t.SetId(GuidGenerator.Create()); + t.BusinessType = businessType; t.KeyCode = t.PN + t.LU; }); await _jisSeDetailRepository.DbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs index aa5c29d2..9393640d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs @@ -91,13 +91,11 @@ public class JitSeSyncAppService : ApplicationService, IInvocable } //WMS发运记录 var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); - var pubSeDetails = ObjectMapper.Map, List>(wmsSeRecords); - pubSeDetails.RemoveAll(t => string.IsNullOrEmpty(t.LU) || string.IsNullOrEmpty(t.FactoryPartCode)); if (pubSeDetails.Any()) { //客户零件号和厂内零件号 - var luRePartCodes = pubSeDetails.Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); + var luRePartCodes = pubSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList(); if (luRePartCodes.Any()) { var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString())); From d7ef4994715fbf6c820a73c4355347d929e41451 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 17 Aug 2023 16:53:17 +0800 Subject: [PATCH 2/2] update --- .../wwwroot/components/list/index.js | 1 + .../wwwroot/models/settle/commerce.js | 12 +- .../wwwroot/models/settle/detail.js | 33 ++++-- .../wwwroot/models/settle/unable.js | 112 ++++++++++++++++++ .../wwwroot/request/index.js | 5 +- .../wwwroot/router/business.js | 6 +- .../wwwroot/views/settle/_check.js | 30 ++++- .../wwwroot/views/settle/commerce.js | 43 ++++++- .../wwwroot/views/settle/unable.js | 24 +++- .../wwwroot/views/settle/usable.js | 2 +- 10 files changed, 231 insertions(+), 37 deletions(-) create mode 100644 code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable.js diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js index 7c829a00..c961f506 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js @@ -885,6 +885,7 @@ export default { load, config, queryModel, + buildQuery, pageModel, treeProps, tableKey, diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js index 77c76808..535e3b8c 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js @@ -6,7 +6,6 @@ const schema = { title: "商务审批", type: "object", properties: { - version, realnvBillNum: { title: "金税发票号", type: "string", @@ -54,10 +53,10 @@ const schema = { export default function (businessType, type) { let service = null; - if (type === "shangwu") { + if (type === "shang-wu") { if (businessType === "JisBBAC") { service = "bbac_ba_service"; - } else if (businessType === "JisBBAC") { + } else if (businessType === "JisHBPO") { service = "hbpo_ba_service"; } else { service = "pub_ba_service"; @@ -108,13 +107,6 @@ export default function (businessType, type) { }, }, default: [ - { - logic: "and", - column: "version", - action: "equal", - value: null, - readOnly: true, - }, { logic: "and", column: "state", diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js index ff9eadd2..1a69b1ca 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js @@ -1,5 +1,3 @@ -import { version } from "../_options.js"; - const schema = { title: "通用代码", type: "object", @@ -68,14 +66,24 @@ const schema = { }, }; -export default function (businessType) { +export default function (businessType, type) { let service; - if (businessType === "JisBBAC") { - service = "bbac_not_sa_service"; - } else if (businessType === "JisHBPO") { - service = "hbpo_not_sa_service"; + if (type === "unable") { + if (businessType === "JisBBAC") { + service = "bbac_not_sa_service"; + } else if (businessType === "JisHBPO") { + service = "hbpo_not_sa_service"; + } else { + service = "pub_not_sa_service"; + } } else { - service = "pub_not_sa_service"; + if (businessType === "JisBBAC") { + service = "bbac_can_sa_service"; + } else if (businessType === "JisHBPO") { + service = "hbpo_can_sa_service"; + } else { + service = "pub_can_sa_service"; + } } if (businessType === "JisBBAC" || businessType === "JisHBPO" || businessType === "MaiDanJianBBAC" || businessType === "MaiDanJianHBPO") { schema.properties.pn.title = "生产码"; @@ -93,7 +101,11 @@ export default function (businessType) { delete schema.properties["site"]; } const queryUrl = `settleaccount/${service}/detail-query`; + const addUrl = `settleaccount/${service}/generate-settlement-order`; + const exportUrl = `settleaccount/${service}/export`; const queryMethod = "POST"; + const addMethod = "POST"; + const exportMethod = "POST"; return { query: { @@ -167,6 +179,11 @@ export default function (businessType) { schema: schema, }, edit: { + addUrl, + exportUrl, + addMethod, + exportUrl, + exportMethod, schema: schema, }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable.js new file mode 100644 index 00000000..ea1a6079 --- /dev/null +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable.js @@ -0,0 +1,112 @@ +import { version, state } from "../_options.js"; + +const schema = { + title: "可结算单", + type: "object", + properties: { + version, + state, + billNum: { + title: "结算单据", + type: "string", + oneToMany: "/settle/detail", + config: "/models/settle/detail.js", + }, + settleBillNum: { + title: "关联结算单号", + type: "string", + }, + invGroupNum: { + title: "发票分组号", + type: "string", + }, + }, +}; + +export default function (businessType) { + let service; + if (businessType === "JisBBAC") { + service = "bbac_can_sa_service"; + } else if (businessType === "JisHBPO") { + service = "hbpo_can_sa_service"; + } else { + service = "pub_can_sa_service"; + } + const queryUrl = `settleaccount/${service}/main-query`; + const exportUrl = `settleaccount/${service}/export`; + const addUrl = `settleaccount/${service}/generate-invoice`; + + const queryMethod = "POST"; + const exportMethod = "POST"; + const addMethod = "POST"; + + return { + query: { + url: queryUrl, + method: queryMethod, + hasFilter: true, + schema: { + title: "发票分组号", + type: "object", + properties: { + filters: { + title: "项目", + type: "array", + hidden: true, + items: { + type: "object", + properties: { + logic: { + type: "int", + }, + column: { + type: "string", + }, + action: { + type: "int", + }, + value: { + type: "string", + }, + }, + }, + default: [ + { + logic: "and", + column: "version", + action: "equal", + value: null, + readOnly: true, + }, + ], + }, + skipCount: { + hidden: true, + default: 0, + }, + maxResultCount: { + hidden: true, + default: 10, + }, + sorting: { + hidden: true, + }, + businessType: { + hidden: true, + default: 0, + }, + }, + }, + }, + table: { + schema: schema, + }, + edit: { + exportUrl, + addUrl, + exportMethod, + addMethod, + schema: schema, + }, + }; +} diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js index da1865b6..534232f2 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js @@ -65,10 +65,7 @@ const getResult = async (response) => { } catch (error) { console.log(error); } - ElMessageBox.alert( - `${result.errors?.error?.message ?? messages.get(response.status) ?? result.status}`, - `${result.errors?.error?.code ?? result.status}` - ); + ElMessageBox.alert(`${result.errors?.error?.message ?? messages.get(response.status) ?? result.status}`, `${result.errors?.error?.code ?? "错误"}`); } return result; }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js index a7e2ba79..c60ac00d 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js @@ -85,10 +85,10 @@ function createCommerceCheckList(path, business, client, title = "商务审批") component: "/settle/commerce", children: [ createButton("query", "title=查询&isTop=true"), - createButton("compare", "title=商务审核通过&isTop=true"), - createButton("reject", "title=退回&isTop=true"), + createButton("approval", "title=商务审核通过&isTop=true"), + createButton("reject", "title=退回"), createButton("export", "title=导出&isTop=true&pattern=paged"), - createButton("????", "title=客户已收票&isTop=true"), + createButton("receive", "title=客户已收票&isTop=true"), ], }; } diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js index 73068307..6f8d38d5 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js @@ -38,7 +38,7 @@ export default { @@ -70,7 +70,7 @@ export default { 上一步 - 下一步 + 下一步 确定 @@ -253,6 +253,8 @@ export default { const addDialogVisible = ref(false); const importDialogVisible = ref(false); const showSetupDialog = () => { + //重开发票号 + //invBillNum= adjList.value = []; setupRef.value = 1; setupDialogVisable.value = true; @@ -276,6 +278,7 @@ export default { type: "string", title: "发票号", rules: [{ required: true }], + default: props.data.invbillNum, }, settleDate: { type: "string", @@ -307,7 +310,7 @@ export default { }, }; const defaultAdjModel = schemaToModel(adjSchema); - const adjModel = ref(Object.assign({}, defaultAdjModel)); + const adjModel = ref(Object.assign({ invBillNum: "" }, defaultAdjModel)); const addAdjFormRef = ref(null); const showAddAdjDialog = () => { adjModel.value = Object.assign({}, defaultAdjModel); @@ -372,6 +375,26 @@ export default { loading.value = false; } }; + const next = async () => { + if (setupRef.value === 1) { + try { + const url = "settleaccount/adj_service/check-import"; + const result = await request(url, adjList.value, { method: "POST" }); + if (!result.errors) { + if (result.data?.code === 200) { + //明细对比逻辑处理 + setupRef += 1; + } else if (result.data?.code === 400 && result.data.fileName) { + window.open(getUrl(`settleaccount/getblobfile/download/${result.data.fileName}`)); + } + } + } catch (e) { + console.log(e); + } + } else { + setupRef += 1; + } + }; const submitReOpen = async () => {}; // onMounted(async () => { @@ -409,6 +432,7 @@ export default { importAdjSchema, importAdj, scrollRef, + next, }; }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/commerce.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/commerce.js index 07f17581..51e8894f 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/commerce.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/commerce.js @@ -2,23 +2,56 @@ import AppList from "../../components/list/index.js"; import html from "html"; import { useRoute } from "vue-router"; import { ref } from "vue"; +import { ElMessage, ElMessageBox } from "element-plus"; +import request from "../../request/index.js"; import useConfig from "../../models/settle/commerce.js"; import AppCheck from "./_check.js"; export default { components: { AppList, AppCheck }, - template: html` `, + template: html` `, setup() { + const appListRef = ref(null); const visable = ref(false); const data = ref(null); const route = useRoute(); const businessType = route.meta.businessType; const config = useConfig(businessType, "shang-wu"); const onCommand = async (item, rows) => { - data.value = { [item.path]: rows[0][item.path] }; - visable.value = true; - console.log(item.path, item, rows); + if (item.path === "approval" || item.path === "reject" || item.path === "receive") { + if (rows.length === 0) { + ElMessage({ + type: "warning", + message: "没有选中的数据", + }); + } else { + const message = + item.path === "approval" + ? `确认审核通过选中的${rows.length}行数据吗?` + : item.path === "reject" + ? `确认退回选中的${rows.length}行数据吗?` + : `确认选中的${rows.length}行数据客户已收票吗?`; + const data = item.path === "approval" ? rows.map((o) => o.invbillNum) : item.path === "reject" ? rows[0]["invGroupNum"] : rows.map((o) => o.invbillNum); + const url = item.path === "approval" ? config.edit.invoiceUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; + try { + await ElMessageBox.confirm(message, "提示", { + type: "warning", + }); + appListRef.value.tableLoading = true; + const result = request(url, data, { method: "POST" }); + console.log(result); + } catch (e) { + console.log(e); + } finally { + appListRef.value.tableLoading = false; + } + } + } else if (item.path === "invbillNum" || item.path === "invGroupNum") { + data.value = { invbillNum: rows[0]["invbillNum"], invGroupNum: rows[0]["invGroupNum"] }; + visable.value = true; + console.log(item.path, item, rows); + } }; - return { config, onCommand, visable, data }; + return { appListRef, config, onCommand, visable, data }; }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js index 47b708b6..ed6df1fc 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js @@ -1,19 +1,37 @@ import AppList from "../../components/list/index.js"; import html from "html"; +import { ref } from "vue"; import { useRoute } from "vue-router"; +import { ElMessageBox } from "element-plus"; import useConfig from "../../models/settle/detail.js"; +import request from "../../request/index.js"; export default { components: { AppList }, - template: html``, + template: html``, setup() { + const appListRef = ref(null); const route = useRoute(); const businessType = route.meta.businessType; - const config = useConfig(businessType); + const config = useConfig(businessType, "unable"); const onCommand = async (item, rows) => { + const url = config.edit.addUrl; if (item.path === "add") { + try { + await ElMessageBox.confirm(`确认是否对所有符合查询条件的数据生成可结算单?`, "提示", { + type: "warning", + }); + appListRef.value.tableLoading = true; + const data = appListRef.value.buildQuery(); + const result = request(url, data, { method: "POST" }); + console.log(result); + } catch (e) { + console.log(e); + } finally { + appListRef.value.tableLoading = false; + } } }; - return { config, onCommand }; + return { appListRef, config, onCommand }; }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js index b14d10a7..f7d0bc3f 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js @@ -19,7 +19,7 @@ export default { if (item.path === "add") { const invbillNum = rows[0].billNum; try { - await ElMessageBox.confirm(`"确认为${invbillNum}创建发票?`, "提示", { + await ElMessageBox.confirm(`确认为${invbillNum}创建发票?`, "提示", { type: "warning", }); appListRef.value.tableLoading = true;