|
|
|
@ -150,7 +150,7 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
|
query.Columns.Add(DQSelectColumn.Max(detail, "Number")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(detail, "ID")); |
|
|
|
|
|
|
|
var list = new List<Tuple<long, int, int>>(); |
|
|
|
var list = new List<Tuple<long, int>>(); |
|
|
|
using (var reader = Session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
@ -161,19 +161,24 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
|
var last = item3 - item2; |
|
|
|
if (last < 0) |
|
|
|
throw new Exception(string.Format("过磅单明细ID{0} 头数{1} 已计划{2} 超出{3}", item1, item3, item2, -last)); |
|
|
|
list.Add(new Tuple<long, int, int>(item1, item2, last)); |
|
|
|
list.Add(new Tuple<long, int>(item1, item2)); |
|
|
|
} |
|
|
|
} |
|
|
|
foreach (var item in weightDetailIDs) |
|
|
|
{ |
|
|
|
if (!list.Any(x => x.Item1 == item)) |
|
|
|
list.Add(new Tuple<long, int>(item, 0)); |
|
|
|
} |
|
|
|
foreach (var item in list) |
|
|
|
UpdateReocrdPlanNumber(item); |
|
|
|
AfterUpdateRecord(weightDetailIDs); |
|
|
|
} |
|
|
|
|
|
|
|
private void UpdateReocrdPlanNumber(Tuple<long, int, int> item) |
|
|
|
private void UpdateReocrdPlanNumber(Tuple<long, int> item) |
|
|
|
{ |
|
|
|
var update = new DQUpdateDom(typeof(WeightBill_Record)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("PlanNumber", item.Item2)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("RemainNumber", item.Item3)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("RemainNumber", DQExpression.Subtract(DQExpression.Field("Number"), DQExpression.Value(item.Item2)))); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", item.Item1)); |
|
|
|
Session.ExecuteNonQuery(update); |
|
|
|
} |
|
|
|
|