public void Push() { var cbsDic = this.GetDataDicByID("S_EP_CBSNode", this.ModelDic.GetValue("CBSNode")); if (cbsDic == null) { throw new Formula.Exceptions.BusinessValidationException("没有找到对应的产值节点,无法补贴产值"); } cbsDic.SetValue("ProductionValue", this.ModelDic.GetValue("ProductionValue")); var cbsNode = new S_EP_CBSNode(cbsDic); var defineChildren = cbsNode.DefineNode.ChildrenNode.Where(c => c.ModelDic.GetValue("NodeType") != CBSNodeType.Communal.ToString() && c.ModelDic.GetValue("NodeType") != CBSNodeType.Reserved.ToString()).ToList(); if (defineChildren.Count > 0) { //判定结构定义中是否有子节点,如果有才能够对子节点进行操作 var detailRows = this.DB.ExecuteDataTable(String.Format("select * from S_EP_ProductionSubsidyApply_Detail where S_EP_ProductionSubsidyApplyID='{0}'" , this.ModelDic.GetValue("ID"))); foreach (DataRow detailRow in detailRows.Rows) { var detail = FormulaHelper.DataRowToDic(detailRow); #region 步更新产值CBS节点明细 var child = this.GetDataDicByID("S_EP_CBSNode", detail.GetValue("CBSID")); if (child == null) { continue; } else { child.SetValue("Name", detail.GetValue("Name")); if (!String.IsNullOrEmpty(detail.GetValue("Code"))) { child.SetValue("Code", detail.GetValue("Code")); } child.SetValue("RelateID", detail.GetValue("RelateID")); child.SetValue("ChargerDept", detail.GetValue("ChargerDept")); child.SetValue("ChargerDeptName", detail.GetValue("ChargerDeptName")); child.SetValue("ChargerUser", detail.GetValue("ChargerUser")); child.SetValue("ChargerUserName", detail.GetValue("ChargerUserName")); child.SetValue("ProductionValue", detail.GetValue("ProductionValueNew")); child.UpdateDB(this.DB, "S_EP_CBSNode", child.GetValue("ID")); this.DB.ExecuteNonQuery(String.Format("update S_EP_ProductionUnit set ProductionValue={0} where CBSNodeID='{1}'", String.IsNullOrEmpty(detail.GetValue("ProductionValueNew")) ? "0" : detail.GetValue("ProductionValueNew"), child.GetValue("ID"))); var childNode = new S_EP_CBSNode(child); childNode.SetUnit(); var changeValue = String.IsNullOrEmpty(detail.GetValue("AdjustValue")) ? 0m : Convert.ToDecimal(detail.GetValue("AdjustValue")); childNode.AutoSplitProductionValueToReversed(changeValue); } #endregion setChangeLoad(detail); } } if (cbsNode.DefineNode.ChildrenNode.Count(c => c.ModelDic.GetValue("NodeType") == CBSNodeType.Reserved.ToString()) > 0) { //当节点定义中有预留节点时,才能进行预留 #region 更新预留产值节点 var reserverNode = cbsNode.Children.FirstOrDefault(c => c.ModelDic.GetValue("NodeType") == CBSNodeType.Reserved.ToString()); if (reserverNode == null) { if (!String.IsNullOrEmpty(this.ModelDic.GetValue("ProductionReserveValue")) && Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue")) > 0) { var revDic = new Dictionary <string, object>(); revDic.SetValue("Name", "产值预留"); revDic.SetValue("Code", "Reserves"); revDic.SetValue("NodeType", CBSNodeType.Reserved.ToString()); var defineNode = cbsNode.Children.FirstOrDefault(c => c.GetValue("NodeType") == CBSNodeType.Reserved.ToString()); revDic.SetValue("DefineID", defineNode.GetValue("ID")); revDic.SetValue("ProductionValue", Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue"))); revDic.SetValue("RelateID", cbsDic.GetValue("ID") + CBSNodeType.Reserved.ToString()); reserverNode = new S_EP_CBSNode(revDic); cbsNode.AddChild(reserverNode); } } else { reserverNode.ModelDic.SetValue("ProductionValue", String.IsNullOrEmpty(this.ModelDic.GetValue("ProductionReserveValue")) ? 0m : Convert.ToDecimal(this.ModelDic.GetValue("ProductionReserveValue"))); reserverNode.ModelDic.UpdateDB(this.DB, "S_EP_CBSNode", reserverNode.ModelDic.GetValue("ID")); } #endregion //如果有预留节点,当前节点的计划产值等于所有子节点计划产值汇总 //因为所有的计划产值必须在分解的时候全部分解完毕,如果暂不分解完成的,必须存放在预留节点内 //没有预留节点说明不能预留 cbsNode.SumProductionValue(); } else { cbsDic.SetValue("ProductionValue", this.ModelDic.GetValue("ProductionValue")); cbsDic.UpdateDB(this.DB, "S_EP_CBSNode", cbsDic.GetValue("ID")); } cbsNode.SumProductionValueToTop(); setChangeLoad(cbsDic); foreach (var ancestor in cbsNode.Ancestors) { setChangeLoad(ancestor.ModelDic); } }
public void Push() { var confirmAdjustInfoDic = this.ModelDic; var productionUnit = this.GetDataDicByID("S_EP_ProductionUnit", confirmAdjustInfoDic.GetValue("ProductionUnit")); if (productionUnit == null) { throw new BusinessException("无法找到ID为【" + confirmAdjustInfoDic.GetValue("ProductionUnit") + "】的产值单元"); } var cbsNodeDic = this.GetDataDicByID("S_EP_CBSNode", productionUnit.GetValue("CBSNodeID")); if (cbsNodeDic == null) { throw new BusinessException("无法找到ID为【" + productionUnit.GetValue("CBSNodeID") + "】的CBSNode"); } string sql = ""; var productionSettleValueDt = this.DB.ExecuteDataTable( "select top 1 * from S_EP_ProductionSettleValue where ConfirmDetailID = '" + confirmAdjustInfoDic.GetValue("ConfirmDetailID") + "'"); var productionSettleValue = FormulaHelper.DataRowToDic(productionSettleValueDt.Rows[0]); productionSettleValue.SetValue("TotalScale", confirmAdjustInfoDic.GetValue("CurrentConfirmScaleTotalNew")); productionSettleValue.SetValue("TotalProductionValue", confirmAdjustInfoDic.GetValue("CurrentConfirmValueTotalNew")); productionSettleValue.SetValue("CurrentProductionValue", confirmAdjustInfoDic.GetValue("CurrentConfirmValueNew")); sql = productionSettleValue.CreateUpdateSql(this.DB, "S_EP_ProductionSettleValue", productionSettleValue.GetValue("ID")); #region 更新ProductionUnit的产值信息 更新cbsNode的产值信息 //更新ProductionUnit的产值信息 decimal tmp1 = 0; decimal.TryParse(productionUnit.GetValue("ProductionSettleValue"), out tmp1); decimal tmp2 = 0; decimal.TryParse(confirmAdjustInfoDic.GetValue("CurrentConfirmValueAdjust"), out tmp2); productionUnit.SetValue("ProductionSettleValue", tmp1 + tmp2); sql += productionUnit.CreateUpdateSql(this.DB, "S_EP_ProductionUnit", productionUnit.GetValue("ID")); //更新cbsNode的产值信息 cbsNodeDic.SetValue("ProductionSettleValue", productionUnit.GetValue("ProductionSettleValue")); sql += cbsNodeDic.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID")); this.DB.ExecuteNonQuery(sql); //更新cbsNode上级节点及cbsinfo产值信息 S_EP_CBSNode cbsNode = new S_EP_CBSNode(cbsNodeDic); cbsNode.SumProductionSettleValueToTop(); #endregion #region 产值公积,同时向上累加公积部分的金额到计划产值父节点上 if (this.ModelDic.GetValue("AdjustMethod") == "CommunalAdjust") { sql = ""; //新的计划产值 decimal oldProductionValue = 0; decimal.TryParse(confirmAdjustInfoDic.GetValue("PlanProductionValue"), out oldProductionValue); decimal currentConfirmValueAdjust = 0; decimal.TryParse(confirmAdjustInfoDic.GetValue("CurrentConfirmValueAdjust"), out currentConfirmValueAdjust); productionSettleValue.SetValue("PlanProductionValue", oldProductionValue + currentConfirmValueAdjust); sql += productionSettleValue.CreateUpdateSql(this.DB, "S_EP_ProductionSettleValue", productionSettleValue.GetValue("ID")); //更新产值单元 productionUnit = this.GetDataDicByID("S_EP_ProductionUnit", confirmAdjustInfoDic.GetValue("ProductionUnit")); productionUnit.SetValue("ProductionValue", oldProductionValue + currentConfirmValueAdjust); sql += productionUnit.CreateUpdateSql(this.DB, "S_EP_ProductionUnit", productionUnit.GetValue("ID")); //更新cbsnode计划产值 cbsNodeDic.SetValue("ProductionValue", oldProductionValue + currentConfirmValueAdjust); sql += cbsNodeDic.CreateUpdateSql(this.DB, "S_EP_CBSNode", cbsNodeDic.GetValue("ID")); this.DB.ExecuteNonQuery(sql); S_EP_CBSNode newCbsNode = new S_EP_CBSNode(cbsNodeDic); //更新父节点计划产值 newCbsNode.SumProductionValueToTop(); //产值公积信息更新 setChangeLoad(cbsNodeDic); foreach (var ancestor in cbsNode.Ancestors) { setChangeLoad(ancestor.ModelDic); } } #endregion }