姜旭之 1 year ago
parent
commit
ffde3ce5f1
  1. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 154
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs

17
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -1,4 +1,5 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Microsoft.AspNetCore.Http;
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -40,6 +41,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public EnumBusinessType BusinessType { get; set; } public EnumBusinessType BusinessType { get; set; }
} }
/// <summary>
/// 导入请求
/// </summary>
public class PUB_SAImportRequestDto
{
/// <summary>
/// 文件
/// </summary>
public IFormFileCollection Files { get; set; }
/// <summary>
/// 是否是备件
/// </summary>
public EnumBusinessType BusinessType { get; set; }
}
/// <summary> /// <summary>
/// 导入 /// 导入
/// </summary> /// </summary>

154
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.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -104,9 +105,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// 导入 /// 导入
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public async Task<string> ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) public async Task<string> ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto)
{ {
return await ImportAsync(files, businessType); return await ImportAsync(pubSaImportRequestDto.Files, pubSaImportRequestDto.BusinessType);
} }
#endregion #endregion
@ -131,52 +132,109 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
public async Task DeleteAsync(Guid id) public async Task DeleteAsync(Guid id)
{ {
//结算主表 //结算主表
PUB_SA pubSaDelEntity; List<PUB_SA> pubSas = new List<PUB_SA>();
//结算明细 //结算明细
List<PUB_SA_DETAIL> pubSaDetailDelEntitys; List<PUB_SA_DETAIL> pubSaDetails = new List<PUB_SA_DETAIL>();
//可结算主表 //可结算主表
List<PUB_CAN_SA> pubCanSaDelEntitys; List<PUB_CAN_SA> pubCanSas = new List<PUB_CAN_SA>();
//可结算明细 //可结算明细
List<PUB_CAN_SA_DETAIL> pubCanSaDetailDelEntitys; List<PUB_CAN_SA_DETAIL> pubCanSaDetails = new List<PUB_CAN_SA_DETAIL>();
//不可结算 //不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetailDelEntitys; List<PUB_NOT_SA_DETAIL> pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
pubSaDelEntity = await _repository.FindAsync(id); try
if (pubSaDelEntity == null) return; {
//结算单据 var pubSaDelItems = await GetPubSaDelItemsAsync(id);
string pubSaBillNum = pubSaDelEntity.BillNum; 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);
}
}
/// <summary>
/// 删除
/// </summary>
[HttpPost]
public async Task DeleteListAsync(List<Guid> ids)
{
//结算主表
List<PUB_SA> pubSas = new List<PUB_SA>();
//结算明细
List<PUB_SA_DETAIL> pubSaDetails = new List<PUB_SA_DETAIL>();
//可结算主表
List<PUB_CAN_SA> pubCanSas = new List<PUB_CAN_SA>();
//可结算明细
List<PUB_CAN_SA_DETAIL> pubCanSaDetails = new List<PUB_CAN_SA_DETAIL>();
//不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
pubCanSaDelEntitys = await _pubCanSaRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); foreach (var id in ids)
//验证可结算主表状态
if (pubCanSaDelEntitys.Any(t => t.State != SettleBillState.))
{ {
throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400"); try
} {
var pubSaDelItems = await GetPubSaDelItemsAsync(id);
pubSaDetailDelEntitys = await _pubSaDetailRepository.GetListAsync(t => t.BillNum == pubSaBillNum); pubSas.AddRange(pubSaDelItems.pubSas);
pubCanSaDetailDelEntitys = await _pubCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); pubSaDetails.AddRange(pubSaDelItems.pubSaDetails);
pubNotSaDetailDelEntitys = await _pubNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == pubSaBillNum); pubCanSas.AddRange(pubSaDelItems.pubCanSas);
pubCanSaDetails.AddRange(pubSaDelItems.pubCanSaDetails);
pubNotSaDetails.AddRange(pubSaDelItems.pubNotSaDetails);
}
catch (Exception)
{
throw;
}
}
//删除 //删除
await _repository.DeleteAsync(pubSaDelEntity); if (pubSas.Any())
if (pubSaDetailDelEntitys.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 #endregion
@ -334,5 +392,43 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
/// <summary>
/// 获取结算关联项
/// </summary>
private async Task<(List<PUB_SA> pubSas, List<PUB_SA_DETAIL> pubSaDetails, List<PUB_CAN_SA> pubCanSas, List<PUB_CAN_SA_DETAIL> pubCanSaDetails, List<PUB_NOT_SA_DETAIL> pubNotSaDetails)> GetPubSaDelItemsAsync(Guid id)
{
//结算主表
List<PUB_SA> pubSas = new List<PUB_SA>();
//结算明细
List<PUB_SA_DETAIL> pubSaDetails = new List<PUB_SA_DETAIL>();
//可结算主表
List<PUB_CAN_SA> pubCanSas = new List<PUB_CAN_SA>();
//可结算明细
List<PUB_CAN_SA_DETAIL> pubCanSaDetails = new List<PUB_CAN_SA_DETAIL>();
//不可结算
List<PUB_NOT_SA_DETAIL> pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
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 #endregion
} }

9
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.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Shouldly; using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -45,9 +47,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 导出 /// 导出
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public async Task<string> ExportAsync(RequestDto input) public async Task<string> 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 entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtos = ObjectMapper.Map<List<PUB_SE_DETAIL>, List<PUB_SE_DETAIL_EXPORT_DTO>>(entities); var dtos = ObjectMapper.Map<List<PUB_SE_DETAIL>, List<PUB_SE_DETAIL_EXPORT_DTO>>(entities);

Loading…
Cancel
Save