标准成本调整回传反写调整后金额

This commit is contained in:
ggxl 2024-11-22 11:08:28 +08:00
parent 2b9d90fef7
commit f6b3c01b15
3 changed files with 122 additions and 20 deletions

View File

@ -25,6 +25,7 @@ import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.field.AmountEdit;
import kd.bos.form.field.DecimalEdit;
import kd.bos.portal.util.OpenPageUtils;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.svc.control.events.AppNavigationMenuEvent;
@ -37,10 +38,10 @@ import java.util.*;
public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements Plugin {
/*
* 定标
* 1.点击变更合约规划按钮跳转到成本管理的 目标成本调整
* 2.将采购明细中的规划金额 < 供应商信息的最终价 所对应的采购项目带到目标成本调整中
* */
* 定标
* 1.点击变更合约规划按钮跳转到成本管理的 目标成本调整
* 2.将采购明细中的规划金额 < 供应商信息的最终价 所对应的采购项目带到目标成本调整中
* */
@Override
public void afterBindData(EventObject e) {
@ -108,34 +109,34 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P
String purProjectNum = "";
DynamicObjectCollection bidSections = model.getEntryEntity("bidsection");// 标段
DynamicObjectCollection bottomSections = model.getEntryEntity("bottomsection");// 标底标段
DynamicObjectCollection supplierEntries = model.getEntryEntity("supplierentry");// 定标供应商
DynamicObjectCollection bottomEntries = model.getEntryEntity("bottomentry");// 采购明细
if (bidSections != null && supplierEntries != null && bottomSections != null && bottomEntries != null) {
int seqNum = 0;
if (bidSections != null && bottomSections != null) {
for (DynamicObject bidSection : bidSections) {
BigDecimal finalPriceSum = new BigDecimal(0);
int seq = bidSection.getInt("seq");
long entryId = bidSection.getLong("id");
DynamicObjectCollection supplierEntries = bidSection.getDynamicObjectCollection("supplierentry");// 定标供应商
if (supplierEntries == null) continue;
for (DynamicObject supplierEntry : supplierEntries) {
DynamicObject parent = (DynamicObject) supplierEntry.getParent();
if (entryId == parent.getLong("id")) {// 判断是否该标段对应的供应商
if (supplierEntry.getBoolean("isrecommended")) {// 是否中标单位
BigDecimal finalPrice = supplierEntry.getBigDecimal("finalprice");
finalPriceSum = finalPriceSum.add(finalPrice);
}
if (supplierEntry.getBoolean("isrecommended")) {// 是否中标单位
BigDecimal finalPrice = supplierEntry.getBigDecimal("finalprice");
finalPriceSum = finalPriceSum.add(finalPrice);
}
}
if (finalPriceSum.equals(new BigDecimal(0))) continue;
DynamicObject project = null;
BigDecimal controlAmountSum = new BigDecimal(0);
for (DynamicObject bottomSection : bottomSections) {
int bottomSeq = bottomSection.getInt("seq");
if (seq == bottomSeq) {
long bottomEntryId = bottomSection.getLong("id");
if (!bottomEntries.isEmpty()) project = bottomEntries.get(0).getDynamicObject("botpurentryproject");
DynamicObjectCollection bottomEntries = bottomSection.getDynamicObjectCollection("bottomentry");// 采购明细
if (bottomEntries != null) {
if (!bottomEntries.isEmpty())
project = bottomEntries.get(0).getDynamicObject("botpurentryproject");
for (DynamicObject bottomEntry : bottomEntries) {
DynamicObject parent = (DynamicObject) bottomEntry.getParent();
if (bottomEntryId == parent.getLong("id")) {
for (DynamicObject bottomEntry : bottomEntries) {
BigDecimal controlAmount = bottomEntry.getBigDecimal("botcontrolamount");// 采购控制金额含税
controlAmountSum = controlAmountSum.add(controlAmount);
}
@ -144,8 +145,9 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P
}
if (finalPriceSum.compareTo(controlAmountSum) >= 1) {
if (!bottomEntries.isEmpty() && project != null) {
if (project != null) {
purProjectNum = project.getString("number");
seqNum = seq;
break;
}
}
@ -163,6 +165,7 @@ public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements P
billShowParameter.setCustomParam("decision_id", model.getDataEntity().getLong("id"));
billShowParameter.setCustomParam("purproject_number", purProjectNum);
billShowParameter.setCustomParam("seqNum", seqNum);
appPageView.showForm(billShowParameter);
getView().sendFormAction(appPageView);

View File

@ -0,0 +1,94 @@
package shkd.repc.rebm.opplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
/**
* 单据操作插件
*/
public class WriteBackAdjustAmountOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
/*
* 目标成本调整-审核/反审核时触发根据合约规划回传调整后金额
* */
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
String operationKey = e.getOperationKey();
if ("audit".equals(operationKey) || "test".equals(operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
for (DynamicObject dataEntity : dataEntities) {
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "recos_aimadjust");
DynamicObject decision = dataEntity.getDynamicObject("qeug_decision");//定标
DynamicObjectCollection conPlanAdjustEntries = dataEntity.getDynamicObjectCollection("conplanadjustentry");// 未签约调整分录
if (decision != null) {
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(decision.getPkValue(), "rebm_decision");
int sectionSeq = dataEntity.getInt("qeug_section_seq");
DynamicObjectCollection bottomSections = dynamicObject.getDynamicObjectCollection("bottomsection");
if (bottomSections != null) {
for (DynamicObject bottomSection : bottomSections) {
int bottomSeq = bottomSection.getInt("seq");
if (sectionSeq == bottomSeq) {
DynamicObjectCollection bottomEntries = bottomSection.getDynamicObjectCollection("bottomentry");// 采购明细
if (bottomEntries != null) {
String billNo = dynamicObject.getString("billno");
QFilter billNoQF = new QFilter("billno", QCP.equals, billNo);
DynamicObject project = BusinessDataServiceHelper.loadSingle("rebm_project", billNoQF.toArray());// 标前预备会
if (project != null) {
DynamicObjectCollection bidSections = project.getDynamicObjectCollection("bidsection");// 标段
DynamicObject bidSection = bidSections.get(sectionSeq - 1);
DynamicObjectCollection projectEntries = bidSection.getDynamicObjectCollection("projectentry");// 采购明细
for (int i = 0; i < bottomEntries.size(); i++) {
DynamicObject bottomEntry = bottomEntries.get(i);
BigDecimal planAmount = bottomEntry.getBigDecimal("planamount");
if (planAmount.intValue() == 0) continue;
DynamicObject projectEntry = projectEntries.get(i);
DynamicObject cqprogcon = projectEntry.getDynamicObject("cqprogcon");// 合约规划
if (conPlanAdjustEntries != null) {
for (DynamicObject conPlanAdjustEntry : conPlanAdjustEntries) {
DynamicObject conplan = conPlanAdjustEntry.getDynamicObject("cpentry_conplan");
if (conplan.getLong("id") == cqprogcon.getLong("id")) {
BigDecimal adjustSumAmt = conPlanAdjustEntry.getBigDecimal("cpentry_adjustsumamt");// 调整后金额
bottomEntry.set("qeug_planamount", bottomEntry.getBigDecimal("planamount"));
bottomEntry.set("qeug_botcontrolamount", bottomEntry.getBigDecimal("botcontrolamount"));
bottomEntry.set("planamount", adjustSumAmt);
bottomEntry.set("botcontrolamount", adjustSumAmt);
bottomEntry.set("botctrlamtexceptvat", adjustSumAmt);
bottomEntry.set("nottaxplanamount", adjustSumAmt);
BigDecimal controlamount = dynamicObject.getBigDecimal("controlamount").add(adjustSumAmt.subtract(bottomEntry.getBigDecimal("botcontrolamount")));
dynamicObject.set("controlamount", controlamount);
dynamicObject.set("exctaxcontrolamount", controlamount);
}
}
}
}
bottomSection.set("bottomentry", bottomEntries);
dynamicObject.set("bottomsection", bottomSections);
dynamicObject.set("qeug_conplan_adjust", String.valueOf(dataEntity.getPkValue()));
SaveServiceHelper.update(dynamicObject);
}
}
}
}
}
}
}
}
}
}

View File

@ -26,12 +26,17 @@ public class GetDecisionAndPurProjectPlugin extends AbstractBillPlugIn implement
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
Object decisionId = formShowParameter.getCustomParam("decision_id");
Object purProjectNumber = formShowParameter.getCustomParam("purproject_number");
Object seqNum = formShowParameter.getCustomParam("seqNum");
IDataModel model = this.getModel();
if (decisionId != null && 0 != (Long) decisionId) {
model.setValue("qeug_decision", decisionId);
}
if (seqNum != null) {
model.setValue("qeug_section_seq", seqNum);
}
if (purProjectNumber != null && !((String) purProjectNumber).isEmpty()) {
DynamicObject project = (DynamicObject) this.getModel().getValue("project");
if (project == null) {