using BWP.B3ButcherManage.BO;
|
|
using BWP.B3ExportBase;
|
|
using BWP.B3ExportBase.BL;
|
|
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;
|
|
using System.Text;
|
|
using TSingSoft.WebPluginFramework;
|
|
using TSingSoft.WebPluginFramework.BIPlugins.BLEvents;
|
|
|
|
namespace BWP.B3ButcherManageExport.BL
|
|
{
|
|
[BusinessInterface(typeof(PayToU8BL))]
|
|
public interface IPayToU8BL : IExportU8BL
|
|
{
|
|
void Export(List<long> dmoIDs, long extSystemID, DateTime? date);
|
|
}
|
|
|
|
[LogicName("屠宰场付款单导U8付款单")]
|
|
//[BindToFeature("B3ButcherManageExport.0006")]
|
|
[ExportID(B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport, B3ButcherManageExportConsts.ExportIDOffsets.PayToU8)]
|
|
public class PayToU8BL : ExportU8BL<Pay>, IPayToU8BL
|
|
{
|
|
protected override Ufinterface CreateUfinterface(IList<Pay> dmos)
|
|
{
|
|
var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this);
|
|
var inv = PayU8s.CreateStoreIn();
|
|
|
|
scriptHelper.AddLocalVar("dmos", dmos);
|
|
scriptHelper.AddLocalVar("invoices", inv);
|
|
scriptHelper.Execute();
|
|
var i = 0;
|
|
foreach (var invoice in inv.Bills)
|
|
{
|
|
BillIDs.Add(i, invoice.B2BillIDs);
|
|
i++;
|
|
}
|
|
return inv;
|
|
}
|
|
|
|
private DateTime _date;
|
|
public DateTime Date
|
|
{
|
|
get { return _date; }
|
|
set { _date = value; }
|
|
}
|
|
|
|
public void Export(List<long> dmoIDs, long extSystemID, DateTime? date)
|
|
{
|
|
_date = date ?? BLContext.Today;
|
|
Export(dmoIDs, extSystemID);
|
|
}
|
|
|
|
protected override Action<List<Pay>> FillDetail
|
|
{
|
|
get
|
|
{
|
|
return dmos =>
|
|
{
|
|
var dmoType = typeof(Pay_Detail);
|
|
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<IDQExpression>();
|
|
foreach (var dmo in dmos)
|
|
expressionList.Add(DQExpression.Value(dmo.ID));
|
|
dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("Pay_ID"), expressionList.ToArray()));
|
|
var details = new List<Pay_Detail>();
|
|
details.Clear();
|
|
using (IDQDataReader reader = Session.ExecuteReader(dom))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var detail = new Pay_Detail
|
|
{
|
|
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.Pay_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);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|