|
|
@ -7,6 +7,7 @@ using System.Text.Json; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using LinqToDB; |
|
|
|
using Minio.DataModel; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using TaskJob.EventArgs; |
|
|
@ -18,6 +19,7 @@ using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win.Sfs.SettleAccount.Bases; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
|
|
using Win.Sfs.SettleAccount.Entities.CodeSettings; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.Shared.Filter; |
|
|
|
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData; |
|
|
@ -50,15 +52,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
bbacquery = bbacquery.Where(filers.ToLambda<BBAC_NOT_SA_DETAIL>()); |
|
|
|
} |
|
|
|
var p_list = bbacquery.ToList(); |
|
|
|
if (p_list.Count == 0) |
|
|
|
{ |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var jis1 = p_list.Where(p => p.Site == "1040").ToList(); |
|
|
|
var jis2 = p_list.Where(p => p.Site == "1046").ToList(); |
|
|
|
List<BBAC_NOT_SA_DETAIL> notlist = new List<BBAC_NOT_SA_DETAIL>(); |
|
|
@ -112,6 +107,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
foreach (var itm1 in ls) |
|
|
|
{ |
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
if (sum > 10000000) |
|
|
|
{ |
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
@ -156,7 +152,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
details.Add(_detailEntity); |
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
|
|
|
|
} |
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa1 = new BBAC_CAN_SA(); |
|
|
@ -171,9 +167,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
billList.Add(bbac_sa1); |
|
|
|
foreach (var detail in details) |
|
|
|
{ |
|
|
|
detail.SetBillNum(billNum1); |
|
|
|
detail.SetGroupNum(billNum1); |
|
|
|
billDetails.Add(detail); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (part_group_small.Count > 0) |
|
|
@ -263,7 +260,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
{ |
|
|
|
foreach (var itm in part_group_big) |
|
|
|
{ |
|
|
|
var ls= bbac_can_list.Where(p=>p.LU==itm.LU).ToList(); |
|
|
|
var ls = bbac_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
|
decimal sum = 0; |
|
|
|
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
foreach (var itm1 in ls) |
|
|
|
{ |
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
if (sum > 10000000) |
|
|
|
{ |
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
@ -275,13 +279,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
billList.Add(bbac_sa); |
|
|
|
foreach (var itm1 in ls) |
|
|
|
foreach (var itm2 in details) |
|
|
|
{ |
|
|
|
itm2.SetBillNum(billNum); |
|
|
|
itm2.SetGroupNum(billNum); |
|
|
|
billDetails.Add(itm2); |
|
|
|
} |
|
|
|
details = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
sum = 0; |
|
|
|
} |
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
version: itm1.Version, |
|
|
|
billNum: billNum, |
|
|
|
billNum: string.Empty, |
|
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
|
lU: itm1.LU, |
|
|
|
pN: itm1.PN, |
|
|
@ -292,13 +303,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
isReturn: itm1.IsReturn, |
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
invGroupNum: billNum, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
contactid: itm1.ContractDocID, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm1.PartCode |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
details.Add(_detailEntity); |
|
|
|
|
|
|
|
} |
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa1 = new BBAC_CAN_SA(); |
|
|
|
bbac_sa1.SetId(Guid.NewGuid()); |
|
|
|
bbac_sa1.BillNum = billNum1; |
|
|
|
bbac_sa1.InvGroupNum = billNum1; |
|
|
|
bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
bbac_sa1.State = SettleBillState.未结状态; |
|
|
|
bbac_sa1.SettleBillNum = string.Empty; |
|
|
|
bbac_sa1.Site = "1046"; |
|
|
|
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
billList.Add(bbac_sa1); |
|
|
|
foreach (var detail in details) |
|
|
|
{ |
|
|
|
detail.SetBillNum(billNum1); |
|
|
|
detail.SetGroupNum(billNum1); |
|
|
|
billDetails.Add(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -356,12 +385,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
_dbcontext.BulkInsert(billDetails);//插入可结主表
|
|
|
|
_dbcontext.BulkInsert(billList);//插入可结明细
|
|
|
|
} |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value=="True").ToList(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
_dbcontext.BulkDelete(ls); |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
transaction.Commit(); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
@ -393,12 +421,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value == "True").ToList(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
_dbcontext.BulkDelete(ls); |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
} |
|
|
|
} |
|
|
|
if (businesstype == "JisHBPO" || businesstype== "MaiDanJianHBPO") |
|
|
@ -412,15 +439,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
bbacquery = bbacquery.Where(filers.ToLambda<HBPO_NOT_SA_DETAIL>()); |
|
|
|
} |
|
|
|
var p_list = bbacquery.ToList(); |
|
|
|
if (p_list.Count == 0) |
|
|
|
{ |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
} |
|
|
|
var jis1 = p_list.Where(p => p.Site == "104T").ToList(); |
|
|
|
if (jis1.Count > 0) |
|
|
|
{ |
|
|
@ -462,13 +480,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
|
if (part_group_big.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var itm in part_group_big) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ls = hbpo_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
|
decimal sum = 0; |
|
|
|
List<HBPO_CAN_SA_DETAIL> details = new List<HBPO_CAN_SA_DETAIL>(); |
|
|
|
foreach (var itm1 in ls) |
|
|
|
{ |
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
if (sum > 10000000) |
|
|
|
{ |
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa = new HBPO_CAN_SA(); |
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
@ -477,16 +499,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
bbac_sa.Site = "104T"; |
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
billList.Add(bbac_sa); |
|
|
|
foreach (var itm1 in ls) |
|
|
|
foreach (var itm2 in details) |
|
|
|
{ |
|
|
|
itm2.SetBillNum(billNum); |
|
|
|
itm2.SetGroupNum(billNum); |
|
|
|
billDetails.Add(itm2); |
|
|
|
} |
|
|
|
details = new List<HBPO_CAN_SA_DETAIL>(); |
|
|
|
sum = 0; |
|
|
|
} |
|
|
|
var _detailEntity = new HBPO_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
version: itm1.Version, |
|
|
|
billNum: billNum, |
|
|
|
billNum: string.Empty, |
|
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
|
lU: itm1.LU, |
|
|
|
pN: itm1.PN, |
|
|
@ -496,12 +525,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
businessType: itm1.BusinessType, |
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
invGroupNum: billNum, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm1.PartCode |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
details.Add(_detailEntity); |
|
|
|
} |
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa1 = new HBPO_CAN_SA(); |
|
|
|
bbac_sa1.SetId(Guid.NewGuid()); |
|
|
|
bbac_sa1.BillNum = billNum1; |
|
|
|
bbac_sa1.InvGroupNum = billNum1; |
|
|
|
bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
bbac_sa1.State = SettleBillState.未结状态; |
|
|
|
bbac_sa1.SettleBillNum = string.Empty; |
|
|
|
bbac_sa1.Site = "1046"; |
|
|
|
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
billList.Add(bbac_sa1); |
|
|
|
foreach (var detail in details) |
|
|
|
{ |
|
|
|
detail.SetBillNum(billNum1); |
|
|
|
detail.SetGroupNum(billNum1); |
|
|
|
billDetails.Add(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -556,14 +602,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
_dbcontext.BulkDelete(notlist);//删除不可结数据
|
|
|
|
_dbcontext.BulkInsert(billDetails);//插入可结明细
|
|
|
|
_dbcontext.BulkInsert(billList);//插入可结主表
|
|
|
|
|
|
|
|
} |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "HBPO_NOT" && p.Value == "True").ToList(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
_dbcontext.BulkDelete(ls); |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
transaction.Commit(); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
@ -575,8 +619,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
if (issucess == true) |
|
|
|
{ |
|
|
|
var result = from a in _dbcontext.Set<BBAC_SA_DETAIL>() |
|
|
|
join b in _dbcontext.Set<BBAC_CAN_SA_DETAIL>() on new { a.KeyCode, a.BusinessType } equals new { b.KeyCode, b.BusinessType } |
|
|
|
var result = from a in _dbcontext.Set<HBPO_SA_DETAIL>() |
|
|
|
join b in _dbcontext.Set<HBPO_CAN_SA_DETAIL>() on new { a.KeyCode, a.BusinessType } equals new { b.KeyCode, b.BusinessType } |
|
|
|
where a.Price == 0 |
|
|
|
select new |
|
|
|
{ |
|
|
@ -592,12 +636,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var flaglist = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.IsReturn == true).ToList(); |
|
|
|
foreach (var flag in flaglist) |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "HBPO_NOT" && p.Value == "True").ToList(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
|
flag.IsReturn = false; |
|
|
|
_dbcontext.BulkDelete(ls); |
|
|
|
} |
|
|
|
_dbcontext.BulkUpdate(flaglist);//插入可结明细
|
|
|
|
} |
|
|
|
} |
|
|
|
return id.ToString(); |
|
|
|