From f9e4a110195b568339a789c1a31c92ed9e0e6139 Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 1 Aug 2023 10:33:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/PUB_SA_SERVICE.cs | 150 ++++++++++++++---- 1 file changed, 123 insertions(+), 27 deletions(-) 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 3dd37bcd..49fe1f70 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 @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using SettleAccount.Domain.BQ; using Volo.Abp; using Volo.Abp.Application.Dtos; @@ -131,52 +132,109 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase public async Task DeleteAsync(Guid id) { //结算主表 - PUB_SA pubSaDelEntity; + List pubSas = new List(); //结算明细 - List pubSaDetailDelEntitys; + List pubSaDetails = new List(); //可结算主表 - List pubCanSaDelEntitys; + List pubCanSas = new List(); //可结算明细 - List pubCanSaDetailDelEntitys; + List pubCanSaDetails = new List(); //不可结算 - List pubNotSaDetailDelEntitys; + List pubNotSaDetails = new List(); - pubSaDelEntity = await _repository.FindAsync(id); - if (pubSaDelEntity == null) return; - //结算单据 - string pubSaBillNum = pubSaDelEntity.BillNum; + try + { + var pubSaDelItems = await GetPubSaDelItemsAsync(id); + pubSas.AddRange(pubSaDelItems.pubSas); + pubSaDetails.AddRange(pubSaDelItems.pubSaDetails); + pubCanSas.AddRange(pubSaDelItems.pubCanSas); + pubCanSaDetails.AddRange(pubSaDelItems.pubCanSaDetails); + pubNotSaDetails.AddRange(pubSaDelItems.pubNotSaDetails); + } + catch (Exception) + { + throw; + } + + //删除 + if (pubSas.Any()) + { + await _repository.DeleteManyAsync(pubSas); + } + if (pubSaDetails.Any()) + { + await _pubSaDetailRepository.DeleteManyAsync(pubSaDetails); + } + if (pubCanSas.Any()) + { + await _pubCanSaRepository.DeleteManyAsync(pubCanSas); + } + if (pubCanSaDetails.Any()) + { + await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetails); + } + if (pubNotSaDetails.Any()) + { + await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetails); + } + } + /// + /// 删除 + /// + [HttpPost] + public async Task DeleteListAsync(List ids) + { + //结算主表 + List pubSas = new List(); + //结算明细 + List pubSaDetails = new List(); + //可结算主表 + List pubCanSas = new List(); + //可结算明细 + List pubCanSaDetails = new List(); + //不可结算 + List pubNotSaDetails = new List(); - pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); - //验证可结算主表状态 - if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.未结状态)) + foreach (var id in ids) { - throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400"); - } + try + { + var pubSaDelItems = await GetPubSaDelItemsAsync(id); - pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum); - pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); - pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + pubSas.AddRange(pubSaDelItems.pubSas); + pubSaDetails.AddRange(pubSaDelItems.pubSaDetails); + pubCanSas.AddRange(pubSaDelItems.pubCanSas); + pubCanSaDetails.AddRange(pubSaDelItems.pubCanSaDetails); + pubNotSaDetails.AddRange(pubSaDelItems.pubNotSaDetails); + } + catch (Exception) + { + throw; + } + } //删除 - await _repository.DeleteAsync(pubSaDelEntity); - if (pubSaDetailDelEntitys.Any()) + if (pubSas.Any()) { - await _pubSaDetailRepository.DeleteManyAsync(pubSaDetailDelEntitys); + await _repository.DeleteManyAsync(pubSas); } - if (pubCanSaDelEntitys.Any()) + if (pubSaDetails.Any()) { - await _pubCanSaRepository.DeleteManyAsync(pubCanSaDelEntitys); + await _pubSaDetailRepository.DeleteManyAsync(pubSaDetails); } - if (pubCanSaDetailDelEntitys.Any()) + if (pubCanSas.Any()) { - await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetailDelEntitys); + await _pubCanSaRepository.DeleteManyAsync(pubCanSas); } - if (pubNotSaDetailDelEntitys.Any()) + if (pubCanSaDetails.Any()) { - await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetailDelEntitys); + await _pubCanSaDetailRepository.DeleteManyAsync(pubCanSaDetails); + } + if (pubNotSaDetails.Any()) + { + await _pubNotSaDetailRepository.DeleteManyAsync(pubNotSaDetails); } - } #endregion @@ -334,5 +392,43 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase return ApplicationConsts.SuccessStr; } + + /// + /// 获取结算关联项 + /// + private async Task<(List pubSas, List pubSaDetails, List pubCanSas, List pubCanSaDetails, List pubNotSaDetails)> GetPubSaDelItemsAsync(Guid id) + { + //结算主表 + List pubSas = new List(); + //结算明细 + List pubSaDetails = new List(); + //可结算主表 + List pubCanSas = new List(); + //可结算明细 + List pubCanSaDetails = new List(); + //不可结算 + List pubNotSaDetails = new List(); + + var pubSaEntity = await _repository.FirstOrDefaultAsync(t => t.Id.Equals(id)); + if (pubSaEntity != null) + { + //结算单据 + string pubSaBillNum = pubSaEntity.BillNum; + + pubCanSas = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + //验证可结算主表状态 + if (pubCanSas.Any(t => t.State != SettleBillState.未结状态) == false) + { + throw new UserFriendlyException($"{pubSaBillNum} 该单据可结算单状态无法删除!", "400"); + } + + pubSas.Add(pubSaEntity); + pubSaDetails = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum); + pubCanSaDetails = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + pubNotSaDetails = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); + } + + return (pubSas, pubSaDetails, pubCanSas , pubCanSaDetails, pubNotSaDetails); + } #endregion } From 2fb3883ef80fc5818d09f252dbbf7d5fbae2b2ea Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 1 Aug 2023 10:59:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?PUB=E7=BB=93=E7=AE=97=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Dtos/PUB_SA_DTO.cs | 17 +++++++++++++++++ .../Entities/BQ/PUB_SA_SERVICE.cs | 4 ++-- 2 files changed, 19 insertions(+), 2 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 f7c40795..afc591b0 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 @@ -1,4 +1,5 @@ using Magicodes.ExporterAndImporter.Core; +using Microsoft.AspNetCore.Http; using System; using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos; @@ -40,6 +41,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public EnumBusinessType BusinessType { get; set; } } + /// + /// 导入请求 + /// + public class PUB_SAImportRequestDto + { + /// + /// 文件 + /// + public IFormFileCollection Files { get; set; } + + /// + /// 是否是备件 + /// + 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 49fe1f70..57545332 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 @@ -105,9 +105,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase /// 导入 /// [HttpPost] - public async Task ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) + public async Task ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto) { - return await ImportAsync(files, businessType); + return await ImportAsync(pubSaImportRequestDto.Files, pubSaImportRequestDto.BusinessType); } #endregion From be7a182c2e31924f579270ac8de5d1717b0d99ac Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 1 Aug 2023 11:09:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8F=91=E8=BF=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=B7=BB=E5=8A=A0BusinessType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/PUB_SE_DETAIL_SERVICE.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 e5c9f289..9c9f127f 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 @@ -1,9 +1,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.OpenApi.Extensions; using SettleAccount.Domain.BQ; using Shouldly; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -45,9 +47,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// 导出 /// [HttpPost] - public async Task ExportAsync(RequestDto input) + public async Task ExportAsync(PUB_SE_DETAIL_RequestDto input) { - string fileName = $"PUB发运单_{Guid.NewGuid()}.xlsx"; + input.Filters.Add(new FilterCondition("BusinessType", input.BusinessType.ToString(), EnumFilterAction.Equal, EnumFilterLogic.And)); + var businessTypeDisplayName = input.BusinessType.GetDisplayName(); + + string fileName = $"{businessTypeDisplayName}发运数据_{Guid.NewGuid()}.xlsx"; var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); var dtos = ObjectMapper.Map, List>(entities);