|
|
@ -1,17 +1,9 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.LinqAsync; |
|
|
|
using System.Security.Policy; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using AutoMapper; |
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts; |
|
|
|
using DocumentFormat.OpenXml.Wordprocessing; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using FlexLabs.EntityFrameworkCore.Upsert.Internal; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using Volo.Abp; |
|
|
@ -162,7 +154,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
//结算分组号
|
|
|
|
var bbacSaGroupNums = importBBACSaDetails.Select(t => t.GroupNum).Distinct(); |
|
|
|
//已存在的结算分组号
|
|
|
|
var havBBACSaGroupNums = (await _bbacSaDetailRepository.GetListAsync(t => bbacSaGroupNums.Contains(t.GroupNum))).Select(t => t.GroupNum).Distinct(); |
|
|
|
var havBBACSaGroupNums = (await _bbacSaDetailRepository.GetListAsync(t => bbacSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct(); |
|
|
|
if (havBBACSaGroupNums.Any() == true) |
|
|
|
{ |
|
|
|
foreach (var item in havBBACSaGroupNums) |
|
|
@ -396,7 +388,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct(); |
|
|
|
//销售价格
|
|
|
|
var priceListEntitys = _priceListRepository.Where(t => importPubSaLUs.Contains(t.LU)).ToList(); |
|
|
|
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)); |
|
|
|
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); |
|
|
|
bbacSaDetails.ForEach(bbacSaDetail => |
|
|
|
{ |
|
|
|
//根据物料号、结算日期获取价格
|
|
|
@ -420,6 +412,19 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
|
|
|
|
#region 添加入库
|
|
|
|
await _bbacSaRepository.InsertAsync(bbacSa).ConfigureAwait(false); |
|
|
|
//存在买单将BBAC数据添加买单件BBAC主表数据
|
|
|
|
if (bbacSaDetails.Any(t => t.BusinessType == EnumBusinessType.MaiDanJianBBAC)) |
|
|
|
{ |
|
|
|
//买单件结算主表
|
|
|
|
await _bbacSaRepository.InsertAsync(new BBAC_SA() |
|
|
|
{ |
|
|
|
BillNum = bbacSaBillNum, |
|
|
|
State = "0", |
|
|
|
BusinessType = EnumBusinessType.MaiDanJianBBAC, |
|
|
|
Site = Site, |
|
|
|
Version = Version |
|
|
|
}).ConfigureAwait(false); |
|
|
|
} |
|
|
|
await _bbacSaDetailRepository.DbContext.BulkInsertAsync(bbacSaDetails).ConfigureAwait(false); |
|
|
|
if (bbacCanSaDetails.Count > 0) |
|
|
|
{ |
|
|
@ -443,7 +448,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
} |
|
|
|
if (materialRelationships.Count > 0) |
|
|
|
{ |
|
|
|
await _materialRelationshipRepository.InsertManyAsync(materialRelationships); |
|
|
|
await _materialRelationshipRepository.InsertManyAsync(materialRelationships).ConfigureAwait(false); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
@ -454,15 +459,15 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
private async Task<(List<BBAC_SA> bbacSas, List<BBAC_SA_DETAIL> bbacSaDetails, List<BBAC_CAN_SA> bbacCanSas, List<BBAC_CAN_SA_DETAIL> bbacCanSaDetails, List<BBAC_NOT_SA_DETAIL> bbacNotSaDetails)> GetBBACSaDelItemsAsync(Guid id) |
|
|
|
{ |
|
|
|
//结算主表
|
|
|
|
List<BBAC_SA> bbacSas = new List<BBAC_SA>(); |
|
|
|
var bbacSas = new List<BBAC_SA>(); |
|
|
|
//结算明细
|
|
|
|
List<BBAC_SA_DETAIL> bbacSaDetails = new List<BBAC_SA_DETAIL>(); |
|
|
|
var bbacSaDetails = new List<BBAC_SA_DETAIL>(); |
|
|
|
//可结算主表
|
|
|
|
List<BBAC_CAN_SA> bbacCanSas = new List<BBAC_CAN_SA>(); |
|
|
|
var bbacCanSas = new List<BBAC_CAN_SA>(); |
|
|
|
//可结算明细
|
|
|
|
List<BBAC_CAN_SA_DETAIL> bbacCanSaDetails = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
var bbacCanSaDetails = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
//不可结算
|
|
|
|
List<BBAC_NOT_SA_DETAIL> bbacNotSaDetails = new List<BBAC_NOT_SA_DETAIL>(); |
|
|
|
var bbacNotSaDetails = new List<BBAC_NOT_SA_DETAIL>(); |
|
|
|
var bbacSaEntity = await _bbacSaRepository.FindAsync(id).ConfigureAwait(false); |
|
|
|
if (bbacSaEntity != null) |
|
|
|
{ |
|
|
@ -476,7 +481,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
throw new UserFriendlyException($"{bbacSaBillNum} 该单据可结算单状态无法删除!", "400"); |
|
|
|
} |
|
|
|
|
|
|
|
bbacSas.Add(bbacSaEntity); |
|
|
|
bbacSas = await _bbacSaRepository.GetListAsync(t => t.BillNum == bbacSaBillNum).ConfigureAwait(false); |
|
|
|
bbacSaDetails = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum).ConfigureAwait(false); |
|
|
|
bbacCanSaDetails = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false); |
|
|
|
bbacNotSaDetails = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false); |
|
|
|