海康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

相关文章

使用C#删除Excel表格中的重复行数据的代码详解

《使用C#删除Excel表格中的重复行数据的代码详解》重复行是指在Excel表格中完全相同的多行数据,删除这些重复行至关重要,因为它们不仅会干扰数据分析,还可能导致错误的决策和结论,所以本文给大家介绍... 目录简介使用工具C# 删除Excel工作表中的重复行语法工作原理实现代码C# 删除指定Excel单元

Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法

《Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法》在Linux系统中,管理磁盘设备和分区是日常运维工作的重要部分,而lsblk命令是一个强大的工具,它用于列出系统中的块设备(blockde... 目录1. 查看所有磁盘的物理信息方法 1:使用 lsblk(推荐)方法 2:使用 fdisk -l(

Mysql中的用户管理实践

《Mysql中的用户管理实践》:本文主要介绍Mysql中的用户管理实践,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录13. 用户管理13.1 用户 13.1.1 用户信息 13.1.2 创建用户 13.1.3 删除用户 13.1.4 修改用户

SpringBoot如何对密码等敏感信息进行脱敏处理

《SpringBoot如何对密码等敏感信息进行脱敏处理》这篇文章主要为大家详细介绍了SpringBoot对密码等敏感信息进行脱敏处理的几个常用方法,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录​1. 配置文件敏感信息脱敏​​2. 日志脱敏​​3. API响应脱敏​​4. 其他注意事项​​总结

Python对PDF书签进行添加,修改提取和删除操作

《Python对PDF书签进行添加,修改提取和删除操作》PDF书签是PDF文件中的导航工具,通常包含一个标题和一个跳转位置,本教程将详细介绍如何使用Python对PDF文件中的书签进行操作... 目录简介使用工具python 向 PDF 添加书签添加书签添加嵌套书签Python 修改 PDF 书签Pytho

详解如何在SpringBoot控制器中处理用户数据

《详解如何在SpringBoot控制器中处理用户数据》在SpringBoot应用开发中,控制器(Controller)扮演着至关重要的角色,它负责接收用户请求、处理数据并返回响应,本文将深入浅出地讲解... 目录一、获取请求参数1.1 获取查询参数1.2 获取路径参数二、处理表单提交2.1 处理表单数据三、

C#实现查找并删除PDF中的空白页面

《C#实现查找并删除PDF中的空白页面》PDF文件中的空白页并不少见,因为它们有可能是作者有意留下的,也有可能是在处理文档时不小心添加的,下面我们来看看如何使用Spire.PDFfor.NET通过C#... 目录安装 Spire.PDF for .NETC# 查找并删除 PDF 文档中的空白页C# 添加与删

SQL常用操作精华之复制表、跨库查询、删除重复数据

《SQL常用操作精华之复制表、跨库查询、删除重复数据》:本文主要介绍SQL常用操作精华之复制表、跨库查询、删除重复数据,这些SQL操作涵盖了数据库开发中最常用的技术点,包括表操作、数据查询、数据管... 目录SQL常用操作精华总结表结构与数据操作高级查询技巧SQL常用操作精华总结表结构与数据操作复制表结

springboot实现配置文件关键信息加解密

《springboot实现配置文件关键信息加解密》在项目配置文件中常常会配置如数据库连接信息,redis连接信息等,连接密码明文配置在配置文件中会很不安全,所以本文就来聊聊如何使用springboot... 目录前言方案实践1、第一种方案2、第二种方案前言在项目配置文件中常常会配置如数据库连接信息、Red

CentOS和Ubuntu系统使用shell脚本创建用户和设置密码

《CentOS和Ubuntu系统使用shell脚本创建用户和设置密码》在Linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设置密码,本文写了一个shell... 在linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设