入库单日期提交操作校验插件添加
This commit is contained in:
parent
d049384f2b
commit
f181f1bbeb
|
|
@ -0,0 +1,112 @@
|
|||
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.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 入库单日期提交操作校验插件
|
||||
* 说明:采购申请审批日期不能晚于开票日期和入库日期(业务日期)
|
||||
*/
|
||||
public class MaterialInBillDateSubValidatorOp extends AbstractOperationServicePlugIn {
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("matinsource");//入库来源
|
||||
e.getFieldKeys().add("zcgj_ispurchaseapplys");//多采购申请
|
||||
e.getFieldKeys().add("zcgj_purchaseapplyentry");//采购申请分录
|
||||
e.getFieldKeys().add("zcgj_purchaseapply_f7");//采购申请
|
||||
e.getFieldKeys().add("bizdate");//业务日期
|
||||
e.getFieldKeys().add("zcgj_entryentity");//合同进项发票信息
|
||||
e.getFieldKeys().add("zcgj_invoice");//发票号码
|
||||
e.getFieldKeys().add("zcgj_purchaseapply");//采购申请
|
||||
}
|
||||
|
||||
@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");//入库来源
|
||||
if ("6".equals(matinsource)) {
|
||||
//入库来源为采购申请
|
||||
boolean zcgj_ispurchaseapplys = ecma_MaterialInBill.getBoolean("zcgj_ispurchaseapplys");//多采购申请
|
||||
if (zcgj_ispurchaseapplys) {
|
||||
DynamicObjectCollection zcgj_purchaseapplyentryCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_purchaseapplyentry");//采购申请分录
|
||||
if (zcgj_purchaseapplyentryCollection.size() > 0) {
|
||||
for (DynamicObject zcgj_purchaseapplyentry : zcgj_purchaseapplyentryCollection) {
|
||||
DynamicObject zcgj_purchaseapply = zcgj_purchaseapplyentry.getDynamicObject("zcgj_purchaseapply_f7");//采购申请
|
||||
if (zcgj_purchaseapply == null) {
|
||||
continue;
|
||||
}
|
||||
String zcgj_number = zcgj_purchaseapply.getString("zcgj_number");
|
||||
QFilter[] qFilters = new QFilter[]{new QFilter("billno", QCP.equals, zcgj_number)};
|
||||
DynamicObject ecma_purchaseapply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply", "auditdate", qFilters);//采购申请
|
||||
Date auditdate = ecma_purchaseapply.getDate("auditdate");//采购申请-审核时间
|
||||
Date bizdate = ecma_MaterialInBill.getDate("bizdate");//业务日期
|
||||
if (auditdate != null && bizdate != null && auditdate.after(bizdate)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "采购申请单:" + zcgj_number + "的审批日期不能晚于业务日期!");
|
||||
continue;
|
||||
}
|
||||
DynamicObjectCollection zcgj_entryentityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息
|
||||
if (zcgj_entryentityCollection.size() > 0) {
|
||||
for (DynamicObject zcgj_entryentity : zcgj_entryentityCollection) {
|
||||
DynamicObject zcgj_invoice = zcgj_entryentity.getDynamicObject("zcgj_invoice");//发票号码
|
||||
if (zcgj_invoice != null) {
|
||||
Date invoicedate = zcgj_invoice.getDate("invoicedate");//发票号码-开票日期
|
||||
String billno = zcgj_invoice.getString("billno");
|
||||
if (invoicedate != null && auditdate != null && auditdate.after(invoicedate)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "采购申请单:" + zcgj_number + "的审批日期不能晚于发票:" + billno + "的开票日期!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DynamicObject zcgj_purchaseapply = ecma_MaterialInBill.getDynamicObject("zcgj_purchaseapply");//采购申请
|
||||
if (zcgj_purchaseapply == null) {
|
||||
continue;
|
||||
}
|
||||
QFilter[] qFilters = new QFilter[]{new QFilter("id", QCP.equals, zcgj_purchaseapply.getPkValue())};
|
||||
DynamicObject ecma_purchaseapply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply", "auditdate", qFilters);//采购申请
|
||||
Date auditdate = ecma_purchaseapply.getDate("auditdate");//采购申请-审核时间
|
||||
Date bizdate = ecma_MaterialInBill.getDate("bizdate");//业务日期
|
||||
if (auditdate != null && bizdate != null && auditdate.after(bizdate)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "采购申请的审批日期不能晚于业务日期!");
|
||||
continue;
|
||||
}
|
||||
DynamicObjectCollection zcgj_entryentityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息
|
||||
if (zcgj_entryentityCollection.size() > 0) {
|
||||
for (DynamicObject zcgj_entryentity : zcgj_entryentityCollection) {
|
||||
DynamicObject zcgj_invoice = zcgj_entryentity.getDynamicObject("zcgj_invoice");//发票号码
|
||||
if (zcgj_invoice != null) {
|
||||
Date invoicedate = zcgj_invoice.getDate("invoicedate");//发票号码-开票日期
|
||||
String billno = zcgj_invoice.getString("billno");
|
||||
if (invoicedate != null && auditdate != null && auditdate.after(invoicedate)) {
|
||||
this.addFatalErrorMessage(extendedDataEntity, "采购申请的审批日期不能晚于发票:" + billno + "的开票日期!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue