Browse Source

修复: 补齐海康请假条目补偿链路的tagId传参

1. 调整 HkLeaveAuthServ 条目级补偿链路,给 executePendingLeaveAuthItemSync 和 executePlatformConfigAddForItem 透传 overrideParm,并在 auth_config/add、auth_config/rate/search、auth_config/search 调用前统一按配置/环境变量/默认值解析 tagId。

2. 为条目级补偿结果补充 tagId 与 tagIdSource 诊断字段,消除正式环境服务内调用与手工探针在请求头口径上的差异,修复相同 personId + resourceInfos 下 rate/search 与 search 返回 0x15400001 param convert error 的问题。

3. 新增 docs/2026-06-16_海康请假补偿tagId缺失修复.md,记录两条排查方向、同参 A/B 探针证据、根因判断与预期效果。

4. 验证:已执行 javac -encoding UTF-8 -sourcepath src -cp '.;out/artifacts/PMS_war_exploded/WEB-INF/classes;out/artifacts/PMS_war_exploded/WEB-INF/lib/*' -d out/artifacts/PMS_war_exploded/WEB-INF/classes src/biz/kq/HkLeaveAuthServ.java,编译通过。
“gaohp” 5 months ago
parent
commit
969b1ef638

+ 132 - 0
docs/2026-06-16_海康请假补偿tagId缺失修复.md

@@ -0,0 +1,132 @@
+# 2026-06-16 海康请假补偿 tagId 缺失修复
+
+## 背景
+
+2026-06-16 正式环境继续排查 `hkkq_leave_auth_pending` 时发现,分钟补偿任务已经能正常选出待处理条目,但条目级海康确认阶段持续失败:
+
+- `auth_config/add` 返回 `code=0`
+- `auth_config/rate/search` 返回 `code=0x15400001`
+- `auth_config/search` 返回 `code=0x15400001`
+- 错误文案为 `param convert error`
+
+现场现象是:
+
+1. 手工独立探针对同一批学生、同一批设备资源可以成功
+2. 正式环境服务内自动补偿对同一批数据却失败
+
+这说明问题不在“学生、设备、时间窗本身无效”,而在“服务运行时实际请求参数”与“手工探针参数”存在差异。
+
+## 本次按两个方向复核
+
+### 1. 用正式环境同一批 `personId + resourceInfos` 重做独立探针
+
+以正式环境失败样本 `rcid=52111803`、`itemType=dorm_return_auth` 为例,直接取 `RCHKLA_ITEM` 内保存的真实资源集做 A/B 探针:
+
+- `personId = 12d6423eec2e46ae87977e312b83510e`
+- `resourceCount = 16`
+- `authBeg = 2026-06-15 18:00:00`
+- `authEnd = 2026-06-16 23:59:59`
+- 海康连接:`host=192.168.68.3`、`appKey=25723525`
+
+探针结果:
+
+1. 不传 `tagId`
+   - `auth_config/add` 成功
+   - `auth_config/rate/search` 失败,`0x15400001`
+   - `auth_config/search` 失败,`0x15400001`
+2. 传 `tagId=frs`
+   - `auth_config/add` 成功
+   - `auth_config/rate/search` 成功
+   - `auth_config/search` 成功
+   - `search total = 16`
+
+结论:同一条 `personId + resourceInfos`,是否带 `tagId` 会直接决定后续确认接口是否报 `param convert error`。
+
+### 2. 对比正式环境运行时参数与手工成功样本差异
+
+对比后发现:
+
+- `host` 一致
+- `appKey` 一致
+- `personId` 一致
+- `resourceInfos` 一致
+- 真正差异在于:正式环境条目级补偿链路未把 `tagId` 放入海康请求头,手工成功探针传了 `tagId=frs`
+
+进一步检查代码:
+
+- 正常主链路 `runPlatformConfigMode(...)` 会执行:
+  - `hkConnParm.put("tagId", tagId)`
+- 条目级补偿链路 `executePlatformConfigAddForItem(...)` 之前没有执行这一步
+
+这就解释了为什么:
+
+1. `auth_config/add` 还能受理
+2. 但后续 `auth_config/rate/search`、`auth_config/search` 在服务内会报 `param convert error`
+
+## 本次代码修复
+
+修复文件:`src/biz/kq/HkLeaveAuthServ.java`
+
+### 1. 条目级补偿下发链路补齐 `tagId`
+
+在 `executePlatformConfigAddForItem(...)` 中补齐:
+
+- 按统一口径读取 `tagId`
+  - 请求覆盖值 `overrideParm.tagId`
+  - 配置项 `hk.leaveAuth.tagId`
+  - 环境变量 `HK_LEAVE_AUTH_TAG_ID`
+  - 默认值 `frs`
+- 若非空,则写入 `hkConnParm`
+
+这样条目级补偿的以下接口会与正常主链路保持一致:
+
+- `/api/acps/v1/auth_config/add`
+- `/api/acps/v1/auth_config/rate/search`
+- `/api/acps/v1/auth_config/search`
+
+### 2. 条目级补偿链路回显真实 `tagId`
+
+同步把以下诊断字段写回结果:
+
+- `tagId`
+- `tagIdSource`
+
+后续正式环境再看 `hkkq_leave_auth_pending` 返回结果时,可以直接确认本次补偿到底用了哪个 `tagId`。
+
+### 3. 补偿入口透传覆盖参数
+
+为避免后续“手工诊断口径”和“正式服务口径”再次分叉,条目级补偿入口也统一透传 `overrideParm`:
+
+- 分钟任务执行时传 `makeReqOverrideParm()`
+- 销假后立即补偿时传 `Map.of()`
+
+这样既不影响正式环境默认执行,也保留了诊断页临时覆盖 `tagId` 的能力。
+
+## 影响范围
+
+本次只影响“条目级分钟补偿 / 条目级立即补偿”的海康调用参数,不改变以下逻辑:
+
+- 请假条目筛选规则
+- 资源集拆分规则
+- 校门与宿舍权限拆条规则
+- 回收 `auth_config/delete` 逻辑
+
+## 预期效果
+
+部署后,`hkkq_leave_auth_pending` 再处理同类条目时应出现以下变化:
+
+1. `authConfigRateResp.code` 不再是 `0x15400001`
+2. `authConfigSearchResp.code` 不再是 `0x15400001`
+3. 条目状态应能从 `accepted/pending` 继续推进到 `confirmed`
+4. `failedCount` 应下降
+
+## 本地验证
+
+已执行:
+
+- `javac -encoding UTF-8 -sourcepath src -cp '.;out/artifacts/PMS_war_exploded/WEB-INF/classes;out/artifacts/PMS_war_exploded/WEB-INF/lib/*' -d out/artifacts/PMS_war_exploded/WEB-INF/classes src/biz/kq/HkLeaveAuthServ.java`
+
+结果:
+
+- 编译通过
+- 仅有既有的未检查操作警告,无新增编译错误

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

