1:入库单审核操作插件:校验是否合计数量超过采购申请单数量;2:入库单审核反审核操作插件:审核、反审核时,将入库单数量反写至采购申请单
This commit is contained in:
parent
88908f67b6
commit
d3499a4d1c
|
@ -0,0 +1,69 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
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 java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 入库单审核操作插件:校验是否合计数量超过采购申请单数量
|
||||
*/
|
||||
public class MaterialInbValidatorAuditOp extends AbstractOperationServicePlugIn {
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("matinsource");
|
||||
e.getFieldKeys().add("zcgj_purchaseapply");
|
||||
e.getFieldKeys().add("entryentity");
|
||||
e.getFieldKeys().add("listingid");
|
||||
e.getFieldKeys().add("qty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
e.getValidators().add(new ValidatorExt());
|
||||
}
|
||||
|
||||
class ValidatorExt extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity();
|
||||
String matInSource = ecma_MaterialInBill.getString("matinsource");//入库来源
|
||||
DynamicObject zcgj_purchaseApply = ecma_MaterialInBill.getDynamicObject("zcgj_purchaseapply");//采购申请
|
||||
if ("6".equals(matInSource) && zcgj_purchaseApply != null) {
|
||||
DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply",
|
||||
new QFilter[]{new QFilter("id", "=", zcgj_purchaseApply.getLong("id"))});//采购申请单
|
||||
DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
|
||||
DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
|
||||
for (int i = 0; i < entryEntityCollection.size(); i++) {
|
||||
DynamicObject entryEntity = entryEntityCollection.get(i);
|
||||
String listingId = entryEntity.getString("listingid");//入库单分录-合同清单id
|
||||
|
||||
for (DynamicObject purchaseEntry : purchaseEntryCollection) {
|
||||
String purchaseEntryId = purchaseEntry.getString("id");//采购明细单据体-id
|
||||
if (purchaseEntryId != null && purchaseEntryId.equals(listingId)) {
|
||||
BigDecimal qty = entryEntity.getBigDecimal("qty");//入库单分录-数量
|
||||
BigDecimal inCount = purchaseEntry.getBigDecimal("zcgj_incount");//采购明细单据体-已入库数量
|
||||
BigDecimal purchaseQty = purchaseEntry.getBigDecimal("purchaseqty");//采购明细单据体-采购数量
|
||||
BigDecimal sum = qty.add(inCount);
|
||||
if (sum.compareTo(purchaseQty) > 0) {
|
||||
int i1 = i + 1;
|
||||
this.addFatalErrorMessage(extendedDataEntity, "第" + i1 + "行,填写数量大于采购申请对应的采购数量!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,12 @@ package zcgj.zcdev.zcdev.pr.plugin.operate;
|
|||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
@ -13,7 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 入库单保存删除插件:保存、删除时,将入库单数量反写至采购申请单
|
||||
* 入库单审核反审核操作插件:审核、反审核时,将入库单数量反写至采购申请单
|
||||
*/
|
||||
public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
|
@ -35,8 +39,8 @@ public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
|
|||
//为采购申请单时反写数量
|
||||
DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply",
|
||||
new QFilter[]{new QFilter("id", "=", zcgj_purchaseApply.getLong("id"))});//采购申请单
|
||||
DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
|
||||
DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
|
||||
DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
|
||||
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||
String listingId = entryEntity.getString("listingid");//入库单分录-合同清单id
|
||||
|
||||
|
@ -45,9 +49,11 @@ public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
|
|||
if (purchaseEntryId != null && purchaseEntryId.equals(listingId)) {
|
||||
BigDecimal qty = entryEntity.getBigDecimal("qty");//入库单分录-数量
|
||||
BigDecimal inCount = purchaseEntry.getBigDecimal("zcgj_incount");//采购明细单据体-已入库数量
|
||||
if ("save".equals(operationKey)) {
|
||||
if ("audit".equals(operationKey)) {
|
||||
//审核时
|
||||
purchaseEntry.set("zcgj_incount", inCount.add(qty));//采购明细单据体-已入库数量
|
||||
} else {
|
||||
} else if ("unaudit".equals(operationKey)) {
|
||||
//反审核时
|
||||
purchaseEntry.set("zcgj_incount", inCount.subtract(qty));//采购明细单据体-已入库数量
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue