Browse Source

feat:剥离审批时间

master
buaixuexideshitongxue 1 month ago
parent
commit
b763cf9321
  1. 1
      src/main/java/com/biutag/supervision/flow/FlowService.java
  2. 7
      src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java
  3. 23
      src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java
  4. 5
      src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java
  5. 20
      src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java
  6. 2
      src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java
  7. 37
      src/main/java/com/biutag/supervision/pojo/entity/Negative.java
  8. 31
      src/main/java/com/biutag/supervision/util/TimeUtil.java

1
src/main/java/com/biutag/supervision/flow/FlowService.java

@ -74,6 +74,7 @@ public class FlowService {
} catch (RuntimeException e) { } catch (RuntimeException e) {
history.setCrtName("模型超市"); history.setCrtName("模型超市");
} }
// System.out.println(1/0);
return negativeHistoryService.save(history); return negativeHistoryService.save(history);
} }

7
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::getCurrentProcessingObject, negative.getIsSecondHandle() ? "市局专班" : String.format("%s专班", negative.getHandleSecondDepartName()))
.set(Negative::getHandleTime, LocalDateTime.now()) .set(Negative::getHandleTime, LocalDateTime.now())
.set(Negative::getHandleTimeout, Objects.isNull(remainingDuration) || remainingDuration >= 0 ? 0 : -remainingDuration) .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); negativeService.update(updateWrapper);
} }

23
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.time.LocalDateTime;
import java.util.List; import java.util.List;
import com.biutag.supervision.util.TimeUtil;
/** /**
* @author wxc * @author wxc
* @date 2024/11/8 * @date 2024/11/8
@ -98,6 +100,8 @@ public class ConfirmationCompletionAction implements Action {
} }
public void updateNegative(String negativeId, ConfirmationCompletionData completionData) { public void updateNegative(String negativeId, ConfirmationCompletionData completionData) {
Negative negative = negativeService.getById(negativeId);
LocalDateTime now = LocalDateTime.now();
LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>() LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>()
.eq(Negative::getId, negativeId) .eq(Negative::getId, negativeId)
.set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name()) .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.getReportId()),Negative::getReportId,completionData.getReportId())
.set(StrUtil.isNotEmpty(completionData.getReportNumber()),Negative::getReportNumber,completionData.getReportNumber()) .set(StrUtil.isNotEmpty(completionData.getReportNumber()),Negative::getReportNumber,completionData.getReportNumber())
.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) .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); negativeService.update(updateWrapper);
} }
public void doneWork(Integer workId, String negativeId) { public void doneWork(Integer workId, String negativeId) {

5
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) { public void updateNegative(String negativeId, String nextFlowKey) {
Negative negative = negativeService.getById(negativeId); Negative negative = negativeService.getById(negativeId);
LocalDateTime now = LocalDateTime.now();
negativeService.update(new LambdaUpdateWrapper<Negative>() negativeService.update(new LambdaUpdateWrapper<Negative>()
.set(Negative::getFlowKey, negative.getIsSecondHandle() ? FlowNodeEnum.VERIFY.getKey() : nextFlowKey) .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::getCurrentProcessingObject, String.format("%s专班", negative.getHandleSecondDepartName()))
// 退回整改后,重新设置二级审批开始时间,下次二级审批完成后继续累加
.set(Negative::getSecondApproveStartTime, now)
.eq(Negative::getId, negativeId)); .eq(Negative::getId, negativeId));
} }

20
src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java

@ -20,6 +20,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; 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) { public void updateNegative(String negativeId, String nextFlowKey) {
Negative negative = negativeService.getById(negativeId);
LocalDateTime now = LocalDateTime.now();
LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>() LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>()
.set(Negative::getFlowKey, nextFlowKey) .set(Negative::getFlowKey, nextFlowKey)
.set(Negative::getUpdTime, LocalDateTime.now()) .set(Negative::getUpdTime, LocalDateTime.now())
.eq(Negative::getId, negativeId); .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())) { if (ApprovalFlowEnum.SECOND_APPROVAL.getValue().equals(negative.getApprovalFlow())) {
updateWrapper.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey()) updateWrapper.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey())
.set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name()) .set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name())
.set(Negative::getCompleteDate, LocalDateTime.now()); .set(Negative::getCompleteDate, now);
} else { } else {
updateWrapper.set(Negative::getFlowKey, nextFlowKey) updateWrapper.set(Negative::getFlowKey, nextFlowKey)
.set(Negative::getCurrentProcessingObject, "市局专班"); .set(Negative::getCurrentProcessingObject, "市局专班")
// 二级审批通过后流转到市局审批,设置市局审批开始时间
.set(Negative::getFirstApproveStartTime, LocalDateTime.now());
} }
negativeService.update(updateWrapper); negativeService.update(updateWrapper);
} }

2
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::getProcessingStatus, ProcessingStatusEnum.processing.name())
// 当前处理对象 // 当前处理对象
.set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleThreeDepartName())) .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleThreeDepartName()))
// 退回整改后,重新设置二级审批开始时间,下次二级审批完成后继续累加
.set(Negative::getSecondApproveStartTime, LocalDateTime.now())
.eq(Negative::getId, negativeId)); .eq(Negative::getId, negativeId));
} }

37
src/main/java/com/biutag/supervision/pojo/entity/Negative.java

@ -370,4 +370,41 @@ public class Negative {
@Schema(description = "下发单位名字") @Schema(description = "下发单位名字")
@TableField("issuingDepartName") @TableField("issuingDepartName")
private String 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;
} }

31
src/main/java/com/biutag/supervision/util/TimeUtil.java

@ -109,4 +109,35 @@ public class TimeUtil {
public static String formatDate(Date date) { public static String formatDate(Date date) {
return new SimpleDateFormat("yyyy年MM月dd日").format(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;
}
} }

Loading…
Cancel
Save