فهرست منبع

修复: 本地海康权限查询页列索引异常

1. 将 auth_config_search.jsp 切换到新的 HkAuthConfigSearchLocalV2U 实现,保留 HkAuthConfigSearchLocalU 作为兼容转发入口,避免本地 Tomcat 持续命中旧类缓存。

2. 修复本地查询 RCHKLA_ITEM 时使用 to_char('yyyy-mm-dd hh24:mi:ss') 导致 SqlCmd 误识别 :mi/:ss 命名参数的问题,改为直接查询时间字段;同时补充 implVersion、errorType、stackTrace 方便 JSP 排查时直接返回真实异常。

3. 补充使用说明文档,记录 V2 调用入口与本次列索引问题的修复结论。

4. 验证:已本地编译相关类,并通过 http://localhost:8082/auth_config_search.jsp?xm=麦云依 实测返回成功,查询到学生与最近权限项,auth_config/search 实时返回 code=0。
“gaohp” 5 ماه پیش
والد
کامیت
cdccb70fbf

+ 2 - 0
docs/2026-06-18_localhost_auth_config_search_jsp使用说明.md

@@ -53,6 +53,8 @@ http://localhost:8082/auth_config_search.jsp?name=麦云依
 ## 6. 备注
 
 - 该页面仅用于本地排查,不影响现有请假自动开门、定时补偿、权限回收等业务代码。
+- 当前 JSP 实际调用 `biz.kq.HkAuthConfigSearchLocalV2U`,旧的 `HkAuthConfigSearchLocalU` 仅保留为兼容转发入口。
+- 已修复本地查询 `RCHKLA_ITEM` 时因 `to_char(...hh24:mi:ss)` 被命名参数解析器误判而触发的“无效的列索引”问题。
 - 查询逻辑会:
   1. 先按学生姓名精确查询
   2. 精确无结果时,再按 `like` 查询

+ 2 - 319
src/biz/kq/HkAuthConfigSearchLocalU.java

