Эх сурвалжийг харах

补齐海康请假权限联调入口

“gaohp” 6 сар өмнө
parent
commit
d01a6a5e7a

+ 16 - 0
docs/2026-05-26_175030_hikvision_leave_auth_followup_report.md

@@ -0,0 +1,16 @@
+# 本轮目标
+在未拿到 `tagId`、`templateId` 前,把海康请假权限下发的后续联调能力补完整。
+
+# 修改内容
+- `HkLeaveAuthServ` 新增 `hkkq_leave_auth_result` 对应结果查询入口
+- 预览/诊断返回补充 `nextSteps`、`tagIdAdvice`、`templateIdAdvice`
+- 返回里直接回显真实下发接口和结果查询接口路径
+- 保留当前“缺配置不真实下发”的安全行为
+
+# 验证结果
+- 已检查服务名、方法名、关键返回字段引用一致
+- 修正了结果查询入口的同名方法冲突
+- 未做完整编译,当前工作区缺少项目依赖 classpath
+
+# 下一步
+等海康侧提供 `tagId` 和 `templateId` 后,先调 `hkkq_leave_auth_execute`,再调 `hkkq_leave_auth_result` 回查结果。

+ 80 - 0
src/biz/kq/HkLeaveAuthServ.java

@@ -96,6 +96,14 @@ public class HkLeaveAuthServ extends Serv {
         return ServC.SERV_notByA;
     }
 
+    /**
+     * 2026-05-26:手工查询特殊人员权限下发结果,便于拿到配置后快速回查海康任务状态。
+     */
+    public String viewLeaveAuthSyncResult() {
+        super.wrJsonByResp(viewLeaveAuthSyncResultData());
+        return ServC.SERV_notByA;
+    }
+
     /**
      * 2026-05-26:预览态统一走同一套组装逻辑,便于和真实下发保持一致。
      */
@@ -302,6 +310,53 @@ public class HkLeaveAuthServ extends Serv {
         }
     }
 
+    /**
+     * 2026-05-26:单独开放结果查询口,避免每次都必须先真实下发才能查看海康侧异步结果。
+     */
+    private Map<String, Object> viewLeaveAuthSyncResultData() {
+        long rcid = rdReqLongParm("rcid");
+        if (rcid <= 0) {
+            Map<String, Object> result = new LinkedHashMap<>();
+            result.put("ok", false);
+            result.put("msg", "缺少有效的 rcid 参数。");
+            return result;
+        }
+
+        Map<String, Object> overrideParm = makeReqOverrideParm();
+        try {
+            Map<String, Object> result = buildLeaveAuthSyncResult(rcid, false, overrideParm);
+            @SuppressWarnings("unchecked")
+            Map<String, Object> queryReq = (Map<String, Object>) result.get("authDownloadResultQueryReq");
+            if (queryReq == null) {
+                result.put("ok", false);
+                result.put("msg", "未能组装下发结果查询条件。");
+                return result;
+            }
+
+            Map<String, Object> hkConnParm = rdHkConnParm();
+            if (hkConnParm == null) {
+                result.put("ok", false);
+                result.put("msg", "缺少海康连接配置,请补齐 hk.host / hk.appKey / hk.appSecret。");
+                return result;
+            }
+
+            String tagId = rdCfgOrOverride(overrideParm, "tagId", CFG_TAG_ID, "HK_LEAVE_AUTH_TAG_ID");
+            if (StringUtils.isNotBlank(tagId))
+                hkConnParm.put("tagId", tagId);
+
+            result.put("mode", "viewResult");
+            result.put("authDownloadResultQueryResp",
+                    HK_API_CLIENT.viewSpecialPersonAuthDownloadResult(hkConnParm, queryReq));
+            return result;
+        } catch (Exception e) {
+            log4j.error("HkLeaveAuthServ.viewLeaveAuthSyncResultData() 异常,rcid={}", rcid, e);
+            Map<String, Object> result = new LinkedHashMap<>();
+            result.put("ok", false);
+            result.put("msg", e.getMessage());
+            return result;
+        }
+    }
+
     /**
      * 2026-05-26:统一组装请假权限同步结果,预览和真实执行共用这条链路。
      */
