优化代码 合同计量与支出合同

This commit is contained in:
xiaoshi 2024-12-23 17:48:26 +08:00
parent fd6033a32a
commit bb6b654434
5 changed files with 112 additions and 71 deletions

View File

@ -0,0 +1,22 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.ec.contract.formplugin.ContractTreeListingPlugin;
public class ContractTreeListExtPlugin extends ContractTreeListingPlugin {
@Override
protected void listingShowCloumn(String listModelId) {
super.listingShowCloumn(listModelId);
Object contractType = this.getModel().getValue("contracttype");
if(contractType != null) {
DynamicObject dynamicObject = (DynamicObject) contractType;
String number = dynamicObject.getString("number");
if(number .equals("wzcg01")||number.equals("sbcg")||number.equals("jjfb")) {
this.getView().setVisible(false, new String[]{"treecbsnumber", "treecbsname","cbs"});
this.getView().setEnable(false,"isincost");
this.getModel().setValue("isincost",false);
}
}
}
}

View File

@ -19,62 +19,59 @@ public class OutContractFromPlugin extends AbstractBillPlugIn implements Plugin
private String entryName = "treelistentry";//分录标识 private String entryName = "treelistentry";//分录标识
private String ecContract = "incontract";// private String ecContract = "incontract";//
@Override @Override
public void propertyChanged(PropertyChangedArgs e) { public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e); super.propertyChanged(e);
String changeName = e.getProperty().getName(); String changeName = e.getProperty().getName();
if(changeName.equals(ecContract)){//收入合同字段值改变 if (changeName.equals(ecContract)) {//收入合同字段值改变
Object outC = this.getModel().getValue(ecContract); Object outC = this.getModel().getValue(ecContract);
if(outC!=null){ if (outC != null) {
DynamicObject contractF7 = (DynamicObject) outC; DynamicObject contractF7 = (DynamicObject) outC;
String paydirection = contractF7.getString("paydirection");//支出/收入 String paydirection = contractF7.getString("paydirection");//支出/收入
String contractNumber = contractF7.getString("number");//获取收入合同合同清单 String contractNumber = contractF7.getString("number");//获取收入合同合同清单
if(paydirection.equals("in")){ if (paydirection.equals("in")) {
QFilter f1 = new QFilter("billno", "=", contractNumber); // QFilter f1 = new QFilter("billno", "=", contractNumber);
DynamicObject inContract = BusinessDataServiceHelper.loadSingle("ec_in_contract", new QFilter[]{f1}); // DynamicObject inContract = BusinessDataServiceHelper.loadSingle("ec_in_contract", new QFilter[]{f1});
DynamicObjectCollection listmodelentry = inContract.getDynamicObjectCollection("listmodelentry"); // DynamicObjectCollection listmodelentry = inContract.getDynamicObjectCollection("listmodelentry");
for (int x = 0; x < listmodelentry.size(); x++ ) { // for (int x = 0; x < listmodelentry.size(); x++ ) {
DynamicObject dynamicObject = listmodelentry.get(x); // DynamicObject dynamicObject = listmodelentry.get(x);
DynamicObjectCollection listmodelentry1 = this.getModel().getEntryEntity("listmodelentry"); // DynamicObjectCollection listmodelentry1 = this.getModel().getEntryEntity("listmodelentry");
DynamicObjectType dynamicObjectType = listmodelentry1.getDynamicObjectType(); // DynamicObjectType dynamicObjectType = listmodelentry1.getDynamicObjectType();
ORM orm = ORM.create(); // ORM orm = ORM.create();
long listingid = orm.genLongId(dynamicObjectType); // long listingid = orm.genLongId(dynamicObjectType);
int entryRow = this.getModel().insertEntryRow("listmodelentry", x); // int entryRow = this.getModel().insertEntryRow("listmodelentry", x);
this.getModel().setValue("modelname",dynamicObject.getString("modelname"),entryRow); // this.getModel().setValue("modelname",dynamicObject.getString("modelname"),entryRow);
this.getModel().setValue("cmptype",dynamicObject.getString("cmptype"),entryRow); // this.getModel().setValue("cmptype",dynamicObject.getString("cmptype"),entryRow);
this.getModel().setValue("rowamount",dynamicObject.getString("rowamount"),entryRow); // this.getModel().setValue("rowamount",dynamicObject.getString("rowamount"),entryRow);
this.getModel().setValue("rowtax",dynamicObject.getString("rowtax"),entryRow); // this.getModel().setValue("rowtax",dynamicObject.getString("rowtax"),entryRow);
this.getModel().setValue("rowoftax",dynamicObject.getString("rowoftax"),entryRow); // this.getModel().setValue("rowoftax",dynamicObject.getString("rowoftax"),entryRow);
this.getModel().setValue("listmodelid",listingid,entryRow); // this.getModel().setValue("listmodelid",listingid,entryRow);
DynamicObjectCollection sublistentry = dynamicObject.getDynamicObjectCollection("sublistentry"); // DynamicObjectCollection sublistentry = dynamicObject.getDynamicObjectCollection("sublistentry");
for (int i = 0; i < sublistentry.size(); i++) { // for (int i = 0; i < sublistentry.size(); i++) {
DynamicObject object = sublistentry.get(i); // DynamicObject object = sublistentry.get(i);
int row = this.getModel().insertEntryRow("sublistentry", i); // int row = this.getModel().insertEntryRow("sublistentry", i);
this.getModel().setValue("sublistmodelid",listingid,row); // this.getModel().setValue("sublistmodelid",listingid,row);
this.getModel().setValue("sysnumber",object.getString("sysnumber"),row); // this.getModel().setValue("sysnumber",object.getString("sysnumber"),row);
this.getModel().setValue("listnumber",object.getString("listnumber"),row); // this.getModel().setValue("listnumber",object.getString("listnumber"),row);
this.getModel().setValue("listname",object.getString("listname"),row); // this.getModel().setValue("listname",object.getString("listname"),row);
this.getModel().setValue("resourceitem",object.getString("resourceitem"),row); // this.getModel().setValue("resourceitem",object.getString("resourceitem"),row);
this.getModel().setValue("measureunit",object.getDynamicObject("measureunit"),row); // this.getModel().setValue("measureunit",object.getDynamicObject("measureunit"),row);
this.getModel().setValue("qty",object.getBigDecimal("qty"),row); // this.getModel().setValue("qty",object.getBigDecimal("qty"),row);
this.getModel().setValue("price",object.getBigDecimal("price"),row); // this.getModel().setValue("price",object.getBigDecimal("price"),row);
this.getModel().setValue("amount",object.getBigDecimal("amount"),row); // this.getModel().setValue("amount",object.getBigDecimal("amount"),row);
this.getModel().setValue("rateobj",object.getDynamicObject("rateobj"),row); // this.getModel().setValue("rateobj",object.getDynamicObject("rateobj"),row);
this.getModel().setValue("tax",object.getBigDecimal("tax"),row); // this.getModel().setValue("tax",object.getBigDecimal("tax"),row);
this.getModel().setValue("taxprice",object.getBigDecimal("taxprice"),row); // this.getModel().setValue("taxprice",object.getBigDecimal("taxprice"),row);
this.getModel().setValue("oftax",object.getBigDecimal("oftax"),row); // this.getModel().setValue("oftax",object.getBigDecimal("oftax"),row);
this.getModel().setValue("listunitproject",object.getDynamicObject("listunitproject"),row); // this.getModel().setValue("listunitproject",object.getDynamicObject("listunitproject"),row);
this.getModel().setValue("desc",object.getString("desc"),row); // this.getModel().setValue("desc",object.getString("desc"),row);
}
}
this.getView().updateView("listmodelentry");
this.getView().updateView("treelistentry");
} else if (paydirection.equals("out")) {
} }
} }
this.getView().updateView("listmodelentry");
this.getView().updateView("treelistentry");
} }
// this.getView().setVisible(false, new String[]{"treelistunitproject", "treelistunitprojectname"});
// this.getView().setVisible(false,"");
} }
}
}

