From 7ab1098969ab77d11f0cf22149e12bfbba91267d Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 1 Aug 2023 09:15:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99?= =?UTF-8?q?=E4=B8=BB=E6=95=B0=E6=8D=AE=E5=88=97=E8=A1=A8=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialRelationship/MaterialRelationshipDtoBase.cs | 6 ------ 1 file changed, 6 deletions(-) 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 38c79f1b..7f9fbd09 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 @@ -91,12 +91,6 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships /// [Display(Name = "客户物料号")] public string SettleMaterialCode { get; set; } - - /// - /// 备注 - /// - [Display(Name = "备注")] - public string Remark { get; set; } } /// From 2bf7e25565fef29f236b9e64d64d6b28d9618565 Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 1 Aug 2023 09:35:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9PUB=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/PUB_SA_DTO.cs | 11 + .../Entities/BQ/PUB_SA_SERVICE.cs | 545 +++++++++--------- 2 files changed, 284 insertions(+), 272 deletions(-) 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 07693f0c..f7c40795 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 @@ -29,6 +29,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string State { get; set; } } + /// + /// 查询 + /// + public class PUB_SARequestDto : RequestDto + { + /// + /// 业务类别 + /// + public EnumBusinessType BusinessType { get; set; } + } + /// /// 导入 /// 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 7f65071e..3dd37bcd 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 @@ -20,318 +20,319 @@ using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.MaterialRelationships; +using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.RepositoryBase; -namespace Win.Sfs.SettleAccount.Entities.BQ +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// PUB结算 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class PUB_SA_SERVICE : SettleAccountApplicationBase { /// - /// PUB结算 + /// PUB结算仓储 + /// + private readonly INormalEfCoreRepository _repository; + + /// + /// PUB结算明细仓储 + /// + private readonly INormalEfCoreRepository _pubSaDetailRepository; + + /// + /// PUB可结算仓储 + /// + private readonly INormalEfCoreRepository _pubCanSaRepository; + + /// + /// PUB可结算明细仓储 + /// + private readonly INormalEfCoreRepository _pubCanSaDetailRepository; + + /// + /// PUB不可结算明细仓储 + /// + private readonly INormalEfCoreRepository _pubNotSaDetailRepository; + + /// + /// 销售价格仓储 + /// + private readonly INormalEfCoreRepository _priceListRepository; + + /// + /// 客户零件关系仓储 + /// + private readonly INormalEfCoreRepository _materialRelationshipRepository; + + /// + /// 替换件关系仓储 + /// + private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; + + /// + /// 构造 + /// + public PUB_SA_SERVICE(INormalEfCoreRepository repository, + INormalEfCoreRepository pubSaDetailRepository, + INormalEfCoreRepository pubCanSaRepository, + INormalEfCoreRepository pubCanSaDetailRepository, + INormalEfCoreRepository pubNotSaDetailRepository, + INormalEfCoreRepository priceListRepository, + INormalEfCoreRepository materialRelationshipRepository, + INormalEfCoreRepository tbRePartsRelationshipRepository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _repository = repository; + _pubSaDetailRepository = pubSaDetailRepository; + _pubCanSaRepository = pubCanSaRepository; + _pubCanSaDetailRepository = pubCanSaDetailRepository; + _pubNotSaDetailRepository = pubNotSaDetailRepository; + _priceListRepository = priceListRepository; + _materialRelationshipRepository = materialRelationshipRepository; + _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; + } + + #region 导入、导出 + /// + /// 导入 + /// + [HttpPost] + public async Task ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) + { + return await ImportAsync(files, businessType); + } + #endregion + + #region CURD + /// + /// 获取列表 /// - [AllowAnonymous] - [Route("api/settleaccount/[controller]/[action]")] - public class PUB_SA_SERVICE : SettleAccountApplicationBase + [HttpPost] + public async Task> GetListAsync(PUB_SARequestDto input) { - /// - /// PUB结算仓储 - /// - private readonly INormalEfCoreRepository _repository; - - /// - /// PUB结算明细仓储 - /// - private readonly INormalEfCoreRepository _pubSaDetailRepository; - - /// - /// PUB可结算仓储 - /// - private readonly INormalEfCoreRepository _pubCanSaRepository; - - /// - /// PUB可结算明细仓储 - /// - private readonly INormalEfCoreRepository _pubCanSaDetailRepository; - - /// - /// PUB不可结算明细仓储 - /// - private readonly INormalEfCoreRepository _pubNotSaDetailRepository; - - /// - /// 销售价格仓储 - /// - private readonly INormalEfCoreRepository _priceListRepository; - - /// - /// 客户零件关系仓储 - /// - private readonly INormalEfCoreRepository _materialRelationshipRepository; - - /// - /// 替换件关系仓储 - /// - private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository; - - /// - /// 构造 - /// - public PUB_SA_SERVICE(INormalEfCoreRepository repository, - INormalEfCoreRepository pubSaDetailRepository, - INormalEfCoreRepository pubCanSaRepository, - INormalEfCoreRepository pubCanSaDetailRepository, - INormalEfCoreRepository pubNotSaDetailRepository, - INormalEfCoreRepository priceListRepository, - INormalEfCoreRepository materialRelationshipRepository, - INormalEfCoreRepository tbRePartsRelationshipRepository, - IDistributedCache cache, - IExcelImportAppService excelImportService, - ISnowflakeIdGenerator snowflakeIdGenerator, - ICommonManager commonManager - ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + input.Filters.Add(new FilterCondition("BusinessType", input.BusinessType.ToString(), EnumFilterAction.Equal, EnumFilterLogic.And)); + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entities); + return new PagedResultDto(totalCount, dtos); + } + + /// + /// 删除 + /// + [HttpPost] + public async Task DeleteAsync(Guid id) + { + //结算主表 + PUB_SA pubSaDelEntity; + //结算明细 + List pubSaDetailDelEntitys; + //可结算主表 + List pubCanSaDelEntitys; + //可结算明细 + List pubCanSaDetailDelEntitys; + //不可结算 + List pubNotSaDetailDelEntitys; + + pubSaDelEntity = await _repository.FindAsync(id); + if (pubSaDelEntity == null) return; + //结算单据 + string pubSaBillNum = pubSaDelEntity.BillNum; + + + pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + //验证可结算主表状态 + if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.未结状态)) { - _repository = repository; - _pubSaDetailRepository = pubSaDetailRepository; - _pubCanSaRepository = pubCanSaRepository; - _pubCanSaDetailRepository = pubCanSaDetailRepository; - _pubNotSaDetailRepository = pubNotSaDetailRepository; - _priceListRepository = priceListRepository; - _materialRelationshipRepository = materialRelationshipRepository; - _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; + throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400"); } - #region 导入、导出 - /// - /// 导入 - /// - [HttpPost] - public async Task ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) + pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum); + pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + + //删除 + await _repository.DeleteAsync(pubSaDelEntity); + if (pubSaDetailDelEntitys.Any()) { - return await ImportAsync(files, businessType); + await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys); } - #endregion - - #region CURD - /// - /// 获取列表 - /// - [HttpPost] - public async Task> GetListAsync(RequestDto input) + if (pubCanSaDelEntitys.Any()) { - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); - var totalCount = await _repository.GetCountByFilterAsync(input.Filters); - var dtos = ObjectMapper.Map, List>(entities); - return new PagedResultDto(totalCount, dtos); + await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys); } - - /// - /// 删除 - /// - [HttpPost] - public async Task DeleteAsync(Guid id) + if (pubCanSaDetailDelEntitys.Any()) { - //结算主表 - PUB_SA pubSaDelEntity; - //结算明细 - List pubSaDetailDelEntitys; - //可结算主表 - List pubCanSaDelEntitys; - //可结算明细 - List pubCanSaDetailDelEntitys; - //不可结算 - List pubNotSaDetailDelEntitys; - - pubSaDelEntity = await _repository.FindAsync(id); - if (pubSaDelEntity == null) return; - //结算单据 - string pubSaBillNum = pubSaDelEntity.BillNum; - - - pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); - //验证可结算主表状态 - if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.未结状态)) - { - throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400"); - } + await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys); + } + if (pubNotSaDetailDelEntitys.Any()) + { + await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys); + } - pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum); - pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); - pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + } + #endregion - //删除 - await _repository.DeleteAsync(pubSaDelEntity); - if (pubSaDetailDelEntitys.Any()) - { - await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys); - } - if (pubCanSaDelEntitys.Any()) - { - await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys); - } - if (pubCanSaDetailDelEntitys.Any()) - { - await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys); - } - if (pubNotSaDetailDelEntitys.Any()) + #region 私有方法 + /// + /// 导入 + /// + private async Task ImportAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) + { + //数据校验 + var checkList = new List(); + //结算单号 + var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); + //结算主表 + var pubSa = new PUB_SA() + { + BillNum = pubSaBillNum, + State = "1", + BusinessType = businessType + }; + //结算明细 + var pubSaDetails = new List(); + //可结算单号 + var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C"); + //可结算主表 + var pubCanSa = new PUB_CAN_SA() + { + BillNum = pubCanSaBillNum, + SettleBillNum = pubSaBillNum, + State = SettleBillState.未结状态, + BusinessType = businessType + }; + //可结算明细 + var pubCanSaDetails = new List(); + //不可结算明细 + var pubNotSaDetails = new List(); + //客户零件关系 + var materialRelationships = new List(); + + + #region 导入数据转换、数据校验 + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var importPubSaDetails = ObjectMapper.Map, List>(result); + + //结算分组号 + var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct(); + + //已存在的结算分组号 + var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => pubSaGroupNums.Contains(t.GroupNum))).Select(t => t.GroupNum).Distinct(); + if (havPubSaGroupNums.Any() == true) + { + foreach (var item in havPubSaGroupNums) { - await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys); + checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty)); } + //throw new UserFriendlyException($"导入失败,结算分组号({string.Join(",", havPubSaGroupNums)})已存在", "400"); + } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); } #endregion - #region 私有方法 - /// - /// 导入 - /// - private async Task ImportAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) - { - //数据校验 - var checkList = new List(); - //结算单号 - var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); - //结算主表 - var pubSa = new PUB_SA() - { - BillNum = pubSaBillNum, - State = "1", - BusinessType = businessType - }; - //结算明细 - var pubSaDetails = new List(); - //可结算单号 - var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C"); - //可结算主表 - var pubCanSa = new PUB_CAN_SA() - { - BillNum = pubCanSaBillNum, - SettleBillNum = pubSaBillNum, - State = SettleBillState.未结状态, - BusinessType = businessType - }; - //可结算明细 - var pubCanSaDetails = new List(); - //不可结算明细 - var pubNotSaDetails = new List(); - //客户零件关系 - var materialRelationships = new List(); - - - #region 导入数据转换、数据校验 - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImport(files, _excelImportService); - var importPubSaDetails = ObjectMapper.Map, List>(result); - - //结算分组号 - var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct(); - - //已存在的结算分组号 - var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => pubSaGroupNums.Contains(t.GroupNum))).Select(t => t.GroupNum).Distinct(); - if (havPubSaGroupNums.Any() == true) - { - foreach (var item in havPubSaGroupNums) - { - checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty)); - } - //throw new UserFriendlyException($"导入失败,结算分组号({string.Join(",", havPubSaGroupNums)})已存在", "400"); - } - if (checkList.Count > 0) + #region 处理结算数据 + //销售价格 + var priceListEntitys = await _priceListRepository.GetAllAsync(); + + importPubSaDetails.ForEach(importPubSaDetail => + { + List luList = importPubSaDetail.LU.Split(" ").ToList(); + importPubSaDetail.LU = luList[0].Replace(" ", ""); + if (luList.Count > 1) { - return await ExportErrorReportAsync(checkList); + luList.RemoveAt(0); + var luAssemble = luList.Select(t => t.Replace(" ", "")); + importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); } - #endregion - - #region 处理结算数据 - //销售价格 - var priceListEntitys = await _priceListRepository.GetAllAsync(); + importPubSaDetail.BillNum = pubSaBillNum; + importPubSaDetail.Site = "XX工厂"; + importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU; - importPubSaDetails.ForEach(importPubSaDetail => - { - List luList = importPubSaDetail.LU.Split(" ").ToList(); - importPubSaDetail.LU = luList[0].Replace(" ", ""); - if (luList.Count > 1) - { - luList.RemoveAt(0); - var luAssemble = luList.Select(t => t.Replace(" ", "")); - importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); - } - - importPubSaDetail.BillNum = pubSaBillNum; - importPubSaDetail.Site = "XX工厂"; - importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU; - - //根据物料号、结算日期获取价格 - var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate > t.BeginTime && importPubSaDetail.SettleDate < t.EndTime); - importPubSaDetail.Price = priceListEntity?.Price ?? 0; - }); + //根据物料号、结算日期获取价格 + var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate > t.BeginTime && importPubSaDetail.SettleDate < t.EndTime); + importPubSaDetail.Price = priceListEntity?.Price ?? 0; + }); - //导入的零件号集合 - var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct(); - var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)); - var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); + //导入的零件号集合 + var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct(); + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)); + 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.ToString()); - materialRelationships.Add(materialRelationship); - }); - #endregion + noExistSettleMaterialCodes.ForEach(t => + { + var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType.ToString()); + materialRelationships.Add(materialRelationship); + }); + #endregion - #region 入库数据赋值 - //结算明细 - pubSaDetails = importPubSaDetails; + #region 入库数据赋值 + //结算明细 + pubSaDetails = importPubSaDetails; - //不可结算 结算分组号码(根据价格区分结算、不可结算) - var pubNotSaGroupNums = importPubSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct(); - var pubSaDetailsCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == false); - var pubSaDetailsNotCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == true); + //不可结算 结算分组号码(根据价格区分结算、不可结算) + var pubNotSaGroupNums = importPubSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct(); + var pubSaDetailsCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == false); + var pubSaDetailsNotCanSes = importPubSaDetails.FindAll(t => pubNotSaGroupNums.Contains(t.GroupNum) == true); - //可结算明细 - pubCanSaDetails = ObjectMapper.Map, List>(pubSaDetailsCanSes); - //不可结算明细 - pubNotSaDetails = ObjectMapper.Map, List>(pubSaDetailsNotCanSes); - #endregion + //可结算明细 + pubCanSaDetails = ObjectMapper.Map, List>(pubSaDetailsCanSes); + //不可结算明细 + pubNotSaDetails = ObjectMapper.Map, List>(pubSaDetailsNotCanSes); + #endregion - #region 添加入库 - await _repository.InsertAsync(pubSa); - await _pubSaDetailRepository.InsertManyAsync(importPubSaDetails); - if (pubCanSaDetails.Count > 0) - { - pubCanSa.InvGroupNum = pubCanSaDetails.Count.ToString(); - pubCanSaDetails.ForEach(pubCanSaDetail => - { - pubCanSaDetail.BillNum = pubCanSaDetail.InvGroupNum = pubCanSaBillNum; - pubCanSaDetail.BusinessType = businessType; - }); - - await _pubCanSaRepository.InsertAsync(pubCanSa); - await _pubCanSaDetailRepository.InsertManyAsync(pubCanSaDetails); - } - if (pubNotSaDetails.Count > 0) + #region 添加入库 + await _repository.InsertAsync(pubSa); + await _pubSaDetailRepository.InsertManyAsync(importPubSaDetails); + if (pubCanSaDetails.Count > 0) + { + pubCanSa.InvGroupNum = pubCanSaDetails.Count.ToString(); + pubCanSaDetails.ForEach(pubCanSaDetail => { - pubNotSaDetails.ForEach(pubNotSaDetail => - { - pubNotSaDetail.BusinessType = businessType; - }); + pubCanSaDetail.BillNum = pubCanSaDetail.InvGroupNum = pubCanSaBillNum; + pubCanSaDetail.BusinessType = businessType; + }); - await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails); - } - if (materialRelationships.Count > 0) + await _pubCanSaRepository.InsertAsync(pubCanSa); + await _pubCanSaDetailRepository.InsertManyAsync(pubCanSaDetails); + } + if (pubNotSaDetails.Count > 0) + { + pubNotSaDetails.ForEach(pubNotSaDetail => { - await _materialRelationshipRepository.InsertManyAsync(materialRelationships); - } - #endregion + pubNotSaDetail.BusinessType = businessType; + }); - return ApplicationConsts.SuccessStr; + await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails); + } + if (materialRelationships.Count > 0) + { + await _materialRelationshipRepository.InsertManyAsync(materialRelationships); } #endregion + + return ApplicationConsts.SuccessStr; } + #endregion }