From 53fc10e26d56a97017d4d7f5ed20233cd4dfe56e Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Tue, 6 Mar 2018 09:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8D=95No.138861=20?= =?UTF-8?q?=E6=8E=92=E5=AE=B0=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=AF=8F=E4=B8=AA=E7=B1=BB=E5=88=AB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E5=A4=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Rpcs/BillRpc/OrderDetailRpc.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs index c42f79a..1313b2f 100644 --- a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs @@ -74,6 +74,44 @@ namespace BWP.B3ClientService.Rpcs.BillRpc return serializer.Serialize(result); } + [Rpc] + public static Tuple GetEveryNumberTuple(DateTime date) + { + var main = new JoinAlias(typeof(WeightBill)); + var detail = new JoinAlias(typeof(WeightBill_Detail)); + var relate = new JoinAlias(typeof(WeightBillShowRelate)); + 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")); + var already = OrderDetailTemp.Register(query, main); + var hurry = HurryOrderTemp.Register(query, main, true); + query.Columns.Add(DQSelectColumn.Field("Show", relate)); + query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); + var alreadyNumber = DQExpression.Add(DQExpression.IfNull(DQExpression.Field(already, "Number"), DQExpression.Value(0)), DQExpression.IfNull(DQExpression.Field(hurry, "Number"), DQExpression.Value(0))); + query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(alreadyNumber), "Already")); + query.GroupBy.Expressions.Add(DQExpression.Field(relate, "Show")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.Between("WeighTime", date.Date, date.Date + new TimeSpan(23, 59, 29)), DQCondition.InEQ("HouseNames", ""))); + query.Where.Conditions.Add(DQCondition.InEQ(DQExpression.IfNull(DQExpression.Field(detail, "Number"), DQExpression.Value(0)), alreadyNumber)); + var n1 = 0; + var n2 = 0; + using (var session = Dmo.NewSession()) + { + using (var reader = session.ExecuteReader(query)) + { + while (reader.Read()) + { + var last = Convert.ToInt32(reader[1] ?? 0) - Convert.ToInt32(reader[2] ?? 0); + var type = (bool?)reader[0]; + if (type == false) + n2 = last; + else + n1 += last; + } + } + } + return new Tuple(n1, n2); + } + class OrderDetailTemp { public long WeightBill_ID { get; set; }