This commit is contained in:
xuhaihui 2025-09-24 10:48:39 +08:00
parent c87bbc2a35
commit 70108b2b8b
3 changed files with 221 additions and 0 deletions

View File

@ -0,0 +1,117 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package zcgj.zcdev.zcdev.pr.plugin.operate;
import java.math.BigDecimal;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.ec.basedata.common.enums.PayDirectionEnum;
import kd.ec.basedata.common.utils.CurrencyHelper;
import kd.ec.contract.common.enums.DirectionEnum;
import kd.ec.contract.opplugin.AbstractReverseWritingContractOp;
import kd.ec.contract.opplugin.validator.OutPerformRecordsValidator;
import kd.ec.contract.opplugin.validator.PerformValidator;
public abstract class AbstractContractPerformOpExt extends AbstractReverseWritingContractOp {
public AbstractContractPerformOpExt() {
}
public void onPreparePropertys(PreparePropertysEventArgs e) {
e.getFieldKeys().add("contract");
e.getFieldKeys().add("project");
e.getFieldKeys().add("org");
e.getFieldKeys().add("currency");
e.getFieldKeys().add("entryentity");
e.getFieldKeys().add("amount");
e.getFieldKeys().add("isclaim");
e.getFieldKeys().add("exratetable");
e.getFieldKeys().add("issettle");
e.getFieldKeys().add("isneedsettle");
e.getFieldKeys().add("ca");
e.getFieldKeys().add("cbs");
e.getFieldKeys().add("boq");
e.getFieldKeys().add("contpayitem");
e.getFieldKeys().add("unitproject");
e.getFieldKeys().add("notaxamount");
e.getFieldKeys().add("performamount");
}
public void reverseWritingToContract(String operationKey, DynamicObject source) {
}
public abstract String getPayDirection();
public void onAddValidators(AddValidatorsEventArgs e) {
if (this.getPayDirection().equals(PayDirectionEnum.IN.getValue())) {
e.addValidator(new PerformValidator());
} else if (this.getPayDirection().equals(PayDirectionEnum.OUT.getValue())) {
e.addValidator(new PerformValidator());
e.addValidator(new OutPerformRecordsValidator());
}
}
protected void updateContractPerformAmt(String opkey, DynamicObject performrecords, DynamicObject contract) {
BigDecimal contractPerformtaxamt = contract.getBigDecimal("performtaxamount");
BigDecimal performamount = contract.getBigDecimal("performamount");
BigDecimal totaloftaxamount = contract.getBigDecimal("totaloftaxamount");
BigDecimal totalamount = contract.getBigDecimal("totalamount");
BigDecimal amount = this.getTotalPerformTaxAmount(performrecords, "amount");
BigDecimal notaxAmount = this.getTotalPerformTaxAmount(performrecords, "notaxamount");
DynamicObject contractCurrency = contract.getDynamicObject("currency");
DynamicObject currency = performrecords.getDynamicObject("currency");
DynamicObject exratetable = performrecords.getDynamicObject("exratetable");
BigDecimal targetAmount = CurrencyHelper.getTargetCurrencyAmount((Long) contractCurrency.getPkValue(), (Long) currency.getPkValue(), exratetable, amount);
BigDecimal targetNotaxAmount = CurrencyHelper.getTargetCurrencyAmount((Long) contractCurrency.getPkValue(), (Long) currency.getPkValue(), exratetable, notaxAmount);
if (StringUtils.equalsIgnoreCase("audit", opkey)) {
contract.set("performtaxamount", contractPerformtaxamt.add(targetAmount));
contract.set("performamount", performamount.add(targetNotaxAmount));
contract.set("totaloftaxamount", totaloftaxamount.add(targetAmount));
contract.set("totalamount", totalamount.add(targetNotaxAmount));
} else if (StringUtils.equalsIgnoreCase("unaudit", opkey)) {
BigDecimal performtaxamount1 = contractPerformtaxamt.subtract(targetAmount);
BigDecimal performamount1 = performamount.subtract(targetNotaxAmount);
BigDecimal totaloftaxamount1 = totaloftaxamount.subtract(targetAmount);
BigDecimal totalamount1 = totalamount.subtract(targetNotaxAmount);
contract.set("performtaxamount", performtaxamount1.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : performtaxamount1);
contract.set("performamount", performamount1.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : performamount1);
contract.set("totaloftaxamount", totaloftaxamount1.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : totaloftaxamount1);
contract.set("totalamount", totalamount1.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : totalamount1);
}
SaveServiceHelper.save(new DynamicObject[]{contract});
}
protected BigDecimal getTotalPerformTaxAmount(DynamicObject source, String amtKey) {
DynamicObjectCollection entry = source.getDynamicObjectCollection("entryentity");
BigDecimal amount = BigDecimal.ZERO;
for (int i = 0; i < entry.size(); ++i) {
DynamicObject row = (DynamicObject) entry.get(i);
if (!row.getBoolean("isclaim")) {
DynamicObject payItem = row.getDynamicObject("contpayitem");
BigDecimal coe = BigDecimal.ONE;
if (payItem != null) {
String direction = payItem.getString("direction");
if (StringUtils.equals(direction, DirectionEnum.NON.getValue())) {
coe = BigDecimal.ZERO;
} else if (StringUtils.equals(direction, DirectionEnum.SUB.getValue())) {
coe = coe.negate();
}
}
amount = amount.add(row.getBigDecimal(amtKey).multiply(coe));
}
}
return amount;
}
}

