|
@ -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
|
|
|
} |
|
|
} |
|
|