@@ -164,7 +164,7 @@ public class HkLeaveAuthServ extends Serv {
                     Timestamp now = new Timestamp(System.currentTimeMillis());
                     if (!ifLeaveEnded(freshCtx.jssj, now) && ifLeaveStarted(freshCtx.kssj, now)) {
                         for (LeaveAuthItemRow newItemRow : selLeaveAuthItemRowList(itemGdba, rcid))
-                            executePendingLeaveAuthItemSync(newItemRow, now, 0);
+                            executePendingLeaveAuthItemSync(newItemRow, now, 0, Map.of());
                     }
                     return;
                 }
@@ -1046,7 +1046,7 @@ public class HkLeaveAuthServ extends Serv {
                 int skippedCount = 0;
                 int failedCount = 0;
                 for (LeaveAuthItemRow itemRow : itemRowList) {
-                    Map<String, Object> item = executePendingLeaveAuthItemSync(itemRow, now, retryDelaySeconds);
+                    Map<String, Object> item = executePendingLeaveAuthItemSync(itemRow, now, retryDelaySeconds, makeReqOverrideParm());
                     detailList.add(item);
 
                     if (rdBoolLike(item.get("platformConfigConfirmed")) || rdBoolLike(item.get("configSearchMatched"))) {
@@ -1226,7 +1226,8 @@ public class HkLeaveAuthServ extends Serv {
      */
     private static Map<String, Object> executePendingLeaveAuthItemSync(LeaveAuthItemRow itemRow,
                                                                        Timestamp now,
-                                                                       int retryDelaySeconds) {
+                                                                       int retryDelaySeconds,
+                                                                       Map<String, Object> overrideParm) {
         Map<String, Object> result = new LinkedHashMap<>();
         result.put("pendingAction", "search");
         result.put("retryDelaySeconds", retryDelaySeconds);
@@ -1287,7 +1288,7 @@ public class HkLeaveAuthServ extends Serv {
                 return result;
             }
 
-            Map<String, Object> runResult = executePlatformConfigAddForItem(gdba, ctx, itemRow, true);
+            Map<String, Object> runResult = executePlatformConfigAddForItem(gdba, ctx, itemRow, true, overrideParm);
             runResult.put("pendingAction", StringUtils.defaultIfBlank(rdStr(runResult.get("pendingAction")), "retryAdd"));
             updLeaveAuthItemRow(gdba, itemRow.itemId, runResult);
             gdba.commit();
@@ -2503,7 +2504,8 @@ public class HkLeaveAuthServ extends Serv {
     private static Map<String, Object> executePlatformConfigAddForItem(Db gdba,
                                                                        LeaveAuthSyncCtx ctx,
                                                                        LeaveAuthItemRow itemRow,
-                                                                       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);
@@ -2535,6 +2537,11 @@ public class HkLeaveAuthServ extends Serv {
             markLeaveAuthStagePending(result, ctx, "pending", new Timestamp(System.currentTimeMillis()), false, 0);
             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(