View File

@ -0,0 +1,69 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.basedata.common.enums.PayDirectionEnum;
import kd.ec.contract.opplugin.AbstractContractPerformOp;
public class InContractPerformOpExt extends AbstractContractPerformOp {
public InContractPerformOpExt() {
}
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("contract");
e.getFieldKeys().add("unitproject");
}
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.addValidator(new AbstractValidator() {
public void validate() {
String key = this.getOperateKey();
if (StringUtils.equals(key, "submit")) {
ExtendedDataEntity[] dataEntities = this.getDataEntities();
ExtendedDataEntity[] var3 = dataEntities;
int var4 = dataEntities.length;
for (int var5 = 0; var5 < var4; ++var5) {
ExtendedDataEntity dataEntity = var3[var5];
DynamicObject contract = dataEntity.getDataEntity().getDynamicObject("contract");
DynamicObject unitProject = dataEntity.getDataEntity().getDynamicObject("unitproject");
if (contract != null) {
DynamicObject contOnunit = BusinessDataServiceHelper.loadSingle("ec_in_contract", "id,onunit", new QFilter[]{new QFilter("id", "=", contract.getPkValue())});
if (contOnunit != null) {
Boolean onUnit = contOnunit.getBoolean("onunit");
if (onUnit && unitProject == null) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("请填写单位工程", "InContractPerformOp_0", "ec-contract-opplugin", new Object[0]));
}
}
}
}
}
}
});
}
public void reverseWritingToContract(String opkey, DynamicObject performrecords) {
String selectors = "currency,performtaxamount,performamount,totaloftaxamount,totalamount";
DynamicObject contract = BusinessDataServiceHelper.loadSingle(performrecords.getDynamicObject("contract").getPkValue(), "ec_in_contract", selectors);
this.updateContractPerformAmt(opkey, performrecords, contract);
}
public String getPayDirection() {
return PayDirectionEnum.IN.getValue();
}
}

View File

@ -0,0 +1,35 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.basedata.common.enums.PayDirectionEnum;
import kd.ec.contract.opplugin.AbstractContractPerformOp;
import kd.ec.contract.opplugin.validator.AfterBillInContractAmtControlValidator;
import kd.ec.contract.opplugin.validator.PerformAmountValidator;
public class OutContractPerformOpExt extends AbstractContractPerformOp {
public OutContractPerformOpExt() {
}
public void reverseWritingToContract(String opkey, DynamicObject performrecords) {
String selectors = "currency,performtaxamount,performamount,totaloftaxamount,totalamount";
DynamicObject contract = BusinessDataServiceHelper.loadSingle(performrecords.getDynamicObject("contract").getPkValue(), "ec_out_contract", selectors);
this.updateContractPerformAmt(opkey, performrecords, contract);
}
public String getPayDirection() {
return PayDirectionEnum.OUT.getValue();
}
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
e.getValidators().add(new AfterBillInContractAmtControlValidator());
e.getValidators().add(new PerformAmountValidator());
}
}