|
|
@ -105,70 +105,75 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
{ |
|
|
|
priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
|
|
|
|
} |
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian) |
|
|
|
List<PriceList> priceLists = new List<PriceList>(); |
|
|
|
var notlist = p_list;//JIT_ASN整发
|
|
|
|
foreach (var itm in notlist) |
|
|
|
{ |
|
|
|
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
|
var notlist = p_list;//JIT_ASN整发
|
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) |
|
|
|
var priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
|
|
.Where(t => t.LU == itm.LU) |
|
|
|
.Where(t => itm.SettleDate >= t.BeginTime && itm.SettleDate <= t.EndTime && t.ClientCode == itm.Site) |
|
|
|
.OrderByDescending(t => t.Date) |
|
|
|
.ThenByDescending(t => t.CreationTime) |
|
|
|
.FirstOrDefault(); |
|
|
|
if (priceListEntity != null) |
|
|
|
{ |
|
|
|
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>(); |
|
|
|
foreach (var itm in notlist) |
|
|
|
{ |
|
|
|
var priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
|
|
.Where(t => t.LU == itm.LU) |
|
|
|
.Where(t => itm.SettleDate >= t.BeginTime && itm.SettleDate <= t.EndTime && t.ClientCode == itm.Site) |
|
|
|
.OrderByDescending(t => t.Date) |
|
|
|
.ThenByDescending(t => t.CreationTime) |
|
|
|
.FirstOrDefault(); |
|
|
|
if (priceListEntity != null) |
|
|
|
{ |
|
|
|
itm.Price = priceListEntity.Price; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
itm.Price = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
var result1 = notlist.Where(p=>p.Price!=0); |
|
|
|
itm.Price = priceListEntity.Price; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
itm.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 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) |
|
|
|
{ |
|
|
|
deletenotList.AddRange(jit1); |
|
|
@ -181,6 +186,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
entity.State = SettleBillState.未结状态; |
|
|
|
entity.SettleBillNum = string.Empty; |
|
|
|
entity.BusinessType = first.BusinessType; |
|
|
|
|
|
|
|
entity.Site = "1040"; |
|
|
|
billList.Add(entity); |
|
|
|
foreach (var itm in jit1) |
|
|
@ -204,6 +210,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
partcode: itm.PartCode, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
{ |
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
} |
|
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
entityList.Add(detailEntity); |
|
|
@ -246,6 +256,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
); |
|
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
{ |
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
} |
|
|
|
entityList.Add(detailEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -284,180 +298,281 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
partcode: itm.PartCode, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
|
|
|
|
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(deletenotList).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(billList).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) |
|
|
|
|
|
|
|
if (jit4.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) |
|
|
|
deletenotList.AddRange(jit4); |
|
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var entity = new PUB_CAN_SA(); |
|
|
|
entity.SetId(Guid.NewGuid()); |
|
|
|
entity.BillNum = billNumber; |
|
|
|
entity.InvGroupNum = billNumber; |
|
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
entity.State = SettleBillState.未结状态; |
|
|
|
entity.SettleBillNum = string.Empty; |
|
|
|
entity.BusinessType = first.BusinessType; |
|
|
|
entity.Site = "104T"; |
|
|
|
billList.Add(entity); |
|
|
|
foreach (var itm in jit4) |
|
|
|
{ |
|
|
|
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 |
|
|
|
var detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm.KeyCode, |
|
|
|
version: itm.Version, |
|
|
|
billNum: billNumber, |
|
|
|
settleBillNum: itm.SettleBillNum, |
|
|
|
lU: itm.LU, |
|
|
|
pN: itm.PN, |
|
|
|
site: itm.Site, |
|
|
|
qty: itm.Qty, |
|
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price, |
|
|
|
businessType: itm.BusinessType, |
|
|
|
settleDate: itm.SettleDate, |
|
|
|
groupNum: itm.GroupNum, |
|
|
|
invGroupNum: billNumber, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
|
|
|
|
); |
|
|
|
_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) |
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
|
{ |
|
|
|
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; |
|
|
|
billDetails.Add(_detailEntity); |
|
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
|
} |
|
|
|
detailEntity.IndexNum = itm.IndexNum; |
|
|
|
detailEntity.RealPartCode = itm.RealPartCode; |
|
|
|
entityList.Add(detailEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
if (jit5.Count > 0) |
|
|
|
{ |
|
|
|
deletenotList.AddRange(jit5); |
|
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
|
var entity = new PUB_CAN_SA(); |
|
|
|
entity.SetId(Guid.NewGuid()); |
|
|
|
entity.BillNum = billNumber; |
|
|
|
entity.InvGroupNum = billNumber; |
|
|
|
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
|
entity.State = SettleBillState.未结状态; |
|
|
|
entity.SettleBillNum = string.Empty; |
|
|
|
entity.BusinessType = first.BusinessType; |
|
|
|
entity.Site = "1049"; |
|
|
|
billList.Add(entity); |
|
|
|
foreach (var itm in jit5) |
|
|
|
{ |
|
|
|
var detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
|
guid: GuidGenerator.Create(), |
|
|
|
keyCode: itm.KeyCode, |
|
|
|
version: itm.Version, |
|
|
|
billNum: billNumber, |
|
|
|
settleBillNum: itm.SettleBillNum, |
|
|
|
lU: itm.LU, |
|
|
|
pN: itm.PN, |
|
|
|
site: itm.Site, |
|
|
|
qty: itm.Qty, |
|
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price, |
|
|
|
businessType: itm.BusinessType, |
|
|
|
settleDate: itm.SettleDate, |
|
|
|
groupNum: itm.GroupNum, |
|
|
|
invGroupNum: billNumber, |
|
|
|
invbillnum: string.Empty, |
|
|
|
partcode: itm.PartCode, |
|
|
|
pobillnum: string.Empty |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); |
|
|
|
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(deletenotList).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkInsertAsync(billList).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; |
|
|
|
} |
|
|
|
} |
|
|
|