diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 824d1f7..ae7c73f 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -74,6 +74,8 @@ + + @@ -88,10 +90,12 @@ + + @@ -123,6 +127,7 @@ + @@ -153,6 +158,7 @@ + diff --git a/B3ClientService/BO/BaseInfo/Customer.cs b/B3ClientService/BO/BaseInfo/Customer.cs new file mode 100644 index 0000000..37c144f --- /dev/null +++ b/B3ClientService/BO/BaseInfo/Customer.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + [Serializable] + public class Customer : BaseInfo + { + } +} diff --git a/B3ClientService/BO/BaseInfo/DeliverGoodsLine.cs b/B3ClientService/BO/BaseInfo/DeliverGoodsLine.cs new file mode 100644 index 0000000..cbc076c --- /dev/null +++ b/B3ClientService/BO/BaseInfo/DeliverGoodsLine.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + + [Serializable] + public class DeliverGoodsLine: BaseInfo + { + } +} diff --git a/B3ClientService/BO/Bill/GoodsDetail.cs b/B3ClientService/BO/Bill/GoodsDetail.cs new file mode 100644 index 0000000..8f74052 --- /dev/null +++ b/B3ClientService/BO/Bill/GoodsDetail.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DomainObjects2; + +namespace BWP.B3ClientService.BO +{ + public abstract class GoodsDetail:Base + { + [LogicName("存货编码")] + public string Goods_Code { get; set; } + + [LogicName("存货")] + public string Goods_Name { get; set; } + + [LogicName("主数量")] + public decimal? Number { get; set; } + + [LogicName("辅数量")] + public decimal? SecondNumber { get; set; } + + [LogicName("报价单位")] + public string Unit { get; set; } + + [LogicName("报价数量")] + public decimal? UnitNum { get; set; } + + [LogicName("主单位比率")] + [DbColumn(DefaultValue = 1)] + public decimal LeftRatio { get; set; } + + [LogicName("辅单位比率")] + [DbColumn(DefaultValue = 1)] + public decimal RightRatio { get; set; } + + [LogicName("主单位")] + public string Goods_MainUnit { get; set; } + + [LogicName("辅单位")] + public string Goods_SecondUnit { get; set; } + + [LogicName("主辅转换方向")] + public string Goods_UnitConvertDirection { get; set; } + + [LogicName("主辅换算主单位比例")] + public decimal? Goods_MainUnitRatio { get; set; } + + [LogicName("主辅换算辅单位比例")] + public decimal? Goods_SecondUnitRatio { get; set; } + + } +} diff --git a/B3ClientService/BO/Bill/SaleOutStore_/SaleOutStore.cs b/B3ClientService/BO/Bill/SaleOutStore_/SaleOutStore.cs new file mode 100644 index 0000000..aebc1bd --- /dev/null +++ b/B3ClientService/BO/Bill/SaleOutStore_/SaleOutStore.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; + +namespace BWP.B3ClientService.BO +{ + [DFClass,Serializable] + public class SaleOutStore: GoodsDetail + { + [LogicName("出库单号")] + public long SaleOutStore_ID { get; set; } + + [LogicName("购货客户")] + public string Customer_Name { get; set; } + + [LogicName("送货地址")] + [DbColumn(Length = 100)] + public string DeliverAddress { get; set; } + + [LogicName("仓库")] + public string Store_Name { get; set; } + + + [LogicName("运输车辆")] + public string Car { get; set; } + + [LogicName("发货时间")] + public DateTime? LoadTime { get; set; } + + [LogicName("单据状态")] + public string BillState { get; set; } + + + + + [LogicName("销售出库明细ID")] + public long SaleOutStoreDetail_ID { get; set; } + + + + } +} diff --git a/B3ClientService/Rpcs/BillRpc/BaseInfoRpc.cs b/B3ClientService/Rpcs/BillRpc/BaseInfoRpc.cs new file mode 100644 index 0000000..0e1d75b --- /dev/null +++ b/B3ClientService/Rpcs/BillRpc/BaseInfoRpc.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.JsonRpc; +using Newtonsoft.Json; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.Rpcs.BillRpc +{ + [Rpc] + public static class BaseInfoRpc + { + [Rpc] + public static string SyncCustomer(string input) + { + var dmoquery = new DmoQuery(typeof(Customer)); + if (!string.IsNullOrWhiteSpace(input)) + { + dmoquery.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name", input), DQCondition.Like("Spell", input))); + } + var list = dmoquery.EExecuteList().Cast().ToList(); + return JsonConvert.SerializeObject(list); + } + [Rpc] + public static string SyncDeliverGoodsLine(string input) + { + var dmoquery = new DmoQuery(typeof(DeliverGoodsLine)); + if (!string.IsNullOrWhiteSpace(input)) + { + dmoquery.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name",input),DQCondition.Like("Spell",input))); + } + var list = dmoquery.EExecuteList().Cast().ToList(); + return JsonConvert.SerializeObject(list); + } + } +} diff --git a/B3ClientService/Tasks/SyncBillFromServer.cs b/B3ClientService/Tasks/SyncBillFromServer.cs new file mode 100644 index 0000000..c34214e --- /dev/null +++ b/B3ClientService/Tasks/SyncBillFromServer.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.JsonRpc.Client; +using Forks.JsonRpc.Client.Data; +using Newtonsoft.Json; +using TSingSoft.WebPluginFramework.TimerTasks; + +namespace BWP.B3ClientService.Tasks +{ + public class SyncBillFromServer : ITimerTask + { + public void Execute() + { + var serverUri = ServerHost.GetServerUrl(); + if (string.IsNullOrEmpty(serverUri)) + throw new Exception("请配置服务器地址"); + //try + { + try + { + RpcFacade.Init(serverUri, "B3ClientServer"); + } + catch (Exception ex) + { + if (ex.Message != "Can only start once") + throw; + } + + SyncSaleOutStore(); + + + } + } + + private void SyncSaleOutStore() + { + //只更新一个星期的 + var minDate = DateTime.Today.AddDays(-7); + var json = RpcFacade.Call("/MainSystem/B3Sale/Rpcs/OffLineRpc/OffLineSaleOutStore/OffLineSaleOutStoreRpc/GetSaleOutStoreList", minDate); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_SaleOutStore];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (SaleOutStore dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + } + + public string Name { get { return "从B3同步单据到Server服务器"; }} + } +} diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index 73540f5..967bfa8 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -55,15 +55,52 @@ namespace BWP.B3ClientService.Tasks SyncLiveVarieties(); SyncBodyDiscontItem(); SyncClientGoodsSet(); + SyncCustomer(); + SyncDeliverGoodsLine(); } //catch { } } + private void SyncDeliverGoodsLine() + { + var json = RpcFacade.Call("/MainSystem/B3Sale/Rpcs/OffLineRpc/OffLineBaseInfo/OffLineBaseInfoRpc/SyncDeliverGoodsLineList"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_DeliverGoodsLine];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (DeliverGoodsLine dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + + } + + private void SyncCustomer() + { + var json = RpcFacade.Call("/MainSystem/B3Sale/Rpcs/OffLineRpc/OffLineBaseInfo/OffLineBaseInfoRpc/SyncCustomerList"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_Customer];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (Customer dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + + } + + private void SyncClientGoodsSet() { var jsonStr = RpcFacade.Call("/MainSystem/B3ButcherManageForClient/Rpcs/ClientGoodsSetRpc/GetList"); - var list =JsonConvert.DeserializeObject>(jsonStr); + var list = JsonConvert.DeserializeObject>(jsonStr); using (var context = new TransactionContext()) { var sql1 = @"truncate table [B3ClientService_ClientGoodsSet];truncate table [B3ClientService_ClientGoodsSet_Detail];"; @@ -178,7 +215,7 @@ namespace BWP.B3ClientService.Tasks void SyncLivestock() { var result = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetLivestock"); - var list = serializer.Deserialize>>(result); + var list = serializer.Deserialize>>(result); using (var context = new TransactionContext()) { var sql1 = @"truncate table [B3ClientService_Livestock];";