View File

@ -0,0 +1,22 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.field.BasedataEdit;
import kd.ec.contract.formplugin.OutContractMeasureBillEditPlugin;
public class OutContractMeasureBillEditExtPlugin extends OutContractMeasureBillEditPlugin {
@Override
protected void controlCostMustInput() {
super.controlCostMustInput();
DynamicObject contract = this.getModel().getDataEntity().getDynamicObject("contract");
String number = contract.getDynamicObject("contracttype").getString("number");
if (number .equals("wzcg01")||number.equals("sbcg")||number.equals("jjfb")){
BasedataEdit basedataEdit = (BasedataEdit)this.getControl("listcbs");
basedataEdit.setMustInput(false);
basedataEdit = (BasedataEdit)this.getControl("cbs");
basedataEdit.setMustInput(false);
this.getView().setVisible(false,"listcbs");
this.getView().setVisible(false,"cbs");
}
}
}

View File

@ -26,18 +26,18 @@ public class InContractSettlementValidator extends InContractSettleValidator {
if (contractTemp == null) { if (contractTemp == null) {
return; return;
} }
DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry"); // DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry");
if (itementry != null) { // if (itementry != null) {
if (itementry.size() == 0) { // if (itementry.size() == 0) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); // this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
} // }
BigDecimal amount = new BigDecimal(0); // BigDecimal amount = new BigDecimal(0);
for (DynamicObject object : itementry) { // for (DynamicObject object : itementry) {
BigDecimal oftaxamount = object.getBigDecimal("oftaxamount"); // BigDecimal oftaxamount = object.getBigDecimal("oftaxamount");
amount = amount.add(oftaxamount); // amount = amount.add(oftaxamount);
} // }
if (amount.compareTo(new BigDecimal(0)) <= 0) { if (settleOfTaxAmount.compareTo(new BigDecimal(0)) <= 0) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项分录中的金额不能为空!", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项分录不能为空或支付合同项分录中的金额不能为空!", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
} }
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract"); DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount"); BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
@ -49,7 +49,7 @@ public class InContractSettlementValidator extends InContractSettleValidator {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr"); contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype")); validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
} }
} // }
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap"); // DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");
// if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) { // if (validateAmount && settleOfTaxAmount.compareTo(totalOfTaxAmount.subtract(totalSettleOfTaxAmount)) > 0) {
// this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); // this.addErrorMessage(dataEntity, ResManager.loadKDString("本期结算价税合计不能大于合同剩余金额价税合计", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));

View File

@ -18,17 +18,17 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount"); BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount");
DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract"); DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract");
DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry"); // DynamicObjectCollection itementry = dataEntity.getDataEntity().getDynamicObjectCollection("itementry");
if (itementry.isEmpty()) { // if (itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); // this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
} // }
BigDecimal amount = new BigDecimal(0); // BigDecimal amount = new BigDecimal(0);
for (DynamicObject object : itementry) { // for (DynamicObject object : itementry) {
BigDecimal oftaxamount = object.getBigDecimal("oftaxamount"); // BigDecimal oftaxamount = object.getBigDecimal("oftaxamount");
amount = amount.add(oftaxamount); // amount = amount.add(oftaxamount);
} // }
if (amount.compareTo(new BigDecimal(0)) <= 0) { if (settleOfTaxAmount.compareTo(new BigDecimal(0)) <= 0) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项分录中的金额不能为空!", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0])); this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项分录不能为空或支付合同项分录中的金额不能为空!", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
} }
if (contractTemp == null) { if (contractTemp == null) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("合同不可为空。", "OutContractSettleValidator_5", "ec-contract-opplugin", new Object[0])); this.addErrorMessage(dataEntity, ResManager.loadKDString("合同不可为空。", "OutContractSettleValidator_5", "ec-contract-opplugin", new Object[0]));