From f4220e3a84db3f2c99bb041592b4aec004bc6a1b Mon Sep 17 00:00:00 2001 From: luanhui <1029149336@qq.com> Date: Thu, 21 Dec 2017 14:07:31 +0800 Subject: [PATCH] . --- .../SegmentationInStoreRecord.cs | 3 + .../SegmentationInStoreRecordRpc.cs | 76 ++++++++++++++++--- .../SegmentationWeightRecordRpc.cs | 3 + .../TrunksIousOutInStoreRecordRpc.cs | 23 +++++- B3ClientService/Utils/UrlUtil.cs | 12 ++- 5 files changed, 99 insertions(+), 18 deletions(-) diff --git a/B3ClientService/BO/SegmentationInStoreRecord_/SegmentationInStoreRecord.cs b/B3ClientService/BO/SegmentationInStoreRecord_/SegmentationInStoreRecord.cs index aede16e..2ad8c59 100644 --- a/B3ClientService/BO/SegmentationInStoreRecord_/SegmentationInStoreRecord.cs +++ b/B3ClientService/BO/SegmentationInStoreRecord_/SegmentationInStoreRecord.cs @@ -16,6 +16,9 @@ namespace BWP.B3ClientService.BO [DFClass] public class SegmentationInStoreRecord:Base { + public long? B3_ID { get; set; } + public DateTime? SyncToB3DateTime { get; set; } + private DateTime mCreateTime = DateTime.Now; [DbColumn(DbType = SqlDbType.DateTime)] public DateTime CreateTime { get { return mCreateTime; } set { mCreateTime = value; } } diff --git a/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc_/SegmentationInStoreRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc_/SegmentationInStoreRecordRpc.cs index 7bb677f..b297915 100644 --- a/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc_/SegmentationInStoreRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc_/SegmentationInStoreRecordRpc.cs @@ -7,6 +7,7 @@ using BWP.B3Frameworks.Utils; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; +using Forks.JsonRpc.Client; using Newtonsoft.Json; using TSingSoft.WebPluginFramework; @@ -17,6 +18,58 @@ namespace BWP.B3ClientService.Rpcs.BillRpc public static class SegmentationInStoreRecordRpc { + [Rpc] + public static long CreateTodayB3ProductInStoreBill() + { + var serverUri = ServerHost.GetServerUrl(); + if (string.IsNullOrEmpty(serverUri)) + { + throw new Exception("请配置服务器地址"); + } + try + { + RpcFacade.Init(serverUri, "B3ClientServer"); + } + catch (Exception ex) + { + if (ex.Message != "Can only start once") + throw; + } + + var today = DateTime.Today; + var query = new DmoQuery(typeof(SegmentationInStoreRecord)); + query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", today)); + query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", today.AddDays(1))); + query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("B3_ID"))); + + using (var session = Dmo.NewSession()) + { + var list = session.ExecuteList(query).Cast().ToList(); + if (list.Count == 0) + { + return -1; + } + var json = JsonConvert.SerializeObject(list); + var b3Id = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/CreateB3ProductInStore", json); + if (b3Id > 0) + { + var update = new DQUpdateDom(typeof(SegmentationInStoreRecord)); + update.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", today)); + update.Where.Conditions.Add(DQCondition.LessThan("CreateTime", today.AddDays(1))); + update.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("B3_ID"))); + update.Columns.Add(new DQUpdateColumn("B3_ID", b3Id)); + update.Columns.Add(new DQUpdateColumn("SyncToB3DateTime", DateTime.Now)); + session.ExecuteNonQuery(update); + session.Commit(); + return b3Id; + } + } + return 0; + + } + + + [Rpc]//根据汇总码得到所有的 public static string GetWeightRecordList(string barcode) { @@ -39,7 +92,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc record = list[0]; return JsonConvert.SerializeObject(record); } - throw new Exception("无效条码"); + return ""; } private static SegmentationWeightRecord GetWeightRecordDmo(string barcode) @@ -52,7 +105,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc { return list[0]; } - throw new Exception("无效条码"); + return null; } private static readonly object _insertObj = new object(); @@ -71,14 +124,17 @@ namespace BWP.B3ClientService.Rpcs.BillRpc if (string.IsNullOrWhiteSpace(dmo.Goods_Name)) { var weight = GetWeightRecordDmo(dmo.BarCode); - dmo.Goods_ID = weight.Goods_ID; - dmo.Goods_Name = weight.Goods_Name; - dmo.Goods_Spec = weight.Goods_Spec; - dmo.Weight = weight.Weight; - dmo.BiaoShi = weight.BiaoShi; - dmo.ProductBatch = weight.ProductBatch; - dmo.CardBarCode = weight.CardBarCode; - dmo.CreateUserName = weight.CreateUserName; + if (weight != null) + { + dmo.Goods_ID = weight.Goods_ID; + dmo.Goods_Name = weight.Goods_Name; + dmo.Goods_Spec = weight.Goods_Spec; + dmo.Weight = weight.Weight; + dmo.BiaoShi = weight.BiaoShi; + dmo.ProductBatch = weight.ProductBatch; + dmo.CardBarCode = weight.CardBarCode; + dmo.CreateUserName = weight.CreateUserName; + } } UpdateWeightRecordInStored(session, dmo.BarCode); session.Insert(dmo); diff --git a/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecord_/SegmentationWeightRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecord_/SegmentationWeightRecordRpc.cs index 8269140..3564c51 100644 --- a/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecord_/SegmentationWeightRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecord_/SegmentationWeightRecordRpc.cs @@ -9,6 +9,7 @@ using BWP.B3Frameworks.Utils; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; +using Forks.EnterpriseServices.SqlDoms; using Forks.JsonRpc.Client; using Newtonsoft.Json; using TSingSoft.WebPluginFramework; @@ -23,6 +24,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc [Rpc] public static long CreateTodayB3OutputBill() { + //todo 一个批次一个单据 var serverUri = ServerHost.GetServerUrl(); if (string.IsNullOrEmpty(serverUri)) { @@ -178,6 +180,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc public static string GetNotInStoreList() { var query=new DmoQuery(typeof(SegmentationWeightRecord)); + query.Range=SelectRange.Top(50); query.Where.Conditions.Add(DQCondition.EQ("IsInStored",false)); var list = query.EExecuteList().Cast().ToList(); return JsonConvert.SerializeObject(list); diff --git a/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs index e62af6f..7959633 100644 --- a/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs @@ -72,13 +72,28 @@ namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_ } [Rpc] - public static long SimpleInsertOrUpdate(long goodsId,string goodsName,string barCode) + public static string GetFinalCode(string barCode) { -// var netUrl=new B3ClientServiceOnLineConfig().OutNetUrl; - if (barCode.Contains("http")) + var netUrl=new B3ClientServiceOnLineConfig().OutNetUrl; + barCode = barCode.Replace(netUrl+"?", ""); + + var code = UrlUtil.GetValueByKey("code", barCode); + if (string.IsNullOrWhiteSpace(code)) + { + code = UrlUtil.GetValueByKey("CODE", barCode); + } + if (string.IsNullOrWhiteSpace(code)) { - barCode = UrlUtil.GetValue("code", barCode); + code = barCode; } + return code; + + } + + [Rpc] + public static long SimpleInsertOrUpdate(long goodsId,string goodsName,string barCode) + { + using (var session = Dmo.NewSession()) { var record = GetExist(session, barCode); diff --git a/B3ClientService/Utils/UrlUtil.cs b/B3ClientService/Utils/UrlUtil.cs index 789a181..df85ce0 100644 --- a/B3ClientService/Utils/UrlUtil.cs +++ b/B3ClientService/Utils/UrlUtil.cs @@ -9,12 +9,16 @@ namespace BWP.B3ClientService.Utils { public class UrlUtil { - public static string GetValue(string name, string queryString) + + public static string GetValueByKey(string key, string queryString) { - var namevalues = GetQueryString(queryString); - return namevalues[name]; + var namevalue = GetQueryString(queryString); + if (namevalue.AllKeys.ToList().Contains(key)) + { + return namevalue[key]; + } + return ""; } - private static NameValueCollection GetQueryString(string queryString) { return GetQueryString(queryString, null, false);