From 8c5cf03426b06a260b41083840037065f61cb0aa Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sat, 9 Sep 2017 23:36:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BO/Bill/WeightBill/WeightBill.cs | 10 +++ .../Bill/WeightBill/WeightBill_HouseDetail.cs | 10 ++- .../WeightBill/WeightBill_SanctionDetail.cs | 9 ++- B3ClientService/Rpcs/BillRpc/WeightBillRpc.cs | 67 +++++++++++++++++++ 4 files changed, 92 insertions(+), 4 deletions(-) diff --git a/B3ClientService/BO/Bill/WeightBill/WeightBill.cs b/B3ClientService/BO/Bill/WeightBill/WeightBill.cs index b8b94a5..ed0ca7a 100644 --- a/B3ClientService/BO/Bill/WeightBill/WeightBill.cs +++ b/B3ClientService/BO/Bill/WeightBill/WeightBill.cs @@ -82,5 +82,15 @@ namespace BWP.B3ClientService.BO [OneToMany(typeof(WeightBill_FarmerDetail), "ID")] [Join("ID", "WeightBill_ID")] public WeightBill_FarmerDetailCollection FarmerDetails { get { return mFarmerDetails; } } + + private readonly WeightBill_HouseDetailCollection mHouseDetails = new WeightBill_HouseDetailCollection(); + [OneToMany(typeof(WeightBill_HouseDetail), "ID")] + [Join("ID", "WeightBill_ID")] + public WeightBill_HouseDetailCollection HouseDetails { get { return mHouseDetails; } } + + private readonly WeightBill_SanctionDetailCollection mSanctionDetails = new WeightBill_SanctionDetailCollection(); + [OneToMany(typeof(WeightBill_SanctionDetail), "ID")] + [Join("ID", "WeightBill_ID")] + public WeightBill_SanctionDetailCollection SanctionDetails { get { return mSanctionDetails; } } } } diff --git a/B3ClientService/BO/Bill/WeightBill/WeightBill_HouseDetail.cs b/B3ClientService/BO/Bill/WeightBill/WeightBill_HouseDetail.cs index d1311f8..ef432aa 100644 --- a/B3ClientService/BO/Bill/WeightBill/WeightBill_HouseDetail.cs +++ b/B3ClientService/BO/Bill/WeightBill/WeightBill_HouseDetail.cs @@ -1,4 +1,5 @@ -using System; +using Forks.EnterpriseServices.DomainObjects2; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -15,8 +16,13 @@ namespace BWP.B3ClientService.BO public long? LiveColonyHouse_ID { get; set; } - public long? LiveColonyHouse_Name { get; set; } + public string LiveColonyHouse_Name { get; set; } public int? Number { get; set; } } + + + [Serializable] + public class WeightBill_HouseDetailCollection : DmoCollection + { } } diff --git a/B3ClientService/BO/Bill/WeightBill/WeightBill_SanctionDetail.cs b/B3ClientService/BO/Bill/WeightBill/WeightBill_SanctionDetail.cs index 8b47dd2..774cf96 100644 --- a/B3ClientService/BO/Bill/WeightBill/WeightBill_SanctionDetail.cs +++ b/B3ClientService/BO/Bill/WeightBill/WeightBill_SanctionDetail.cs @@ -1,4 +1,5 @@ -using System; +using Forks.EnterpriseServices.DomainObjects2; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -26,8 +27,12 @@ namespace BWP.B3ClientService.BO /// /// 异常项目名称 /// - public long? AbnormalItem_Name { get; set; } + public string AbnormalItem_Name { get; set; } public int? Number { get; set; } } + + [Serializable] + public class WeightBill_SanctionDetailCollection : DmoCollection + { } } diff --git a/B3ClientService/Rpcs/BillRpc/WeightBillRpc.cs b/B3ClientService/Rpcs/BillRpc/WeightBillRpc.cs index 19db263..d110bb3 100644 --- a/B3ClientService/Rpcs/BillRpc/WeightBillRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/WeightBillRpc.cs @@ -2,6 +2,8 @@ using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; +using Forks.EnterpriseServices.SqlDoms; +using Forks.JsonRpc.Client.Data; using System; using System.Collections.Generic; using System.Linq; @@ -57,5 +59,70 @@ namespace BWP.B3ClientService.Rpcs.BillRpc query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.Between("WeighTime", date.Date, date.Date + new TimeSpan(23, 59, 29)))); return query.EExecuteList().Cast().ToList(); } + + [Rpc] + public static List GetNoHouseInfoWeightBills(DateTime date) + { + var main = new JoinAlias(typeof(WeightBill)); + var detail = new JoinAlias(typeof(WeightBill_HouseDetail)); + 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.Where.Conditions.Add(DQCondition.And(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.Between("WeighTime", date.Date, date.Date + new TimeSpan(23, 59, 29))))); + query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(detail, "ID"))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Columns.Add(DQSelectColumn.Field("B3ID")); + query.Columns.Add(DQSelectColumn.Field("Supplier_Name")); + var result = query.EExecuteList(); + var list = new List(); + foreach (var item in result) + { + var entity = new WeightBill(); + list.Add(entity); + entity.ID = item.Item1; + entity.B3ID = item.Item2; + entity.Supplier_Name = item.Item3; + } + return list; + } + + [Rpc] + public static int InsertWeightBillHouseDetail(WeightBill bo) + { + using (var session = Dmo.NewSession()) + { + foreach (var item in bo.HouseDetails) + session.Insert(item); + foreach (var item in bo.SanctionDetails) + session.Insert(item); + + var update = new DQUpdateDom(typeof(WeightBill)); + update.Columns.Add(new DQUpdateColumn("HogGrade_ID", bo.HogGrade_ID)); + update.Columns.Add(new DQUpdateColumn("HogGrade_Name", bo.HogGrade_Name)); + update.Columns.Add(new DQUpdateColumn("Inspector_ID", bo.Inspector_ID)); + update.Columns.Add(new DQUpdateColumn("Inspector_Name", bo.Inspector_Name)); + update.Columns.Add(new DQUpdateColumn("Sync", false)); + update.Columns.Add(new DQUpdateColumn("ModifyTime", DateTime.Now)); + update.Where.Conditions.Add(DQCondition.EQ("ID", bo.ID)); + session.ExecuteNonQuery(update); + session.Commit(); + } + return 1; + } + + [Rpc] + public static int GetHouseDetailTotalNumber(DateTime date) + { + var main = new JoinAlias(typeof(WeightBill)); + var detail = new JoinAlias(typeof(WeightBill_HouseDetail)); + 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.Where.Conditions.Add(DQCondition.And(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.Between("WeighTime", date.Date, date.Date + new TimeSpan(23, 59, 29))))); + query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); + var result = query.EExecuteScalar(); + + if (result == null) + return 0; + return Convert.ToInt32(result); + } } }