|
|
@ -94,16 +94,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
PartCode = d.PartCode, |
|
|
|
Qty = d.Qty |
|
|
|
}, |
|
|
|
b=d |
|
|
|
b = d |
|
|
|
}; |
|
|
|
var bbac_can_list= query.Select(p => p.a).ToList(); |
|
|
|
var bbac_not_list= query.Select(p => p.b).ToList(); |
|
|
|
if(bbac_can_list.Count>0) |
|
|
|
var bbac_can_list = query.Select(p => p.a).ToList(); |
|
|
|
var bbac_not_list = query.Select(p => p.b).ToList(); |
|
|
|
if (bbac_can_list.Count > 0) |
|
|
|
{ |
|
|
|
notlist.AddRange(bbac_not_list); |
|
|
|
var t1 = bbac_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); |
|
|
|
var part_group_big = t1.Where(p=> p.Amt >= 10000000).ToList(); |
|
|
|
var part_group_small = t1.Where(p=> p.Amt < 10000000).ToList(); |
|
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
|
if (part_group_big.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var itm in part_group_big) |
|
|
@ -133,39 +133,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
itm2.SetGroupNum(billNum); |
|
|
|
billDetails.Add(itm2); |
|
|
|
} |
|
|
|
|
|
|
|
var test = details.Sum(p => p.Price * p.Qty); |
|
|
|
|
|
|
|
var count = details.Count; |
|
|
|
|
|
|
|
details = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
sum = itm1.Qty * itm1.Price; |
|
|
|
} |
|
|
|
|
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
version: itm1.Version, |
|
|
|
billNum: string.Empty, |
|
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
|
lU: itm1.LU, |
|
|
|
pN: itm1.PN, |
|
|
|
site: itm1.Site, |
|
|
|
qty: itm1.Qty, |
|
|
|
price: itm1.Price, |
|
|
|
category: itm1.BusinessType, |
|
|
|
isReturn: itm1.IsReturn, |
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
contactid: itm1.ContractDocID, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm1.PartCode |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
details.Add(_detailEntity); |
|
|
|
|
|
|
|
|
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
version: itm1.Version, |
|
|
|
billNum: string.Empty, |
|
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
|
lU: itm1.LU, |
|
|
|
pN: itm1.PN, |
|
|
|
site: itm1.Site, |
|
|
|
qty: itm1.Qty, |
|
|
|
price: itm1.Price, |
|
|
|
category: itm1.BusinessType, |
|
|
|
isReturn: itm1.IsReturn, |
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
contactid: itm1.ContractDocID, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm1.PartCode |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
details.Add(_detailEntity); |
|
|
|
} |
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa1 = new BBAC_CAN_SA(); |
|
|
@ -183,7 +177,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
detail.SetBillNum(billNum1); |
|
|
|
detail.SetGroupNum(billNum1); |
|
|
|
billDetails.Add(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (part_group_small.Count > 0) |
|
|
@ -238,28 +232,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "1046" |
|
|
|
select new |
|
|
|
{ |
|
|
|
a =new BBAC_CAN_SA_DETAIL() |
|
|
|
{ |
|
|
|
ContractDocID = d.ContractDocID, |
|
|
|
IsMaiDan = d.IsMaiDan, |
|
|
|
Version = d.Version, |
|
|
|
KeyCode = d.KeyCode, |
|
|
|
Site = "1046", |
|
|
|
BusinessType = d.BusinessType, |
|
|
|
ErpLoc = d.ErpLoc, |
|
|
|
CreationTime = d.CreationTime, |
|
|
|
GroupNum = d.GroupNum, |
|
|
|
InvGroupNum = d.InvGroupNum, |
|
|
|
LU = d.LU, |
|
|
|
PN = d.PN, |
|
|
|
SettleBillNum = d.SettleBillNum, |
|
|
|
Price = p.Price, |
|
|
|
SettleDate = d.SettleDate, |
|
|
|
RealPartCode = d.RealPartCode, |
|
|
|
PartCode = d.PartCode, |
|
|
|
Qty = d.Qty |
|
|
|
}, |
|
|
|
b = d |
|
|
|
a = new BBAC_CAN_SA_DETAIL() |
|
|
|
{ |
|
|
|
ContractDocID = d.ContractDocID, |
|
|
|
IsMaiDan = d.IsMaiDan, |
|
|
|
Version = d.Version, |
|
|
|
KeyCode = d.KeyCode, |
|
|
|
Site = "1046", |
|
|
|
BusinessType = d.BusinessType, |
|
|
|
ErpLoc = d.ErpLoc, |
|
|
|
CreationTime = d.CreationTime, |
|
|
|
GroupNum = d.GroupNum, |
|
|
|
InvGroupNum = d.InvGroupNum, |
|
|
|
LU = d.LU, |
|
|
|
PN = d.PN, |
|
|
|
SettleBillNum = d.SettleBillNum, |
|
|
|
Price = p.Price, |
|
|
|
SettleDate = d.SettleDate, |
|
|
|
RealPartCode = d.RealPartCode, |
|
|
|
PartCode = d.PartCode, |
|
|
|
Qty = d.Qty |
|
|
|
}, |
|
|
|
b = d |
|
|
|
}; |
|
|
|
var bbac_can_list = query.Select(p => p.a).ToList(); |
|
|
|
var bbac_not_list = query.Select(p => p.b).ToList(); |
|
|
@ -268,7 +262,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
notlist.AddRange(bbac_not_list); |
|
|
|
var t1 = bbac_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); |
|
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
|
var part_group_small = t1.Where(p => p.Amt <10000000).ToList(); |
|
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
|
if (part_group_big.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var itm in part_group_big) |
|
|
@ -279,7 +273,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
foreach (var itm1 in ls) |
|
|
|
{ |
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
|
|
|
|
if (sum > 10000000) |
|
|
|
{ |
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
@ -299,14 +292,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
itm2.SetGroupNum(billNum); |
|
|
|
billDetails.Add(itm2); |
|
|
|
} |
|
|
|
|
|
|
|
var test = details.Sum(p => p.Price * p.Qty); |
|
|
|
|
|
|
|
details = new List<BBAC_CAN_SA_DETAIL>(); |
|
|
|
sum = itm1.Qty * itm1.Price; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm1.KeyCode, |
|
|
@ -329,7 +317,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
); |
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
details.Add(_detailEntity); |
|
|
|
|
|
|
|
} |
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa1 = new BBAC_CAN_SA(); |
|
|
@ -353,7 +340,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
if (part_group_small.Count > 0) |
|
|
|
{ |
|
|
|
var partlist = part_group_small.Select(p => p.LU).ToList(); |
|
|
|
var ls=bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); |
|
|
|
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); |
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
@ -404,7 +391,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
_dbcontext.BulkInsert(billDetails);//插入可结主表
|
|
|
|
_dbcontext.BulkInsert(billList);//插入可结明细
|
|
|
|
} |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value=="True").ToList(); |
|
|
|
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value == "True").ToList(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
|
_dbcontext.BulkDelete(ls); |
|
|
@ -447,7 +434,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (businesstype == "JisHBPO" || businesstype== "MaiDanJianHBPO") |
|
|
|
if (businesstype == "JisHBPO" || businesstype == "MaiDanJianHBPO") |
|
|
|
{ |
|
|
|
List<HBPO_NOT_SA_DETAIL> notlist = new List<HBPO_NOT_SA_DETAIL>(); |
|
|
|
List<HBPO_CAN_SA> billList = new List<HBPO_CAN_SA>(); |
|
|
@ -509,7 +496,6 @@ 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(); |
|
|
@ -551,10 +537,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
site: itm1.Site, |
|
|
|
qty: itm1.Qty, |
|
|
|
price: itm1.Price, |
|
|
|
businessType: itm1.BusinessType, |
|
|
|
businessType: itm1.BusinessType, |
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
invGroupNum: string.Empty, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm1.PartCode |
|
|
|
); |
|
|
@ -620,7 +606,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
bool issucess = true; |
|
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
|
{ |
|
|
@ -641,7 +627,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
issucess = false;// 回滚事务
|
|
|
|
transaction.Rollback(); |
|
|
|
} |
|
|
|