From edccaca25b8b6bdb582c60cbd2983bc05a4e1ff3 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 13 七月 2026 09:42:57 +0800
Subject: [PATCH] update

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HikvisionAccessControlApi.java |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HikvisionAccessControlApi.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HikvisionAccessControlApi.java
index f864d00..3bbb057 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HikvisionAccessControlApi.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/HikvisionAccessControlApi.java
@@ -33,6 +33,8 @@
     private static final String USER_INFO_SET_UP_PATH = "/ISAPI/AccessControl/UserInfo/SetUp?format=json";
     private static final String CARD_INFO_SET_UP_PATH = "/ISAPI/AccessControl/CardInfo/SetUp?format=json";
     private static final String FACE_DATA_RECORD_PATH = "/ISAPI/Intelligent/FDLib/FaceDataRecord?format=json";
+    private static final String USER_INFO_DELETE_PATH = "/ISAPI/AccessControl/UserInfo/Delete?format=json";
+    private static final String CARD_INFO_DELETE_PATH = "/ISAPI/AccessControl/CardInfo/Delete?format=json";
     private static final MediaType JSON_MEDIA_TYPE = MediaType.parse("application/json; charset=utf-8");
     private static final MediaType JPEG_MEDIA_TYPE = MediaType.parse("image/jpeg");
     private static final MediaType PNG_MEDIA_TYPE = MediaType.parse("image/png");
@@ -66,6 +68,25 @@
             result.setFace(face);
             ensureSuccess(face, "绑定员工人脸失败");
         }
+        return result;
+    }
+
+    /**
+     * 删除门禁人员,并尽量清理绑定卡和人脸凭据。
+     */
+    public static DeleteResult deleteEmployee(DeviceConfig device, EmployeeCredential employee) throws IOException {
+        Objects.requireNonNull(employee, "employee");
+        requireText(employee.getEmployeeNo(), "employeeNo");
+
+        DeleteResult result = new DeleteResult();
+        if (isNotBlank(employee.getCardNo())) {
+            result.setCard(deleteCard(device, employee.getCardNo()));
+        }
+        result.setFace(deleteFace(device, employee.getEmployeeNo()));
+
+        HikvisionResult userInfo = deleteUserInfo(device, employee.getEmployeeNo());
+        result.setUserInfo(userInfo);
+        ensureSuccess(userInfo, "delete user info failed");
         return result;
     }
 
@@ -152,6 +173,53 @@
     }
 
     /**
+     * 删除设备端人员基础信息。
+     */
+    public static HikvisionResult deleteUserInfo(DeviceConfig device, String employeeNo) throws IOException {
+        requireDevice(device);
+        requireText(employeeNo, "employeeNo");
+
+        JSONObject employeeNoItem = new JSONObject(true);
+        employeeNoItem.put("employeeNo", employeeNo);
+
+        JSONObject userInfoDelCond = new JSONObject(true);
+        userInfoDelCond.put("EmployeeNoList", singletonList(employeeNoItem));
+
+        JSONObject body = new JSONObject(true);
+        body.put("UserInfoDelCond", userInfoDelCond);
+        return executeJson(device, "DELETE", USER_INFO_DELETE_PATH, body);
+    }
+
+    public static HikvisionResult deleteCard(DeviceConfig device, String cardNo) throws IOException {
+        requireDevice(device);
+        requireText(cardNo, "cardNo");
+
+        JSONObject cardNoItem = new JSONObject(true);
+        cardNoItem.put("cardNo", cardNo);
+
+        JSONObject cardInfoDelCond = new JSONObject(true);
+        cardInfoDelCond.put("CardNoList", singletonList(cardNoItem));
+
+        JSONObject body = new JSONObject(true);
+        body.put("CardInfoDelCond", cardInfoDelCond);
+        return executeJson(device, "DELETE", CARD_INFO_DELETE_PATH, body);
+    }
+
+    public static HikvisionResult deleteFace(DeviceConfig device, String employeeNo) throws IOException {
+        requireDevice(device);
+        requireText(employeeNo, "employeeNo");
+
+        JSONObject faceData = new JSONObject(true);
+        faceData.put("faceLibType", "blackFD");
+        faceData.put("FDID", "1");
+        faceData.put("FPID", employeeNo);
+
+        JSONObject body = new JSONObject(true);
+        body.put("FaceDataRecord", faceData);
+        return executeJson(device, "DELETE", FACE_DATA_RECORD_PATH, body);
+    }
+
+    /**
      * 通过图片 URL 下载人脸并绑定到员工。
      */
     public static HikvisionResult bindFaceByUrl(DeviceConfig device, String employeeNo, String faceImageUrl) throws IOException {
@@ -179,6 +247,8 @@
                 .header("Accept", "application/json");
         if ("POST".equals(method)) {
             builder.post(requestBody);
+        } else if ("DELETE".equals(method)) {
+            builder.delete(requestBody);
         } else {
             builder.put(requestBody);
         }
@@ -668,6 +738,36 @@
         }
     }
 
+    public static final class DeleteResult {
+        private HikvisionResult userInfo;
+        private HikvisionResult card;
+        private HikvisionResult face;
+
+        public HikvisionResult getUserInfo() {
+            return userInfo;
+        }
+
+        public void setUserInfo(HikvisionResult userInfo) {
+            this.userInfo = userInfo;
+        }
+
+        public HikvisionResult getCard() {
+            return card;
+        }
+
+        public void setCard(HikvisionResult card) {
+            this.card = card;
+        }
+
+        public HikvisionResult getFace() {
+            return face;
+        }
+
+        public void setFace(HikvisionResult face) {
+            this.face = face;
+        }
+    }
+
     public static final class IssueResult {
         private HikvisionResult userInfo;
         private HikvisionResult card;

--
Gitblit v1.7.1