|
@ -105,49 +105,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
{ |
|
|
{ |
|
|
priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
|
|
|
priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
|
|
|
} |
|
|
} |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian) |
|
|
|
|
|
{ |
|
|
|
|
|
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
|
|
|
var notlist = p_list;//JIT_ASN整发
|
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) |
|
|
|
|
|
{ |
|
|
|
|
|
var subqueryA = (from a in notlist |
|
|
|
|
|
where a.BusinessType == first.BusinessType |
|
|
|
|
|
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
Number = groupedData.Count(), |
|
|
|
|
|
groupedData.Key.GroupNum, |
|
|
|
|
|
groupedData.Key.SettleBillNum, |
|
|
|
|
|
groupedData.Key.Version, |
|
|
|
|
|
groupedData.Key.Site |
|
|
|
|
|
}).AsQueryable(); |
|
|
|
|
|
var subqueryB = (from a in notlist |
|
|
|
|
|
join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode } |
|
|
|
|
|
where a.SettleDate >= b.BeginTime && a.SettleDate <= b.EndTime && b.IsCancel == false |
|
|
|
|
|
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
Number = groupedData.Count(), |
|
|
|
|
|
groupedData.Key.GroupNum, |
|
|
|
|
|
groupedData.Key.SettleBillNum, |
|
|
|
|
|
groupedData.Key.Version, |
|
|
|
|
|
groupedData.Key.Site |
|
|
|
|
|
}).AsQueryable(); |
|
|
|
|
|
var result = from tmp1 in notlist |
|
|
|
|
|
join tmp2 in (from a in subqueryA |
|
|
|
|
|
join b in subqueryB on new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } equals new { b.GroupNum, b.SettleBillNum, b.Version, b.Site } |
|
|
|
|
|
where a.Number == b.Number |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
a.GroupNum, |
|
|
|
|
|
a.SettleBillNum, |
|
|
|
|
|
a.Version, |
|
|
|
|
|
a.Number |
|
|
|
|
|
}) |
|
|
|
|
|
on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum } |
|
|
|
|
|
select tmp1;//不可结
|
|
|
|
|
|
List<PriceList> priceLists = new List<PriceList>(); |
|
|
List<PriceList> priceLists = new List<PriceList>(); |
|
|
|
|
|
var notlist = p_list;//JIT_ASN整发
|
|
|
foreach (var itm in notlist) |
|
|
foreach (var itm in notlist) |
|
|
{ |
|
|
{ |
|
|
var priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
|
var priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
@ -165,10 +124,56 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
itm.Price = 0; |
|
|
itm.Price = 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
var result1 = notlist.Where(p=>p.Price!=0); |
|
|
var result1 = notlist.Where(p => p.Price != 0); |
|
|
|
|
|
|
|
|
|
|
|
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
|
|
|
|
|
|
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
|
|
|
|
|
|
//{
|
|
|
|
|
|
//var subqueryA = (from a in notlist
|
|
|
|
|
|
// where a.BusinessType == first.BusinessType
|
|
|
|
|
|
// group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
|
|
|
|
|
|
// select new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Number = groupedData.Count(),
|
|
|
|
|
|
// groupedData.Key.GroupNum,
|
|
|
|
|
|
// groupedData.Key.SettleBillNum,
|
|
|
|
|
|
// groupedData.Key.Version,
|
|
|
|
|
|
// groupedData.Key.Site
|
|
|
|
|
|
// }).AsQueryable();
|
|
|
|
|
|
//var subqueryB = (from a in notlist
|
|
|
|
|
|
// join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode }
|
|
|
|
|
|
// where a.SettleDate >= b.BeginTime && a.SettleDate <= b.EndTime && b.IsCancel == false
|
|
|
|
|
|
// group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
|
|
|
|
|
|
// select new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Number = groupedData.Count(),
|
|
|
|
|
|
// groupedData.Key.GroupNum,
|
|
|
|
|
|
// groupedData.Key.SettleBillNum,
|
|
|
|
|
|
// groupedData.Key.Version,
|
|
|
|
|
|
// groupedData.Key.Site
|
|
|
|
|
|
// }).AsQueryable();
|
|
|
|
|
|
//var result = from tmp1 in notlist
|
|
|
|
|
|
// join tmp2 in (from a in subqueryA
|
|
|
|
|
|
// join b in subqueryB on new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } equals new { b.GroupNum, b.SettleBillNum, b.Version, b.Site }
|
|
|
|
|
|
// where a.Number == b.Number
|
|
|
|
|
|
// select new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// a.GroupNum,
|
|
|
|
|
|
// a.SettleBillNum,
|
|
|
|
|
|
// a.Version,
|
|
|
|
|
|
// a.Number
|
|
|
|
|
|
// })
|
|
|
|
|
|
// on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum }
|
|
|
|
|
|
// select tmp1;//不可结
|
|
|
|
|
|
|
|
|
var jit1 = result1.Where(p => p.Site == "1040").ToList(); |
|
|
var jit1 = result1.Where(p => p.Site == "1040").ToList(); |
|
|
var jit2 = result1.Where(p => p.Site == "1046").ToList(); |
|
|
var jit2 = result1.Where(p => p.Site == "1046").ToList(); |
|
|
var jit3 = result.Where(p => p.Site == "1041").ToList(); |
|
|
var jit3 = result1.Where(p => p.Site == "1041").ToList(); |
|
|
|
|
|
var jit4= result1.Where(p => p.Site == "104T").ToList(); |
|
|
|
|
|
var jit5 = result1.Where(p => p.Site == "1049").ToList(); |
|
|
|
|
|
|
|
|
if (jit1.Count > 0) |
|
|
if (jit1.Count > 0) |
|
|
{ |
|
|
{ |
|
|
deletenotList.AddRange(jit1); |
|
|
deletenotList.AddRange(jit1); |
|
@ -181,6 +186,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
entity.State = SettleBillState.未结状态; |
|
|
entity.State = SettleBillState.未结状态; |
|
|
entity.SettleBillNum = string.Empty; |
|
|
entity.SettleBillNum = string.Empty; |
|
|
entity.BusinessType = first.BusinessType; |
|
|
entity.BusinessType = first.BusinessType; |
|
|
|
|
|
|
|
|
entity.Site = "1040"; |
|
|
entity.Site = "1040"; |
|
|
billList.Add(entity); |
|
|
billList.Add(entity); |
|
|
foreach (var itm in jit1) |
|
|
foreach (var itm in jit1) |
|
@ -204,6 +210,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
partcode: itm.PartCode, |
|
|
partcode: itm.PartCode, |
|
|
pobillnum: string.Empty |
|
|
pobillnum: string.Empty |
|
|
); |
|
|
); |
|
|
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
|
|
{ |
|
|
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
|
|
} |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
entityList.Add(detailEntity); |
|
|
entityList.Add(detailEntity); |
|
@ -246,6 +256,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
); |
|
|
); |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
|
|
{ |
|
|
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
|
|
} |
|
|
entityList.Add(detailEntity); |
|
|
entityList.Add(detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -284,180 +298,281 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
partcode: itm.PartCode, |
|
|
partcode: itm.PartCode, |
|
|
pobillnum: string.Empty |
|
|
pobillnum: string.Empty |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
|
|
{ |
|
|
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
|
|
} |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
entityList.Add(detailEntity); |
|
|
entityList.Add(detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
await _repository.DbContext.BulkDeleteAsync(deletenotList).ConfigureAwait(false); |
|
|
|
|
|
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); |
|
|
if (jit4.Count > 0) |
|
|
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) |
|
|
|
|
|
{ |
|
|
|
|
|
var _first = p_list.FirstOrDefault(); |
|
|
|
|
|
var pricelist = priceList.Where(p => p.ClientCode == "104T" && p.IsCancel == false).ToList(); |
|
|
|
|
|
var query1 = from d in p_list |
|
|
|
|
|
join p in pricelist |
|
|
|
|
|
on d.LU equals p.LU |
|
|
|
|
|
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T" |
|
|
|
|
|
select |
|
|
|
|
|
new |
|
|
|
|
|
{ |
|
|
|
|
|
a = new PUB_CAN_SA_DETAIL() |
|
|
|
|
|
{ |
|
|
|
|
|
Version = d.Version, |
|
|
|
|
|
KeyCode = d.KeyCode, |
|
|
|
|
|
Site = "104T", |
|
|
|
|
|
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 pub_can_list = query1.Select(p => p.a).ToList(); |
|
|
|
|
|
var pub_not_list = query1.Select(p => p.b).ToList(); |
|
|
|
|
|
if (pub_can_list.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var t1 = pub_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(); |
|
|
|
|
|
if (part_group_big.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var itm in part_group_big) |
|
|
|
|
|
{ |
|
|
|
|
|
var ls = pub_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
|
|
|
decimal sum = 0; |
|
|
|
|
|
List<PUB_CAN_SA_DETAIL> details = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
|
|
foreach (var itm1 in ls) |
|
|
|
|
|
{ |
|
|
|
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
|
|
|
if (sum > 10000000) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
deletenotList.AddRange(jit4); |
|
|
var bbac_sa = new PUB_CAN_SA(); |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
var entity = new PUB_CAN_SA(); |
|
|
bbac_sa.BillNum = billNum; |
|
|
entity.SetId(Guid.NewGuid()); |
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
entity.BillNum = billNumber; |
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
entity.InvGroupNum = billNumber; |
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
entity.State = SettleBillState.未结状态; |
|
|
bbac_sa.Site = "104T"; |
|
|
entity.SettleBillNum = string.Empty; |
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
entity.BusinessType = first.BusinessType; |
|
|
billList.Add(bbac_sa); |
|
|
entity.Site = "104T"; |
|
|
foreach (var itm2 in details) |
|
|
billList.Add(entity); |
|
|
|
|
|
foreach (var itm in jit4) |
|
|
{ |
|
|
{ |
|
|
itm2.SetBillNum(billNum); |
|
|
var detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
itm2.SetGroupNum(billNum); |
|
|
|
|
|
billDetails.Add(itm2); |
|
|
|
|
|
} |
|
|
|
|
|
details = new List<PUB_CAN_SA_DETAIL>(); |
|
|
|
|
|
sum = (itm1.Qty * itm1.Price); |
|
|
|
|
|
} |
|
|
|
|
|
var _detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
|
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
keyCode: itm1.KeyCode, |
|
|
keyCode: itm.KeyCode, |
|
|
version: itm1.Version, |
|
|
version: itm.Version, |
|
|
billNum: string.Empty, |
|
|
billNum: billNumber, |
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
lU: itm1.LU, |
|
|
lU: itm.LU, |
|
|
pN: itm1.PN, |
|
|
pN: itm.PN, |
|
|
site: itm1.Site, |
|
|
site: itm.Site, |
|
|
qty: itm1.Qty, |
|
|
qty: itm.Qty, |
|
|
price: itm1.Price, |
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price, |
|
|
businessType: itm1.BusinessType, |
|
|
businessType: itm.BusinessType, |
|
|
settleDate: itm1.SettleDate, |
|
|
settleDate: itm.SettleDate, |
|
|
groupNum: itm1.GroupNum, |
|
|
groupNum: itm.GroupNum, |
|
|
invGroupNum: string.Empty, |
|
|
invGroupNum: billNumber, |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm1.PartCode, |
|
|
partcode: itm.PartCode, |
|
|
pobillnum: itm1.PoBillNum |
|
|
pobillnum: string.Empty |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
|
|
details.Add(_detailEntity); |
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
} |
|
|
|
|
|
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
|
|
var bbac_sa1 = new PUB_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 = "104T"; |
|
|
|
|
|
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC; |
|
|
|
|
|
billList.Add(bbac_sa1); |
|
|
|
|
|
foreach (var detail in details) |
|
|
|
|
|
{ |
|
|
{ |
|
|
detail.SetBillNum(billNum1); |
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
detail.SetGroupNum(billNum1); |
|
|
|
|
|
billDetails.Add(detail); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
|
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
|
|
entityList.Add(detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (part_group_small.Count > 0) |
|
|
if (jit5.Count > 0) |
|
|
{ |
|
|
{ |
|
|
var partlist = part_group_small.Select(p => p.LU).ToList(); |
|
|
deletenotList.AddRange(jit5); |
|
|
var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList(); |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
var entity = new PUB_CAN_SA(); |
|
|
var bbac_sa = new PUB_CAN_SA(); |
|
|
entity.SetId(Guid.NewGuid()); |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
entity.BillNum = billNumber; |
|
|
bbac_sa.BillNum = billNum; |
|
|
entity.InvGroupNum = billNumber; |
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
entity.State = SettleBillState.未结状态; |
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
entity.SettleBillNum = string.Empty; |
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
entity.BusinessType = first.BusinessType; |
|
|
bbac_sa.Site = "104T"; |
|
|
entity.Site = "1049"; |
|
|
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; |
|
|
billList.Add(entity); |
|
|
billList.Add(bbac_sa); |
|
|
foreach (var itm in jit5) |
|
|
foreach (var itm1 in ls) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var _detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
var detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
guid: GuidGenerator.Create(), |
|
|
guid: GuidGenerator.Create(), |
|
|
keyCode: itm1.KeyCode, |
|
|
keyCode: itm.KeyCode, |
|
|
version: itm1.Version, |
|
|
version: itm.Version, |
|
|
billNum: billNum, |
|
|
billNum: billNumber, |
|
|
settleBillNum: itm1.SettleBillNum, |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
lU: itm1.LU, |
|
|
lU: itm.LU, |
|
|
pN: itm1.PN, |
|
|
pN: itm.PN, |
|
|
site: itm1.Site, |
|
|
site: itm.Site, |
|
|
qty: itm1.Qty, |
|
|
qty: itm.Qty, |
|
|
price: itm1.Price, |
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price, |
|
|
businessType: itm1.BusinessType, |
|
|
businessType: itm.BusinessType, |
|
|
settleDate: itm1.SettleDate, |
|
|
settleDate: itm.SettleDate, |
|
|
groupNum: itm1.GroupNum, |
|
|
groupNum: itm.GroupNum, |
|
|
invGroupNum: billNum, |
|
|
invGroupNum: billNumber, |
|
|
invbillnum: string.Empty, |
|
|
invbillnum: string.Empty, |
|
|
partcode: itm1.PartCode, |
|
|
partcode: itm.PartCode, |
|
|
pobillnum:itm1.PoBillNum |
|
|
pobillnum: string.Empty |
|
|
); |
|
|
); |
|
|
_detailEntity.RealPartCode = itm1.RealPartCode; |
|
|
|
|
|
billDetails.Add(_detailEntity); |
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
|
|
{ |
|
|
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
|
|
} |
|
|
|
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
|
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
|
|
entityList.Add(detailEntity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkDeleteAsync(deletenotList).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); |
|
|
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); |
|
|
} |
|
|
//}
|
|
|
} |
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
//if (first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var _first = p_list.FirstOrDefault();
|
|
|
|
|
|
// var pricelist = priceList.Where(p => p.ClientCode == "104T" && p.IsCancel == false).ToList();
|
|
|
|
|
|
// var query1 = from d in p_list
|
|
|
|
|
|
// join p in pricelist
|
|
|
|
|
|
// on d.LU equals p.LU
|
|
|
|
|
|
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T"
|
|
|
|
|
|
// select
|
|
|
|
|
|
// new
|
|
|
|
|
|
// {
|
|
|
|
|
|
// a = new PUB_CAN_SA_DETAIL()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Version = d.Version,
|
|
|
|
|
|
// KeyCode = d.KeyCode,
|
|
|
|
|
|
// Site = "104T",
|
|
|
|
|
|
// 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 pub_can_list = query1.Select(p => p.a).ToList();
|
|
|
|
|
|
// var pub_not_list = query1.Select(p => p.b).ToList();
|
|
|
|
|
|
// if (pub_can_list.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var t1 = pub_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();
|
|
|
|
|
|
// if (part_group_big.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (var itm in part_group_big)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var ls = pub_can_list.Where(p => p.LU == itm.LU).ToList();
|
|
|
|
|
|
// decimal sum = 0;
|
|
|
|
|
|
// List<PUB_CAN_SA_DETAIL> details = new List<PUB_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 PUB_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 = "104T";
|
|
|
|
|
|
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
|
|
|
|
|
|
// billList.Add(bbac_sa);
|
|
|
|
|
|
// foreach (var itm2 in details)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// itm2.SetBillNum(billNum);
|
|
|
|
|
|
// itm2.SetGroupNum(billNum);
|
|
|
|
|
|
// billDetails.Add(itm2);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// details = new List<PUB_CAN_SA_DETAIL>();
|
|
|
|
|
|
// sum = (itm1.Qty * itm1.Price);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// var _detailEntity = new PUB_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,
|
|
|
|
|
|
// businessType: itm1.BusinessType,
|
|
|
|
|
|
// settleDate: itm1.SettleDate,
|
|
|
|
|
|
// groupNum: itm1.GroupNum,
|
|
|
|
|
|
// invGroupNum: string.Empty,
|
|
|
|
|
|
// invbillnum: string.Empty,
|
|
|
|
|
|
// partcode: itm1.PartCode,
|
|
|
|
|
|
// pobillnum: itm1.PoBillNum
|
|
|
|
|
|
|
|
|
} |
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
// _detailEntity.RealPartCode = itm1.RealPartCode;
|
|
|
|
|
|
// details.Add(_detailEntity);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
|
|
|
|
|
|
// var bbac_sa1 = new PUB_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 = "104T";
|
|
|
|
|
|
// bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
|
|
|
|
|
|
// billList.Add(bbac_sa1);
|
|
|
|
|
|
// foreach (var detail in details)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// detail.SetBillNum(billNum1);
|
|
|
|
|
|
// detail.SetGroupNum(billNum1);
|
|
|
|
|
|
// billDetails.Add(detail);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (part_group_small.Count > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var partlist = part_group_small.Select(p => p.LU).ToList();
|
|
|
|
|
|
// var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList();
|
|
|
|
|
|
// var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
|
|
|
|
|
|
// var bbac_sa = new PUB_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 = "104T";
|
|
|
|
|
|
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
|
|
|
|
|
|
// billList.Add(bbac_sa);
|
|
|
|
|
|
// foreach (var itm1 in ls)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var _detailEntity = new PUB_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,
|
|
|
|
|
|
// pobillnum:itm1.PoBillNum
|
|
|
|
|
|
// );
|
|
|
|
|
|
// _detailEntity.RealPartCode = itm1.RealPartCode;
|
|
|
|
|
|
// foreach (var extra in itm1.ExtraProperties)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// billDetails.Add(_detailEntity);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false);
|
|
|
|
|
|
// await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false);
|
|
|
|
|
|
// await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
return errors; |
|
|
return errors; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|