海康ISAPI删除用户信息

2024-02-18 21:28

本文主要是介绍海康ISAPI删除用户信息,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

海康ISAPI删除用户信息

IotIsapiUrlConstant

/*** 海康ISAPI请求URL** @date 2022/10/12*/
public class IotIsapiUrlConstant {/*** 添加人员信息* post*/public static final String ADD_USER_INFO = "/ISAPI/AccessControl/UserInfo/Record?format=json";/*** 添加人脸数据* post*/public static final String ADD_USER_FACE = "/ISAPI/Intelligent/FDLib/FaceDataRecord?format=json";/*** 修改人脸数据*/public static final String EDIT_USER_FACE = "/ISAPI/Intelligent/FDLib/FDModify?format=json";/*** 添加或修改人脸数据* put*/public static final String FDSETUP_USER_FACE = "/ISAPI/Intelligent/FDLib/FDSetUp?format=json";/*** 添加或修改人员数据* put*/public static final String SETUP_USER_INFO= "/ISAPI/AccessControl/UserInfo/SetUp?format=json";/*** 上传人脸照片*/public static final String UPLOAD_STORAGE_CLOUD = "/ISAPI/Intelligent/uploadStorageCloud?format=json";/*** 删除人员信息*/public static final String DEL_USER_INFO = "/ISAPI/AccessControl/UserInfo/Delete?format=json";/*** 查询人员信息*/public static final String QUER_USER_INFO = "/ISAPI/AccessControl/UserInfo/Search?format=json";/*** 修改人员信息*/public static final String MODIFY_USER_INFO = "/ISAPI/AccessControl/UserInfo/Modify?format=json";/*** 获取人员权限计划模板参数配置能力*/public static final String USER_RIGHTPLAN_TEMPLATE = "/ISAPI/AccessControl/UserRightPlanTemplate/capabilities?format=json";/*** 人员权限计划模板* 模板编号,从1开始,设备支持的最大值从能力集中获取*/public static String allocationUserRightPlanTemplate(String planTemplateID){return "/ISAPI/AccessControl/UserRightPlanTemplate/"+planTemplateID+"?format=json";}/*** 员权限周计划* 周计划编号,从1开始,设备支持的最大值从能力集中获取* 128*/public static String allocationUserRightWeekPlanCfg(int weekPlanID){return "/ISAPI/AccessControl/UserRightWeekPlanCfg/"+weekPlanID+"?format=json";}/*** 查询人员数量*/public static final String GET_USER_COUNT= "/ISAPI/AccessControl/UserInfo/Count?format=json";}

HttpClientUtil

/*** @date 2023/11/9*/
@Slf4j
public class HttpClientUtil {public static CloseableHttpClient httpUsernamePassword(String username, String password) {Credentials creds = new UsernamePasswordCredentials(username, password);CredentialsProvider credsProvider = new BasicCredentialsProvider();credsProvider.setCredentials(AuthScope.ANY, creds);return HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();}/*** get 请求** @param username 账号* @param password 密码* @param isapiUrl URL* @return*/public static String getHttpIsapi(String username, String password, String isapiUrl) {HttpGet httpGet = new HttpGet(isapiUrl);CloseableHttpClient httpclient = httpUsernamePassword(username, password);try {HttpResponse response = httpclient.execute(httpGet);return EntityUtils.toString(response.getEntity(), "utf-8");} catch (Exception e) {log.error("调用接口失败", e);}return null;}/*** post 请求** @param username 账号* @param password 密码* @param isapiUrl URL* @return*/public static String postHttpIsapi(String username, String password, String isapiUrl, String body) {HttpPost httpPost = new HttpPost(isapiUrl);CloseableHttpClient httpclient = httpUsernamePassword(username, password);httpPost.setEntity(new StringEntity(body, "UTF-8"));try {HttpResponse response = httpclient.execute(httpPost);return EntityUtils.toString(response.getEntity(), "utf-8");} catch (Exception e) {log.error("调用接口失败", e);}return null;}/*** put 请求** @param username 账号* @param password 密码* @param isapiUrl URL* @param putXml   参数 字符串* @return*/public static String putHttpIsapi(String username, String password, String isapiUrl, String putXml) {HttpPut httpPut = new HttpPut(isapiUrl);CloseableHttpClient httpclient = httpUsernamePassword(username, password);httpPut.setEntity(new StringEntity(putXml, "UTF-8"));try {HttpResponse response = httpclient.execute(httpPut);return EntityUtils.toString(response.getEntity(), "utf-8");} catch (Exception e) {log.error("调用接口失败", e);}return null;}public static String doPostModFacePicRecord(String username, String password, String url, String json, byte[] faceimage, String boundary) {String respoon = "";try {CloseableHttpResponse response;CloseableHttpClient httpsClient = httpUsernamePassword(username, password);HttpPost method = new HttpPost(url);method.addHeader("Accept-Language", "zh-CN");method.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary);method.addHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");method.addHeader("Accept-Encoding", "gzip, deflate");method.addHeader("Connection", "Keep-Alive");method.addHeader("Cache-Control", "no-cache");String bodyParam ="--" + boundary + "\r\n"+ "Content-Disposition: form-data; name=\"FaceDataRecord\";\r\n"+ "Content-Type: text/json\r\n"+ "Content-Length: " + json.length() + "\r\n\r\n"+ json + "\r\n"+ "--" + boundary + "\r\n"+ "Content-Disposition: form-data; name=\"img\";\r\n"+ "Content-Type: image/jpeg\r\n"+ "Content-Length: " + faceimage.length + "\r\n\r\n"+ faceimage+ "\r\n--" + boundary + "--\r\n";HttpEntity inboundInfoEntity = new StringEntity(bodyParam, "UTF-8");method.setEntity(inboundInfoEntity);response = httpsClient.execute(method);int statusCode = response.getStatusLine().getStatusCode();if (statusCode != HttpStatus.SC_OK) {respoon = "error " + statusCode;}HttpEntity entity = response.getEntity();if (entity == null) {respoon = "error response is null";}respoon = EntityUtils.toString(entity, "utf-8");// Release the connectionmethod.releaseConnection();} catch (IOException e) {log.error("添加人脸失败", e);}return respoon;}public static String doPutModFacePicRecord(String username, String password, String url, String json, byte[] faceimage, String boundary) {String respon = "";try {CloseableHttpResponse response;CloseableHttpClient httpsClient = httpUsernamePassword(username, password);HttpPut method = new HttpPut(url);method.addHeader("Accept", "text/html, application/xhtml+xml");method.addHeader("Accept-Language", "zh-CN");method.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary);method.addHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");method.addHeader("Accept-Encoding", "gzip, deflate");method.addHeader("Connection", "Keep-Alive");method.addHeader("Cache-Control", "no-cache");String bodyParam ="--" + boundary + "\r\n"+ "Content-Disposition: form-data; name=\"FaceDataRecord\";\r\n"+ "Content-Type: text/json\r\n"+ "Content-Length: " + json.length() + "\r\n\r\n"+ json + "\r\n"+ "--" + boundary + "\r\n"+ "Content-Disposition: form-data; name=\"img\";\r\n"+ "Content-Type: image/jpeg\r\n"+ "Content-Length: " + faceimage.length + "\r\n\r\n"+ faceimage+ "\r\n--" + boundary + "--\r\n";HttpEntity inboundInfoEntity = new StringEntity(bodyParam, "UTF-8");method.setEntity(inboundInfoEntity);response = httpsClient.execute(method);int statusCode = response.getStatusLine().getStatusCode();if (statusCode != HttpStatus.SC_OK) {respon = "error " + statusCode;}HttpEntity entity = response.getEntity();if (entity == null) {respon = "error response is null";}respon = EntityUtils.toString(entity, "utf-8");// Release the connectionmethod.releaseConnection();} catch (IOException e) {log.error("添加人脸失败", e);}return respon;}}

IotUserInfoDelCond

/*** req, object, 删除条件* @date 2023/11/13*/
@Getter
@Setter
public class IotUserInfoDelCond {/**opt, string, 操作类型* byTerminal* */private String operateType;/*** 工号(人员ID)* opt, array, 人员ID列表, subType:object,* desc:EployeeNoList字段不存在或为空时,代表删除所有人员。删除所有人员时,超时时间建议设置为60s。删除人员* 时,人员关联的凭证信息也会被删除。*/private List<IotEmployeeNo> EmployeeNoList;/**opt, array, 终端ID列表, subType:int, desc:type为byTerminal,byTerminalOrg时必填,终端ID列表(目前仅支持单个终端)*/private List<Integer> terminalNoList;}

IotEmployeeNo

/*** 工号(人员ID)* @date 2023/11/13*/
@Getter
@Setter
public class IotEmployeeNo {/*** 工号(人员ID)*/private String employeeNo;}

IotDelUserFaceParam

/***删除用户人脸信息* @author czm* @date 2023/11/10*/
@Getter
@Setter
public class IotDelUserFaceParam {private IotUserInfoDelCond UserInfoDelCond;}

删除用户信息

/**
*camera 设备信息
*userIds 用户编码集合
*/
public static String deleteUserFace(IotCameraParam camera, Collection<Long> userIds) {String url = HTTP + camera.getIp() + IotIsapiUrlConstant.DEL_USER_INFO;IotUserInfoDelCond userInfoDelCond = new IotUserInfoDelCond();userInfoDelCond.setOperateType("byTerminal");if (CollUtil.isNotEmpty(userIds)) {List<IotEmployeeNo> employeeNos = new ArrayList<>();for (Long userId : userIds) {IotEmployeeNo employeeNo = new IotEmployeeNo();employeeNo.setEmployeeNo(String.valueOf(userId));employeeNos.add(employeeNo);}userInfoDelCond.setEmployeeNoList(employeeNos);}userInfoDelCond.setTerminalNoList(Collections.singletonList(1));IotDelUserFaceParam delUserFaceParam = new IotDelUserFaceParam();delUserFaceParam.setUserInfoDelCond(userInfoDelCond);String delUserInfoRespoon = HttpClientUtil.putHttpIsapi(camera.getUsername(), camera.getPassword(), url, JSONUtil.toJsonStr(delUserFaceParam));log.info("ISAPI delUser:{}", delUserInfoRespoon);return delUserInfoRespoon;}

这篇关于海康ISAPI删除用户信息的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/722501

相关文章

SQL Server跟踪自动统计信息更新实战指南

《SQLServer跟踪自动统计信息更新实战指南》本文详解SQLServer自动统计信息更新的跟踪方法,推荐使用扩展事件实时捕获更新操作及详细信息,同时结合系统视图快速检查统计信息状态,重点强调修... 目录SQL Server 如何跟踪自动统计信息更新:深入解析与实战指南 核心跟踪方法1️⃣ 利用系统目录

最新Spring Security的基于内存用户认证方式

《最新SpringSecurity的基于内存用户认证方式》本文讲解SpringSecurity内存认证配置,适用于开发、测试等场景,通过代码创建用户及权限管理,支持密码加密,虽简单但不持久化,生产环... 目录1. 前言2. 因何选择内存认证?3. 基础配置实战❶ 创建Spring Security配置文件

MySQL逻辑删除与唯一索引冲突解决方案

《MySQL逻辑删除与唯一索引冲突解决方案》本文探讨MySQL逻辑删除与唯一索引冲突问题,提出四种解决方案:复合索引+时间戳、修改唯一字段、历史表、业务层校验,推荐方案1和方案3,适用于不同场景,感兴... 目录问题背景问题复现解决方案解决方案1.复合唯一索引 + 时间戳删除字段解决方案2:删除后修改唯一字

一文详解如何使用Java获取PDF页面信息

《一文详解如何使用Java获取PDF页面信息》了解PDF页面属性是我们在处理文档、内容提取、打印设置或页面重组等任务时不可或缺的一环,下面我们就来看看如何使用Java语言获取这些信息吧... 目录引言一、安装和引入PDF处理库引入依赖二、获取 PDF 页数三、获取页面尺寸(宽高)四、获取页面旋转角度五、判断

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

Java中读取YAML文件配置信息常见问题及解决方法

《Java中读取YAML文件配置信息常见问题及解决方法》:本文主要介绍Java中读取YAML文件配置信息常见问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录1 使用Spring Boot的@ConfigurationProperties2. 使用@Valu

Mysql实现范围分区表(新增、删除、重组、查看)

《Mysql实现范围分区表(新增、删除、重组、查看)》MySQL分区表的四种类型(范围、哈希、列表、键值),主要介绍了范围分区的创建、查询、添加、删除及重组织操作,具有一定的参考价值,感兴趣的可以了解... 目录一、mysql分区表分类二、范围分区(Range Partitioning1、新建分区表:2、分

MySQL 删除数据详解(最新整理)

《MySQL删除数据详解(最新整理)》:本文主要介绍MySQL删除数据的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、前言二、mysql 中的三种删除方式1.DELETE语句✅ 基本语法: 示例:2.TRUNCATE语句✅ 基本语

一文详解Git中分支本地和远程删除的方法

《一文详解Git中分支本地和远程删除的方法》在使用Git进行版本控制的过程中,我们会创建多个分支来进行不同功能的开发,这就容易涉及到如何正确地删除本地分支和远程分支,下面我们就来看看相关的实现方法吧... 目录技术背景实现步骤删除本地分支删除远程www.chinasem.cn分支同步删除信息到其他机器示例步骤