@@ -1,331 +1,14 @@
 package biz.kq;
 
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import core.co.haikang.HkApiClient;
-import org.apache.commons.lang3.StringUtils;
-import ss.db.Db;
-import ss.db.SqlCmd;
-
-import java.sql.Timestamp;
-import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-
 /**
- * 本地 JSP 手工排查用。
- * 不接入现有 serv 路由,只提供“按学生姓名实时查询海康 auth_config/search”的独立能力。
+ * 兼容旧调用入口,统一转到最新实现。
  */
 public final class HkAuthConfigSearchLocalU {
 
-    private static final HkApiClient HK_API_CLIENT = new HkApiClient();
-    private static final Gson GSON = new GsonBuilder()
-            .setPrettyPrinting()
-            .disableHtmlEscaping()
-            .create();
-
-    private static final String DEF_TAG_ID = "frs";
-
     private HkAuthConfigSearchLocalU() {
     }
 
     public static String queryByStudentNameJson(String studentName) {
-        try {
-            return GSON.toJson(queryByStudentName(studentName));
-        } catch (Exception e) {
-            Map<String, Object> errorMap = new LinkedHashMap<>();
-            errorMap.put("ok", false);
-            errorMap.put("queryStudentName", StringUtils.trimToNull(studentName));
-            errorMap.put("error", e.getMessage());
-            return GSON.toJson(errorMap);
-        }
-    }
-
-    public static Map<String, Object> queryByStudentName(String studentName) throws Exception {
-        String name = StringUtils.trimToNull(studentName);
-
-        Map<String, Object> root = new LinkedHashMap<>();
-        root.put("queryStudentName", name);
-        root.put("queryTime", OffsetDateTime.now().toString());
-
-        Map<String, Object> hkConnParm = makeHkConnParm();
-        root.put("hkConnSummary", makeHkConnSummary(hkConnParm));
-
-        if (StringUtils.isBlank(name)) {
-            root.put("ok", false);
-            root.put("msg", "缺少学生姓名,请使用 ?xm=姓名 或 ?学生姓名=姓名 访问。");
-            root.put("studentCount", 0);
-            root.put("studentList", List.of());
-            return root;
-        }
-
-        try (Db gdba = Db.makeConn()) {
-            if (gdba == null) {
-                root.put("ok", false);
-                root.put("msg", "数据库连接失败,Db.makeConn() 返回 null。");
-                root.put("studentCount", 0);
-                root.put("studentList", List.of());
-                return root;
-            }
-
-            List<Map<String, Object>> studentList = loadStudentList(gdba, name);
-            String matchMode = "exact";
-            if (studentList.isEmpty()) {
-                studentList = loadStudentListLike(gdba, name);
-                matchMode = "like";
-            }
-
-            for (Map<String, Object> student : studentList) {
-                List<Map<String, Object>> itemList = loadLeaveAuthItemList(gdba, rdLong(student.get("ryid")));
-                for (Map<String, Object> item : itemList)
-                    fillAuthConfigSearchResult(hkConnParm, item);
-                student.put("leaveAuthItemCount", itemList.size());
-                student.put("leaveAuthItemList", itemList);
-            }
-
-            root.put("ok", true);
-            root.put("matchMode", matchMode);
-            root.put("studentCount", studentList.size());
-            root.put("studentList", studentList);
-            root.put("msg", studentList.isEmpty() ? "未查询到匹配学生。" : "查询成功。");
-            return root;
-        }
-    }
-
-    private static Map<String, Object> makeHkConnParm() {
-        Map<String, Object> hkConnParm = new LinkedHashMap<>(HkConnU.makeHkConnParm());
-        String tagId = rdCfg("hk.leaveAuth.tagId", "HK_LEAVE_AUTH_TAG_ID");
-        hkConnParm.put("tagId", StringUtils.defaultIfBlank(tagId, DEF_TAG_ID));
-        return hkConnParm;
-    }
-
-    private static Map<String, Object> makeHkConnSummary(Map<String, Object> hkConnParm) {
-        Map<String, Object> row = new LinkedHashMap<>();
-        row.put("host", hkConnParm.get("host"));
-        row.put("port", hkConnParm.get("port"));
-        row.put("appKey", hkConnParm.get("appKey"));
-        row.put("tagId", hkConnParm.get("tagId"));
-        return row;
-    }
-
-    private static List<Map<String, Object>> loadStudentList(Db gdba, String studentName) throws Exception {
-        String sql = ""
-                + "select ryid,xm,ryh,rylbm,jlztm,bmid "
-                + "from ry where xm=:xm order by ryid desc";
-        SqlCmd sqlCmd = new SqlCmd(sql);
-        sqlCmd.wrStrParm("xm", studentName);
-        return gdba.doSelMapListByC(sqlCmd);
-    }
-
-    private static List<Map<String, Object>> loadStudentListLike(Db gdba, String studentName) throws Exception {
-        String sql = ""
-                + "select ryid,xm,ryh,rylbm,jlztm,bmid "
-                + "from ry where xm like :xm order by ryid desc";
-        SqlCmd sqlCmd = new SqlCmd(sql);
-        sqlCmd.wrStrParm("xm", "%" + studentName + "%");
-        return gdba.doSelMapListByC(sqlCmd);
-    }
-
-    private static List<Map<String, Object>> loadLeaveAuthItemList(Db gdba, long ryid) throws Exception {
-        String sql = ""
-                + "select * from ("
-                + " select rc.rcid,rc.rclbm,to_char(rc.kssj,'yyyy-mm-dd hh24:mi:ss') kssj,"
-                + " to_char(rc.jssj,'yyyy-mm-dd hh24:mi:ss') jssj,"
-                + " i.item_id,i.item_type,i.item_name,i.resource_scope,i.resource_keys,i.person_id,"
-                + " to_char(i.auth_beg,'yyyy-mm-dd hh24:mi:ss') auth_beg,"
-                + " to_char(i.auth_end,'yyyy-mm-dd hh24:mi:ss') auth_end,"
-                + " i.sync_stage,i.platform_config_confirmed,i.config_search_matched,"
-                + " i.delete_confirmed,i.config_task_id,i.delete_task_id,"
-                + " to_char(i.delete_time,'yyyy-mm-dd hh24:mi:ss') delete_time,"
-                + " to_char(i.updated_at,'yyyy-mm-dd hh24:mi:ss') updated_at "
-                + " from rc rc"
-                + " join rchkla_item i on i.rcid=rc.rcid"
-                + " where rc.fzryid=:ryid"
-                + " order by i.updated_at desc nulls last,i.item_id desc"
-                + " ) where rownum<=20";
-        SqlCmd sqlCmd = new SqlCmd(sql);
-        sqlCmd.wrLongParm("ryid", ryid);
-        return gdba.doSelMapListByC(sqlCmd);
-    }
-
-    private static void fillAuthConfigSearchResult(Map<String, Object> hkConnParm,
-                                                   Map<String, Object> item) {
-        String personId = rdStr(item.get("person_id"));
-        String resourceKeys = rdStr(item.get("resource_keys"));
-        item.put("resourceKeyCount", makeAuthConfigResourceInfoList(resourceKeys).size());
-
-        if (StringUtils.isAnyBlank(personId, resourceKeys)) {
-            item.put("authConfigSearchSkipReason", "personId 或 resourceKeys 为空,跳过海康查询。");
-            return;
-        }
-
-        Map<String, Object> req = makeAuthConfigSearchReq(personId, resourceKeys);
-        item.put("authConfigSearchReq", req);
-        try {
-            Map<String, Object> resp = HK_API_CLIENT.searchAuthConfig(hkConnParm, req);
-            item.put("authConfigSearchResp", resp);
-            item.put("authConfigSearchRespBrief", makeSearchRespBrief(resp));
-            item.put("currentWindowCount", countAuthConfigWindow(
-                    resp,
-                    rdStr(item.get("auth_beg")),
-                    rdStr(item.get("auth_end")),
-                    true));
-            item.put("foreignWindowCount", countAuthConfigWindow(
-                    resp,
-                    rdStr(item.get("auth_beg")),
-                    rdStr(item.get("auth_end")),
-                    false));
-        } catch (Exception e) {
-            item.put("authConfigSearchError", e.getMessage());
-        }
-    }
-
-    private static Map<String, Object> makeAuthConfigSearchReq(String personId, String resourceKeys) {
-        List<Map<String, Object>> resourceInfoList = makeAuthConfigResourceInfoList(resourceKeys);
-        Map<String, Object> req = new LinkedHashMap<>();
-        req.put("personDataIds", List.of(personId));
-        req.put("personDataType", "person");
-        req.put("resourceInfos", resourceInfoList);
-        req.put("resourceDataType", "resource");
-        req.put("pageNo", 1);
-        req.put("pageSize", Math.max(20, Math.min(200, resourceInfoList.size())));
-        return req;
-    }
-
-    private static List<Map<String, Object>> makeAuthConfigResourceInfoList(String resourceKeys) {
-        LinkedHashSet<String> keySet = new LinkedHashSet<>();
-        if (resourceKeys != null) {
-            for (String part : resourceKeys.split("\\|")) {
-                String key = rdStr(part);
-                if (key != null)
-                    keySet.add(key);
-            }
-        }
-
-        List<Map<String, Object>> out = new ArrayList<>();
-        for (String key : keySet) {
-            int idx = key.lastIndexOf('#');
-            if (idx <= 0 || idx >= key.length() - 1)
-                continue;
-            String resourceIndexCode = key.substring(0, idx).trim();
-            int channelNo = rdChannelNo(key.substring(idx + 1));
-            Map<String, Object> row = new LinkedHashMap<>();
-            row.put("resourceIndexCode", resourceIndexCode);
-            row.put("resourceType", "acsDevice");
-            row.put("channelNos", List.of(channelNo));
-            out.add(row);
-        }
-        return out;
-    }
-
-    private static Map<String, Object> makeSearchRespBrief(Map<String, Object> resp) {
-        Map<String, Object> row = new LinkedHashMap<>();
-        row.put("code", resp == null ? null : resp.get("code"));
-        row.put("msg", resp == null ? null : resp.get("msg"));
-        Map<String, Object> dataMap = castMap(resp == null ? null : resp.get("data"));
-        if (dataMap != null) {
-            row.put("total", dataMap.get("total"));
-            row.put("pageNo", dataMap.get("pageNo"));
-            row.put("pageSize", dataMap.get("pageSize"));
-        }
-        return row;
-    }
-
-    private static int countAuthConfigWindow(Map<String, Object> resp,
-                                             String authBeg,
-                                             String authEnd,
-                                             boolean currentWindow) {
-        Map<String, Object> dataMap = castMap(resp == null ? null : resp.get("data"));
-        if (dataMap == null)
-            return 0;
-
-        Object listObj = dataMap.get("list");
-        if (!(listObj instanceof List<?> list))
-            return 0;
-
-        int count = 0;
-        for (Object itemObj : list) {
-            Map<String, Object> row = castMap(itemObj);
-            if (row == null)
-                continue;
-            boolean same = sameTime(rdStr(row.get("startTime")), authBeg)
-                    && sameTime(rdStr(row.get("endTime")), authEnd);
-            if (same == currentWindow)
-                count++;
-        }
-        return count;
-    }
-
-    private static boolean sameTime(String hkText, String dbText) {
-        LocalDateTime hkTime = parseHkTime(hkText);
-        LocalDateTime dbTime = parseDbTime(dbText);
-        return hkTime != null && dbTime != null && hkTime.equals(dbTime);
-    }
-
-    private static LocalDateTime parseHkTime(String text) {
-        try {
-            return OffsetDateTime.parse(text)
-                    .atZoneSameInstant(ZoneId.of("Asia/Shanghai"))
-                    .toLocalDateTime();
-        } catch (Exception ignored) {
-            return null;
-        }
-    }
-
-    private static LocalDateTime parseDbTime(String text) {
-        try {
-            return Timestamp.valueOf(text).toLocalDateTime();
-        } catch (Exception ignored) {
-            return null;
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private static Map<String, Object> castMap(Object obj) {
-        if (obj instanceof Map<?, ?> map)
-            return (Map<String, Object>) map;
-        return null;
-    }
-
-    private static int rdChannelNo(String text) {
-        try {
-            return Math.max(1, (int) Math.round(Double.parseDouble(StringUtils.trim(text))));
-        } catch (Exception ignored) {
-            return 1;
-        }
-    }
-
-    private static long rdLong(Object value) {
-        if (value == null)
-            return 0L;
-        if (value instanceof Number number)
-            return number.longValue();
-        try {
-            return Long.parseLong(String.valueOf(value).trim());
-        } catch (Exception ignored) {
-            return 0L;
-        }
-    }
-
-    private static String rdStr(Object value) {
-        if (value == null)
-            return null;
-        String text = String.valueOf(value).trim();
-        return text.isEmpty() ? null : text;
-    }
-
-    private static String rdCfg(String propName, String envName) {
-        String value = System.getProperty(propName);
-        if (StringUtils.isNotBlank(value))
-            return StringUtils.trim(value);
-        value = System.getenv(envName);
-        if (StringUtils.isNotBlank(value))
-            return StringUtils.trim(value);
-        return null;
+        return HkAuthConfigSearchLocalV2U.queryByStudentNameJson(studentName);
     }
 }

+ 357 - 0
src/biz/kq/HkAuthConfigSearchLocalV2U.java

@@ -0,0 +1,357 @@
+package biz.kq;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import core.co.haikang.HkApiClient;
+import org.apache.commons.lang3.StringUtils;
+import ss.db.Db;
+import ss.db.SqlCmd;
+
+import java.sql.Timestamp;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 本地 JSP 手工排查用。
+ * 不接入现有 serv 路由,只提供“按学生姓名实时查询海康 auth_config/search”的独立能力。
+ */
+public final class HkAuthConfigSearchLocalV2U {
+
+    private static final HkApiClient HK_API_CLIENT = new HkApiClient();
+    private static final Gson GSON = new GsonBuilder()
+            .setPrettyPrinting()
+            .disableHtmlEscaping()
+            .create();
+
+    private static final String DEF_TAG_ID = "frs";
+
+    private HkAuthConfigSearchLocalV2U() {
+    }
+
+    public static String queryByStudentNameJson(String studentName) {
+        try {
+            return GSON.toJson(queryByStudentName(studentName));
+        } catch (Exception e) {
+            Map<String, Object> errorMap = new LinkedHashMap<>();
+            errorMap.put("ok", false);
+            errorMap.put("implVersion", "2026-06-18-v2");
+            errorMap.put("queryStudentName", StringUtils.trimToNull(studentName));
+            errorMap.put("errorType", e.getClass().getName());
+            errorMap.put("error", e.getMessage());
+            errorMap.put("stackTrace", makeStackTrace(e));
+            return GSON.toJson(errorMap);
+        }
+    }
+
+    public static Map<String, Object> queryByStudentName(String studentName) throws Exception {
+        String name = StringUtils.trimToNull(studentName);
+
+        Map<String, Object> root = new LinkedHashMap<>();
+        root.put("implVersion", "2026-06-18-v2");
+        root.put("queryStudentName", name);
+        root.put("queryTime", OffsetDateTime.now().toString());
+
+        Map<String, Object> hkConnParm = makeHkConnParm();
+        root.put("hkConnSummary", makeHkConnSummary(hkConnParm));
+
+        if (StringUtils.isBlank(name)) {
+            root.put("ok", false);
+            root.put("msg", "缺少学生姓名,请使用 ?xm=姓名 或 ?学生姓名=姓名 访问。");
+            root.put("studentCount", 0);
+            root.put("studentList", List.of());
+            return root;
+        }
+
+        try (Db gdba = Db.makeConn()) {
+            if (gdba == null) {
+                root.put("ok", false);
+                root.put("msg", "数据库连接失败,Db.makeConn() 返回 null。");
+                root.put("studentCount", 0);
+                root.put("studentList", List.of());
+                return root;
+            }
+
+            List<Map<String, Object>> studentList = loadStudentList(gdba, name);
+            String matchMode = "exact";
+            if (studentList.isEmpty()) {
+                studentList = loadStudentListLike(gdba, name);
+                matchMode = "like";
+            }
+
+            for (Map<String, Object> student : studentList) {
+                long ryid = rdLong(student.get("ryid"));
+                List<Map<String, Object>> itemList = loadLeaveAuthItemList(gdba, ryid);
+                for (Map<String, Object> item : itemList)
+                    fillAuthConfigSearchResult(hkConnParm, item);
+                student.put("leaveAuthItemCount", itemList.size());
+                student.put("leaveAuthItemList", itemList);
+            }
+
+            root.put("ok", true);
+            root.put("matchMode", matchMode);
+            root.put("studentCount", studentList.size());
+            root.put("studentList", studentList);
+            root.put("msg", studentList.isEmpty() ? "未查询到匹配学生。" : "查询成功。");
+            return root;
+        }
+    }
+
+    private static Map<String, Object> makeHkConnParm() {
+        Map<String, Object> hkConnParm = new LinkedHashMap<>(HkConnU.makeHkConnParm());
+        String tagId = rdCfg("hk.leaveAuth.tagId", "HK_LEAVE_AUTH_TAG_ID");
+        hkConnParm.put("tagId", StringUtils.defaultIfBlank(tagId, DEF_TAG_ID));
+        return hkConnParm;
+    }
+
+    private static Map<String, Object> makeHkConnSummary(Map<String, Object> hkConnParm) {
+        Map<String, Object> row = new LinkedHashMap<>();
+        row.put("host", hkConnParm.get("host"));
+        row.put("port", hkConnParm.get("port"));
+        row.put("appKey", hkConnParm.get("appKey"));
+        row.put("tagId", hkConnParm.get("tagId"));
+        return row;
+    }
+
+    private static List<Map<String, Object>> loadStudentList(Db gdba, String studentName) throws Exception {
+        String sql = ""
+                + "select ryid,xm,ryh,rylbm,jlztm,bmid "
+                + "from ry where xm=:xm order by ryid desc";
+        SqlCmd sqlCmd = new SqlCmd(sql);
+        sqlCmd.wrStrParm("xm", studentName);
+        try {
+            return gdba.doSelMapListByC(sqlCmd);
+        } catch (Exception e) {
+            throw new RuntimeException("loadStudentList 执行失败,xm=" + studentName, e);
+        }
+    }
+
+    private static List<Map<String, Object>> loadStudentListLike(Db gdba, String studentName) throws Exception {
+        String sql = ""
+                + "select ryid,xm,ryh,rylbm,jlztm,bmid "
+                + "from ry where xm like :xm order by ryid desc";
+        SqlCmd sqlCmd = new SqlCmd(sql);
+        sqlCmd.wrStrParm("xm", "%" + studentName + "%");
+        try {
+            return gdba.doSelMapListByC(sqlCmd);
+        } catch (Exception e) {
+            throw new RuntimeException("loadStudentListLike 执行失败,xm=" + studentName, e);
+        }
+    }
+
+    private static List<Map<String, Object>> loadLeaveAuthItemList(Db gdba, long ryid) throws Exception {
+        String sql = ""
+                + "select * from ("
+                + " select rc.rcid,rc.rclbm,rc.kssj,rc.jssj,"
+                + " i.item_id,i.item_type,i.item_name,i.resource_scope,i.resource_keys,i.person_id,"
+                + " i.auth_beg,i.auth_end,"
+                + " i.sync_stage,i.platform_config_confirmed,i.config_search_matched,"
+                + " i.delete_confirmed,i.config_task_id,i.delete_task_id,"
+                + " i.delete_time,i.updated_at "
+                + " from rc rc"
+                + " join rchkla_item i on i.rcid=rc.rcid"
+                + " where rc.fzryid=:ryid"
+                + " order by i.updated_at desc nulls last,i.item_id desc"
+                + " ) where rownum<=20";
+        SqlCmd sqlCmd = new SqlCmd(sql);
+        sqlCmd.wrLongParm("ryid", ryid);
+        try {
+            return gdba.doSelMapListByC(sqlCmd);
+        } catch (Exception e) {
+            throw new RuntimeException("loadLeaveAuthItemList 执行失败,ryid=" + ryid, e);
+        }
+    }
+
+    private static void fillAuthConfigSearchResult(Map<String, Object> hkConnParm,
+                                                   Map<String, Object> item) {
+        String personId = rdStr(item.get("person_id"));
+        String resourceKeys = rdStr(item.get("resource_keys"));
+        item.put("resourceKeyCount", makeAuthConfigResourceInfoList(resourceKeys).size());
+
+        if (StringUtils.isAnyBlank(personId, resourceKeys)) {
+            item.put("authConfigSearchSkipReason", "personId 或 resourceKeys 为空,跳过海康查询。");
+            return;
+        }
+
+        Map<String, Object> req = makeAuthConfigSearchReq(personId, resourceKeys);
+        item.put("authConfigSearchReq", req);
+        try {
+            Map<String, Object> resp = HK_API_CLIENT.searchAuthConfig(hkConnParm, req);
+            item.put("authConfigSearchResp", resp);
+            item.put("authConfigSearchRespBrief", makeSearchRespBrief(resp));
+            item.put("currentWindowCount", countAuthConfigWindow(
+                    resp,
+                    rdStr(item.get("auth_beg")),
+                    rdStr(item.get("auth_end")),
+                    true));
+            item.put("foreignWindowCount", countAuthConfigWindow(
+                    resp,
+                    rdStr(item.get("auth_beg")),
+                    rdStr(item.get("auth_end")),
+                    false));
+        } catch (Exception e) {
+            item.put("authConfigSearchError", e.getMessage());
+        }
+    }
+
+    private static Map<String, Object> makeAuthConfigSearchReq(String personId, String resourceKeys) {
+        List<Map<String, Object>> resourceInfoList = makeAuthConfigResourceInfoList(resourceKeys);
+        Map<String, Object> req = new LinkedHashMap<>();
+        req.put("personDataIds", List.of(personId));
+        req.put("personDataType", "person");
+        req.put("resourceInfos", resourceInfoList);
+        req.put("resourceDataType", "resource");
+        req.put("pageNo", 1);
+        req.put("pageSize", Math.max(20, Math.min(200, resourceInfoList.size())));
+        return req;
+    }
+
+    private static List<Map<String, Object>> makeAuthConfigResourceInfoList(String resourceKeys) {
+        LinkedHashSet<String> keySet = new LinkedHashSet<>();
+        if (resourceKeys != null) {
+            for (String part : resourceKeys.split("\\|")) {
+                String key = rdStr(part);
+                if (key != null)
+                    keySet.add(key);
+            }
+        }
+
+        List<Map<String, Object>> out = new ArrayList<>();
+        for (String key : keySet) {
+            int idx = key.lastIndexOf('#');
+            if (idx <= 0 || idx >= key.length() - 1)
+                continue;
+            String resourceIndexCode = key.substring(0, idx).trim();
+            int channelNo = rdChannelNo(key.substring(idx + 1));
+            Map<String, Object> row = new LinkedHashMap<>();
+            row.put("resourceIndexCode", resourceIndexCode);
+            row.put("resourceType", "acsDevice");
+            row.put("channelNos", List.of(channelNo));
+            out.add(row);
+        }
+        return out;
+    }
+
+    private static Map<String, Object> makeSearchRespBrief(Map<String, Object> resp) {
+        Map<String, Object> row = new LinkedHashMap<>();
+        row.put("code", resp == null ? null : resp.get("code"));
+        row.put("msg", resp == null ? null : resp.get("msg"));
+        Map<String, Object> dataMap = castMap(resp == null ? null : resp.get("data"));
+        if (dataMap != null) {
+            row.put("total", dataMap.get("total"));
+            row.put("pageNo", dataMap.get("pageNo"));
+            row.put("pageSize", dataMap.get("pageSize"));
+        }
+        return row;
+    }
+
+    private static int countAuthConfigWindow(Map<String, Object> resp,
+                                             String authBeg,
+                                             String authEnd,
+                                             boolean currentWindow) {
+        Map<String, Object> dataMap = castMap(resp == null ? null : resp.get("data"));
+        if (dataMap == null)
+            return 0;
+
+        Object listObj = dataMap.get("list");
+        if (!(listObj instanceof List<?> list))
+            return 0;
+
+        int count = 0;
+        for (Object itemObj : list) {
+            Map<String, Object> row = castMap(itemObj);
+            if (row == null)
+                continue;
+            boolean same = sameTime(rdStr(row.get("startTime")), authBeg)
+                    && sameTime(rdStr(row.get("endTime")), authEnd);
+            if (same == currentWindow)
+                count++;
+        }
+        return count;
+    }
+
+    private static boolean sameTime(String hkText, String dbText) {
+        LocalDateTime hkTime = parseHkTime(hkText);
+        LocalDateTime dbTime = parseDbTime(dbText);
+        return hkTime != null && dbTime != null && hkTime.equals(dbTime);
+    }
+
+    private static LocalDateTime parseHkTime(String text) {
+        try {
+            return OffsetDateTime.parse(text)
+                    .atZoneSameInstant(ZoneId.of("Asia/Shanghai"))
+                    .toLocalDateTime();
+        } catch (Exception ignored) {
+            return null;
+        }
+    }
+
+    private static LocalDateTime parseDbTime(String text) {
+        try {
+            return Timestamp.valueOf(text).toLocalDateTime();
+        } catch (Exception ignored) {
+            return null;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Map<String, Object> castMap(Object obj) {
+        if (obj instanceof Map<?, ?> map)
+            return (Map<String, Object>) map;
+        return null;
+    }
+
+    private static int rdChannelNo(String text) {
+        try {
+            return Math.max(1, (int) Math.round(Double.parseDouble(StringUtils.trim(text))));
+        } catch (Exception ignored) {
+            return 1;
+        }
+    }
+
+    private static long rdLong(Object value) {
+        if (value == null)
+            return 0L;
+        if (value instanceof Number number)
+            return number.longValue();
+        try {
+            return Long.parseLong(String.valueOf(value).trim());
+        } catch (Exception ignored) {
+            return 0L;
+        }
+    }
+
+    private static String rdStr(Object value) {
+        if (value == null)
+            return null;
+        String text = String.valueOf(value).trim();
+        return text.isEmpty() ? null : text;
+    }
+
+    private static String rdCfg(String propName, String envName) {
+        String value = System.getProperty(propName);
+        if (StringUtils.isNotBlank(value))
+            return StringUtils.trim(value);
+        value = System.getenv(envName);
+        if (StringUtils.isNotBlank(value))
+            return StringUtils.trim(value);
+        return null;
+    }
+
+    private static String makeStackTrace(Throwable e) {
+        if (e == null)
+            return null;
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        e.printStackTrace(pw);
+        pw.flush();
+        return sw.toString();
+    }
+}

+ 2 - 2
web/auth_config_search.jsp

@@ -1,5 +1,5 @@
 <%@ page contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>
-<%@ page import="biz.kq.HkAuthConfigSearchLocalU" %>
+<%@ page import="biz.kq.HkAuthConfigSearchLocalV2U" %>
 <%@ page import="org.apache.commons.lang3.StringUtils" %>
 <%
 request.setCharacterEncoding("UTF-8");
@@ -11,5 +11,5 @@ if (StringUtils.isBlank(studentName))
 if (StringUtils.isBlank(studentName))
     studentName = request.getParameter("name");
 
-out.write(HkAuthConfigSearchLocalU.queryByStudentNameJson(studentName));
+out.write(HkAuthConfigSearchLocalV2U.queryByStudentNameJson(studentName));
 %>