From 15f9e70aacd611f2d1c0be4f9c104bc50d153e11 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Mon, 2 Apr 2018 00:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=9A=E5=8A=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3ClientService/B3ClientService.csproj | 4 +- B3ClientService/BO/Bill/CarcassFullInfo.cs | 101 ++++++++++++++++++ B3ClientService/NamedValueTemplate.cs | 6 ++ .../OfflinRpc/CarcassInStoreRpc.cs | 84 ++++++++++++++- B3ClientService/OfflinRpc/ExtensionObj.cs | 18 ++++ B3ClientService/OfflinRpc/GradeAndWeightBL.cs | 75 +++++++++++++ B3ClientService/OfflinRpc/SimpleBackObjs.cs | 14 --- .../Rpcs/BillRpc/GradeAndWeightRpc.cs | 9 +- .../config/NamedValue/B3ClientService.xml | 4 + 9 files changed, 295 insertions(+), 20 deletions(-) create mode 100644 B3ClientService/BO/Bill/CarcassFullInfo.cs create mode 100644 B3ClientService/OfflinRpc/ExtensionObj.cs create mode 100644 B3ClientService/OfflinRpc/GradeAndWeightBL.cs delete mode 100644 B3ClientService/OfflinRpc/SimpleBackObjs.cs diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 3735f65..c5ec622 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -101,6 +101,7 @@ + @@ -148,8 +149,9 @@ + + - diff --git a/B3ClientService/BO/Bill/CarcassFullInfo.cs b/B3ClientService/BO/Bill/CarcassFullInfo.cs new file mode 100644 index 0000000..f415ef5 --- /dev/null +++ b/B3ClientService/BO/Bill/CarcassFullInfo.cs @@ -0,0 +1,101 @@ +using BWP.B3ClientService.NamedValueTemplate; +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DataDictionary; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.Utils; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + + [DBIndex("IDX_B3ClientService_CarcassFullInfo_Clustered", "BarCode", false, 0)] + [DBIndexType("IDX_B3ClientService_CarcassFullInfo_Clustered", IndexType.Normal)] + [DFClass] + [LogicName("白条数据表")] + public class CarcassFullInfo : Base + { + public CarcassFullInfo() + { + CreateTime = DateTime.Now; + } + + [DbColumn(DbType = SqlDbType.DateTime)] + [LogicName("创建时间")] + public DateTime CreateTime { get; set; } + + [DbColumn(AllowNull = false, Unique = true)] + [LogicName("条码")] + public string BarCode { get; set; } + + #region 定级信息 + + [LogicName("屠宰日期")] + public DateTime? ButcherDate { get; set; } + + [DbColumn(DbType = SqlDbType.DateTime)] + [LogicName("定级时间")] + public DateTime? GradeTime { get; set; } + + [LogicName("定级员")] + public long? GradeWorker_ID { get; set; } + + [LogicName("胴体级别")] + public long? Livestock_ID { get; set; } + + [LogicName("胴体重量")] + public decimal? GradeWeight { get; set; } + + #endregion + + #region 入库信息 + + [LogicName("入库员")] + public long? InStoreWorker_ID { get; set; } + + [LogicName("工作单元")] + public long? WorkUnit_ID { get; set; } + + [LogicName("生产批次")] + public long? ProductBatch_ID { get; set; } + + [LogicName("入库存货")] + public long? InStoreGoods_ID { get; set; } + + [LogicName("入库重量")] + public decimal? InStoreWeight { get; set; } + + [LogicName("入库时间")] + [DbColumn(DbType = SqlDbType.DateTime)] + public DateTime? InStoreTime { get; set; } + + #endregion + + #region 领用信息 + + [LogicName("领用人员")] + public long? PickWorker_ID { get; set; } + + [LogicName("领用时间")] + public DateTime? PickTime { get; set; } + + [LogicName("领用类型")] + public NamedValue<领用类型>? PickType { get; set; } + + [LogicName("销售存货")] + public long? SaleGoods_ID { get; set; } + + [LogicName("领用重量")] + public decimal? PickWeight { get; set; } + + [LogicName("领用重量")] + public long? PickGroupID { get; set; } + + #endregion + } +} diff --git a/B3ClientService/NamedValueTemplate.cs b/B3ClientService/NamedValueTemplate.cs index dd834bc..90ebe91 100644 --- a/B3ClientService/NamedValueTemplate.cs +++ b/B3ClientService/NamedValueTemplate.cs @@ -27,4 +27,10 @@ namespace BWP.B3ClientService.NamedValueTemplate public static readonly NamedValue<适用客户端> 分割品 = new NamedValue<适用客户端>(1); public static readonly NamedValue<适用客户端> 副产品 = new NamedValue<适用客户端>(2); } + + public sealed class 领用类型 + { + public static readonly NamedValue<领用类型> 分割领用 = new NamedValue<领用类型>(0); + public static readonly NamedValue<领用类型> 白条销售 = new NamedValue<领用类型>(1); + } } diff --git a/B3ClientService/OfflinRpc/CarcassInStoreRpc.cs b/B3ClientService/OfflinRpc/CarcassInStoreRpc.cs index a2986d9..458fc0b 100644 --- a/B3ClientService/OfflinRpc/CarcassInStoreRpc.cs +++ b/B3ClientService/OfflinRpc/CarcassInStoreRpc.cs @@ -45,6 +45,8 @@ namespace BWP.B3ClientService.Rpcs { if (string.IsNullOrEmpty(barCode)) throw new Exception("编码为空"); + if (barCode.Length != 23) + throw new Exception("条码格式不正确"); using (var session = Dmo.NewSession()) { var id = CheckExist(barCode, session); @@ -116,7 +118,7 @@ namespace BWP.B3ClientService.Rpcs [Rpc(RpcFlags.SkipAuth)] public static int SetPadDataSync(string backInfo) { - var arr = JsonConvert.DeserializeObject>(backInfo); + var arr = JsonConvert.DeserializeObject>(backInfo); using (var session = Dmo.NewSession()) { foreach (var item in arr) @@ -126,17 +128,80 @@ namespace BWP.B3ClientService.Rpcs return 1; } - static void UpdateSynced(IDRowVersion info, IDmoSession session) + static void UpdateSynced(ExtensionObj info, IDmoSession session) { var update = new DQUpdateDom(typeof(PadCarcassInStore)); update.Columns.Add(new DQUpdateColumn("Sync", true)); - update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", info.ID), DQCondition.EQ("RowVersion", info.RowVersion))); + update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", info.LongExt1), DQCondition.EQ("RowVersion", info.DecimalExt1))); session.ExecuteNonQuery(update); } #endregion + [Rpc(RpcFlags.SkipAuth)] + public static int UploadCarcassInfo(string json) + { + var list = JsonConvert.DeserializeObject>(json); + using (var session = Dmo.NewSession()) + { + foreach (var item in list) + { + var id = GetID(item.BarCode, session); + if (id.HasValue) + Update(id.Value, item, session); + else + Insert(item, session); + } + session.Commit(); + } + return 1; + } + + static long? GetID(string code, IDmoSession session) + { + var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Where.Conditions.Add(DQCondition.EQ("BarCode", code)); + return query.EExecuteScalar(session); + } + static void Update(long id, CarcassInStoreObj obj, IDmoSession session) + { + var update = new DQUpdateDom(typeof(CarcassFullInfo)); + update.Columns.Add(new DQUpdateColumn("InStoreWorker_ID", obj.InStoreWorker_ID)); + update.Columns.Add(new DQUpdateColumn("WorkUnit_ID", obj.WorkUnit_ID)); + update.Columns.Add(new DQUpdateColumn("ProductBatch_ID", obj.ProductBatch_ID)); + update.Columns.Add(new DQUpdateColumn("InStoreGoods_ID", obj.InStoreGoods_ID)); + update.Columns.Add(new DQUpdateColumn("InStoreWeight", obj.InStoreWeight)); + update.Columns.Add(new DQUpdateColumn("InStoreTime", obj.InStoreTime)); + update.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(update); + } + + static void Insert(CarcassInStoreObj obj, IDmoSession session) + { + var entity = new CarcassFullInfo(); + entity.BarCode = obj.BarCode; + entity.InStoreWorker_ID = obj.InStoreWorker_ID; + entity.WorkUnit_ID = obj.WorkUnit_ID; + entity.ProductBatch_ID = obj.ProductBatch_ID; + entity.InStoreGoods_ID = obj.InStoreGoods_ID; + entity.InStoreWeight = obj.InStoreWeight; + entity.InStoreTime = obj.InStoreTime; + session.Insert(entity); + } + + [Rpc(RpcFlags.SkipAuth)] + public static string GetWeightInfo(List codeList) + { + var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo))); + query.Columns.Add(DQSelectColumn.Field("BarCode")); + query.Columns.Add(DQSelectColumn.Field("GradeWeight")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("GradeWeight")), DQCondition.InList(DQExpression.Field("BarCode"), codeList.Select(x => DQExpression.Value(x)).ToArray()))); + var result = query.EExecuteList(); + var back = result.Select(x => new ExtensionObj { StringExt1 = x.Item1, DecimalExt1 = x.Item2 }); + return JsonConvert.SerializeObject(back); + } } class MinGoodsObj @@ -144,4 +209,17 @@ namespace BWP.B3ClientService.Rpcs public long Goods_ID { get; set; } public string Goods_Name { get; set; } } + + class CarcassInStoreObj + { + public long ID { get; set; } + public int RowVersion { get; set; } + public string BarCode { get; set; } + public long? InStoreWorker_ID { get; set; } + public long? WorkUnit_ID { get; set; } + public long? ProductBatch_ID { get; set; } + public long? InStoreGoods_ID { get; set; } + public decimal? InStoreWeight { get; set; } + public DateTime? InStoreTime { get; set; } + } } diff --git a/B3ClientService/OfflinRpc/ExtensionObj.cs b/B3ClientService/OfflinRpc/ExtensionObj.cs new file mode 100644 index 0000000..bf8c59e --- /dev/null +++ b/B3ClientService/OfflinRpc/ExtensionObj.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3ClientService.BO +{ + public class ExtensionObj + { + public long? LongExt1 { get; set; } + + public long? LongExt2 { get; set; } + + public decimal? DecimalExt1 { get; set; } + + public string StringExt1 { get; set; } + } +} diff --git a/B3ClientService/OfflinRpc/GradeAndWeightBL.cs b/B3ClientService/OfflinRpc/GradeAndWeightBL.cs new file mode 100644 index 0000000..f03ce88 --- /dev/null +++ b/B3ClientService/OfflinRpc/GradeAndWeightBL.cs @@ -0,0 +1,75 @@ +using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.BL +{ + public static class GradeAndWeightBL + { + public static void UpdataOrInsert(GradeAndWeight_Detail obj, IDmoSession session) + { + if (string.IsNullOrEmpty(obj.BarCode)) + return; + var id = GetID(obj.BarCode, session); + if (id.HasValue) + Update(id.Value, obj, session); + else + Insert(obj, session); + } + + static long? GetID(string code, IDmoSession session) + { + var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Where.Conditions.Add(DQCondition.EQ("BarCode", code)); + return query.EExecuteScalar(session); + } + + static void Update(long id, GradeAndWeight_Detail obj, IDmoSession session) + { + var update = new DQUpdateDom(typeof(CarcassFullInfo)); + update.Columns.Add(new DQUpdateColumn("ButcherDate", obj.Date)); + update.Columns.Add(new DQUpdateColumn("GradeTime", obj.Time)); + //update.Columns.Add(new DQUpdateColumn("GradeWorker_ID", obj.Worker_ID)); + update.Columns.Add(new DQUpdateColumn("Livestock_ID", obj.Livestock_ID)); + update.Columns.Add(new DQUpdateColumn("GradeWeight", obj.Weight)); + update.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(update); + } + + static void Insert(GradeAndWeight_Detail obj, IDmoSession session) + { + var entity = new CarcassFullInfo(); + entity.BarCode = obj.BarCode; + entity.ButcherDate = obj.Date; + entity.GradeTime = obj.Time; + //entity.GradeWorker_ID = obj.Worker_ID; + entity.Livestock_ID = obj.Livestock_ID; + entity.GradeWeight = obj.Weight; + session.Insert(entity); + } + + public static void Delete(string barCode, IDmoSession session) + { + if (string.IsNullOrEmpty(barCode)) + return; + var id = GetID(barCode, session); + if (id == null) + return; + + var update = new DQUpdateDom(typeof(CarcassFullInfo)); + update.Columns.Add(new DQUpdateColumn("ButcherDate", null)); + update.Columns.Add(new DQUpdateColumn("GradeTime", null)); + //update.Columns.Add(new DQUpdateColumn("GradeWorker_ID", obj.)); + update.Columns.Add(new DQUpdateColumn("Livestock_ID", null)); + update.Columns.Add(new DQUpdateColumn("GradeWeight", null)); + update.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(update); + } + } +} diff --git a/B3ClientService/OfflinRpc/SimpleBackObjs.cs b/B3ClientService/OfflinRpc/SimpleBackObjs.cs deleted file mode 100644 index 82a347d..0000000 --- a/B3ClientService/OfflinRpc/SimpleBackObjs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BWP.B3ClientService.Rpcs -{ - public class IDRowVersion - { - public long ID { get; set; } - - public int RowVersion { get; set; } - } -} diff --git a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs index d198efe..d2e1da6 100644 --- a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs @@ -1,4 +1,5 @@ -using BWP.B3ClientService.BO; +using BWP.B3ClientService.BL; +using BWP.B3ClientService.BO; using BWP.B3ClientService.RpcBO; using BWP.B3ClientService.Rpcs.RpcBO; using BWP.B3Frameworks.Utils; @@ -73,7 +74,10 @@ namespace BWP.B3ClientService.Rpcs.BillRpc using (var session = Dmo.NewSession()) { if (entity.IsDeleted) + { + GradeAndWeightBL.Delete(entity.BarCode, session); session.Delete(new DmoIdentity(typeof(GradeAndWeight_Detail), entity.ID)); + } else { entity.ID = GetIDIfExist(session, entity.SID) ?? 0; @@ -81,6 +85,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc session.Insert(entity); else session.Update(entity); + GradeAndWeightBL.UpdataOrInsert(entity, session); } session.Commit(); } @@ -152,7 +157,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc var list = new List(); while (reader.Read()) { - list.Add(new DataConfirmList { Order = (int)reader[0], PlanNumber = (int)reader[1], HotFadeNumber = (int?)reader[2] ?? 0 ,WeightID=(long?)reader[3]}); + list.Add(new DataConfirmList { Order = (int)reader[0], PlanNumber = (int)reader[1], HotFadeNumber = (int?)reader[2] ?? 0, WeightID = (long?)reader[3] }); } return serializer.Serialize(list); } diff --git a/WebFolder/config/NamedValue/B3ClientService.xml b/WebFolder/config/NamedValue/B3ClientService.xml index 2ad7be8..6d0fd8b 100644 --- a/WebFolder/config/NamedValue/B3ClientService.xml +++ b/WebFolder/config/NamedValue/B3ClientService.xml @@ -16,4 +16,8 @@ + + + + \ No newline at end of file