|
|
@@ -61,6 +61,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
private static final String HK_DEF_MODE = "platform_config";
|
|
|
private static final int HK_DEF_DOWNLOAD_POLL_COUNT = 4;
|
|
|
private static final int HK_DEF_DOWNLOAD_POLL_SLEEP_MS = 1200;
|
|
|
+ private static final int HK_DEF_RECYCLE_LIMIT = 20;
|
|
|
private static final int RC_WCMSWJ_MAX_BYTES = 4000;
|
|
|
private static final String RC_WCMSWJ_TRUNCATE_SUFFIX = "...";
|
|
|
private static final DateTimeFormatter HK_AUTH_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
@@ -125,6 +126,14 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return ServC.SERV_notByA;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:手工触发请假临时权限删除,供请假结束后的权限回收联调用。
|
|
|
+ */
|
|
|
+ public String executeLeaveAuthDelete() {
|
|
|
+ super.wrJsonByResp(executeLeaveAuthDeleteResult());
|
|
|
+ return ServC.SERV_notByA;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-05-26:手工查询特殊人员权限下发结果,便于拿到配置后快速回查海康任务状态。
|
|
|
*/
|
|
|
@@ -133,6 +142,16 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return ServC.SERV_notByA;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:定时回收已结束请假的海康临时权限,避免请假结束后继续压住宿舍门权限。
|
|
|
+ */
|
|
|
+ public String recycleExpiredLeaveAuth() {
|
|
|
+ Map<String, Object> result = recycleExpiredLeaveAuthResult();
|
|
|
+ if (super.resp != null)
|
|
|
+ super.wrJsonByResp(result);
|
|
|
+ return ServC.SERV_notByA;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:海康下载结果回调入口,优先把任务号与下载摘要回写到请假记录,便于现场后补确认。
|
|
|
*/
|
|
|
@@ -275,6 +294,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("personInfo", makePersonInfoResp(personInfo));
|
|
|
|
|
|
String personId = rdStr(personInfo.get("personId"));
|
|
|
+ result.put("personId", personId);
|
|
|
if (StringUtils.isBlank(personId)) {
|
|
|
result.put("ok", false);
|
|
|
result.put("msg", "海康人员缺少 personId。");
|
|
|
@@ -434,6 +454,303 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:手工删除当前请假单在海康上的临时权限。
|
|
|
+ */
|
|
|
+ private Map<String, Object> executeLeaveAuthDeleteResult() {
|
|
|
+ long rcid = rdReqLongParm("rcid");
|
|
|
+ if (rcid <= 0) {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "缺少有效的 rcid 参数。");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean forceDelete = rdBoolLike(rdReqStrParm("force", "allowActiveDelete", "ignoreLeaveEnd"));
|
|
|
+ Map<String, Object> overrideParm = makeReqOverrideParm();
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
+ LeaveAuthSyncCtx ctx = selLeaveAuthSyncCtx(gdba, rcid);
|
|
|
+ if (ctx == null) {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "未找到对应请假记录。");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return executePlatformConfigDeleteResult(gdba, ctx, overrideParm, forceDelete, false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("HkLeaveAuthServ.executeLeaveAuthDelete() 异常,rcid={}", rcid, e);
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", e.getMessage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:批量回收已结束请假的临时权限,给定时器复用。
|
|
|
+ */
|
|
|
+ private Map<String, Object> recycleExpiredLeaveAuthResult() {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", true);
|
|
|
+ result.put("mode", "execute_platform_config_delete_recycle_batch");
|
|
|
+ int limit = rdReqIntParm("limit", "batchSize");
|
|
|
+ if (limit <= 0)
|
|
|
+ limit = HK_DEF_RECYCLE_LIMIT;
|
|
|
+ result.put("limit", limit);
|
|
|
+
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
+ List<LeaveAuthSyncCtx> ctxList = selExpiredPlatformConfigDeleteCtxList(gdba, limit);
|
|
|
+ result.put("candidateCount", ctxList.size());
|
|
|
+
|
|
|
+ List<Map<String, Object>> itemList = new ArrayList<>();
|
|
|
+ int confirmedCount = 0;
|
|
|
+ int skippedCount = 0;
|
|
|
+ int failedCount = 0;
|
|
|
+ for (LeaveAuthSyncCtx ctx : ctxList) {
|
|
|
+ Map<String, Object> item;
|
|
|
+ try {
|
|
|
+ item = executePlatformConfigDeleteResult(gdba, ctx, Map.of(), false, true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("HkLeaveAuthServ.recycleExpiredLeaveAuthResult() 删除异常,rcid={}", ctx.rcid, e);
|
|
|
+ item = new LinkedHashMap<>();
|
|
|
+ item.put("ok", false);
|
|
|
+ item.put("rcid", ctx.rcid);
|
|
|
+ item.put("xm", ctx.xm);
|
|
|
+ item.put("msg", makeExceptionMsg(e));
|
|
|
+ }
|
|
|
+ itemList.add(item);
|
|
|
+
|
|
|
+ if (rdBoolLike(item.get("deleteConfirmed"))) {
|
|
|
+ confirmedCount++;
|
|
|
+ } else if (StringUtils.isNotBlank(rdStr(item.get("deleteSkipReason")))) {
|
|
|
+ skippedCount++;
|
|
|
+ } else {
|
|
|
+ failedCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("confirmedCount", confirmedCount);
|
|
|
+ result.put("skippedCount", skippedCount);
|
|
|
+ result.put("failedCount", failedCount);
|
|
|
+ result.put("detailList", itemList);
|
|
|
+ result.put("msg", "请假到期回收执行完成。");
|
|
|
+ log4j.info("HkLeaveAuthServ.recycleExpiredLeaveAuthResult() 完成:limit={}, candidateCount={}, confirmedCount={}, skippedCount={}, failedCount={}",
|
|
|
+ limit, ctxList.size(), confirmedCount, skippedCount, failedCount);
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("HkLeaveAuthServ.recycleExpiredLeaveAuthResult() 异常", e);
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", e.getMessage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:平台权限配置模式的删除链路。
|
|
|
+ * 先查当前请假时段是否仍存在,再按同一批资源做定向 delete,最后用 search 反查确认已清空。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> executePlatformConfigDeleteResult(Db gdba,
|
|
|
+ LeaveAuthSyncCtx ctx,
|
|
|
+ Map<String, Object> overrideParm,
|
|
|
+ boolean forceDelete,
|
|
|
+ boolean autoTrigger) throws Exception {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("ok", true);
|
|
|
+ result.put("autoTrigger", autoTrigger);
|
|
|
+ result.put("forceDelete", forceDelete);
|
|
|
+ result.put("mode", autoTrigger ? "execute_platform_config_delete_recycle" : "execute_platform_config_delete");
|
|
|
+ result.put("deleteMode", autoTrigger ? "timerRecycle" : "manual");
|
|
|
+ result.put("rcid", ctx == null ? null : ctx.rcid);
|
|
|
+ result.put("leaveCtx", ctx == null ? null : makeLeaveCtxResp(ctx));
|
|
|
+ result.put("deleteTime", makeHkTime(new Timestamp(System.currentTimeMillis())));
|
|
|
+ result.put("executeApiPath", "/artemis/api/acps/v1/auth_config/add");
|
|
|
+ result.put("searchApiPath", "/artemis/api/acps/v1/auth_config/search");
|
|
|
+ result.put("deleteApiPath", "/artemis/api/acps/v1/auth_config/delete");
|
|
|
+ result.put("rateApiPath", "/artemis/api/acps/v1/auth_config/rate/search");
|
|
|
+ applyPersistedLeaveAuthSnapshot(ctx, result);
|
|
|
+
|
|
|
+ if (gdba == null || ctx == null) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "删除上下文无效。");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ Timestamp now = new Timestamp(System.currentTimeMillis());
|
|
|
+ boolean leaveExpired = ifLeaveEnded(ctx.jssj, now);
|
|
|
+ result.put("leaveExpired", leaveExpired);
|
|
|
+ if (!forceDelete && !leaveExpired) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("deleteSkipReason", "leaveNotEnded");
|
|
|
+ result.put("msg", "请假尚未结束,暂不执行海康临时权限删除。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rdBoolLike(rdLeaveAuthLogField(ctx, "deleteConfirmed"))) {
|
|
|
+ result.put("deleteConfirmed", true);
|
|
|
+ result.put("deleteConfirmSource", StringUtils.defaultIfBlank(
|
|
|
+ rdLeaveAuthLogField(ctx, "deleteConfirmSource"), "persisted"));
|
|
|
+ result.put("deleteSkipReason", "alreadyConfirmed");
|
|
|
+ result.put("msg", "该请假记录的海康临时权限已回收,无需重复删除。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(ctx.jobNo)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "学生缺少人员号(jobNo/RYH),无法匹配海康人员。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> hkConnParm = makeHkConnParm();
|
|
|
+ if (hkConnParm == null) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "缺少海康连接配置,请补齐 hk.host / hk.appKey / hk.appSecret。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String tagId = rdCfgOrOverride(overrideParm, "tagId", CFG_TAG_ID, "HK_LEAVE_AUTH_TAG_ID", HK_DEF_TAG_ID);
|
|
|
+ if (StringUtils.isNotBlank(tagId))
|
|
|
+ hkConnParm.put("tagId", tagId);
|
|
|
+ result.put("tagId", tagId);
|
|
|
+ result.put("tagIdSource", rdCfgSource(overrideParm, "tagId", CFG_TAG_ID, "HK_LEAVE_AUTH_TAG_ID", HK_DEF_TAG_ID));
|
|
|
+ result.put("hkConn", makeSafeHkConnResp(hkConnParm));
|
|
|
+
|
|
|
+ Map<String, Map<String, Object>> personInfoMap = HK_API_CLIENT.loadPersonInfoMapByJobNo(
|
|
|
+ hkConnParm, List.of(ctx.jobNo));
|
|
|
+ Map<String, Object> personInfo = personInfoMap.get(makeNormKey(ctx.jobNo));
|
|
|
+ result.put("personQueryJobNo", ctx.jobNo);
|
|
|
+ result.put("personInfoFound", personInfo != null);
|
|
|
+ if (personInfo == null) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康侧未找到对应人员。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.put("personInfo", makePersonInfoResp(personInfo));
|
|
|
+
|
|
|
+ String personId = rdStr(personInfo.get("personId"));
|
|
|
+ result.put("personId", personId);
|
|
|
+ if (StringUtils.isBlank(personId)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康人员缺少 personId。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> resourceInfoList = resolveDeleteResourceInfoList(gdba, hkConnParm, ctx, result);
|
|
|
+ result.put("resourceInfos", resourceInfoList);
|
|
|
+ result.put("resourceCount", resourceInfoList.size());
|
|
|
+ result.put("resourceKeyList", makeResourceKeyList(resourceInfoList));
|
|
|
+ if (resourceInfoList.isEmpty()) {
|
|
|
+ result.put("ok", false);
|
|
|
+ if (StringUtils.isBlank(rdStr(result.get("msg"))))
|
|
|
+ result.put("msg", "未能确定本次请假的海康资源集合,无法安全删除。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> deleteSearchReq = makeAuthConfigSearchReq(personId, resourceInfoList);
|
|
|
+ result.put("authConfigDeleteSearchReq", deleteSearchReq);
|
|
|
+ Map<String, Object> deleteSearchBeforeResp = HK_API_CLIENT.searchAuthConfig(hkConnParm, deleteSearchReq);
|
|
|
+ result.put("authConfigDeleteSearchBeforeResp", deleteSearchBeforeResp);
|
|
|
+ if (!isHkRespAccepted(deleteSearchBeforeResp)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康平台未能返回当前权限配置查询结果。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> matchedBeforeRowList = extAuthConfigMatchedRowList(
|
|
|
+ deleteSearchBeforeResp, ctx.kssj, ctx.jssj, resourceInfoList, personId);
|
|
|
+ List<Map<String, Object>> foreignBeforeRowList = extAuthConfigForeignRowList(
|
|
|
+ deleteSearchBeforeResp, ctx.kssj, ctx.jssj, resourceInfoList, personId);
|
|
|
+ result.put("deleteSearchTotalBefore", rdAuthConfigTotalCount(deleteSearchBeforeResp));
|
|
|
+ result.put("deleteSearchMatchedBefore", matchedBeforeRowList.size());
|
|
|
+ result.put("deleteSearchForeignBefore", foreignBeforeRowList.size());
|
|
|
+ result.put("deleteSearchMatchedBeforeSample", makeAuthConfigBriefList(matchedBeforeRowList, 12));
|
|
|
+ result.put("deleteSearchForeignBeforeSample", makeAuthConfigBriefList(foreignBeforeRowList, 12));
|
|
|
+
|
|
|
+ if (matchedBeforeRowList.isEmpty()) {
|
|
|
+ result.put("deleteConfirmed", true);
|
|
|
+ result.put("deleteConfirmSource", "authConfigSearchCurrentWindowAbsent");
|
|
|
+ result.put("deleteTaskAccepted", false);
|
|
|
+ result.put("deleteSkipReason", "searchAlreadyEmpty");
|
|
|
+ result.put("msg", "海康侧当前请假时段权限已不存在,无需再次删除。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!foreignBeforeRowList.isEmpty()) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("deleteConfirmed", false);
|
|
|
+ result.put("deleteSkipReason", "searchContainsOtherTimeWindows");
|
|
|
+ result.put("msg", "同一批门禁资源上仍存在其他时间窗权限,delete 接口不带时间条件,已停止自动删除。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> deleteReq = makeAuthConfigDeleteReq(personId, resourceInfoList);
|
|
|
+ result.put("authConfigDeleteReq", deleteReq);
|
|
|
+ Map<String, Object> deleteResp = HK_API_CLIENT.deleteAuthConfig(hkConnParm, deleteReq);
|
|
|
+ result.put("authConfigDeleteResp", deleteResp);
|
|
|
+ result.put("deleteTaskAccepted", isHkRespAccepted(deleteResp));
|
|
|
+ if (!isHkRespAccepted(deleteResp)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康平台未受理权限删除请求。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String deleteTaskId = rdTaskId(deleteResp);
|
|
|
+ result.put("deleteTaskId", deleteTaskId);
|
|
|
+ if (StringUtils.isNotBlank(deleteTaskId)) {
|
|
|
+ Map<String, Object> deleteRateReq = Map.of("taskId", deleteTaskId);
|
|
|
+ result.put("authConfigDeleteRateReq", deleteRateReq);
|
|
|
+ try {
|
|
|
+ result.put("authConfigDeleteRateResp", HK_API_CLIENT.searchAuthConfigRate(hkConnParm, deleteRateReq));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authConfigDeleteRateError", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> deleteSearchAfterResp = queryAuthConfigDeleteClearedWithRetry(
|
|
|
+ hkConnParm, deleteSearchReq, ctx.kssj, ctx.jssj, resourceInfoList, personId);
|
|
|
+ result.put("authConfigDeleteSearchAfterResp", deleteSearchAfterResp);
|
|
|
+ if (!isHkRespAccepted(deleteSearchAfterResp)) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康已受理权限删除,但删除后的查询结果获取失败。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> matchedAfterRowList = extAuthConfigMatchedRowList(
|
|
|
+ deleteSearchAfterResp, ctx.kssj, ctx.jssj, resourceInfoList, personId);
|
|
|
+ List<Map<String, Object>> foreignAfterRowList = extAuthConfigForeignRowList(
|
|
|
+ deleteSearchAfterResp, ctx.kssj, ctx.jssj, resourceInfoList, personId);
|
|
|
+ result.put("deleteSearchTotalAfter", rdAuthConfigTotalCount(deleteSearchAfterResp));
|
|
|
+ result.put("deleteSearchMatchedAfter", matchedAfterRowList.size());
|
|
|
+ result.put("deleteSearchForeignAfter", foreignAfterRowList.size());
|
|
|
+ result.put("deleteSearchMatchedAfterSample", makeAuthConfigBriefList(matchedAfterRowList, 12));
|
|
|
+ result.put("deleteSearchForeignAfterSample", makeAuthConfigBriefList(foreignAfterRowList, 12));
|
|
|
+
|
|
|
+ boolean deleteConfirmed = matchedAfterRowList.isEmpty();
|
|
|
+ result.put("deleteConfirmed", deleteConfirmed);
|
|
|
+ result.put("deleteConfirmSource", deleteConfirmed ? "authConfigSearchCurrentWindowCleared" : null);
|
|
|
+ if (!deleteConfirmed) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "海康已受理权限删除,但 auth_config/search 仍能查到当前请假时段权限。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("msg", "海康当前请假时段权限已完成回收。");
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-05-26:单独开放结果查询口,避免每次都必须先真实下发才能查看海康侧异步结果。
|
|
|
*/
|
|
|
@@ -576,6 +893,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("resourceUnmappedList", resourceBundle.unmappedSourceList);
|
|
|
result.put("resourceInfos", resourceInfoList);
|
|
|
result.put("resourceCount", resourceInfoList.size());
|
|
|
+ result.put("resourceKeyList", makeResourceKeyList(resourceInfoList));
|
|
|
result.put("resourceSourceCount", resourceBundle.resourceSourceList.size());
|
|
|
result.put("resourceMappedCount", resourceInfoList.size());
|
|
|
result.put("hkAcsDeviceCount", resourceBundle.hkAcsDeviceCount);
|
|
|
@@ -1100,6 +1418,20 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return req;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:按平台权限配置模式删除当前人员在指定设备通道上的临时权限。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> makeAuthConfigDeleteReq(String personId,
|
|
|
+ List<Map<String, Object>> resourceInfoList) {
|
|
|
+ Map<String, Object> req = new LinkedHashMap<>();
|
|
|
+ Map<String, Object> personData = new LinkedHashMap<>();
|
|
|
+ personData.put("indexCodes", List.of(personId));
|
|
|
+ personData.put("personDataType", "person");
|
|
|
+ req.put("personDatas", List.of(personData));
|
|
|
+ req.put("resourceInfos", makeAuthConfigResourceInfoList(resourceInfoList));
|
|
|
+ return req;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:平台配置完成后,按人员和设备通道做一次定向重下发,更贴近“请假单即时生效”场景。
|
|
|
*/
|
|
|
@@ -1231,6 +1563,39 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return lastResp;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:delete 接口不返回是否已清空,需要继续轮询 auth_config/search,直到当前请假窗消失。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> queryAuthConfigDeleteClearedWithRetry(Map<String, Object> hkConnParm,
|
|
|
+ Map<String, Object> searchReq,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList,
|
|
|
+ String personId) throws Exception {
|
|
|
+ Map<String, Object> lastResp = null;
|
|
|
+ int pollCount = Math.max(1, rdIntCfg("hk.leaveAuth.platform.searchPollCount",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_SEARCH_POLL_COUNT", HK_DEF_DOWNLOAD_POLL_COUNT));
|
|
|
+ int sleepMs = Math.max(0, rdIntCfg("hk.leaveAuth.platform.searchPollSleepMs",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_SEARCH_POLL_SLEEP_MS", HK_DEF_DOWNLOAD_POLL_SLEEP_MS));
|
|
|
+
|
|
|
+ for (int i = 0; i < pollCount; i++) {
|
|
|
+ if (i > 0 && sleepMs > 0) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(sleepMs);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lastResp = HK_API_CLIENT.searchAuthConfig(hkConnParm, searchReq);
|
|
|
+ if (!isHkRespAccepted(lastResp))
|
|
|
+ continue;
|
|
|
+ if (extAuthConfigMatchedRowList(lastResp, leaveBeg, leaveEnd, resourceInfoList, personId).isEmpty())
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return lastResp;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-05-28:平台权限配置和快捷下载复用同一批资源,但不强制带 channelIndexCodes。
|
|
|
*/
|
|
|
@@ -1525,12 +1890,28 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
putLeaveAuthPersistField(fieldMap, "mode", rdStr(result.get("mode")));
|
|
|
putLeaveAuthPersistField(fieldMap, "ok", rdStr(result.get("ok")));
|
|
|
putLeaveAuthPersistField(fieldMap, "msg", rdStr(result.get("msg")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "personId", rdStr(result.get("personId")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "resourceKeys", makeResourceKeyText(castMapList(result.get("resourceInfos"))));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "resourceCount", rdStr(result.get("resourceCount")));
|
|
|
putLeaveAuthPersistField(fieldMap, "platformConfigConfirmed", rdStr(result.get("platformConfigConfirmed")));
|
|
|
putLeaveAuthPersistField(fieldMap, "platformConfirmSource", rdStr(result.get("platformConfirmSource")));
|
|
|
putLeaveAuthPersistField(fieldMap, "configSearchMatched", rdStr(result.get("configSearchMatched")));
|
|
|
putLeaveAuthPersistField(fieldMap, "expectedConfigCount", rdStr(result.get("expectedConfigCount")));
|
|
|
putLeaveAuthPersistField(fieldMap, "matchedConfigCount", rdStr(result.get("matchedConfigCount")));
|
|
|
putLeaveAuthPersistField(fieldMap, "configTaskId", rdStr(result.get("configTaskId")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteTime", rdStr(result.get("deleteTime")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteMode", rdStr(result.get("deleteMode")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteConfirmed", rdStr(result.get("deleteConfirmed")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteConfirmSource", rdStr(result.get("deleteConfirmSource")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteTaskAccepted", rdStr(result.get("deleteTaskAccepted")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteTaskId", rdStr(result.get("deleteTaskId")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSkipReason", rdStr(result.get("deleteSkipReason")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchTotalBefore", rdStr(result.get("deleteSearchTotalBefore")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchMatchedBefore", rdStr(result.get("deleteSearchMatchedBefore")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchForeignBefore", rdStr(result.get("deleteSearchForeignBefore")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchTotalAfter", rdStr(result.get("deleteSearchTotalAfter")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchMatchedAfter", rdStr(result.get("deleteSearchMatchedAfter")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "deleteSearchForeignAfter", rdStr(result.get("deleteSearchForeignAfter")));
|
|
|
putLeaveAuthPersistField(fieldMap, "downloadTaskId", rdStr(result.get("downloadTaskId")));
|
|
|
putLeaveAuthPersistField(fieldMap, "downloadTaskSource", rdStr(result.get("downloadTaskSource")));
|
|
|
putLeaveAuthPersistField(fieldMap, "callbackConfigured", rdStr(result.get("callbackConfigured")));
|
|
|
@@ -1560,6 +1941,10 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
putLeaveAuthPersistField(fieldMap, "callbackPersonDownloadResult", rdStr(result.get("callbackPersonDownloadResult")));
|
|
|
putLeaveAuthPersistField(fieldMap, "authSyncResp", makeRespBrief(result.get("authSyncResp")));
|
|
|
putLeaveAuthPersistField(fieldMap, "authConfigSearchResp", makeRespBrief(result.get("authConfigSearchResp")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "authConfigDeleteResp", makeRespBrief(result.get("authConfigDeleteResp")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "authConfigDeleteRateResp", makeRespBrief(result.get("authConfigDeleteRateResp")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "authConfigDeleteSearchBeforeResp", makeRespBrief(result.get("authConfigDeleteSearchBeforeResp")));
|
|
|
+ putLeaveAuthPersistField(fieldMap, "authConfigDeleteSearchAfterResp", makeRespBrief(result.get("authConfigDeleteSearchAfterResp")));
|
|
|
putLeaveAuthPersistField(fieldMap, "authDownloadResultQueryResp", makeRespBrief(result.get("authDownloadResultQueryResp")));
|
|
|
putLeaveAuthPersistField(fieldMap, "authDownloadResetResp", makeRespBrief(result.get("authDownloadResetResp")));
|
|
|
putLeaveAuthPersistField(fieldMap, "downloadRecordChannelResp", makeRespBrief(result.get("downloadRecordChannelResp")));
|
|
|
@@ -1722,11 +2107,27 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
private static void applyPersistedLeaveAuthSnapshot(LeaveAuthSyncCtx ctx, Map<String, Object> result) {
|
|
|
if (ctx == null || result == null)
|
|
|
return;
|
|
|
+ putPersistedField(result, "personId", rdLeaveAuthLogField(ctx, "personId"));
|
|
|
+ putPersistedField(result, "resourceKeys", rdLeaveAuthLogField(ctx, "resourceKeys"));
|
|
|
+ putPersistedField(result, "resourceCount", rdLeaveAuthLogField(ctx, "resourceCount"));
|
|
|
putPersistedField(result, "platformConfigConfirmed", rdLeaveAuthLogField(ctx, "platformConfigConfirmed"));
|
|
|
putPersistedField(result, "platformConfirmSource", rdLeaveAuthLogField(ctx, "platformConfirmSource"));
|
|
|
putPersistedField(result, "configSearchMatched", rdLeaveAuthLogField(ctx, "configSearchMatched"));
|
|
|
putPersistedField(result, "expectedConfigCount", rdLeaveAuthLogField(ctx, "expectedConfigCount"));
|
|
|
putPersistedField(result, "matchedConfigCount", rdLeaveAuthLogField(ctx, "matchedConfigCount"));
|
|
|
+ putPersistedField(result, "deleteTime", rdLeaveAuthLogField(ctx, "deleteTime"));
|
|
|
+ putPersistedField(result, "deleteMode", rdLeaveAuthLogField(ctx, "deleteMode"));
|
|
|
+ putPersistedField(result, "deleteConfirmed", rdLeaveAuthLogField(ctx, "deleteConfirmed"));
|
|
|
+ putPersistedField(result, "deleteConfirmSource", rdLeaveAuthLogField(ctx, "deleteConfirmSource"));
|
|
|
+ putPersistedField(result, "deleteTaskAccepted", rdLeaveAuthLogField(ctx, "deleteTaskAccepted"));
|
|
|
+ putPersistedField(result, "deleteTaskId", rdLeaveAuthLogField(ctx, "deleteTaskId"));
|
|
|
+ putPersistedField(result, "deleteSkipReason", rdLeaveAuthLogField(ctx, "deleteSkipReason"));
|
|
|
+ putPersistedField(result, "deleteSearchTotalBefore", rdLeaveAuthLogField(ctx, "deleteSearchTotalBefore"));
|
|
|
+ putPersistedField(result, "deleteSearchMatchedBefore", rdLeaveAuthLogField(ctx, "deleteSearchMatchedBefore"));
|
|
|
+ putPersistedField(result, "deleteSearchForeignBefore", rdLeaveAuthLogField(ctx, "deleteSearchForeignBefore"));
|
|
|
+ putPersistedField(result, "deleteSearchTotalAfter", rdLeaveAuthLogField(ctx, "deleteSearchTotalAfter"));
|
|
|
+ putPersistedField(result, "deleteSearchMatchedAfter", rdLeaveAuthLogField(ctx, "deleteSearchMatchedAfter"));
|
|
|
+ putPersistedField(result, "deleteSearchForeignAfter", rdLeaveAuthLogField(ctx, "deleteSearchForeignAfter"));
|
|
|
putPersistedField(result, "callbackConfigured", rdLeaveAuthLogField(ctx, "callbackConfigured"));
|
|
|
putPersistedField(result, "downloadResetAccepted", rdLeaveAuthLogField(ctx, "downloadResetAccepted"));
|
|
|
putPersistedField(result, "downloadTaskAccepted", rdLeaveAuthLogField(ctx, "downloadTaskAccepted"));
|
|
|
@@ -1748,6 +2149,108 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
putPersistedField(result, "callbackPersonDownloadResult", rdLeaveAuthLogField(ctx, "callbackPersonDownloadResult"));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:删除链路优先复用新增时已落库的资源键,避免因为门禁映射变化误删其他资源。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> resolveDeleteResourceInfoList(Db gdba,
|
|
|
+ Map<String, Object> hkConnParm,
|
|
|
+ LeaveAuthSyncCtx ctx,
|
|
|
+ Map<String, Object> result) throws Exception {
|
|
|
+ List<Map<String, Object>> persistedResourceInfoList = rdPersistedResourceInfoList(ctx);
|
|
|
+ if (!persistedResourceInfoList.isEmpty()) {
|
|
|
+ result.put("deleteResourceSource", "persistedResourceKeys");
|
|
|
+ return persistedResourceInfoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (gdba == null || hkConnParm == null) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "缺少删除资源解析上下文。");
|
|
|
+ return List.of();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> resourceSourceList = selAllActiveMjdList(gdba);
|
|
|
+ LeaveAuthResourceBundle resourceBundle = buildLeaveAuthResourceBundle(hkConnParm, resourceSourceList);
|
|
|
+ result.put("deleteResourceSource", "currentActiveMjdFallback");
|
|
|
+ result.put("resourceSourceList", resourceBundle.resourceSourceList);
|
|
|
+ result.put("resourceUnmappedList", resourceBundle.unmappedSourceList);
|
|
|
+ result.put("resourceSourceCount", resourceBundle.resourceSourceList.size());
|
|
|
+ result.put("resourceMappedCount", resourceBundle.resourceInfoList.size());
|
|
|
+ result.put("hkAcsDeviceCount", resourceBundle.hkAcsDeviceCount);
|
|
|
+ result.put("resourceMapMode", "acsDeviceSearchByNameAndChannel");
|
|
|
+ if (!resourceBundle.unmappedSourceList.isEmpty()) {
|
|
|
+ result.put("ok", false);
|
|
|
+ result.put("msg", "历史请假记录未保留 resourceKeys,且当前门禁点映射不完整,无法安全执行 delete。");
|
|
|
+ return List.of();
|
|
|
+ }
|
|
|
+ return resourceBundle.resourceInfoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:从 RC.wcmswj 中恢复新增时真正下发过的资源键列表。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> rdPersistedResourceInfoList(LeaveAuthSyncCtx ctx) {
|
|
|
+ String resourceKeyText = rdLeaveAuthLogField(ctx, "resourceKeys");
|
|
|
+ if (StringUtils.isBlank(resourceKeyText))
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ LinkedHashSet<String> resourceKeySet = new LinkedHashSet<>();
|
|
|
+ for (String part : StringUtils.split(resourceKeyText, '|')) {
|
|
|
+ String key = StringUtils.trimToNull(part);
|
|
|
+ if (key != null)
|
|
|
+ resourceKeySet.add(key);
|
|
|
+ }
|
|
|
+ if (resourceKeySet.isEmpty())
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ List<Map<String, Object>> resourceInfoList = new ArrayList<>();
|
|
|
+ for (String resourceKey : resourceKeySet) {
|
|
|
+ Map<String, Object> resourceInfo = makeResourceInfoByKey(resourceKey);
|
|
|
+ if (resourceInfo != null)
|
|
|
+ resourceInfoList.add(resourceInfo);
|
|
|
+ }
|
|
|
+ return resourceInfoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:把持久化的 `设备#通道` 恢复成 auth_config 所需的 resourceInfo。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> makeResourceInfoByKey(String resourceKey) {
|
|
|
+ String key = StringUtils.trimToNull(resourceKey);
|
|
|
+ if (key == null)
|
|
|
+ return null;
|
|
|
+ int idx = key.lastIndexOf('#');
|
|
|
+ if (idx <= 0 || idx >= key.length() - 1)
|
|
|
+ return null;
|
|
|
+ String resourceIndexCode = StringUtils.trimToNull(key.substring(0, idx));
|
|
|
+ int channelNo = rdInt(key.substring(idx + 1));
|
|
|
+ if (StringUtils.isBlank(resourceIndexCode))
|
|
|
+ return null;
|
|
|
+ return makeResourceInfo(resourceIndexCode, channelNo > 0 ? channelNo : 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:把本次资源集合压成可持久化的一行文本,供后续 delete 精确复用。
|
|
|
+ */
|
|
|
+ private static String makeResourceKeyText(List<Map<String, Object>> resourceInfoList) {
|
|
|
+ List<String> resourceKeyList = makeResourceKeyList(resourceInfoList);
|
|
|
+ return resourceKeyList.isEmpty() ? null : String.join("|", resourceKeyList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:为结果页和持久化生成稳定的资源键列表。
|
|
|
+ */
|
|
|
+ private static List<String> makeResourceKeyList(List<Map<String, Object>> resourceInfoList) {
|
|
|
+ LinkedHashSet<String> resourceKeySet = new LinkedHashSet<>();
|
|
|
+ if (resourceInfoList != null) {
|
|
|
+ for (Map<String, Object> item : resourceInfoList) {
|
|
|
+ String resourceKey = makeResourceKey(item);
|
|
|
+ if (StringUtils.isNotBlank(resourceKey))
|
|
|
+ resourceKeySet.add(resourceKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>(resourceKeySet);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:海康下载回调在应答后落库,至少把任务号与最近一次设备结果写回到请假单。
|
|
|
*/
|
|
|
@@ -2005,6 +2508,47 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return ctxList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:仅挑选“已走过平台配置模式且尚未确认删除”的过期请假单,给定时回收使用。
|
|
|
+ */
|
|
|
+ private static List<LeaveAuthSyncCtx> selExpiredPlatformConfigDeleteCtxList(Db gdba, int limit) throws Exception {
|
|
|
+ if (gdba == null)
|
|
|
+ return List.of();
|
|
|
+ String sql = "select * from ("
|
|
|
+ + " select rc.RCID rcid,rc.BJID bjid,rc.FZRYID ryid,rc.RCLBM rclbm,rc.KSSJ kssj,rc.JSSJ jssj,"
|
|
|
+ + " rc.MS ms,rc.MSWJ mswj,rc.WCMSWJ wcmswj,ry.XM xm,ry.RYH ryh"
|
|
|
+ + " from RC rc"
|
|
|
+ + " join RY ry on ry.RYID=rc.FZRYID"
|
|
|
+ + " where rc.JSSJ is not null"
|
|
|
+ + " and rc.JSSJ<=sysdate"
|
|
|
+ + " and rc.WCMSWJ like '%mode=execute_platform_config%'"
|
|
|
+ + " and nvl(rc.WCMSWJ,' ') not like '%deleteConfirmed=true%'"
|
|
|
+ + " order by rc.JSSJ asc,rc.RCID asc"
|
|
|
+ + " ) where rownum<=:limit";
|
|
|
+ SqlCmd sqlCmd = new SqlCmd(sql);
|
|
|
+ sqlCmd.wrIntParm("limit", Math.max(1, limit));
|
|
|
+ List<Map<String, Object>> rowList = gdba.doSelMapListByC(sqlCmd);
|
|
|
+ if (rowList == null || rowList.isEmpty())
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ List<LeaveAuthSyncCtx> ctxList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ ctxList.add(new LeaveAuthSyncCtx(
|
|
|
+ rdLong(row.get("rcid")),
|
|
|
+ rdLong(row.get("bjid")),
|
|
|
+ rdLong(row.get("ryid")),
|
|
|
+ rdInt(row.get("rclbm")),
|
|
|
+ (Timestamp) row.get("kssj"),
|
|
|
+ (Timestamp) row.get("jssj"),
|
|
|
+ rdStr(row.get("xm")),
|
|
|
+ rdStr(row.get("ryh")),
|
|
|
+ rdStr(row.get("ms")),
|
|
|
+ rdStr(row.get("mswj")),
|
|
|
+ rdStr(row.get("wcmswj"))));
|
|
|
+ }
|
|
|
+ return ctxList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-05-28:平台配置模式结果回查。
|
|
|
*/
|
|
|
@@ -2039,6 +2583,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (personInfo != null) {
|
|
|
result.put("personInfo", makePersonInfoResp(personInfo));
|
|
|
personId = rdStr(personInfo.get("personId"));
|
|
|
+ result.put("personId", personId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2049,6 +2594,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("resourceUnmappedList", resourceBundle.unmappedSourceList);
|
|
|
result.put("resourceInfos", resourceInfoList);
|
|
|
result.put("resourceCount", resourceInfoList.size());
|
|
|
+ result.put("resourceKeyList", makeResourceKeyList(resourceInfoList));
|
|
|
result.put("resourceSourceCount", resourceBundle.resourceSourceList.size());
|
|
|
result.put("resourceMappedCount", resourceInfoList.size());
|
|
|
result.put("hkAcsDeviceCount", resourceBundle.hkAcsDeviceCount);
|
|
|
@@ -2781,6 +3327,104 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return matchedCount;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-10:筛出当前请假时段真正命中的 person 级权限配置,供 delete 前后确认复用。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> extAuthConfigMatchedRowList(Object searchRespObj,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList,
|
|
|
+ String personId) {
|
|
|
+ return extAuthConfigRowList(searchRespObj, leaveBeg, leaveEnd, resourceInfoList, personId, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:筛出同一批资源上“不是本次请假时间窗”的 person 级权限配置,避免 delete 误删其他时段。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> extAuthConfigForeignRowList(Object searchRespObj,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList,
|
|
|
+ String personId) {
|
|
|
+ return extAuthConfigRowList(searchRespObj, leaveBeg, leaveEnd, resourceInfoList, personId, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:统一筛选 auth_config/search 返回行,按“当前资源集合 + personId + 是否命中当前请假窗”过滤。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> extAuthConfigRowList(Object searchRespObj,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList,
|
|
|
+ String personId,
|
|
|
+ boolean matchCurrentWindow) {
|
|
|
+ Map<String, Object> searchResp = castMap(searchRespObj);
|
|
|
+ Map<String, Object> dataMap = rdDataMap(searchResp);
|
|
|
+ if (dataMap == null)
|
|
|
+ return List.of();
|
|
|
+ Object listObj = dataMap.get("list");
|
|
|
+ if (!(listObj instanceof List<?> list) || list.isEmpty())
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ Set<String> resourceKeySet = makeResourceKeySet(resourceInfoList);
|
|
|
+ List<Map<String, Object>> rowList = new ArrayList<>();
|
|
|
+ for (Object item : list) {
|
|
|
+ Map<String, Object> row = castMap(item);
|
|
|
+ if (!isAuthConfigRowInScope(row, resourceKeySet, personId))
|
|
|
+ continue;
|
|
|
+ boolean currentWindow = sameAuthTime(rdStr(row.get("startTime")), leaveBeg)
|
|
|
+ && sameAuthTime(rdStr(row.get("endTime")), leaveEnd);
|
|
|
+ if (currentWindow == matchCurrentWindow)
|
|
|
+ rowList.add(row);
|
|
|
+ }
|
|
|
+ return rowList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:delete 口只允许处理当前人、当前资源集合下的 person 级权限配置。
|
|
|
+ */
|
|
|
+ private static boolean isAuthConfigRowInScope(Map<String, Object> row,
|
|
|
+ Set<String> resourceKeySet,
|
|
|
+ String personId) {
|
|
|
+ if (row == null)
|
|
|
+ return false;
|
|
|
+ if (resourceKeySet != null && !resourceKeySet.isEmpty()) {
|
|
|
+ String resourceKey = makeAuthItemResourceKey(row);
|
|
|
+ if (!resourceKeySet.contains(resourceKey))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String rowPersonDataType = rdStr(row.get("personDataType"));
|
|
|
+ if (StringUtils.isNotBlank(rowPersonDataType) && !"person".equalsIgnoreCase(rowPersonDataType))
|
|
|
+ return false;
|
|
|
+ String rowPersonDataId = rdStr(row.get("personDataId"));
|
|
|
+ if (StringUtils.isNotBlank(personId) && StringUtils.isNotBlank(rowPersonDataId)
|
|
|
+ && !StringUtils.equals(personId, rowPersonDataId))
|
|
|
+ return false;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-10:删除诊断只回显少量核心字段,避免结果页塞满整段 search 明细。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> makeAuthConfigBriefList(List<Map<String, Object>> rowList, int limit) {
|
|
|
+ List<Map<String, Object>> briefList = new ArrayList<>();
|
|
|
+ if (rowList == null || rowList.isEmpty() || limit <= 0)
|
|
|
+ return briefList;
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ Map<String, Object> brief = new LinkedHashMap<>();
|
|
|
+ brief.put("personDataId", rdStr(row.get("personDataId")));
|
|
|
+ brief.put("personDataType", rdStr(row.get("personDataType")));
|
|
|
+ brief.put("resourceIndexCode", rdStr(row.get("resourceIndexCode")));
|
|
|
+ brief.put("channelNo", rdStr(row.get("channelNo")));
|
|
|
+ brief.put("startTime", rdStr(row.get("startTime")));
|
|
|
+ brief.put("endTime", rdStr(row.get("endTime")));
|
|
|
+ briefList.add(brief);
|
|
|
+ if (briefList.size() >= limit)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return briefList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-04:从 authItem 列表中筛出当前请假窗口和当前资源集合真正命中的条目。
|
|
|
*/
|