Commit a8e95e2a authored by 赵啸非's avatar 赵啸非

添加海康门禁链接库

parent bf4a7fa6
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>attendance-performance-manager</artifactId> <artifactId>attendance-performance-manager</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<description>考勤绩效管理平台</description> <description>考勤绩效管理平台</description>
<parent> <parent>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
...@@ -14,381 +14,408 @@ ...@@ -14,381 +14,408 @@
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
<profiles> <profiles>
<profile> <profile>
<id>develop</id> <id>develop</id>
<properties> <properties>
<profiles.active>develop</profiles.active> <profiles.active>develop</profiles.active>
<profiles.server.port>17500</profiles.server.port> <profiles.server.port>17500</profiles.server.port>
<profiles.server.path>/attendance</profiles.server.path> <profiles.server.path>/attendance</profiles.server.path>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level> <profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host> <profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.protocol>http://</profiles.hik.protocol> <profiles.hik.protocol>http://</profiles.hik.protocol>
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain> <profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl> <profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
<profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd</profiles.dingtalk.appSecret> <profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd
<profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey> </profiles.dingtalk.appSecret>
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token> <profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey>
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId> <profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
<profiles.webUrl>http://8.136.255.30:11039/attendance</profiles.webUrl> <profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
<package.environment>serve</package.environment> <profiles.webUrl>http://8.136.255.30:11039/attendance</profiles.webUrl>
<skipUi>false</skipUi> <package.environment>serve</package.environment>
</properties> <skipUi>false</skipUi>
</profile> </properties>
<profile> </profile>
<id>test</id> <profile>
<activation> <id>test</id>
<activeByDefault>true</activeByDefault> <activation>
</activation> <activeByDefault>true</activeByDefault>
<properties> </activation>
<profiles.active>test</profiles.active> <properties>
<profiles.server.port>17500</profiles.server.port> <profiles.active>test</profiles.active>
<profiles.server.path>/attendance</profiles.server.path> <profiles.server.port>17500</profiles.server.port>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.server.path>/attendance</profiles.server.path>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.level>INFO</profiles.log.level> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.log.level>INFO</profiles.log.level>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.hik.protocol>http://</profiles.hik.protocol> <profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.hik.protocol>http://</profiles.hik.protocol>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl> <profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd</profiles.dingtalk.appSecret> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
<profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey> <profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token> </profiles.dingtalk.appSecret>
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId> <profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey>
<profiles.webUrl>http://8.136.255.30:11039/attendance</profiles.webUrl> <profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
<package.environment>test</package.environment> <profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
<skipUi>false</skipUi> <profiles.webUrl>http://8.136.255.30:11039/attendance</profiles.webUrl>
</properties> <package.environment>test</package.environment>
</profile> <skipUi>false</skipUi>
</properties>
<profile> </profile>
<id>product</id>
<properties> <profile>
<profiles.active>product</profiles.active> <id>product</id>
<profiles.server.port>17500</profiles.server.port> <properties>
<profiles.server.path>/attendance</profiles.server.path> <profiles.active>product</profiles.active>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.server.port>17500</profiles.server.port>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr> <profiles.server.path>/attendance</profiles.server.path>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.log.level>INFO</profiles.log.level> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.log.level>INFO</profiles.log.level>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.hik.protocol>http://</profiles.hik.protocol> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.protocol>http://</profiles.hik.protocol>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd</profiles.dingtalk.appSecret> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token> <profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId> </profiles.dingtalk.appSecret>
<profiles.webUrl>http://8.136.255.30:21039/attendance</profiles.webUrl> <profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey>
<package.environment>build</package.environment> <profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
<skipUi>false</skipUi> <profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
</properties> <profiles.webUrl>http://8.136.255.30:21039/attendance</profiles.webUrl>
</profile> <package.environment>build</package.environment>
<profile> <skipUi>false</skipUi>
<id>yibin</id> </properties>
<properties> </profile>
<profiles.active>yibin</profiles.active> <profile>
<profiles.server.port>17500</profiles.server.port> <id>yibin</id>
<profiles.server.path>/attendance</profiles.server.path> <properties>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.active>yibin</profiles.active>
<profiles.nacos.server-addr>192.168.0.124:8848</profiles.nacos.server-addr> <profiles.server.port>17500</profiles.server.port>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.server.path>/attendance</profiles.server.path>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path> <profiles.nacos.server-addr>192.168.0.124:8848</profiles.nacos.server-addr>
<profiles.log.level>INFO</profiles.log.level> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.sms.smsSendUrl>http://172.15.28.113:8901/api/index/index</profiles.sms.smsSendUrl> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.hik.host>10.12.177.245:443</profiles.hik.host> <profiles.log.level>INFO</profiles.log.level>
<profiles.hik.protocol>https://</profiles.hik.protocol> <profiles.sms.smsSendUrl>http://172.15.28.113:8901/api/index/index</profiles.sms.smsSendUrl>
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.host>10.12.177.245:443</profiles.hik.host>
<profiles.hik.protocol>https://</profiles.hik.protocol>
<profiles.dingtalk.domain>http://172.15.28.113:8918</profiles.dingtalk.domain> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.dingtalk.oaUrl>172.15.28.113:8919</profiles.dingtalk.oaUrl> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.domain>http://172.15.28.113:8918</profiles.dingtalk.domain>
<profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd</profiles.dingtalk.appSecret> <profiles.dingtalk.oaUrl>172.15.28.113:8919</profiles.dingtalk.oaUrl>
<profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId> <profiles.dingtalk.appSecret>bF2WALmo5_Wuj3hg5gXeWqezrYnZChUJ88HjzNWpkA9ivdOxfBDGOGYcfVRfB3vd
<profiles.webUrl>https://ybswxxcx.zwfwhfgjjfzj.yibin.gov.cn/performance-h5</profiles.webUrl> </profiles.dingtalk.appSecret>
<package.environment>build</package.environment> <profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey>
<skipUi>false</skipUi> <profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
</properties> <profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
</profile> <profiles.webUrl>https://ybswxxcx.zwfwhfgjjfzj.yibin.gov.cn/performance-h5</profiles.webUrl>
<package.environment>build</package.environment>
</profiles> <skipUi>false</skipUi>
</properties>
<properties> </profile>
</properties>
</profiles>
<dependencies>
<dependency> <properties>
<groupId>com.mortals.xhx</groupId> </properties>
<artifactId>common-lib</artifactId>
</dependency> <dependencies>
<dependency>
<dependency> <groupId>com.mortals.xhx</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>common-lib</artifactId>
<artifactId>spring-boot-starter-web</artifactId> </dependency>
</dependency>
<dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<groupId>com.alibaba</groupId> <artifactId>spring-boot-starter-web</artifactId>
<artifactId>druid-spring-boot-starter</artifactId> </dependency>
</dependency>
<dependency>
<dependency> <groupId>com.alibaba</groupId>
<groupId>org.mybatis.spring.boot</groupId> <artifactId>druid-spring-boot-starter</artifactId>
<artifactId>mybatis-spring-boot-starter</artifactId> </dependency>
</dependency>
<dependency>
<dependency> <groupId>org.mybatis.spring.boot</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId>
<artifactId>spring-boot-starter-websocket</artifactId> </dependency>
<version>2.5.2</version>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-websocket</artifactId>
<groupId>mysql</groupId> <version>2.5.2</version>
<artifactId>mysql-connector-java</artifactId> </dependency>
</dependency>
<dependency>
<dependency> <groupId>mysql</groupId>
<groupId>org.springframework.data</groupId> <artifactId>mysql-connector-java</artifactId>
<artifactId>spring-data-redis</artifactId> </dependency>
</dependency>
<dependency>
<!--Token生成与解析--> <groupId>org.springframework.data</groupId>
<dependency> <artifactId>spring-data-redis</artifactId>
<groupId>io.jsonwebtoken</groupId> </dependency>
<artifactId>jjwt</artifactId>
</dependency> <!--Token生成与解析-->
<dependency>
<dependency> <groupId>io.jsonwebtoken</groupId>
<groupId>com.hikvision.ga</groupId> <artifactId>jjwt</artifactId>
<artifactId>artemis-http-client</artifactId> </dependency>
<version>1.1.8</version>
<!-- <systemPath>${project.basedir}/src/main/resources/lib/artemis-http-client-1.1.8.jar</systemPath>--> <dependency>
</dependency> <groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<!--dingdingtalk sdk--> <version>1.1.8</version>
<dependency> <!-- <systemPath>${project.basedir}/src/main/resources/lib/artemis-http-client-1.1.8.jar</systemPath>-->
<groupId>com.aliyun</groupId> </dependency>
<artifactId>dingtalk</artifactId>
<version>2.0.22</version> <!--dingdingtalk sdk-->
</dependency> <dependency>
<groupId>com.aliyun</groupId>
<!--dingdingtalk service sdk--> <artifactId>dingtalk</artifactId>
<dependency> <version>2.0.22</version>
<groupId>com.aliyun</groupId> </dependency>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>2.0.0</version> <!--dingdingtalk service sdk-->
</dependency> <dependency>
<groupId>com.aliyun</groupId>
<dependency> <artifactId>alibaba-dingtalk-service-sdk</artifactId>
<groupId>junit</groupId> <version>2.0.0</version>
<artifactId>junit</artifactId> </dependency>
<scope>test</scope>
</dependency> <dependency>
<groupId>junit</groupId>
</dependencies> <artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<build>
<resources>
<resource> <dependency>
<directory>src/main/resources</directory> <groupId>com.mortals</groupId>
<filtering>true</filtering> <artifactId>jna</artifactId>
</resource> <version>1.0</version>
</resources> </dependency>
<plugins>
<plugin> <dependency>
<groupId>org.apache.maven.plugins</groupId> <groupId>com.mortals</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>json</artifactId>
<version>2.19.1</version> <version>1.0</version>
<configuration> </dependency>
<skipTests>true</skipTests> <!--默认关掉单元测试 -->
</configuration>
</plugin> <dependency>
<plugin> <groupId>com.mortals</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>examples</artifactId>
<artifactId>spring-boot-maven-plugin</artifactId> <version>1.0</version>
</plugin> </dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId> </dependencies>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source> <build>
<target>${java.version}</target> <resources>
<encoding>${project.build.sourceEncoding}</encoding> <resource>
</configuration> <directory>src/main/resources</directory>
</plugin> <filtering>true</filtering>
</resource>
<plugin> </resources>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <plugins>
<executions> <plugin>
<execution> <groupId>org.apache.maven.plugins</groupId>
<id>copy-bin</id> <artifactId>maven-surefire-plugin</artifactId>
<phase>package</phase> <version>2.19.1</version>
<goals> <configuration>
<goal>copy-resources</goal> <skipTests>true</skipTests> <!--默认关掉单元测试 -->
</goals> </configuration>
<configuration> </plugin>
<encoding>UTF-8</encoding> <plugin>
<outputDirectory>target/bin <groupId>org.springframework.boot</groupId>
</outputDirectory> <artifactId>spring-boot-maven-plugin</artifactId>
<resources> </plugin>
<resource> <plugin>
<directory>src/main/bin/</directory> <groupId>org.apache.maven.plugins</groupId>
<excludes> <artifactId>maven-compiler-plugin</artifactId>
<exclude>deploy.sh</exclude> <configuration>
</excludes> <source>${java.version}</source>
<filtering>true</filtering> <target>${java.version}</target>
</resource> <encoding>${project.build.sourceEncoding}</encoding>
</resources> </configuration>
</configuration> </plugin>
</execution>
<plugin>
<execution> <groupId>org.apache.maven.plugins</groupId>
<id>copy-deploy</id> <artifactId>maven-resources-plugin</artifactId>
<phase>package</phase> <executions>
<goals> <execution>
<goal>copy-resources</goal> <id>copy-bin</id>
</goals> <phase>package</phase>
<configuration> <goals>
<encoding>UTF-8</encoding> <goal>copy-resources</goal>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/ </goals>
</outputDirectory> <configuration>
<resources> <encoding>UTF-8</encoding>
<resource> <outputDirectory>target/bin
<directory>src/main/bin</directory> </outputDirectory>
<includes> <resources>
<include>deploy.sh</include> <resource>
</includes> <directory>src/main/bin/</directory>
<filtering>true</filtering> <excludes>
</resource> <exclude>deploy.sh</exclude>
</resources> </excludes>
</configuration> <filtering>true</filtering>
</execution> </resource>
</executions> </resources>
</plugin> </configuration>
</execution>
<plugin>
<groupId>org.codehaus.mojo</groupId> <execution>
<artifactId>exec-maven-plugin</artifactId> <id>copy-deploy</id>
<version>1.6.0</version> <phase>package</phase>
<configuration> <goals>
<skip>${skipUi}</skip> <goal>copy-resources</goal>
</configuration> </goals>
<executions> <configuration>
<execution> <encoding>UTF-8</encoding>
<id>exec-npm-install</id> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/
<phase>generate-resources</phase> </outputDirectory>
<goals> <resources>
<goal>exec</goal> <resource>
</goals> <directory>src/main/bin</directory>
<configuration> <includes>
<executable>yarn</executable> <include>deploy.sh</include>
<arguments> </includes>
<argument></argument> <filtering>true</filtering>
</arguments> </resource>
<workingDirectory>${project.parent.basedir}/attendance-performance-manager-ui/admin</workingDirectory> </resources>
</configuration> </configuration>
</execution> </execution>
</executions>
<execution> </plugin>
<id>exec-npm-run-build</id>
<phase>generate-resources</phase> <plugin>
<goals> <groupId>org.codehaus.mojo</groupId>
<goal>exec</goal> <artifactId>exec-maven-plugin</artifactId>
</goals> <version>1.6.0</version>
<configuration> <configuration>
<executable>yarn</executable> <skip>${skipUi}</skip>
<arguments> </configuration>
<argument>run</argument> <executions>
<arguments>${package.environment}</arguments> <execution>
</arguments> <id>exec-npm-install</id>
<workingDirectory>${project.parent.basedir}/attendance-performance-manager-ui/admin</workingDirectory> <phase>generate-resources</phase>
</configuration> <goals>
</execution> <goal>exec</goal>
</goals>
</executions> <configuration>
</plugin> <executable>yarn</executable>
<arguments>
<plugin> <argument></argument>
<artifactId>maven-assembly-plugin</artifactId> </arguments>
<version>3.3.0</version> <workingDirectory>${project.parent.basedir}/attendance-performance-manager-ui/admin
<executions> </workingDirectory>
<execution> </configuration>
<id>make-assembly</id> </execution>
<phase>package</phase>
<goals> <execution>
<goal>single</goal> <id>exec-npm-run-build</id>
</goals> <phase>generate-resources</phase>
<configuration> <goals>
<finalName>${project.artifactId}</finalName> <goal>exec</goal>
<appendAssemblyId>false</appendAssemblyId> </goals>
<descriptors> <configuration>
<descriptor>../assembly/assembly.xml</descriptor> <executable>yarn</executable>
</descriptors> <arguments>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory> <argument>run</argument>
</configuration> <arguments>${package.environment}</arguments>
</execution> </arguments>
<execution> <workingDirectory>${project.parent.basedir}/attendance-performance-manager-ui/admin
<id>make-assembly-ui</id> </workingDirectory>
<phase>package</phase> </configuration>
<goals> </execution>
<goal>single</goal>
</goals> </executions>
<configuration> </plugin>
<skipAssembly>${skipUi}</skipAssembly>
<finalName>${project.artifactId}-ui</finalName> <plugin>
<appendAssemblyId>false</appendAssemblyId> <artifactId>maven-assembly-plugin</artifactId>
<descriptors> <version>3.3.0</version>
<descriptor>../assembly/assembly-manager-ui.xml</descriptor> <executions>
</descriptors> <execution>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory> <id>make-assembly</id>
</configuration> <phase>package</phase>
</execution> <goals>
</executions> <goal>single</goal>
</plugin> </goals>
</plugins> <configuration>
</build> <finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>../assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration>
</execution>
<execution>
<id>make-assembly-ui</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<skipAssembly>${skipUi}</skipAssembly>
<finalName>${project.artifactId}-ui</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>../assembly/assembly-manager-ui.xml</descriptor>
</descriptors>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.ptr.IntByReference;
/**
* 门禁设备管理:
* 1、获取(设置)门禁主机参数
* 2、获取门禁主机工作状态
*/
public class ACSManage {
/**
* 获取(设置)门禁主机参数
*
* @param lUserID 用户登录句柄
*/
public static void acsCfg(int lUserID) {
/**获取门禁主机参数*/
HCNetSDK.NET_DVR_ACS_CFG struAcsCfg = new HCNetSDK.NET_DVR_ACS_CFG();
struAcsCfg.dwSize = struAcsCfg.size();
struAcsCfg.write();
IntByReference intByReference = new IntByReference(0);
boolean b_GetAcsCfg = AcsMain.hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_CFG, 0xFFFFFFFF, struAcsCfg.getPointer(),
struAcsCfg.size(), intByReference);
if (b_GetAcsCfg = false) {
System.out.println("获取门禁主机参数,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("获取门禁主机参数成功");
struAcsCfg.read();
System.out.println("1.是否显示抓拍图片:" + struAcsCfg.byShowCapPic + "\n"); //是否显示抓拍图片, 0-不显示,1-显示
System.out.println("2.是否显示卡号:" + struAcsCfg.byShowCardNo + "\n"); //是否显示卡号,0-不显示,1-显示
System.out.println("3.是否开启语音提示:" + struAcsCfg.byVoicePrompt + "\n"); //是否启用语音提示,0-不启用,1-启用
System.out.println("4.联动抓图是否上传:" + struAcsCfg.byUploadCapPic + "\n"); //联动抓拍是否上传图片,0-不上传,1-上传
}
/**设置门禁主机参数*/
struAcsCfg.byShowCardNo = 1; //开启显示卡号
struAcsCfg.byVoicePrompt = 0; //关闭语音提示
struAcsCfg.byUploadCapPic = 1; //开启联动抓图后,设备上抓拍的图片才会通过报警布防上传,否则没有不上传
struAcsCfg.byShowCapPic = 1;
struAcsCfg.write();
boolean b_SetAcsCfg = AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_ACS_CFG, 0xFFFFFFFF, struAcsCfg.getPointer(), struAcsCfg.size());
if (b_SetAcsCfg = false) {
System.out.println("设置门禁主机参数,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("设置门禁主机参数成功!!!");
}
}
/**
* 获取门禁主机工作状态
*
* @param lUserID 用户登录句柄
*/
public static void getAcsStatus(int lUserID){
HCNetSDK.NET_DVR_ACS_WORK_STATUS_V50 netDvrAcsWorkStatusV50 = new HCNetSDK.NET_DVR_ACS_WORK_STATUS_V50();
netDvrAcsWorkStatusV50.dwSize = netDvrAcsWorkStatusV50.size();
netDvrAcsWorkStatusV50.write();
IntByReference intByReference = new IntByReference(0);
boolean b_GetAcsStatus = AcsMain.hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_WORK_STATUS_V50, 0xFFFFFFFF, netDvrAcsWorkStatusV50.getPointer(),
netDvrAcsWorkStatusV50.size(), intByReference);
if (b_GetAcsStatus = false) {
System.out.println("获取门禁主机工作状态,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("获取门禁主机工作状态成功!!!");
netDvrAcsWorkStatusV50.read();
System.out.println("1.门锁状态(或者梯控的继电器开合状态):" + netDvrAcsWorkStatusV50.byDoorLockStatus[0] + "\n"); //门锁状态:0- 正常关,1- 正常开,2- 短路报警,3- 断路报警,4- 异常报警
System.out.println("2.门状态(或者梯控的楼层状态):" + netDvrAcsWorkStatusV50.byDoorStatus[0] + "\n"); //门状态(或者梯控的楼层状态):1- 休眠,2- 常开状态(对于梯控,表示自由状态),3- 常闭状态(对于梯控,表示禁用状态),4- 普通状态(对于梯控,表示受控状态)
System.out.println("3.门磁状态:" + netDvrAcsWorkStatusV50.byMagneticStatus[0] + "\n"); //门磁状态,0-正常关,1-正常开,2-短路报警,3-断路报警,4-异常报警
System.out.println("4.事件报警输入状态:" + netDvrAcsWorkStatusV50.byCaseStatus[0] + "\n"); //事件报警输入状态:0- 无输入,1- 有输入
}
}
/**
* 远程控门
* @param userID
*/
public static void remoteControlGate(int userID)
{
/**第二个参数lGatewayIndex
[in] 门禁序号(楼层编号、锁ID),从1开始,-1表示对所有门(或者梯控的所有楼层)进行操作
第三个参数dwStaic
[in] 命令值:0- 关闭(对于梯控,表示受控),1- 打开(对于梯控,表示开门),2- 常开(对于梯控,表示自由、通道状态),3- 常关(对于梯控,表示禁用),4- 恢复(梯控,普通状态),5- 访客呼梯(梯控),6- 住户呼梯(梯控)*/
boolean b_gate=AcsMain.hCNetSDK.NET_DVR_ControlGateway(userID,1,1);
if (b_gate==false)
{
System.out.println("远程控门失败,err="+AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
System.out.println("远程控门成功");
return;
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.Commom.osSelect;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Native;
import org.json.JSONException;
import java.io.UnsupportedEncodingException;
/**
*明眸门禁以卡为中心demo示例
*/
public class AcsMain {
static HCNetSDK hCNetSDK = null;
static int lUserID = -1;//用户句柄
static int iCharEncodeType = 0; //设备字符集
/**
* 根据不同操作系统选择不同的库文件和库路径
* @return
*/
private static boolean createSDKInstance()
{
if(hCNetSDK == null)
{
synchronized (HCNetSDK.class)
{
String strDllPath = "";
try
{
//System.setProperty("jna.debug_load", "true");
if(osSelect.isWindows())
//win系统加载库路径
strDllPath = System.getProperty("user.dir")+"\\lib\\HCNetSDK.dll";
else if(osSelect.isLinux())
//Linux系统加载库路径
strDllPath = System.getProperty("user.dir")+"/lib/libhcnetsdk.so";
hCNetSDK = (HCNetSDK) Native.loadLibrary(strDllPath, HCNetSDK.class);
}catch (Exception ex) {
System.out.println("loadLibrary: " + strDllPath + " Error: " + ex.getMessage());
return false;
}
}
}
return true;
}
/**
* @param args
* @throws UnsupportedEncodingException
* @throws InterruptedException
*/
public static void main(String[] args) throws UnsupportedEncodingException, InterruptedException, JSONException {
if(hCNetSDK == null)
{
if(!createSDKInstance())
{
System.out.println("Load SDK fail");
return;
}
}
//linux系统建议调用以下接口加载组件库
if (osSelect.isLinux())
{
HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256);
HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256);
//这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限
String strPath1 = System.getProperty("user.dir")+"/lib/libcrypto.so.1.1";
String strPath2 = System.getProperty("user.dir")+"/lib/libssl.so.1.1";
System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length());
ptrByteArray1.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer());
System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length());
ptrByteArray2.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer());
String strPathCom = System.getProperty("user.dir")+"/lib/";
HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
struComPath.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
}
/**初始化*/
hCNetSDK.NET_DVR_Init();
/**加载日志*/
boolean i= hCNetSDK.NET_DVR_SetLogToFile(3, "./sdklog", false);
/**登录*/
login_V40("192.168.0.111","admin","asd12345",(short)8000);
/**远程控门*/
// DoorManage.controlGateway(lUserID, 1, 0);
/**门禁主机参数设置(获取)*/
ACSManage.acsCfg(lUserID);
/**获取门禁主机工作状态*/
// ACSManage.getAcsStatus(lUserID);
/**设置卡计划模块*/
// CardManage.setCardTemplate(lUserID, 2);
/**卡下发*/
// CardManage.setOneCard(lUserID, "123555", 2222, (short) 1);
/**获取(查询)一张卡信息*/
// CardManage.getOneCard(lUserID, "123555");
/**
* 删除人员
*/
// UserManage.deleteUserInfo(lUserID);
/**获取所有卡*/
// CardManage.getAllCard(lUserID);
/**批量卡号下发*/
// String[] CardNo = new String[]{"1111", "2222", "3333", "4444"};
// int[] EmployeeNo = new int[]{111, 222, 333, 444};
// CardManage.setMultiCard(lUserID, CardNo, EmployeeNo, 4);
/**删除单张卡(删除单张卡号之前要先删除这张卡关联的人脸和指纹信息)*/
// CardManage.delOneCard(lUserID,"123555");
/**清空设备所有人脸、指纹、卡号信息*/
// CardManage.cleanCardInfo(lUserID);
/**下发一张人脸*/
/**注意:下发人脸之前先下发卡号 */
// FaceManage.setOneFace(lUserID,"123555");
/**删除单独人脸信息*/
// FaceManage.delOneFace(lUserID,"123555");
/**查询单张卡号关联的人脸信息*/
// FaceManage.getFaceCfg(lUserID,"4444");
/**人脸采集(设备采集人脸图片保存到本地)*/
// FaceManage.captureFaceInfo(lUserID);
/**门状态计划模板配置*/
// DoorManage.doorTemplate(lUserID,1);
/**指纹采集*/
// FingerManage.captureFinger(lUserID);
/**指纹下发*/
// FingerManage.setOneFinger(lUserID,"123555");
/**指纹删除*/
// FingerManage.delFinger(lUserID,"123123");
/**查询设备事件*/
EventSearch.searchAllEvent(lUserID);
/**下发身份证禁止名单*/
// IDBlockListManage.uploadBlockList(lUserID);
/**清空身份证禁止名单*/
// IDBlockListManage.cleanBlockList(lUserID);
/**
* 增加sleep时间,保证程序一直运行,
*/
Thread.sleep(20000);
/**登出操作*/
AcsMain.logout();
//释放SDK,程序退出前调用
hCNetSDK.NET_DVR_Cleanup();
return;
}
/**
* 设备登录
* @param ipadress IP地址
* @param user 用户名
* @param psw 密码
* @param port 端口,默认8000
*/
public static void login_V40(String ipadress, String user, String psw, short port) {
//注册
HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
String m_sDeviceIP = ipadress;//设备ip地址
m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
String m_sUsername = user;//设备用户名
m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
String m_sPassword = psw;//设备密码
m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
m_strLoginInfo.wPort = port; //sdk端口
m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
m_strLoginInfo.write();
HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
if (lUserID == -1) {
System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("登录成功!");
m_strDeviceInfo.read();
iCharEncodeType = m_strDeviceInfo.byCharEncodeType;
return;
}
}
/**
* 登出操作
*
*/
public static void logout(){
/**登出和清理,释放SDK资源*/
if (lUserID>=0)
{
hCNetSDK.NET_DVR_Logout(lUserID);
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.io.UnsupportedEncodingException;
/**
* @create 2021-03-12-13:53
* 以卡为中心,先下发卡参数(可以一起下发工号),再根据卡号下发人脸、指纹等参数
* 卡管理模块,实现功能:卡下发、卡获取(单张、所有)、卡删除(单张、所有)、卡计划模块设置
*/
public class CardManage {
public static short iPlanTemplateNumber;
/**
* 卡下发
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @param EmployeeNo 工号 卡下发的时候可以一起下发工号
* @param iPlanTemplateNumber 关联门计划模板,计划模板的配置可以参考卡计划模板配置模块,(下发卡前要设置好计划模板)
* @throws UnsupportedEncodingException
* @throws InterruptedException
*/
public static void setOneCard(int lUserID, String CardNo, int EmployeeNo, short iPlanTemplateNumber) throws UnsupportedEncodingException, InterruptedException {
HCNetSDK.NET_DVR_CARD_COND struCardCond = new HCNetSDK.NET_DVR_CARD_COND();
struCardCond.read();
struCardCond.dwSize = struCardCond.size();
struCardCond.dwCardNum = 1; //下发一张
struCardCond.write();
Pointer ptrStruCond = struCardCond.getPointer();
int m_lSetCardCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_SET_CARD, ptrStruCond, struCardCond.size(), null, null);
if (m_lSetCardCfgHandle == -1) {
System.out.println("建立下发卡长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立下发卡长连接成功!");
}
HCNetSDK.NET_DVR_CARD_RECORD struCardRecord = new HCNetSDK.NET_DVR_CARD_RECORD();
struCardRecord.read();
struCardRecord.dwSize = struCardRecord.size();
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struCardRecord.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struCardRecord.byCardNo[i] = CardNo.getBytes()[i];
}
struCardRecord.byCardType = 1; //普通卡
struCardRecord.byLeaderCard = 0; //是否为首卡,0-否,1-是
struCardRecord.byUserType = 0;
struCardRecord.byDoorRight[0] = 1; //门1有权限
struCardRecord.wCardRightPlan[0] = iPlanTemplateNumber; //关联门计划模板,计划模板的配置可以参考卡计划模板配置模块,(下发卡前要设置好计划模板)
struCardRecord.wCardRightPlan[1] = (short) 2;
struCardRecord.struValid.byEnable = 1; //卡有效期使能,下面是卡有效期从2000-1-1 11:11:11到2030-1-1 11:11:11
struCardRecord.struValid.struBeginTime.wYear = 2020;
struCardRecord.struValid.struBeginTime.byMonth = 1;
struCardRecord.struValid.struBeginTime.byDay = 1;
struCardRecord.struValid.struBeginTime.byHour = 11;
struCardRecord.struValid.struBeginTime.byMinute = 11;
struCardRecord.struValid.struBeginTime.bySecond = 11;
struCardRecord.struValid.struEndTime.wYear = 2022;
struCardRecord.struValid.struEndTime.byMonth = 1;
struCardRecord.struValid.struEndTime.byDay = 1;
struCardRecord.struValid.struEndTime.byHour = 11;
struCardRecord.struValid.struEndTime.byMinute = 11;
struCardRecord.struValid.struEndTime.bySecond = 11;
struCardRecord.dwEmployeeNo = EmployeeNo; //工号 卡下发的时候可以一起下发工号
if ((AcsMain.iCharEncodeType == 0) || (AcsMain.iCharEncodeType == 1) || (AcsMain.iCharEncodeType == 2)) {
byte[] strCardName = "jx".getBytes("GBK"); //姓名
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struCardRecord.byName[i] = 0;
}
System.arraycopy(strCardName, 0, struCardRecord.byName, 0, strCardName.length);
}
if (AcsMain.iCharEncodeType == 6) {
byte[] strCardName = "jx".getBytes("UTF-8"); //姓名
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struCardRecord.byName[i] = 0;
}
System.arraycopy(strCardName, 0, struCardRecord.byName, 0, strCardName.length);
}
struCardRecord.write();
HCNetSDK.NET_DVR_CARD_STATUS struCardStatus = new HCNetSDK.NET_DVR_CARD_STATUS();
struCardStatus.read();
struCardStatus.dwSize = struCardStatus.size();
struCardStatus.write();
IntByReference pInt = new IntByReference(0);
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetCardCfgHandle, struCardRecord.getPointer(), struCardRecord.size(), struCardStatus.getPointer(), struCardStatus.size(), pInt);
struCardStatus.read();
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
Thread.sleep(10);
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("下发卡失败, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("下发卡异常, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struCardStatus.dwErrorCode != 0) {
System.out.println("下发卡成功,但是错误码" + struCardStatus.dwErrorCode + ", 卡号:" + new String(struCardStatus.byCardNo).trim());
} else {
System.out.println("下发卡成功, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 状态:" + struCardStatus.byStatus);
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("下发卡完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSetCardCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 批量卡号下发
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @param iEmployeeNo 工号
* @param iNum 下发张数
* @throws UnsupportedEncodingException
* @throws InterruptedException
*/
public static void setMultiCard(int lUserID, String[] CardNo, int[] iEmployeeNo, int iNum) throws UnsupportedEncodingException, InterruptedException {
HCNetSDK.NET_DVR_CARD_COND struCardCond = new HCNetSDK.NET_DVR_CARD_COND();
struCardCond.read();
struCardCond.dwSize = struCardCond.size();
struCardCond.dwCardNum = iNum; //下发张数
struCardCond.write();
Pointer ptrStruCond = struCardCond.getPointer();
int m_lSetMultiCardCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_SET_CARD, ptrStruCond, struCardCond.size(), null, null);
if (m_lSetMultiCardCfgHandle == -1) {
System.out.println("建立下发卡长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立下发卡长连接成功!");
}
HCNetSDK.NET_DVR_CARD_RECORD[] struCardRecord = (HCNetSDK.NET_DVR_CARD_RECORD[]) new HCNetSDK.NET_DVR_CARD_RECORD().toArray(iNum);
HCNetSDK.NET_DVR_CARD_STATUS struCardStatus = new HCNetSDK.NET_DVR_CARD_STATUS();
struCardStatus.read();
struCardStatus.dwSize = struCardStatus.size();
struCardStatus.write();
IntByReference pInt = new IntByReference(0);
for (int i = 0; i < iNum; i++) {
struCardRecord[i].read();
struCardRecord[i].dwSize = struCardRecord[i].size();
for (int j = 0; j < HCNetSDK.ACS_CARD_NO_LEN; j++) {
struCardRecord[i].byCardNo[j] = 0;
}
System.arraycopy(CardNo[i].getBytes(), 0, struCardRecord[i].byCardNo, 0, CardNo[i].getBytes().length);
struCardRecord[i].byCardType = 1; //普通卡
struCardRecord[i].byLeaderCard = 0; //是否为首卡,0-否,1-是
struCardRecord[i].byUserType = 0;
struCardRecord[i].byDoorRight[0] = 1; //门1有权限
struCardRecord[i].wCardRightPlan[0] = iPlanTemplateNumber;//关联门计划模板,使用了前面配置的计划模板
struCardRecord[i].struValid.byEnable = 1; //卡有效期使能,下面是卡有效期从2000-1-1 11:11:11到2030-1-1 11:11:11
struCardRecord[i].struValid.struBeginTime.wYear = 2000;
struCardRecord[i].struValid.struBeginTime.byMonth = 1;
struCardRecord[i].struValid.struBeginTime.byDay = 1;
struCardRecord[i].struValid.struBeginTime.byHour = 11;
struCardRecord[i].struValid.struBeginTime.byMinute = 11;
struCardRecord[i].struValid.struBeginTime.bySecond = 11;
struCardRecord[i].struValid.struEndTime.wYear = 2030;
struCardRecord[i].struValid.struEndTime.byMonth = 1;
struCardRecord[i].struValid.struEndTime.byDay = 1;
struCardRecord[i].struValid.struEndTime.byHour = 11;
struCardRecord[i].struValid.struEndTime.byMinute = 11;
struCardRecord[i].struValid.struEndTime.bySecond = 11;
struCardRecord[i].dwEmployeeNo = iEmployeeNo[i]; //工号
if ((AcsMain.iCharEncodeType == 0) || (AcsMain.iCharEncodeType == 1) || (AcsMain.iCharEncodeType == 2)) {
byte[] strCardName = "张三".getBytes("GBK"); //姓名
for (int j = 0; j < HCNetSDK.NAME_LEN; j++) {
struCardRecord[i].byName[j] = 0;
}
System.arraycopy(strCardName, 0, struCardRecord[i].byName, 0, strCardName.length);
}
if (AcsMain.iCharEncodeType == 6) {
byte[] strCardName = "张三".getBytes("UTF-8"); //姓名
for (int j = 0; j < HCNetSDK.NAME_LEN; j++) {
struCardRecord[i].byName[j] = 0;
}
System.arraycopy(strCardName, 0, struCardRecord[i].byName, 0, strCardName.length);
}
struCardRecord[i].write();
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetMultiCardCfgHandle, struCardRecord[i].getPointer(), struCardRecord[i].size(), struCardStatus.getPointer(), struCardStatus.size(), pInt);
struCardStatus.read();
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("下发卡失败, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
//可以继续下发下一个
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("下发卡异常, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
//异常是长连接异常,不能继续下发后面的数据,需要重新建立长连接
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struCardStatus.dwErrorCode != 0) {
System.out.println("下发卡失败,错误码" + struCardStatus.dwErrorCode + ", 卡号:" + new String(struCardStatus.byCardNo).trim());
} else {
System.out.println("下发卡成功, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 状态:" + struCardStatus.byStatus);
}
//可以继续下发下一个
} else {
System.out.println("其他状态:" + dwState);
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSetMultiCardCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 获取(查询)一张卡
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
*/
public static void getOneCard(int lUserID, String CardNo) {
HCNetSDK.NET_DVR_CARD_COND struCardCond = new HCNetSDK.NET_DVR_CARD_COND();
struCardCond.read();
struCardCond.dwSize = struCardCond.size();
struCardCond.dwCardNum = 1; //查询一个卡参数
struCardCond.write();
Pointer ptrStruCond = struCardCond.getPointer();
int m_lGetCardCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_CARD, ptrStruCond, struCardCond.size(), null, null);
if (m_lGetCardCfgHandle == -1) {
System.out.println("建立查询卡参数长连接失败,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立查询卡参数长连接成功!");
}
//查找指定卡号的参数,需要下发查找的卡号条件
HCNetSDK.NET_DVR_CARD_SEND_DATA struCardNo = new HCNetSDK.NET_DVR_CARD_SEND_DATA();
struCardNo.read();
struCardNo.dwSize = struCardNo.size();
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struCardNo.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struCardNo.byCardNo[i] = CardNo.getBytes()[i];
}
struCardNo.write();
HCNetSDK.NET_DVR_CARD_RECORD struCardRecord = new HCNetSDK.NET_DVR_CARD_RECORD();
struCardRecord.read();
IntByReference pInt = new IntByReference(0);
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lGetCardCfgHandle, struCardNo.getPointer(), struCardNo.size(),
struCardRecord.getPointer(), struCardRecord.size(), pInt);
struCardRecord.read();
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig查询卡参数调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("获取卡参数失败, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("获取卡参数异常, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
try {
String strName = "";
if ((AcsMain.iCharEncodeType == 0) || (AcsMain.iCharEncodeType == 1) || (AcsMain.iCharEncodeType == 2)) {
strName = new String(struCardRecord.byName, "GBK").trim();
}
if (AcsMain.iCharEncodeType == 6) {
strName = new String(struCardRecord.byName, "UTF-8").trim();
}
//获取的卡信息打印
System.out.println("获取卡参数成功, 卡号: " + new String(struCardRecord.byCardNo).trim()
+ ", 卡类型:" + struCardRecord.byCardType
+ ", 姓名:" + strName);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取卡参数完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lGetCardCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 获取所有卡
*
* @param lUserID 用户登录句柄
*/
public static void getAllCard(int lUserID) {
HCNetSDK.NET_DVR_CARD_COND struCardCond = new HCNetSDK.NET_DVR_CARD_COND();
struCardCond.read();
struCardCond.dwSize = struCardCond.size();
struCardCond.dwCardNum = 0xffffffff; //查询所有卡
struCardCond.write();
Pointer ptrStruCond = struCardCond.getPointer();
int m_lGetAllCardCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_CARD, ptrStruCond, struCardCond.size(), null, null);
if (m_lGetAllCardCfgHandle == -1) {
System.out.println("建立查询卡长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立查询卡长连接成功!");
}
HCNetSDK.NET_DVR_CARD_RECORD struCardRecord = new HCNetSDK.NET_DVR_CARD_RECORD();
struCardRecord.read();
struCardRecord.dwSize = struCardRecord.size();
struCardRecord.write();
IntByReference pInt = new IntByReference(0);
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(m_lGetAllCardCfgHandle, struCardRecord.getPointer(), struCardRecord.size());
struCardRecord.read();
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("获取卡参数失败");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("获取卡参数异常");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
try {
String strName = "";
if ((AcsMain.iCharEncodeType == 0) || (AcsMain.iCharEncodeType == 1) || (AcsMain.iCharEncodeType == 2)) {
strName = new String(struCardRecord.byName, "GBK").trim();
}
if (AcsMain.iCharEncodeType == 6) {
strName = new String(struCardRecord.byName, "UTF-8").trim();
}
//获取的卡信息打印
System.out.println("获取卡参数成功, 卡号: " + new String(struCardRecord.byCardNo).trim()
+ ", 卡类型:" + struCardRecord.byCardType
+ ", 姓名:" + strName);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取卡参数完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lGetAllCardCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 删除单张卡(删除单张卡号之前要先删除这张卡关联的人脸和指纹信息)
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @throws UnsupportedEncodingException
* @throws InterruptedException
*/
public static void delOneCard(int lUserID, String CardNo) throws UnsupportedEncodingException, InterruptedException {
HCNetSDK.NET_DVR_CARD_COND struCardCond = new HCNetSDK.NET_DVR_CARD_COND();
struCardCond.read();
struCardCond.dwSize = struCardCond.size();
struCardCond.dwCardNum = 1; //删除一张卡号
struCardCond.write();
Pointer ptrStruCond = struCardCond.getPointer();
int m_lDelCardCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_DEL_CARD, ptrStruCond, struCardCond.size(), null, null);
if (m_lDelCardCfgHandle == -1) {
System.out.println("建立删除卡长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立删除卡长连接成功!");
}
HCNetSDK.NET_DVR_CARD_SEND_DATA struCardData = new HCNetSDK.NET_DVR_CARD_SEND_DATA();
struCardData.read();
struCardData.dwSize = struCardData.size();
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struCardData.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struCardData.byCardNo[i] = CardNo.getBytes()[i];
}
struCardData.write();
HCNetSDK.NET_DVR_CARD_STATUS struCardStatus = new HCNetSDK.NET_DVR_CARD_STATUS();
struCardStatus.read();
struCardStatus.dwSize = struCardStatus.size();
struCardStatus.write();
IntByReference pInt = new IntByReference(0);
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lDelCardCfgHandle, struCardData.getPointer(), struCardData.size(), struCardStatus.getPointer(), struCardStatus.size(), pInt);
struCardStatus.read();
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
Thread.sleep(10);
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("删除卡失败, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("删除卡异常, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 错误码:" + struCardStatus.dwErrorCode);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struCardStatus.dwErrorCode != 0) {
System.out.println("删除卡成功,但是错误码" + struCardStatus.dwErrorCode + ", 卡号:" + new String(struCardStatus.byCardNo).trim());
} else {
System.out.println("删除卡成功, 卡号: " + new String(struCardStatus.byCardNo).trim() + ", 状态:" + struCardStatus.byStatus);
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("删除卡完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lDelCardCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 清空设备卡号、人脸、指纹信息
* 清空设备所有人脸、指纹、卡号信息
*
* 设备中要清除所有已经下发的卡号,必须先和卡号关联的人脸信息、指纹信息,人脸和指纹清除后清楚,再调用清空卡号的接口,清空设备上所有卡号
* @param lUserID 用户登录句柄
*/
public static void cleanCardInfo(int lUserID) {
//清空所有人脸信息
HCNetSDK.NET_DVR_FACE_PARAM_CTRL struFaceCtrl = new HCNetSDK.NET_DVR_FACE_PARAM_CTRL();
struFaceCtrl.read();
struFaceCtrl.dwSize = struFaceCtrl.size();
struFaceCtrl.byMode = 1; //删除方式:0- 按卡号方式删除,1- 按读卡器删除
if (struFaceCtrl.byMode == 1) {
struFaceCtrl.struProcessMode.setType(HCNetSDK.NET_DVR_FACE_PARAM_BYREADER.class);
struFaceCtrl.struProcessMode.struByReader.dwCardReaderNo = 1; //读卡器编号
struFaceCtrl.struProcessMode.struByReader.byClearAllCard = 1; //是否删除所有卡的人脸信息:0- 按卡号删除人脸信息,1- 删除所有卡的人脸信息
}
struFaceCtrl.write();
boolean b_face = AcsMain.hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_DEL_FACE_PARAM_CFG, struFaceCtrl.getPointer(), struFaceCtrl.size());
if (b_face == false) {
System.out.println("删除人脸错误,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("删除人脸成功");
}
//清空所有指纹
HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL struFingerCtrl = new HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL();
struFingerCtrl.read();
struFingerCtrl.dwSize = struFingerCtrl.size();
struFingerCtrl.byMode = 1; //删除方式:0- 按卡号方式删除,1- 按读卡器删除
if (struFingerCtrl.byMode == 1) {
struFingerCtrl.struProcessMode.setType(HCNetSDK.NET_DVR_FINGER_PRINT_BYREADER.class);
struFingerCtrl.struProcessMode.struByReader.dwCardReaderNo = 1; //读卡器编号
struFingerCtrl.struProcessMode.struByReader.byClearAllCard = 1; //是否删除所有卡的指纹信息:0- 按卡号删除指纹信息,1- 删除所有卡的指纹信息
}
struFingerCtrl.write();
boolean b_finger = AcsMain.hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_DEL_FINGERPRINT_CFG, struFingerCtrl.getPointer(), struFingerCtrl.size());
if (b_finger == false) {
System.out.println("删除指纹错误,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("删除指纹成功");
}
//清空所有卡号
HCNetSDK.NET_DVR_ACS_PARAM_TYPE struAcsPapamType = new HCNetSDK.NET_DVR_ACS_PARAM_TYPE();
struAcsPapamType.read();
struAcsPapamType.dwSize = struAcsPapamType.size();
struAcsPapamType.dwParamType = HCNetSDK.ACS_PARAM_CARD; //清空卡参数
struAcsPapamType.wLocalControllerID = 0; // 就地控制器序号[1,255],0代表门禁主机
struAcsPapamType.write();
boolean b_AcsCard = AcsMain.hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_CLEAR_ACS_PARAM, struAcsPapamType.getPointer(), struAcsPapamType.size());
if (b_AcsCard == false) {
System.out.println("清空卡号错误,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("清空卡号成功");
}
}
/**
* 卡计划模板配置
*
* @param lUserID 用户登录句柄
* @param iPlanTemplateNumber 计划模板编号,从1开始,最大值从门禁能力集获取
*/
public static void setCardTemplate(int lUserID, int iPlanTemplateNumber) {
//设置卡权限计划模板参数
HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND struPlanCond = new HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND();
struPlanCond.dwSize = struPlanCond.size();
struPlanCond.dwPlanTemplateNumber = iPlanTemplateNumber;//计划模板编号,从1开始,最大值从门禁能力集获取
struPlanCond.wLocalControllerID = 0;//就地控制器序号[1,64],0表示门禁主机
struPlanCond.write();
HCNetSDK.NET_DVR_PLAN_TEMPLATE struPlanTemCfg = new HCNetSDK.NET_DVR_PLAN_TEMPLATE();
struPlanTemCfg.dwSize = struPlanTemCfg.size();
struPlanTemCfg.byEnable = 1; //是否使能:0- 否,1- 是
struPlanTemCfg.dwWeekPlanNo = 2;//周计划编号,0表示无效
struPlanTemCfg.dwHolidayGroupNo[0] = 0;//假日组编号,按值表示,采用紧凑型排列,中间遇到0则后续无效
byte[] byTemplateName;
try {
byTemplateName = "CardTemplatePlan_2".getBytes("GBK");
//计划模板名称
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struPlanTemCfg.byTemplateName[i] = 0;
}
System.arraycopy(byTemplateName, 0, struPlanTemCfg.byTemplateName, 0, byTemplateName.length);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
struPlanTemCfg.write();
IntByReference pInt = new IntByReference(0);
Pointer lpStatusList = pInt.getPointer();
if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(lUserID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50, 1, struPlanCond.getPointer(), struPlanCond.size(), lpStatusList, struPlanTemCfg.getPointer(), struPlanTemCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50成功!");
//获取卡权限周计划参数
HCNetSDK.NET_DVR_WEEK_PLAN_COND struWeekPlanCond = new HCNetSDK.NET_DVR_WEEK_PLAN_COND();
struWeekPlanCond.dwSize = struWeekPlanCond.size();
struWeekPlanCond.dwWeekPlanNumber = 2;
struWeekPlanCond.wLocalControllerID = 0;
HCNetSDK.NET_DVR_WEEK_PLAN_CFG struWeekPlanCfg = new HCNetSDK.NET_DVR_WEEK_PLAN_CFG();
struWeekPlanCond.write();
struWeekPlanCfg.write();
Pointer lpCond = struWeekPlanCond.getPointer();
Pointer lpInbuferCfg = struWeekPlanCfg.getPointer();
if (false == AcsMain.hCNetSDK.NET_DVR_GetDeviceConfig(lUserID, HCNetSDK.NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
struWeekPlanCfg.read();
struWeekPlanCfg.byEnable = 1; //是否使能:0- 否,1- 是
/**避免时间段交叉,先初始化, 七天八小时*/
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 8; j++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].byEnable = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.bySecond = 0;
}
}
/**一周7天,全天24小时*/
for (int i = 0; i < 7; i++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 14;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 16;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 0;
}
/**一周7天,每天设置2个时间段*/
/*for(int i=0;i<7;i++)
{
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 11;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byHour = 13;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byMinute = 30;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byHour = 19;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.bySecond = 59;
}*/
struWeekPlanCfg.write();
//设置卡权限周计划参数
if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(lUserID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}else {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50成功!");
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.io.UnsupportedEncodingException;
/**
* @create 2021-03-11-14:12
*/
public class DoorManage {
/**
* 门状态计划模板配置
*
* @param lUserID 用户登录句柄
* @param iDoorTemplateNo 计划模板编号,为0表示取消关联,恢复默认状态(普通状态)
*/
public static void doorTemplate(int lUserID, int iDoorTemplateNo) {
//设置门状态计划参数
HCNetSDK.NET_DVR_DOOR_STATUS_PLAN struDoorStatus = new HCNetSDK.NET_DVR_DOOR_STATUS_PLAN();
struDoorStatus.read();
struDoorStatus.dwSize = struDoorStatus.size();
struDoorStatus.dwTemplateNo = iDoorTemplateNo;
struDoorStatus.write();
boolean b_SetDoorStatus = AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_DOOR_STATUS_PLAN, 1, struDoorStatus.getPointer(), struDoorStatus.size());
if (b_SetDoorStatus == false) {
System.out.println("设置门状态计划参数,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("设置门状态计划参数成功");
}
//设置门状态计划模板参数
HCNetSDK.NET_DVR_PLAN_TEMPLATE struDoorTemp = new HCNetSDK.NET_DVR_PLAN_TEMPLATE();
struDoorTemp.read();
struDoorTemp.dwSize = struDoorTemp.size();
struDoorTemp.byEnable = 1; //使能
struDoorTemp.dwWeekPlanNo = 1; //周计划模板编号;
byte[] byTemplateName;
try {
byTemplateName = "DoorTemplatePlan_1".getBytes("GBK");
//计划模板名称
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struDoorTemp.byTemplateName[i] = 0;
}
System.arraycopy(byTemplateName, 0, struDoorTemp.byTemplateName, 0, byTemplateName.length);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
struDoorTemp.write();
boolean b_SetDoorTemp = AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_DOOR_STATUS_PLAN_TEMPLATE, iDoorTemplateNo, struDoorTemp.getPointer(), struDoorTemp.size());
if (b_SetDoorTemp == false) {
System.out.println("设置门状态计划模板失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("设置门状态计划模板成功");
}
//获取(设置)门状态周计划参数
HCNetSDK.NET_DVR_WEEK_PLAN_CFG struDoorWeekPlan = new HCNetSDK.NET_DVR_WEEK_PLAN_CFG();
struDoorWeekPlan.read();
Pointer pstruDoorWeekPlan = struDoorWeekPlan.getPointer();
IntByReference Ipint = new IntByReference(0);
boolean b_GetPlan = AcsMain.hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_WEEK_PLAN_CFG, 1, pstruDoorWeekPlan, struDoorWeekPlan.size(), Ipint);
if (b_GetPlan == false) {
System.out.println("获取门状态周计划参数失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("获取门状态周计划参数成功");
}
struDoorWeekPlan.read();
struDoorWeekPlan.byEnable = 1; //是否使能:0- 否,1- 是
/**避免时间段交叉,先初始化*/
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 8; j++) {
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].byEnable = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byHour = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byMinute = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.bySecond = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byHour = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byMinute = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.bySecond = 0;
}
}
/**一周7天,全天24小时*/
for (int i = 0; i < 7; i++) {
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 23;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 0;
struDoorWeekPlan.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 0;
}
/**一周7天,每天设置2个时间段*/
/*for(int i=0;i<7;i++)
{
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 11;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byHour = 13;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byMinute = 30;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byHour = 19;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.bySecond = 59;
}*/
struDoorWeekPlan.write();
boolean b_SetPlan = AcsMain.hCNetSDK.NET_DVR_SetDVRConfig(lUserID, HCNetSDK.NET_DVR_SET_WEEK_PLAN_CFG, 1, pstruDoorWeekPlan, struDoorWeekPlan.size());
if (b_SetPlan == false) {
System.out.println("获取设置状态周计划参数失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("设置门状态周计划参数成功");
}
}
/**
* 远程控门
*
* @param lUserID 用户登录句柄
* @param lGatewayIndex 门禁序号(楼层编号、锁ID),从1开始,-1表示对所有门(或者梯控的所有楼层)进行操作
* @param dwStaic 命令值:0- 关闭(对于梯控,表示受控),1- 打开(对于梯控,表示开门),2- 常开(对于梯控,表示自由、通道状态),3- 常关(对于梯控,表示禁用),4- 恢复(梯控,普通状态),5- 访客呼梯(梯控),6- 住户呼梯(梯控)
*/
public static void controlGateway(int lUserID, int lGatewayIndex, int dwStaic) {
boolean b_Gate = AcsMain.hCNetSDK.NET_DVR_ControlGateway(lUserID, lGatewayIndex, dwStaic);
if (b_Gate == false) {
System.out.println("NET_DVR_ControlGateway远程控门失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}else {
System.out.println("远程控门成功");
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
/**
* 事件查询模块
*/
public final class EventSearch {
public static void searchAllEvent(int lUserID) throws UnsupportedEncodingException, InterruptedException {
int i = 0; //事件条数
HCNetSDK.NET_DVR_ACS_EVENT_COND struAcsEventCond = new HCNetSDK.NET_DVR_ACS_EVENT_COND();
struAcsEventCond.read();
struAcsEventCond.dwSize = struAcsEventCond.size();
//查询全部主次类型的报警
struAcsEventCond.dwMajor = 0; // 主次事件类型设为0,代表查询所有事件
struAcsEventCond.dwMinor = 0; //
//开始时间
struAcsEventCond.struStartTime.dwYear = 2023;
struAcsEventCond.struStartTime.dwMonth = 11;
struAcsEventCond.struStartTime.dwDay = 01;
struAcsEventCond.struStartTime.dwHour = 9;
struAcsEventCond.struStartTime.dwMinute = 0;
struAcsEventCond.struStartTime.dwSecond = 0;
//结束时间
struAcsEventCond.struEndTime.dwYear = 2023;
struAcsEventCond.struEndTime.dwMonth = 11;
struAcsEventCond.struEndTime.dwDay = 30;
struAcsEventCond.struEndTime.dwHour = 16;
struAcsEventCond.struEndTime.dwMinute = 0;
struAcsEventCond.struEndTime.dwSecond = 0;
struAcsEventCond.wInductiveEventType = 1;
struAcsEventCond.byPicEnable = 1; //是否带图片,0-不带图片,1-带图片
struAcsEventCond.write();
Pointer ptrStruEventCond = struAcsEventCond.getPointer();
int m_lSearchEventHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_EVENT, ptrStruEventCond, struAcsEventCond.size(), null, null);
if (m_lSearchEventHandle<=-1)
{
System.out.println("NET_DVR_StartRemoteConfig调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}
HCNetSDK.NET_DVR_ACS_EVENT_CFG struAcsEventCfg = new HCNetSDK.NET_DVR_ACS_EVENT_CFG();
struAcsEventCfg.read();
struAcsEventCfg.dwSize = struAcsEventCfg.size();
struAcsEventCfg.write();
Pointer ptrStruEventCfg = struAcsEventCfg.getPointer();
while (true) {
System.out.println("i=" + i);
int dwEventSearch = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(m_lSearchEventHandle, ptrStruEventCfg, struAcsEventCfg.size());
if (dwEventSearch <= -1) {
System.out.println("NET_DVR_GetNextRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}
if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT) {
System.out.println("配置等待....");
Thread.sleep(10);
continue;
} else if (dwEventSearch == HCNetSDK.NET_SDK_NEXT_STATUS__FINISH) {
System.out.println("获取事件完成");
break;
} else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED) {
System.out.println("获取事件出现异常");
break;
} else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) {
struAcsEventCfg.read();
//获取的事件信息通过struAcsEventCfg结构体进行解析,
System.out.println(i + "获取事件成功, 报警主类型:" + Integer.toHexString(struAcsEventCfg.dwMajor) + "报警次类型:" + Integer.toHexString(struAcsEventCfg.dwMinor) + "卡号:" + new String(struAcsEventCfg.struAcsEventInfo.byCardNo).trim());
/**
* 工号有两个字段,dwEmployeeNo表示工号,当值为0时,表示无效,解析byEmployeeNo参数
*/
System.out.println("工号1:"+struAcsEventCfg.struAcsEventInfo.dwEmployeeNo);
System.out.println("工号2:"+new String(struAcsEventCfg.struAcsEventInfo.byEmployeeNo,"GBK"));
//人脸温度数据,需要设备和支持测温功能
System.out.println("人脸温度:" + struAcsEventCfg.struAcsEventInfo.fCurrTemperature + "是否异常:" + struAcsEventCfg.struAcsEventInfo.byIsAbnomalTemperature);
//口罩功能,需要设备支持此功能 0-保留,1-未知,2-不戴口罩,3-戴口罩
System.out.println("是否带口罩:"+struAcsEventCfg.struAcsEventInfo.byMask);
System.out.println("考勤状态值:"+struAcsEventCfg.struAcsEventInfo.byStatusValue);
System.out.println("时间:"+struAcsEventCfg.struTime);
//人脸图片保存
if (struAcsEventCfg.dwPicDataLen>0 || struAcsEventCfg.pPicData != null )
{
FileOutputStream fout;
try {
/**
* 人脸图片保存路径
*/
String filename = "..\\pic\\"+i+"_event.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = struAcsEventCfg.pPicData.getByteBuffer(offset, struAcsEventCfg.dwPicDataLen);
byte[] bytes = new byte[struAcsEventCfg.dwPicDataLen];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
i++;
continue;
}
}
i = 0;
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSearchEventHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
return;
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.io.*;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 人脸管理模块
* 实现功能:人脸下发(单张、多张)、人脸查询、人脸删除、人脸采集
*/
public class FaceManage {
static int dwState = -1; //下发卡数据状态
/**
* 下发一张人脸
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @throws InterruptedException
*/
public static void setOneFace(int lUserID, String CardNo) throws InterruptedException {
HCNetSDK.NET_DVR_FACE_COND struFaceCond = new HCNetSDK.NET_DVR_FACE_COND();
struFaceCond.read();
struFaceCond.dwSize = struFaceCond.size();
struFaceCond.byCardNo = CardNo.getBytes();
struFaceCond.dwFaceNum = 1; //下发一张
struFaceCond.dwEnableReaderNo = 1;//人脸读卡器编号
struFaceCond.write();
Pointer ptrStruFaceCond = struFaceCond.getPointer();
int m_lSetFaceCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_SET_FACE, ptrStruFaceCond, struFaceCond.size(), null, null);
if (m_lSetFaceCfgHandle == -1) {
System.out.println("建立下发人脸长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立下发人脸长连接成功!");
}
HCNetSDK.NET_DVR_FACE_RECORD struFaceRecord = new HCNetSDK.NET_DVR_FACE_RECORD();
struFaceRecord.read();
struFaceRecord.dwSize = struFaceRecord.size();
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struFaceRecord.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struFaceRecord.byCardNo[i] = CardNo.getBytes()[i];
}
/*****************************************
* 从本地文件里面读取JPEG图片二进制数据
*****************************************/
FileInputStream picfile = null;
int picdataLength = 0;
try {
picfile = new FileInputStream(new File(System.getProperty("user.dir") + "\\pic\\FDLib.jpg"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
picdataLength = picfile.available();
} catch (IOException e1) {
e1.printStackTrace();
}
if (picdataLength < 0) {
System.out.println("input file dataSize < 0");
return;
}
HCNetSDK.BYTE_ARRAY ptrpicByte = new HCNetSDK.BYTE_ARRAY(picdataLength);
try {
picfile.read(ptrpicByte.byValue);
} catch (IOException e2) {
e2.printStackTrace();
}
ptrpicByte.write();
struFaceRecord.dwFaceLen = picdataLength;
struFaceRecord.pFaceBuffer = ptrpicByte.getPointer();
struFaceRecord.write();
HCNetSDK.NET_DVR_FACE_STATUS struFaceStatus = new HCNetSDK.NET_DVR_FACE_STATUS();
struFaceStatus.read();
struFaceStatus.dwSize = struFaceStatus.size();
struFaceStatus.write();
IntByReference pInt = new IntByReference(0);
while (true) {
int dwFaceState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetFaceCfgHandle, struFaceRecord.getPointer(), struFaceRecord.size(), struFaceStatus.getPointer(), struFaceStatus.size(), pInt);
struFaceStatus.read();
if (dwFaceState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
Thread.sleep(10);
continue;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("下发人脸失败, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("下发人脸异常, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struFaceStatus.byRecvStatus != 1) {
System.out.println("下发人脸失败,人脸读卡器状态:" + struFaceStatus.byRecvStatus + ", 下发错误信息:" + new String(struFaceStatus.byErrorMsg) + ", 卡号:" + new String(struFaceStatus.byCardNo).trim());
break;
} else {
System.out.println("下发人脸成功, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 状态:" + struFaceStatus.byRecvStatus);
}
continue;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("下发人脸完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSetFaceCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
//批量下发多张人脸
public static void setMultiFace(int lUserID, String[] CardNo, String[] strFilePath, int iNum) throws InterruptedException {
HCNetSDK.NET_DVR_FACE_COND struFaceCond = new HCNetSDK.NET_DVR_FACE_COND();
struFaceCond.read();
struFaceCond.dwSize = struFaceCond.size();
struFaceCond.byCardNo = new byte[32]; //批量下发,该卡号不需要赋值
struFaceCond.dwFaceNum = iNum; //下发人脸个数
struFaceCond.dwEnableReaderNo = 1;//人脸读卡器编号
struFaceCond.write();
Pointer ptrStruFaceCond = struFaceCond.getPointer();
int m_lSetMultiFaceCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_SET_FACE, ptrStruFaceCond, struFaceCond.size(), null, null);
if (m_lSetMultiFaceCfgHandle == -1) {
System.out.println("建立下发人脸长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立下发人脸长连接成功!");
}
HCNetSDK.NET_DVR_FACE_STATUS struFaceStatus = new HCNetSDK.NET_DVR_FACE_STATUS();
struFaceStatus.read();
struFaceStatus.dwSize = struFaceStatus.size();
struFaceStatus.write();
IntByReference pInt = new IntByReference(0);
for (int i = 0; i < iNum; i++) {
HCNetSDK.NET_DVR_FACE_RECORD struFaceRecord = new HCNetSDK.NET_DVR_FACE_RECORD();
struFaceRecord.read();
struFaceRecord.dwSize = struFaceRecord.size();
for (int j = 0; j < HCNetSDK.ACS_CARD_NO_LEN; j++) {
struFaceRecord.byCardNo[j] = 0;
}
for (int j = 0; j < CardNo[i].length(); j++) {
struFaceRecord.byCardNo[j] = CardNo[i].getBytes()[j];
}
/*****************************************
* 从本地文件里面读取JPEG图片二进制数据
*****************************************/
FileInputStream picfile = null;
int picdataLength = 0;
try {
picfile = new FileInputStream(new File(strFilePath[i]));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
picdataLength = picfile.available();
} catch (IOException e1) {
e1.printStackTrace();
}
if (picdataLength < 0) {
System.out.println("input file dataSize < 0");
return;
}
HCNetSDK.BYTE_ARRAY ptrpicByte = new HCNetSDK.BYTE_ARRAY(picdataLength);
try {
picfile.read(ptrpicByte.byValue);
} catch (IOException e2) {
e2.printStackTrace();
}
ptrpicByte.write();
struFaceRecord.dwFaceLen = picdataLength;
struFaceRecord.pFaceBuffer = ptrpicByte.getPointer();
struFaceRecord.write();
int dwFaceState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetMultiFaceCfgHandle, struFaceRecord.getPointer(), struFaceRecord.size(), struFaceStatus.getPointer(), struFaceStatus.size(), pInt);
struFaceStatus.read();
if (dwFaceState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("下发人脸失败, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
//可以继续下发下一个
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("下发人脸异常, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
//异常是长连接异常,不能继续下发后面的数据,需要重新建立长连接
break;
} else if (dwFaceState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struFaceStatus.byRecvStatus != 1) {
System.out.println("下发人脸失败,人脸读卡器状态" + struFaceStatus.byRecvStatus + ", 卡号:" + new String(struFaceStatus.byCardNo).trim());
} else {
System.out.println("下发人脸成功, 卡号: " + new String(struFaceStatus.byCardNo).trim() + ", 状态:" + struFaceStatus.byRecvStatus);
}
//可以继续下发下一个
} else {
System.out.println("其他状态:" + dwState);
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lSetMultiFaceCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功\n");
}
}
/**
* 查询单张卡号关联的人脸信息
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
*/
public static void getFaceCfg(int lUserID, String CardNo) {
HCNetSDK.NET_DVR_FACE_COND struFaceCond = new HCNetSDK.NET_DVR_FACE_COND();
struFaceCond.read();
struFaceCond.dwSize = struFaceCond.size();
struFaceCond.dwFaceNum = 1; //查询一个人脸参数
struFaceCond.dwEnableReaderNo = 1;//读卡器编号
for (int j = 0; j < HCNetSDK.ACS_CARD_NO_LEN; j++) {
struFaceCond.byCardNo[j] = 0;
}
System.arraycopy(CardNo.getBytes(), 0, struFaceCond.byCardNo, 0, CardNo.getBytes().length);
struFaceCond.write();
int m_lGetFaceHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_FACE, struFaceCond.getPointer(), struFaceCond.size(), null, null);
if (m_lGetFaceHandle == -1) {
System.out.println("建立查询人脸参数长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立查询人脸参数长连接成功!");
}
//查询结果
HCNetSDK.NET_DVR_FACE_RECORD struFaceRecord = new HCNetSDK.NET_DVR_FACE_RECORD();
struFaceRecord.read();
while (true) {
dwState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(m_lGetFaceHandle, struFaceRecord.getPointer(), struFaceRecord.size());
struFaceRecord.read();
if (dwState == -1) {
System.out.println("NET_DVR_GetNextRemoteConfig查询人脸调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("查询中,请等待...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("获取人脸参数失败, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("获取人脸参数异常, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if ((struFaceRecord.dwFaceLen > 0) && (struFaceRecord.pFaceBuffer != null)) {
FileOutputStream fout;
try {
String filename = System.getProperty("user.dir") + "\\pic\\" + CardNo + "_Face.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = struFaceRecord.pFaceBuffer.getByteBuffer(offset, struFaceRecord.dwFaceLen);
byte[] bytes = new byte[struFaceRecord.dwFaceLen];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
System.out.println("获取人脸参数成功, 卡号: " + CardNo + "图片保存路径: " + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取卡参数完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFaceHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
/**
* 删除单独人脸信息
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @throws UnsupportedEncodingException
* @throws InterruptedException
*/
public static void delOneFace(int lUserID, String CardNo) throws UnsupportedEncodingException, InterruptedException {
HCNetSDK.NET_DVR_FACE_PARAM_CTRL struFaceDelCond = new HCNetSDK.NET_DVR_FACE_PARAM_CTRL();
struFaceDelCond.dwSize = struFaceDelCond.size();
struFaceDelCond.byMode = 0; //删除方式:0- 按卡号方式删除,1- 按读卡器删除
struFaceDelCond.struProcessMode.setType(HCNetSDK.NET_DVR_FACE_PARAM_BYCARD.class);
//需要删除人脸关联的卡号
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struFaceDelCond.struProcessMode.struByCard.byCardNo[i] = 0;
}
System.arraycopy(CardNo.getBytes(), 0, struFaceDelCond.struProcessMode.struByCard.byCardNo, 0, CardNo.length());
struFaceDelCond.struProcessMode.struByCard.byEnableCardReader[0] = 1; //读卡器
struFaceDelCond.struProcessMode.struByCard.byFaceID[0] = 1; //人脸ID
struFaceDelCond.write();
Pointer ptrFaceDelCond = struFaceDelCond.getPointer();
boolean bRet = AcsMain.hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_DEL_FACE_PARAM_CFG, ptrFaceDelCond, struFaceDelCond.size());
if (!bRet) {
System.out.println("删除人脸失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("删除人脸成功!");
}
}
/**
* 人脸采集(设备采集人脸图片保存到本地)
*
* @param lUserID 用户登录句柄
*/
public static void captureFaceInfo(int lUserID) {
HCNetSDK.NET_DVR_CAPTURE_FACE_COND struCapCond = new HCNetSDK.NET_DVR_CAPTURE_FACE_COND();
struCapCond.read();
struCapCond.dwSize = struCapCond.size();
struCapCond.write();
int lCaptureFaceHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_CAPTURE_FACE_INFO, struCapCond.getPointer(), struCapCond.size(), null, null);
if (lCaptureFaceHandle == -1) {
System.out.println("建立采集人脸长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立采集人脸长连接成功!");
}
//采集的人脸信息
HCNetSDK.NET_DVR_CAPTURE_FACE_CFG struFaceInfo = new HCNetSDK.NET_DVR_CAPTURE_FACE_CFG();
struFaceInfo.read();
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lCaptureFaceHandle, struFaceInfo.getPointer(), struFaceInfo.size());
struFaceInfo.read();
if (dwState == -1) {
System.out.println("NET_DVR_GetNextRemoteConfig采集人脸失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("正在采集中,请等待...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("采集人脸失败");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
//超时时间5秒内设备本地人脸采集失败就会返回失败,连接会断开
System.out.println("采集人脸异常, 网络异常导致连接断开 ");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if ((struFaceInfo.dwFacePicSize > 0) && (struFaceInfo.pFacePicBuffer != null)) {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String newName = sf.format(new Date());
FileOutputStream fout;
try {
String filename = System.getProperty("user.dir") + "\\pic\\" + newName + "_capFaceInfo.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = struFaceInfo.pFacePicBuffer.getByteBuffer(offset, struFaceInfo.dwFacePicSize);
byte[] bytes = new byte[struFaceInfo.dwFacePicSize];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
System.out.println("采集人脸成功, 图片保存路径: " + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
} else {
System.out.println("其他异常, dwState: " + dwState);
break;
}
}
//采集成功之后断开连接、释放资源
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lCaptureFaceHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.io.*;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 指纹管理模块,实现功能:指纹下发,指纹获取、指纹采集、指纹删除
*/
public class FingerManage {
/**
* 指纹下发
*
* @param lUserID 用户登录句柄
* @param CardNo 卡号
* @throws InterruptedException
*
* 注意: 下发的指纹数据长度为512位,如果直接调用采集接口从设备采集到的指纹数据长度为768位,需要做截取
*/
public static void setOneFinger(int lUserID, String CardNo) throws InterruptedException {
HCNetSDK.NET_DVR_FINGERPRINT_COND struFingerCond = new HCNetSDK.NET_DVR_FINGERPRINT_COND();
struFingerCond.read();
struFingerCond.dwSize = struFingerCond.size();
struFingerCond.dwFingerprintNum = 1; //下发一个指纹
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struFingerCond.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struFingerCond.byCardNo[i] = CardNo.getBytes()[i];
}
struFingerCond.byFingerPrintID = 1;
struFingerCond.dwEnableReaderNo = 1;
struFingerCond.write();
Pointer ptrStruCond = struFingerCond.getPointer();
int m_lSetFingerCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_SET_FINGERPRINT, ptrStruCond, struFingerCond.size(), null, null);
if (m_lSetFingerCfgHandle == -1) {
System.out.println("建立下发指纹长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立下发指纹长连接成功!");
}
HCNetSDK.NET_DVR_FINGERPRINT_RECORD struFingerRecond = new HCNetSDK.NET_DVR_FINGERPRINT_RECORD();
struFingerRecond.read();
struFingerRecond.dwSize = struFingerRecond.size();
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struFingerRecond.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struFingerRecond.byCardNo[i] = CardNo.getBytes()[i];
}
struFingerRecond.byFingerPrintID = 1;
struFingerRecond.dwEnableReaderNo = 1;
struFingerRecond.byFingerType = 0;
/*****************************************
* 从本地文件里面读取指纹二进制数据
*****************************************/
FileInputStream picfile = null;
int picdataLength = 0;
try {
picfile = new FileInputStream(new File(System.getProperty("user.dir") + "\\FingerData\\FingerTest.data"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
picdataLength = picfile.available();
} catch (IOException e1) {
e1.printStackTrace();
}
if (picdataLength < 0) {
System.out.println("input file dataSize < 0");
return;
}
HCNetSDK.BYTE_ARRAY ptrpicByte = new HCNetSDK.BYTE_ARRAY(picdataLength);
try {
picfile.read(ptrpicByte.byValue);
picfile.close();
} catch (IOException e2) {
e2.printStackTrace();
}
ptrpicByte.write();
/** 从采集到的指纹数据中截取前512位数据传入 */
HCNetSDK.BYTE_ARRAY ptrpicByte_512 = new HCNetSDK.BYTE_ARRAY(512);
ptrpicByte_512.read();
System.arraycopy(ptrpicByte.byValue, 0, ptrpicByte_512.byValue, 0, 512);
ptrpicByte_512.write();
struFingerRecond.dwFingerPrintLen = ptrpicByte_512.byValue.length;
struFingerRecond.byFingerData = ptrpicByte_512.byValue;
struFingerRecond.write();
Pointer pFingerRecond = struFingerRecond.getPointer();
HCNetSDK.NET_DVR_FINGERPRINT_STATUS struFingerStatus = new HCNetSDK.NET_DVR_FINGERPRINT_STATUS();
struFingerStatus.read();
struFingerStatus.dwSize = struFingerStatus.size();
struFingerStatus.write();
IntByReference pInt = new IntByReference(0);
Pointer pFingerStatus = struFingerStatus.getPointer();
while (true) {
int dwFingerState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(m_lSetFingerCfgHandle, pFingerRecond, struFingerRecond.size(), pFingerStatus, struFingerStatus.size(), pInt);
struFingerStatus.read();
if (dwFingerState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
Thread.sleep(10);
continue;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("下发指纹失败, 卡号: " + new String(struFingerStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("下发指纹异常, 卡号: " + new String(struFingerStatus.byCardNo).trim() + ", 错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if (struFingerStatus.byRecvStatus != 0) {
System.out.println("下发指纹失败,读卡器状态: " + struFingerStatus.byCardReaderRecvStatus + ", 下发错误信息:" + new String(struFingerStatus.byErrorMsg) + ", 卡号:" + new String(struFingerStatus.byCardNo).trim());
break;
} else {
System.out.println("下发指纹成功, 卡号: " + new String(struFingerStatus.byCardNo).trim() + ", 状态:" + struFingerStatus.byRecvStatus);
}
continue;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("下发指纹完成");
break;
}
}
}
/**
* 指纹采集
*
* @param lUserID 用户登录句柄
*/
public static void captureFinger(int lUserID) {
HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_COND strFingerCond = new HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_COND();
strFingerCond.read();
strFingerCond.dwSize = strFingerCond.size();
strFingerCond.byFingerPrintPicType = 1;
strFingerCond.byFingerNo = 1;
strFingerCond.write();
int lGetFingerHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_INFO, strFingerCond.getPointer(), strFingerCond.dwSize, null, null);
if (lGetFingerHandle == -1) {
System.out.println("建立采集指纹长连接失败,错误码为:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立采集指纹长连接成功!");
}
HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_CFG strFingerCfg = new HCNetSDK.NET_DVR_CAPTURE_FINGERPRINT_CFG();
strFingerCfg.read();
while (true) {
int dwFingerState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lGetFingerHandle, strFingerCfg.getPointer(), strFingerCfg.size());
strFingerCfg.read();
if (dwFingerState == -1) {
System.out.println("NET_DVR_GetNextRemoteConfig采集指纹失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED) {
System.out.println("采集指纹失败");
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT) {
System.out.println("正在采集指纹中,请等待...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwFingerState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
//超时时间5秒内设备本地人脸采集失败就会返回失败,连接会断开
System.out.println("采集指纹异常, 网络异常导致连接断开 ");
break;
} else if (dwFingerState == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String newName = sf.format(new Date());
String fileName = newName + "_capFinger.data";
String filePath = System.getProperty("user.dir") + "\\FingerData\\" + fileName;
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {
File dir = new File(filePath);
if (!dir.exists() && dir.isDirectory()) {//判断文件目录是否存在
dir.mkdirs();
}
file = new File(filePath);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(strFingerCfg.byFingerData);
System.out.println("采集指纹成功!");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
if ((strFingerCfg.dwFingerPrintPicSize > 0) && (strFingerCfg.pFingerPrintPicBuffer != null)) {
FileOutputStream fout;
try {
String filename = System.getProperty("user.dir") + "\\FingerData\\" + newName + "_FingerPrintPic.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = strFingerCfg.pFingerPrintPicBuffer.getByteBuffer(offset, strFingerCfg.dwFingerPrintPicSize);
byte[] bytes = new byte[strFingerCfg.dwFingerPrintPicSize];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
System.out.println("采集指纹成功, 图片保存路径: " + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
} else {
System.out.println("其他异常, dwState: " + dwFingerState);
break;
}
}
//采集成功之后断开连接、释放资源
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lGetFingerHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
//指纹获取
public static void getOneFinger(int lUserID, String CardNo) {
HCNetSDK.NET_DVR_FINGERPRINT_COND struFingerCond = new HCNetSDK.NET_DVR_FINGERPRINT_COND();
struFingerCond.read();
struFingerCond.dwSize = struFingerCond.size();
struFingerCond.dwFingerprintNum = 1; //下发一个指纹
struFingerCond.dwEnableReaderNo = 1;
struFingerCond.byFingerPrintID = 1;
for (int i = 0; i < HCNetSDK.ACS_CARD_NO_LEN; i++) {
struFingerCond.byCardNo[i] = 0;
}
for (int i = 0; i < CardNo.length(); i++) {
struFingerCond.byCardNo[i] = CardNo.getBytes()[i];
}
struFingerCond.write();
Pointer ptrStruCond = struFingerCond.getPointer();
int m_lGetFingerCfgHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_FINGERPRINT, ptrStruCond, struFingerCond.size(), null, null);
if (m_lGetFingerCfgHandle == -1) {
System.out.println("建立获取指纹长连接失败,错误码为" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("建立获取指纹长连接成功!");
}
//查询结果
HCNetSDK.NET_DVR_FINGERPRINT_RECORD struFingerRecord = new HCNetSDK.NET_DVR_FINGERPRINT_RECORD();
struFingerRecord.read();
while (true) {
int dwState = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(m_lGetFingerCfgHandle, struFingerRecord.getPointer(), struFingerRecord.size());
struFingerRecord.read();
if (dwState == -1) {
System.out.println("NET_DVR_GetNextRemoteConfig查询指纹调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("查询中,请等待...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("获取指纹参数失败, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("获取指纹参数异常, 卡号: " + CardNo);
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if ((struFingerRecord.dwFingerPrintLen > 0) && (struFingerRecord.byFingerData != null)) {
FileOutputStream fout;
try {
String filename = System.getProperty("user.dir") + "\\FingerData\\" + CardNo + "_Finger.data";
fout = new FileOutputStream(filename);
//将字节写入文件
InputStream is = new ByteArrayInputStream(struFingerRecord.byFingerData);
byte[] buff = new byte[1024];
int len = 0;
while ((len = is.read(buff)) != -1) {
fout.write(buff, 0, len);
}
is.close();
fout.close();
System.out.println("获取指纹参数成功, 卡号: " + CardNo + "指纹保存路径: " + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取指纹参数完成");
break;
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(m_lGetFingerCfgHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
//指纹删除
public static void delFinger(int lUserID, String cardNo) {
int iErr = 0;
HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50 m_struFingerDelInfoParam = new HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50();
m_struFingerDelInfoParam.dwSize = m_struFingerDelInfoParam.size();
m_struFingerDelInfoParam.byMode = 0;// 删除方式,0-按卡号(人员ID)方式删除,1-按读卡器删除
m_struFingerDelInfoParam.struProcessMode.setType(HCNetSDK.NET_DVR_FINGER_PRINT_BYCARD_V50.class);
for (int i = 0; i < cardNo.length(); i++) {
m_struFingerDelInfoParam.struProcessMode.struByCard.byCardNo[i] = cardNo.getBytes()[i];
}
m_struFingerDelInfoParam.struProcessMode.struByCard.byEnableCardReader[0] = 1;//指纹的读卡器信息,按位表示
m_struFingerDelInfoParam.struProcessMode.struByCard.byFingerPrintID[0] = 1;//需要删除的指纹编号,按数组下标,值表示0-不删除,1-删除该指纹 ,指纹编号1删除
Pointer lpInBuffer1 = m_struFingerDelInfoParam.getPointer();
m_struFingerDelInfoParam.write();
int lHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_DEL_FINGERPRINT, lpInBuffer1, m_struFingerDelInfoParam.size(), null, null);
if (lHandle < 0) {
iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError();
System.out.println("NET_DVR_DEL_FINGERPRINT_CFG_V50 建立长连接失败,错误号:" + iErr);
return;
}
while (true) {
HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50 v50 = new HCNetSDK.NET_DVR_FINGER_PRINT_INFO_CTRL_V50();
v50.dwSize = v50.size();
v50.write();
int res = AcsMain.hCNetSDK.NET_DVR_GetNextRemoteConfig(lHandle, v50.getPointer(), v50.size());
if (res == 1002) {
AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandle);
System.out.println("删除指纹成功!!!");
break;
} else if (res == 1003) {
System.out.println("接口失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandle);
break;
}
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
/**
*身份证禁止名单下发,需要设备支持此功能,例如DS-5604
* 实现功能:禁止人员名单下发、逐条删除、清空
*/
public class IDBlockListManage {
public static FRemoteConfigCallback callback = null;
public static class FRemoteConfigCallback implements HCNetSDK.FRemoteConfigCallBack {
public void invoke(int dwType, Pointer lpBuffer, int dwBufLen, Pointer pUserData)
{
System.err.println("NET_DVR_StartRemoteConfig Callback:" + dwType);
switch (dwType)
{
case 0:
HCNetSDK.REMOTECONFIGSTATUS struCfgStatus = new HCNetSDK.REMOTECONFIGSTATUS();
struCfgStatus.write();
Pointer pCfgStatus = struCfgStatus.getPointer();
pCfgStatus.write(0, lpBuffer.getByteArray(0, struCfgStatus.size()), 0,struCfgStatus.size());
struCfgStatus.read();
int iStatus = 0;
for(int i=0;i<4;i++)
{
int ioffset = i*8;
int iByte = struCfgStatus.byStatus[i]&0xff;
iStatus = iStatus + (iByte << ioffset);
}
switch (iStatus){
case 1000:// NET_SDK_CALLBACK_STATUS_SUCCESS
System.out.println("下发成功,dwStatus:" + iStatus);
break;
case 1001:
System.out.println("正在下发中,dwStatus:" + iStatus);
break;
case 1002:
int iErrorCode = 0;
for(int i=0;i<4;i++)
{
int ioffset = i*8;
int iByte = struCfgStatus.byErrorCode[i]&0xff;
iErrorCode = iErrorCode + (iByte << ioffset);
}
System.err.println("下发失败, dwStatus:" + iStatus + "错误号:" + iErrorCode);
break;
}
break;
default:
break;
}
}
}
//逐条下发身份证禁止人员名单
public static void uploadBlockList(int lUserID) {
HCNetSDK.NET_DVR_UPLOAD_ID_BLOCKLIST_COND startParams = new HCNetSDK.NET_DVR_UPLOAD_ID_BLOCKLIST_COND();
startParams.read();
startParams.dwSize = startParams.size();
startParams.dwBlockListNum = 1; //下发禁止名单数量
startParams.write();
if (callback==null)
{
FRemoteConfigCallback callback=new FRemoteConfigCallback();
}
int lHandle = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_BULK_UPLOAD_ID_BLOCKLIST, startParams.getPointer(), startParams.size(),callback, Pointer.NULL);
if (lHandle < 0) {
System.out.println("NET_DVR_StartRemoteConfig失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
HCNetSDK.NET_DVR_UPLOAD_ID_BLOCKLIST_CFG sendParams = new HCNetSDK.NET_DVR_UPLOAD_ID_BLOCKLIST_CFG();
sendParams.read();
sendParams.dwSize = sendParams.size();
sendParams.struIDCardCfg.dwSize = sendParams.struIDCardCfg.size();
sendParams.byBlockListValid = 1; //身份证禁止名单是否有效:0-无效,1-有效(用于按身份证号码删除身份证禁止名单,该字段为0时代表删除)
sendParams.struIDCardCfg.byName = "zhansn".getBytes();
sendParams.struIDCardCfg.struBirth.read();
sendParams.struIDCardCfg.struBirth.wYear = 1994;
sendParams.struIDCardCfg.struBirth.byMonth = 03;
sendParams.struIDCardCfg.struBirth.byDay = 02;
sendParams.struIDCardCfg.byAddr = "浙江省杭州市".getBytes();
sendParams.struIDCardCfg.byIDNum = "1111111111111111".getBytes();
sendParams.struIDCardCfg.byIssuingAuthority = "浙江省杭州市".getBytes();
sendParams.struIDCardCfg.struStartDate.wYear = 2020;
sendParams.struIDCardCfg.struStartDate.byMonth = 4;
sendParams.struIDCardCfg.struStartDate.byDay = 20;
sendParams.struIDCardCfg.struEndDate.wYear = 2022;
sendParams.struIDCardCfg.struEndDate.byMonth = 4;
sendParams.struIDCardCfg.struEndDate.byDay = 20;
sendParams.struIDCardCfg.byTermOfValidity = 0;
sendParams.struIDCardCfg.bySex = 1;
sendParams.struIDCardCfg.byNation = 1;
sendParams.byBlockListValid = 1;
sendParams.write();
if (!AcsMain.hCNetSDK.NET_DVR_SendRemoteConfig(lHandle, 0x3, sendParams.getPointer(), sendParams.size())) {
System.err.println("NET_DVR_SendRemoteConfig失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_SendRemoteConfig成功");
}
}
if (!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandle)) {
System.err.println("NET_DVR_StopRemoteConfig失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig成功");
}
}
//清空禁止人员名单
public static void cleanBlockList(int lUserID) {
HCNetSDK.NET_DVR_ACS_PARAM_TYPE struAcsParam = new HCNetSDK.NET_DVR_ACS_PARAM_TYPE();
struAcsParam.read();
struAcsParam.dwSize = struAcsParam.size();
struAcsParam.dwParamType = 0x00080000; //身份证禁止名单参数
struAcsParam.wLocalControllerID = 0; // 就地控制器序号。0代表门禁设备
struAcsParam.write();
if (!AcsMain.hCNetSDK.NET_DVR_RemoteControl(lUserID, HCNetSDK.NET_DVR_CLEAR_ACS_PARAM, struAcsParam.getPointer(), struAcsParam.size())) {
System.err.println("清空身份证禁止名单失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("清除成功");
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
/**
* @create 2021-04-13-15:23
* 功能:透传接口实现,透传ISAPI命令
*/
public final class TransIsapi {
public static String get_isapi(int lUserID, String url) {
HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT();
struXMLInput.read();
HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024);
stringRequest.read();
//输入ISAPI协议命令
System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length());
stringRequest.write();
struXMLInput.dwSize = struXMLInput.size();
struXMLInput.lpRequestUrl = stringRequest.getPointer();
struXMLInput.dwRequestUrlLen = url.length();
struXMLInput.lpInBuffer = null;
struXMLInput.dwInBufferSize = 0;
struXMLInput.write();
HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(8 * 1024);
stringXMLOut.read();
HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024);
struXMLStatus.read();
HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
struXMLOutput.read();
struXMLOutput.dwSize = struXMLOutput.size();
struXMLOutput.lpOutBuffer = stringXMLOut.getPointer();
struXMLOutput.dwOutBufferSize = stringXMLOut.size();
struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer();
struXMLOutput.dwStatusSize = struXMLStatus.size();
struXMLOutput.write();
if (!AcsMain.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)) {
int iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError();
System.err.println("NET_DVR_STDXMLConfig失败,错误号" + iErr+"----URL:"+url);
return null;
} else {
stringXMLOut.read();
System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize);
//打印输出XML文本
String strOutXML = new String(stringXMLOut.byValue).trim();
System.out.println(strOutXML);
struXMLStatus.read();
String strStatus = new String(struXMLStatus.byValue).trim();
System.out.println(strStatus);
return strOutXML;
}
}
public static String put_isapi(int lUserID, String url, String inputXml) {
HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT();
struXMLInput.read();
HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024);
stringRequest.read();
//输入ISAPI协议命令
System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length());
stringRequest.write();
struXMLInput.dwSize = struXMLInput.size();
struXMLInput.lpRequestUrl = stringRequest.getPointer();
struXMLInput.dwRequestUrlLen = url.length();
HCNetSDK.BYTE_ARRAY ptrInBuffer = new HCNetSDK.BYTE_ARRAY(inputXml.length());
ptrInBuffer.read();
System.arraycopy(inputXml.getBytes(), 0, ptrInBuffer.byValue, 0, inputXml.length());
ptrInBuffer.write();
struXMLInput.lpInBuffer = ptrInBuffer.getPointer();
struXMLInput.dwInBufferSize = inputXml.length();
struXMLInput.write();
HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(8 * 1024);
stringXMLOut.read();
HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024);
struXMLStatus.read();
HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
struXMLOutput.read();
struXMLOutput.dwSize = struXMLOutput.size();
struXMLOutput.lpOutBuffer = stringXMLOut.getPointer();
struXMLOutput.dwOutBufferSize = stringXMLOut.size();
struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer();
struXMLOutput.dwStatusSize = struXMLStatus.size();
struXMLOutput.write();
if (!AcsMain.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)){
int iErr = AcsMain.hCNetSDK.NET_DVR_GetLastError();
System.err.println("NET_DVR_STDXMLConfig失败,错误号" + iErr+"----URL:"+url);
return null;
} else {
stringXMLOut.read();
System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize);
//打印输出XML文本
String strOutXML = new String(stringXMLOut.byValue).trim();
struXMLStatus.read();
String strStatus = new String(struXMLStatus.byValue).trim();
return strOutXML;
}
}
}
package com.mortals.xhx.hikdoor.Acs;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
/**
* 功能:人脸下发、查询、删除、人员计划模板配置
*/
public class UserManage {
/**
* 添加人员
* @param lUserID 登录句柄
* @param employeeNo 工号
* @throws UnsupportedEncodingException
* @throws InterruptedException
* @throws JSONException
*/
public static void addUserInfo(int lUserID,String employeeNo) throws UnsupportedEncodingException, InterruptedException, JSONException {
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
//"POST /ISAPI/AccessControl/UserInfo/Record?format=json" 此URL也是下发人员
String strInBuffer = "PUT /ISAPI/AccessControl/UserInfo/SetUp?format=json";
System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中
ptrByteArray.write();
int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(),null, null);
if (lHandler < 0)
{
System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
else{
System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 成功!");
byte[] Name = "测试".getBytes("utf-8"); //根据iCharEncodeType判断,如果iCharEncodeType返回6,则是UTF-8编码。
//如果是0或者1或者2,则是GBK编码
//将中文字符编码之后用数组拷贝的方式,避免因为编码导致的长度问题
String strInBuffer1 = "{\"UserInfo\":{\"Valid\":{\"beginTime\":\"2017-08-01T17:30:08\",\"enable\":true,\"endTime\":" +
"\"2030-08-01T17:30:08\"}," +
"\"checkUser\":false,\"doorRight\":\"1\",\"RightPlan\":[{\"doorNo\": 1,\"planTemplateNo\": \"1,3,5\"}]," +
"\"employeeNo\":\""+employeeNo+"\",\"floorNumber\":2,\"maxOpenDoorTime\":0,\"name\":\"";
String strInBuffer2 = "\",\"openDelayEnabled\":false,\"password\":\"123456\",\"roomNumber\":4,\"userType\":\"normal\"}}";
int iStringSize = Name.length + strInBuffer1.length() + strInBuffer2.length();
HCNetSDK.BYTE_ARRAY ptrByte = new HCNetSDK.BYTE_ARRAY(iStringSize);
System.arraycopy(strInBuffer1.getBytes(), 0, ptrByte.byValue, 0, strInBuffer1.length());
System.arraycopy(Name, 0, ptrByte.byValue, strInBuffer1.length(), Name.length);
System.arraycopy(strInBuffer2.getBytes(), 0, ptrByte.byValue, strInBuffer1.length() + Name.length, strInBuffer2.length());
ptrByte.write();
System.out.println(new String(ptrByte.byValue));
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024);
IntByReference pInt = new IntByReference(0);
while(true){
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrByte.getPointer(), iStringSize ,ptrOutuff.getPointer(), 1024, pInt);
//读取返回的json并解析
ptrOutuff.read();
String strResult = new String(ptrOutuff.byValue).trim();
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
JSONObject jsonResult = new JSONObject(strResult);
int statusCode = jsonResult.getInt("statusCode");
String statusString = jsonResult.getString("statusString");
if(dwState == -1){
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT)
{
System.out.println("配置等待");
Thread.sleep(10);
continue;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED)
{
System.out.println("下发人员失败, json retun:" + jsonResult.toString());
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION)
{
System.out.println("下发人员异常, json retun:" + jsonResult.toString());
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS)
{//返回NET_SDK_CONFIG_STATUS_SUCCESS代表流程走通了,但并不代表下发成功,比如有些设备可能因为人员已存在等原因下发失败,所以需要解析Json报文
if (statusCode != 1){
System.out.println("下发人员成功,但是有异常情况:" + jsonResult.toString());
}
else{
System.out.println("下发人员成功: json retun:" + jsonResult.toString());
}
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
//下发人员时:dwState其实不会走到这里,因为设备不知道我们会下发多少个人,所以长连接需要我们主动关闭
System.out.println("下发人员完成");
break;
}
}
if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}
else{
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
}
public static void searchUserInfo(int userID) throws JSONException{
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
String strInBuffer = "POST /ISAPI/AccessControl/UserInfo/Search?format=json";
System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中
ptrByteArray.write();
int lHandler = AcsMain.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if(lHandler < 0){
System.out.println("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为"+AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
else{
//组装查询的JSON报文,这边查询的是所有的人员
JSONObject jsonObject = new JSONObject();
JSONObject jsonSearchCond = new JSONObject();
//如果需要查询指定的工号人员信息,把下面注释的内容去除掉即可
/* JSONArray EmployeeNoList = new JSONArray();
JSONObject employeeNo1 = new JSONObject();
employeeNo1.put("employeeNo", "12346");
JSONObject employeeNo2 = new JSONObject();
employeeNo2.put("employeeNo", "1000");
EmployeeNoList.put(employeeNo1);
EmployeeNoList.put(employeeNo2);
jsonSearchCond.put("EmployeeNoList", EmployeeNoList);*/
jsonSearchCond.put("searchID", "20211126");
jsonSearchCond.put("searchResultPosition", 0);
jsonSearchCond.put("maxResults", 50);
jsonObject.put("UserInfoSearchCond", jsonSearchCond);
String strInbuff = jsonObject.toString();
System.out.println("查询的json报文:" + strInbuff);
//把string传递到Byte数组中,后续用.getPointer()方法传入指针地址中。
HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length());
System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length());
ptrInbuff.write();
//定义接收结果的结构体
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(10*1024);
IntByReference pInt = new IntByReference(0);
while(true){
int dwState = AcsMain.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutuff.getPointer(), 10*1024, pInt);
System.out.println(dwState);
if(dwState == -1){
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT)
{
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED)
{
System.out.println("查询人员失败");
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION)
{
System.out.println("查询人员异常");
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS)
{
ptrOutuff.read();
System.out.println("查询人员成功, json:" + new String(ptrOutuff.byValue).trim());
break;
}
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取人员完成");
break;
}
}
if(!AcsMain.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}
else{
System.out.println("NET_DVR_StopRemoteConfig接口成功");
lHandler = -1;
}
}
}
public static void deleteUserInfo(int userID) throws JSONException {
//删除单个人员
// String deleteUserjson="{\n" +
// "\t\"UserInfoDetail\": {\t\n" +
// "\t\t\"mode\": \"byEmployeeNo\",\t\n" +
// "\t\t\"EmployeeNoList\": [\t\n" +
// "\t\t\t{\n" +
// "\t\t\t\t\"employeeNo\": \"stu2204278\"\t\n" +
// "\t\t\t}\n" +
// "\t\t]\n" +
// "\n" +
// "\t}\n" +
// "}";
//删除所有人员
String deleteUserjson ="{\n" +
"\t\"UserInfoDetail\": {\t\n" +
"\t\t\"mode\": \"byEmployeeNo\",\t\n" +
"\t\t\"EmployeeNoList\": [\t\n" +
"\t\t]\n" +
"\t}\n" +
"}";
String deleteUserUrl="PUT /ISAPI/AccessControl/UserInfoDetail/Delete?format=json";
String result= TransIsapi.put_isapi(userID,deleteUserUrl,deleteUserjson);
System.out.println(result);
//获取删除进度
while (true) {
String getDeleteProcessUrl = "GET /ISAPI/AccessControl/UserInfoDetail/DeleteProcess?format=json";
String deleteResult = TransIsapi.get_isapi(userID, getDeleteProcessUrl);
JSONObject jsonObject = new JSONObject(deleteResult);
JSONObject jsonObject1 = jsonObject.getJSONObject("UserInfoDetailDeleteProcess");
String process = jsonObject1.getString("status");
System.out.println("process ="+process);
if (process.equals("processing")) {
System.out.println("正在删除");
continue;
} else if (process.equals("success")) {
System.out.println("删除成功");
break;
}
}
}
/**
* 人员计划模板配置
*
* @param userID 用户登录句柄
* @param iPlanTemplateNumber 计划模板编号,从1开始,最大值从门禁能力集获取
*/
public static void setCardTemplate(int userID, int iPlanTemplateNumber) {
//设置卡权限计划模板参数
HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND struPlanCond = new HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND();
struPlanCond.dwSize = struPlanCond.size();
struPlanCond.dwPlanTemplateNumber = iPlanTemplateNumber;//计划模板编号,从1开始,最大值从门禁能力集获取
struPlanCond.wLocalControllerID = 0;//就地控制器序号[1,64],0表示门禁主机
struPlanCond.write();
HCNetSDK.NET_DVR_PLAN_TEMPLATE struPlanTemCfg = new HCNetSDK.NET_DVR_PLAN_TEMPLATE();
struPlanTemCfg.dwSize = struPlanTemCfg.size();
struPlanTemCfg.byEnable = 1; //是否使能:0- 否,1- 是
struPlanTemCfg.dwWeekPlanNo = 2;//周计划编号,0表示无效
struPlanTemCfg.dwHolidayGroupNo[0] = 0;//假日组编号,按值表示,采用紧凑型排列,中间遇到0则后续无效
byte[] byTemplateName;
try {
byTemplateName = "CardTemplatePlan_2".getBytes("GBK");
//计划模板名称
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struPlanTemCfg.byTemplateName[i] = 0;
}
System.arraycopy(byTemplateName, 0, struPlanTemCfg.byTemplateName, 0, byTemplateName.length);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
struPlanTemCfg.write();
IntByReference pInt = new IntByReference(0);
Pointer lpStatusList = pInt.getPointer();
if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50, 1, struPlanCond.getPointer(), struPlanCond.size(), lpStatusList, struPlanTemCfg.getPointer(), struPlanTemCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50成功!");
//获取卡权限周计划参数
HCNetSDK.NET_DVR_WEEK_PLAN_COND struWeekPlanCond = new HCNetSDK.NET_DVR_WEEK_PLAN_COND();
struWeekPlanCond.dwSize = struWeekPlanCond.size();
struWeekPlanCond.dwWeekPlanNumber = 2;
struWeekPlanCond.wLocalControllerID = 0;
HCNetSDK.NET_DVR_WEEK_PLAN_CFG struWeekPlanCfg = new HCNetSDK.NET_DVR_WEEK_PLAN_CFG();
struWeekPlanCond.write();
struWeekPlanCfg.write();
Pointer lpCond = struWeekPlanCond.getPointer();
Pointer lpInbuferCfg = struWeekPlanCfg.getPointer();
if (false == AcsMain.hCNetSDK.NET_DVR_GetDeviceConfig(userID, HCNetSDK.NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
return;
}
struWeekPlanCfg.read();
struWeekPlanCfg.byEnable = 1; //是否使能:0- 否,1- 是
/**避免时间段交叉,先初始化, 七天八小时*/
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 8; j++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].byEnable = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.bySecond = 0;
}
}
/**一周7天,全天24小时*/
for (int i = 0; i < 7; i++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 21;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 23;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 0;
}
/**一周7天,每天设置2个时间段*/
/*for(int i=0;i<7;i++)
{
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 11;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byHour = 13;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byMinute = 30;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byHour = 19;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.bySecond = 59;
}*/
struWeekPlanCfg.write();
//设置卡权限周计划参数
if (false == AcsMain.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50失败,错误号:" + AcsMain.hCNetSDK.NET_DVR_GetLastError());
}else {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50成功!");
}
}
}
package com.mortals.xhx.hikdoor.Commom;
public class osSelect {
public static boolean isLinux() {
return System.getProperty("os.name").toLowerCase().contains("linux");
}
public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
The dll in this directoryiconv.dll,libxml2.dll,zlib1.dll,calib.dllonly used in ClientDemo.
\ No newline at end of file
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
【Demo内容说明】
-------------------------------------
1. 该Demo主要介绍以卡为中心的卡参数下发、人脸下发、指纹下发、人脸采集、事件查询等功能。
2. 该Demo使用Eclipse开发和编译运行。
【注意事项】
------------------------------------
1. 请到海康威视官网下载最新版本设备网络SDK:https://open.hikvision.com/download/5cda567cf47ae80dd41a54b3?type=10
2. 请修改程序代码,其中AcsMain.java中CreateSDKInstance()接口中指定SDK动态库的路径。此Demo在Win和Linux系统下通用,切换到Linux系统运行,CreateSDKInstance()接口中设置Linux系统SDK库文件路径。
3. Windows开发时需要将“库文件”文件夹中的HCNetSDK.dll、HCCore.dll、HCNetSDKCom文件夹、libssl-1_1-x64.dll、libcrypto-1_1-x64.dll、hlog.dll、hpr.dll、zlib1.dll等文件拷贝到lib文件夹下,HCNetSDKCom文件夹(包含里面的功能组件dll库文件)需要和HCNetSDK.dll、HCCore.dll一起加载,放在同一个目录下,且HCNetSDKCom文件夹名不能修改。如果自行开发软件不能正常实现相应功能,而且程序没有指定加载的dll库路径,请在程序运行的情况下尝试删除HCNetSDK.dll。如果可以删除,说明程序可能调用到系统盘Windows->System32目录下的dll文件,建议删除或者更新该目录下的相关dll文件;如果不能删除,dll文件右键选择属性确认SDK库版本。
4. Linux开发时需要将“库文件”文件夹中libhcnetsdk.so、libHCCore.so、libcrypto.so.1.1、libssl.so.1.1、libhpr.so、libz.so等文件拷贝到lib文件夹下。HCNetSDKCom文件夹(包含里面的功能组件dll库文件)需要和libhcnetsdk.so、libHCCore.so一起加载,放在同一个目录下,且HCNetSDKCom文件夹名不能修改。如果库文件加载有问题,初始化失败,也可以尝试将SDK所在路径添加到LD_LIBRARY_PATH环境变量中。
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment