收入与支出合同计量校验去除
This commit is contained in:
parent
5c05a986fb
commit
a056e71046
|
@ -0,0 +1,32 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.ec.contract.formplugin.ContractMeasureBillEditPlugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ContractEeasurementBillPlugin extends ContractMeasureBillEditPlugin {
|
||||
|
||||
@Override
|
||||
protected void onThisQtyChanged(ChangeData changeData) {
|
||||
BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal)changeData.getNewValue());
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
int parentRowIndex = changeData.getParentRowIndex();
|
||||
BigDecimal totalqty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
||||
BigDecimal preQty = (BigDecimal)this.getModel().getValue("preqty", rowIndex, parentRowIndex);
|
||||
BigDecimal balanceQty = totalqty.subtract(preQty);
|
||||
if (qty.compareTo(balanceQty) > 0) {
|
||||
// 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);
|
||||
} else {
|
||||
this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex);
|
||||
BigDecimal taxPrice = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
|
||||
BigDecimal amount = taxPrice.multiply(qty);
|
||||
this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex);
|
||||
if (this.isInContract()) {
|
||||
this.countPercent(rowIndex, parentRowIndex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.ec.contract.formplugin.InContractMeasureBillEditPlugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEditPlugin {
|
||||
|
||||
@Override
|
||||
protected void onThisQtyChanged(ChangeData changeData) {
|
||||
BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal)changeData.getNewValue());
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
int parentRowIndex = changeData.getParentRowIndex();
|
||||
BigDecimal totalqty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
||||
BigDecimal preQty = (BigDecimal)this.getModel().getValue("preqty", rowIndex, parentRowIndex);
|
||||
BigDecimal balanceQty = totalqty.subtract(preQty);
|
||||
if (qty.compareTo(balanceQty) > 0) {
|
||||
// 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);
|
||||
} else {
|
||||
this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex);
|
||||
BigDecimal taxPrice = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
|
||||
BigDecimal amount = taxPrice.multiply(qty);
|
||||
this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex);
|
||||
if (this.isInContract()) {
|
||||
this.countPercent(rowIndex, parentRowIndex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.ec.basedata.common.enums.BillStatusEnum;
|
||||
import kd.ec.contract.opplugin.validator.ContractMeasureValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class ContractMeasurementValidator extends ContractMeasureValidator {
|
||||
|
||||
@Override
|
||||
protected void validateListingQty(Set<Long> excludeIds) {
|
||||
{
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
Set<Long> listingIds = new HashSet(16);
|
||||
Set<Long> measureIds = new HashSet(16);
|
||||
Set<Long> repeatListingIds = new HashSet(16);
|
||||
ExtendedDataEntity[] var6 = dataEntities;
|
||||
int var7 = dataEntities.length;
|
||||
|
||||
DynamicObject changeListing;
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
ExtendedDataEntity dataEntity = var6[var8];
|
||||
changeListing = dataEntity.getDataEntity();
|
||||
if (!excludeIds.contains(changeListing.getLong("id"))) {
|
||||
measureIds.add(changeListing.getLong("id"));
|
||||
DynamicObjectCollection modelEntries = changeListing.getDynamicObjectCollection("listmodelentry");
|
||||
Iterator var12 = modelEntries.iterator();
|
||||
|
||||
while(var12.hasNext()) {
|
||||
DynamicObject modelEntry = (DynamicObject)var12.next();
|
||||
DynamicObjectCollection listingEntries = modelEntry.getDynamicObjectCollection("listentry");
|
||||
Iterator var15 = listingEntries.iterator();
|
||||
|
||||
while(var15.hasNext()) {
|
||||
DynamicObject listingEntry = (DynamicObject)var15.next();
|
||||
DynamicObject listing = listingEntry.getDynamicObject("listing");
|
||||
if (listing != null && !listingIds.add(listing.getLong("id"))) {
|
||||
repeatListingIds.add(listing.getLong("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listingIds.removeAll(repeatListingIds);
|
||||
QFilter changeFilter = new QFilter("kapianentry.entryentity.listid", "in", listingIds);
|
||||
changeFilter.and("billstatus", "=", BillStatusEnum.SUBMIT.getValue());
|
||||
DynamicObjectCollection changeListings = QueryServiceHelper.query("ec_inrevision", "kapianentry.entryentity.listid", new QFilter[]{changeFilter});
|
||||
Set<Long> changedListingIds = new HashSet(16);
|
||||
Iterator var30 = changeListings.iterator();
|
||||
|
||||
while(var30.hasNext()) {
|
||||
changeListing = (DynamicObject)var30.next();
|
||||
changedListingIds.add(changeListing.getLong("kapianentry.entryentity.listid"));
|
||||
}
|
||||
|
||||
QFilter listingFilter = new QFilter("id", "in", listingIds);
|
||||
DynamicObject[] listings = BusinessDataServiceHelper.load("ec_intreelisting", "id,totalqty", new QFilter[]{listingFilter});
|
||||
Map<Long, BigDecimal> listingQtyBalance = new HashMap(16);
|
||||
DynamicObject[] var34 = listings;
|
||||
int var36 = listings.length;
|
||||
|
||||
DynamicObject measureListing;
|
||||
for(int var38 = 0; var38 < var36; ++var38) {
|
||||
measureListing = var34[var38];
|
||||
listingQtyBalance.put(measureListing.getLong("id"), measureListing.getBigDecimal("totalqty"));
|
||||
}
|
||||
|
||||
QFilter filter = new QFilter("listmodelentry.listentry.listing", "in", listingIds);
|
||||
filter.and("billstatus", "in", new String[]{BillStatusEnum.SUBMIT.getValue(), BillStatusEnum.AUDIT.getValue()});
|
||||
filter.and("id", "not in", measureIds);
|
||||
DynamicObjectCollection measureListings = QueryServiceHelper.query("ec_incontractmeasure", "listmodelentry.listentry.listing,listmodelentry.listentry.thisqty", new QFilter[]{filter});
|
||||
Iterator var39 = measureListings.iterator();
|
||||
|
||||
while(var39.hasNext()) {
|
||||
measureListing = (DynamicObject)var39.next();
|
||||
long listingId = measureListing.getLong("listmodelentry.listentry.listing");
|
||||
if (listingId != 0L) {
|
||||
BigDecimal qtyBalance = (BigDecimal)listingQtyBalance.getOrDefault(listingId, BigDecimal.ZERO);
|
||||
listingQtyBalance.put(listingId, qtyBalance.subtract(measureListing.getBigDecimal("listmodelentry.listentry.thisqty")));
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedDataEntity[] var41 = dataEntities;
|
||||
int var42 = dataEntities.length;
|
||||
|
||||
for(int var44 = 0; var44 < var42; ++var44) {
|
||||
ExtendedDataEntity dataEntity = var41[var44];
|
||||
DynamicObject bill = dataEntity.getDataEntity();
|
||||
if (!excludeIds.contains(bill.getLong("id"))) {
|
||||
DynamicObjectCollection modelEntries = bill.getDynamicObjectCollection("listmodelentry");
|
||||
Iterator var20 = modelEntries.iterator();
|
||||
|
||||
while(var20.hasNext()) {
|
||||
DynamicObject modelEntry = (DynamicObject)var20.next();
|
||||
DynamicObjectCollection listingEntries = modelEntry.getDynamicObjectCollection("listentry");
|
||||
Iterator var23 = listingEntries.iterator();
|
||||
|
||||
while(var23.hasNext()) {
|
||||
DynamicObject listingEntry = (DynamicObject)var23.next();
|
||||
DynamicObject listing = listingEntry.getDynamicObject("listing");
|
||||
if (listing != null) {
|
||||
if (repeatListingIds.contains(listing.getLong("id"))) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("本次操作的单据中清单【%s】存在重复,请检查。", "ContractMeasureValidator_2", "ec-contract-opplugin", new Object[0]), listing.getString("name")));
|
||||
} else if (changedListingIds.contains(listing.getLong("id"))) {
|
||||
this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("清单【%s】正在变更中,请检查。", "ContractMeasureValidator_3", "ec-contract-opplugin", new Object[0]), listing.getString("name")));
|
||||
} else {
|
||||
// BigDecimal thisQty = listingEntry.getBigDecimal("thisqty");
|
||||
// if (thisQty != null && thisQty.compareTo(BigDecimal.ZERO) != 0 && thisQty.compareTo((BigDecimal)listingQtyBalance.getOrDefault(listing.getLong("id"), BigDecimal.ZERO)) > 0) {
|
||||
// this.addErrorMessage(dataEntity, String.format(ResManager.loadKDString("清单【%s】本次计量数量已超剩余可计量数量,请修改。", "ContractMeasureValidator_4", "ec-contract-opplugin", new Object[0]), listing.getString("name")));
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.ec.contract.opplugin.ContractMeasureOp;
|
||||
import kd.ec.contract.opplugin.validator.ContractMeasureValidator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InContractMeasurementOp extends ContractMeasureOp {
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
List<AbstractValidator> validators = e.getValidators();
|
||||
// 删除标品校验器
|
||||
validators.removeIf(validator -> validator instanceof ContractMeasureValidator);
|
||||
|
||||
// 添加定制二开的校验器(位置放第一位,优先执行)
|
||||
validators.add(0, new ContractMeasurementValidator());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.ec.contract.opplugin.OutContractMeasureOp;
|
||||
import kd.ec.contract.opplugin.validator.ContractMeasureValidator;
|
||||
import java.util.List;
|
||||
|
||||
public class OutContractMeasurementOp extends OutContractMeasureOp{
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
List<AbstractValidator> validators = e.getValidators();
|
||||
// 删除标品校验器
|
||||
validators.removeIf(validator -> validator instanceof ContractMeasureValidator);
|
||||
|
||||
// 添加定制二开的校验器(位置放第一位,优先执行)
|
||||
validators.add(0, new ContractMeasurementValidator());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue