|
|
@ -97,7 +97,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int UpdateInsertHouseAndSanction(string json) |
|
|
|
|
|
|
|
|
public static bool UpdateInsertHouseAndSanction(string json) |
|
|
{ |
|
|
{ |
|
|
var entity = serializer.Deserialize<HouseAndSanctionEdit>(json); |
|
|
var entity = serializer.Deserialize<HouseAndSanctionEdit>(json); |
|
|
var exist = ClientServiceUtils.Exist<WeightBill>(entity.ID); |
|
|
var exist = ClientServiceUtils.Exist<WeightBill>(entity.ID); |
|
|
@ -106,6 +106,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
var detailExist = ClientServiceUtils.Exist<WeightBill_Detail>("WeightBill_ID", entity.ID); |
|
|
var detailExist = ClientServiceUtils.Exist<WeightBill_Detail>("WeightBill_ID", entity.ID); |
|
|
if (!detailExist) |
|
|
if (!detailExist) |
|
|
throw new Exception("过磅记录已被删除,提交失败!"); |
|
|
throw new Exception("过磅记录已被删除,提交失败!"); |
|
|
|
|
|
bool multilOrder = false; |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
//为了节省ID,把传过来的通过栋舍匹配,并到原有明细里。然后从新的集合里把上传的集合里不存在的剔除掉
|
|
|
//为了节省ID,把传过来的通过栋舍匹配,并到原有明细里。然后从新的集合里把上传的集合里不存在的剔除掉
|
|
|
@ -167,11 +168,9 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("Sanction_ID"), delete.Select(x => DQExpression.Value(x)).ToArray())); |
|
|
dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("Sanction_ID"), delete.Select(x => DQExpression.Value(x)).ToArray())); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var dUpdate = new DQUpdateDom(typeof(WeightBill_Detail)); |
|
|
|
|
|
dUpdate.Columns.Add(new DQUpdateColumn("Number", entity.Number)); |
|
|
|
|
|
dUpdate.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("WeightBill_ID", entity.ID), DQCondition.EQ("DeleteState", false))); |
|
|
|
|
|
session.ExecuteNonQuery(dUpdate); |
|
|
|
|
|
|
|
|
int oldNumber; |
|
|
|
|
|
UpdateWeightNumber(session, entity.ID, entity.Number.Value, out oldNumber); |
|
|
|
|
|
multilOrder = UpdateOrderNumber(session, entity.ID, entity.Number.Value, oldNumber); |
|
|
|
|
|
|
|
|
var update = new DQUpdateDom(typeof(WeightBill)); |
|
|
var update = new DQUpdateDom(typeof(WeightBill)); |
|
|
update.Columns.Add(new DQUpdateColumn("HogGrade_ID", entity.HogGrade_ID)); |
|
|
update.Columns.Add(new DQUpdateColumn("HogGrade_ID", entity.HogGrade_ID)); |
|
|
@ -186,7 +185,66 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
session.ExecuteNonQuery(update); |
|
|
session.ExecuteNonQuery(update); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
} |
|
|
} |
|
|
return 1; |
|
|
|
|
|
|
|
|
return multilOrder; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void UpdateWeightNumber(IDmoSession session, long weightID, int number, out int oldNumber) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(WeightBill_Detail))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("WeightBill_ID", weightID), DQCondition.EQ("DeleteState", false))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Number")); |
|
|
|
|
|
query.Range = SelectRange.Top(1); |
|
|
|
|
|
var r = query.EExecuteScalar<long, int?>(); |
|
|
|
|
|
oldNumber = r.Item2 ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
if (number == oldNumber) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var dUpdate = new DQUpdateDom(typeof(WeightBill_Detail)); |
|
|
|
|
|
dUpdate.Columns.Add(new DQUpdateColumn("Number", number)); |
|
|
|
|
|
dUpdate.Where.Conditions.Add(DQCondition.EQ("ID", r.Item1)); |
|
|
|
|
|
session.ExecuteNonQuery(dUpdate); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool UpdateOrderNumber(IDmoSession session, long weightID, int newNumber, int oldNumber) |
|
|
|
|
|
{ |
|
|
|
|
|
if (newNumber == oldNumber) |
|
|
|
|
|
return false; |
|
|
|
|
|
var unOrderNumber = HurryRecordUnOrderNumber(session, weightID); |
|
|
|
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("WeightBill_ID", weightID), DQCondition.EQ("DeleteState", false)));//, DQCondition.EQ("IsHurryButcher", false), DQCondition.EQ("IsDrop", false)
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("PlanNumber")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("IsHurryButcher")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("IsDrop")); |
|
|
|
|
|
var order = query.EExecuteList<long, int, bool, bool>(session); |
|
|
|
|
|
if (order.Count == 0) |
|
|
|
|
|
return false; |
|
|
|
|
|
var tags = order.Where(x => !x.Item3 && !x.Item4); |
|
|
|
|
|
if (tags.Count() == 0) |
|
|
|
|
|
return false; |
|
|
|
|
|
if (tags.Count() > 1) |
|
|
|
|
|
return true; |
|
|
|
|
|
else if (oldNumber - unOrderNumber - order.Sum(x => x.Item2) > 0) |
|
|
|
|
|
return true; |
|
|
|
|
|
var update = new DQUpdateDom(typeof(OrderDetail)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", tags.First().Item1)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PlanNumber", DQExpression.Add(DQExpression.Field("PlanNumber"), DQExpression.Value(newNumber - oldNumber)))); |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int HurryRecordUnOrderNumber(IDmoSession session, long wid) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("WeightBill_ID", wid), DQCondition.IsNull(DQExpression.Field("ToOrderDetail_ID")))); |
|
|
|
|
|
var rst = query.EExecuteScalar(session); |
|
|
|
|
|
if (rst != null) |
|
|
|
|
|
return Convert.ToInt32(rst); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static List<T> GetList<T>(long billID) |
|
|
static List<T> GetList<T>(long billID) |
|
|
|