|
|
@ -1,15 +1,18 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
|
using DocumentFormat.OpenXml.Office2010.Excel; |
|
|
|
using DocumentFormat.OpenXml.Wordprocessing; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore.Query.SqlExpressions; |
|
|
|
using SettleAccount.Bases; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using Volo.Abp; |
|
|
@ -22,10 +25,12 @@ using Win.Sfs.SettleAccount.Constant; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
using static System.Runtime.CompilerServices.RuntimeHelpers; |
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Bases; |
|
|
|
/// <summary>
|
|
|
@ -42,6 +47,8 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
protected readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _bbacRepository; |
|
|
|
protected readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubRepository; |
|
|
|
protected readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _hbpoRepository; |
|
|
|
protected readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
|
protected readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository; |
|
|
|
|
|
|
|
|
|
|
|
public ADJ_SERVICE( |
|
|
@ -54,7 +61,9 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
INormalEfCoreRepository<MaterialRelationship, Guid> relRepository, |
|
|
|
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> bbacRepository, |
|
|
|
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> pubRepository, |
|
|
|
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> hbpoRepository |
|
|
|
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> hbpoRepository, |
|
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository, |
|
|
|
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository |
|
|
|
|
|
|
|
) |
|
|
|
: base(excelImportService, snowflakeIdGenerator, commonManager) |
|
|
@ -65,7 +74,9 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
_baseDomainService = baseDomainService; |
|
|
|
_bbacRepository = bbacRepository; |
|
|
|
_pubRepository = pubRepository; |
|
|
|
_hbpoRepository= hbpoRepository; |
|
|
|
_hbpoRepository = hbpoRepository; |
|
|
|
_priceRepository = priceRepository; |
|
|
|
_pricebjRepository = pricebjRepository; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
///查询明细
|
|
|
@ -193,11 +204,11 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
{ |
|
|
|
itm.KeyCode = itm.PN + itm.LU.Replace(" ", "").Trim(); |
|
|
|
} |
|
|
|
var pnlist=p_list.Select(p => p.PN).Distinct(); |
|
|
|
|
|
|
|
var pnlist = p_list.Select(p => p.PN).Distinct(); |
|
|
|
int flag = 0; |
|
|
|
var keylist = p_list.Select(p => p.KeyCode).Distinct(); |
|
|
|
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>(); |
|
|
|
var first=p_list.FirstOrDefault(); |
|
|
|
var first = p_list.FirstOrDefault(); |
|
|
|
if (first != null) |
|
|
|
{ |
|
|
|
var inv = _invRepository.Where(p => p.InvbillNum == first.InvBillNum).FirstOrDefault(); |
|
|
@ -228,6 +239,7 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
} |
|
|
|
break; |
|
|
|
case EnumBusinessType.BeiJian: |
|
|
|
flag = 1; |
|
|
|
var errors3 = _pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
foreach (var p in errors3) |
|
|
|
{ |
|
|
@ -238,18 +250,18 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
var errors4 = _bbacRepository.Where(p => keylist.Contains(p.KeyCode)); |
|
|
|
foreach (var p in errors4) |
|
|
|
{ |
|
|
|
errorList.Add(new ERR_EXP_DTO() {Message=$"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); |
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); |
|
|
|
} |
|
|
|
break; |
|
|
|
case EnumBusinessType.JisHBPO: |
|
|
|
var errors5=_hbpoRepository.Where(p => keylist.Contains(p.KeyCode)); |
|
|
|
var errors5 = _hbpoRepository.Where(p => keylist.Contains(p.KeyCode)); |
|
|
|
foreach (var p in errors5) |
|
|
|
{ |
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); |
|
|
|
} |
|
|
|
break; |
|
|
|
case EnumBusinessType.YinDuJian: |
|
|
|
var errors6=_pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
var errors6 = _pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
foreach (var p in errors6) |
|
|
|
{ |
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在发货单{p.PN}数据,不能导入调整表" }); |
|
|
@ -281,8 +293,63 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorList) }); |
|
|
|
|
|
|
|
} |
|
|
|
List<PUB_ADJ_DETAIL_DTO> ls = new List<PUB_ADJ_DETAIL_DTO>(); |
|
|
|
if (flag == 1) |
|
|
|
{ |
|
|
|
var pricebjlist = _pricebjRepository.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var inner = from d in p_list |
|
|
|
join p in pricebjlist on d.LU equals p.LU |
|
|
|
where |
|
|
|
d.SettleDate >= p.BeginDate && d.SettleDate <= p.EndDate |
|
|
|
select |
|
|
|
new PUB_ADJ_DETAIL_DTO() |
|
|
|
{ |
|
|
|
InvBillNum = d.InvBillNum, |
|
|
|
SettleDate = d.SettleDate, |
|
|
|
LU = d.LU, |
|
|
|
PN = d.PN, |
|
|
|
Qty = d.Qty, |
|
|
|
GroupNum = d.GroupNum, |
|
|
|
KeyCode = d.KeyCode, |
|
|
|
Price = d.Price, |
|
|
|
}; |
|
|
|
|
|
|
|
ls = inner.ToList(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var pricelist = _priceRepository.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var inner = from d in p_list |
|
|
|
join p in pricelist on d.LU equals p.LU |
|
|
|
where |
|
|
|
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime |
|
|
|
select new PUB_ADJ_DETAIL_DTO() |
|
|
|
{ |
|
|
|
InvBillNum = d.InvBillNum, |
|
|
|
SettleDate = d.SettleDate, |
|
|
|
LU = d.LU, |
|
|
|
PN = d.PN, |
|
|
|
Qty = d.Qty, |
|
|
|
GroupNum = d.GroupNum, |
|
|
|
KeyCode = d.KeyCode, |
|
|
|
Price = d.Price, |
|
|
|
}; |
|
|
|
ls = inner.ToList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, Message = "校验成功" }); ; |
|
|
|
return new JsonResult(new { Code = 200, Message =ls }); ; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|