|
|
|
|
@ -4,7 +4,9 @@ import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.biutag.supervision.constants.enums.FlowNodeEnum; |
|
|
|
|
import com.biutag.supervision.pojo.entity.SupDictData; |
|
|
|
|
import com.biutag.supervision.service.HolidayService; |
|
|
|
|
import com.biutag.supervision.service.SupDictDataService; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
@ -51,7 +53,46 @@ public class TimeUtil {
|
|
|
|
|
* @return true=可以更新,false=已锁定不可更新(>=86400秒) |
|
|
|
|
*/ |
|
|
|
|
public static boolean canUpdateApproveTime(Long currentDuration) { |
|
|
|
|
return currentDuration == null || currentDuration < APPROVAL_LOCK_THRESHOLD; |
|
|
|
|
return canUpdateApproveTime(currentDuration, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断审批时长是否可以更新 |
|
|
|
|
* @param currentDuration 当前审批时长(秒),null表示尚未开始计时 |
|
|
|
|
* @param dictValue 审批超时字典值,branch=分局审批,city=市局审批 |
|
|
|
|
* @return true=可以更新,false=已锁定不可更新 |
|
|
|
|
*/ |
|
|
|
|
public static boolean canUpdateApproveTime(Long currentDuration, String dictValue) { |
|
|
|
|
Long threshold = getApprovalLockThreshold(dictValue); |
|
|
|
|
return currentDuration == null || currentDuration < threshold; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 读取审批超时锁定阈值(秒) |
|
|
|
|
* @param dictValue 字典值,branch=分局审批,city=市局审批 |
|
|
|
|
* @return 阈值秒数,读取失败时按默认值返回 |
|
|
|
|
*/ |
|
|
|
|
public static Long getApprovalLockThreshold(String dictValue) { |
|
|
|
|
if (StrUtil.isBlank(dictValue)) { |
|
|
|
|
return APPROVAL_LOCK_THRESHOLD; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
SupDictData dictData = SpringUtil.getBean(SupDictDataService.class) |
|
|
|
|
.get("spscTime", dictValue); |
|
|
|
|
if (dictData != null && StrUtil.isNotBlank(dictData.getDictValue())) { |
|
|
|
|
long days = Long.parseLong(dictData.getDictValue()); |
|
|
|
|
return days * SECONDS_OF_A_DAY; |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 字典读取失败时使用默认值,不影响流程
|
|
|
|
|
} |
|
|
|
|
if ("city".equals(dictValue)) { |
|
|
|
|
return 3L * SECONDS_OF_A_DAY; |
|
|
|
|
} |
|
|
|
|
if ("branch".equals(dictValue)) { |
|
|
|
|
return 2L * SECONDS_OF_A_DAY; |
|
|
|
|
} |
|
|
|
|
return APPROVAL_LOCK_THRESHOLD; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -218,4 +259,33 @@ public class TimeUtil {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断指定审批时长是否超时(按审批层级阈值) |
|
|
|
|
* @param usedSeconds 已用审批时长(秒) |
|
|
|
|
* @param dictValue 审批超时字典值,branch=分局审批,city=市局审批 |
|
|
|
|
* @return 未超时/已超时 |
|
|
|
|
*/ |
|
|
|
|
public static String getTimeoutStatus(long usedSeconds, String dictValue) { |
|
|
|
|
return getTimeoutStatus(usedSeconds, dictValue, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断指定审批时长是否超时(按审批层级阈值) |
|
|
|
|
* @param usedSeconds 已用审批时长(秒) |
|
|
|
|
* @param dictValue 审批超时字典值,branch=分局审批,city=市局审批 |
|
|
|
|
* @param detail 是否展示超时明细 |
|
|
|
|
* @return 未超时,或 已超时/超时xx天xx时xx分 |
|
|
|
|
*/ |
|
|
|
|
public static String getTimeoutStatus(long usedSeconds, String dictValue, boolean detail) { |
|
|
|
|
Long threshold = getApprovalLockThreshold(dictValue); |
|
|
|
|
long diff = threshold - usedSeconds; |
|
|
|
|
if (diff >= 0) { |
|
|
|
|
return "未超时"; |
|
|
|
|
} |
|
|
|
|
if (detail) { |
|
|
|
|
return "已超时/超时" + formatDuration(-diff); |
|
|
|
|
} |
|
|
|
|
return "已超时"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|