|
|
|
@ -18,34 +18,20 @@ namespace ButcherFactory.BO.LocalBL |
|
|
|
{ |
|
|
|
const string RpcPath = @"/MainSystem/B3ClientService/Rpcs/CarcassInStoreRpc/"; |
|
|
|
|
|
|
|
public static CarcassInStore Insert(long? workUnitID, long batchID, long goodsID, string barCode) |
|
|
|
public static CarcassInStore Insert(long? workUnitID, long batchID, decimal weight) |
|
|
|
{ |
|
|
|
using (var session = DmoSession.New()) |
|
|
|
{ |
|
|
|
var exist = CheckExist(barCode, session); |
|
|
|
if (exist) |
|
|
|
throw new Exception("条码已使用过"); |
|
|
|
var entity = new CarcassInStore(); |
|
|
|
entity.WorkUnit_ID = workUnitID; |
|
|
|
entity.ProductBatch_ID = batchID; |
|
|
|
entity.UserID = AppContext.Worker.ID; |
|
|
|
entity.Goods_ID = goodsID; |
|
|
|
entity.BarCode = barCode; |
|
|
|
entity.Weight = weight; |
|
|
|
entity.RowIndex = GenerateRowIndex(session, batchID); |
|
|
|
session.Insert(entity); |
|
|
|
session.Commit(); |
|
|
|
return entity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static bool CheckExist(string barCode, IDmoSession session) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(barCode)) |
|
|
|
return false; |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore))); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
return query.EExecuteScalar(session) != null; |
|
|
|
} |
|
|
|
|
|
|
|
static int GenerateRowIndex(IDmoSession session, long batchID) |
|
|
|
@ -56,13 +42,17 @@ namespace ButcherFactory.BO.LocalBL |
|
|
|
return (query.EExecuteScalar<int?>(session) ?? 0) + 1; |
|
|
|
} |
|
|
|
|
|
|
|
public static void FillWeight(long id, decimal weight) |
|
|
|
public static void FillCodeAndGoods(long id, string barCode, long goodsID) |
|
|
|
{ |
|
|
|
using (var session = DmoSession.New()) |
|
|
|
{ |
|
|
|
var exist = CheckExist(barCode, session); |
|
|
|
if (exist) |
|
|
|
throw new Exception("条码已使用过"); |
|
|
|
var update = new DQUpdateDom(typeof(CarcassInStore)); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Weight", weight)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("BarCode", barCode)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Goods_ID", goodsID)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Sync", false)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1)))); |
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
@ -70,22 +60,32 @@ namespace ButcherFactory.BO.LocalBL |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static bool CheckExist(string barCode, IDmoSession session) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(barCode)) |
|
|
|
return false; |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore))); |
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
return query.EExecuteScalar(session) != null; |
|
|
|
} |
|
|
|
|
|
|
|
public static BindingList<CarcassInStore> GetLocalDataWithState(bool history) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("RowIndex")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
if (history) |
|
|
|
{ |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BeforeWeight")); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("Weight"))); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("Goods_ID"))); |
|
|
|
query.Range = SelectRange.Top(30); |
|
|
|
} |
|
|
|
else |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("Weight"))); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("Goods_ID"))); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
|
var result = new BindingList<CarcassInStore>(); |
|
|
|
using (var session = DmoSession.New()) |
|
|
|
@ -98,11 +98,11 @@ namespace ButcherFactory.BO.LocalBL |
|
|
|
result.Add(entity); |
|
|
|
entity.RowIndex = (int?)reader[0]; |
|
|
|
entity.ID = (long)reader[1]; |
|
|
|
entity.BarCode = (string)reader[2]; |
|
|
|
entity.Goods_Name = (string)reader[3]; |
|
|
|
entity.Weight = (decimal)reader[2]; |
|
|
|
if (history) |
|
|
|
{ |
|
|
|
entity.Weight = (decimal)reader[4]; |
|
|
|
entity.BarCode = (string)reader[3]; |
|
|
|
entity.Goods_Name = (string)reader[4]; |
|
|
|
entity.BeforeWeight = (decimal?)reader[5]; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -182,7 +182,7 @@ namespace ButcherFactory.BO.LocalBL |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("CreateTime")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("Weight")), DQCondition.EQ("Sync", false))); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("Goods_ID")), DQCondition.EQ("Sync", false))); |
|
|
|
query.Range = SelectRange.Top(10); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID")); |
|
|
|
|
|
|
|
|