|
|
@ -350,6 +350,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
|
|
|
|
var materialList = await _baseservice.GetMaterialList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
|
|
|
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities); |
|
|
|
var invdetail= await DetailQueryAsync(input); |
|
|
@ -379,139 +382,172 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var mgroup =m.Where(p => p.InvbillNum == itm.InvbillNum).ToList(); |
|
|
|
var adjp = adj.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); |
|
|
|
var nolist = not.Where(p => p.InvBillNum == itm.InvbillNum).ToList(); |
|
|
|
var lsC =nolist.Where(p => p.Extend1 == "可结算").ToList(); |
|
|
|
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList(); |
|
|
|
// var r = (from t1 in lsC
|
|
|
|
// join t2 in lsN on new { t1.LU, t1.SettleGroupNum }
|
|
|
|
// equals new { t2.LU, t2.SettleGroupNum }
|
|
|
|
|
|
|
|
// into temp
|
|
|
|
// from tm in temp.DefaultIfEmpty()
|
|
|
|
// select new INVOICE_NOT_SETTLE_EXT_DTO
|
|
|
|
// {
|
|
|
|
// RealInvBillNum = t1.RealInvBillNum,
|
|
|
|
// InvDate = t1.InvDate,
|
|
|
|
// InvBillNum = t1.InvBillNum,
|
|
|
|
// InvGroupNum = t1.InvGroupNum,
|
|
|
|
// SettleGroupNum = t1.SettleGroupNum,
|
|
|
|
// SettleLU = t1.LU,
|
|
|
|
// NotSettleLU = tm == null ? string.Empty : tm.LU,
|
|
|
|
// Qty = tm == null ? string.Empty : tm.Qty
|
|
|
|
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
//.Union
|
|
|
|
//(from t2 in lsN
|
|
|
|
// join t1 in lsC
|
|
|
|
// on new { t2.LU, t2.SettleGroupNum }
|
|
|
|
// equals new { t1.LU, t1.SettleGroupNum }
|
|
|
|
// into temp
|
|
|
|
// from tm in temp.DefaultIfEmpty()
|
|
|
|
// where tm == null
|
|
|
|
// select new INVOICE_NOT_SETTLE_EXT_DTO
|
|
|
|
// {
|
|
|
|
// RealInvBillNum = t2.RealInvBillNum,
|
|
|
|
// InvDate = t2.InvDate,
|
|
|
|
// InvBillNum = t2.InvBillNum,
|
|
|
|
// InvGroupNum = t2.InvGroupNum,
|
|
|
|
// SettleGroupNum = t2.SettleGroupNum,
|
|
|
|
// SettleLU = string.Empty,
|
|
|
|
// NotSettleLU = t2.LU,
|
|
|
|
// Qty = t2.Qty
|
|
|
|
|
|
|
|
// }
|
|
|
|
// );
|
|
|
|
|
|
|
|
//_excel.Append(r.OrderBy(p=>p.SettleGroupNum).ToList(), "结算分组零件" + itm.InvbillNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lsC = nolist.Where(p => p.Extend1 == "可结算") |
|
|
|
.GroupBy(p => new |
|
|
|
{ |
|
|
|
p.LU, |
|
|
|
p.RealInvBillNum, |
|
|
|
p.InvDate, |
|
|
|
p.InvBillNum, |
|
|
|
p.InvGroupNum, |
|
|
|
|
|
|
|
}).Select(p => new INVOICE_NOT_SETTLE_DTO() { |
|
|
|
LU =p.Key.LU, |
|
|
|
RealInvBillNum =p.Key.RealInvBillNum, |
|
|
|
InvDate =p.Key.InvDate, |
|
|
|
InvBillNum =p.Key.InvBillNum, |
|
|
|
InvGroupNum =p.Key.InvGroupNum, |
|
|
|
Qty=p.Sum(itm=>itm.Qty) |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList() |
|
|
|
.GroupBy(p => new |
|
|
|
{ |
|
|
|
p.LU, |
|
|
|
p.RealInvBillNum, |
|
|
|
p.InvDate, |
|
|
|
p.InvBillNum, |
|
|
|
p.InvGroupNum, |
|
|
|
|
|
|
|
}).Select(p => new INVOICE_NOT_SETTLE_DTO() |
|
|
|
{ |
|
|
|
LU = p.Key.LU, |
|
|
|
RealInvBillNum = p.Key.RealInvBillNum, |
|
|
|
InvDate = p.Key.InvDate, |
|
|
|
InvBillNum = p.Key.InvBillNum, |
|
|
|
InvGroupNum = p.Key.InvGroupNum, |
|
|
|
Qty = p.Sum(itm => itm.Qty) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var lineC = lsC.Count; |
|
|
|
var lineN = lsN.Count; |
|
|
|
List<INVOICE_NOT_SETTLE_EXT_DTO> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO>(); |
|
|
|
if (lineC > lineN)//可结大于不可结行数时
|
|
|
|
|
|
|
|
for (int i = 0; i < 10000; i++) |
|
|
|
{ |
|
|
|
for (int number = 0; number < lineC; number++) |
|
|
|
{ |
|
|
|
if (number + 1 > lineN) |
|
|
|
{ |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
|
|
|
|
|
|
|
|
|
entity.RealInvBillNum = lsC[number].RealInvBillNum; |
|
|
|
entity.InvDate = lsC[number].InvDate; |
|
|
|
entity.InvBillNum = lsC[number].InvBillNum; |
|
|
|
entity.InvGroupNum = lsC[number].InvGroupNum; |
|
|
|
entity.SettleGroupNum = lsC[number].SettleGroupNum; |
|
|
|
entity.SettleLU = lsC[number].LU; |
|
|
|
entity.SettleQty = lsC[number].Qty; |
|
|
|
entity.NotSettleLU = string.Empty; |
|
|
|
entity.Qty = string.Empty; |
|
|
|
ls.Add(entity); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
|
entity.RealInvBillNum = lsC[number].RealInvBillNum; |
|
|
|
entity.InvDate = lsC[number].InvDate; |
|
|
|
entity.InvBillNum = lsC[number].InvBillNum; |
|
|
|
entity.InvGroupNum = lsC[number].InvGroupNum; |
|
|
|
entity.SettleGroupNum = lsC[number].SettleGroupNum; |
|
|
|
entity.SettleLU = lsC[number].LU; |
|
|
|
entity.SettleQty= lsC[number].Qty; |
|
|
|
entity.NotSettleLU = lsN[number].LU; |
|
|
|
entity.Qty = lsN[number].Qty; |
|
|
|
ls.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO invnot = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
|
invnot.RealInvBillNum = string.Empty; |
|
|
|
invnot.InvDate = null; |
|
|
|
invnot.InvBillNum = string.Empty; |
|
|
|
invnot.InvGroupNum = string.Empty; |
|
|
|
invnot.SettleGroupNum = string.Empty; |
|
|
|
invnot.SettleLU = string.Empty; |
|
|
|
invnot.SettleQty = null; |
|
|
|
invnot.NotSettleLU = string.Empty; |
|
|
|
invnot.Qty = string.Empty; |
|
|
|
ls.Add(invnot); |
|
|
|
} |
|
|
|
else |
|
|
|
var entity= nolist.FirstOrDefault(); |
|
|
|
var disList = lsC.Select(p => p.SettleGroupNum).Distinct().ToList(); |
|
|
|
|
|
|
|
for (int i = 0; i < disList.Count; i++) |
|
|
|
{ |
|
|
|
for (int number = 0; number < lineN; number++) |
|
|
|
{ |
|
|
|
if (number + 1 > lineC)//不可结大于可结行数时
|
|
|
|
{ |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
|
entity.RealInvBillNum = lsN[number].RealInvBillNum; |
|
|
|
entity.InvDate = lsN[number].InvDate; |
|
|
|
entity.InvBillNum = lsN[number].InvBillNum; |
|
|
|
entity.InvGroupNum = lsN[number].InvGroupNum; |
|
|
|
entity.SettleGroupNum = lsN[number].SettleGroupNum; |
|
|
|
entity.SettleLU = string.Empty; |
|
|
|
entity.SettleQty = string.Empty; |
|
|
|
entity.NotSettleLU = lsN[number].LU; |
|
|
|
entity.Qty = lsN[number].Qty; |
|
|
|
ls.Add(entity); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO(); |
|
|
|
entity.RealInvBillNum = lsN[number].RealInvBillNum; |
|
|
|
entity.InvDate = lsN[number].InvDate; |
|
|
|
entity.InvBillNum = lsN[number].InvBillNum; |
|
|
|
entity.InvGroupNum = lsN[number].InvGroupNum; |
|
|
|
entity.SettleGroupNum = lsN[number].SettleGroupNum; |
|
|
|
entity.SettleLU = lsC[number].LU; |
|
|
|
entity.NotSettleLU = lsN[number].LU; |
|
|
|
entity.Qty = lsN[number].Qty; |
|
|
|
entity.SettleQty = lsC[number].Qty; |
|
|
|
ls.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
ls[i].SettleGroupNum = disList[i]; |
|
|
|
} |
|
|
|
|
|
|
|
var disList= ls.Select(p => p.SettleGroupNum).Distinct().ToList(); |
|
|
|
foreach (var de in ls) |
|
|
|
for (int i = 0; i < lineC; i++) |
|
|
|
{ |
|
|
|
de.SettleGroupNum = string.Empty; |
|
|
|
ls[i].RealInvBillNum = entity.RealInvBillNum; |
|
|
|
ls[i].InvDate = entity.InvDate; |
|
|
|
ls[i].InvBillNum = entity.InvBillNum; |
|
|
|
ls[i].InvGroupNum = entity.InvGroupNum; |
|
|
|
ls[i].SettleGroupNum = entity.SettleGroupNum; |
|
|
|
ls[i].SettleLU = lsC[i].LU; |
|
|
|
ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString(); |
|
|
|
} |
|
|
|
for (int i = 0; i < disList.Count; i++) |
|
|
|
for (int i = 0; i < lineN; i++) |
|
|
|
{ |
|
|
|
ls[i].SettleGroupNum = disList[i]; |
|
|
|
ls[i].RealInvBillNum = entity.RealInvBillNum; |
|
|
|
ls[i].InvDate = entity.InvDate; |
|
|
|
ls[i].InvBillNum = entity.InvBillNum; |
|
|
|
ls[i].InvGroupNum = entity.InvGroupNum; |
|
|
|
ls[i].SettleGroupNum = entity.SettleGroupNum; |
|
|
|
ls[i].NotSettleLU = lsN[i].LU; |
|
|
|
ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (lineC > lineN)//可结大于不可结行数时
|
|
|
|
//{
|
|
|
|
// for (int number = 0; number < lineC; number++)
|
|
|
|
// {
|
|
|
|
// if (number + 1 > lineN)
|
|
|
|
// {
|
|
|
|
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
|
|
|
|
// entity.RealInvBillNum = lsC[number].RealInvBillNum;
|
|
|
|
// entity.InvDate = lsC[number].InvDate;
|
|
|
|
// entity.InvBillNum = lsC[number].InvBillNum;
|
|
|
|
// entity.InvGroupNum = lsC[number].InvGroupNum;
|
|
|
|
// entity.SettleGroupNum = lsC[number].SettleGroupNum;
|
|
|
|
// entity.SettleLU = lsC[number].LU;
|
|
|
|
// entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString();
|
|
|
|
// entity.NotSettleLU = string.Empty;
|
|
|
|
// entity.Qty = string.Empty;
|
|
|
|
// ls.Add(entity);
|
|
|
|
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
|
|
|
|
// entity.RealInvBillNum = lsC[number].RealInvBillNum;
|
|
|
|
// entity.InvDate = lsC[number].InvDate;
|
|
|
|
// entity.InvBillNum = lsC[number].InvBillNum;
|
|
|
|
// entity.InvGroupNum = lsC[number].InvGroupNum;
|
|
|
|
// entity.SettleGroupNum = lsC[number].SettleGroupNum;
|
|
|
|
// entity.SettleLU = lsC[number].LU;
|
|
|
|
// entity.SettleQty= lsC[number].Qty==null?string.Empty:lsC[number].Qty.ToString();
|
|
|
|
// entity.NotSettleLU = lsN[number].LU;
|
|
|
|
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsC[number].Qty.ToString();
|
|
|
|
// ls.Add(entity);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// for (int number = 0; number < lineN; number++)
|
|
|
|
// {
|
|
|
|
// if (number + 1 > lineC)//不可结大于可结行数时
|
|
|
|
// {
|
|
|
|
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
|
|
|
|
// entity.RealInvBillNum = lsN[number].RealInvBillNum;
|
|
|
|
// entity.InvDate = lsN[number].InvDate;
|
|
|
|
// entity.InvBillNum = lsN[number].InvBillNum;
|
|
|
|
// entity.InvGroupNum = lsN[number].InvGroupNum;
|
|
|
|
// entity.SettleGroupNum = lsN[number].SettleGroupNum;
|
|
|
|
// entity.SettleLU = string.Empty;
|
|
|
|
// entity.SettleQty = string.Empty;
|
|
|
|
// entity.NotSettleLU = lsN[number].LU;
|
|
|
|
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString();
|
|
|
|
// ls.Add(entity);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
|
|
|
|
// entity.RealInvBillNum = lsN[number].RealInvBillNum;
|
|
|
|
// entity.InvDate = lsN[number].InvDate;
|
|
|
|
// entity.InvBillNum = lsN[number].InvBillNum;
|
|
|
|
// entity.InvGroupNum = lsN[number].InvGroupNum;
|
|
|
|
// entity.SettleGroupNum = lsN[number].SettleGroupNum;
|
|
|
|
// entity.SettleLU = lsC[number].LU;
|
|
|
|
// entity.NotSettleLU = lsN[number].LU;
|
|
|
|
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString(); ;
|
|
|
|
// entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString(); ;
|
|
|
|
// ls.Add(entity);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//var disList= ls.Select(p => p.SettleGroupNum).Distinct().ToList();
|
|
|
|
//foreach (var de in ls)
|
|
|
|
//{
|
|
|
|
// de.SettleGroupNum = string.Empty;
|
|
|
|
//}
|
|
|
|
//for (int i = 0; i < disList.Count; i++)
|
|
|
|
//{
|
|
|
|
// ls[i].SettleGroupNum = disList[i];
|
|
|
|
//}
|
|
|
|
_excel.Append(ls, "结算分组零件" + itm.InvbillNum); |
|
|
|
_excel.Append(mgroup, "发票结算分组对应" + itm.InvbillNum).SeparateBySheet(); |
|
|
|
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet(); |
|
|
|