From 660f04e6bcc6d2ae87e1f32cabc575279c501685 Mon Sep 17 00:00:00 2001 From: mahao Date: Fri, 14 Jul 2023 10:31:39 +0800 Subject: [PATCH] tj --- .../SettleAccount.HttpApi.Host/Program.cs | 10 +-- .../Entities/BQ/PUB_SA_SERVICE.cs | 63 ++++++++++++++++--- .../Controls/CentralizedControlAppService.cs | 31 +++++++++ 3 files changed, 91 insertions(+), 13 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs index 55acc2bc..90ac0bf8 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs @@ -29,11 +29,11 @@ namespace Win.Sfs.SettleAccount var configuration = new ConfigurationBuilder() -#if DEBUG - .AddJsonFile("appsettings.Development.json") -#else - .AddJsonFile("appsettings.json") -#endif +//#if DEBUG +// .AddJsonFile("appsettings.Development.json") +//#else +// .AddJsonFile("appsettings.json") +//#endif .Build(); 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 238b4ed8..ed325820 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 @@ -15,6 +15,7 @@ using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.Shared.RepositoryBase; @@ -37,11 +38,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// private readonly INormalEfCoreRepository _pubSaDetailRepository; + /// + /// PUB可结算仓储 + /// + private readonly INormalEfCoreRepository _pubCanSaRepository; + + /// + /// PUB可结算明细仓储 + /// + private readonly INormalEfCoreRepository _pubCanSaDetailRepository; + + /// + /// PUB不可结算明细仓储 + /// + private readonly INormalEfCoreRepository _pubNotSaDetailRepository; + + /// + /// 销售价格仓储 + /// + private readonly INormalEfCoreRepository _priceListRepository; + /// /// 构造 /// public PUB_SA_SERVICE(INormalEfCoreRepository repository, INormalEfCoreRepository pubSaDetailRepository, + INormalEfCoreRepository priceListRepository, IDistributedCache cache, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -50,6 +72,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { _repository = repository; _pubSaDetailRepository = pubSaDetailRepository; + _priceListRepository = priceListRepository; } #region 直供件 @@ -67,6 +90,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var result = await _exportImporter.UploadExcelImport(files, _excelImportService); var _ls = ObjectMapper.Map, List>(result); + //销售价格 + var priceListEntitys = await _priceListRepository.GetAllAsync(); + var billNum = GuidGenerator.Create().ToString(); var pubSa = new PUB_SA() { @@ -74,20 +100,41 @@ namespace Win.Sfs.SettleAccount.Entities.BQ State = "1" }; - _ls.ForEach(s => + _ls.ForEach(s => { - string[] luArr = s.LU.Split(" "); - var lus = luArr.Reverse(); - var result = lus.Aggregate(" ", (current, index) => current + index); - - //s.LU = s.LU.Replace(" ", "").Replace(" ", " "); + if (s.LU != null) + { + List luList = s.LU.Split(" ").ToList(); + s.LU = luList[0].Replace(" ", ""); + if (luList.Count > 1) + { + luList.RemoveAt(0); + luList.Reverse(); + var luAssemble = luList.Select(t => t.Replace(" ", "")); + s.LU += luAssemble.Aggregate(" ", (current, index) => current + index); + } + } + + s.LU = s.LU; s.BillNum = billNum; s.Site = "直供件"; s.KeyCode = s.LU + s.PN; + + var priceListEntity = priceListEntitys.Find(t => t.LU == s.LU && s.SettleDate > t.BeginTime && s.SettleDate < t.EndTime); + s.Price = priceListEntity?.Price ?? 0; }); - //await _repository.InsertAsync(pubSa); - //await _pubSaDetailRepository.InsertManyAsync(_ls); + //可结算 + var pubCanSa = new List(); + //不可结算 + var pubNotCanSa = new List(); + + + + + + await _repository.InsertAsync(pubSa); + await _pubSaDetailRepository.InsertManyAsync(_ls); return ApplicationConsts.SuccessStr; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs index 9efa0c95..de890cec 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs @@ -3,7 +3,9 @@ using Microsoft.AspNetCore.Mvc; using Shouldly; using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Win.Abp.Snowflakes; @@ -72,6 +74,35 @@ namespace Win.Sfs.SettleAccount.Entities.Controls var dtos = ObjectMapper.Map, List>(entities); return new PagedResultDto(totalCount, dtos); } + + /// + /// 新增实体 + /// + [HttpPost] + virtual public async Task CreateAsync(CentralizedControlCreateDto input) + { + var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault(); + + if (_first != null) + { + throw new BusinessException("001", "已经存在该期间,不能重复添加!"); + } + + var entity = new CentralizedControl( + GuidGenerator.Create(), + input.BranchId, + input.Year, + input.Period, + input.Year + input.Period, + input.State + ); + + await _repository.InsertAsync(entity); + + var dto = ObjectMapper.Map(entity); + return dto; + + } #endregion #region 开启、关闭