| @ -0,0 +1,108 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using B3_QiLianMuGe.BL; | |||||
| using BWP.B3ExportBase; | |||||
| using BWP.B3ExportBase.Utils; | |||||
| using BWP.B3Frameworks; | |||||
| using BWP.B3Frameworks.BO.NamedValueTemplate; | |||||
| using BWP.B3Sale.BO; | |||||
| using BWP.B3Sale.Utils; | |||||
| using BWP.Web.Pages.B3ExportBase; | |||||
| using BWP.Web.Utils; | |||||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||||
| using Forks.EnterpriseServices.DomainObjects2; | |||||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||||
| using Forks.EnterpriseServices.SqlDoms; | |||||
| using Forks.Utils.Collections; | |||||
| using TSingSoft.WebControls2; | |||||
| using BWP.B3CowButcherManage.BO; | |||||
| namespace BWP.Web.Pages.B3_QiLianMuGe.ToK3Cloud | |||||
| { | |||||
| public class PayToK3CloudList : ExportBaseList<Pay, IPayToToK3CloudBL> { | |||||
| protected override string Caption { | |||||
| get { return "付款单导金蝶云凭证"; } | |||||
| } | |||||
| public override string Url { | |||||
| get { return "~/B3_QiLianMuGe/ToK3Cloud/PayToK3CloudList.aspx"; } | |||||
| } | |||||
| protected override string EditUrl { | |||||
| get { | |||||
| return "B3CowButcherManage/Bills/Pay_/PayEdit.aspx"; | |||||
| } | |||||
| } | |||||
| protected override string DoExport(List<long> idList) { | |||||
| if (idList.Count == 0) { | |||||
| throw new ApplicationException("请选择单据!"); | |||||
| } | |||||
| if (_dfcUrl.IsEmpty) { | |||||
| throw new ApplicationException("请选择外部系统!"); | |||||
| } | |||||
| BL.Export(idList, long.Parse(_dfcUrl.Value)); | |||||
| return BIFactory.GetLastMessage(); | |||||
| } | |||||
| private ChoiceBox _dfcUrl; | |||||
| // private DFDateInput _billDate; | |||||
| protected override void AddExportControl(HLayoutPanel hbox) { | |||||
| hbox.Add(new SimpleLabel("外部系统")); | |||||
| _dfcUrl = hbox.Add(new ChoiceBox()); | |||||
| _dfcUrl.DataKind = B3ExportBaseConsts.DataSources.外部系统; | |||||
| _dfcUrl.EnableInputArgument = true; | |||||
| _dfcUrl.SmartOrderEnabled = false; | |||||
| _dfcUrl.EnableTopItem = true; | |||||
| _dfcUrl.Width = 130; | |||||
| //hbox.Add(new SimpleLabel("日期")); | |||||
| //_billDate = hbox.Add(new DFDateInput()); | |||||
| //_billDate.Value = DateTime.Today; | |||||
| base.AddExportControl(hbox); | |||||
| } | |||||
| protected override void AddQueryControls(VLayoutPanel vPanel) { | |||||
| vPanel.Add(CreateDefaultBillQueryControls((panel, config) => { | |||||
| config.AddAfter("Account_ID", "ID"); | |||||
| config.AddAfter("Supplier_ID", "ID"); | |||||
| config.AddAfter("Employee_ID", "ID"); | |||||
| config.AddAfter("Department_ID", "ID"); | |||||
| config.AddAfter("AccountingUnit_ID", "ID"); | |||||
| config.AddAfter("Date", "ID"); | |||||
| config.AddAfter("PaySupplier_ID", "ID"); | |||||
| })); | |||||
| } | |||||
| protected override void AddDFBrowseGridColumn(DFBrowseGrid grid, string field) { | |||||
| base.AddDFBrowseGridColumn(grid, field); | |||||
| if (field == "BillState") { | |||||
| AddDFBrowseGridColumn(grid, "Date"); | |||||
| AddDFBrowseGridColumn(grid, "Supplier_Name"); | |||||
| AddDFBrowseGridColumn(grid, "Account_Name"); | |||||
| AddDFBrowseGridColumn(grid, "PaySupplier_Name"); | |||||
| AddDFBrowseGridColumn(grid, "PaySupplier_AccountNo"); | |||||
| } | |||||
| } | |||||
| protected override DQueryDom GetQueryDom() { | |||||
| var dom = base.GetQueryDom(); | |||||
| dom.EAddCheckedCondition(dom.From.RootSource.Alias); | |||||
| return dom; | |||||
| } | |||||
| protected override void OnLoad(EventArgs e) { | |||||
| base.OnLoad(e); | |||||
| if (!IsPostBack) { | |||||
| var tuple = ExportConfigUtil.LoadDefaultExtSystems(MethodID); | |||||
| if (tuple != null) { | |||||
| _dfcUrl.Value = tuple.Item1.ToString(); | |||||
| _dfcUrl.DisplayValue = tuple.Item2; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,80 @@ | |||||
| <?xml version="1.0" encoding="utf-8" ?> | |||||
| <Select xmlns="urn:XDQuery"> | |||||
| <Columns> | |||||
| <Field name="ID"/> | |||||
| </Columns> | |||||
| <From> | |||||
| <DmoClass class="BWP.B3CowButcherManage.BO.Pay, B3CowButcherManage"/> | |||||
| </From> | |||||
| <Where> | |||||
| <And> | |||||
| <EQ> | |||||
| <Field name="ID"/> | |||||
| <QBE paramName="ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="Supplier_ID"/> | |||||
| <QBE paramName="Supplier_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="Account_ID"/> | |||||
| <QBE paramName="Account_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="AccountingUnit_ID"/> | |||||
| <QBE paramName="AccountingUnit_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="Department_ID"/> | |||||
| <QBE paramName="Department_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="PaySupplier_ID"/> | |||||
| <QBE paramName="PaySupplier_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="Employee_ID"/> | |||||
| <QBE paramName="Employee_ID"/> | |||||
| </EQ> | |||||
| <EQ> | |||||
| <Field name="IsLocked"/> | |||||
| <QBE paramName="IsLocked"/> | |||||
| </EQ> | |||||
| <Contains> | |||||
| <Field name="Remark"/> | |||||
| <QBE paramName="Remark"/> | |||||
| </Contains> | |||||
| <Contains> | |||||
| <Field name="CreateUser_Name"/> | |||||
| <QBE paramName="CreateUser_Name"/> | |||||
| </Contains> | |||||
| <Contains> | |||||
| <Field name="CheckUser_Name"/> | |||||
| <QBE paramName="CheckUser_Name"/> | |||||
| </Contains> | |||||
| <GreaterThanOrEqual> | |||||
| <Field name="CreateTime"/> | |||||
| <QBE paramName="MinCreateTime" /> | |||||
| </GreaterThanOrEqual> | |||||
| <LessThanOrEqual> | |||||
| <Field name="CreateTime"/> | |||||
| <QBE paramName="MaxCreateTime"/> | |||||
| </LessThanOrEqual> | |||||
| <GreaterThanOrEqual> | |||||
| <Field name="Date"/> | |||||
| <QBE paramName="MinDate" /> | |||||
| </GreaterThanOrEqual> | |||||
| <LessThanOrEqual> | |||||
| <Field name="Date"/> | |||||
| <QBE paramName="MaxDate"/> | |||||
| </LessThanOrEqual> | |||||
| <EQ> | |||||
| <Field name="BillState"/> | |||||
| <QBE paramName ="BillState"/> | |||||
| </EQ> | |||||
| </And> | |||||
| </Where> | |||||
| </Select> | |||||
| @ -0,0 +1,105 @@ | |||||
| using System; | |||||
| using System.Collections; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using BWP.B3CowButcherManage.BO; | |||||
| using BWP.B3ExportBase; | |||||
| using BWP.B3ExportBase.BL.K3Cloud; | |||||
| using BWP.B3Frameworks; | |||||
| using BWP.B3Sale.BO; | |||||
| using Forks.EnterpriseServices; | |||||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||||
| using Forks.EnterpriseServices.DomainObjects2; | |||||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||||
| using TSingSoft.WebPluginFramework; | |||||
| namespace B3_QiLianMuGe.BL { | |||||
| [BusinessInterface(typeof(PayToToK3CloudBL))] | |||||
| public interface IPayToToK3CloudBL : IK3CloudVoucherBL<Pay> { | |||||
| } | |||||
| [LogicName("付款单导金蝶云凭证")] | |||||
| [ExportID(B3FrameworksConsts.DmoTypeIDBases.B3_QiLianMuGe, B3QiLianMuGeConsts.ExportIDOffsets.PayToToK3Cloud)] | |||||
| public class PayToToK3CloudBL : K3CloudVoucherBL<Pay>, IPayToToK3CloudBL { | |||||
| public override short GetMethodID() { | |||||
| return B3FrameworksConsts.DmoTypeIDBases.B3_QiLianMuGe + B3QiLianMuGeConsts.ExportIDOffsets.PayToToK3Cloud; | |||||
| } | |||||
| public IEnumerable<StatPay_MaoDetail> GetStatPayMaoDetail(IEnumerable<long> ids) { | |||||
| var query = new DQueryDom(new JoinAlias(typeof(StatPay_MaoDetail))); | |||||
| query.Columns.Add(DQSelectColumn.Field("StatPay_ID")); | |||||
| query.Columns.Add(DQSelectColumn.Field("LiveVarieties_ID")); | |||||
| query.Columns.Add(DQSelectColumn.Field("GrossWeight")); | |||||
| query.Columns.Add(DQSelectColumn.Field("Price")); | |||||
| query.Columns.Add(DQSelectColumn.Field("Money")); | |||||
| query.Where.Conditions.EFieldInList(DQExpression.Field("StatPay_ID"), ids.ToList()); | |||||
| var list = new List<StatPay_MaoDetail>(); | |||||
| using (var session = Dmo.NewSession()) { | |||||
| using (var reader = session.ExecuteReader(query)) { | |||||
| while (reader.Read()) { | |||||
| list.Add(new StatPay_MaoDetail() { | |||||
| StatPay_ID = (long)reader[0], | |||||
| LiveVarieties_ID = (long?)reader[1], | |||||
| GrossWeight = Convert.ToDecimal(reader[2] ?? 0), | |||||
| Price = Convert.ToDecimal(reader[3] ?? 0), | |||||
| Money = Convert.ToDecimal(reader[4] ?? 0), | |||||
| }); | |||||
| } | |||||
| } | |||||
| } | |||||
| return list; | |||||
| } | |||||
| public IEnumerable GetStatPayMaoDetailByIds(IEnumerable<long> ids, IEnumerable<StatPay_MaoDetail> details) { | |||||
| var list= details.Where(detail => ids.Contains(detail.StatPay_ID)).ToList(); | |||||
| return list.GroupBy(x => x.LiveVarieties_ID); | |||||
| } | |||||
| 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.OrderBy(x => x.ID)) { | |||||
| firstDmo.Details.Add(billDetail); | |||||
| } | |||||
| } | |||||
| }; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using BWP.B3CowButcherManage.BO; | |||||
| using BWP.B3CowButcherManage.NamedValueTemplate; | |||||
| using BWP.B3ExportBase; | |||||
| using BWP.B3ExportBase.BL.K3Cloud; | |||||
| using BWP.B3Frameworks; | |||||
| using Forks.EnterpriseServices; | |||||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||||
| using Forks.EnterpriseServices.DomainObjects2; | |||||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||||
| using Forks.Utils; | |||||
| using TSingSoft.WebPluginFramework; | |||||
| namespace B3_QiLianMuGe.BL { | |||||
| //[BusinessInterface(typeof(StatPayToToK3CloudBL))] | |||||
| //public interface IStatPayToToK3CloudBL : IK3CloudVoucherBL<StatPay> { | |||||
| //} | |||||
| //[LogicName("结算单导金蝶云凭证")] | |||||
| ////[ExportID(B3FrameworksConsts.DmoTypeIDBases.B3_QiLianMuGe, B3QiLianMuGeConsts.ExportIDOffsets.StatPayToToK3Cloud)] | |||||
| //public class StatPayToToK3CloudBL : K3CloudVoucherBL<StatPay>, IStatPayToToK3CloudBL { | |||||
| // public override short GetMethodID() { | |||||
| // return B3FrameworksConsts.DmoTypeIDBases.B3_QiLianMuGe + B3QiLianMuGeConsts.ExportIDOffsets.StatPayToToK3Cloud; | |||||
| // } | |||||
| //} | |||||
| } | |||||
| @ -0,0 +1,100 @@ | |||||
| from BWP.B3ExportBase.BL.K3Cloud import Voucher ,VoucherEntity,FDetailid | |||||
| from System.Collections.Generic import List ,Dictionary | |||||
| from System import Int64 ,Object ,Convert | |||||
| from BWP.B3ExportBase import B3ExportBaseConsts; | |||||
| class BLMethodEvents(BLMethodEventsBase): | |||||
| def before(self): | |||||
| self.proxy.LoadFullDom = 0 | |||||
| self.proxy.MinDmoProperties.Add("ID"); | |||||
| self.proxy.MinDmoProperties.Add("Supplier_ID"); | |||||
| self.proxy.MinDmoProperties.Add("Supplier_Name"); | |||||
| self.proxy.MinDmoProperties.Add("Money"); | |||||
| self.proxy.MinDmoProperties.Add("Date"); | |||||
| self.proxy.MinDmoProperties.Add("Account_ID"); | |||||
| self.proxy.MinDetailProperties.Add("Pay_ID"); | |||||
| self.proxy.MinDetailProperties.Add("StatPay_ID"); | |||||
| def execute(self): | |||||
| def sum_money(items): | |||||
| result = 0.0 | |||||
| for item in items: | |||||
| if not item.Money: | |||||
| continue | |||||
| result = result + Convert.ToDecimal(item.Money) | |||||
| return result | |||||
| def sum_gross_weight(items): | |||||
| result = 0.0 | |||||
| for item in items: | |||||
| if not item.GrossWeight: | |||||
| continue | |||||
| result = result + Convert.ToDecimal(item.GrossWeight) | |||||
| return result | |||||
| accDmoType = B3ExportBaseConsts.DmoTypeID.账户; | |||||
| liveVarDmoType = B3ExportBaseConsts.DmoTypeID.活体品种 | |||||
| statIds = [] | |||||
| for dmo in dmos: | |||||
| for d in dmo.Details: | |||||
| statIds.append(d.StatPay_ID) | |||||
| statPayDetails = self.proxy.GetStatPayMaoDetail(statIds) | |||||
| i = 0 | |||||
| for dmo in dmos: | |||||
| ids = List[Int64](); | |||||
| ids.Add(dmo.ID) | |||||
| idsDic.Add(i,ids) | |||||
| i = i + 1 | |||||
| voucher = Voucher() | |||||
| voucherContainer.Model.Add(voucher); | |||||
| voucher.FAccountBookID.Add("FNumber", "001"); #账簿 | |||||
| voucher.FVOUCHERGROUPID.Add("FNumber", "PRE001"); #凭证字 | |||||
| voucher.FVOUCHERGROUPNO = "1"; #凭证号 默认 | |||||
| voucher.FDocumentStatus = "Z"; | |||||
| voucher.FYEAR = gToday.Year; #会计年度 | |||||
| voucher.FPERIOD = gToday.Month; #期间 | |||||
| #借方-------------------------------------------------------- | |||||
| statIds = [] | |||||
| for detail in dmo.Details: | |||||
| statIds.append(d.StatPay_ID) | |||||
| details_stat = self.proxy.GetStatPayMaoDetailByIds(statIds,statPayDetails) | |||||
| for details in details_stat: | |||||
| detail = details[0] | |||||
| money = sum_money(details) | |||||
| weight = sum_gross_weight(details) | |||||
| entry = VoucherEntity(); | |||||
| entry.FEXPLANATION = "银付" + dmo.Supplier_Name + " 牛款 " + self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd"); | |||||
| entry.FACCOUNTID.Add("FNumber", "1412.01"); #会计科目 | |||||
| entry.FCURRENCYID.Add("FNumber", "PRE001"); #币别 | |||||
| entry.FEXCHANGERATETYPE.Add("FNumber", "HLTX01_SYS");#汇率类型 | |||||
| entry.FEXCHANGERATE = 1.0; #汇率 | |||||
| entry.FAMOUNTFOR = money #原币金额 | |||||
| entry.FDEBIT = money #借方金额 | |||||
| entry.FUnitId.Add("FNUMBER", "kg"); | |||||
| entry.FQty = weight | |||||
| if not weight: | |||||
| entry.FPrice = money/weight | |||||
| entry.FDetailID = FDetailid(); #核算维度 | |||||
| no = self.proxy.GetExtFieldByName(detail.LiveVarieties_ID,liveVarDmoType ,"ExternalField1"); | |||||
| entry.FDetailID.FDETAILID__FFLEX8 = Dictionary[str,Object](); | |||||
| entry.FDetailID.FDETAILID__FFLEX8.Add("FNumber", no); | |||||
| voucher.FEntity.Add(entry); | |||||
| #贷方------------------------------------------------------------ | |||||
| entry2 = VoucherEntity(); | |||||
| entry2.FEXPLANATION = "银付" + dmo.Supplier_Name + " 牛款 " + self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd"); | |||||
| entry2.FACCOUNTID.Add("FNumber", "1002"); | |||||
| entry2.FCURRENCYID.Add("FNumber", "PRE001"); | |||||
| entry2.FEXCHANGERATETYPE.Add("FNumber", "HLTX01_SYS"); | |||||
| entry2.FEXCHANGERATE = 1.0; | |||||
| entry2.FAMOUNTFOR = Convert.ToDecimal(dmo.Money) | |||||
| entry2.FCREDIT = Convert.ToDecimal(dmo.Money) | |||||
| entry2.FDetailID = FDetailid(); #核算维度 | |||||
| no = self.proxy.GetExtFieldByName(dmo.Account_ID,accDmoType ,"ExternalField1"); | |||||
| entry2.FDetailID.FDETAILID__FF100002 = Dictionary[str,Object](); | |||||
| entry2.FDetailID.FDETAILID__FF100002.Add("FNumber", no); | |||||
| voucher.FEntity.Add(entry2); | |||||