优化代码 计算问题解决

This commit is contained in:
xiaoshi 2024-12-17 18:03:25 +08:00
parent 0612c52985
commit 5fe89369d6
2 changed files with 53 additions and 25 deletions

View File

@ -8,6 +8,7 @@ import kd.bos.form.CloseCallBack;
import kd.bos.form.ShowFormHelper; import kd.bos.form.ShowFormHelper;
import kd.bos.list.ListShowParameter; import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.ec.contract.common.enums.PriceAdjustModeEnum;
import kd.ec.contract.formplugin.ContractMeasureBillEditPlugin; import kd.ec.contract.formplugin.ContractMeasureBillEditPlugin;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -22,25 +23,25 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
@Override @Override
protected void onThisQtyChanged(ChangeData changeData) { protected void onThisQtyChanged(ChangeData changeData) {
BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal)changeData.getNewValue()); BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal) changeData.getNewValue());
int rowIndex = changeData.getRowIndex(); int rowIndex = changeData.getRowIndex();
int parentRowIndex = changeData.getParentRowIndex(); int parentRowIndex = changeData.getParentRowIndex();
BigDecimal totalqty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex, parentRowIndex); BigDecimal totalqty = (BigDecimal) this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
BigDecimal preQty = (BigDecimal)this.getModel().getValue("preqty", rowIndex, parentRowIndex); BigDecimal preQty = (BigDecimal) this.getModel().getValue("preqty", rowIndex, parentRowIndex);
BigDecimal balanceQty = totalqty.subtract(preQty); BigDecimal balanceQty = totalqty.subtract(preQty);
if (qty.compareTo(balanceQty) > 0) { // if (qty.compareTo(balanceQty) > 0) {
// this.getView().showMessage(String.format(ResManager.loadKDString("本期计量数量不能超过%s总数量-期初累计计量数量)。", "ContractMeasureBillEditPlugin_4", "ec-contract-formplugin", new Object[0]), balanceQty.intValue())); //// this.getView().showMessage(String.format(ResManager.loadKDString("本期计量数量不能超过%s总数量-期初累计计量数量)。", "ContractMeasureBillEditPlugin_4", "ec-contract-formplugin", new Object[0]), balanceQty.intValue()));
// this.getModel().setValue("thisqty", BigDecimal.ZERO, rowIndex, parentRowIndex); //// this.getModel().setValue("thisqty", BigDecimal.ZERO, rowIndex, parentRowIndex);
} else { // } else {
this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex); this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex);
BigDecimal taxPrice = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex); BigDecimal taxPrice = (BigDecimal) this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
BigDecimal amount = taxPrice.multiply(qty); BigDecimal amount = taxPrice.multiply(qty);
this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex); this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex);
if (this.isInContract()) { if (this.isInContract()) {
this.countPercent(rowIndex, parentRowIndex); this.countPercent(rowIndex, parentRowIndex);
}
} }
// }
} }
@Override @Override
@ -54,8 +55,8 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
List<Object> listingIds = new ArrayList(); List<Object> listingIds = new ArrayList();
int rowIndex; int rowIndex;
for(rowIndex = 0; rowIndex < rowCount; ++rowIndex) { for (rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
DynamicObject listing = (DynamicObject)this.getModel().getValue("listing", rowIndex); DynamicObject listing = (DynamicObject) this.getModel().getValue("listing", rowIndex);
if (listing != null) { if (listing != null) {
// listingIds.add(listing.getPkValue()); // listingIds.add(listing.getPkValue());
} }
@ -63,9 +64,9 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
qFilters.add(new QFilter("id", "not in", listingIds)); qFilters.add(new QFilter("id", "not in", listingIds));
rowIndex = this.getModel().getEntryCurrentRowIndex("listmodelentry"); rowIndex = this.getModel().getEntryCurrentRowIndex("listmodelentry");
String listModelId = (String)this.getModel().getValue("listmodelid", rowIndex); String listModelId = (String) this.getModel().getValue("listmodelid", rowIndex);
qFilters.add(new QFilter("listingmodel", "=", StringUtils.isNotBlank(listModelId) ? Long.parseLong(listModelId) : 0L)); qFilters.add(new QFilter("listingmodel", "=", StringUtils.isNotBlank(listModelId) ? Long.parseLong(listModelId) : 0L));
DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); DynamicObject contract = (DynamicObject) this.getModel().getValue("contract");
if (contract != null) { if (contract != null) {
qFilters.add(new QFilter("contractid", "=", contract.getLong("id"))); qFilters.add(new QFilter("contractid", "=", contract.getLong("id")));
} }
@ -77,9 +78,35 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
} }
} }
// @Override @Override
// public void propertyChanged(PropertyChangedArgs e) { public void propertyChanged(PropertyChangedArgs e) {
// super.propertyChanged(e); super.propertyChanged(e);
String propName = e.getProperty().getName();
ChangeData changeData = e.getChangeSet()[0];
if (StringUtils.equals(propName, "contract")) {
this.onContractChanged(changeData);
} else if (StringUtils.equals(propName, "period")) {
this.onPeriodChanged(changeData);
} else if (!StringUtils.equals(propName, "begindate") && !StringUtils.equals(propName, "enddate")) {
if (StringUtils.equals(propName, "thisqty")) {
this.onThisQtyChanged(changeData);
} else if (StringUtils.equals(propName, "thisamount")) {
this.onThisAmountChanged(changeData);
} else if (StringUtils.equals(propName, "thisoftaxmount")) {
this.onThisOfTaxAmountChanged(changeData);
} else if (StringUtils.equals(propName, "thistax")) {
this.onThisTaxChanged(changeData);
} else if (StringUtils.equals(propName, "ismeasurebymatin")) {
this.isMeasureByMaterialInChanged(changeData);
} else if (StringUtils.equals(propName, PriceAdjustModeEnum.ADJUST_AMOUNT.getValue())) {
this.onAdjustAmountChange(changeData);
} else if (StringUtils.equals(propName, PriceAdjustModeEnum.ADJUST_TAX.getValue())) {
this.onAdjustTaxChange(changeData);
}
} else {
this.onDateChanged(changeData, propName);
}
// String name = e.getProperty().getName(); // String name = e.getProperty().getName();
// ChangeData changeData = e.getChangeSet()[0]; // ChangeData changeData = e.getChangeSet()[0];
// int rowIndex = changeData.getRowIndex(); // int rowIndex = changeData.getRowIndex();
@ -131,6 +158,6 @@ public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin
//// this.getView().updateView(); //// this.getView().updateView();
//// } //// }
//// ////
//// } // }
// } }
} }

View File

@ -34,7 +34,8 @@ public class ResourceFilterExtPlugin extends ResourceItemListPlugin {
} else if (contractType.toString().equals("sbcg")) {//设备采购 } else if (contractType.toString().equals("sbcg")) {//设备采购
this.setResourceTypeStyle("equipment"); this.setResourceTypeStyle("equipment");
this.afterSelectedTag("equipment"); this.afterSelectedTag("equipment");
}else if (contractType.toString().equals("qtcc") || contractType.toString().equals("lwlcc")) {//产出物 }else if (contractType.toString().equals("qtcc") || contractType.toString().equals("lwlcc")|| contractType.toString().equals("ck")||
contractType.toString().equals("zyfbcc")|| contractType.toString().equals("jjbc")) {//产出物
this.setResourceTypeStyle("turnover"); this.setResourceTypeStyle("turnover");
this.afterSelectedTag("turnover"); this.afterSelectedTag("turnover");
}else { }else {