From db14295dbce30fd4e59a3f353ae6fe5df47c1158 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sat, 27 Jan 2018 17:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bills/StatPay_/StatPayEdit.cs | 105 +++++++++++++++++- .../SubKillGathering_/SelectStatPayDialog.xml | 2 +- .../BL/Bills/StatPay/StatPayBL.cs | 4 + .../SubKillButcherOrderBL.cs | 87 ++++++++++++++- .../SubKillWeightBill/SubKillWeightBillBL.cs | 44 +++++++- B3SubstituteKill/BO/Bills/StatPay/StatPay.cs | 2 +- .../StatPay/StatPay_CallbackPayDetail.cs | 3 + .../Utils/B3SubstituteKillOnlineConfig.cs | 4 +- .../config/Plugins/B3SubstituteKill.plugin | 2 - 9 files changed, 240 insertions(+), 13 deletions(-) diff --git a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs index d2cfaf7..1617a44 100644 --- a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs +++ b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/StatPay_/StatPayEdit.cs @@ -10,6 +10,11 @@ using System.Text; using System.Web.UI.WebControls; using TSingSoft.WebControls2; using Forks.Utils.Collections; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.DomainObjects2; +using BWP.B3SubstituteKill.Utils; +using TSingSoft.WebPluginFramework; +using Forks.EnterpriseServices.BusinessInterfaces; namespace BWP.Web.Pages.B3SubstituteKill.Bills.StatPay_ { @@ -101,10 +106,23 @@ __DFContainer.setValue('PriceBill_ID',''); DFEditGrid _costDetail; private void AddCostDetail(TitlePanel titlePanel) { + if (CanSave) + titlePanel.EAdd(new TSButton("载入", delegate + { + GetFromUI(); + if (Dmo.PriceBill_ID == null) + throw new Exception("没有定价单号"); + Dmo.CostDetails.Clear(); + LoadCostItemDetail(); + _costDetail.DataBind(); + })); var editor = new DFCollectionEditor(() => Dmo.CostDetails); editor.AllowDeletionFunc = () => CanSave; editor.CanDeleteFunc = detail => CanSave; - editor.IsEditableFunc = (field, detail) => false; + editor.IsEditableFunc = (field, detail) => + { + return CanSave && field.Name == "Number"; + }; _costDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) }); _costDetail.Columns.Add(new DFEditGridColumn("SubKillProductLine_Name")); _costDetail.Columns.Add(new DFEditGridColumn("GenerationCostItem_Name")); @@ -120,12 +138,26 @@ __DFContainer.setValue('PriceBill_ID',''); DFEditGrid _callbackPayDetail; private void AddCallbackPayDetail(TitlePanel titlePanel) { + if (CanSave) + titlePanel.EAdd(new TSButton("载入", delegate + { + GetFromUI(); + if (Dmo.PriceBill_ID == null) + throw new Exception("没有定价单号"); + Dmo.CallbackPayDetails.Clear(); + LoadCallBackDetail(); + _callbackPayDetail.DataBind(); + })); var editor = new DFCollectionEditor(() => Dmo.CallbackPayDetails); editor.AllowDeletionFunc = () => CanSave; editor.CanDeleteFunc = detail => CanSave; - editor.IsEditableFunc = (field, detail) => false; + editor.IsEditableFunc = (field, detail) => + { + return CanSave && field.Name == "Number"; + }; _callbackPayDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) }); _callbackPayDetail.Columns.Add(new DFEditGridColumn("SubKillCallBack_Name")); + _callbackPayDetail.Columns.Add(new DFEditGridColumn("Number")); _callbackPayDetail.Columns.Add(new DFEditGridColumn("Price")); _callbackPayDetail.Columns.EAdd(new DFEditGridColumn("Money")); var section = mPageLayoutManager.AddSection("CallbackPayDetail", "回收应付"); @@ -147,5 +179,74 @@ __DFContainer.setValue('PriceBill_ID',''); _costDetail.GetFromUI(); _callbackPayDetail.GetFromUI(); } + + void LoadCallBackDetail() + { + var details = GetDetails(); + var num = details.Sum(x => x.Item2); + if (num == 0) + return; + var price = BIFactory.Create().Load(Dmo.PriceBill_ID.Value); + if (price == null) + return; + foreach (var detail in price.CallBackDetails) + { + var d = new StatPay_CallbackPayDetail(); + d.Number = num; + d.SubKillCallBack_ID = detail.SubKillCallBack_ID; + d.SubKillCallBack_Name = detail.SubKillCallBack_Name; + d.Price = detail.Price; + d.Money = d.Price * d.Number; + Dmo.CallbackPayDetails.Add(d); + } + } + + void LoadCostItemDetail() + { + var price = BIFactory.Create().Load(Dmo.PriceBill_ID.Value); + if (price == null) + return; + var details = GetDetails(); + foreach (var detail in details) + { + var tags = price.CostItemDetails.Where(x => x.SubKillProductLine_ID == detail.Item1); + foreach (var t in tags) + { + var d = new StatPay_CostDetail(); + d.GenerationCostItem_ID = t.GenerationCostItem_ID; + d.GenerationCostItem_Name = t.GenerationCostItem_Name; + d.SubKillProductLine_ID = t.SubKillProductLine_ID; + d.SubKillProductLine_Name = t.SubKillProductLine_Name; + d.Number = detail.Item2; + d.Price = t.Price; + d.Money = d.Price * d.Number; + Dmo.CostDetails.Add(d); + } + } + } + + List> GetDetails() + { + Type t = null; + string join = string.Empty; + var config = new B3SubstituteKillOnlineConfig(); + if (config.ButcherOrderCreateStatPay && Dmo.SourceBillType == DmoTypeIDAttribute.GetID(typeof(SubKillButcherOrder))) + { + t = typeof(SubKillButcherOrder_Detail); + join = "SubKillButcherOrder_ID"; + } + else if (!config.ButcherOrderCreateStatPay && Dmo.SourceBillType == DmoTypeIDAttribute.GetID(typeof(SubKillWeightBill))) + { + t = typeof(SubKillWeightBill_Detail); + join = "SubKillWeightBill_ID"; + } + else + return new List>(); + var query = new DQueryDom(new JoinAlias(t)); + query.Columns.Add(DQSelectColumn.Field("SubKillProductLine_ID")); + query.Columns.Add(DQSelectColumn.Field("Number")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("Number")), DQCondition.EQ(join, Dmo.SourceBillID))); + return query.EExecuteList(); + } } } diff --git a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/SubKillGathering_/SelectStatPayDialog.xml b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/SubKillGathering_/SelectStatPayDialog.xml index c49a303..b919156 100644 --- a/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/SubKillGathering_/SelectStatPayDialog.xml +++ b/B3SubstituteKill.Web/Pages/B3SubstituteKill/Bills/SubKillGathering_/SelectStatPayDialog.xml @@ -14,7 +14,7 @@ - + diff --git a/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs b/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs index 8b81c4f..ad8a88c 100644 --- a/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs +++ b/B3SubstituteKill/BL/Bills/StatPay/StatPayBL.cs @@ -22,6 +22,10 @@ namespace BWP.B3SubstituteKill.BL dmo.PriceBill_ID = null; if (dmo.Date.HasValue && dmo.Supplier_ID.HasValue) dmo.PriceBill_ID = SupplierRpc.GetPriceBillID(dmo.Supplier_ID.Value, dmo.Date.Value); + foreach (var d in dmo.CostDetails) + d.Money = d.Price * d.Number; + foreach (var d in dmo.CallbackPayDetails) + d.Money = d.Price * d.Number; dmo.ReceiveMoney = dmo.CostDetails.CostMoney - dmo.CallbackPayDetails.CallbackPayMoney; base.beforeSave(dmo); } diff --git a/B3SubstituteKill/BL/Bills/SubKillButcherOrder/SubKillButcherOrderBL.cs b/B3SubstituteKill/BL/Bills/SubKillButcherOrder/SubKillButcherOrderBL.cs index 4375639..93f30c4 100644 --- a/B3SubstituteKill/BL/Bills/SubKillButcherOrder/SubKillButcherOrderBL.cs +++ b/B3SubstituteKill/BL/Bills/SubKillButcherOrder/SubKillButcherOrderBL.cs @@ -8,6 +8,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using BWP.B3Frameworks; +using BWP.B3Frameworks.BO.NamedValueTemplate; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using Forks.Utils; using TSingSoft.WebPluginFramework; namespace BWP.B3SubstituteKill.BL @@ -32,16 +38,89 @@ namespace BWP.B3SubstituteKill.BL protected override void doCheck(SubKillButcherOrder dmo) { if (new B3SubstituteKillOnlineConfig().ButcherOrderCreateStatPay) - { - - } + CreateStatPay(dmo); base.doCheck(dmo); } protected override void doUnCheck(SubKillButcherOrder dmo) { - + DeleteUnCheckedStatPay(dmo); base.doUnCheck(dmo); } + + private void DeleteUnCheckedStatPay(SubKillButcherOrder dmo) + { + var query = new DQueryDom(new JoinAlias(typeof(StatPay))); + query.Columns.Add(DQSelectColumn.Field("ID")); + query.Columns.Add(DQSelectColumn.Field("BillState")); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("SourceBillID", dmo.ID), DQCondition.EQ("SourceBillType", mDmoTypeID))); + var info = query.EExecuteScalar>(Session); + if (info == null) + return; + if (info.Item2 >= 单据状态.已审核) + throw new Exception(string.Format("结算单 No.{0}{1},不能执行此操作。", info.Item1, info.Item2)); + var statPayBL = BIFactory.Create(Session); + var statPay = statPayBL.Load(info.Item1); + statPayBL.Delete(statPay); + AppendMessage("已删除结算单No." + statPay.ID); + } + + private void CreateStatPay(SubKillButcherOrder dmo) + { + var statPay = new StatPay(); + statPay.AccountingUnit_ID = dmo.AccountingUnit_ID; + statPay.Domain_ID = dmo.Domain_ID; + statPay.Department_ID = dmo.Department_ID; + statPay.Employee_ID = dmo.Employee_ID; + statPay.Date = dmo.Date; + statPay.Supplier_ID = dmo.Supplier_ID; + statPay.Number = dmo.Number; + statPay.Weight = dmo.Weight; + statPay.PriceBill_ID = dmo.PriceBill_ID; + statPay.SourceBillID = dmo.ID; + statPay.SourceBillType = mDmoTypeID; + + BuildDetail(statPay, dmo); + + BIFactory.Create(Session).Insert(statPay); + AppendMessage("生成代宰结算单:" + statPay.ID); + } + + private void BuildDetail(StatPay statPay, SubKillButcherOrder dmo) + { + if (dmo.PriceBill_ID == null) + return; + var priceBill = BIFactory.Create(Session).Load(dmo.PriceBill_ID.Value); + if (priceBill == null) + return; + foreach (var detail in dmo.Details) + { + var tags = priceBill.CostItemDetails.Where(x => x.SubKillProductLine_ID == detail.SubKillProductLine_ID); + foreach (var t in tags) + { + var d = new StatPay_CostDetail(); + d.GenerationCostItem_ID = t.GenerationCostItem_ID; + d.GenerationCostItem_Name = t.GenerationCostItem_Name; + d.SubKillProductLine_ID = t.SubKillProductLine_ID; + d.SubKillProductLine_Name = t.SubKillProductLine_Name; + d.Number = detail.Number; + d.Price = t.Price; + d.Money = d.Price * d.Number; + statPay.CostDetails.Add(d); + } + } + if (dmo.Number == 0) + return; + foreach (var t in priceBill.CallBackDetails) + { + var d = new StatPay_CallbackPayDetail(); + d.SubKillCallBack_ID = t.SubKillCallBack_ID; + d.SubKillCallBack_Name = t.SubKillCallBack_Name; + d.Number = dmo.Number; + d.Price = t.Price; + d.Money = d.Price * d.Number; + statPay.CallbackPayDetails.Add(d); + } + } } } diff --git a/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs b/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs index 6581e66..df6bc3c 100644 --- a/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs +++ b/B3SubstituteKill/BL/Bills/SubKillWeightBill/SubKillWeightBillBL.cs @@ -58,7 +58,7 @@ namespace BWP.B3SubstituteKill.BL var query = new DQueryDom(new JoinAlias(typeof(StatPay))); query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("BillState")); - query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("SourceBillID", dmo.ID), DQCondition.EQ("ShourceBillType", mDmoTypeID))); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("SourceBillID", dmo.ID), DQCondition.EQ("SourceBillType", mDmoTypeID))); var info = query.EExecuteScalar>(Session); if (info == null) return; @@ -83,9 +83,49 @@ namespace BWP.B3SubstituteKill.BL statPay.Weight = dmo.Weight; statPay.PriceBill_ID = dmo.PriceBill_ID; statPay.SourceBillID = dmo.ID; - statPay.ShourceBillType = mDmoTypeID; + statPay.SourceBillType = mDmoTypeID; + + BuildDetail(statPay, dmo); + BIFactory.Create(Session).Insert(statPay); AppendMessage("生成代宰结算单:" + statPay.ID); } + + private void BuildDetail(StatPay statPay, SubKillWeightBill dmo) + { + if (dmo.PriceBill_ID == null) + return; + var priceBill = BIFactory.Create(Session).Load(dmo.PriceBill_ID.Value); + if (priceBill == null) + return; + foreach (var detail in dmo.Details) + { + var tags = priceBill.CostItemDetails.Where(x => x.SubKillProductLine_ID == detail.SubKillProductLine_ID); + foreach (var t in tags) + { + var d = new StatPay_CostDetail(); + d.GenerationCostItem_ID = t.GenerationCostItem_ID; + d.GenerationCostItem_Name = t.GenerationCostItem_Name; + d.SubKillProductLine_ID = t.SubKillProductLine_ID; + d.SubKillProductLine_Name = t.SubKillProductLine_Name; + d.Number = detail.Number; + d.Price = t.Price; + d.Money = d.Price * d.Number; + statPay.CostDetails.Add(d); + } + } + if (dmo.Number == 0) + return; + foreach (var t in priceBill.CallBackDetails) + { + var d = new StatPay_CallbackPayDetail(); + d.SubKillCallBack_ID = t.SubKillCallBack_ID; + d.SubKillCallBack_Name = t.SubKillCallBack_Name; + d.Number = dmo.Number; + d.Price = t.Price; + d.Money = d.Price * d.Number; + statPay.CallbackPayDetails.Add(d); + } + } } } diff --git a/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs b/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs index 8fd1263..37b62dd 100644 --- a/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs +++ b/B3SubstituteKill/BO/Bills/StatPay/StatPay.cs @@ -91,7 +91,7 @@ namespace BWP.B3SubstituteKill.BO public long? SourceBillID { get; set; } - public short? ShourceBillType { get; set; } + public short? SourceBillType { get; set; } private StatPay_CostDetailCollection _mCostDetails = new StatPay_CostDetailCollection(); [OneToMany(typeof(StatPay_CostDetail), "ID")] diff --git a/B3SubstituteKill/BO/Bills/StatPay/StatPay_CallbackPayDetail.cs b/B3SubstituteKill/BO/Bills/StatPay/StatPay_CallbackPayDetail.cs index 9290da6..0e144ca 100644 --- a/B3SubstituteKill/BO/Bills/StatPay/StatPay_CallbackPayDetail.cs +++ b/B3SubstituteKill/BO/Bills/StatPay/StatPay_CallbackPayDetail.cs @@ -20,6 +20,9 @@ namespace BWP.B3SubstituteKill.BO [LogicName("回收项目")] public long SubKillCallBack_ID { get; set; } + [LogicName("头数")] + public int? Number { get; set; } + [LogicName("单价")] public Money? Price { get; set; } diff --git a/B3SubstituteKill/Utils/B3SubstituteKillOnlineConfig.cs b/B3SubstituteKill/Utils/B3SubstituteKillOnlineConfig.cs index 3417539..7685249 100644 --- a/B3SubstituteKill/Utils/B3SubstituteKillOnlineConfig.cs +++ b/B3SubstituteKill/Utils/B3SubstituteKillOnlineConfig.cs @@ -1,4 +1,5 @@ -using Forks.EnterpriseServices; +using BWP.B3Frameworks.Attributes; +using Forks.EnterpriseServices; using Forks.Utils.Configuration; using System; using System.Collections.Generic; @@ -20,6 +21,7 @@ namespace BWP.B3SubstituteKill.Utils [LogicName("代宰排宰创建代宰结算")] [ConfigurationItemGroup("B3代宰模块")] [ConfigurationItemDescription("代宰排宰创建代宰结算,默认“否”;如果选“是”,则“代宰排宰”审核创建代宰结算,否 代宰过磅审核创建代宰结算 ")] + [DomainConfigurationItem] public BoolConfigRef ButcherOrderCreateStatPay { get { return _butcherOrderCreateStatPay; } diff --git a/WebFolder/config/Plugins/B3SubstituteKill.plugin b/WebFolder/config/Plugins/B3SubstituteKill.plugin index 4a462da..557d2a1 100644 --- a/WebFolder/config/Plugins/B3SubstituteKill.plugin +++ b/WebFolder/config/Plugins/B3SubstituteKill.plugin @@ -147,9 +147,7 @@ - -