From ad57e7f5015991ef7c68d849863d2a2be59421e9 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Fri, 10 Oct 2025 16:41:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=AE=E6=97=85=E6=8A=A5=E9=94=80=E5=8D=95?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=97=A5=E6=9C=9F=E5=92=8C=E8=A1=8C=E7=A8=8B?= =?UTF-8?q?=E6=9C=9F=E9=97=B4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...TripreimbursebillIsInvoiceDateCheckOp.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsInvoiceDateCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsInvoiceDateCheckOp.java index c04c97e..7b6fca5 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsInvoiceDateCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsInvoiceDateCheckOp.java @@ -76,15 +76,15 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ //发票明细 DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry"); DynamicObjectCollection writeoffapply = dataEntity.getDynamicObjectCollection("writeoffapply");//关联的出差申请 - Date earliestAuditDate = null; + LocalDate earliestAuditDate = null; for (DynamicObject dynamicObject : writeoffapply) { //er_tripreqbill long sourceapplybillid = dynamicObject.getLong("sourceapplybillid"); DynamicObject tripreqbill = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "er_tripreqbill"); boolean ischange = tripreqbill.getBoolean("ischange");//出差申请单发生过变更后,不进行校验 - Date auditDate = dynamicObject.getDate("zcgj_glsq_auditdate"); + LocalDate auditDate = dateToLocalDate(dynamicObject.getDate("zcgj_glsq_auditdate")); if (auditDate != null && !ischange) { - if (earliestAuditDate == null || auditDate.before(earliestAuditDate)) { + if (earliestAuditDate == null || auditDate.isBefore(earliestAuditDate)) { earliestAuditDate = auditDate; // 保留最小审批日期 } } @@ -95,15 +95,15 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ for (DynamicObject invoice : invoiceentry) { i++; String invoicetype = invoice.getString("invoicetype"); - Date carrierDate = invoice.getDate("carrierdate"); // 乘车日期 + LocalDate carrierDate = dateToLocalDate(invoice.getDate("carrierdate")); // 乘车日期 if(carrierDate != null){ // 校验1: 是否在行程时间范围内 boolean inTripRange = false; for (DynamicObject trip : tripentry) { - Date startDate = trip.getDate("startdate"); - Date endDate = trip.getDate("enddate"); + LocalDate startDate = dateToLocalDate(trip.getDate("startdate")); + LocalDate endDate = dateToLocalDate(trip.getDate("enddate")); if (carrierDate != null && startDate != null && endDate != null) { - if (!carrierDate.before(startDate) && !carrierDate.after(endDate)) { + if (!carrierDate.isBefore(startDate) && !carrierDate.isAfter(endDate)) { inTripRange = true; break; } @@ -117,7 +117,7 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ // 校验2: 必须在最早审批日期之后 if (earliestAuditDate != null && carrierDate != null && StringUtils.isEmpty(zcgjInvoiceremark)) { - if (carrierDate.compareTo(earliestAuditDate) != 0 && carrierDate.before(earliestAuditDate)) { + if (!carrierDate.isEqual(earliestAuditDate) && carrierDate.isBefore(earliestAuditDate)) { this.addFatalErrorMessage(extendedDataEntity, String.format("发票信息中的第%d行,乘车/机日期早于关联申请最早审批日期,请填写特殊说明!",i)); //throw new RuntimeException("乘车日期【" + carrierDate + "】早于出差申请最早审批日期【" + earliestAuditDate + "】!"); } @@ -136,9 +136,14 @@ public class TripreimbursebillIsInvoiceDateCheckOp extends AbstractOperationServ * @return java.time.LocalDate */ public static LocalDate dateToLocalDate(Date date) { - return date.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); + if(date!=null){ + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + } + else{ + return null; + } }