海康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#代码在PDF文档中添加、删除和替换图片

《使用C#代码在PDF文档中添加、删除和替换图片》在当今数字化文档处理场景中,动态操作PDF文档中的图像已成为企业级应用开发的核心需求之一,本文将介绍如何在.NET平台使用C#代码在PDF文档中添加、... 目录引言用C#添加图片到PDF文档用C#删除PDF文档中的图片用C#替换PDF文档中的图片引言在当

macOS无效Launchpad图标轻松删除的4 种实用方法

《macOS无效Launchpad图标轻松删除的4种实用方法》mac中不在appstore上下载的应用经常在删除后它的图标还残留在launchpad中,并且长按图标也不会出现删除符号,下面解决这个问... 在 MACOS 上,Launchpad(也就是「启动台」)是一个便捷的 App 启动工具。但有时候,应

Mysql删除几亿条数据表中的部分数据的方法实现

《Mysql删除几亿条数据表中的部分数据的方法实现》在MySQL中删除一个大表中的数据时,需要特别注意操作的性能和对系统的影响,本文主要介绍了Mysql删除几亿条数据表中的部分数据的方法实现,具有一定... 目录1、需求2、方案1. 使用 DELETE 语句分批删除2. 使用 INPLACE ALTER T

C++从序列容器中删除元素的四种方法

《C++从序列容器中删除元素的四种方法》删除元素的方法在序列容器和关联容器之间是非常不同的,在序列容器中,vector和string是最常用的,但这里也会介绍deque和list以供全面了解,尽管在一... 目录一、简介二、移除给定位置的元素三、移除与某个值相等的元素3.1、序列容器vector、deque

C++原地删除有序数组重复项的N种方法

《C++原地删除有序数组重复项的N种方法》给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度,不要使用额外的数组空间,你必须在原地修改输入数组并在使用O(... 目录一、问题二、问题分析三、算法实现四、问题变体:最多保留两次五、分析和代码实现5.1、问题分析5.

SQL Server清除日志文件ERRORLOG和删除tempdb.mdf

《SQLServer清除日志文件ERRORLOG和删除tempdb.mdf》数据库再使用一段时间后,日志文件会增大,特别是在磁盘容量不足的情况下,更是需要缩减,以下为缩减方法:如果可以停止SQLSe... 目录缩减 ERRORLOG 文件(停止服务后)停止 SQL Server 服务:找到错误日志文件:删除

一文详解SQL Server如何跟踪自动统计信息更新

《一文详解SQLServer如何跟踪自动统计信息更新》SQLServer数据库中,我们都清楚统计信息对于优化器来说非常重要,所以本文就来和大家简单聊一聊SQLServer如何跟踪自动统计信息更新吧... SQL Server数据库中,我们都清楚统计信息对于优化器来说非常重要。一般情况下,我们会开启"自动更新

Python如何获取域名的SSL证书信息和到期时间

《Python如何获取域名的SSL证书信息和到期时间》在当今互联网时代,SSL证书的重要性不言而喻,它不仅为用户提供了安全的连接,还能提高网站的搜索引擎排名,那我们怎么才能通过Python获取域名的S... 目录了解SSL证书的基本概念使用python库来抓取SSL证书信息安装必要的库编写获取SSL证书信息

mysql删除无用用户的方法实现

《mysql删除无用用户的方法实现》本文主要介绍了mysql删除无用用户的方法实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 1、删除不用的账户(1) 查看当前已存在账户mysql> select user,host,pa

Win32下C++实现快速获取硬盘分区信息

《Win32下C++实现快速获取硬盘分区信息》这篇文章主要为大家详细介绍了Win32下C++如何实现快速获取硬盘分区信息,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 实现代码CDiskDriveUtils.h#pragma once #include <wtypesbase