Bläddra i källkod

调整: 提交菜单图标与海康排查资产基线

1. 提交 MenuServ 的业务图标名映射调整,为住宿相关菜单补充专用图标编码,并同步纳入 iconfont.css 与字体资源更新。

2. 新增 .codex 下的 hikvision-clear-expired-person-auth skill,包括排查流程说明、agent 元信息和一键清理残留个人权限的 Java 模板,便于后续复用海康排查能力。

3. 新增 docs/2026-07-24_海康人脸照片样本规格分析.md,沉淀海康平台人脸照片下载链路与 480x640 JPEG 规格样本基线。

4. 影响范围:仅提交当前工作区中明确可复用的源码、图标资源、skill 与文档;未纳入 tmp、数据库导出包、Tomcat 运行目录等临时产物。

5. 验证:未执行自动化测试,仅完成 staged diff 复核与文件级内容核对。
“gaohp” 4 månader sedan
förälder
incheckning
5a644f82e9

+ 107 - 0
.codex/skills/hikvision-clear-expired-person-auth/SKILL.md

@@ -0,0 +1,107 @@
+---
+name: hikvision-clear-expired-person-auth
+description: Clear stale Hikvision personal auth_config permissions left behind by historical leave records. Use when a student shows expired permission or cannot enter/exit after a leave has already ended, especially when PMS and Hikvision organization status look normal but auth_config/search may still return an old personal time window. This skill is for confirming a residual personal permission window, deleting it with auth_config/delete, and re-checking that auth_config/search returns zero.
+---
+
+# Hikvision Clear Expired Person Auth
+
+Use this skill when the likely problem is a historical personal leave permission that was never recycled on Hikvision.
+
+## Workflow
+
+1. Identify the student and the target historical leave window.
+2. Confirm the student is not failing because of a current leave still in effect.
+3. Confirm Hikvision still returns the exact old personal time window through `auth_config/search`.
+4. Delete only that exact expired window's resources through `auth_config/delete`.
+5. Re-run `auth_config/search` and require the matched count to become `0`.
+
+## Required Evidence
+
+Collect these before deleting:
+
+- `RYID`
+- `XM`
+- `RYH`
+- Hikvision `personId`
+- target `RCID`
+- leave time window `KSSJ ~ JSSJ`
+- the current `auth_config/search` result proving the exact old window still exists
+
+Do not delete if:
+
+- the time window has not ended yet
+- search returns multiple unrelated windows and you have not isolated the exact expired one
+- the student issue is clearly caused by current organization permission or field device problems instead
+
+## Preferred Approach
+
+Prefer a one-off Java probe in the project `tmp/` directory that:
+
+1. reads the historical leave resource set from `RCHKLA.RESOURCE_KEYS` or `RCHKLA_ITEM.RESOURCE_KEYS`
+2. uses the student's Hikvision `personId`
+3. calls `auth_config/search`
+4. filters rows by exact `startTime/endTime`
+5. builds `resourceInfos` only from the matched rows
+6. calls `auth_config/delete`
+7. polls `auth_config/search` until the matched row count becomes `0`
+
+This is safer than deleting by a broad all-device search result without filtering the exact window.
+
+## Reusable Scripts
+
+Read these project scripts first and copy the nearest one into a new one-off probe:
+
+- `tmp/prod_delete_lusiyu_expired_auth_probe.java`
+- `tmp/prod_delete_yuanweiqi_expired_auth_probe.java`
+- `tmp/prod_delete_two_students_expired_auth_probe.java`
+
+Use `prod_delete_lusiyu_expired_auth_probe.java` as the default starting point for a single student.
+
+## Minimal Edit Points
+
+When cloning a probe, normally only change these constants:
+
+```java
+private static final String XM = "学生姓名";
+private static final String PERSON_ID = "海康personId";
+private static final String EXPECT_BEG = "yyyy-MM-dd HH:mm:ss";
+private static final String EXPECT_END = "yyyy-MM-dd HH:mm:ss";
+```
+
+If the resource set comes from a head-only old record, keep loading `resource_keys` from `RCHKLA`.
+
+If the record already has `RCHKLA_ITEM`, prefer the item-level `resource_keys`.
+
+## Compile And Run
+
+From the PMS project root:
+
+```powershell
+javac -cp 'tmp;.;out\artifacts\PMS_war_exploded\WEB-INF\lib\*' 'tmp\your_probe.java'
+java -cp 'tmp;.;out\artifacts\PMS_war_exploded\WEB-INF\lib\*' your_probe
+```
+
+## Success Criteria
+
+Deletion is only considered successful if all of these hold:
+
+- `auth_config/delete` returns `code=0` or an accepted `taskId`
+- the post-delete `auth_config/search` exact-window matched count is `0`
+- the result clearly states the residual personal permission has been cleared
+
+## Output Pattern
+
+Report in this order:
+
+1. Student identity and `personId`
+2. Historical leave `RCID` and expired window
+3. Search-before matched count
+4. Delete acceptance result and `taskId`
+5. Search-after matched count
+6. Clear conclusion: residual permission cleared / not cleared
+
+## Notes
+
+- This skill is only for expired personal leave permissions.
+- It does not fix organization-level normal access permissions.
+- If the student is a resident student in both PMS and Hikvision organization data, but still fails and an expired personal window exists, clear the residual window first before escalating elsewhere.

