From cfc67fc2ec2d45791cb1046a761e9ea3154cf743 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sat, 18 Nov 2017 00:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BO/Utils/BillRpc/GradeAndWeightRpc.cs | 92 +++++++++++++++++++-------- WeighAndGrading/AbnormalModifyForm.cs | 4 +- WeighAndGrading/GradeFrom.cs | 73 ++++++++++++++++++++- 3 files changed, 137 insertions(+), 32 deletions(-) diff --git a/BO/Utils/BillRpc/GradeAndWeightRpc.cs b/BO/Utils/BillRpc/GradeAndWeightRpc.cs index 4521eef..09cc292 100644 --- a/BO/Utils/BillRpc/GradeAndWeightRpc.cs +++ b/BO/Utils/BillRpc/GradeAndWeightRpc.cs @@ -51,15 +51,12 @@ namespace BO.Utils.BillRpc { static JavaScriptSerializer serializer = new JavaScriptSerializer(); - - - - public static void ClearWeightBySID(long sid) { var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail)); updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid)); updateDom.Columns.Add(new DQUpdateColumn("Weight", DQExpression.NULL)); + updateDom.Columns.Add(new DQUpdateColumn("Sync", false)); using (var session = LocalDmoSession.New()) { session.ExecuteNonQuery(updateDom); @@ -69,11 +66,13 @@ namespace BO.Utils.BillRpc public static void DeleteBySID(long sid) { - var delDom = new DQDeleteDom(typeof(GradeAndWeight_Detail)); - delDom.Where.Conditions.Add(DQCondition.EQ("SID", sid)); + var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail)); + updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid)); + updateDom.Columns.Add(new DQUpdateColumn("IsDeleted", true)); + updateDom.Columns.Add(new DQUpdateColumn("Sync", false)); using (var session = LocalDmoSession.New()) { - session.ExecuteNonQuery(delDom); + session.ExecuteNonQuery(updateDom); session.Commit(); } } @@ -98,7 +97,7 @@ namespace BO.Utils.BillRpc var list = new List(); var query = new DmoQuery(typeof(GradeAndWeight_Detail)); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date))); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true)); query.Range = SelectRange.Top(top); using (var session = LocalDmoSession.New()) @@ -112,11 +111,10 @@ namespace BO.Utils.BillRpc return bindList; } - public static int GetTangTuiSumNumber(DateTime date) + public static int GetSumNumber(DateTime date, short type) { var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); - query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "烫褪")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Technics", type), DQCondition.EQ("Date", date))); query.Columns.Add(DQSelectColumn.Count()); using (var session = LocalDmoSession.New()) { @@ -124,21 +122,39 @@ namespace BO.Utils.BillRpc } } - public static int GetMaoBoSumNumber(DateTime date) - { - var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); - query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "毛剥")); - query.Columns.Add(DQSelectColumn.Count()); - using (var session = LocalDmoSession.New()) - { - return Convert.ToInt32(session.ExecuteScalar(query)); - } - } + //public static int GetSumNumber(long orderID, short type) + //{ + // var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); + // query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Technics", type), DQCondition.EQ("OrderDetail_ID", orderID))); + // query.Columns.Add(DQSelectColumn.Count()); + // using (var session = LocalDmoSession.New()) + // { + // return Convert.ToInt32(session.ExecuteScalar(query)); + // } + //} + + //public static List> GetSumNumber(long orderID) + //{ + // var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); + // query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("OrderDetail_ID", orderID))); + // query.Columns.Add(DQSelectColumn.Field("Technics")); + // query.Columns.Add(DQSelectColumn.Count()); + // query.GroupBy.Expressions.Add(DQExpression.Field("Technics")); + // var list = new List>(); + // using (var session = LocalDmoSession.New()) + // { + // using (var reader = session.ExecuteReader(query)) + // { + // list.Add(new Tuple((short)reader[0], Convert.ToInt32(reader[1]))); + // } + // return list; + // } + //} + public static decimal GetSumWeight(DateTime date) { var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date))); query.Columns.Add(DQSelectColumn.Sum("Weight")); using (var session = LocalDmoSession.New()) @@ -151,8 +167,7 @@ namespace BO.Utils.BillRpc public static List GetLostWeightDetails(DateTime date) { var query = new DmoQuery(typeof(GradeAndWeight_Detail)); - query.Where.Conditions.Add(DQCondition.EQ("IsLostWeight", true)); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("IsLostWeight", true), DQCondition.EQ("Date", date))); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true)); using (var session = LocalDmoSession.New()) @@ -202,13 +217,36 @@ namespace BO.Utils.BillRpc public static void Sync() { + ClearUnSyncDelete(); var syncs = GetAllNeedSyncDetails(); foreach (var detail in syncs) { const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc/UpdateOrInsertDetailOrDelete"; var id = RpcFacade.Call(method, serializer.Serialize(detail)); + if (detail.IsDeleted) + Delete(detail.SID); + else + SetDetailSynced(detail, id); + } + } - SetDetailSynced(detail, id); + static void ClearUnSyncDelete() + { + using (var session = LocalDmoSession.New()) + { + var delete = new DQDeleteDom(typeof(GradeAndWeight_Detail)); + delete.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", true), DQCondition.EQ("ID", 0))); + session.ExecuteNonQuery(delete); + } + } + + static void Delete(long sid) + { + using (var session = LocalDmoSession.New()) + { + var delete = new DQDeleteDom(typeof(GradeAndWeight_Detail)); + delete.Where.Conditions.Add(DQCondition.EQ("SID", sid)); + session.ExecuteNonQuery(delete); } } @@ -256,7 +294,7 @@ namespace BO.Utils.BillRpc { var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); query.Columns.Add(DQSelectColumn.Count()); - query.Where.Conditions.Add(DQCondition.EQ("Date", date)); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date))); using (var session = LocalDmoSession.New()) { return Convert.ToInt32(session.ExecuteScalar(query)); diff --git a/WeighAndGrading/AbnormalModifyForm.cs b/WeighAndGrading/AbnormalModifyForm.cs index 7e867e4..5343778 100644 --- a/WeighAndGrading/AbnormalModifyForm.cs +++ b/WeighAndGrading/AbnormalModifyForm.cs @@ -44,8 +44,8 @@ namespace WeighAndGrading lblPaiZaiMB.Text = maoboList.Sum(x => x.Number).ToString(); - var tangtui = LocalGradeAndWeightBL.GetTangTuiSumNumber(mDate); - var maobo = LocalGradeAndWeightBL.GetMaoBoSumNumber(mDate); + var tangtui = LocalGradeAndWeightBL.GetSumNumber(mDate,0); + var maobo = LocalGradeAndWeightBL.GetSumNumber(mDate, 1); var weight = LocalGradeAndWeightBL.GetSumWeight(mDate); lblWeightTT.Text = tangtui.ToString(); diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index 4c44486..eb9ac35 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -143,14 +143,52 @@ namespace WeighAndGrading } else { + var needUpdate = modifyDetail.Technics != livestockTag.Item3; StartPrintEntity(tech, modifyDetail.Index); modifyDetail.Livestock_ID = livestockTag.Item1; modifyDetail.Livestock_Name = livestockTag.Item2; modifyDetail.Technics = livestockTag.Item3; modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name"); - - + if (needUpdate) + { + //因为工艺被修改 所以这里取相反 + var currentRow = modifyDetail.Technics == 0 ? maoEntity : tangEntity; + if (currentRow != null) + { + currentRow.Already -= 1; + orderLabel.Text = currentRow.Order.ToString(); + alreadyLabel.Text = currentRow.Already.ToString(); + if (modifyDetail.Technics == 0) + { + maoGridView.Refresh(); + foreach (DataGridViewRow row in tangGridView.Rows) + { + if ((long)row.Cells["T_OrderDetail_ID"].Value == modifyDetail.OrderDetail_ID) + { + var r = row.DataBoundItem as GradeAndWeight; + r.Already += 1; + tangGridView.Refresh(); + break; + } + } + } + else + { + tangGridView.Refresh(); + foreach (DataGridViewRow row in maoGridView.Rows) + { + if ((long)row.Cells["M_OrderDetail_ID"].Value == modifyDetail.OrderDetail_ID) + { + var r = row.DataBoundItem as GradeAndWeight; + r.Already += 1; + maoGridView.Refresh(); + break; + } + } + } + } + } noLivestockList = new ConcurrentQueue(); var stack = new Stack(); @@ -1038,7 +1076,7 @@ namespace WeighAndGrading } } - static object insertweightdetail=new object(); + static object insertweightdetail = new object(); void LocalGradeAndWeightBLInsert(GradeAndWeight_Detail entity) { //为了防止点级别和称重同时进行 @@ -1147,6 +1185,35 @@ namespace WeighAndGrading //删除选中 更新 IsDeleted 和 Sync lastCheckItem.IsDeleted = true; LocalGradeAndWeightBL.Update(lastCheckItem, "IsDeleted"); + if (lastCheckItem.OrderDetail_ID.HasValue) + { + if (lastCheckItem.Technics == 0) + { + foreach (DataGridViewRow row in tangGridView.Rows) + { + if ((long)row.Cells["T_OrderDetail_ID"].Value == lastCheckItem.OrderDetail_ID.Value) + { + var r = row.DataBoundItem as GradeAndWeight; + r.Already -= 1; + tangGridView.Refresh(); + break; + } + } + } + else + { + foreach (DataGridViewRow row in maoGridView.Rows) + { + if ((long)row.Cells["M_OrderDetail_ID"].Value == lastCheckItem.OrderDetail_ID.Value) + { + var r = row.DataBoundItem as GradeAndWeight; + r.Already -= 1; + maoGridView.Refresh(); + break; + } + } + } + } //修改本地 if (lastCheckItem.OrderDetail_ID.HasValue)