|
@ -1504,26 +1504,70 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var _ls = p_list.Select(p => p.AskBillNum); |
|
|
var _ls = p_list.Select(p => p.AskBillNum).ToList(); |
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
List<string> numlist = new List<string>(); |
|
|
_buffer.Append(" select distinct (C.AskBillNum)from V_TB_ASK_DETAIL C"); |
|
|
var askdetailList = db.V_TB_ASK_DETAIL.Where(q => _ls.Contains(q.AskBillNum) && q.IsDeleted == false).ToList().Distinct().ToList(); |
|
|
_buffer.Append(" left JOIN "); |
|
|
var asndetailList = db.V_TB_ASN_DETAIL.Where(q => _ls.Contains(q.AskBillNum) && q.IsDeleted == false).ToList(); |
|
|
_buffer.Append(" (select SUM(Qty) as Qty, a.PoLine, a.AskBillNum, a.PartCode from v_tb_asn_detail a where a.IsDeleted=0 "); |
|
|
if (askdetailList.Count() > 0) |
|
|
_buffer.Append(" group by a.PoLine, a.AskBillNum, a.PartCode) AS D "); |
|
|
|
|
|
_buffer.Append(" ON C.AskBillNum = D.AskBillNum AND C.PoLine = D.PoLine AND C.PartCode = D.PartCode "); |
|
|
|
|
|
_buffer.Append(" WHERE C.AskQty>isnull(D.Qty,0)"); |
|
|
|
|
|
_buffer.Append(" and c.AskBillNum in ('{0}')"); |
|
|
|
|
|
var _str = string.Format(_buffer.ToString(), string.Join("','", _ls.ToArray())); |
|
|
|
|
|
var _list = db.Database.SqlQuery<string>(_str).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.IsComplete = true; |
|
|
if (asndetailList.Count() > 0) |
|
|
if (_list.Contains(p.AskBillNum)) |
|
|
{ |
|
|
|
|
|
//按照看板号 行号 零件号分组
|
|
|
|
|
|
var list = asndetailList.GroupBy(p => new { p.AskBillNum, p.PoLine, p.PartCode }).Select(p => new { Sum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, AskBillNum = p.Key.AskBillNum, PartCode = p.Key.PartCode }).ToList(); |
|
|
|
|
|
askdetailList.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
var detail = list.FirstOrDefault(q => q.AskBillNum == p.AskBillNum && q.PoLine == p.PoLine && q.PartCode == p.PartCode); |
|
|
|
|
|
if (detail != null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (detail.Sum < p.AskQty) |
|
|
|
|
|
{ |
|
|
|
|
|
numlist.Add(p.AskBillNum); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
numlist.Add(p.AskBillNum); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if (numlist.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
if (numlist.Contains(p.AskBillNum)) |
|
|
|
|
|
{ |
|
|
|
|
|
p.IsComplete = false; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else // 全部没有
|
|
|
{ |
|
|
{ |
|
|
p.IsComplete = false; |
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
p.IsComplete = true; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
|
//StringBuilder _buffer = new StringBuilder();
|
|
|
|
|
|
//_buffer.Append(" select distinct (C.AskBillNum)from V_TB_ASK_DETAIL C");
|
|
|
|
|
|
//_buffer.Append(" left JOIN ");
|
|
|
|
|
|
//_buffer.Append(" (select SUM(Qty) as Qty, a.PoLine, a.AskBillNum, a.PartCode from v_tb_asn_detail a where a.IsDeleted=0 ");
|
|
|
|
|
|
//_buffer.Append(" group by a.PoLine, a.AskBillNum, a.PartCode) AS D ");
|
|
|
|
|
|
//_buffer.Append(" ON C.AskBillNum = D.AskBillNum AND C.PoLine = D.PoLine AND C.PartCode = D.PartCode ");
|
|
|
|
|
|
//_buffer.Append(" WHERE C.AskQty>isnull(D.Qty,0)");
|
|
|
|
|
|
//_buffer.Append(" and c.AskBillNum in ('{0}')");
|
|
|
|
|
|
//var _str = string.Format(_buffer.ToString(), string.Join("','", _ls.ToArray()));
|
|
|
|
|
|
//var _list = db.Database.SqlQuery<string>(_str).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
//p_list.ForEach(p =>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// p.IsComplete = true;
|
|
|
|
|
|
// if (_list.Contains(p.AskBillNum))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// p.IsComplete = false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return p_list; |
|
|
return p_list; |
|
|