+ 4 - 0
.codex/skills/hikvision-clear-expired-person-auth/agents/openai.yaml

@@ -0,0 +1,4 @@
+interface:
+  display_name: "海康残留权限清理"
+  short_description: "清除海康历史残留个人权限并回查"
+  default_prompt: "Use $hikvision-clear-expired-person-auth to confirm and clear a student's expired Hikvision personal leave permission."

+ 294 - 0
.codex/skills/hikvision-clear-expired-person-auth/scripts/delete_expired_person_auth_template.java

@@ -0,0 +1,294 @@
+import com.google.gson.Gson;
+import core.co.haikang.HkApiClient;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+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;
+import java.util.Set;
+
+public class delete_expired_person_auth_template {
+    private static final String JDBC_URL = "jdbc:oracle:thin:@192.168.69.26:31521/ORCLPDB";
+    private static final String JDBC_USER = "C##DC";
+    private static final String JDBC_PWD = "6bcb4bd7bbhbgz9cb44";
+
+    private static final String HK_HOST = "192.168.68.3";
+    private static final int HK_PORT = 443;
+    private static final String HK_APP_KEY = "25723525";
+    private static final String HK_APP_SECRET = "V8KVC0McdY5KVARbIpQv";
+    private static final String HK_TAG_ID = "frs";
+    private static final ZoneId HK_ZONE = ZoneId.of("Asia/Shanghai");
+
+    private static final long TARGET_RCID = 0L;
+    private static final String XM = "学生姓名";
+    private static final String PERSON_ID = "海康personId";
+    private static final String EXPECT_BEG = "yyyy-MM-dd HH:mm:ss";
+    private static final String EXPECT_END = "yyyy-MM-dd HH:mm:ss";
+    private static final boolean LOAD_RESOURCE_KEYS_FROM_HEAD = true;
+
+    public static void main(String[] args) throws Exception {
+        HkApiClient client = new HkApiClient();
+        Map<String, Object> hkConn = makeHkConn();
+        List<Map<String, Object>> searchResourceInfos = loadSearchResourceInfos();
+
+        Map<String, Object> root = new LinkedHashMap<>();
+        root.put("xm", XM);
+        root.put("personId", PERSON_ID);
+        root.put("targetRcid", TARGET_RCID);
+        root.put("expectBeg", EXPECT_BEG);
+        root.put("expectEnd", EXPECT_END);
+
+        Map<String, Object> beforeReq = makeSearchReq(PERSON_ID, searchResourceInfos);
+        Map<String, Object> beforeResp = client.searchAuthConfig(hkConn, beforeReq);
+        List<Map<String, Object>> beforeRowList = extractMatchedRows(beforeResp, PERSON_ID, EXPECT_BEG, EXPECT_END);
+        root.put("beforeSearchRespBrief", makeRespBrief(beforeResp));
+        root.put("beforeMatchedCount", beforeRowList.size());
+
+        if (beforeRowList.isEmpty()) {
+            root.put("deleted", false);
+            root.put("skipReason", "searchMatchedEmpty");
+            root.put("msg", "未查到该历史时间窗残留,无需删除。");
+            System.out.println(new Gson().toJson(root));
+            return;
+        }
+
+        String endTimeText = str(beforeRowList.get(0).get("endTime"));
+        LocalDateTime endTime = parseAuthTime(endTimeText);
+        if (endTime == null || !endTime.isBefore(LocalDateTime.now(HK_ZONE))) {
+            root.put("deleted", false);
+            root.put("skipReason", "windowNotExpired");
+            root.put("msg", "当前时间窗未过期,停止自动删除。");
+            System.out.println(new Gson().toJson(root));
+            return;
+        }
+
+        List<Map<String, Object>> deleteResourceInfos = buildDeleteResourceInfos(beforeRowList);
+        Map<String, Object> deleteReq = makeDeleteReq(PERSON_ID, deleteResourceInfos);
+        Map<String, Object> deleteResp = client.deleteAuthConfig(hkConn, deleteReq);
+        root.put("deleteResp", deleteResp);
+        root.put("deleteAccepted", isAccepted(deleteResp));
+
+        Map<String, Object> afterReq = makeSearchReq(PERSON_ID, deleteResourceInfos);
+        Map<String, Object> afterResp = null;
+        List<Map<String, Object>> afterRowList = List.of();
+        for (int i = 0; i < 6; i++) {
+            if (i > 0)
+                Thread.sleep(2000L);
+            afterResp = client.searchAuthConfig(hkConn, afterReq);
+            afterRowList = extractMatchedRows(afterResp, PERSON_ID, EXPECT_BEG, EXPECT_END);
+            if (afterRowList.isEmpty())
+                break;
+        }
+
+        root.put("afterSearchRespBrief", makeRespBrief(afterResp));
+        root.put("afterMatchedCount", afterRowList.size());
+        root.put("deleted", afterRowList.isEmpty());
+        root.put("msg", afterRowList.isEmpty() ? "历史残留权限已清空。" : "delete 已执行,但该历史时间窗仍有残留。");
+        System.out.println(new Gson().toJson(root));
+    }
+
+    private static List<Map<String, Object>> loadSearchResourceInfos() throws Exception {
+        String sql = LOAD_RESOURCE_KEYS_FROM_HEAD
+                ? "select resource_keys from rchkla where rcid=?"
+                : "select resource_keys from rchkla_item where rcid=? order by item_id fetch first 1 rows only";
+        try (Connection conn = DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PWD);
+             PreparedStatement ps = conn.prepareStatement(sql)) {
+            ps.setLong(1, TARGET_RCID);
+            try (ResultSet rs = ps.executeQuery()) {
+                if (!rs.next())
+                    return List.of();
+                return parseResourceInfos(rs.getString(1));
+            }
+        }
+    }
+
+    private static List<Map<String, Object>> parseResourceInfos(String resourceKeys) {
+        Set<String> keySet = new LinkedHashSet<>();
+        if (resourceKeys != null) {
+            for (String part : resourceKeys.split("\\|")) {
+                String key = str(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 = readChannelNo(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> makeHkConn() {
+        Map<String, Object> row = new LinkedHashMap<>();
+        row.put("host", HK_HOST);
+        row.put("port", HK_PORT);
+        row.put("appKey", HK_APP_KEY);
+        row.put("appSecret", HK_APP_SECRET);
+        row.put("tagId", HK_TAG_ID);
+        return row;
+    }
+
+    private static Map<String, Object> makeSearchReq(String personId, List<Map<String, Object>> resourceInfos) {
+        Map<String, Object> req = new LinkedHashMap<>();
+        req.put("personDataIds", List.of(personId));
+        req.put("personDataType", "person");
+        req.put("resourceInfos", resourceInfos);
+        req.put("resourceDataType", "resource");
+        req.put("pageNo", 1);
+        req.put("pageSize", 200);
+        return req;
+    }
+
+    private static Map<String, Object> makeDeleteReq(String personId, List<Map<String, Object>> resourceInfos) {
+        Map<String, Object> personData = new LinkedHashMap<>();
+        personData.put("indexCodes", List.of(personId));
+        personData.put("personDataType", "person");
+
+        Map<String, Object> req = new LinkedHashMap<>();
+        req.put("personDatas", List.of(personData));
+        req.put("resourceInfos", resourceInfos);
+        return req;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static boolean isAccepted(Map<String, Object> resp) {
+        if (resp == null)
+            return false;
+        if ("0".equals(String.valueOf(resp.get("code"))))
+            return true;
+        Object dataObj = resp.get("data");
+        if (!(dataObj instanceof Map<?, ?> dataMap))
+            return false;
+        Object taskId = ((Map<String, Object>) dataMap).get("taskId");
+        return taskId != null && !String.valueOf(taskId).isBlank();
+    }
+
+    @SuppressWarnings("unchecked")
+    private static List<Map<String, Object>> extractMatchedRows(Map<String, Object> resp,
+                                                                String personId,
+                                                                String authBeg,
+                                                                String authEnd) {
+        Object dataObj = resp == null ? null : resp.get("data");
+        if (!(dataObj instanceof Map<?, ?> dataMap))
+            return List.of();
+        Object listObj = ((Map<String, Object>) dataMap).get("list");
+        if (!(listObj instanceof List<?> list))
+            return List.of();
+
+        List<Map<String, Object>> out = new ArrayList<>();
+        for (Object item : list) {
+            if (!(item instanceof Map<?, ?> raw))
+                continue;
+            Map<String, Object> row = (Map<String, Object>) raw;
+            if (!personId.equals(str(row.get("personDataId"))))
+                continue;
+            if (!"person".equalsIgnoreCase(str(row.get("personDataType"))))
+                continue;
+            if (!sameTime(str(row.get("startTime")), authBeg) || !sameTime(str(row.get("endTime")), authEnd))
+                continue;
+            out.add(row);
+        }
+        return out;
+    }
+
+    private static List<Map<String, Object>> buildDeleteResourceInfos(List<Map<String, Object>> rowList) {
+        Set<String> keySet = new LinkedHashSet<>();
+        List<Map<String, Object>> out = new ArrayList<>();
+        for (Map<String, Object> row : rowList) {
+            String resourceIndexCode = str(row.get("resourceIndexCode"));
+            int channelNo = readChannelNo(row.get("channelNo"));
+            if (resourceIndexCode == null)
+                continue;
+            String key = resourceIndexCode + "#" + channelNo;
+            if (!keySet.add(key))
+                continue;
+            Map<String, Object> item = new LinkedHashMap<>();
+            item.put("resourceIndexCode", resourceIndexCode);
+            item.put("resourceType", str(row.get("resourceType")) == null ? "acsDevice" : str(row.get("resourceType")));
+            item.put("channelNos", List.of(channelNo));
+            out.add(item);
+        }
+        return out;
+    }
+
+    private static Map<String, Object> makeRespBrief(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"));
+        Object dataObj = resp == null ? null : resp.get("data");
+        if (dataObj instanceof Map<?, ?> dataMap) {
+            row.put("total", ((Map<?, ?>) dataMap).get("total"));
+            row.put("pageNo", ((Map<?, ?>) dataMap).get("pageNo"));
+            row.put("pageSize", ((Map<?, ?>) dataMap).get("pageSize"));
+        }
+        return row;
+    }
+
+    private static boolean sameTime(String hkText, String dbText) {
+        LocalDateTime hk = parseAuthTime(hkText);
+        LocalDateTime db = parseDbTime(dbText);
+        return hk != null && db != null && hk.equals(db);
+    }
+
+    private static LocalDateTime parseAuthTime(String text) {
+        String value = str(text);
+        if (value == null)
+            return null;
+        try {
+            return OffsetDateTime.parse(value).atZoneSameInstant(HK_ZONE).toLocalDateTime();
+        } catch (Exception ignored) {
+            return null;
+        }
+    }
+
+    private static LocalDateTime parseDbTime(String text) {
+        String value = str(text);
+        if (value == null)
+            return null;
+        try {
+            return java.sql.Timestamp.valueOf(value).toLocalDateTime();
+        } catch (Exception ignored) {
+            return null;
+        }
+    }
+
+    private static int readChannelNo(Object value) {
+        if (value instanceof Number number) {
+            int channelNo = number.intValue();
+            return channelNo > 0 ? channelNo : 1;
+        }
+        String text = str(value);
+        if (text == null)
+            return 1;
+        try {
+            int channelNo = (int) Math.round(Double.parseDouble(text));
+            return channelNo > 0 ? channelNo : 1;
+        } catch (Exception ignored) {
+            return 1;
+        }
+    }
+
+    private static String str(Object value) {
+        if (value == null)
+            return null;
+        String text = String.valueOf(value).trim();
+        return text.isEmpty() ? null : text;
+    }
+}

+ 47 - 0
docs/2026-07-24_海康人脸照片样本规格分析.md

@@ -0,0 +1,47 @@
+# 海康人脸照片样本规格分析
+
+日期:2026-07-24
+
+## 1. 说明
+
+本次从海康平台中抽取了 6 位学生的人脸照片样本,下载链路为:
+
+1. 通过海康人员接口获取 `personPhoto.picUri` 与 `serverIndexCode`
+2. 调用 `/api/resource/v1/person/picture`
+3. 获取 302 `Location`
+4. 在 `192.168.69.26` 服务器上实际下载图片
+5. 回传到本地目录做规格分析
+
+本地样本目录:
+
+`C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724`
+
+## 2. 样本明细
+
+| 姓名 | 工号 | 文件名 | 格式 | 分辨率 | DPI | 大小(bytes) | 大小(KB) | MD5 | 本地路径 |
+| --- | --- | --- | --- | --- | --- | ---: | ---: | --- | --- |
+| 邓杰恒 | 23200108010060 | 01_23200108010060.jpg | JPEG | 480x640 | 96x96 | 21986 | 21.47 | `98823428e42b71d0f2ab19ffab08973d` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\01_23200108010060.jpg` |
+| 李铭康 | 23200105010266 | 02_23200105010266.jpg | JPEG | 480x640 | 96x96 | 17402 | 16.99 | `98308b0920b3ba747c6b7ae9263b4b53` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\02_23200105010266.jpg` |
+| 冯铖壕 | 23200118010490 | 03_23200118010490.jpg | JPEG | 480x640 | 96x96 | 26108 | 25.50 | `e0ad8fff74fd6b26601962b66755768e` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\03_23200118010490.jpg` |
+| 谭伟锋 | 23200107120485 | 04_23200107120485.jpg | JPEG | 480x640 | 96x96 | 19113 | 18.67 | `99aeb2589328452a619aba9a4bdc221b` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\04_23200107120485.jpg` |
+| 吴展毅 | 23200102010725 | 05_23200102010725.jpg | JPEG | 480x640 | 96x96 | 24926 | 24.34 | `6a31ac5d02d6e74742d02e1f6e362daf` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\05_23200102010725.jpg` |
+| 黎晓彤 | 23200101010475 | 06_23200101010475.jpg | JPEG | 480x640 | 96x96 | 21131 | 20.64 | `003fd6818d51663b1d03b3af3468de35` | `C:\Users\38479\.codex\visualizations\2026\06\04\019e9020-cbec-78e3-80a9-ddd0c48a7252\hk_faces_20260724\06_23200101010475.jpg` |
+
+## 3. 汇总结论
+
+这 6 张样本图片的规格非常统一:
+
+- 格式全部为 `JPEG`
+- 分辨率全部为 `480x640`
+- DPI 全部为 `96x96`
+- 文件大小范围为 `17402 ~ 26108 bytes`
+- 换算为 `16.99 KB ~ 25.50 KB`
+
+按当前样本看,海康库中实际在用的人脸图片并不是超大图,而是一批较为统一的中小尺寸 `JPEG` 图片。
+
+## 4. 当前判断
+
+基于本次样本,可以先得到两个直接判断:
+
+1. 海康当前已存的人脸照片可以正常提取,不存在“平台里没有照片”的问题。
+2. 当前样本的统一规格可以作为后续对比基线;如果后面发现某些学生上传照片异常,可以优先和本批样本的 `JPEG / 480x640 / 96 DPI / 17KB~26KB` 口径做对照。

+ 10 - 2
src/ss/menu/MenuServ.java

@@ -898,8 +898,9 @@ public class MenuServ extends Serv {
 			JsonObject item = new JsonObject();
 /// 再增加,增加 "iconName" -- 增加 个人菜单.业务名,实现 新UI 的图标体系。Lin
  //    一级菜单图标 为 业务名,来自 个人菜单.业务名
-			item.addProperty("iconName", SkinC.ICON_bizPrfx + group.bizName);	// 业务名,如 "ks"(考试)。Lin
-			SsLog.print("业务名的 iconName:"+ SkinC.ICON_bizPrfx + group.bizName);
+			String iconName = rdBizIconName(group);
+			item.addProperty("iconName", iconName);	// 业务名,如 "ks"(考试)。Lin
+			SsLog.print("业务名的 iconName:"+ iconName);
 ///
 			item.addProperty("id", group.groupId);
 			item.addProperty("pid", "");
@@ -1088,6 +1089,13 @@ public class MenuServ extends Serv {
 		}
 	}
 
+	private String rdBizIconName(MenuGrpB group) {
+		String bizName = group.bizName;
+		if ("xyss".equals(bizName) || (StringUtils.isBlank(bizName) && StringUtils.contains(group.name, "住宿")))
+			return SkinC.ICON_bizPrfx + "zs";
+		return SkinC.ICON_bizPrfx + bizName;
+	}
+
 
 // ---
 

+ 12 - 0
web/skin/easy/css/icon-biz/iconfont.css

@@ -13,6 +13,18 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.icon-obj-zssq:before {
+  content: "\e6a5";
+}
+
+.icon-obj-xyss:before {
+  content: "\e6a4";
+}
+
+.icon-biz-zs:before {
+  content: "\e6a3";
+}
+
 .icon-biz-xm:before {
   content: "\e6a1";
 }

BIN
web/skin/easy/fonts/icon-biz/iconfont.ttf


BIN
web/skin/easy/fonts/icon-biz/iconfont.woff


BIN
web/skin/easy/fonts/icon-biz/iconfont.woff2