|
@ -99,45 +99,96 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
var bbac_not_list= query.Select(p => p.b).ToList(); |
|
|
var bbac_not_list= query.Select(p => p.b).ToList(); |
|
|
if(bbac_can_list.Count>0) |
|
|
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 billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
var entity = new BBAC_CAN_SA(); |
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
entity.SetId(Guid.NewGuid()); |
|
|
|
|
|
entity.BillNum = billNumber; |
|
|
if (part_group_big.Count > 0) |
|
|
entity.InvGroupNum = billNumber; |
|
|
{ |
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
foreach (var itm in part_group_big) |
|
|
entity.State = SettleBillState.未结状态; |
|
|
{ |
|
|
entity.SettleBillNum = string.Empty; |
|
|
var ls = bbac_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
entity.Site = "1040"; |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
entity.BusinessType = EnumBusinessType.JisBBAC; |
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
billList.Add(entity); |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
foreach (var itm in bbac_can_list) |
|
|
bbac_sa.BillNum = billNum; |
|
|
|
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1040"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
{ |
|
|
{ |
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
keyCode: itm.KeyCode, |
|
|
keyCode: itm1.KeyCode, |
|
|
version: itm.Version, |
|
|
version: itm1.Version, |
|
|
billNum: billNumber, |
|
|
billNum: billNum, |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
lU: itm.LU, |
|
|
lU: itm1.LU, |
|
|
pN: itm.PN, |
|
|
pN: itm1.PN, |
|
|
site: itm.Site, |
|
|
site: itm1.Site, |
|
|
qty: itm.Qty, |
|
|
qty: itm1.Qty, |
|
|
price: itm.Price, |
|
|
price: itm1.Price, |
|
|
category: itm.BusinessType, |
|
|
category: itm1.BusinessType, |
|
|
isReturn: itm.IsReturn, |
|
|
isReturn: itm1.IsReturn, |
|
|
settleDate: itm.SettleDate, |
|
|
settleDate: itm1.SettleDate, |
|
|
groupNum: itm.GroupNum, |
|
|
groupNum: itm1.GroupNum, |
|
|
invGroupNum: billNumber, |
|
|
invGroupNum: billNum, |
|
|
contactid: itm.ContractDocID, |
|
|
contactid: itm1.ContractDocID, |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm.PartCode |
|
|
partcode: itm1.PartCode |
|
|
); |
|
|
); |
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
billDetails.Add(_detailEntity); |
|
|
billDetails.Add(_detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
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 billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
|
|
|
bbac_sa.BillNum = billNum; |
|
|
|
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1040"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
|
|
|
{ |
|
|
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
|
|
version: itm1.Version, |
|
|
|
|
|
billNum: billNum, |
|
|
|
|
|
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: billNum, |
|
|
|
|
|
contactid: itm1.ContractDocID, |
|
|
|
|
|
invbillnum: string.Empty, |
|
|
|
|
|
partcode: itm1.PartCode |
|
|
|
|
|
); |
|
|
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if (jis2.Count > 0) |
|
|
if (jis2.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var pricelist = _dbcontext.Set<PriceList>().Where(p => p.ClientCode == "1046" && p.IsCancel == false).ToList(); |
|
|
var pricelist = _dbcontext.Set<PriceList>().Where(p => p.ClientCode == "1046" && p.IsCancel == false).ToList(); |
|
@ -175,45 +226,95 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
if (bbac_can_list.Count > 0) |
|
|
if (bbac_can_list.Count > 0) |
|
|
{ |
|
|
{ |
|
|
notlist.AddRange(bbac_not_list); |
|
|
notlist.AddRange(bbac_not_list); |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
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 entity = new BBAC_CAN_SA(); |
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
entity.SetId(Guid.NewGuid()); |
|
|
var part_group_small = t1.Where(p => p.Amt <10000000).ToList(); |
|
|
entity.BillNum = billNumber; |
|
|
if (part_group_big.Count > 0) |
|
|
entity.InvGroupNum = billNumber; |
|
|
{ |
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
foreach (var itm in part_group_big) |
|
|
entity.State = SettleBillState.未结状态; |
|
|
{ |
|
|
entity.SettleBillNum = string.Empty; |
|
|
var ls= bbac_can_list.Where(p=>p.LU==itm.LU).ToList(); |
|
|
entity.Site = "1046"; |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
entity.BusinessType = EnumBusinessType.JisBBAC; |
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
billList.Add(entity); |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
|
|
|
bbac_sa.BillNum = billNum; |
|
|
foreach (var itm in bbac_can_list) |
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
{ |
|
|
{ |
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
keyCode: itm.KeyCode, |
|
|
keyCode: itm1.KeyCode, |
|
|
version: itm.Version, |
|
|
version: itm1.Version, |
|
|
billNum: billNumber, |
|
|
billNum: billNum, |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
lU: itm.LU, |
|
|
lU: itm1.LU, |
|
|
pN: itm.PN, |
|
|
pN: itm1.PN, |
|
|
site: itm.Site, |
|
|
site: itm1.Site, |
|
|
qty: itm.Qty, |
|
|
qty: itm1.Qty, |
|
|
price: itm.Price, |
|
|
price: itm1.Price, |
|
|
category: itm.BusinessType, |
|
|
category: itm1.BusinessType, |
|
|
isReturn: itm.IsReturn, |
|
|
isReturn: itm1.IsReturn, |
|
|
settleDate: itm.SettleDate, |
|
|
settleDate: itm1.SettleDate, |
|
|
groupNum: itm.GroupNum, |
|
|
groupNum: itm1.GroupNum, |
|
|
invGroupNum: billNumber, |
|
|
invGroupNum: billNum, |
|
|
contactid: itm.ContractDocID, |
|
|
contactid: itm1.ContractDocID, |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm.PartCode |
|
|
partcode: itm1.PartCode |
|
|
); |
|
|
); |
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
billDetails.Add(_detailEntity); |
|
|
billDetails.Add(_detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
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 billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
|
|
var bbac_sa = new BBAC_CAN_SA(); |
|
|
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
|
|
|
bbac_sa.BillNum = billNum; |
|
|
|
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
|
|
|
{ |
|
|
|
|
|
var _detailEntity = new BBAC_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
|
|
version: itm1.Version, |
|
|
|
|
|
billNum: billNum, |
|
|
|
|
|
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: billNum, |
|
|
|
|
|
contactid: itm1.ContractDocID, |
|
|
|
|
|
invbillnum: string.Empty, |
|
|
|
|
|
partcode: itm1.PartCode |
|
|
|
|
|
); |
|
|
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
bool issucess = true; |
|
|
bool issucess = true; |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
{ |
|
|
{ |
|
@ -244,7 +345,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
{ |
|
|
{ |
|
|
if (billDetails.Count > 0) |
|
|
if (billDetails.Count > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var result = from a in _dbcontext.Set<BBAC_SA_DETAIL>() |
|
|
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 } |
|
|
join b in _dbcontext.Set<BBAC_CAN_SA_DETAIL>() on new { a.KeyCode, a.BusinessType } equals new { b.KeyCode, b.BusinessType } |
|
|
where a.Price == 0 |
|
|
where a.Price == 0 |
|
@ -326,43 +426,91 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
var hbpo_not_list = query.Select(p => p.b).ToList(); |
|
|
var hbpo_not_list = query.Select(p => p.b).ToList(); |
|
|
if (hbpo_can_list.Count > 0) |
|
|
if (hbpo_can_list.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
var t1 = hbpo_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 entity = new HBPO_CAN_SA(); |
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
entity.SetId(Guid.NewGuid()); |
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
entity.BillNum = billNumber; |
|
|
if (part_group_big.Count > 0) |
|
|
entity.InvGroupNum = billNumber; |
|
|
{ |
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
foreach (var itm in part_group_big) |
|
|
entity.State = SettleBillState.未结状态; |
|
|
{ |
|
|
entity.SettleBillNum = string.Empty; |
|
|
var ls = hbpo_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
entity.Site = "104T"; |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
entity.BusinessType =(businesstype== "JisHBPO")?EnumBusinessType.JisHBPO:EnumBusinessType.MaiDanJianHBPO ; |
|
|
var bbac_sa = new HBPO_CAN_SA(); |
|
|
billList.Add(entity); |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
notlist.AddRange(hbpo_not_list); |
|
|
bbac_sa.BillNum = billNum; |
|
|
foreach (var itm in hbpo_can_list) |
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
|
|
|
{ |
|
|
|
|
|
var _detailEntity = new HBPO_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
|
|
keyCode: itm1.KeyCode, |
|
|
|
|
|
version: itm1.Version, |
|
|
|
|
|
billNum: billNum, |
|
|
|
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
|
|
|
lU: itm1.LU, |
|
|
|
|
|
pN: itm1.PN, |
|
|
|
|
|
site: itm1.Site, |
|
|
|
|
|
qty: itm1.Qty, |
|
|
|
|
|
price: itm1.Price, |
|
|
|
|
|
businessType: itm1.BusinessType, |
|
|
|
|
|
settleDate: itm1.SettleDate, |
|
|
|
|
|
groupNum: itm1.GroupNum, |
|
|
|
|
|
invGroupNum: billNum, |
|
|
|
|
|
invbillnum: string.Empty, |
|
|
|
|
|
partcode: itm1.PartCode |
|
|
|
|
|
); |
|
|
|
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (part_group_small.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var partlist = part_group_small.Select(p => p.LU).ToList(); |
|
|
|
|
|
var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList(); |
|
|
|
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
|
|
var bbac_sa = new HBPO_CAN_SA(); |
|
|
|
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
|
|
|
bbac_sa.BillNum = billNum; |
|
|
|
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
|
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
|
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
|
|
|
bbac_sa.Site = "1046"; |
|
|
|
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
{ |
|
|
{ |
|
|
var _detailEntity = new HBPO_CAN_SA_DETAIL( |
|
|
var _detailEntity = new HBPO_CAN_SA_DETAIL( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
keyCode: itm.KeyCode, |
|
|
keyCode: itm1.KeyCode, |
|
|
version: itm.Version, |
|
|
version: itm1.Version, |
|
|
billNum: billNumber, |
|
|
billNum: billNum, |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
lU: itm.LU, |
|
|
lU: itm1.LU, |
|
|
pN: itm.PN, |
|
|
pN: itm1.PN, |
|
|
site: itm.Site, |
|
|
site: itm1.Site, |
|
|
qty: itm.Qty, |
|
|
qty: itm1.Qty, |
|
|
price: itm.Price, |
|
|
price: itm1.Price, |
|
|
businessType: itm.BusinessType, |
|
|
businessType: itm1.BusinessType, |
|
|
settleDate: itm.SettleDate, |
|
|
settleDate: itm1.SettleDate, |
|
|
groupNum: itm.GroupNum, |
|
|
groupNum: itm1.GroupNum, |
|
|
invGroupNum: billNumber, |
|
|
invGroupNum: billNum, |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm.PartCode |
|
|
partcode: itm1.PartCode |
|
|
); |
|
|
); |
|
|
_detailEntity.RealPartCode = itm.RealPartCode; |
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
billDetails.Add(_detailEntity); |
|
|
billDetails.Add(_detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
bool issucess = true; |
|
|
bool issucess = true; |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
using (var transaction = _dbcontext.Database.BeginTransaction()) |
|
|
{ |
|
|
{ |
|
|