需求:在设置付款条件时不允许账期+付款方式重复。
由于本次需求仅需要对VO缓存中的数据进行重复性校验,所以仅需进行缓存遍历即可,不需要校验数据库。
方式1,在EORow的进行数据校验。
public void setPaymentTermsId(Number value) { if(value!=null && !"".equals(value) && this.getPaymentMethod()!=null && !"".equals(getPaymentMethod()) ){ validateRepeat(value, getPaymentMethod(), "TERMS"); } setAttributeInternal(PAYMENTTERMSID, value); } public void setPaymentMethod(String value) { if(value!=null && !"".equals(value) && this.getPaymentTermsId()!=null && !"".equals(getPaymentTermsId()) ){ validateRepeat(getPaymentTermsId(), value, "METHOD"); } setAttributeInternal(PAYMENTMETHOD, value); } public void validateRepeat(Number payTerms,String payMethod,String cloumn){ com.sun.java.util.collections.Iterator payIterator = getEntityDef().getAllEntityInstancesIterator(getDBTransaction()); String currentStr = payTerms+"-"+payMethod; while(payIterator.hasNext()){ CuxPoPayProvisionTempEOImpl cachePay = (CuxPoPayProvisionTempEOImpl)payIterator.next(); String validationStr = cachePay.getPaymentTermsId()+"-"+cachePay.getPaymentMethod(); if(currentStr.equals(validationStr)){ if("TERMS".equals(cloumn)){ //发生重复异常时,设置选择值为空,避免选择后提示了异常,选择值仍然放置到了Poplist中 setPaymentTermsId(null); } if("METHOD".equals(cloumn)){ //发生重复异常时,设置选择值为空,避免选择后提示了异常,选择值仍然放置到了Poplist中 setPaymentMethod(null); } throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, getEntityDef().getFullName(), getPrimaryKey(), "PayProvisionTempId", currentStr, "CUX", "CUX_PO_PAY_PROVI_VALIDATION"); // Message name } } }
2.在VORow中进行校验,
public void setPaymentTermsId(Number value) { if(value!=null && !"".equals(value) && this.getPaymentMethod()!=null && !"".equals(getPaymentMethod()) ){ validateRepeat(value, getPaymentMethod(), "TERMS"); } setAttributeInternal(PAYMENTTERMSID, value); } public String getPaymentMethod() { return (String) getAttributeInternal(PAYMENTMETHOD); } public void validateRepeat(Number payTerms,String payMethod,String cloumn){ CuxPoPayProvisionTempEOImpl tempEO =(CuxPoPayProvisionTempEOImpl)this.getEntity(0); com.sun.java.util.collections.Iterator payIterator = tempEO.getDefinitionObject().getAllEntityInstancesIterator(tempEO.getDBTransaction()); String currentStr = payTerms+"-"+payMethod; while(payIterator.hasNext()){ CuxPoPayProvisionTempEOImpl cachePay = (CuxPoPayProvisionTempEOImpl)payIterator.next(); String validationStr = cachePay.getPaymentTermsId()+"-"+cachePay.getPaymentMethod(); if(currentStr.equals(validationStr)){ if("TERMS".equals(cloumn)){ setPaymentTermsId(null); } if("METHOD".equals(cloumn)){ setPaymentMethod(null); } throw new OAAttrValException(OAException.TYP_VIEW_OBJECT, getViewObject().getFullName(), getKey(), "PayProvisionTempId", currentStr, "CUX", "CUX_PO_PAY_PROVI_VALIDATION"); // Message name } } }
时间: 2024-11-09 01:46:49