Quellcode durchsuchen

修复: 补齐海康请假条目回收链路的tagId透传

1. 调整 HkLeaveAuthServ.executeLeaveAuthDeleteForItem,新增 overrideParm 透传,并在条目级 auth_config/search/delete 前统一注入 tagId、tagIdSource 与安全化 hkConn 诊断信息。

2. 同步修改销假缩短结束时间、取消请假、定时回收三条条目级删权调用链,避免补偿链路与回收链路配置口径不一致,修复 recycle 场景下 auth_config/search 返回 param convert error 的问题。

3. 新增 docs/2026-06-17_海康请假回收条目缺失tagId修复.md,记录正式环境症状、根因、修复点与部署后复核建议。

4. 验证:已执行 HkLeaveAuthServ 单文件 javac 编译通过;未执行正式环境联调。
“gaohp” vor 5 Monaten
Ursprung
Commit
4116db99b6

+ 72 - 0
docs/2026-06-17_海康请假回收条目缺失tagId修复.md

@@ -0,0 +1,72 @@
+# 2026-06-17 海康请假回收条目缺失 tagId 修复
+
+## 问题现象
+
+- 正式环境 `hkkq_leave_auth_recycle` 手工触发后,候选条目都进入失败。
+- 失败点集中在条目级回收前置查询:
+  - `auth_config/search`
+  - 返回 `code=0x15400001`
+  - 返回 `msg=param convert error`
+- 典型影响:
+  - 已过结束时间的 `dorm_return_auth` 条目仍然 `delete_confirmed=0`
+  - 学生请假结束后,宿舍或校门仍持续出现“权限过期/无权限”
+
+## 根因
+
+当前代码里,海康请假权限的 `add` 链路和整单 `delete` 链路都已经把 `tagId` 注入到 `hkConnParm`。
+
+但条目级回收方法 `executeLeaveAuthDeleteForItem(...)` 在调用:
+
+- `/api/acps/v1/auth_config/search`
+- `/api/acps/v1/auth_config/delete`
+
+之前没有把 `tagId` 放入海康连接参数,导致正式环境服务内发起的回收查询被海康直接判定为参数转换错误。
+
+这与 2026-06-16 已验证过的现象一致:
+
+- 同一组 `personId + resourceInfos`
+- 不带 `tagId` 时,`auth_config/search` 返回 `param convert error`
+- 带 `tagId=frs` 时,查询成功
+
+## 本次修复
+
+修改文件:
+
+- `src/biz/kq/HkLeaveAuthServ.java`
+
+修复点:
+
+1. 给 `executeLeaveAuthDeleteForItem(...)` 增加 `overrideParm` 透传入口。
+2. 统一按现有配置读取 `tagId`:
+   - 请求参数覆盖值
+   - `hk.leaveAuth.tagId`
+   - `HK_LEAVE_AUTH_TAG_ID`
+   - 默认值 `frs`
+3. 将 `tagId` 注入 `hkConnParm` 后再执行:
+   - `auth_config/search`
+   - `auth_config/delete`
+4. 把以下诊断信息写回结果,便于后续正式环境核对:
+   - `tagId`
+   - `tagIdSource`
+   - `hkConn`
+5. 定时回收服务 `hkkq_leave_auth_recycle` 也统一透传覆盖参数,避免手工服务和内部回收逻辑口径不一致。
+
+## 预期效果
+
+- 条目级回收不再因缺少 `tagId` 在前置查询阶段失败。
+- 已结束请假条目的 `delete_confirmed` 应能被正常推进。
+- `dorm_return_auth` 一类“补给宿舍门的临时权限”在结束后可被正确回收,避免持续影响学生后续正常通行。
+
+## 部署后建议复核
+
+1. 手工触发:
+   - `https://m.sxlg.net/service?ssServ=hkkq_leave_auth_recycle&limit=20`
+2. 重点看返回中的:
+   - `confirmedCount`
+   - `failedCount`
+   - `authConfigDeleteSearchBeforeResp`
+3. 再核对本地扩展表中已过期条目:
+   - 是否从 `delete_confirmed=0` 逐步转为 `1`
+4. 若仍失败,再继续区分:
+   - 是否存在海康侧其他时间窗权限,触发了当前保护逻辑 `searchContainsOtherTimeWindows`
+   - 是否为资源集合不一致,而不再是 `tagId` 缺失问题

+ 12 - 4
src/biz/kq/HkLeaveAuthServ.java

@@ -144,7 +144,7 @@ public class HkLeaveAuthServ extends Serv {
                         return;
                     List<LeaveAuthItemRow> oldItemRowList = selLeaveAuthItemRowList(itemGdba, rcid);
                     for (LeaveAuthItemRow itemRow : oldItemRowList) {
-                        Map<String, Object> deleteResult = executeLeaveAuthDeleteForItem(itemGdba, itemRow, true, false);
+                        Map<String, Object> deleteResult = executeLeaveAuthDeleteForItem(itemGdba, itemRow, true, false, Map.of());
                         if (!rdBoolLike(deleteResult.get("deleteConfirmed"))) {
                             log4j.warn("HkLeaveAuthServ.syncLeaveAuthAfterEndTimeChange() item旧时间窗未能确认回收,itemId={}, rcid={}",
                                     itemRow.itemId, rcid);
@@ -726,7 +726,7 @@ public class HkLeaveAuthServ extends Serv {
                     markLeaveAuthStageDeleted(itemResult, ctx, new Timestamp(System.currentTimeMillis()));
                     updLeaveAuthItemRow(gdba, itemRow.itemId, itemResult);
                 } else {
-                    itemResult = executeLeaveAuthDeleteForItem(gdba, itemRow, true, false);
+                    itemResult = executeLeaveAuthDeleteForItem(gdba, itemRow, true, false, Map.of());
                     if (!rdBoolLike(itemResult.get("deleteConfirmed")))
                         allOk = false;
                 }
@@ -915,6 +915,7 @@ public class HkLeaveAuthServ extends Serv {
         if (limit <= 0)
             limit = HK_DEF_RECYCLE_LIMIT;
         result.put("limit", limit);
+        Map<String, Object> overrideParm = makeReqOverrideParm();
         Timestamp now = new Timestamp(System.currentTimeMillis());
         result.put("now", makeHkTime(now));
 
@@ -930,7 +931,7 @@ public class HkLeaveAuthServ extends Serv {
                 for (LeaveAuthItemRow itemRow : itemRowList) {
                     Map<String, Object> item;
                     try {
-                        item = executeLeaveAuthDeleteForItem(gdba, itemRow, false, true);
+                        item = executeLeaveAuthDeleteForItem(gdba, itemRow, false, true, overrideParm);
                     } catch (Exception e) {
                         log4j.error("HkLeaveAuthServ.recycleExpiredLeaveAuthResult() item删除异常,itemId={}", itemRow.itemId, e);
                         item = new LinkedHashMap<>();
@@ -1592,7 +1593,8 @@ public class HkLeaveAuthServ extends Serv {
     private static Map<String, Object> executeLeaveAuthDeleteForItem(Db gdba,
                                                                      LeaveAuthItemRow itemRow,
                                                                      boolean forceDelete,
-                                                                     boolean autoTrigger) throws Exception {
+                                                                     boolean autoTrigger,
+                                                                     Map<String, Object> overrideParm) throws Exception {
         Map<String, Object> result = new LinkedHashMap<>();
         result.put("ok", true);
         result.put("autoTrigger", autoTrigger);
@@ -1658,6 +1660,12 @@ public class HkLeaveAuthServ extends Serv {
             updLeaveAuthItemRow(gdba, itemRow.itemId, 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));