Browse Source

fix:重新剥离出审批时间--lastTime方案

master
buaixuexideshitongxue 1 month ago
parent
commit
68b11b7193
  1. 3
      src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java
  2. 10
      src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java
  3. 10
      src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java
  4. 11
      src/main/java/com/biutag/supervision/flow/action/SecondApproveAction.java
  5. 7
      src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java
  6. 28
      src/main/java/com/biutag/supervision/pojo/entity/Negative.java
  7. 31
      src/main/java/com/biutag/supervision/util/TimeUtil.java

3
src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java

@ -70,7 +70,8 @@ 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())
.set(Negative::getLatestProcessTime, LocalDateTime.now());
negativeService.update(updateWrapper); negativeService.update(updateWrapper);
} }

10
src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java

@ -14,6 +14,7 @@ import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.pojo.entity.NegativeWork; import com.biutag.supervision.pojo.entity.NegativeWork;
import com.biutag.supervision.pojo.model.UserAuth; import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.*; import com.biutag.supervision.service.*;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -98,6 +99,12 @@ 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();
Long firstApproveTime = negative.getFirstApproveTime() == null ? 0L : negative.getFirstApproveTime();
if (negative.getLatestProcessTime() != null) {
firstApproveTime = firstApproveTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), 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 +114,8 @@ 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, LocalDateTime.now())
.set(Negative::getFirstApproveTime, firstApproveTime);
negativeService.update(updateWrapper); negativeService.update(updateWrapper);
} }
public void doneWork(Integer workId, String negativeId) { public void doneWork(Integer workId, String negativeId) {

10
src/main/java/com/biutag/supervision/flow/action/FirstApproveReturnAction.java

@ -14,6 +14,7 @@ import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.NegativeApproveService; import com.biutag.supervision.service.NegativeApproveService;
import com.biutag.supervision.service.NegativeService; import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.NegativeWorkService; import com.biutag.supervision.service.NegativeWorkService;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -44,12 +45,19 @@ 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();
Long firstApproveTime = negative.getFirstApproveTime() == null ? 0L : negative.getFirstApproveTime();
if (negative.getLatestProcessTime() != null) {
firstApproveTime = firstApproveTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), 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, LocalDateTime.now())
// 当前处理对象 // 当前处理对象
.set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleSecondDepartName())) .set(Negative::getCurrentProcessingObject, String.format("%s专班", negative.getHandleSecondDepartName()))
.eq(Negative::getId, negativeId)); .eq(Negative::getId, negativeId)
.set(Negative::getFirstApproveTime, firstApproveTime)
.set(Negative::getLatestProcessTime, now));
} }
public void addApprove(String negativeId, String comments, Integer workId) { public void addApprove(String negativeId, String comments, Integer workId) {

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

@ -15,6 +15,7 @@ import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.NegativeApproveService; import com.biutag.supervision.service.NegativeApproveService;
import com.biutag.supervision.service.NegativeService; import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.NegativeWorkService; import com.biutag.supervision.service.NegativeWorkService;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -50,17 +51,25 @@ 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();
Long secondApprovalTime = negative.getSecondApprovalTime() == null ? 0L : negative.getSecondApprovalTime();
if (negative.getLatestProcessTime() != null) {
secondApprovalTime = secondApprovalTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), 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())
.set(Negative::getSecondApprovalTime, secondApprovalTime)
.eq(Negative::getId, negativeId); .eq(Negative::getId, negativeId);
Negative negative = negativeService.getById(negativeId); // Negative negative = negativeService.getById(negativeId);
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, LocalDateTime.now());
} else { } else {
updateWrapper.set(Negative::getFlowKey, nextFlowKey) updateWrapper.set(Negative::getFlowKey, nextFlowKey)
.set(Negative::getLatestProcessTime, now)
.set(Negative::getCurrentProcessingObject, "市局专班"); .set(Negative::getCurrentProcessingObject, "市局专班");
} }
negativeService.update(updateWrapper); negativeService.update(updateWrapper);

7
src/main/java/com/biutag/supervision/flow/action/SecondApproveReturnAction.java

@ -15,6 +15,7 @@ import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.NegativeApproveService; import com.biutag.supervision.service.NegativeApproveService;
import com.biutag.supervision.service.NegativeService; import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.NegativeWorkService; import com.biutag.supervision.service.NegativeWorkService;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -45,12 +46,18 @@ public class SecondApproveReturnAction 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();
Long secondApprovalTime = negative.getSecondApprovalTime() == null ? 0L : negative.getSecondApprovalTime();
if (negative.getLatestProcessTime() != null) {
secondApprovalTime = secondApprovalTime + TimeUtil.calculateWorkdayDuration(negative.getLatestProcessTime(), now);
}
negativeService.update(new LambdaUpdateWrapper<Negative>() negativeService.update(new LambdaUpdateWrapper<Negative>()
.set(Negative::getFlowKey, nextFlowKey) .set(Negative::getFlowKey, nextFlowKey)
.set(Negative::getUpdTime, LocalDateTime.now()) .set(Negative::getUpdTime, LocalDateTime.now())
.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::getSecondApprovalTime, secondApprovalTime)
.eq(Negative::getId, negativeId)); .eq(Negative::getId, negativeId));
} }

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

@ -370,4 +370,32 @@ public class Negative {
@Schema(description = "下发单位名字") @Schema(description = "下发单位名字")
@TableField("issuingDepartName") @TableField("issuingDepartName")
private String issuingDepartName; private String issuingDepartName;
/**
* 2级审批开始时间
* 设置时机3级专班提交时ApplyCompletionAction或市局退回后任务回到2级时FirstApproveReturnAction
* 重置时机2级审批完成或退回时SecondApproveAction/SecondApproveReturnAction
* 用途计算2级审批累计时长
*/
@TableField("latest_process_time")
private LocalDateTime latestProcessTime;
/**
* 2级审批累计时长
* 计算公式每次2级审批完成时累加 duration += (当前时间 - secondApproveStartTime)
* 包含场景正常审批时长 + 退回后再审批时长
* 不包含本级办理isSecondHandle=true
*/
@TableField("second_approval_time")
private Long secondApprovalTime;
/**
* 市局审批累计时长
* 计算公式每次市局审批完成时累加 duration += (当前时间 - firstApproveStartTime)
* 包含场景正常审批时长 + 退回后再审批时长
* 不包含二级审批流程approvalFlow="2"
*/
@TableField("first_approve_time")
private Long firstApproveTime;
} }

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