|
|
@ -20,6 +20,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|
|
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
@ -32,6 +33,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _relationRepository; |
|
|
|
|
|
|
|
private readonly ADJ_SERVICE _adjservice; |
|
|
|
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService, |
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
@ -42,6 +46,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, |
|
|
|
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, |
|
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, |
|
|
|
|
|
|
|
INormalEfCoreRepository<MaterialRelationship, Guid> relationRepository, |
|
|
|
|
|
|
|
BBAC_CAN_SA_MNG bbacMng, |
|
|
|
HBPO_CAN_SA_MNG hbpoMng, |
|
|
|
PUB_CAN_SA_MNG pubMng, |
|
|
@ -66,6 +73,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
service, |
|
|
|
baseservice) |
|
|
|
{ |
|
|
|
_relationRepository = relationRepository; |
|
|
|
_priceRepository = priceRepository; |
|
|
|
_adjservice = adjservice; |
|
|
|
} |
|
|
@ -77,13 +85,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <returns></returns>
|
|
|
|
public override async Task<IActionResult> ReissueInvoice([FromBody] string p_invbillnum) |
|
|
|
{ |
|
|
|
|
|
|
|
var version = int.Parse(DateTime.Now.ToString("yyyymm")); |
|
|
|
|
|
|
|
var inv = await GetInvoiceGroupByInvBillNum(p_invbillnum).ConfigureAwait(false); |
|
|
|
|
|
|
|
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (settle == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"选择发票:{p_invbillnum}对应的可结算单不在请检查!", "400"); |
|
|
@ -203,6 +211,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task<IActionResult> ReissueInvoiceExtend(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
|
{ |
|
|
|
|
|
|
|
var errorlist = await CheckRepeat(p_list).ConfigureAwait(false);//是否录入数据重复
|
|
|
|
if (errorlist.Count > 0) |
|
|
|
{ |
|
|
@ -237,6 +246,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
// var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
|
|
|
|
if (adjlist != null && adjlist.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
var relationList =_relationRepository.Where(p => p.BusinessType == inv.BusinessType); |
|
|
|
|
|
|
|
var relist= relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var itm in adjlist) |
|
|
|
{ |
|
|
|
bbaclist.Add(new BBAC_CAN_SA_DETAIL( |
|
|
@ -245,7 +260,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
version: itm.Version, |
|
|
|
billNum: itm.InvGroupNum, |
|
|
|
settleBillNum: itm.SettleBillNum, |
|
|
|
lU: itm.LU, |
|
|
|
lU: itm.LU, |
|
|
|
pN: itm.PN, |
|
|
|
site: itm.Site, |
|
|
|
qty: itm.Qty, |
|
|
@ -257,7 +272,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
invGroupNum: itm.InvGroupNum, |
|
|
|
contactid: itm.Extend1,//生产号
|
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode |
|
|
|
partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -331,6 +346,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
|
{ |
|
|
|
|
|
|
|
var result = await _adjservice.CheckImport(p_list).ConfigureAwait(false); |
|
|
|
if (result != "OK") |
|
|
|
{ |
|
|
@ -372,6 +388,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
|
|
|
|
if (adjlist != null && adjlist.Count > 0) |
|
|
|
{ |
|
|
|
var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); |
|
|
|
|
|
|
|
var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); |
|
|
|
var errorList=await CheckAdJRules(adjlist, relist.ToList(),inv.BusinessType); |
|
|
|
if (errorList.Count > 0) |
|
|
|
{ |
|
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var itm in adjlist) |
|
|
|
{ |
|
|
|
bbaclist.Add(new BBAC_CAN_SA_DETAIL( |
|
|
@ -392,7 +417,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
invGroupNum: itm.InvGroupNum, |
|
|
|
contactid: itm.Extend1,//生产号
|
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode |
|
|
|
partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -501,6 +526,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum).ConfigureAwait(false);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
|
|
|
|
if (adjlist != null && adjlist.Count > 0) |
|
|
|
{ |
|
|
|
var relationList = _relationRepository.Where(p => p.BusinessType == inv.BusinessType); |
|
|
|
var relist = relationList.GroupBy(p => new { p.SettleMaterialCode, p.ErpMaterialCode }).Select(p => p.FirstOrDefault()); |
|
|
|
var errorList = await CheckAdJRules(adjlist, relist.ToList(), inv.BusinessType); |
|
|
|
if (errorList.Count > 0) |
|
|
|
{ |
|
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var itm in adjlist) |
|
|
|
{ |
|
|
|
bbaclist.Add(new BBAC_CAN_SA_DETAIL( |
|
|
@ -521,7 +554,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
invGroupNum: itm.InvGroupNum, |
|
|
|
contactid: itm.Extend1,//生产号
|
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode |
|
|
|
partcode: relist.FirstOrDefault(p => p.SettleMaterialCode == itm.LU).ErpMaterialCode |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|