diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 9d0cf81..1828194 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -82,10 +82,14 @@ + + + + @@ -110,6 +114,7 @@ + @@ -166,6 +171,7 @@ + diff --git a/B3ClientService/BO/BaseInfo/ProductBatch.cs b/B3ClientService/BO/BaseInfo/ProductBatch.cs new file mode 100644 index 0000000..4e2e3ea --- /dev/null +++ b/B3ClientService/BO/BaseInfo/ProductBatch.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Forks.EnterpriseServices.DomainObjects2; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.BO +{ + + [Serializable, BOClass] + [KeyField("ID", KeyGenType.assigned)] + public class ProductBatch + { + public long ID { get; set; } + public string Name { get; set; } + } +} diff --git a/B3ClientService/BO/BaseInfo/Store.cs b/B3ClientService/BO/BaseInfo/Store.cs new file mode 100644 index 0000000..a23f24a --- /dev/null +++ b/B3ClientService/BO/BaseInfo/Store.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + [Serializable] + public class Store: BaseInfo + { + + } +} diff --git a/B3ClientService/BO/BaseInfo/WorkShop.cs b/B3ClientService/BO/BaseInfo/WorkShop.cs new file mode 100644 index 0000000..82a1619 --- /dev/null +++ b/B3ClientService/BO/BaseInfo/WorkShop.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + [Serializable] + public class WorkShop:BaseInfo + { + } +} diff --git a/B3ClientService/BO/BaseInfo/WorkUnit.cs b/B3ClientService/BO/BaseInfo/WorkUnit.cs new file mode 100644 index 0000000..072fbcf --- /dev/null +++ b/B3ClientService/BO/BaseInfo/WorkUnit.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3ClientService.BO; + +namespace BWP.B3ClientService.BO + { + [Serializable] + public class WorkUnit:BaseInfo + { + public string Code { get; set; } + } +} diff --git a/B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs b/B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs index e3a2d5d..bd85386 100644 --- a/B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs +++ b/B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs @@ -24,6 +24,7 @@ namespace BWP.B3ClientService.BO public long Goods_ID { get; set; } public string Goods_Name { get; set; } + public string Goods_Spec { get; set; } public decimal PiWeight { get; set; }//皮重 diff --git a/B3ClientService/BO/SegmentationByPproductTrace_/SegmentationByPproductTrace.cs b/B3ClientService/BO/SegmentationByPproductTrace_/SegmentationByPproductTrace.cs new file mode 100644 index 0000000..8e2959e --- /dev/null +++ b/B3ClientService/BO/SegmentationByPproductTrace_/SegmentationByPproductTrace.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices.DomainObjects2; + +namespace BWP.B3ClientService.BO +{ + + /// + /// 分割品入库 + /// + [Serializable] + public class SegmentationByPproductTrace : Base + { + private DateTime mCreateTime = DateTime.Now; + [DbColumn(DbType = SqlDbType.DateTime)] + public DateTime CreateTime { get { return mCreateTime; } set { mCreateTime = value; } } + + public string BarCode { get; set; }//条码 + + public long? Goods_ID { get; set; } + + public string Goods_Name { get; set; } + + public string Goods_Spec { get; set; } + + public decimal Weight { get; set; } + + public DateTime? ProductTime { get; set; }//生产时间 + public DateTime? InStoreTime { get; set; }//入库时间 + public DateTime? SendTime { get; set; }//发货时间 + + public string Customer_Name { get; set; } + + public string CarNumber { get; set; }//车牌 + + public long? B3SaleOutStore_ID { get; set; } + } +} diff --git a/B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs b/B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs index 0fcb9fb..c2b3aa2 100644 --- a/B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs +++ b/B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs @@ -25,6 +25,7 @@ namespace BWP.B3ClientService.BO public long Goods_ID { get; set; } public string Goods_Name { get; set; } + public string Goods_Spec { get; set; } public decimal PiWeight { get; set; }//皮重 diff --git a/B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs b/B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs index e1b2ff1..e8e018f 100644 --- a/B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs +++ b/B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs @@ -23,5 +23,8 @@ namespace BWP.B3ClientService.BO public string CarcassStatus { get; set; }// 胴体状态 + public bool? IsSubmited { get; set; }//界面有2个状态 待提交 已提交 , 有条码有重量为已提交 + + public decimal? LossWeight{ get; set; }//损耗 } } diff --git a/B3ClientService/Rpcs/BaseInfoRpc.cs b/B3ClientService/Rpcs/BaseInfoRpc.cs index 84f71dd..ff007c2 100644 --- a/B3ClientService/Rpcs/BaseInfoRpc.cs +++ b/B3ClientService/Rpcs/BaseInfoRpc.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web.Script.Serialization; +using Newtonsoft.Json; using TSingSoft.WebPluginFramework; namespace BWP.B3ClientService.Rpcs @@ -19,6 +20,34 @@ namespace BWP.B3ClientService.Rpcs { static JavaScriptSerializer serializer = new JavaScriptSerializer(); + + [Rpc] + public static List GetWorkShopList(string input, string args, int top) + { + return GetBaseInfoList(input, args, top); + } + + [Rpc] + public static string GetWorkUnitList() + { + var query = new DmoQuery(typeof(WorkUnit)); + var list = query.EExecuteList().Cast().ToList(); + return JsonConvert.SerializeObject(list); + } + + [Rpc] + public static string GetProductBatchList(string input) + { + var query = new DmoQuery(typeof(ProductBatch)); + if (!string.IsNullOrEmpty(input)) + { + query.Where.Conditions.Add(DQCondition.Like("Name", input)); + } + var list = query.EExecuteList().Cast().ToList(); + return JsonConvert.SerializeObject(list); + } + + [Rpc] public static List GetCarList(string input, string args, int top) { diff --git a/B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs index b11deb3..86d931b 100644 --- a/B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs @@ -1,5 +1,6 @@ using System; using BWP.B3ClientService.BO; +using BWP.B3ClientService.Utils; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.JsonRpc; using Newtonsoft.Json; @@ -17,10 +18,23 @@ namespace BWP.B3ClientService.Rpcs.BillRpc using (var session = Dmo.NewSession()) { session.Insert(record); + var segmentationByPproductTrace = GetSegmentationByPproductTrace(record); + SegmentationByPproductTraceBL.Insert(session, segmentationByPproductTrace); session.Commit(); } return record.ID; } + private static SegmentationByPproductTrace GetSegmentationByPproductTrace(ByProductWeightRecord record) + { + var dmo = new SegmentationByPproductTrace(); + dmo.BarCode = record.BarCode; + dmo.Goods_ID = record.Goods_ID; + dmo.Goods_Name = record.Goods_Name; + dmo.Weight = record.JingWeight; + dmo.Goods_Spec = record.Goods_Spec; + dmo.ProductTime = record.CreateTime; + return dmo; + } } } diff --git a/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs index 81558cb..65a152c 100644 --- a/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using BWP.B3ClientService.BO; +using BWP.B3ClientService.Utils; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; @@ -22,11 +23,25 @@ namespace BWP.B3ClientService.Rpcs.BillRpc using (var session=Dmo.NewSession()) { session.Insert(record); + var segmentationByPproductTrace = GetSegmentationByPproductTrace(record); + SegmentationByPproductTraceBL.Insert(session, segmentationByPproductTrace); session.Commit(); } return record.ID; } + private static SegmentationByPproductTrace GetSegmentationByPproductTrace(SegmentationWeightRecord record) + { + var dmo = new SegmentationByPproductTrace(); + dmo.BarCode = record.BarCode; + dmo.Goods_ID = record.Goods_ID; + dmo.Goods_Name = record.Goods_Name; + dmo.Weight = record.JingWeight; + dmo.Goods_Spec = record.Goods_Spec; + dmo.ProductTime = record.CreateTime; + return dmo; + } + /// /// 获取为入库的 /// diff --git a/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs b/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs index 1705997..6d39248 100644 --- a/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs @@ -4,20 +4,59 @@ using BWP.B3Frameworks.Utils; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; +using Forks.EnterpriseServices.SqlDoms; using Newtonsoft.Json; +using TSingSoft.WebPluginFramework; namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_ { - //todo 这里需要维护大表 + [Rpc] public static class TrunksIousOutInStoreRecordRpc { + [Rpc] + public static string GetUnSubmitList() + { + var query = new DQueryDom(new JoinAlias(typeof(TrunksIousOutInStoreRecord))); + query.Where.Conditions.Add(DQCondition.Or(DQCondition.IsNull(DQExpression.Field("IsSubmited")), DQCondition.EQ("IsSubmited", false))); + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); + var list = query.EExecuteDmoList("ID", "BarCode", "Goods_Name", "Number", "Weight", "LossWeight"); + + return JsonConvert.SerializeObject(list); + } + + [Rpc] + public static string GetSubmitedList() + { + var query = new DQueryDom(new JoinAlias(typeof(TrunksIousOutInStoreRecord))); + query.Where.Conditions.Add(DQCondition.EQ("IsSubmited", true)); + query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); + query.Range = SelectRange.Top(50); + + var list = query.EExecuteDmoList("ID", "BarCode", "Goods_Name", "Number", "Weight", "LossWeight"); + + return JsonConvert.SerializeObject(list); + } + + [Rpc] + public static long SetWeight(long id,decimal weight) + { + var query = new DQUpdateDom(typeof(TrunksIousOutInStoreRecord)); + query.Columns.Add(new DQUpdateColumn("Weight", weight)); + query.Columns.Add(new DQUpdateColumn("IsSubmited", true)); +// query.Columns.Add(new DQUpdateColumn("LossWeight", )); +//todo 这里要算损耗 + query.Where.Conditions.Add(DQCondition.EQ("ID", id)); + query.EExecute(); + return id; + } + [Rpc] public static long Insert(string json) { var clientRecord = JsonConvert.DeserializeObject(json); - using (var session=Dmo.NewSession()) + using (var session = Dmo.NewSession()) { var record = new TrunksIousOutInStoreRecord(); DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID"); @@ -25,17 +64,34 @@ namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_ session.Commit(); return record.ID; } - + + } + + [Rpc] + public static long SimpleInsert(long goodsId,string goodsName,string barCode) + { + using (var session = Dmo.NewSession()) + { + var record = new TrunksIousOutInStoreRecord(); + record.Goods_ID = goodsId; + record.Goods_Name = goodsName; + record.BarCode = barCode; + record.IsSubmited = false; + session.Insert(record); + session.Commit(); + return record.ID; + } + } [Rpc] public static int Update(string json) { var clientRecord = JsonConvert.DeserializeObject(json); - using (var session=Dmo.NewSession()) + using (var session = Dmo.NewSession()) { - var record = session.Load(new DmoIdentity(typeof(TrunksIousOutInStoreRecord), clientRecord.Service_ID??0)); - DmoUtil.CopyDmoFields(clientRecord,record,"ID", "B3_ID"); + var record = session.Load(new DmoIdentity(typeof(TrunksIousOutInStoreRecord), clientRecord.Service_ID ?? 0)); + DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID"); session.Update(record); } return 1; @@ -45,8 +101,8 @@ namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_ public static int Delete(long id) { var delDom = new DQDeleteDom(typeof(TrunksIousOutInStoreRecord)); - delDom.Where.Conditions.Add(DQCondition.EQ("ID",id)); - using (var session=Dmo.NewSession()) + delDom.Where.Conditions.Add(DQCondition.EQ("ID", id)); + using (var session = Dmo.NewSession()) { session.Update(delDom); } diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index 52b9d29..21d6f73 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -57,11 +57,82 @@ namespace BWP.B3ClientService.Tasks SyncClientGoodsSet(); SyncCustomer(); SyncDeliverGoodsLine(); + + SyncWorkShop(); + SyncWorkUnit(); + SyncProductBatch(); + SyncStore(); } //catch { } } + private void SyncStore() + { + var json = RpcFacade.Call("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncStoreList"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_Store];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (BO.Store dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + } + + private void SyncProductBatch() + { + var json = RpcFacade.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/SyncProductBatch"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_ProductBatch];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (ProductBatch dmo in list) + { +// var dmo = new ProductBatch(); +// dmo.Name = name; + context.Session.Insert(dmo); + } + context.Commit(); + } + } + + private void SyncWorkUnit() + { + var json = RpcFacade.Call("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncWorkUnitList"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_WorkUnit];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (WorkUnit dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + } + + private void SyncWorkShop() + { + var json = RpcFacade.Call("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncWorkShopList"); + var list = JsonConvert.DeserializeObject>(json); + using (var context = new TransactionContext()) + { + var sql1 = @"truncate table [B3ClientService_WorkShop];"; + context.Session.ExecuteSqlNonQuery(sql1); + foreach (WorkShop dmo in list) + { + context.Session.Insert(dmo); + } + context.Commit(); + } + } + private void SyncDeliverGoodsLine() { var json = RpcFacade.Call("/MainSystem/B3Sale/Rpcs/OffLineRpc/OffLineBaseInfo/OffLineBaseInfoRpc/SyncDeliverGoodsLineList"); diff --git a/B3ClientService/Utils/SegmentationByPproductTraceBL.cs b/B3ClientService/Utils/SegmentationByPproductTraceBL.cs new file mode 100644 index 0000000..c2cf830 --- /dev/null +++ b/B3ClientService/Utils/SegmentationByPproductTraceBL.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.Utils +{ + public class SegmentationByPproductTraceBL + { + public static long Insert(IDmoSession session, SegmentationByPproductTrace dmo) + { + session.Insert(dmo); + return dmo.ID; + } + + public static void SetInStoreTime(string barCode, DateTime inStoreTime) + { + using (var session = Dmo.NewSession()) + { + var id = CheckIsExistByBarCode(session, barCode); + var dqupdateDom = new DQUpdateDom(typeof(SegmentationByPproductTrace)); + dqupdateDom.Where.Conditions.Add(DQCondition.EQ("ID", id)); + dqupdateDom.Columns.Add(new DQUpdateColumn("InStoreTime", inStoreTime)); + session.ExecuteNonQuery(dqupdateDom); + session.Commit(); + } + } + + public static void SetSendInfo(string barCode, DateTime sendTime,string customerName,string carNumber,long? saleOutStoreId=null) + { + using (var session = Dmo.NewSession()) + { + var id = CheckIsExistByBarCode(session, barCode); + var dqupdateDom = new DQUpdateDom(typeof(SegmentationByPproductTrace)); + dqupdateDom.Where.Conditions.Add(DQCondition.EQ("ID", id)); + dqupdateDom.Columns.Add(new DQUpdateColumn("SendTime", sendTime)); + dqupdateDom.Columns.Add(new DQUpdateColumn("CarNumber", carNumber)); + dqupdateDom.Columns.Add(new DQUpdateColumn("Customer_Name", customerName)); + dqupdateDom.Columns.Add(new DQUpdateColumn("B3SaleOutStore_ID", saleOutStoreId)); + session.ExecuteNonQuery(dqupdateDom); + session.Commit(); + } + } + + private static long CheckIsExistByBarCode(IDmoSessionWithTransaction session, string barCode) + { + var query = new DQueryDom(new JoinAlias(typeof(SegmentationByPproductTrace))); + query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); + query.Columns.Add(DQSelectColumn.Field("ID")); + var res = query.EExecuteScalar(session); + if (res == null) + { + throw new Exception("不存在条码为:" + barCode + " 的记录"); + } + return res.Value; + } + } +}