using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
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 TSingSoft.WebPluginFramework;
|
|
using TSingSoft.WebPluginFramework.BIPlugins.BLEvents;
|
|
|
|
namespace BWP.B3ButcherManageExport.BL
|
|
{
|
|
[BusinessInterface(typeof(PayToNcBL))]
|
|
public interface IPayToNcBL : INcBL<Pay>
|
|
{
|
|
void Export(List<long> idList, long p, DateTime? nullable);
|
|
}
|
|
|
|
[LogicName("付款单导NC凭证")]
|
|
[BindToFeature("B3ButcherManageExport.0001")]
|
|
[ExportID(B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport, B3ButcherManageExportConsts.ExportIDOffsets.PayToNc)]
|
|
public class PayToNcBL : NcBL<Pay>, IPayToNcBL
|
|
{
|
|
protected override NcUfinterface CreateUfinterface(IList<Pay> dmos)
|
|
{
|
|
var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this);
|
|
scriptHelper.AddLocalVar("dmos", dmos);
|
|
if (Version == "6.3")
|
|
{
|
|
{
|
|
var bills = BO.NcVouchers.New();
|
|
scriptHelper.AddLocalVar("vouchers", bills);
|
|
scriptHelper.Execute();
|
|
var i = 0;
|
|
foreach (var bill in bills.Bills)
|
|
{
|
|
BillIDs.Add(i, bill.B2BillIDs);
|
|
i++;
|
|
}
|
|
return bills;
|
|
}
|
|
}
|
|
throw new Exception("未实现导出方法");
|
|
}
|
|
|
|
public override short GetMethodID()
|
|
{
|
|
return B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport + B3ButcherManageExportConsts.ExportIDOffsets.PayToNc;
|
|
}
|
|
|
|
public DateTime Date { get; set; }
|
|
public void Export(List<long> dmoIDs, long extSystemID, DateTime? date)
|
|
{
|
|
Date = date ?? BLContext.Today;
|
|
Export(dmoIDs, extSystemID);
|
|
}
|
|
|
|
public void CheckAccountingUnit(IEnumerable<AdvancePay> dmos)
|
|
{
|
|
var groups = dmos.GroupBy(x => x.AccountingUnit_Name);
|
|
var count = groups.Count();
|
|
if (count > 1)
|
|
{
|
|
throw new ApplicationException("一次导出只能选择同一个会计单位下的单据");
|
|
}
|
|
}
|
|
|
|
public string GetSumNumber(IEnumerable<Pay_Detail> details)
|
|
{
|
|
return details.Sum(x => (x.WeighBill_BuyNum ?? 0)).ToString();
|
|
}
|
|
|
|
public string GetSumWeight(IEnumerable<Pay_Detail> details)
|
|
{
|
|
return details.Sum(x => (x.WeighBill_BuyWeigh1 ?? 0).Value).ToString("0.00");
|
|
}
|
|
|
|
public string GetStatPayDate(Pay dmo, string format)
|
|
{
|
|
if (dmo.Details.Count == 0)
|
|
return string.Empty;
|
|
return GetDateTime(dmo.Details[0].StatPay_Date, format);
|
|
}
|
|
}
|
|
}
|