From 645588997ddd4c1d0f191a2468d71a3a55431416 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 21 Nov 2025 16:24:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=93=8D=E4=BD=9C=E6=A0=A1=E9=AA=8C=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialInBillDateSubValidatorOp.java | 82 +++++++++++-------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillDateSubValidatorOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillDateSubValidatorOp.java index dee8fad..b12a472 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillDateSubValidatorOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillDateSubValidatorOp.java @@ -10,6 +10,7 @@ import kd.bos.entity.validate.AbstractValidator; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; import java.util.Date; @@ -28,6 +29,7 @@ public class MaterialInBillDateSubValidatorOp extends AbstractOperationServicePl e.getFieldKeys().add("zcgj_entryentity");//合同进项发票信息 e.getFieldKeys().add("zcgj_invoice");//发票号码 e.getFieldKeys().add("zcgj_purchaseapply");//采购申请 + e.getFieldKeys().add("fiaccountorg");//财务记账组织 } @Override @@ -45,22 +47,56 @@ public class MaterialInBillDateSubValidatorOp extends AbstractOperationServicePl 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");//采购申请 + DynamicObject fiaccountorg = ecma_MaterialInBill.getDynamicObject("fiaccountorg");//财务记账组织 + if (fiaccountorg != null) { + QFilter filter = new QFilter("zcgj_companyblentry.zcgj_org.id", QCP.equals, fiaccountorg.getPkValue()); + filter.and(new QFilter("zcgj_checkreqdate", QCP.equals, true)); + DynamicObject zcgj_companybelong = QueryServiceHelper.queryOne("zcgj_companybelong", "id", new QFilter[]{filter}); + if (zcgj_companybelong != null) { + 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; } - String zcgj_number = zcgj_purchaseapply.getString("zcgj_number"); - QFilter[] qFilters = new QFilter[]{new QFilter("billno", QCP.equals, zcgj_number)}; + 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, "采购申请单:" + zcgj_number + "的审批日期不能晚于业务日期!"); + this.addFatalErrorMessage(extendedDataEntity, "采购申请的审批日期不能晚于业务日期!"); continue; } DynamicObjectCollection zcgj_entryentityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息 @@ -71,39 +107,13 @@ public class MaterialInBillDateSubValidatorOp extends AbstractOperationServicePl 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 + "的开票日期!"); + this.addFatalErrorMessage(extendedDataEntity, "采购申请的审批日期不能晚于发票:" + 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 + "的开票日期!"); - } - } - } - } } } }