|
|
@@ -78,6 +78,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
|
|
|
/**
|
|
|
* 2026-05-26:请假保存后执行入口,保持原来的挂点不变。
|
|
|
+ * 2026-06-12:创建时仅登记本地待同步状态,不再立即触发海康 add,下发交给临近开始补偿任务。
|
|
|
*/
|
|
|
static void syncLeaveAuthAfterCommit(RcPo rcPo) {
|
|
|
if (rcPo == null || rcPo.getRcid() <= 0)
|
|
|
@@ -86,9 +87,26 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return;
|
|
|
|
|
|
try {
|
|
|
- Map<String, Object> result = buildLeaveAuthSyncResult(rcPo.getRcid(), true, Map.of());
|
|
|
- if (!Boolean.TRUE.equals(result.get("ok")) || StringUtils.isNotBlank(rdStr(result.get("skipReason"))))
|
|
|
+ Map<String, Object> result = registerPendingLeaveAuthAfterCommit(rcPo.getRcid());
|
|
|
+ if (!Boolean.TRUE.equals(result.get("ok")) || StringUtils.isNotBlank(rdStr(result.get("skipReason")))) {
|
|
|
logSkip(rdStr(result.get("msg")), rcPo.getRcid(), null, null);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ Map<String, Object> leaveCtx = (Map<String, Object>) result.get("leaveCtx");
|
|
|
+ Map<String, Object> logRow = new LinkedHashMap<>();
|
|
|
+ logRow.put("mode", rdStr(result.get("mode")));
|
|
|
+ logRow.put("msg", rdStr(result.get("msg")));
|
|
|
+ logRow.put("rcid", rcPo.getRcid());
|
|
|
+ if (leaveCtx != null) {
|
|
|
+ logRow.put("ryid", leaveCtx.get("ryid"));
|
|
|
+ logRow.put("xm", leaveCtx.get("xm"));
|
|
|
+ logRow.put("leaveBeg", leaveCtx.get("leaveBeg"));
|
|
|
+ logRow.put("leaveEnd", leaveCtx.get("leaveEnd"));
|
|
|
+ }
|
|
|
+ logRow.put("syncStage", rdStr(result.get("syncStage")));
|
|
|
+ log4j.info("HkLeaveAuthServ.syncLeaveAuthAfterCommit() 已登记待同步:{}", logRow);
|
|
|
} catch (Exception e) {
|
|
|
log4j.error("HkLeaveAuthServ.syncLeaveAuthAfterCommit() 异常,rcid={}", rcPo.getRcid(), e);
|
|
|
persistUnexpectedSyncError(rcPo.getRcid(), e);
|
|
|
@@ -512,6 +530,48 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-12:请假创建后只登记本地待同步状态,真正的海康 add 交给临近开始补偿任务。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> registerPendingLeaveAuthAfterCommit(long rcid) throws Exception {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", true);
|
|
|
+ result.put("autoTrigger", true);
|
|
|
+ result.put("mode", "pendingRegister");
|
|
|
+ result.put("rcid", rcid);
|
|
|
+
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
+ LeaveAuthSyncCtx ctx = selLeaveAuthSyncCtx(gdba, rcid);
|
|
|
+ if (ctx == null) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "未找到对应请假记录。");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("leaveCtx", makeLeaveCtxResp(ctx));
|
|
|
+ applyPersistedLeaveAuthSnapshot(ctx, result);
|
|
|
+
|
|
|
+ Timestamp now = new Timestamp(System.currentTimeMillis());
|
|
|
+ result.put("syncTime", makeHkTime(now));
|
|
|
+ result.put("leaveExpired", ifLeaveEnded(ctx.jssj, now));
|
|
|
+ if (ifLeaveEnded(ctx.jssj, now)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("mode", "skipExpired");
|
|
|
+ result.put("skipReason", "请假时间段已结束,跳过海康自动开门。");
|
|
|
+ result.put("msg", "请假结束时间早于当前时间,不能再登记海康临时权限下发。");
|
|
|
+ markLeaveAuthStageExpired(result, now);
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("msg", "请假已登记,待临近开始时再同步海康临时权限。");
|
|
|
+ result.put("pendingAction", "registerOnly");
|
|
|
+ markLeaveAuthStagePending(result, ctx, "pending", now, false, 0);
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-10:批量回收已结束请假的临时权限,给定时器复用。
|
|
|
*/
|