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 3dd37bcd..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
@@ -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;
@@ -104,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
@@ -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
}
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);