|
|
@ -20,20 +20,23 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
{ |
|
|
{ |
|
|
static JavaScriptSerializer serializer = new JavaScriptSerializer(); |
|
|
static JavaScriptSerializer serializer = new JavaScriptSerializer(); |
|
|
|
|
|
|
|
|
|
|
|
#region 排宰
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static string GetNeedOrderWeightBill(DateTime date, bool? showType) |
|
|
public static string GetNeedOrderWeightBill(DateTime date, bool? showType) |
|
|
{ |
|
|
{ |
|
|
var main = new JoinAlias(typeof(WeightBill)); |
|
|
var main = new JoinAlias(typeof(WeightBill)); |
|
|
|
|
|
var detail = new JoinAlias(typeof(WeightBill_Detail)); |
|
|
var relate = new JoinAlias(typeof(WeightBillShowRelate)); |
|
|
var relate = new JoinAlias(typeof(WeightBillShowRelate)); |
|
|
var query = new DQueryDom(main); |
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.And(DQCondition.EQ(main, "ID", detail, "WeightBill_ID"), DQCondition.EQ(detail, "DeleteState", false))); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "WeightBill_ID")); |
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "WeightBill_ID")); |
|
|
var detail = WeightDetailTemp.Register(query, main); |
|
|
|
|
|
var already = OrderDetailTemp.Register(query, main); |
|
|
var already = OrderDetailTemp.Register(query, main); |
|
|
|
|
|
var hurry = HurryOrderTemp.Register(query, main, true); |
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("HouseNames")); |
|
|
query.Columns.Add(DQSelectColumn.Field("HouseNames")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Number", detail)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Number", detail)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Number", already)); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Add(DQExpression.IfNull(DQExpression.Field(already, "Number"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(hurry, "Number"), DQExpression.Value(0))), "Already")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeighTime")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeighTime")); |
|
|
query.Columns.Add(DQSelectColumn.Field("B3ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("B3ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Show", relate)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Show", relate)); |
|
|
@ -70,7 +73,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
return serializer.Serialize(result); |
|
|
return serializer.Serialize(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class WeightDetailTemp |
|
|
|
|
|
|
|
|
class OrderDetailTemp |
|
|
{ |
|
|
{ |
|
|
public long WeightBill_ID { get; set; } |
|
|
public long WeightBill_ID { get; set; } |
|
|
|
|
|
|
|
|
@ -78,35 +81,35 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias) |
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias) |
|
|
{ |
|
|
{ |
|
|
var query = new DQueryDom(new JoinAlias(typeof(WeightBill_Detail))); |
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Sum("Number")); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("PlanNumber")); |
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false)); |
|
|
query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false)); |
|
|
rootQuery.RegisterQueryTable(typeof(WeightDetailTemp), new string[] { "WeightBill_ID", "Number" }, query); |
|
|
|
|
|
|
|
|
|
|
|
var alias = new JoinAlias(typeof(WeightDetailTemp)); |
|
|
|
|
|
|
|
|
rootQuery.RegisterQueryTable(typeof(OrderDetailTemp), new string[] { "WeightBill_ID", "Number" }, query); |
|
|
|
|
|
var alias = new JoinAlias(typeof(OrderDetailTemp)); |
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, "ID", alias, "WeightBill_ID")); |
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, "ID", alias, "WeightBill_ID")); |
|
|
return alias; |
|
|
return alias; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class OrderDetailTemp |
|
|
|
|
|
|
|
|
class HurryOrderTemp |
|
|
{ |
|
|
{ |
|
|
public long WeightBill_ID { get; set; } |
|
|
public long WeightBill_ID { get; set; } |
|
|
|
|
|
|
|
|
public int? Number { get; set; } |
|
|
public int? Number { get; set; } |
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias) |
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias, bool unOrder, string joinField = "ID") |
|
|
{ |
|
|
{ |
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Sum("PlanNumber")); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false)); |
|
|
|
|
|
rootQuery.RegisterQueryTable(typeof(OrderDetailTemp), new string[] { "WeightBill_ID", "Number" }, query); |
|
|
|
|
|
var alias = new JoinAlias(typeof(OrderDetailTemp)); |
|
|
|
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, "ID", alias, "WeightBill_ID")); |
|
|
|
|
|
|
|
|
if (unOrder) |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("ToOrderDetail_ID"))); |
|
|
|
|
|
rootQuery.RegisterQueryTable(typeof(HurryOrderTemp), new string[] { "WeightBill_ID", "Number" }, query); |
|
|
|
|
|
var alias = new JoinAlias(typeof(HurryOrderTemp)); |
|
|
|
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, joinField, alias, "WeightBill_ID")); |
|
|
return alias; |
|
|
return alias; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -117,7 +120,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
var totalNumber = GetWeightNumber(weightID); |
|
|
var totalNumber = GetWeightNumber(weightID); |
|
|
var alreadyNumber = GetAlreadyNumberWithoutBack(weightID, backId); |
|
|
var alreadyNumber = GetAlreadyNumberWithoutBack(weightID, backId); |
|
|
|
|
|
|
|
|
return totalNumber - alreadyNumber; |
|
|
|
|
|
|
|
|
return totalNumber - alreadyNumber - HurryRecordUnOrderNumber(weightID); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int GetWeightNumber(long wid) |
|
|
static int GetWeightNumber(long wid) |
|
|
@ -142,14 +145,25 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int HurryRecordUnOrderNumber(long wid) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("ToOrderDetail_ID"))); |
|
|
|
|
|
var rst = query.EExecuteScalar(); |
|
|
|
|
|
if (rst != null) |
|
|
|
|
|
return Convert.ToInt32(rst); |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static string GetOrderDetail(DateTime date, bool onlyNormal) |
|
|
|
|
|
|
|
|
public static string GetOrderDetail(DateTime date) |
|
|
{ |
|
|
{ |
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Order")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Order")); |
|
|
query.Columns.Add(DQSelectColumn.Field("PlanNumber")); |
|
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("PlanNumber")); |
|
|
query.Columns.Add(DQSelectColumn.Field("LiveColonyHouse_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("LiveColonyHouse_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("IsHurryButcher")); |
|
|
query.Columns.Add(DQSelectColumn.Field("IsHurryButcher")); |
|
|
query.Columns.Add(DQSelectColumn.Field("B3WeighBill_ID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("B3WeighBill_ID")); |
|
|
@ -157,12 +171,6 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); |
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Date", date), DQCondition.EQ("DeleteState", false))); |
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Date", date), DQCondition.EQ("DeleteState", false))); |
|
|
if (onlyNormal) |
|
|
|
|
|
{ |
|
|
|
|
|
var record = HurryRecordTemp.Register(query, query.From.RootSource.Alias); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Number", record)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("IsHurryButcher", false)); |
|
|
|
|
|
} |
|
|
|
|
|
var list = new List<OrderDetail>(); |
|
|
var list = new List<OrderDetail>(); |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
@ -180,11 +188,6 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
entity.B3WeighBill_ID = (long?)reader[6]; |
|
|
entity.B3WeighBill_ID = (long?)reader[6]; |
|
|
entity.SecondarySplit = (bool)reader[7]; |
|
|
entity.SecondarySplit = (bool)reader[7]; |
|
|
entity.Supplier_Name = (string)reader[8]; |
|
|
entity.Supplier_Name = (string)reader[8]; |
|
|
if (onlyNormal) |
|
|
|
|
|
{ |
|
|
|
|
|
entity.HurryNumber = Convert.ToInt32(reader[9] ?? 0); |
|
|
|
|
|
entity.PlanNumber += entity.HurryNumber; |
|
|
|
|
|
} |
|
|
|
|
|
list.Add(entity); |
|
|
list.Add(entity); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -192,26 +195,6 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
return serializer.Serialize(list); |
|
|
return serializer.Serialize(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class HurryRecordTemp |
|
|
|
|
|
{ |
|
|
|
|
|
public long OrderDetail_ID { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public int? Number { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("FromOrderDetail_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("FromOrderDetail_ID")); |
|
|
|
|
|
rootQuery.RegisterQueryTable(typeof(HurryRecordTemp), new string[] { "OrderDetail_ID", "Number" }, query); |
|
|
|
|
|
|
|
|
|
|
|
var alias = new JoinAlias(typeof(HurryRecordTemp)); |
|
|
|
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, "ID", alias, "OrderDetail_ID")); |
|
|
|
|
|
return alias; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int GetMaxOrder(DateTime date) |
|
|
public static int GetMaxOrder(DateTime date) |
|
|
{ |
|
|
{ |
|
|
@ -319,46 +302,59 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
session.ExecuteNonQuery(update); |
|
|
session.ExecuteNonQuery(update); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region hurryButcher
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static string GetHurryRecords(long orderId) |
|
|
|
|
|
|
|
|
public static string GetHurryRecords(long weightId) |
|
|
{ |
|
|
{ |
|
|
var query = new DmoQuery(typeof(HurryRecord)); |
|
|
var query = new DmoQuery(typeof(HurryRecord)); |
|
|
query.Where.Conditions.Add(DQCondition.EQ("FromOrderDetail_ID", orderId)); |
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("WeightBill_ID", weightId)); |
|
|
return serializer.Serialize(query.EExecuteList().Cast<HurryRecord>().ToList()); |
|
|
return serializer.Serialize(query.EExecuteList().Cast<HurryRecord>().ToList()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int DeleteHurryRecord(long id) |
|
|
|
|
|
|
|
|
public static long? DeleteHurryRecord(long id) |
|
|
{ |
|
|
{ |
|
|
|
|
|
long? orderID; |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
var hurryNumber = InnerBLUtil.GetDmoPropertyByID<int>(session, typeof(HurryRecord), "HurryNumber", id); |
|
|
|
|
|
|
|
|
var entity = InnerBLUtil.GetSingleDmo<HurryRecord>(session, "ID", id, "HurryNumber", "WeightBill_ID"); |
|
|
|
|
|
orderID = GetOrderID(entity.WeightBill_ID); |
|
|
var delete = new DQDeleteDom(typeof(HurryRecord)); |
|
|
var delete = new DQDeleteDom(typeof(HurryRecord)); |
|
|
delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
session.ExecuteNonQuery(delete); |
|
|
session.ExecuteNonQuery(delete); |
|
|
AddOrderNumber(session, id, hurryNumber); |
|
|
|
|
|
|
|
|
if (orderID > 0) |
|
|
|
|
|
AddOrderNumber(session, orderID.Value, entity.HurryNumber); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
} |
|
|
} |
|
|
return 1; |
|
|
|
|
|
|
|
|
return orderID; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int InsertHurryRecord(string detail) |
|
|
|
|
|
|
|
|
public static string InsertHurryRecord(string detail) |
|
|
{ |
|
|
{ |
|
|
detail = detail.ESerializeDateTime(); |
|
|
detail = detail.ESerializeDateTime(); |
|
|
var entity = serializer.Deserialize<HurryRecord>(detail); |
|
|
var entity = serializer.Deserialize<HurryRecord>(detail); |
|
|
|
|
|
long? orderID = null; |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
session.Insert(entity); |
|
|
session.Insert(entity); |
|
|
AddOrderNumber(session, entity.ID, -entity.HurryNumber); |
|
|
|
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("FromOrderDetail_ID", entity.FromOrderDetail_ID)); |
|
|
|
|
|
var r= Convert.ToInt32(query.EExecuteScalar(session) ?? 0); |
|
|
|
|
|
|
|
|
orderID = GetOrderID(entity.WeightBill_ID); |
|
|
|
|
|
if (orderID > 0) |
|
|
|
|
|
AddOrderNumber(session, orderID.Value, -entity.HurryNumber); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
return r; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return string.Format("{0}|{1}", orderID, entity.ID); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static int GetHurryRecordNumber(long weightId) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(HurryRecord))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Sum("HurryNumber")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("WeightBill_ID", weightId)); |
|
|
|
|
|
return Convert.ToInt32(query.EExecuteScalar() ?? 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void AddOrderNumber(IDmoSession session, long ID, int subNumber) |
|
|
static void AddOrderNumber(IDmoSession session, long ID, int subNumber) |
|
|
@ -369,5 +365,93 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
update.Columns.Add(new DQUpdateColumn("PlanNumber", DQExpression.Add(DQExpression.Field("PlanNumber"), DQExpression.Value(subNumber)))); |
|
|
update.Columns.Add(new DQUpdateColumn("PlanNumber", DQExpression.Add(DQExpression.Field("PlanNumber"), DQExpression.Value(subNumber)))); |
|
|
session.ExecuteNonQuery(update); |
|
|
session.ExecuteNonQuery(update); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static long? GetOrderID(long weightBillId) |
|
|
|
|
|
{ |
|
|
|
|
|
var detail = new JoinAlias(typeof(WeightBill_Detail)); |
|
|
|
|
|
var order = new JoinAlias(typeof(OrderDetail)); |
|
|
|
|
|
var query = new DQueryDom(detail); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(order), DQCondition.EQ(detail, "WeightBill_ID", order, "WeightBill_ID")); |
|
|
|
|
|
var hurry = HurryOrderTemp.Register(query, detail, false, "WeightBill_ID"); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", order)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(DQExpression.Subtract(DQExpression.IfNull(DQExpression.Field(detail, "Number"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(order, "PlanNumber"), DQExpression.Value(0))), DQExpression.IfNull(DQExpression.Field(hurry, "Number"), DQExpression.Value(0))), "last")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("PlanNumber", order)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Number", hurry)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(detail, "DeleteState", false), DQCondition.EQ(order, "DeleteState", false), DQCondition.EQ(order, "IsHurryButcher", false))); |
|
|
|
|
|
long? id = null; |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
|
|
{ |
|
|
|
|
|
while (reader.Read()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (id.HasValue || Convert.ToInt32(reader[1]) != 0) |
|
|
|
|
|
return -1; |
|
|
|
|
|
id = (long)reader[0]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return id; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static string GetSelectHurryList() |
|
|
|
|
|
{ |
|
|
|
|
|
var bill = new JoinAlias(typeof(WeightBill)); |
|
|
|
|
|
var detail = new JoinAlias(typeof(WeightBill_Detail)); |
|
|
|
|
|
var query = new DQueryDom(bill); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.And(DQCondition.EQ(bill, "ID", detail, "WeightBill_ID"), DQCondition.EQ(detail, "DeleteState", false))); |
|
|
|
|
|
var hurry = HurryOrderTemp.Register(query, bill, false); |
|
|
|
|
|
var start = StartOrderTemp.Register(query, bill); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("B3ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("HouseNames")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Number", detail)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Number", hurry)); |
|
|
|
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.InEQ("HouseNames", ""), DQCondition.IsNull(DQExpression.Field(start, "WeightBill_ID")))); |
|
|
|
|
|
|
|
|
|
|
|
var list = new List<SelectHurryList>(); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
|
|
{ |
|
|
|
|
|
while (reader.Read()) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = new SelectHurryList(); |
|
|
|
|
|
entity.WeightBill_ID = (long)reader[0]; |
|
|
|
|
|
entity.B3WeighBill_ID = (long?)reader[1]; |
|
|
|
|
|
entity.Supplier_Name = (string)reader[2]; |
|
|
|
|
|
entity.LiveColonyHouse_Name = (string)reader[3]; |
|
|
|
|
|
entity.WeightNumber = (int?)reader[4] ?? 0; |
|
|
|
|
|
entity.HurryNumber = Convert.ToInt32(reader[5] ?? 0); |
|
|
|
|
|
list.Add(entity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return serializer.Serialize(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class StartOrderTemp |
|
|
|
|
|
{ |
|
|
|
|
|
public long WeightBill_ID { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom rootQuery, JoinAlias rootAlias) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(OrderDetail))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false)); |
|
|
|
|
|
query.Having.Conditions.Add(DQCondition.GreaterThanOrEqual(DQExpression.Min(DQExpression.Field("OrderState")), DQExpression.Value(10))); |
|
|
|
|
|
|
|
|
|
|
|
rootQuery.RegisterQueryTable(typeof(StartOrderTemp), new string[] { "WeightBill_ID" }, query); |
|
|
|
|
|
var alias = new JoinAlias(typeof(StartOrderTemp)); |
|
|
|
|
|
rootQuery.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(rootAlias, "ID", alias, "WeightBill_ID")); |
|
|
|
|
|
return alias; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |