From b763cf9321b65fba133769e046f0eab450287a9b Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Wed, 1 Apr 2026 18:32:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E5=89=A5=E7=A6=BB=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biutag/supervision/flow/FlowService.java | 1 + .../flow/action/ApplyCompletionAction.java | 7 +++- .../action/ConfirmationCompletionAction.java | 23 +++++++++++- .../flow/action/FirstApproveReturnAction.java | 5 ++- .../flow/action/SecondApproveAction.java | 20 ++++++++-- .../action/SecondApproveReturnAction.java | 2 + .../supervision/pojo/entity/Negative.java | 37 +++++++++++++++++++ .../com/biutag/supervision/util/TimeUtil.java | 31 ++++++++++++++++ 8 files changed, 120 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/biutag/supervision/flow/FlowService.java b/src/main/java/com/biutag/supervision/flow/FlowService.java index efa9c64..78f81ce 100644 --- a/src/main/java/com/biutag/supervision/flow/FlowService.java +++ b/src/main/java/com/biutag/supervision/flow/FlowService.java @@ -74,6 +74,7 @@ public class FlowService { } catch (RuntimeException e) { history.setCrtName("模型超市"); } +// System.out.println(1/0); return negativeHistoryService.save(history); } diff --git a/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java b/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java index 33a7e2d..91412b6 100644 --- a/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java @@ -70,7 +70,12 @@ public class ApplyCompletionAction implements Action { .set(Negative::getCurrentProcessingObject, negative.getIsSecondHandle() ? "市局专班" : String.format("%s专班", negative.getHandleSecondDepartName())) .set(Negative::getHandleTime, LocalDateTime.now()) .set(Negative::getHandleTimeout, Objects.isNull(remainingDuration) || remainingDuration >= 0 ? 0 : -remainingDuration) - .set(Negative::getVerifyTime, LocalDateTime.now()); + .set(Negative::getVerifyTime, LocalDateTime.now()) + // 设置审批开始时间 + // 二级审批开始时间:isSecondHandle=false(3级提交本级办理)时设置, 如果不是二级办理,此时是提交到二级,需要记录二级审批开始时间 + .set(Negative::getSecondApproveStartTime, negative.getIsSecondHandle() ? null : LocalDateTime.now()) + // 市局审批开始时间:isSecondHandle=true(2级提交本级办理)时设置,如果是二级办理,此时是提交到市局,需要记录市局审批开始时间 + .set(Negative::getFirstApproveStartTime, negative.getIsSecondHandle() ? LocalDateTime.now() : null); negativeService.update(updateWrapper); } 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 ead16c8..df09bb5 100644 --- a/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java @@ -20,6 +20,8 @@ import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.util.List; +import com.biutag.supervision.util.TimeUtil; + /** * @author wxc * @date 2024/11/8 @@ -98,6 +100,8 @@ public class ConfirmationCompletionAction implements Action { } public void updateNegative(String negativeId, ConfirmationCompletionData completionData) { + Negative negative = negativeService.getById(negativeId); + LocalDateTime now = LocalDateTime.now(); LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .eq(Negative::getId, negativeId) .set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name()) @@ -107,7 +111,24 @@ public class ConfirmationCompletionAction implements Action { .set(StrUtil.isNotEmpty(completionData.getReportId()),Negative::getReportId,completionData.getReportId()) .set(StrUtil.isNotEmpty(completionData.getReportNumber()),Negative::getReportNumber,completionData.getReportNumber()) .set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) - .set(Negative::getUpdTime, LocalDateTime.now()); + .set(Negative::getUpdTime, now); + + // 计算并累加市局审批时长(仅三级审批流程) + if (FlowNodeEnum.FIRST_APPROVE.getKey().equals(negative.getFlowKey()) + && negative.getFirstApproveStartTime() != null) { + long currentDuration = TimeUtil.calculateWorkdayDuration(negative.getFirstApproveStartTime(), now); + long accumulatedDuration = (negative.getFirstApproveDuration() == null ? 0 : negative.getFirstApproveDuration()) + currentDuration; + updateWrapper.set(Negative::getFirstApproveDuration, accumulatedDuration); + } + + // 计算并累加二级审批时长 + if (FlowNodeEnum.SECOND_APPROVE.getKey().equals(negative.getFlowKey()) + && negative.getSecondApproveStartTime() != null) { + long currentDuration = TimeUtil.calculateWorkdayDuration(negative.getSecondApproveStartTime(), now); + long accumulatedDuration = (negative.getSecondApproveDuration() == null ? 0 : negative.getSecondApproveDuration()) + currentDuration; + updateWrapper.set(Negative::getSecondApproveDuration, accumulatedDuration); + } + negativeService.update(updateWrapper); } public void doneWork(Integer workId, String negativeId) { 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 80b39b1..b59b416 100644 --- a/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java @@ -44,11 +44,14 @@ public class FirstApproveReturnAction implements Action { public void updateNegative(String negativeId, String nextFlowKey) { Negative negative = negativeService.getById(negativeId); + LocalDateTime now = LocalDateTime.now(); negativeService.update(new LambdaUpdateWrapper() .set(Negative::getFlowKey, negative.getIsSecondHandle() ? FlowNodeEnum.VERIFY.getKey() : nextFlowKey) - .set(Negative::getUpdTime, LocalDateTime.now()) + .set(Negative::getUpdTime, now) // 当前处理对象 .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleSecondDepartName())) + // 退回整改后,重新设置二级审批开始时间,下次二级审批完成后继续累加 + .set(Negative::getSecondApproveStartTime, now) .eq(Negative::getId, negativeId)); } 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 000916a..0849d15 100644 --- a/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java @@ -20,6 +20,8 @@ import org.springframework.stereotype.Component; import java.time.LocalDateTime; +import com.biutag.supervision.util.TimeUtil; + /** * 二级机构审批通过 */ @@ -50,18 +52,30 @@ public class SecondApproveAction implements Action { } public void updateNegative(String negativeId, String nextFlowKey) { + Negative negative = negativeService.getById(negativeId); + LocalDateTime now = LocalDateTime.now(); LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .set(Negative::getFlowKey, nextFlowKey) .set(Negative::getUpdTime, LocalDateTime.now()) .eq(Negative::getId, negativeId); - Negative negative = negativeService.getById(negativeId); + + // 计算并累加二级审批时长 + if (negative.getSecondApproveStartTime() != null) { + long currentDuration = TimeUtil.calculateWorkdayDuration(negative.getSecondApproveStartTime(), now); + + long accumulatedDuration = (negative.getSecondApproveDuration() == null ? 0 : negative.getSecondApproveDuration()) + currentDuration; + updateWrapper.set(Negative::getSecondApproveDuration, accumulatedDuration); + } + if (ApprovalFlowEnum.SECOND_APPROVAL.getValue().equals(negative.getApprovalFlow())) { updateWrapper.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) .set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name()) - .set(Negative::getCompleteDate, LocalDateTime.now()); + .set(Negative::getCompleteDate, now); } else { updateWrapper.set(Negative::getFlowKey, nextFlowKey) - .set(Negative::getCurrentProcessingObject, "市局专班"); + .set(Negative::getCurrentProcessingObject, "市局专班") + // 二级审批通过后流转到市局审批,设置市局审批开始时间 + .set(Negative::getFirstApproveStartTime, LocalDateTime.now()); } negativeService.update(updateWrapper); } 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 d22f116..b543ea7 100644 --- a/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java @@ -51,6 +51,8 @@ public class SecondApproveReturnAction implements Action { .set(Negative::getProcessingStatus, ProcessingStatusEnum.processing.name()) // 当前处理对象 .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleThreeDepartName())) + // 退回整改后,重新设置二级审批开始时间,下次二级审批完成后继续累加 + .set(Negative::getSecondApproveStartTime, LocalDateTime.now()) .eq(Negative::getId, negativeId)); } diff --git a/src/main/java/com/biutag/supervision/pojo/entity/Negative.java b/src/main/java/com/biutag/supervision/pojo/entity/Negative.java index dc8114f..ce5a777 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/Negative.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/Negative.java @@ -370,4 +370,41 @@ public class Negative { @Schema(description = "下发单位名字") @TableField("issuingDepartName") private String issuingDepartName; + + // ==================== 审批时长统计字段 ==================== + + /** + * 二级审批开始时间(最近一次开始审批的时间) + * 触发条件:isSecondHandle=false 且 3级提交后 + */ + @Schema(description = "二级审批开始时间") + @TableField("second_approve_start_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime secondApproveStartTime; + + /** + * 二级审批累计时长(秒) + * 累加规则:每次二级审批完成(包括通过/退回)后累加 + * 不计入:本级办理不计入 + */ + @Schema(description = "二级审批累计时长(秒)") + @TableField("second_approve_duration") + private Long secondApproveDuration; + + /** + * 市局审批开始时间(最近一次开始审批的时间) + * 触发条件:approvalFlow="3" 且 2级提交后 + */ + @Schema(description = "市局审批开始时间") + @TableField("first_approve_start_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime firstApproveStartTime; + + /** + * 市局审批累计时长(秒) + * 累加规则:每次市局审批完成(包括通过/退回)后累加 + */ + @Schema(description = "市局审批累计时长(秒)") + @TableField("first_approve_duration") + private Long firstApproveDuration; } diff --git a/src/main/java/com/biutag/supervision/util/TimeUtil.java b/src/main/java/com/biutag/supervision/util/TimeUtil.java index 2a0019d..1adfeaa 100644 --- a/src/main/java/com/biutag/supervision/util/TimeUtil.java +++ b/src/main/java/com/biutag/supervision/util/TimeUtil.java @@ -109,4 +109,35 @@ public class TimeUtil { public static String formatDate(Date date) { return new SimpleDateFormat("yyyy年MM月dd日").format(date); } + + + /** + * 计算两个时间之间的工作日时长(秒) + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return 工作日时长(秒) + */ + public static long calculateWorkdayDuration(LocalDateTime beginTime, LocalDateTime endTime) { + if (Objects.isNull(beginTime) || Objects.isNull(endTime)) { + return 0; + } + HolidayService holidayService = SpringUtil.getBean(HolidayService.class); + long duration = 0; + for (LocalDateTime time = beginTime; time.isBefore(endTime.with(LocalTime.MAX)); time = time.plusDays(1)) { + if (holidayService.isHoliday(DatePattern.NORM_DATE_FORMATTER.format(time))) { + continue; + } + if (beginTime.toLocalDate().equals(endTime.toLocalDate())) { + duration += ChronoUnit.SECONDS.between(beginTime, endTime); + } else if (time.equals(beginTime)) { + duration += ChronoUnit.SECONDS.between(time, time.with(LocalTime.MAX)); + } else if (time.toLocalDate().equals(endTime.toLocalDate())) { + duration += ChronoUnit.SECONDS.between(time.with(LocalTime.MIN), endTime); + } else { + duration += SECONDS_OF_A_DAY; + } + } + return duration; + } + } From afc0140d258eafe12aad2faf93b3311f22a3bf7d Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Wed, 1 Apr 2026 18:33:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/biutag/supervision/flow/FlowService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/biutag/supervision/flow/FlowService.java b/src/main/java/com/biutag/supervision/flow/FlowService.java index 78f81ce..efa9c64 100644 --- a/src/main/java/com/biutag/supervision/flow/FlowService.java +++ b/src/main/java/com/biutag/supervision/flow/FlowService.java @@ -74,7 +74,6 @@ public class FlowService { } catch (RuntimeException e) { history.setCrtName("模型超市"); } -// System.out.println(1/0); return negativeHistoryService.save(history); }