From 737cb41753b7e1095c5a7d45a34642578dfce92b Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Thu, 19 Jul 2018 09:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E5=8F=91=E8=B4=A7=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3ClientService/B3ClientService.csproj | 1 + .../BO/Bill/SegmentProductionInfo.cs | 2 + .../OfflinRpc/SegmentSaleOutStoreRpc.cs | 90 +++++++++++++++++++ .../Rpcs/BillRpc/OrderDetailRpc.cs | 2 +- 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 B3ClientService/OfflinRpc/SegmentSaleOutStoreRpc.cs diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index b745dec..c5b131a 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -213,6 +213,7 @@ + diff --git a/B3ClientService/BO/Bill/SegmentProductionInfo.cs b/B3ClientService/BO/Bill/SegmentProductionInfo.cs index 57be59b..bb6d948 100644 --- a/B3ClientService/BO/Bill/SegmentProductionInfo.cs +++ b/B3ClientService/BO/Bill/SegmentProductionInfo.cs @@ -60,6 +60,8 @@ namespace BWP.B3ClientService.BO #endregion #region 领用信息 + [LogicName("领用时间")] + public DateTime? PickTime { get; set; } #endregion public bool IsDelete { get; set; } diff --git a/B3ClientService/OfflinRpc/SegmentSaleOutStoreRpc.cs b/B3ClientService/OfflinRpc/SegmentSaleOutStoreRpc.cs new file mode 100644 index 0000000..70584ca --- /dev/null +++ b/B3ClientService/OfflinRpc/SegmentSaleOutStoreRpc.cs @@ -0,0 +1,90 @@ +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.JsonRpc; +using Forks.EnterpriseServices.SqlDoms; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.Rpcs +{ + [Rpc] + public static class SegmentSaleOutStoreRpc + { + [Rpc(RpcFlags.SkipAuth)] + public static string GetSegmentInfo(string barCode) + { + var main = new JoinAlias(typeof(SegmentProductionInfo)); + var goods = new JoinAlias(typeof(Goods)); + var query = new DQueryDom(main); + query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID")); + query.Columns.Add(DQSelectColumn.Field("Code", goods)); + query.Columns.Add(DQSelectColumn.Field("Weight")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDelete", false), DQCondition.EQ("BarCode", barCode))); + query.Range = SelectRange.Top(1); + var rst = query.EExecuteScalar(); + var entity = new ExtensionObj(); + if (rst != null) + { + entity.StringExt1 = rst.Item1; + entity.DecimalExt1 = rst.Item2; + } + return JsonConvert.SerializeObject(entity); + } + + [Rpc(RpcFlags.SkipAuth)] + public static int UploadSegmentInfo(string json) + { + var list = JsonConvert.DeserializeObject>(json); + using (var session = Dmo.NewSession()) + { + foreach (var item in list) + { + var id = GetSegmentID(item.BarCode, session); + if (id == null) + Insert(item, session); + else + Update(id.Value, item, session); + } + session.Commit(); + } + return 1; + } + + static long? GetSegmentID(string code, IDmoSession session) + { + if (string.IsNullOrEmpty(code)) + return null; + var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDelete", false), DQCondition.EQ("BarCode", code))); + return query.EExecuteScalar(session); + } + + static void Update(long id, SegmentSaleOutStoreObj obj, IDmoSession session) + { + var update = new DQUpdateDom(typeof(SegmentProductionInfo)); + update.Columns.Add(new DQUpdateColumn("PickTime", obj.Time)); + update.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(update); + } + + static void Insert(SegmentSaleOutStoreObj obj, IDmoSession session) + { + var entity = new SegmentProductionInfo(); + entity.BarCode = obj.BarCode; + entity.PickTime = obj.Time; + session.Insert(entity); + } + } + + class SegmentSaleOutStoreObj + { + public string BarCode { get; set; } + public DateTime? Time { get; set; } + } +} diff --git a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs index b3d8a28..aee65e2 100644 --- a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs @@ -391,7 +391,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc return 1; } - public static void UpdateSecondOrder(long id, IDmoSessionWithTransaction session) + public static void UpdateSecondOrder(long id, IDmoSession session) { var update = new DQUpdateDom(typeof(SecondOrder)); update.Columns.Add(new DQUpdateColumn("Sync", false));