From 36e4934d3698e005af3f091269be215fb62131a4 Mon Sep 17 00:00:00 2001 From: gaowenwei Date: Thu, 14 Dec 2017 19:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8D=95No.137222=EF=BC=9A1.?= =?UTF-8?q?=E3=80=90=E7=BB=93=E7=AE=97=E5=8D=95=E3=80=91=E5=AF=BC=E7=94=A8?= =?UTF-8?q?=E5=8F=8B=E3=80=90=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E3=80=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BL/U8/StatPayToU8BL_/StatPayToU8BL.cs | 66 +++++++++++++++++-- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/BWP.B3ButcherManageExport/BL/U8/StatPayToU8BL_/StatPayToU8BL.cs b/BWP.B3ButcherManageExport/BL/U8/StatPayToU8BL_/StatPayToU8BL.cs index e670280..5dadfef 100644 --- a/BWP.B3ButcherManageExport/BL/U8/StatPayToU8BL_/StatPayToU8BL.cs +++ b/BWP.B3ButcherManageExport/BL/U8/StatPayToU8BL_/StatPayToU8BL.cs @@ -5,6 +5,8 @@ using BWP.B3ExportBase.BO; using BWP.B3Frameworks; using Forks.EnterpriseServices; using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; using System; using System.Collections.Generic; using System.Linq; @@ -27,16 +29,20 @@ namespace BWP.B3ButcherManageExport.BL { protected override Ufinterface CreateUfinterface(IList dmos) { + if (string.IsNullOrEmpty(Config.Script)) + throw new ApplicationException("脚本为空"); var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this); - var inv = SaleInvoices.CreateSaleInvoice(); - + var inv = StatPayU8s.CreateStoreIn(); + new StoreInBodyEntry(); scriptHelper.AddLocalVar("dmos", dmos); - scriptHelper.AddLocalVar("invoices", inv); + scriptHelper.AddLocalVar("vouchers", inv); scriptHelper.Execute(); var i = 0; - foreach (var invoice in inv.Bills) + foreach (var voucher in inv.Bills) { - BillIDs.Add(i, invoice.B2BillIDs); + //回执文件里 会有这个信息,通过这个voucherid来判断单据是否导出成功 + voucher.Head.Id = i.ToString(); + BillIDs.Add(i, voucher.B2BillIDs); i++; } return inv; @@ -54,5 +60,55 @@ namespace BWP.B3ButcherManageExport.BL _date = date ?? BLContext.Today; Export(dmoIDs, extSystemID); } + + protected override Action> FillDetail + { + get + { + return dmos => + { + var dmoType = typeof(StatPay_Butcher); + var dom = new DQueryDom(new JoinAlias(dmoType)); + dom.Columns.Add(DQSelectColumn.Field("ID")); + foreach (string property in MinDetailProperties) + { + dom.Columns.Add(DQSelectColumn.Field(property)); + } + var expressionList = new List(); + foreach (var dmo in dmos) + expressionList.Add(DQExpression.Value(dmo.ID)); + dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("StatPay_ID"), expressionList.ToArray())); + var details = new List(); + details.Clear(); + using (IDQDataReader reader = Session.ExecuteReader(dom)) + { + while (reader.Read()) + { + var detail = new StatPay_Butcher + { + ID = (long)reader[0] + }; + int i = 1; + foreach (var property in MinDetailProperties) + { + dmoType.GetProperty(property).SetValue(detail, reader[i++], null); + } + details.Add(detail); + } + } + var groups = details.GroupBy(x => x.StatPay_ID); + foreach (var gDetail in groups) + { + var firstDmo = dmos.FirstOrDefault(x => x.ID == gDetail.Key); + if (firstDmo == null) + continue; + foreach (var billDetail in gDetail) + { + firstDmo.Details.Add(billDetail); + } + } + }; + } + } } }