diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs index 3359c5d0..7af3f939 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs @@ -551,3 +551,17 @@ public class PubSaSeCompareRequestDto /// public DateTime? SeEndDateTime { get; set; } } + +public class JobRequestDto +{ + /// + /// 业务类别 + /// + public EnumBusinessType BusinessType { get; set; } + + //public Guid Id { get; set; } + + //public List ExportName { get; set; } + + //public List Propert { get; set; } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs index 2456f978..285487a4 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs @@ -146,7 +146,6 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// 厂内物料描述 /// [ImporterHeader(Name = "厂内物料描述")] - [Required(ErrorMessage = "{0}是必填项")] [MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")] public string MaterialDesc { get; set; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs index b407ca7e..aa3ecc37 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs @@ -5,6 +5,7 @@ using System.LinqAsync; using System.Security.Policy; using System.Threading.Tasks; using AutoMapper; +using DocumentFormat.OpenXml.Drawing.Charts; using EFCore.BulkExtensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -146,6 +147,22 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase } } + if (!checkList.Any()) + { + //验证客户对应厂内零件号是否存在 + //导入的零件号集合 + var importPubSaLUs = importBBACSaDetails.Select(t => t.LU).Distinct(); + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); + var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + + //不存在的客户零件号(差集) + var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); + noExistSettleMaterialCodes.ForEach(t => + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty)); + }); + } + if (checkList.Count > 0) { string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); @@ -253,7 +270,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase { try { - var bbacSaDelItems = await GetBBACSaDelItemsAsync(id); + var bbacSaDelItems = await GetBBACSaDelItemsAsync(id).ConfigureAwait(false); bbacSas.AddRange(bbacSaDelItems.bbacSas); bbacSaDetails.AddRange(bbacSaDelItems.bbacSaDetails); @@ -325,9 +342,6 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase var materialRelationships = new List(); #region 处理结算数据 - //销售价格 - var priceListEntitys = await _priceListRepository.GetAllAsync(); - bbacSaDetails.ForEach(bbacSaDetail => { bbacSaDetail.SetId(GuidGenerator.Create()); @@ -342,35 +356,21 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase bbacSaDetail.BillNum = bbacSaBillNum; bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU; - - //根据物料号、结算日期获取价格 - var priceListEntity = priceListEntitys.Find(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate > t.BeginTime && bbacSaDetail.SettleDate < t.EndTime); - bbacSaDetail.Price = priceListEntity?.Price ?? default; bbacSaDetail.BusinessType = bbacSaDetail.PN.Contains("R0") ? EnumBusinessType.MaiDanJianBBAC : _businessType; }); //导入的零件号集合 var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct(); + //销售价格 + var priceListEntitys = _priceListRepository.Where(t => importPubSaLUs.Contains(t.LU)).ToList(); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)); - var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); - - /* - * (不存在的客户零件号)差集 - * 转换为厂内零件号 - * 转换规则6个空格替换成“-” - */ - var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); - - noExistSettleMaterialCodes.ForEach(t => - { - var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType); - materialRelationships.Add(materialRelationship); - }); - - var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships); bbacSaDetails.ForEach(bbacSaDetail => { - bbacSaDetail.PartCode = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(" ", "-"); + //根据物料号、结算日期获取价格 + var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate >= t.BeginTime && bbacSaDetail.SettleDate <= t.EndTime); + bbacSaDetail.Price = priceListEntity?.Price ?? 0; + + bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(" ", "-"); }); #endregion @@ -430,14 +430,14 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase List bbacCanSaDetails = new List(); //不可结算 List bbacNotSaDetails = new List(); - - var bbacSaEntity = await _bbacSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)); + var bbacSaEntity = await _bbacSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false); + //var bbacSaEntity = await _bbacSaRepository.FindAsync(id).ConfigureAwait(false); if (bbacSaEntity != null) { //结算单据 string bbacSaBillNum = bbacSaEntity.BillNum; - bbacCanSas = await _bbacCanSaRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum); + bbacCanSas = await _bbacCanSaRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false); //验证可结算主表状态 if (bbacCanSas.Any() && bbacCanSas.Any(t => t.State != SettleBillState.未结状态)) { @@ -445,9 +445,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase } bbacSas.Add(bbacSaEntity); - bbacSaDetails = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum); - bbacCanSaDetails = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum); - bbacNotSaDetails = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum); + bbacSaDetails = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum).ConfigureAwait(false); + bbacCanSaDetails = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false); + bbacNotSaDetails = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false); } return (bbacSas, bbacSaDetails, bbacCanSas, bbacCanSaDetails, bbacNotSaDetails); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs index d54de401..907674da 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs @@ -140,6 +140,22 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase } } + if (!checkList.Any()) + { + //验证客户对应厂内零件号是否存在 + //导入的零件号集合 + var importPubSaLUs = (importCN1HBOPSaDetails.Select(t => t.LU).Union(importCN5HBOPSaDetails.Select(t => t.LU))).Distinct(); + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); + var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + + //不存在的客户零件号(差集) + var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); + noExistSettleMaterialCodes.ForEach(t => + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty)); + }); + } + if (checkList.Count > 0) { string fileName = await ExportErrorReportAsync(checkList); @@ -325,9 +341,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase var materialRelationships = new List(); #region 处理结算数据 - //销售价格 - var priceListEntitys = await _priceListRepository.GetAllAsync().ConfigureAwait(false); - hbpoSaDetails.ForEach(hbpoSaDetail => { hbpoSaDetail.SetId(GuidGenerator.Create()); @@ -342,34 +355,20 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase hbpoSaDetail.BillNum = hbpoSaBillNum; hbpoSaDetail.KeyCode = hbpoSaDetail.PN + hbpoSaDetail.LU; - - //根据物料号、结算日期获取价格 - var priceListEntity = priceListEntitys.Find(t => t.LU == hbpoSaDetail.LU && hbpoSaDetail.SettleDate > t.BeginTime && hbpoSaDetail.SettleDate < t.EndTime); - hbpoSaDetail.Price = priceListEntity?.Price ?? default; hbpoSaDetail.BusinessType = _businessType; }); //导入的零件号集合 var importPubSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct(); + //销售价格 + var priceListEntitys = _priceListRepository.Where(t => importPubSaLUs.Contains(t.LU)).ToList(); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); - var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); - - /* - * (不存在的客户零件号)差集 - * 转换为厂内零件号 - * 转换规则6个空格替换成“-” - */ - var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); - - noExistSettleMaterialCodes.ForEach(t => - { - var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType); - materialRelationships.Add(materialRelationship); - }); - - var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships); hbpoSaDetails.ForEach(hbpoSaDetail => { + //根据物料号、结算日期获取价格 + var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == hbpoSaDetail.LU && hbpoSaDetail.SettleDate >= t.BeginTime && hbpoSaDetail.SettleDate <= t.EndTime); + hbpoSaDetail.Price = priceListEntity?.Price ?? 0; + hbpoSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(" ", "-"); }); #endregion @@ -425,7 +424,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase //不可结算 List hbpoNotSaDetails = new List(); - var hbpoSaEntity = await _hbpoSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)); + var hbpoSaEntity = await _hbpoSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false); if (hbpoSaEntity != null) { //结算单据 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs index adc0e448..5efff9cf 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs @@ -454,6 +454,23 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty)); } } + + if (!checkList.Any()) + { + //验证客户对应厂内零件号是否存在 + //导入的零件号集合 + var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); + var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + + //不存在的客户零件号(差集) + var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); + noExistSettleMaterialCodes.ForEach(t => + { + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty)); + }); + } + return checkList; #endregion } @@ -499,11 +516,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase else { //销售价格 - var priceListEntitys = _priceListRepository.Join(lus, a => a.LU, b => b, (a, b) => a).ToList(); + var priceListEntitys = _priceListRepository.Where(t => lus.Contains(t.LU)).ToList(); pubSaDetails.ForEach(importPubSaDetail => { //根据物料号、结算日期获取价格 - var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime); + var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime); importPubSaDetail.Price = priceListEntity?.Price ?? 0; }); } @@ -511,25 +528,25 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase //导入的零件号集合 var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); - var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + //var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); - /* - * (不存在的客户零件号)差集 - * 转换为厂内零件号 - * 转换规则6个空格替换成“-” - */ - var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); + ///* + // * (不存在的客户零件号)差集 + // * 转换为厂内零件号 + // * 转换规则6个空格替换成“-” + // */ + //var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); - noExistSettleMaterialCodes.ForEach(t => - { - var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType); - materialRelationships.Add(materialRelationship); - }); + //noExistSettleMaterialCodes.ForEach(t => + //{ + // var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType); + // materialRelationships.Add(materialRelationship); + //}); var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships); pubSaDetails.ForEach(pubSaDetail => { - pubSaDetail.PartCode = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(" ", "-"); + pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(" ", "-"); }); #endregion diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs index 77e6062e..a357e541 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs @@ -3,9 +3,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.OpenApi.Extensions; using SettleAccount.Domain.BQ; using Shouldly; +using SqlSugar; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -49,22 +51,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task ExportAsync(PUB_SE_DETAIL_RequestDto input) { - input.Filters.Add(new FilterCondition("BusinessType", input.BusinessType.ToString(), EnumFilterAction.Equal, EnumFilterLogic.And)); - var businessTypeDisplayName = input.BusinessType.ToString(); - DisplayAttribute attributeOfType = input.BusinessType.GetAttributeOfType(); + var businessTypeDisplayName = string.Empty; + var strBusinessType = input.Filters.FirstOrDefault(t => t.Column == "businessType")?.Value; + var businessType = (EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), strBusinessType); + DisplayAttribute attributeOfType = businessType.GetAttributeOfType(); if (attributeOfType != null) { businessTypeDisplayName = attributeOfType.Name; } string fileName = $"{businessTypeDisplayName}发运数据_{Guid.NewGuid()}.xlsx"; - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); var dtos = ObjectMapper.Map, List>(entities); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExcelExporter(dtos); + var result = await _exportImporter.ExcelExporter(dtos).ConfigureAwait(false); result.ShouldNotBeNull(); - await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); + await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false); return fileName; } #endregion diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs new file mode 100644 index 00000000..171b6d77 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs @@ -0,0 +1,55 @@ +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; + +/// +/// 手动同步 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class HomeAppService : ApplicationService +{ + private readonly IServiceProvider _applicationServices; + + public HomeAppService(IHost host) + { + _applicationServices = host.Services; + } + + /// + /// 同步 + /// + [HttpPost] + public async Task 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(), + // EnumBusinessType.JisHBPO => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.MaiDanJianBBAC => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.MaiDanJianHBPO => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.ZhiGongJianBBAC => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.ZhiGongJianHBPO => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.BeiJian => scope.ServiceProvider.GetRequiredService(), + // EnumBusinessType.YinDuJian => scope.ServiceProvider.GetRequiredService(), + // _ => throw new ArgumentOutOfRangeException(nameof(jobDto.businessType), $"Not expected direction value: {jobDto.businessType}"), + //}; + //exportJob.ExportFile(jobDto.Id, jobDto.ExportName, jobDto.Propert); + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index 9df9f0f6..421b32ec 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -74,7 +74,7 @@ public class PriceListAppService : SettleAccountApplicationBase { var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService); + var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService).ConfigureAwait(false); List _checkls = new List(); _checkls.Add("1040"); _checkls.Add("1046"); @@ -82,35 +82,39 @@ public class PriceListAppService : SettleAccountApplicationBase result = result.Where(p => _checkls.Contains(p.Plant)).ToList(); var entityList = ObjectMapper.Map, List>(result); entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList(); + var contractNo = entityList.FirstOrDefault().ContractNo; #region 校验 - var lus = entityList.Select(p => p.LU).ToList(); - var priceListModelEntitys = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU)); - if (priceListModelEntitys.Count > 0) + if (entityList.Any()) { - var query = from item1 in priceListModelEntitys + var query = from item1 in entityList join item2 in entityList - on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } + on new { item1.LU } equals new { item2.LU } where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) select item1; foreach (var item in query) { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginTime}-{item.EndTime}与系统数据存在时间交集", string.Empty)); + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty)); } } if (checkList.Count > 0) { - string fileName = await ExportErrorReportAsync(checkList); + string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); } #endregion + var lus = entityList.Select(p => new { p.LU, p.ContractNo }); + var priceListModelEntitys = _priceListRepository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList(); + if (priceListModelEntitys.Any()) + { + await _priceListRepository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false); + } foreach (var item in entityList) { item.Update(GuidGenerator.Create()); } - - await _priceListManager.ImportAsync(entityList.ToList(), version); + await _priceListRepository.InsertManyAsync(entityList).ConfigureAwait(false); return new JsonResult(new { Code = 200, Message = "导入成功" }); } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index f79dd504..0820aa74 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -52,7 +52,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices { var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService); + var result = await _exportImporter.UploadExcelImportByHeadDesc(files, _excelImportService).ConfigureAwait(false); List _checkls = new List(); _checkls.Add("1040"); _checkls.Add("1046"); @@ -63,33 +63,36 @@ namespace Win.Sfs.SettleAccount.Entities.Prices entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList(); #region 校验 - var lus = entityList.Select(p => p.LU).ToList(); - var priceListBJModelEntitys = await _repository.GetListAsync(p => lus.Contains(p.LU)); - if (priceListBJModelEntitys.Count > 0) + if (entityList.Any()) { - var query = from item1 in priceListBJModelEntitys + var query = from item1 in entityList join item2 in entityList - on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } - where (item1.BeginDate > item2.BeginDate && item1.BeginDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.BeginDate < item1.EndDate) + on new { item1.LU } equals new { item2.LU } + where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate) select item1; foreach (var item in query) { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginDate}-{item.EndDate}与系统数据存在时间交集", string.Empty)); + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty)); } } if (checkList.Count > 0) { - string fileName = await ExportErrorReportAsync(checkList); + string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); } #endregion + var lus = entityList.Select(p => new { p.LU, p.ContractNo }); + var priceListModelEntitys = _repository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList(); + if (priceListModelEntitys.Any()) + { + await _repository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false); + } foreach (var item in entityList) { item.Update(GuidGenerator.Create()); } - - await _priceListManagerBJ.ImportAsync(entityList, version); + await _repository.InsertManyAsync(entityList).ConfigureAwait(false); return new JsonResult(new { Code = 200, Message = "导入成功" }); }