From 0b8d01a17384153234564410ded3e1785c747a8e Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Wed, 15 Apr 2026 16:54:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=A1=E6=89=B9=E4=B8=8D=E7=B4=AF?= =?UTF-8?q?=E8=AE=A1=E8=AE=A1=E7=AE=97=EF=BC=8C=E5=AF=BC=E5=87=BA=E4=B9=9F?= =?UTF-8?q?=E6=B2=A1=E5=BF=85=E8=A6=81=E6=98=BE=E7=A4=BA=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E7=94=A8=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/ConfirmationCompletionAction.java | 23 ++++++++++++------- .../flow/action/FirstApproveReturnAction.java | 9 ++++---- .../flow/action/SecondApproveAction.java | 12 ++++++---- .../action/SecondApproveReturnAction.java | 9 ++++---- .../com/biutag/supervision/util/TimeUtil.java | 16 +++++++++++-- 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java b/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java index 0d33468..cbfc839 100644 --- a/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java @@ -101,13 +101,14 @@ public class ConfirmationCompletionAction implements Action { public void updateNegative(String negativeId, ConfirmationCompletionData completionData) { Negative negative = negativeService.getById(negativeId); LocalDateTime now = LocalDateTime.now(); - Long firstApproveTime = negative.getFirstApproveTime() == null ? 0L : negative.getFirstApproveTime(); - if (negative.getLatestProcessTime() != null) { - firstApproveTime = firstApproveTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); + Long firstApproveTime = negative.getFirstApproveTime(); + // 覆盖制:每次重新计算,超时锁定则不更新 + if (TimeUtil.canUpdateApproveTime(firstApproveTime) && negative.getLatestProcessTime() != null) { + firstApproveTime = TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); } - Long secondApprovalTime = negative.getSecondApprovalTime() == null ? 0L : negative.getSecondApprovalTime(); - if (negative.getLatestProcessTime() != null) { - secondApprovalTime = secondApprovalTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); + Long secondApprovalTime = negative.getSecondApprovalTime(); + if (TimeUtil.canUpdateApproveTime(secondApprovalTime) && negative.getLatestProcessTime() != null) { + secondApprovalTime = TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); } LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .eq(Negative::getId, negativeId) @@ -120,10 +121,16 @@ public class ConfirmationCompletionAction implements Action { .set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) .set(Negative::getUpdTime, LocalDateTime.now()); if ("2".equals(negative.getApprovalFlow())){ - updateWrapper.set(Negative::getSecondApprovalTime, secondApprovalTime); + // 超时锁定时,不更新审批时长字段 + if (TimeUtil.canUpdateApproveTime(secondApprovalTime)) { + updateWrapper.set(Negative::getSecondApprovalTime, secondApprovalTime); + } } if ("3".equals(negative.getApprovalFlow())){ - updateWrapper.set(Negative::getFirstApproveTime, firstApproveTime); + // 超时锁定时,不更新审批时长字段 + if (TimeUtil.canUpdateApproveTime(firstApproveTime)) { + updateWrapper.set(Negative::getFirstApproveTime, firstApproveTime); + } } negativeService.update(updateWrapper); } diff --git a/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java b/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java index 85d220b..ae54e5c 100644 --- a/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java @@ -46,9 +46,10 @@ public class FirstApproveReturnAction implements Action { public void updateNegative(String negativeId, String nextFlowKey) { Negative negative = negativeService.getById(negativeId); LocalDateTime now = LocalDateTime.now(); - Long firstApproveTime = negative.getFirstApproveTime() == null ? 0L : negative.getFirstApproveTime(); - if (negative.getLatestProcessTime() != null) { - firstApproveTime = firstApproveTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); + Long firstApproveTime = negative.getFirstApproveTime(); + // 覆盖制:每次重新计算,超时锁定则不更新 + if (TimeUtil.canUpdateApproveTime(firstApproveTime) && negative.getLatestProcessTime() != null) { + firstApproveTime = TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); } negativeService.update(new LambdaUpdateWrapper() .set(Negative::getFlowKey, negative.getIsSecondHandle() ? FlowNodeEnum.VERIFY.getKey() : nextFlowKey) @@ -56,7 +57,7 @@ public class FirstApproveReturnAction implements Action { // 当前处理对象 .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleSecondDepartName())) .eq(Negative::getId, negativeId) - .set(Negative::getFirstApproveTime, firstApproveTime) + .set(TimeUtil.canUpdateApproveTime(firstApproveTime), Negative::getFirstApproveTime, firstApproveTime) .set(Negative::getLatestProcessTime, now)); } diff --git a/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java b/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java index 64e8da7..3b80972 100644 --- a/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java @@ -53,15 +53,19 @@ public class SecondApproveAction implements Action { public void updateNegative(String negativeId, String nextFlowKey) { Negative negative = negativeService.getById(negativeId); LocalDateTime now = LocalDateTime.now(); - Long secondApprovalTime = negative.getSecondApprovalTime() == null ? 0L : negative.getSecondApprovalTime(); - if (negative.getLatestProcessTime() != null) { - secondApprovalTime = secondApprovalTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); + Long secondApprovalTime = negative.getSecondApprovalTime(); + // 覆盖制:每次重新计算,超时锁定则不更新 + if (TimeUtil.canUpdateApproveTime(secondApprovalTime) && negative.getLatestProcessTime() != null) { + secondApprovalTime = TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); } LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .set(Negative::getFlowKey, nextFlowKey) .set(Negative::getUpdTime, LocalDateTime.now()) - .set(Negative::getSecondApprovalTime, secondApprovalTime) .eq(Negative::getId, negativeId); + // 超时锁定时,不更新审批时长字段 + if (TimeUtil.canUpdateApproveTime(secondApprovalTime)) { + updateWrapper.set(Negative::getSecondApprovalTime, secondApprovalTime); + } // Negative negative = negativeService.getById(negativeId); if (ApprovalFlowEnum.SECOND_APPROVAL.getValue().equals(negative.getApprovalFlow())) { updateWrapper.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) diff --git a/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java b/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java index 5ac468d..68f2d15 100644 --- a/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java @@ -47,9 +47,10 @@ public class SecondApproveReturnAction implements Action { public void updateNegative(String negativeId, String nextFlowKey) { Negative negative = negativeService.getById(negativeId); LocalDateTime now = LocalDateTime.now(); - Long secondApprovalTime = negative.getSecondApprovalTime() == null ? 0L : negative.getSecondApprovalTime(); - if (negative.getLatestProcessTime() != null) { - secondApprovalTime = secondApprovalTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); + Long secondApprovalTime = negative.getSecondApprovalTime(); + // 覆盖制:每次重新计算,超时锁定则不更新 + if (TimeUtil.canUpdateApproveTime(secondApprovalTime) && negative.getLatestProcessTime() != null) { + secondApprovalTime = TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now); } negativeService.update(new LambdaUpdateWrapper() .set(Negative::getFlowKey, nextFlowKey) @@ -57,7 +58,7 @@ public class SecondApproveReturnAction implements Action { .set(Negative::getProcessingStatus, ProcessingStatusEnum.processing.name()) // 当前处理对象 .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleThreeDepartName())) - .set(Negative::getSecondApprovalTime, secondApprovalTime) + .set(TimeUtil.canUpdateApproveTime(secondApprovalTime), Negative::getSecondApprovalTime, secondApprovalTime) .eq(Negative::getId, negativeId)); } diff --git a/src/main/java/com/biutag/supervision/util/TimeUtil.java b/src/main/java/com/biutag/supervision/util/TimeUtil.java index 77145eb..fe91c2c 100644 --- a/src/main/java/com/biutag/supervision/util/TimeUtil.java +++ b/src/main/java/com/biutag/supervision/util/TimeUtil.java @@ -18,6 +18,18 @@ public class TimeUtil { // 一天86400秒 public static final Long SECONDS_OF_A_DAY = 86400L; + // 超时锁定阈值(秒),超过此值则不再更新审批时长 + public static final Long APPROVAL_LOCK_THRESHOLD = SECONDS_OF_A_DAY; + + /** + * 判断审批时长是否可以更新 + * @param currentDuration 当前审批时长(秒),null表示尚未开始计时 + * @return true=可以更新,false=已锁定不可更新(>=86400秒) + */ + public static boolean canUpdateApproveTime(Long currentDuration) { + return currentDuration == null || currentDuration < APPROVAL_LOCK_THRESHOLD; + } + /** * * @param beginTime @@ -176,9 +188,9 @@ public class TimeUtil { long limit = SECONDS_OF_A_DAY; // 86400秒 = 1天 long diff = limit - usedSeconds; // diff > 0 表示剩余时间,diff < 0 表示超出时间 if (diff >= 0) { - return "未超时/用时:" + formatDuration(usedSeconds); + return "未超时"; } else { - return "已超时/用时:" + formatDuration(usedSeconds); + return "已超时"; } }