@@ -411,10 +466,16 @@ public class HkLeaveAuthServ extends Serv {
             if (StringUtils.isBlank(effectiveTemplateId))
                 missingCfgList.add("templateId");
             result.put("missingConfig", missingCfgList);
+            result.put("nextSteps", makeNextStepList(missingCfgList));
+            result.put("tagIdAdvice", "当前项目只做接口下发时,tagId 只要海康侧提供可用值即可;若还要求平台门禁管理可见,再评估是否改成 acs。");
+            result.put("templateIdAdvice", "templateId 需要海康侧在门禁权限模板中提供,当前 single/search 不能稳定自动探测。");
+            result.put("executeApiPath", "/artemis/api/acps/v1/authDownload/special/person/diy");
+            result.put("resultApiPath", "/artemis/api/acps/v1/authDownload/special/person/diy/result");
 
             Map<String, Object> payload = makeSpecialAuthPayload(
                     ctx, personInfo, personId, resourceInfoList, tagId, callbackUrl, effectiveTemplateId, templateDimension);
             result.put("payload", payload);
+            result.put("authDownloadResultQueryReq", makeAuthDownloadResultQueryReq(personId, resourceInfoList));
 
             if (StringUtils.isBlank(tagId) || StringUtils.isBlank(effectiveTemplateId)) {
                 result.put("skipReason", "缺少海康下发配置,暂不执行 special/person/diy。");
@@ -617,6 +678,25 @@ public class HkLeaveAuthServ extends Serv {
         return row;
     }
 
+    /**
+     * 2026-05-26:把当前缺少的配置转换成可执行的下一步,减少联调时反复口头确认。
+     */
+    private static List<String> makeNextStepList(List<String> missingCfgList) {
+        List<String> nextStepList = new ArrayList<>();
+        if (missingCfgList == null || missingCfgList.isEmpty()) {
+            nextStepList.add("已具备海康下发参数,可直接调用 hkkq_leave_auth_execute 做人工联调。");
+            nextStepList.add("下发后可调用 hkkq_leave_auth_result 查看海康侧结果。");
+            return nextStepList;
+        }
+        if (missingCfgList.contains("tagId"))
+            nextStepList.add("联系海康侧提供当前合作方账号可用的 tagId。");
+        if (missingCfgList.contains("templateId"))
+            nextStepList.add("联系海康侧提供门禁权限模板 templateId,或在平台门禁权限模板中确认后填写。");
+        nextStepList.add("配置补齐前可继续使用 hkkq_leave_auth_preview / hkkq_leave_auth_diag 做联调。");
+        nextStepList.add("配置补齐后先调用 hkkq_leave_auth_execute,再调用 hkkq_leave_auth_result 回查。");
+        return nextStepList;
+    }
+
     /**
      * 2026-05-26:single/search 需要“人员 + 单个门禁资源”的精确查询体。
      * 2026-05-26:这里按海康文档只传最小查询字段,不再把 channelIndexCodes 混进 single/search。

+ 1 - 0
web/cfg/biz/kq/hkkq.serv.xml

@@ -16,6 +16,7 @@
 	<serv name="hkkq_leave_auth_diag" desc="海康权限条目诊断" clazz="biz.kq.HkLeaveAuthServ" func="diagLeaveAuthItem" auth="true"/>
 	<serv name="hkkq_leave_auth_diag_template" desc="海康请假模板探测" clazz="biz.kq.HkLeaveAuthServ" func="diagLeaveAuthTemplateId" auth="true"/>
 	<serv name="hkkq_leave_auth_execute" desc="海康请假权限真实下发" clazz="biz.kq.HkLeaveAuthServ" func="executeLeaveAuthSync" auth="true"/>
+	<serv name="hkkq_leave_auth_result" desc="海康请假权限下发结果查询" clazz="biz.kq.HkLeaveAuthServ" func="viewLeaveAuthSyncResult" auth="true"/>
 	<serv name="hkkq_event_push" desc="海康事件订阅回调" clazz="biz.kq.HkKqServ" func="recvHkEventPush" pub="true"/>
 	<serv name="hkkq_timer_plan" desc="海康考勤定时计划" clazz="biz.kq.HkKqServ" func="runScheduledPlan" pub="true"/>
 </servs>