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