|
|
@@ -31,7 +31,7 @@ import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 2026-05-26:班主任请假后的海康临时权限同步服务。
|
|
|
- * 2026-05-26:请假默认走“特殊人员权限直接下发 + 结果回查”口径,不再依赖 authItemNo。
|
|
|
+ * 2026-06-04:当前默认走“平台权限配置 + authItem 下载状态确认”口径,主链路不再依赖 person/reset。
|
|
|
*/
|
|
|
public class HkLeaveAuthServ extends Serv {
|
|
|
|
|
|
@@ -835,8 +835,9 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 2026-05-28:按平台权限配置模式执行。
|
|
|
- * 流程:添加权限配置 -> 查询配置进度 -> 按配置快捷下载 -> 查询下载进度。
|
|
|
+ * 2026-06-04:按平台权限配置模式执行。
|
|
|
+ * 流程:添加权限配置 -> 查询配置进度/配置结果 -> 以 authItem 为主确认设备下载状态。
|
|
|
+ * 如显式开启 shortcut 补下载,再补做一次 authItem 复核。
|
|
|
*/
|
|
|
private static Map<String, Object> runPlatformConfigMode(Db gdba,
|
|
|
LeaveAuthSyncCtx ctx,
|
|
|
@@ -863,7 +864,9 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("platformConfigAddReq", configAddReq);
|
|
|
result.put("executeApiPath", "/artemis/api/acps/v1/auth_config/add");
|
|
|
result.put("resultApiPath", "/artemis/api/acps/v1/auth_config/rate/search");
|
|
|
- result.put("downloadApiPath", "/artemis/api/acps/v1/authDownload/configuration/person/reset");
|
|
|
+ result.put("authItemTotalApiPath", "/artemis/api/acps/v1/auth_item/total/search");
|
|
|
+ result.put("authItemListApiPath", "/artemis/api/acps/v1/auth_item/list/search");
|
|
|
+ result.put("downloadApiPath", "/artemis/api/acps/v1/authDownload/configuration/shortcut");
|
|
|
result.put("downloadTaskProgressApiPath", "/artemis/api/acps/v1/authDownload/task/progress");
|
|
|
result.put("downloadTaskSearchApiPath", "/artemis/api/acps/v1/authDownload/task/search");
|
|
|
result.put("downloadRecordChannelApiPath", "/artemis/api/acps/v1/download_record/channel/list/search");
|
|
|
@@ -906,29 +909,60 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("authConfigSearchError", e.getMessage());
|
|
|
}
|
|
|
|
|
|
- boolean autoDownload = rdBoolCfg("hk.leaveAuth.platform.autoDownload", "HK_LEAVE_AUTH_PLATFORM_AUTO_DOWNLOAD", true);
|
|
|
- result.put("downloadMode", autoDownload ? "platformConfigAndDownload" : "platformConfigOnly");
|
|
|
-
|
|
|
- if (autoDownload) {
|
|
|
- Map<String, Object> resetReq = makeAuthConfigPersonResetReq(personId, resourceInfoList, callbackUrl);
|
|
|
- result.put("authDownloadResetReq", resetReq);
|
|
|
- Map<String, Object> resetResp = HK_API_CLIENT.resetAuthDownloadByPerson(hkConnParm, resetReq);
|
|
|
- result.put("authDownloadResetResp", resetResp);
|
|
|
- boolean downloadResetAccepted = isHkRespAccepted(resetResp);
|
|
|
- result.put("downloadResetAccepted", downloadResetAccepted);
|
|
|
-
|
|
|
- String downloadTaskId = rdTaskId(resetResp);
|
|
|
- String downloadTaskSource = downloadResetAccepted || StringUtils.isNotBlank(downloadTaskId) ? "personReset" : null;
|
|
|
- result.put("downloadTaskAccepted", downloadResetAccepted || StringUtils.isNotBlank(downloadTaskId));
|
|
|
- result.put("downloadTaskId", downloadTaskId);
|
|
|
- result.put("downloadTaskSource", downloadTaskSource);
|
|
|
- if (downloadResetAccepted && StringUtils.isBlank(downloadTaskId)) {
|
|
|
- result.put("downloadPendingReason",
|
|
|
- callbackConfigured ? "resetAcceptedAwaitCallback" : "resetAcceptedWithoutTaskIdOrCallback");
|
|
|
- } else if (!downloadResetAccepted) {
|
|
|
- result.put("downloadPendingReason", "resetNotAccepted");
|
|
|
+ Map<String, Object> authItemTotalReq = makeAuthItemTotalReq(personId, resourceInfoList);
|
|
|
+ Map<String, Object> authItemListReq = makeAuthItemListReq(personId, resourceInfoList);
|
|
|
+ result.put("authItemTotalReq", authItemTotalReq);
|
|
|
+ result.put("authItemListReq", authItemListReq);
|
|
|
+ try {
|
|
|
+ result.put("authItemTotalResp",
|
|
|
+ queryAuthItemTotalWithRetry(hkConnParm, authItemTotalReq, resourceInfoList.size()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemTotalError", e.getMessage());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ result.put("authItemListResp",
|
|
|
+ queryAuthItemListWithRetry(hkConnParm, authItemListReq, ctx.kssj, ctx.jssj, resourceInfoList, false));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemListError", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean shortcutEnabled = rdBoolCfg("hk.leaveAuth.platform.shortcutEnabled",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_SHORTCUT_ENABLED", false);
|
|
|
+ result.put("downloadMode", shortcutEnabled ? "platformConfigAndShortcutDownload" : "platformConfigAndAuthItemConfirm");
|
|
|
+ result.put("shortcutEnabled", shortcutEnabled);
|
|
|
+
|
|
|
+ List<Map<String, Object>> preAuthItemMatchedRowList = extAuthItemMatchedRowList(
|
|
|
+ result.get("authItemListResp"), ctx.kssj, ctx.jssj, resourceInfoList);
|
|
|
+ boolean shortcutNeeded = shortcutEnabled && hasPendingAuthItemDownload(preAuthItemMatchedRowList);
|
|
|
+ result.put("shortcutNeeded", shortcutNeeded);
|
|
|
+ if (shortcutNeeded) {
|
|
|
+ result.put("authItemBeforeShortcutResp", result.get("authItemListResp"));
|
|
|
+ List<Integer> shortcutTaskTypeList = rdShortcutTaskTypeList(preAuthItemMatchedRowList);
|
|
|
+ result.put("shortcutTaskTypeList", shortcutTaskTypeList);
|
|
|
+ result.put("authDownloadShortcutReqList", makeAuthConfigShortcutReqList(shortcutTaskTypeList, resourceInfoList));
|
|
|
+
|
|
|
+ List<Map<String, Object>> shortcutRespList = new ArrayList<>();
|
|
|
+ List<String> downloadTaskIdList = new ArrayList<>();
|
|
|
+ boolean shortcutAccepted = false;
|
|
|
+ for (Map<String, Object> shortcutReq : castMapList(result.get("authDownloadShortcutReqList"))) {
|
|
|
+ Map<String, Object> shortcutResp = HK_API_CLIENT.shortcutAuthDownload(hkConnParm, shortcutReq);
|
|
|
+ shortcutRespList.add(shortcutResp);
|
|
|
+ if (isHkRespAccepted(shortcutResp))
|
|
|
+ shortcutAccepted = true;
|
|
|
+ String taskId = rdTaskId(shortcutResp);
|
|
|
+ if (StringUtils.isNotBlank(taskId))
|
|
|
+ downloadTaskIdList.add(taskId);
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(downloadTaskId)) {
|
|
|
+ result.put("authDownloadShortcutRespList", shortcutRespList);
|
|
|
+ result.put("authDownloadShortcutAccepted", shortcutAccepted);
|
|
|
+ result.put("downloadTaskAccepted", shortcutAccepted || !downloadTaskIdList.isEmpty());
|
|
|
+ result.put("downloadTaskSource", "configShortcut");
|
|
|
+ result.put("downloadTaskIdList", downloadTaskIdList);
|
|
|
+ if (downloadTaskIdList.size() == 1)
|
|
|
+ result.put("downloadTaskId", downloadTaskIdList.get(0));
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(rdStr(result.get("downloadTaskId")))) {
|
|
|
+ String downloadTaskId = rdStr(result.get("downloadTaskId"));
|
|
|
Map<String, Object> taskSearchReq = makeAuthDownloadTaskSearchReq(downloadTaskId);
|
|
|
result.put("authDownloadTaskSearchReq", taskSearchReq);
|
|
|
try {
|
|
|
@@ -960,9 +994,22 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("downloadRecordQueryError", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ try {
|
|
|
+ result.put("authItemTotalResp",
|
|
|
+ queryAuthItemTotalWithRetry(hkConnParm, authItemTotalReq, resourceInfoList.size()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemTotalError", e.getMessage());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ result.put("authItemListResp",
|
|
|
+ queryAuthItemListWithRetry(hkConnParm, authItemListReq, ctx.kssj, ctx.jssj, resourceInfoList, true));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemListError", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- finalizePlatformConfigResult(result, ctx.kssj, ctx.jssj, resourceInfoList.size(), autoDownload);
|
|
|
+ finalizePlatformConfigResult(result, ctx.kssj, ctx.jssj, resourceInfoList.size(), shortcutEnabled);
|
|
|
logExecute(ctx, personInfo, configAddReq, configAddResp);
|
|
|
persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
|
@@ -1001,6 +1048,50 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return req;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-04:按人员与设备通道查询权限条目总数,用于确认平台配置是否已落到 authItem 层。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> makeAuthItemTotalReq(String personId,
|
|
|
+ List<Map<String, Object>> resourceInfoList) {
|
|
|
+ Map<String, Object> req = new LinkedHashMap<>();
|
|
|
+ req.put("personIds", List.of(personId));
|
|
|
+ req.put("resourceInfos", makeAuthConfigResourceInfoList(resourceInfoList));
|
|
|
+ req.put("queryType", rdAuthItemQueryType(resourceInfoList));
|
|
|
+ return req;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:查询权限条目列表时追加分页和排序,便于直接拿到当前请假的完整资源明细。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> makeAuthItemListReq(String personId,
|
|
|
+ List<Map<String, Object>> resourceInfoList) {
|
|
|
+ Map<String, Object> req = makeAuthItemTotalReq(personId, resourceInfoList);
|
|
|
+ req.put("sortObjects", List.of(Map.of("field", "startTime", "sort", "asc")));
|
|
|
+ req.put("pageNo", 1);
|
|
|
+ int pageSize = resourceInfoList == null ? 50 : Math.max(50, Math.min(1000, resourceInfoList.size() * 3));
|
|
|
+ req.put("pageSize", pageSize);
|
|
|
+ return req;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:如海康侧未开启“权限自动下发”,可显式用 shortcut 按任务类型补一轮下载。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> makeAuthConfigShortcutReqList(List<Integer> taskTypeList,
|
|
|
+ List<Map<String, Object>> resourceInfoList) {
|
|
|
+ if (taskTypeList == null || taskTypeList.isEmpty())
|
|
|
+ return List.of();
|
|
|
+ List<Map<String, Object>> reqList = new ArrayList<>();
|
|
|
+ for (Integer taskType : taskTypeList) {
|
|
|
+ if (taskType == null || taskType <= 0)
|
|
|
+ continue;
|
|
|
+ Map<String, Object> req = new LinkedHashMap<>();
|
|
|
+ req.put("taskType", taskType);
|
|
|
+ req.put("resourceInfos", makeAuthConfigResourceInfoList(resourceInfoList));
|
|
|
+ reqList.add(req);
|
|
|
+ }
|
|
|
+ return reqList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:下载任务摘要查询需要按 taskId 精确查询。
|
|
|
*/
|
|
|
@@ -1866,8 +1957,26 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
} catch (Exception e) {
|
|
|
result.put("authConfigSearchError", e.getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, Object> authItemTotalReq = makeAuthItemTotalReq(personId, resourceInfoList);
|
|
|
+ Map<String, Object> authItemListReq = makeAuthItemListReq(personId, resourceInfoList);
|
|
|
+ result.put("authItemTotalReq", authItemTotalReq);
|
|
|
+ result.put("authItemListReq", authItemListReq);
|
|
|
+ try {
|
|
|
+ result.put("authItemTotalResp",
|
|
|
+ queryAuthItemTotalWithRetry(hkConnParm, authItemTotalReq, resourceInfoList.size()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemTotalError", e.getMessage());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ result.put("authItemListResp",
|
|
|
+ queryAuthItemListWithRetry(hkConnParm, authItemListReq, ctx.kssj, ctx.jssj, resourceInfoList, true));
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.put("authItemListError", e.getMessage());
|
|
|
+ }
|
|
|
} else {
|
|
|
result.put("authConfigSearchError", "未能获取海康 personId,无法查询平台权限配置。");
|
|
|
+ result.put("authItemListError", "未能获取海康 personId,无法查询 authItem 下载状态。");
|
|
|
}
|
|
|
|
|
|
String downloadTaskId = StringUtils.defaultIfBlank(
|
|
|
@@ -1911,16 +2020,85 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("mode", "viewPlatformConfigResult");
|
|
|
result.put("executeApiPath", "/artemis/api/acps/v1/auth_config/add");
|
|
|
result.put("resultApiPath", "/artemis/api/acps/v1/auth_config/rate/search");
|
|
|
- result.put("downloadApiPath", "/artemis/api/acps/v1/authDownload/configuration/person/reset");
|
|
|
+ result.put("authItemTotalApiPath", "/artemis/api/acps/v1/auth_item/total/search");
|
|
|
+ result.put("authItemListApiPath", "/artemis/api/acps/v1/auth_item/list/search");
|
|
|
+ result.put("downloadApiPath", "/artemis/api/acps/v1/authDownload/configuration/shortcut");
|
|
|
result.put("downloadTaskProgressApiPath", "/artemis/api/acps/v1/authDownload/task/progress");
|
|
|
result.put("downloadTaskSearchApiPath", "/artemis/api/acps/v1/authDownload/task/search");
|
|
|
result.put("downloadRecordChannelApiPath", "/artemis/api/acps/v1/download_record/channel/list/search");
|
|
|
result.put("downloadRecordPersonDetailApiPath", "/artemis/api/acps/v2/download_record/person/detail/search");
|
|
|
- boolean autoDownload = rdBoolCfg("hk.leaveAuth.platform.autoDownload", "HK_LEAVE_AUTH_PLATFORM_AUTO_DOWNLOAD", true);
|
|
|
- finalizePlatformConfigResult(result, ctx.kssj, ctx.jssj, resourceInfoList.size(), autoDownload);
|
|
|
+ boolean shortcutEnabled = rdBoolCfg("hk.leaveAuth.platform.shortcutEnabled",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_SHORTCUT_ENABLED", false);
|
|
|
+ result.put("shortcutEnabled", shortcutEnabled);
|
|
|
+ result.put("downloadMode", shortcutEnabled ? "platformConfigAndShortcutDownload" : "platformConfigAndAuthItemConfirm");
|
|
|
+ finalizePlatformConfigResult(result, ctx.kssj, ctx.jssj, resourceInfoList.size(), shortcutEnabled);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem 总数一般会比平台配置结果稍晚可见,做短轮询避免刚创建就误判为“无权限条目”。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> queryAuthItemTotalWithRetry(Map<String, Object> hkConnParm,
|
|
|
+ Map<String, Object> totalReq,
|
|
|
+ int expectedResourceCount) throws Exception {
|
|
|
+ Map<String, Object> lastResp = null;
|
|
|
+ int pollCount = Math.max(1, rdIntCfg("hk.leaveAuth.platform.downloadPollCount",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_DOWNLOAD_POLL_COUNT", HK_DEF_DOWNLOAD_POLL_COUNT));
|
|
|
+ int sleepMs = Math.max(0, rdIntCfg("hk.leaveAuth.platform.downloadPollSleepMs",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_DOWNLOAD_POLL_SLEEP_MS", HK_DEF_DOWNLOAD_POLL_SLEEP_MS));
|
|
|
+ int expectedCount = Math.max(1, expectedResourceCount);
|
|
|
+
|
|
|
+ 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.searchAuthItemTotal(hkConnParm, totalReq);
|
|
|
+ if (rdAuthItemTotalCount(lastResp) >= expectedCount)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return lastResp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem 列表既能看见权限配置,也能看见下载状态,是当前主链路的核心确认口。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> queryAuthItemListWithRetry(Map<String, Object> hkConnParm,
|
|
|
+ Map<String, Object> listReq,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList,
|
|
|
+ boolean waitDownloaded) throws Exception {
|
|
|
+ Map<String, Object> lastResp = null;
|
|
|
+ int pollCount = Math.max(1, rdIntCfg("hk.leaveAuth.platform.downloadPollCount",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_DOWNLOAD_POLL_COUNT", HK_DEF_DOWNLOAD_POLL_COUNT));
|
|
|
+ int sleepMs = Math.max(0, rdIntCfg("hk.leaveAuth.platform.downloadPollSleepMs",
|
|
|
+ "HK_LEAVE_AUTH_PLATFORM_DOWNLOAD_POLL_SLEEP_MS", HK_DEF_DOWNLOAD_POLL_SLEEP_MS));
|
|
|
+ int expectedCount = Math.max(1, resourceInfoList == null ? 0 : resourceInfoList.size());
|
|
|
+
|
|
|
+ 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.searchAuthItemList(hkConnParm, listReq);
|
|
|
+ List<Map<String, Object>> matchedRowList = extAuthItemMatchedRowList(lastResp, leaveBeg, leaveEnd, resourceInfoList);
|
|
|
+ if (matchedRowList.size() < expectedCount)
|
|
|
+ continue;
|
|
|
+ if (!waitDownloaded || !hasPendingAuthItemDownload(matchedRowList))
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return lastResp;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-05-29:下载任务是异步的,短轮询几次后再回显,避免刚建任务就固定看到未完成。
|
|
|
*/
|
|
|
@@ -2386,22 +2564,32 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 2026-06-02:平台配置模式必须同时确认“配置成功 + 平台可查 + 下载可确认”后,才对外返回成功。
|
|
|
- * 否则 PMS 虽然拿到了 taskId,但现场门禁仍可能提示“当前时间无效”。
|
|
|
+ * 2026-06-04:平台配置模式必须同时确认“配置成功 + 平台可查 + authItem 已显示下载完成”后,才对外返回成功。
|
|
|
+ * task / download_record / callback 现在只作为辅助诊断,主判据改为 authItem。
|
|
|
*/
|
|
|
private static void finalizePlatformConfigResult(Map<String, Object> result,
|
|
|
Timestamp leaveBeg,
|
|
|
Timestamp leaveEnd,
|
|
|
int expectedResourceCount,
|
|
|
- boolean autoDownload) {
|
|
|
+ boolean shortcutEnabled) {
|
|
|
int configTotalCount = rdAuthConfigTotalCount(result.get("authConfigSearchResp"));
|
|
|
int matchedConfigCount = rdAuthConfigMatchedCount(result.get("authConfigSearchResp"), leaveBeg, leaveEnd);
|
|
|
boolean configRateFinished = isAuthConfigFinished(result.get("authConfigRateResp"));
|
|
|
boolean configRateSuccess = isAuthConfigSuccess(result.get("authConfigRateResp"), expectedResourceCount);
|
|
|
boolean configSearchMatched = expectedResourceCount > 0 && matchedConfigCount >= expectedResourceCount;
|
|
|
boolean callbackConfigured = rdBoolLike(result.get("callbackConfigured"));
|
|
|
- boolean downloadResetAccepted = rdBoolLike(result.get("downloadResetAccepted"))
|
|
|
- || isHkRespAccepted(result.get("authDownloadResetResp"));
|
|
|
+ List<Map<String, Object>> authItemMatchedRowList = extAuthItemMatchedRowList(
|
|
|
+ result.get("authItemListResp"), leaveBeg, leaveEnd, castMapList(result.get("resourceInfos")));
|
|
|
+ int authItemTotalCount = rdAuthItemTotalCount(result.get("authItemTotalResp"));
|
|
|
+ int authItemMatchedCount = authItemMatchedRowList.size();
|
|
|
+ int authItemDownloadedCount = rdAuthItemDownloadedCount(authItemMatchedRowList);
|
|
|
+ int authItemPendingCount = rdAuthItemPendingCount(authItemMatchedRowList);
|
|
|
+ int authItemCredentialMissingCount = rdAuthItemCredentialMissingCount(authItemMatchedRowList);
|
|
|
+ boolean authItemSearchMatched = expectedResourceCount > 0 && authItemMatchedCount >= expectedResourceCount;
|
|
|
+ boolean authItemDownloaded = expectedResourceCount > 0
|
|
|
+ && authItemMatchedCount >= expectedResourceCount
|
|
|
+ && authItemPendingCount == 0
|
|
|
+ && authItemDownloadedCount >= expectedResourceCount;
|
|
|
String downloadTaskId = rdStr(result.get("downloadTaskId"));
|
|
|
boolean downloadTaskIdPresent = StringUtils.isNotBlank(downloadTaskId);
|
|
|
boolean downloadTaskExists = hasAuthDownloadTask(result.get("authDownloadTaskSearchResp"));
|
|
|
@@ -2409,8 +2597,9 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
boolean downloadProgressFinished = isAuthDownloadFinished(castMap(result.get("authDownloadTaskProgressResp")));
|
|
|
boolean downloadCallbackReceived = rdBoolLike(result.get("downloadCallbackReceived"));
|
|
|
boolean downloadCallbackSuccess = isPersistedLeaveAuthCallbackSuccess(result);
|
|
|
+ boolean shortcutAccepted = rdBoolLike(result.get("authDownloadShortcutAccepted"));
|
|
|
boolean downloadTaskAccepted = rdBoolLike(result.get("downloadTaskAccepted"))
|
|
|
- || downloadResetAccepted
|
|
|
+ || shortcutAccepted
|
|
|
|| downloadTaskIdPresent
|
|
|
|| downloadTaskExists
|
|
|
|| downloadCallbackReceived;
|
|
|
@@ -2429,30 +2618,30 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
&& downloadRecordChannelFailedCount == 0
|
|
|
&& downloadRecordPersonDetailSuccessCount >= expectedResourceCount
|
|
|
&& downloadRecordPersonDetailFailedCount == 0;
|
|
|
- boolean downloadConfirmed = !autoDownload || downloadRecordConfirmed || downloadCallbackSuccess;
|
|
|
+ boolean downloadConfirmed = authItemDownloaded || downloadRecordConfirmed || downloadCallbackSuccess;
|
|
|
String downloadConfirmSource = null;
|
|
|
String downloadPendingReason;
|
|
|
- if (!autoDownload) {
|
|
|
- downloadConfirmSource = "notRequired";
|
|
|
- downloadPendingReason = "downloadNotRequired";
|
|
|
+ if (authItemDownloaded) {
|
|
|
+ downloadConfirmSource = "authItem";
|
|
|
+ downloadPendingReason = "authItemDownloaded";
|
|
|
} else if (downloadRecordConfirmed) {
|
|
|
downloadConfirmSource = "taskRecord";
|
|
|
downloadPendingReason = "taskRecordConfirmed";
|
|
|
} else if (downloadCallbackSuccess) {
|
|
|
downloadConfirmSource = "callback";
|
|
|
downloadPendingReason = "callbackCompleted";
|
|
|
- } else if (!downloadTaskAccepted) {
|
|
|
- downloadPendingReason = "resetNotAccepted";
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived && !downloadTaskIdPresent && callbackConfigured) {
|
|
|
- downloadPendingReason = "resetAcceptedAwaitCallback";
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived && !downloadTaskIdPresent) {
|
|
|
- downloadPendingReason = "resetAcceptedWithoutTaskIdOrCallback";
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived) {
|
|
|
- downloadPendingReason = "taskIdReturnedAwaitTaskSearch";
|
|
|
+ } else if (!authItemSearchMatched) {
|
|
|
+ downloadPendingReason = "authItemNotReady";
|
|
|
} else if (downloadCallbackReceived) {
|
|
|
downloadPendingReason = "callbackReturnedFailure";
|
|
|
- } else if (!downloadTaskFinished && !downloadProgressFinished) {
|
|
|
+ } else if (shortcutEnabled && !downloadTaskAccepted) {
|
|
|
+ downloadPendingReason = "shortcutNotAccepted";
|
|
|
+ } else if (shortcutEnabled && downloadTaskAccepted && !downloadTaskExists && !downloadCallbackReceived && !downloadTaskIdPresent) {
|
|
|
+ downloadPendingReason = "shortcutAcceptedAwaitAuthItem";
|
|
|
+ } else if (shortcutEnabled && !downloadTaskFinished && !downloadProgressFinished && downloadTaskExists) {
|
|
|
downloadPendingReason = "taskRunning";
|
|
|
+ } else if (authItemPendingCount > 0) {
|
|
|
+ downloadPendingReason = "authItemNotDownloaded";
|
|
|
} else if (downloadRecordChannelMatchedCount <= 0) {
|
|
|
downloadPendingReason = "noChannelRecord";
|
|
|
} else if (downloadRecordPersonDetailMatchedCount <= 0) {
|
|
|
@@ -2471,8 +2660,18 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("configRateFinished", configRateFinished);
|
|
|
result.put("configRateSuccess", configRateSuccess);
|
|
|
result.put("configSearchMatched", configSearchMatched);
|
|
|
+ result.put("authItemTotalCount", authItemTotalCount);
|
|
|
+ result.put("authItemMatchedCount", authItemMatchedCount);
|
|
|
+ result.put("authItemDownloadedCount", authItemDownloadedCount);
|
|
|
+ result.put("authItemPendingCount", authItemPendingCount);
|
|
|
+ result.put("authItemCredentialMissingCount", authItemCredentialMissingCount);
|
|
|
+ result.put("authItemSearchMatched", authItemSearchMatched);
|
|
|
+ result.put("authItemDownloaded", authItemDownloaded);
|
|
|
+ result.put("authItemStatusSummary", makeAuthItemStatusSummary(authItemMatchedRowList));
|
|
|
+ result.put("authItemPendingSampleList", makeAuthItemPendingSampleList(authItemMatchedRowList, 12));
|
|
|
result.put("callbackConfigured", callbackConfigured);
|
|
|
- result.put("downloadResetAccepted", downloadResetAccepted);
|
|
|
+ result.put("downloadResetAccepted", false);
|
|
|
+ result.put("authDownloadShortcutAccepted", shortcutAccepted);
|
|
|
result.put("downloadTaskAccepted", downloadTaskAccepted);
|
|
|
result.put("downloadTaskExists", downloadTaskExists);
|
|
|
result.put("downloadTaskFinished", downloadTaskFinished);
|
|
|
@@ -2504,39 +2703,41 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
if (!downloadConfirmed) {
|
|
|
result.put("ok", false);
|
|
|
- if (!downloadTaskAccepted) {
|
|
|
- result.put("msg", "海康人员权限重下发未确认受理,设备生效状态未确认。");
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived && !downloadTaskIdPresent && callbackConfigured) {
|
|
|
- result.put("msg", "海康已受理人员权限重下发,当前等待回调确认设备生效。");
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived && !downloadTaskIdPresent) {
|
|
|
- result.put("msg", "海康已受理人员权限重下发,但未返回 taskId,且当前未配置回调地址,无法继续确认设备生效状态。");
|
|
|
- } else if (!downloadTaskExists && !downloadCallbackReceived) {
|
|
|
- result.put("msg", "海康已返回 downloadTaskId,但暂未查到任务摘要或完整设备记录。");
|
|
|
- } else if (!downloadTaskFinished && !downloadProgressFinished) {
|
|
|
- result.put("msg", "海康下载任务仍未结束,设备生效状态未确认。");
|
|
|
+ if (!authItemSearchMatched) {
|
|
|
+ result.put("msg", "海康平台配置已完成,但 authItem 暂未生成覆盖当前请假时段的完整权限条目。");
|
|
|
} else if (downloadCallbackReceived) {
|
|
|
result.put("msg", "已收到海康下载回调,但回调结果未显示全部成功。");
|
|
|
+ } else if (authItemPendingCount > 0 && !shortcutEnabled) {
|
|
|
+ result.put("msg", "海康平台已生成权限条目,但 authItem 显示仍有资源处于“已配置未下载/待下载”状态,请确认海康 ACPS 是否已开启权限自动下发。");
|
|
|
+ } else if (authItemPendingCount > 0 && !downloadTaskAccepted) {
|
|
|
+ result.put("msg", "海康平台已生成权限条目,但 shortcut 下载未确认受理,设备生效状态未确认。");
|
|
|
+ } else if (authItemPendingCount > 0 && !downloadTaskExists && !downloadTaskIdPresent && callbackConfigured) {
|
|
|
+ result.put("msg", "海康已受理 shortcut 下载,当前等待 authItem 或回调反映设备侧生效结果。");
|
|
|
+ } else if (authItemPendingCount > 0 && !downloadTaskExists && !downloadTaskIdPresent) {
|
|
|
+ result.put("msg", "海康平台已生成权限条目,但 authItem 仍显示未下载,且 shortcut 未返回可追踪任务号。");
|
|
|
+ } else if (authItemPendingCount > 0 && !downloadTaskFinished && !downloadProgressFinished && downloadTaskExists) {
|
|
|
+ result.put("msg", "海康 shortcut 下载任务仍未结束,authItem 尚未反映全部设备已下载。");
|
|
|
} else if (downloadRecordChannelMatchedCount <= 0) {
|
|
|
- result.put("msg", "海康下载任务已结束,但未查询到设备通道下载记录。");
|
|
|
+ result.put("msg", "authItem 仍未显示全部下载完成,且当前未查询到可支撑确认的设备通道下载记录。");
|
|
|
} else if (downloadRecordPersonDetailMatchedCount <= 0) {
|
|
|
- result.put("msg", "海康已生成设备通道下载记录,但未查询到该学生的人员下载详情。");
|
|
|
+ result.put("msg", "海康已生成设备通道下载记录,但当前仍缺少该学生的完整人员下载详情。");
|
|
|
} else if (downloadRecordChannelFailedCount > 0 || downloadRecordPersonDetailFailedCount > 0) {
|
|
|
- result.put("msg", "海康下载记录显示存在失败或部分失败,设备生效状态未全部确认。");
|
|
|
+ result.put("msg", "海康下载记录显示存在失败或部分失败,authItem 也未显示全部下载完成。");
|
|
|
} else if (downloadTaskFinished) {
|
|
|
- result.put("msg", "海康下载任务摘要显示已结束,但设备侧下载记录仍未达到完整成功状态。");
|
|
|
- } else if (downloadTaskExists) {
|
|
|
- result.put("msg", "海康下载任务已创建,但设备侧下载记录仍未达到完整成功状态。");
|
|
|
+ result.put("msg", "海康下载任务摘要显示已结束,但 authItem 仍未达到完整下载成功状态。");
|
|
|
} else {
|
|
|
- result.put("msg", "海康下载链路未返回完整成功记录,门禁设备生效状态未确认。");
|
|
|
+ result.put("msg", "海康 authItem 仍未达到完整下载成功状态,门禁设备生效结果未确认。");
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
result.put("ok", true);
|
|
|
- if (autoDownload && "callback".equals(downloadConfirmSource)) {
|
|
|
+ if ("callback".equals(downloadConfirmSource)) {
|
|
|
result.put("msg", "海康平台权限配置已完成,设备生效已由回调确认。");
|
|
|
+ } else if ("authItem".equals(downloadConfirmSource)) {
|
|
|
+ result.put("msg", "海康平台权限配置已完成,authItem 已确认设备下载成功。");
|
|
|
} else {
|
|
|
- result.put("msg", autoDownload ? "海康平台权限配置与下载已确认完成。" : "海康平台权限配置已确认完成。");
|
|
|
+ result.put("msg", "海康平台权限配置与下载已确认完成。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2571,6 +2772,26 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return "CONFIGEND".equalsIgnoreCase(status) || "FINISHED".equalsIgnoreCase(status) || "SUCCESS".equalsIgnoreCase(status);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem total 接口直接在 data 字段返回数字,不走 `{data:{...}}` 结构。
|
|
|
+ */
|
|
|
+ private static int rdAuthItemTotalCount(Object totalRespObj) {
|
|
|
+ Map<String, Object> totalResp = castMap(totalRespObj);
|
|
|
+ if (totalResp == null)
|
|
|
+ return 0;
|
|
|
+ Object dataObj = totalResp.get("data");
|
|
|
+ if (dataObj instanceof Number number)
|
|
|
+ return number.intValue();
|
|
|
+ String text = rdStr(dataObj);
|
|
|
+ if (StringUtils.isBlank(text))
|
|
|
+ return 0;
|
|
|
+ try {
|
|
|
+ return (int) Math.round(Double.parseDouble(text));
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:统计海康平台当前查到的权限配置总数。
|
|
|
*/
|
|
|
@@ -2612,6 +2833,185 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return matchedCount;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-04:从 authItem 列表中筛出当前请假窗口和当前资源集合真正命中的条目。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> extAuthItemMatchedRowList(Object listRespObj,
|
|
|
+ Timestamp leaveBeg,
|
|
|
+ Timestamp leaveEnd,
|
|
|
+ List<Map<String, Object>> resourceInfoList) {
|
|
|
+ Map<String, Object> listResp = castMap(listRespObj);
|
|
|
+ Map<String, Object> dataMap = rdDataMap(listResp);
|
|
|
+ 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>> matchedRowList = new ArrayList<>();
|
|
|
+ for (Object item : list) {
|
|
|
+ if (!(item instanceof Map<?, ?> rawMap))
|
|
|
+ continue;
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ Map<String, Object> row = (Map<String, Object>) rawMap;
|
|
|
+ String resourceKey = makeAuthItemResourceKey(row);
|
|
|
+ if (!resourceKeySet.isEmpty() && !resourceKeySet.contains(resourceKey))
|
|
|
+ continue;
|
|
|
+ if (!sameAuthTime(rdStr(row.get("startTime")), leaveBeg) || !sameAuthTime(rdStr(row.get("endTime")), leaveEnd))
|
|
|
+ continue;
|
|
|
+ matchedRowList.add(row);
|
|
|
+ }
|
|
|
+ return matchedRowList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem 行命中后,只要还存在 0/1/2 状态,就说明设备侧下载尚未完全完成。
|
|
|
+ */
|
|
|
+ private static boolean hasPendingAuthItemDownload(List<Map<String, Object>> rowList) {
|
|
|
+ return rdAuthItemPendingCount(rowList) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:统计当前请假资源里 authItem 已确认下载完成的条目数。
|
|
|
+ */
|
|
|
+ private static int rdAuthItemDownloadedCount(List<Map<String, Object>> rowList) {
|
|
|
+ if (rowList == null || rowList.isEmpty())
|
|
|
+ return 0;
|
|
|
+ int count = 0;
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ if (isAuthItemRowDownloaded(row))
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:统计 authItem 中仍处于“未下载 / 待下载 / 待删除”的条目数。
|
|
|
+ */
|
|
|
+ private static int rdAuthItemPendingCount(List<Map<String, Object>> rowList) {
|
|
|
+ if (rowList == null || rowList.isEmpty())
|
|
|
+ return 0;
|
|
|
+ int count = 0;
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ if (isAuthItemRowPending(row))
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:补充统计“人员已下载,但卡片和人脸都未配置”的场景,便于现场核对学生凭证资料是否完整。
|
|
|
+ */
|
|
|
+ private static int rdAuthItemCredentialMissingCount(List<Map<String, Object>> rowList) {
|
|
|
+ if (rowList == null || rowList.isEmpty())
|
|
|
+ return 0;
|
|
|
+ int count = 0;
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ int personStatus = rdStatusInt(row == null ? null : row.get("personStatus"));
|
|
|
+ int cardStatus = rdStatusInt(row == null ? null : row.get("cardStatus"));
|
|
|
+ int faceStatus = rdStatusInt(row == null ? null : row.get("faceStatus"));
|
|
|
+ if (personStatus == 3 && cardStatus == 4 && faceStatus == 4)
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:shortcut 下载任务类型支持显式配置;未配置时按 authItem 待下载状态自动推断卡片/人脸。
|
|
|
+ */
|
|
|
+ private static List<Integer> rdShortcutTaskTypeList(List<Map<String, Object>> authItemRowList) {
|
|
|
+ LinkedHashSet<Integer> taskTypeSet = new LinkedHashSet<>();
|
|
|
+ String cfgVal = rdCfg("hk.leaveAuth.platform.shortcutTaskTypes", "HK_LEAVE_AUTH_PLATFORM_SHORTCUT_TASK_TYPES");
|
|
|
+ if (StringUtils.isNotBlank(cfgVal)) {
|
|
|
+ for (String part : StringUtils.split(cfgVal, ",;| ")) {
|
|
|
+ int taskType = rdInt(part);
|
|
|
+ if (taskType > 0)
|
|
|
+ taskTypeSet.add(taskType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!taskTypeSet.isEmpty())
|
|
|
+ return new ArrayList<>(taskTypeSet);
|
|
|
+
|
|
|
+ boolean needCard = false;
|
|
|
+ boolean needFace = false;
|
|
|
+ if (authItemRowList != null) {
|
|
|
+ for (Map<String, Object> row : authItemRowList) {
|
|
|
+ if (isPendingAuthItemStatus(rdStatusInt(row == null ? null : row.get("cardStatus"))))
|
|
|
+ needCard = true;
|
|
|
+ if (isPendingAuthItemStatus(rdStatusInt(row == null ? null : row.get("faceStatus"))))
|
|
|
+ needFace = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (needCard)
|
|
|
+ taskTypeSet.add(1);
|
|
|
+ if (needFace)
|
|
|
+ taskTypeSet.add(4);
|
|
|
+ if (taskTypeSet.isEmpty()) {
|
|
|
+ taskTypeSet.add(1);
|
|
|
+ taskTypeSet.add(4);
|
|
|
+ }
|
|
|
+ return new ArrayList<>(taskTypeSet);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:汇总当前命中 authItem 的状态分布,便于直接看出是“未下载”还是“已下载”。
|
|
|
+ */
|
|
|
+ private static Map<String, Object> makeAuthItemStatusSummary(List<Map<String, Object>> rowList) {
|
|
|
+ Map<String, Integer> personStatusMap = new LinkedHashMap<>();
|
|
|
+ Map<String, Integer> cardStatusMap = new LinkedHashMap<>();
|
|
|
+ Map<String, Integer> faceStatusMap = new LinkedHashMap<>();
|
|
|
+ if (rowList != null) {
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ addStatusCount(personStatusMap, row == null ? null : row.get("personStatus"));
|
|
|
+ addStatusCount(cardStatusMap, row == null ? null : row.get("cardStatus"));
|
|
|
+ addStatusCount(faceStatusMap, row == null ? null : row.get("faceStatus"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> summary = new LinkedHashMap<>();
|
|
|
+ summary.put("personStatus", personStatusMap);
|
|
|
+ summary.put("cardStatus", cardStatusMap);
|
|
|
+ summary.put("faceStatus", faceStatusMap);
|
|
|
+ summary.put("rowCount", rowList == null ? 0 : rowList.size());
|
|
|
+ return summary;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:状态统计统一按数字语义聚合,避免 0 / 0.0 被拆成两个桶。
|
|
|
+ */
|
|
|
+ private static void addStatusCount(Map<String, Integer> counter, Object value) {
|
|
|
+ if (counter == null)
|
|
|
+ return;
|
|
|
+ int status = rdStatusInt(value);
|
|
|
+ String key = status >= 0 ? String.valueOf(status) : StringUtils.defaultIfBlank(rdStr(value), "null");
|
|
|
+ counter.put(key, counter.getOrDefault(key, 0) + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:回显少量未下载样本,避免结果页一次性塞入整批 36 条明细。
|
|
|
+ */
|
|
|
+ private static List<Map<String, Object>> makeAuthItemPendingSampleList(List<Map<String, Object>> rowList, int limit) {
|
|
|
+ List<Map<String, Object>> sampleList = new ArrayList<>();
|
|
|
+ if (rowList == null || rowList.isEmpty() || limit <= 0)
|
|
|
+ return sampleList;
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ if (!isAuthItemRowPending(row))
|
|
|
+ continue;
|
|
|
+ Map<String, Object> brief = new LinkedHashMap<>();
|
|
|
+ brief.put("resourceIndexCode", rdStr(row.get("resourceIndexCode")));
|
|
|
+ brief.put("channelNo", rdStr(row.get("channelNo")));
|
|
|
+ brief.put("personStatus", rdStatusInt(row.get("personStatus")));
|
|
|
+ brief.put("cardStatus", rdStatusInt(row.get("cardStatus")));
|
|
|
+ brief.put("faceStatus", rdStatusInt(row.get("faceStatus")));
|
|
|
+ brief.put("startTime", rdStr(row.get("startTime")));
|
|
|
+ brief.put("endTime", rdStr(row.get("endTime")));
|
|
|
+ sampleList.add(brief);
|
|
|
+ if (sampleList.size() >= limit)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return sampleList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:把海康返回时间与当前请假时间窗按“同一时刻”比较,避免毫秒位差异误判。
|
|
|
*/
|
|
|
@@ -2626,6 +3026,79 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem 查询需要 queryType,当前请假链路资源类型固定跟随第一条资源。
|
|
|
+ */
|
|
|
+ private static String rdAuthItemQueryType(List<Map<String, Object>> resourceInfoList) {
|
|
|
+ if (resourceInfoList == null || resourceInfoList.isEmpty())
|
|
|
+ return "acsDevice";
|
|
|
+ String resourceType = rdStr(resourceInfoList.get(0).get("resourceType"));
|
|
|
+ return StringUtils.defaultIfBlank(resourceType, "acsDevice");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:把 authItem 返回行转成与本地资源同口径的 resourceKey,便于判定是否属于当前请假门禁范围。
|
|
|
+ */
|
|
|
+ private static String makeAuthItemResourceKey(Map<String, Object> authItemRow) {
|
|
|
+ if (authItemRow == null)
|
|
|
+ return null;
|
|
|
+ String resourceIndexCode = rdStr(authItemRow.get("resourceIndexCode"));
|
|
|
+ if (StringUtils.isBlank(resourceIndexCode))
|
|
|
+ return null;
|
|
|
+ String channelNo = rdStr(authItemRow.get("channelNo"));
|
|
|
+ return resourceIndexCode + "#" + StringUtils.defaultIfBlank(channelNo, "1");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:当前条目真正可视为设备已下载的条件是:人员状态已下载,且卡片/人脸不再处于待下载态。
|
|
|
+ */
|
|
|
+ private static boolean isAuthItemRowDownloaded(Map<String, Object> row) {
|
|
|
+ if (row == null)
|
|
|
+ return false;
|
|
|
+ int personStatus = rdStatusInt(row.get("personStatus"));
|
|
|
+ int cardStatus = rdStatusInt(row.get("cardStatus"));
|
|
|
+ int faceStatus = rdStatusInt(row.get("faceStatus"));
|
|
|
+ return personStatus == 3
|
|
|
+ && !isPendingAuthItemStatus(cardStatus)
|
|
|
+ && !isPendingAuthItemStatus(faceStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:authItem 任一状态仍是 0/1/2,都代表设备侧仍未完成这条权限的最终生效。
|
|
|
+ */
|
|
|
+ private static boolean isAuthItemRowPending(Map<String, Object> row) {
|
|
|
+ if (row == null)
|
|
|
+ return false;
|
|
|
+ return isPendingAuthItemStatus(rdStatusInt(row.get("personStatus")))
|
|
|
+ || isPendingAuthItemStatus(rdStatusInt(row.get("cardStatus")))
|
|
|
+ || isPendingAuthItemStatus(rdStatusInt(row.get("faceStatus")));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:0=已配置未下载,1=更新待下载,2=更新待删除,都归为“未完成下载”。
|
|
|
+ */
|
|
|
+ private static boolean isPendingAuthItemStatus(int status) {
|
|
|
+ return status >= 0 && status <= 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2026-06-04:海康状态字段有时会落成 0.0 / 3.0,这里统一按数值语义取整。
|
|
|
+ */
|
|
|
+ private static int rdStatusInt(Object value) {
|
|
|
+ if (value == null)
|
|
|
+ return -1;
|
|
|
+ if (value instanceof Number number)
|
|
|
+ return number.intValue();
|
|
|
+ String text = rdStr(value);
|
|
|
+ if (StringUtils.isBlank(text))
|
|
|
+ return -1;
|
|
|
+ try {
|
|
|
+ return (int) Math.round(Double.parseDouble(text));
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2026-06-02:统一把海康 `{code,msg,data}` 响应里的 `data` 取成 Map。
|
|
|
*/
|