From 3af1b85247031e328a718c968726c6017a86741d Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Wed, 9 May 2018 14:37:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E5=8F=91=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3QingDaoWanFu.Web/PluginClass.cs | 1 - .../Tasks/SyncSaleOutStoreInfoToMES.cs | 68 ++----------------- .../TypeIOCs/SaleOutStoreBLTypeIoc.cs | 17 +---- 3 files changed, 10 insertions(+), 76 deletions(-) diff --git a/B3QingDaoWanFu.Web/PluginClass.cs b/B3QingDaoWanFu.Web/PluginClass.cs index 84eac5d..53e1a09 100644 --- a/B3QingDaoWanFu.Web/PluginClass.cs +++ b/B3QingDaoWanFu.Web/PluginClass.cs @@ -30,7 +30,6 @@ namespace BWP.B3QingDaoWanFu GlobalFlags.On(B3SaleConsts.Flags.SendOutStoreNoAvailableStorage); GlobalFlags.On(B3SaleConsts.Flags.CustAcceptAnalyseHasFactoryPrice); GlobalFlags.On(B3ButcherManageConsts.GlobalFlags.预付款单不关联过磅单); - GlobalFlags.On(B3SaleConsts.Flags.SaleOutStoreEnableScan); GlobalFlags.On(B3SaleConsts.Flags.EnableABCPay); TimerConfig.Register(() => "* * * * *", new QueryTrustPayTask()); diff --git a/B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs b/B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs index 563e404..84ae278 100644 --- a/B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs +++ b/B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs @@ -45,34 +45,25 @@ namespace BWP.B3QingDaoWanFu.Tasks var main = new JoinAlias(typeof(SaleOutStore)); var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); var detail = new JoinAlias(typeof(SaleOutStore_Detail)); - var weight = new JoinAlias(typeof(WeightingInfor)); var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); - var temp = new JoinAlias(typeof(Temp)); var query = new DQueryDom(main); query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); - query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); - query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID"))); - query.RegisterQueryTable(typeof(Temp), new string[] { "GroupID", "Weight" }, Temp.GetQueryDom()); - query.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(detail, "ID", temp, "GroupID")); + query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.EQ(detail, "ID", scan, "Detail_ID")); query.Columns.Add(DQSelectColumn.Field("ID", main)); query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); - query.Columns.Add(DQSelectColumn.Field("NetWeight", weight)); - query.Columns.Add(DQSelectColumn.Field("ID", detail)); + query.Columns.Add(DQSelectColumn.Field("Weight", scan)); + query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID", scan)); query.Columns.Add(DQSelectColumn.Field("LoadTime", main)); - query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); - query.Columns.Add(DQSelectColumn.Field("Weight", temp)); - + query.Columns.Add(DQSelectColumn.Field("Goods_Code", scan)); query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); - query.OrderBy.Expressions.Add(DQOrderByExpression.Create(weight, "NetWeight", true)); using (var session = Dmo.NewSession()) { var list = new List(); var ids = new List(); - var discont = new Dictionary(); using (var reader = session.ExecuteReader(query)) { while (reader.Read()) @@ -82,18 +73,10 @@ namespace BWP.B3QingDaoWanFu.Tasks ids.Add(id); var entity = new CarcassSaleOutStoreObj(); entity.BarCode = (string)reader[1]; - var wv = ((Money?)reader[2]).EToDecimal(); - entity.GroupID = (long)reader[3]; - if (wv < 0) - { - var first = list.FirstOrDefault(x => x.GroupID == entity.GroupID && x.BarCode == entity.BarCode); - if (first != null) - list.Remove(first); - continue; - } + entity.Weight = (decimal?)reader[2]; + entity.ProductBatch_ID = (long?)reader[3]; entity.Time = (DateTime?)reader[4]; entity.SaleGoods_Code = (string)reader[5]; - entity.Weight = (decimal?)reader[6]; list.Add(entity); } } @@ -101,18 +84,6 @@ namespace BWP.B3QingDaoWanFu.Tasks return; if (list.Any()) { - foreach (var g in list.GroupBy(x => x.GroupID)) - { - var first = true; - foreach (var item in g) - { - if (first) - first = false; - else - item.Weight = 0; - } - } - var slist = TraceBackInfoUtil.SplitList(list, 1000); foreach (var items in slist) { @@ -132,31 +103,6 @@ namespace BWP.B3QingDaoWanFu.Tasks { get { return "上传审核的销售出库扫码信息到MES"; } } - - class Temp - { - public long GroupID { get; set; } - public decimal? Weight { get; set; } - - public static DQueryDom GetQueryDom() - { - var main = new JoinAlias(typeof(SaleOutStore)); - var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); - var detail = new JoinAlias(typeof(SaleOutStore_Detail)); - var weight = new JoinAlias(typeof(WeightingInfor)); - var query = new DQueryDom(main); - query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); - query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); - query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); - - query.Columns.Add(DQSelectColumn.Field("ID", detail)); - query.Columns.Add(DQSelectColumn.Sum(weight, "NetWeight")); - query.GroupBy.Expressions.Add(DQExpression.Field(detail, "ID")); - - query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(weight, "ID")))); - return query; - } - } } class CarcassSaleOutStoreObj @@ -164,7 +110,7 @@ namespace BWP.B3QingDaoWanFu.Tasks public string BarCode { get; set; } public decimal? Weight { get; set; } public DateTime? Time { get; set; } - public long? GroupID { get; set; } public string SaleGoods_Code { get; set; } + public long? ProductBatch_ID { get; set; } } } diff --git a/B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs b/B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs index 9f9823f..0fa6668 100644 --- a/B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs +++ b/B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs @@ -151,38 +151,27 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs { var detail = new JoinAlias(typeof(SaleOutStore_Detail)); var bill = new JoinAlias(typeof(SaleOutStore)); - var weight = new JoinAlias(typeof(WeightingInfor)); var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); var query = new DQueryDom(detail); query.From.AddJoin(JoinType.Left, new DQDmoSource(bill), DQCondition.EQ(detail, "SaleOutStore_ID", bill, "ID")); - query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); - query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID"))); + query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.EQ(detail, "ID", scan, "Detail_ID")); query.Columns.Add(DQSelectColumn.Field("Customer_Name", bill)); query.Columns.Add(DQSelectColumn.Field("Car_Name", bill)); query.Columns.Add(DQSelectColumn.Field("LoadTime", bill)); query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); - query.Columns.Add(DQSelectColumn.Field("NetWeight", weight)); query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(detail, "SaleOutStore_ID", id), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); - query.OrderBy.Expressions.Add(DQOrderByExpression.Create(weight, "NetWeight", true)); + query.Where.Conditions.Add(DQCondition.InEQ(scan, "BarCode", "")); var list = new List(); using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var entity = new TractBillSaleInfo(); - entity.Code = (string)reader[3]; - var wv = (Money)reader[4]; - if (wv < 0) - { - var first = list.FirstOrDefault(x => x.Code == entity.Code); - if (first != null) - list.Remove(first); - continue; - } entity.SendCustomer = (string)reader[0]; entity.CarNo = (string)reader[1]; entity.SendDate = ((DateTime)reader[2]).ToString("yyyyMMdd"); + entity.Code = (string)reader[3]; list.Add(entity); } }