|
@ -105,70 +105,75 @@ 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) |
|
|
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 priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
|
var notlist = p_list;//JIT_ASN整发
|
|
|
.Where(t => t.LU == itm.LU) |
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) |
|
|
.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 |
|
|
itm.Price = priceListEntity.Price; |
|
|
where a.BusinessType == first.BusinessType |
|
|
} |
|
|
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData |
|
|
else |
|
|
select new |
|
|
{ |
|
|
{ |
|
|
itm.Price = 0; |
|
|
Number = groupedData.Count(), |
|
|
} |
|
|
groupedData.Key.GroupNum, |
|
|
} |
|
|
groupedData.Key.SettleBillNum, |
|
|
var result1 = notlist.Where(p => p.Price != 0); |
|
|
groupedData.Key.Version, |
|
|
|
|
|
groupedData.Key.Site |
|
|
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
|
|
|
}).AsQueryable(); |
|
|
//{
|
|
|
var subqueryB = (from a in notlist |
|
|
// var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
|
|
|
join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode } |
|
|
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
|
|
|
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 |
|
|
//var subqueryA = (from a in notlist
|
|
|
select new |
|
|
// where a.BusinessType == first.BusinessType
|
|
|
{ |
|
|
// group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
|
|
|
Number = groupedData.Count(), |
|
|
// select new
|
|
|
groupedData.Key.GroupNum, |
|
|
// {
|
|
|
groupedData.Key.SettleBillNum, |
|
|
// Number = groupedData.Count(),
|
|
|
groupedData.Key.Version, |
|
|
// groupedData.Key.GroupNum,
|
|
|
groupedData.Key.Site |
|
|
// groupedData.Key.SettleBillNum,
|
|
|
}).AsQueryable(); |
|
|
// groupedData.Key.Version,
|
|
|
var result = from tmp1 in notlist |
|
|
// groupedData.Key.Site
|
|
|
join tmp2 in (from a in subqueryA |
|
|
// }).AsQueryable();
|
|
|
join b in subqueryB on new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } equals new { b.GroupNum, b.SettleBillNum, b.Version, b.Site } |
|
|
//var subqueryB = (from a in notlist
|
|
|
where a.Number == b.Number |
|
|
// join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode }
|
|
|
select new |
|
|
// 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
|
|
|
a.GroupNum, |
|
|
// select new
|
|
|
a.SettleBillNum, |
|
|
// {
|
|
|
a.Version, |
|
|
// Number = groupedData.Count(),
|
|
|
a.Number |
|
|
// groupedData.Key.GroupNum,
|
|
|
}) |
|
|
// groupedData.Key.SettleBillNum,
|
|
|
on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum } |
|
|
// groupedData.Key.Version,
|
|
|
select tmp1;//不可结
|
|
|
// groupedData.Key.Site
|
|
|
List<PriceList> priceLists = new List<PriceList>(); |
|
|
// }).AsQueryable();
|
|
|
foreach (var itm in notlist) |
|
|
//var result = from tmp1 in notlist
|
|
|
{ |
|
|
// join tmp2 in (from a in subqueryA
|
|
|
var priceListEntity = priceList.Where(p => p.IsCancel == false) |
|
|
// 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(t => t.LU == itm.LU) |
|
|
// where a.Number == b.Number
|
|
|
.Where(t => itm.SettleDate >= t.BeginTime && itm.SettleDate <= t.EndTime && t.ClientCode == itm.Site) |
|
|
// select new
|
|
|
.OrderByDescending(t => t.Date) |
|
|
// {
|
|
|
.ThenByDescending(t => t.CreationTime) |
|
|
// a.GroupNum,
|
|
|
.FirstOrDefault(); |
|
|
// a.SettleBillNum,
|
|
|
if (priceListEntity != null) |
|
|
// a.Version,
|
|
|
{ |
|
|
// a.Number
|
|
|
itm.Price = priceListEntity.Price; |
|
|
// })
|
|
|
} |
|
|
// on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum }
|
|
|
else |
|
|
// select tmp1;//不可结
|
|
|
{ |
|
|
|
|
|
itm.Price = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
var result1 = notlist.Where(p=>p.Price!=0); |
|
|
|
|
|
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(); |
|
|
deletenotList.AddRange(jit4); |
|
|
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); |
|
|
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); |
|
|
var entity = new PUB_CAN_SA(); |
|
|
if (part_group_big.Count > 0) |
|
|
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 detailEntity = new PUB_CAN_SA_DETAIL( |
|
|
{ |
|
|
guid: GuidGenerator.Create(), |
|
|
var ls = pub_can_list.Where(p => p.LU == itm.LU).ToList(); |
|
|
keyCode: itm.KeyCode, |
|
|
decimal sum = 0; |
|
|
version: itm.Version, |
|
|
List<PUB_CAN_SA_DETAIL> details = new List<PUB_CAN_SA_DETAIL>(); |
|
|
billNum: billNumber, |
|
|
foreach (var itm1 in ls) |
|
|
settleBillNum: itm.SettleBillNum, |
|
|
{ |
|
|
lU: itm.LU, |
|
|
sum += (itm1.Qty * itm1.Price); |
|
|
pN: itm.PN, |
|
|
if (sum > 10000000) |
|
|
site: itm.Site, |
|
|
{ |
|
|
qty: itm.Qty, |
|
|
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); |
|
|
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price, |
|
|
var bbac_sa = new PUB_CAN_SA(); |
|
|
businessType: itm.BusinessType, |
|
|
bbac_sa.SetId(Guid.NewGuid()); |
|
|
settleDate: itm.SettleDate, |
|
|
bbac_sa.BillNum = billNum; |
|
|
groupNum: itm.GroupNum, |
|
|
bbac_sa.InvGroupNum = billNum; |
|
|
invGroupNum: billNumber, |
|
|
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); |
|
|
invbillnum: string.Empty, |
|
|
bbac_sa.State = SettleBillState.未结状态; |
|
|
partcode: itm.PartCode, |
|
|
bbac_sa.SettleBillNum = string.Empty; |
|
|
pobillnum: 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 |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
_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( |
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
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.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 |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var extra in itm.ExtraProperties) |
|
|
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); |
|
|
{ |
|
|
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); |
|
|
detailEntity.ExtraProperties.Add(extra.Key, extra.Value); |
|
|
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); |
|
|
} |
|
|
|
|
|
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; |
|
|
return errors; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|