✨ version0.0.2 init
This commit is contained in:
commit
3edac3da8b
35
.gitignore
vendored
Normal file
35
.gitignore
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
.DS_Store
|
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
18
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
18
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
316
mvnw
vendored
Executable file
316
mvnw
vendored
Executable file
|
@ -0,0 +1,316 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
188
mvnw.cmd
vendored
Normal file
188
mvnw.cmd
vendored
Normal file
|
@ -0,0 +1,188 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
103
pom.xml
Normal file
103
pom.xml
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.15</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>net.javase.hk</groupId>
|
||||
<artifactId>hk-sup-spring-boot-starter</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<name>hk-sup-spring-boot-starter</name>
|
||||
<description>hk-sup-spring-boot-starter</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dreamlu</groupId>
|
||||
<artifactId>mica-auto</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.26</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>3.0.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.52it.vip/api/packages/Frank/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.52it.vip/api/packages/Frank/maven</url>
|
||||
</repository>
|
||||
|
||||
<snapshotRepository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.52it.vip/api/packages/Frank/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
package net.javase.hksup.starter.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javase.hksup.starter.service.CmsServer;
|
||||
import net.javase.hksup.starter.service.SsServer;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* HkSupSdkConfiguration
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@EnableConfigurationProperties(HkSupSdkProperties.class)
|
||||
public class HkSupSdkConfiguration {
|
||||
|
||||
private final HkSupSdkProperties hkSupSdkProperties;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@Bean(initMethod = "startCmsServer", destroyMethod = "stopCmsServer")
|
||||
public CmsServer cmsServer() {
|
||||
return new CmsServer(hkSupSdkProperties, applicationContext);
|
||||
}
|
||||
|
||||
|
||||
@Bean(initMethod = "startSsServer", destroyMethod = "stopSsServer")
|
||||
public SsServer ssServer() {
|
||||
return new SsServer(hkSupSdkProperties, applicationContext);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package net.javase.hksup.starter.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* HkSupSdkProperties
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties("hk.sup")
|
||||
public class HkSupSdkProperties {
|
||||
|
||||
private String cmsServerIp;
|
||||
|
||||
private Integer cmsServerPort = 7660;
|
||||
|
||||
private String dasServerIp;
|
||||
|
||||
private Integer dasServerPort = 7660;
|
||||
|
||||
private String smsServerIp;
|
||||
|
||||
private Integer smsServerPort = 7665;
|
||||
|
||||
private String smsServerListenIp = "127.0.0.1";
|
||||
|
||||
private Integer smsServerListenPort = 7665;
|
||||
|
||||
private String smsBackServerIp;
|
||||
|
||||
private Integer smsBackServerPort = 8000;
|
||||
|
||||
private String smsBackServerListenIp = "127.0.0.1";
|
||||
|
||||
private Integer smsBackServerListenPort = 8000;
|
||||
|
||||
private String voiceSmsServerIp;
|
||||
|
||||
private Integer voiceSmsServerPort = 7500;
|
||||
|
||||
private String voiceSmsServerListenIp = "127.0.0.1";
|
||||
|
||||
private Integer voiceSmsServerListenPort = 7500;
|
||||
|
||||
private String alarmServerIp;
|
||||
|
||||
private Integer alarmServerTCPPort = 7663;
|
||||
|
||||
private Integer alarmServerUDPPort = 7662;
|
||||
|
||||
private Integer alarmServerType;
|
||||
|
||||
private String alarmServerListenIp = "127.0.0.1";
|
||||
|
||||
private Integer alarmServerListenTcpPort = 7663;
|
||||
|
||||
private Integer alarmServerListenUdpPort = 7662;
|
||||
|
||||
private String picServerIp;
|
||||
|
||||
private Integer picServerPort = 6011;
|
||||
|
||||
private Integer picServerType;
|
||||
|
||||
private String picServerListenIp = "127.0.0.1";
|
||||
|
||||
private Integer picServerListenPort = 6011;
|
||||
|
||||
private String kmsUsername = "test";
|
||||
|
||||
private String kmsPassword = "12345";
|
||||
|
||||
private String szAk = "test";
|
||||
|
||||
private String szSk = "12345";
|
||||
|
||||
/**
|
||||
* ISUP5.0登录秘钥
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* lib目录
|
||||
*/
|
||||
private String libPath;
|
||||
|
||||
private Boolean jnaDebug = false;
|
||||
|
||||
private String sdkLogPath;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package net.javase.hksup.starter.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* FaceInfoParam
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FaceInfoParam implements Serializable {
|
||||
|
||||
/**
|
||||
* 人脸图片URL,ISUP协议下发人脸使用URL方式
|
||||
*/
|
||||
private String faceURL;
|
||||
|
||||
private String faceLibType = "blackFD";
|
||||
|
||||
private String FDID = "1";
|
||||
|
||||
/**
|
||||
* 人员工号,以人为中心方式,下发人脸前需要先下发人员工号,人脸绑定在工号上
|
||||
*/
|
||||
private String FPID;
|
||||
|
||||
public FaceInfoParam(String faceURL, String FPID) {
|
||||
this.faceURL = faceURL;
|
||||
this.FPID = FPID;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.javase.hksup.starter.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SearchFaceInfoParam
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SearchFaceInfoParam implements Serializable {
|
||||
|
||||
private Integer searchResultPosition = 0;
|
||||
|
||||
private Integer maxResults = 30;
|
||||
|
||||
private String faceLibType = "blackFD";
|
||||
|
||||
private String FDID = "1";
|
||||
|
||||
private String FPID;
|
||||
|
||||
public SearchFaceInfoParam() {
|
||||
}
|
||||
|
||||
public SearchFaceInfoParam(String FPID) {
|
||||
this.FPID = FPID;
|
||||
}
|
||||
|
||||
public SearchFaceInfoParam(Integer searchResultPosition, Integer maxResults, String faceLibType, String FDID, String FPID) {
|
||||
this.searchResultPosition = searchResultPosition;
|
||||
this.maxResults = maxResults;
|
||||
this.faceLibType = faceLibType;
|
||||
this.FDID = FDID;
|
||||
this.FPID = FPID;
|
||||
}
|
||||
}
|
70
src/main/java/net/javase/hksup/starter/model/UserInfo.java
Normal file
70
src/main/java/net/javase/hksup/starter/model/UserInfo.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package net.javase.hksup.starter.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserInfo
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class UserInfo implements Serializable {
|
||||
|
||||
private String employeeNo;
|
||||
|
||||
private String name;
|
||||
|
||||
@Builder.Default
|
||||
private String userType = "normal";
|
||||
|
||||
private Valid Valid;
|
||||
|
||||
@Builder.Default
|
||||
private String doorRight = "1";
|
||||
|
||||
private List<RightPlan> RightPlan;
|
||||
|
||||
@Builder.Default
|
||||
private String gender = "male";
|
||||
|
||||
@Builder.Default
|
||||
private Boolean localUIRight = false;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Valid {
|
||||
private Boolean enable = true;
|
||||
|
||||
private String beginTime = "2023-01-01T00:00:00";
|
||||
|
||||
private String endTime = "2050-12-30T23:59:59";
|
||||
|
||||
private String timeType = "local";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class RightPlan {
|
||||
|
||||
private Long doorNo;
|
||||
|
||||
private String planTemplateNo = "1";
|
||||
|
||||
public RightPlan(Long doorNo) {
|
||||
this.doorNo = doorNo;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package net.javase.hksup.starter.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserInfoDetail
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserInfoDetail implements Serializable {
|
||||
|
||||
private String mode;
|
||||
|
||||
private List<EmployeeNo> EmployeeNoList;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class EmployeeNo {
|
||||
|
||||
private String employeeNo;
|
||||
}
|
||||
|
||||
}
|
483
src/main/java/net/javase/hksup/starter/sdk/HCISUPAlarm.java
Executable file
483
src/main/java/net/javase/hksup/starter/sdk/HCISUPAlarm.java
Executable file
|
@ -0,0 +1,483 @@
|
|||
package net.javase.hksup.starter.sdk;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
//SDK接口说明,HCNetSDK.dll
|
||||
|
||||
//windows gdi接口,gdi32.dll in system32 folder, 在设置遮挡区域,移动侦测区域等情况下使用
|
||||
public interface HCISUPAlarm extends Library {
|
||||
|
||||
/***宏定义***/
|
||||
//常量
|
||||
public static final int MAX_DEVICE_ID_LEN = 256; //设备ID长度
|
||||
public static final int NAME_LEN = 32; //用户名长度(在HCNetSDK的头文件中也有定义)
|
||||
public static final int NET_EHOME_SERIAL_LEN = 12; //设备序列号长度
|
||||
|
||||
public static final int MAX_TIME_LEN = 32; //时间字符串长度
|
||||
public static final int MAX_REMARK_LEN = 64; //报警备注长度
|
||||
public static final int MAX_URL_LEN = 512; //URL长度
|
||||
public static final int CID_DES_LEN = 32; //CID报警描述长度
|
||||
public static final int MAX_FILE_PATH_LEN = 256;
|
||||
public static final int MAX_UUID_LEN = 64; //最大UUID长度
|
||||
public static final int CID_DES_LEN_EX = 256; //CID报警描述长度扩展
|
||||
public static final int MAX_PICTURE_NUM = 5; //最大图片数量
|
||||
public static final int MAX_VIDEO_TYPE_LEN = 16;
|
||||
public static final int MAX_SUBSYSTEM_LEN = 64; //子系统个数最大值
|
||||
|
||||
// 报警事件
|
||||
public static final int EHOME_ALARM_UNKNOWN = 0; //未知报警类型
|
||||
public static final int EHOME_ALARM = 1; //Ehome基本报警
|
||||
public static final int EHOME_ALARM_HEATMAP_REPORT = 2; //热度图报告
|
||||
public static final int EHOME_ALARM_FACESNAP_REPORT = 3; //人脸抓拍报告
|
||||
public static final int EHOME_ALARM_GPS = 4; //GPS信息上传
|
||||
public static final int EHOME_ALARM_CID_REPORT = 5; //报警主机CID告警上传
|
||||
public static final int EHOME_ALARM_NOTICE_PICURL = 6; //图片URL上报
|
||||
public static final int EHOME_ALARM_NOTIFY_FAIL = 7; //异步失败通知
|
||||
public static final int EHOME_ALARM_SELFDEFINE = 9; //自定义报警上传
|
||||
public static final int EHOME_ALARM_DEVICE_NETSWITCH_REPORT = 10; //设备网络切换上传
|
||||
public static final int EHOME_ALARM_ACS = 11; //门禁事件上报
|
||||
public static final int EHOME_ALARM_WIRELESS_INFO = 12; //无线网络信息上传
|
||||
public static final int EHOME_ISAPI_ALARM = 13; //ISAPI报警上传
|
||||
public static final int EHOME_INFO_RELEASE_PRIVATE = 14; //为了兼容信息发布产品的私有EHome协议报警(不再维护)
|
||||
public static final int EHOME_ALARM_MPDCDATA = 15; //车载设备的客流数据
|
||||
public static final int EHOME_ALARM_QRCODE = 20; //二维码报警上传
|
||||
public static final int EHOME_ALARM_FACETEMP = 21; //人脸测温报警上传
|
||||
|
||||
public static final int ALARM_TYPE_DEV_CHANGED_STATUS = 700; //700-设备状态改变报警上传
|
||||
public static final int ALARM_TYPE_CHAN_CHANGED_STATUS = 701; //701-通道状态改变报警上报
|
||||
public static final int ALARM_TYPE_HD_CHANGED_STATUS = 702; //702-磁盘状态改变报警上报
|
||||
public static final int ALARM_TYPE_DEV_TIMING_STATUS = 703; //703-定时上报设备状态信息
|
||||
public static final int ALARM_TYPE_CHAN_TIMING_STATUS = 704; //704-定时上报通道状态信息
|
||||
public static final int ALARM_TYPE_HD_TIMING_STATUS = 705; //705-定时上报磁盘状态信息
|
||||
public static final int ALARM_TYPE_RECORD_ABNORMAL = 706; //706-录像异常,当前时间点本来应该是在执行录像的,结果因为异常原因导致设备无法正常录像。
|
||||
|
||||
/**
|
||||
* 地址信息结构体
|
||||
*/
|
||||
public static class NET_EHOME_IPADDRESS extends Structure {
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
public byte[] szIP = new byte[128];
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
public short wPort; //端口
|
||||
/**
|
||||
* 保留,设为 0
|
||||
*/
|
||||
public byte[] byRes = new byte[2];
|
||||
}
|
||||
|
||||
public static class BYTE_ARRAY extends Structure {
|
||||
public byte[] byValue;
|
||||
|
||||
public BYTE_ARRAY(int iLen) {
|
||||
byValue = new byte[iLen];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警信息结构体
|
||||
*/
|
||||
public static class NET_EHOME_ALARM_MSG extends Structure {
|
||||
/**
|
||||
* 报警类型
|
||||
*/
|
||||
public int dwAlarmType; //报警类型,见EN_ALARM_TYPE
|
||||
|
||||
/**
|
||||
* 报警信息详情,不同报警类型对应不同报警详情
|
||||
*/
|
||||
public Pointer pAlarmInfo; //报警内容(结构体)
|
||||
|
||||
/**
|
||||
* 保存报警信息详情所需的缓冲区大小
|
||||
*/
|
||||
public int dwAlarmInfoLen; //结构体报警内容长度
|
||||
|
||||
/**
|
||||
* XML 格式的报警信息报文
|
||||
*/
|
||||
public Pointer pXmlBuf; //报警内容(XML)
|
||||
|
||||
/**
|
||||
* 保存报警信息 XML 报文所需的缓冲区大小
|
||||
*/
|
||||
public int dwXmlBufLen; //xml报警内容长度
|
||||
|
||||
/**
|
||||
* 设备序列号。最大长度为 12 字节(对应宏定义为“NET_EHOME_SERIAL_LEN”)
|
||||
*/
|
||||
public byte[] sSerialNumber = new byte[NET_EHOME_SERIAL_LEN]; //设备序列号,用于进行Token认证
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
public Pointer pHttpUrl;
|
||||
|
||||
/**
|
||||
* URL 大小
|
||||
*/
|
||||
public int dwHttpUrlLen;
|
||||
|
||||
/**
|
||||
* 保留,设为 0。最大长度为 12 字节
|
||||
*/
|
||||
public byte[] byRes = new byte[12];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_ALARM_ISAPI_INFO extends Structure {
|
||||
public Pointer pAlarmData; // 报警数据
|
||||
public int dwAlarmDataLen; // 报警数据长度
|
||||
public byte byDataType; // 0-invalid,1-xml,2-json
|
||||
public byte byPicturesNumber; // 图片数量
|
||||
public byte[] byRes = new byte[2];
|
||||
public Pointer pPicPackData; // 图片变长部分,byPicturesNumber个NET_EHOME_ALARM_ISAPI_PICDATA
|
||||
public byte[] byRes1 = new byte[32];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_HEATMAP_REPORT extends Structure {
|
||||
public int dwSize;
|
||||
public byte[] byDeviceID = new byte[MAX_DEVICE_ID_LEN]; //设备注册ID
|
||||
public int dwVideoChannel; //通道号
|
||||
public byte[] byStartTime = new byte[MAX_TIME_LEN]; //开始时间(设备本地时间),格式:YYYY-MM-DD HH:MM:SS
|
||||
public byte[] byStopTime = new byte[MAX_TIME_LEN]; //结束时间(设备本地时间),格式:YYYY-MM-DD HH:MM:SS
|
||||
public NET_EHOME_HEATMAP_VALUE struHeatmapValue; //热度值
|
||||
public NET_EHOME_PIXEL_ARRAY_SIZE struPixelArraySize; //热度图大小
|
||||
public byte[] byPixelArrayData = new byte[MAX_URL_LEN]; //热度图数据索引
|
||||
public byte byRetransFlag; //重传标记,0-实时包,1-重传包
|
||||
public byte byTimeDiffH; //byStartTime,byStopTime与国际标准时间(UTC)的时差(小时),-12 ... +14,0xff表示无效
|
||||
public byte byTimeDiffM; //byStartTime,byStopTime与国际标准时间(UTC)的时差(分钟),-30,0, 30, 45, 0xff表示无效
|
||||
public byte[] byRes = new byte[61];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_HEATMAP_VALUE extends Structure {
|
||||
public int dwMaxHeatMapValue; //最大热度值
|
||||
public int dwMinHeatMapValue; //最小热度值
|
||||
public int dwTimeHeatMapValue; //平均热度值
|
||||
}
|
||||
|
||||
public static class NET_EHOME_PIXEL_ARRAY_SIZE extends Structure {
|
||||
public int dwLineValue; //像素点行值
|
||||
public int dwColumnValue; //像素点列值
|
||||
}
|
||||
|
||||
public static class NET_EHOME_FACESNAP_REPORT extends Structure {
|
||||
public int dwSize;
|
||||
public byte[] byDeviceID = new byte[MAX_DEVICE_ID_LEN]; //设备注册ID
|
||||
public int dwVideoChannel; //通道号
|
||||
public byte[] byAlarmTime = new byte[MAX_TIME_LEN]; //报警时间(设备本地时间),格式:YYYY-MM-DD HH:MM:SS
|
||||
public int dwFacePicID; //人脸图ID
|
||||
public int dwFaceScore; //人脸评分,0-100
|
||||
public int dwTargetID; //目标ID
|
||||
public NET_EHOME_ZONE struTarketZone; //目标区域,归一化坐标:数值为当前画面的百分比大小*1000,精度为小数点后三位
|
||||
public NET_EHOME_ZONE struFacePicZone; //人脸子图区域,归一化坐标:数值为当前画面的百分比大小*1000,精度为小数点后三位
|
||||
public NET_EHOME_HUMAN_FEATURE struHumanFeature;//人属性
|
||||
public int dwStayDuration; //停留画面中时间
|
||||
public int dwFacePicLen; //人脸图长度,单位:字节
|
||||
public byte[] byFacePicUrl = new byte[MAX_URL_LEN]; //人脸子图数据索引
|
||||
public int dwBackgroudPicLen; //背景图片长度,单位:字节
|
||||
public byte[] byBackgroudPicUrl = new byte[MAX_URL_LEN]; //背景图片数据索引
|
||||
public byte byRetransFlag; //重传标记,0-实时包,1-重传包
|
||||
public byte byTimeDiffH; //byAlamTime与国际标准时间(UTC)的时差(小时),-12 ... +14,0xff表示无效
|
||||
public byte byTimeDiffM; //byAlamTime与国际标准时间(UTC)的时差(分钟),-30,0, 30, 45, 0xff表示无效
|
||||
public byte[] byRes = new byte[61];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_ZONE extends Structure {
|
||||
public int dwX; //X轴坐标
|
||||
public int dwY; //Y轴坐标
|
||||
public int dwWidth; //宽度
|
||||
public int dwHeight; //高度
|
||||
}
|
||||
|
||||
public static class NET_EHOME_HUMAN_FEATURE extends Structure {
|
||||
public byte byAgeGroup; //年龄属性,1-婴幼儿,2-儿童,3-少年,4-青少年,5-青年,6-壮年,7-中年,8-中老年,9-老年
|
||||
public byte bySex; //性别属性,1-男,2-女
|
||||
public byte byEyeGlass; //是否戴眼睛,1-不戴,2-戴
|
||||
public byte byMask; //是否戴口罩,1-不戴,2-戴
|
||||
public byte[] byRes = new byte[12];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_GPS_INFO extends Structure {
|
||||
public int dwSize;
|
||||
public byte[] bySampleTime = new byte[MAX_TIME_LEN]; //GPS采样时间,设备本地时间,格式:YYYY-MM-DD HH:MM:SS
|
||||
public byte[] byDeviceID = new byte[MAX_DEVICE_ID_LEN]; //设备注册ID
|
||||
public byte[] byDivision = new byte[2]; //division[0]:'E'or'W'(东经/西经), division[1]:'N'or'S'(北纬/南纬)
|
||||
public byte bySatelites;//卫星数量
|
||||
public byte byPrecision; //精度因子,原始值*100
|
||||
public int dwLongitude; //经度,取值范围为(0~180*3600*100),转换公式为:longitude= 实际度*3600*100+实际分*60*100+实际秒*100
|
||||
public int dwLatitude; //纬度,取值范围为(0~90*3600*100),转换公式为:latitude = 实际度*3600*100+实际分*60*100+实际秒*100
|
||||
public int dwDirection; //方向,取值范围为(0~359.9*100),正北方向为0,转换公式为:direction= 实际方向*100
|
||||
public int dwSpeed;//速度,取值范围为(0~999.9*100000),转换公式为:speed =实际速度*100000,相当于cm/h
|
||||
public int dwHeight; //高度,单位:cm
|
||||
public byte byRetransFlag; //重传标记,0-实时包,1-重传包
|
||||
public byte byLocateMode; //定位模式(初值0),仅NMEA0183 3.00版本输出,值:0-自主定位,1- 差分,2- 估算,3- 数据无效
|
||||
public byte byTimeDiffH; //bySampleTime与国际标准时间(UTC)的时差(小时),-12 ... +14,0xff表示无效
|
||||
public byte byTimeDiffM; //bySampleTimee与国际标准时间(UTC)的时差(分钟),-30,0, 30, 45, 0xff表示无效
|
||||
public int dwMileage; //设备里程数统计,单位为米,整型,每天第一次开机或者00:00:00时清零,后续累加当天里程数上报到中心
|
||||
public byte[] byRes = new byte[56];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_CID_INFO extends Structure {
|
||||
public int dwSize;
|
||||
public byte[] byDeviceID = new byte[MAX_DEVICE_ID_LEN];//设备注册ID
|
||||
public int dwCIDCode; //CID报告代码
|
||||
public int dwCIDType; //CID报警类型
|
||||
public int dwSubSysNo; //产生报告的子系统号,0为全局报告,子系统范围0~32
|
||||
public byte[] byCIDDescribe = new byte[CID_DES_LEN]; //CID报警描述
|
||||
public byte[] byTriggerTime = new byte[MAX_TIME_LEN]; //CID报警发生时间(设备本地时间),格式:YYYY-MM-DD HH:MM:SS
|
||||
public byte[] byUploadTime = new byte[MAX_TIME_LEN];//CID报告上传时间(设备本地时间),格式:YYYY-MM-DD HH:MM:SS
|
||||
public NET_EHOME_CID_PARAM struCIDParam; //CID报警参数
|
||||
public byte byTimeDiffH;//byTriggerTime,byUploadTime与国际标准时间(UTC)的时差(小时),-12 ... +14,0xff表示无效
|
||||
public byte byTimeDiffM;//byTriggerTime,byUploadTime与国际标准时间(UTC)的时差(分钟),-30,0, 30, 45, 0xff表示无效
|
||||
public byte byExtend;//是否有扩展字段
|
||||
public byte[] byRes1 = new byte[5];
|
||||
public Pointer pCidInfoEx; //byExtend为1是有效,指向NET_EHOME_CID_INFO_INTERNAL_EX结构体
|
||||
public Pointer pPicInfoEx;
|
||||
public byte[] byRes = new byte[44];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_CID_PARAM extends Structure {
|
||||
public int dwUserType; //用户类型,1键盘用户 2网络用户,其他值表示无效
|
||||
public int lUserNo; //用户类型,-1表示无效
|
||||
public int lZoneNo; //防区号,-1表示无效
|
||||
public int lKeyboardNo; //键盘号
|
||||
public int lVideoChanNo; //视频通道号
|
||||
public int lDiskNo; //硬盘号
|
||||
public int lModuleAddr; //模块地址
|
||||
public byte[] byUserName = new byte[NAME_LEN]; //用户名
|
||||
public byte[] byRes = new byte[32];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_CID_INFO_INTERNAL_EX extends Structure {
|
||||
public byte byRecheck; //是否是视频复核报警 1-复核报警,0-普通报警
|
||||
public byte[] byRes = new byte[3];
|
||||
public byte[] byUUID = new byte[MAX_UUID_LEN]; //报警唯一ID,区分是否属于同一个报警;不支持视频复核报警时,该字段为0;
|
||||
public byte[] byVideoURL = new byte[MAX_URL_LEN]; // byRecheck为1时有效,视频复核报警中视频的URL地址,用于从存储服务器获取视频;(复核报警第二次上报该URL)
|
||||
public byte[] byCIDDescribeEx = new byte[CID_DES_LEN_EX]; //CID报警描述扩展
|
||||
public byte[] byVideoType = new byte[MAX_VIDEO_TYPE_LEN];
|
||||
public byte[] byLinkageSubSystem = new byte[MAX_SUBSYSTEM_LEN]; //关联的子系统
|
||||
public byte[] byRes1 = new byte[176];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_CID_INFO_PICTUREINFO_EX extends Structure {
|
||||
public byte[][] byPictureURL = new byte[MAX_PICTURE_NUM][MAX_URL_LEN];//图片URL
|
||||
public byte[] byRes1 = new byte[512];
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警回调函数
|
||||
*/
|
||||
public static interface EHomeMsgCallBack extends Callback {
|
||||
|
||||
/**
|
||||
* 报警回调函数
|
||||
*
|
||||
* @param iHandle 报警监听句柄
|
||||
* @param pAlarmMsg 报警信息,详情参见结构体 {@link NET_EHOME_ALARM_MSG}
|
||||
* @param pUser 用户参数
|
||||
* @return true | false
|
||||
*/
|
||||
public boolean invoke(int iHandle, NET_EHOME_ALARM_MSG pAlarmMsg, Pointer pUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警监听参数结构体
|
||||
*/
|
||||
public static class NET_EHOME_ALARM_LISTEN_PARAM extends Structure {
|
||||
/**
|
||||
* 本地监听信息。IP 为 0.0.0.0 的情况下,默认
|
||||
* 为本地地址,多个网卡的情况下,默认为从操
|
||||
* 作系统获取到的第一个地址
|
||||
*/
|
||||
public NET_EHOME_IPADDRESS struAddress;
|
||||
public EHomeMsgCallBack fnMsgCb; //报警信息回调函数
|
||||
public Pointer pUserData; //用户数据
|
||||
public byte byProtocolType; //协议类型,0-TCP,1-UDP
|
||||
public byte byUseCmsPort; //是否复用CMS端口,0-不复用,非0-复用,如果复用cms端口,协议类型字段无效(此时本地监听信息struAddress填本地回环地址)
|
||||
public byte byUseThreadPool; //0-回调报警时,使用线程池,1-回调报警时,不使用线程池,默认情况下,报警回调的时候,使用线程池
|
||||
public byte byRes[] = new byte[29];
|
||||
;
|
||||
}
|
||||
|
||||
public static class NET_EHOME_LOCAL_GENERAL_CFG extends Structure {
|
||||
public byte byAlarmPictureSeparate; //控制透传ISAPI报警数据和图片是否分离,0-不分离,1-分离(分离后走EHOME_ISAPI_ALARM回调返回)
|
||||
public byte[] byRes = new byte[127];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_ALARM_INFO extends Structure {
|
||||
public int dwSize;
|
||||
public byte[] szAlarmTime = new byte[MAX_TIME_LEN]; //报警触发时间(设备本地时间),格式,YYYY-MM-DD HH:MM:SS
|
||||
public byte[] szDeviceID = new byte[MAX_DEVICE_ID_LEN]; //设备注册ID
|
||||
public int dwAlarmType; //报警类型见EN_ALARM_TYPE枚举变量
|
||||
public int dwAlarmAction; //报警动作0:开始 1:停止
|
||||
public int dwVideoChannel;//各报警中的意义见注释
|
||||
public int dwAlarmInChannel;//各报警中的意义见注释
|
||||
public int dwDiskNumber; //各报警中的意义见注释
|
||||
public byte[] byRemark = new byte[MAX_REMARK_LEN]; //重传标记,0-实时包,1-重传包
|
||||
public byte byRetransFlag; //重传标记,0-实时包,1-重传包
|
||||
public byte byTimeDiffH; //重传标记,0-实时包,1-重传包
|
||||
public byte byTimeDiffM;//szAlarmTime,szAlarmUploadTime与国际标准时间(UTC)的时差(小时),-12 ... +14,0xff表示无效
|
||||
public byte byRes1;
|
||||
public byte[] szAlarmUploadTime = new byte[MAX_TIME_LEN]; //报警上传时间(设备本地时间),时间格式,YYYY-MM-DD HH:MM:SS
|
||||
public NET_EHOME_ALARM_STATUS_UNION uStatusUnion;
|
||||
public byte[] byRes2 = new byte[16];
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警状态联合体
|
||||
*/
|
||||
public static class NET_EHOME_ALARM_STATUS_UNION extends Structure {
|
||||
public byte[] byRes = new byte[12]; // 联合体大小
|
||||
public NET_EHOME_DEV_STATUS_CHANGED struDevStatusChanged;
|
||||
public NET_EHOME_CHAN_STATUS_CHANGED struChanStatusChanged;
|
||||
public NET_EHOME_HD_STATUS_CHANGED struHdStatusChanged;
|
||||
public NET_EHOME_DEV_TIMING_STATUS struDevTimeStatus;
|
||||
public NET_EHOME_CHAN_TIMING_STATUS_SINGLE struChanTimeStatus;
|
||||
public NET_EHOME_HD_TIMING_STATUS_SINGLE struHdTimeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备状态改变信息结构体
|
||||
*/
|
||||
public static class NET_EHOME_DEV_STATUS_CHANGED extends Structure {
|
||||
/**
|
||||
* 设备状态:0-正常;1-CPU 使用率超过 85%;2-硬件错误,如串口异常
|
||||
*/
|
||||
public byte byDeviceStatus;
|
||||
|
||||
/**
|
||||
* 保留。最大长度为 11 字节
|
||||
*/
|
||||
public byte[] byRes = new byte[11];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_CHAN_STATUS_CHANGED extends Structure {
|
||||
public short wChanNO; // 通道号
|
||||
public byte byChanStatus; //通道状态,按位表示
|
||||
//bit0:启用状态,0-禁用/删除,1-启用/添加
|
||||
//模拟通道由禁用到启用,或者启用到禁用,上报该字段
|
||||
//数字通道添加到删除,或者删除到重新添加,上报该字段
|
||||
//bit1:在线状态,0-不在线,1-在线
|
||||
//bit2:信号状态,0-无信号,1-有信号
|
||||
//bit3:录像状态,0-不在录像 1-在录像
|
||||
//bit4:IP通道信息改变状态,0-未改变 1-有改变,这位表示该通道的配
|
||||
//置信息发生了改变,比如添加的IPC有过更换,通知上层更新能力集
|
||||
|
||||
public byte[] byRes = new byte[9];
|
||||
}
|
||||
|
||||
// 磁盘状态改变
|
||||
public static class NET_EHOME_HD_STATUS_CHANGED extends Structure {
|
||||
public int dwVolume; //硬盘容量,单位:MB
|
||||
public short wHDNo; //硬盘号
|
||||
public byte byHDStatus; //硬盘的状态, 0-活动1-休眠,2-异常,3-休眠硬盘出错,4-未格式化, 5-未连接状态(网络硬盘),6-硬盘正在格式化
|
||||
public byte[] byRes = new byte[5]; //保留
|
||||
}
|
||||
|
||||
// 定时上报设备状态项
|
||||
public static class NET_EHOME_DEV_TIMING_STATUS extends Structure {
|
||||
public int dwMemoryTotal; // 内存总量,单位Kbyte
|
||||
public int dwMemoryUsage; // 内存使用量,单位Kbyte
|
||||
public byte byCPUUsage; // CPU使用率,0-100
|
||||
public byte byMainFrameTemp; // 机箱温度,单位:摄氏度
|
||||
public byte byBackPanelTemp; // 背板温度,单位:摄氏度
|
||||
public byte byRes;
|
||||
}
|
||||
|
||||
// 定时上报通道状态项-单个通道
|
||||
public static class NET_EHOME_CHAN_TIMING_STATUS_SINGLE extends Structure {
|
||||
public int dwBitRate; // 实际码率,单位kbps
|
||||
public short wChanNO; // 通道号
|
||||
public byte byLinkNum; // 客户端连接的个数
|
||||
public byte[] byRes = new byte[5];
|
||||
}
|
||||
|
||||
// 定时上报磁盘状态项
|
||||
public static class NET_EHOME_HD_TIMING_STATUS_SINGLE extends Structure {
|
||||
public int dwHDFreeSpace; // 硬盘剩余空间,单位:MB
|
||||
public short wHDNo; // 磁盘号
|
||||
public byte[] byRes = new byte[6];
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化报警管理服务器(AMS)的报警库 <br>
|
||||
* 如果初始化失败,请检查加载库文件的路径和系统环境 <br>
|
||||
* 该接口必须与 {@link HCISUPAlarm#NET_EALARM_Fini} 配套调用
|
||||
*
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败
|
||||
*/
|
||||
boolean NET_EALARM_Init();
|
||||
|
||||
/**
|
||||
* 反初始化报警库并释放报警管理服务器(AMS)占用的资源 <br>
|
||||
* 该接口必须与 {@link HCISUPAlarm#NET_EALARM_Init} 配套调用
|
||||
*
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败
|
||||
*/
|
||||
boolean NET_EALARM_Fini();
|
||||
|
||||
/**
|
||||
* 设置报警管理服务器(AMS)的本地配置参数
|
||||
*
|
||||
* @param enumType 支持的本地配置类型宏定义值:-1,0,1,2,3 和 4,参见枚举定义 NET_EHOME_LOCAL_CFG_TYPE
|
||||
* @param lpInbuffer 本地配置参数,与本地配置类型(enumType)相关
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败。如果返回 FALSE,请调用 {@link HCISUPAlarm#NET_EALARM_GetLastError} 获取错误码
|
||||
*/
|
||||
boolean NET_EALARM_SetSDKLocalCfg(int enumType, Pointer lpInbuffer);
|
||||
|
||||
/**
|
||||
* 启用报警管理服务器(AMS)监听并注册回调函数以接收报警信息
|
||||
*
|
||||
* @param pAlarmListenParam 开启监听后用于接收报警信息的输入参数,详情参见结构体 {@link NET_EHOME_ALARM_LISTEN_PARAM}
|
||||
* @return 返回-1 表示失败,返回其他值表示 {@link HCISUPAlarm#NET_EALARM_StopListen} 的句柄。如果返回-1,请调用 {@link HCISUPAlarm#NET_EALARM_GetLastError} 获取错误码
|
||||
*/
|
||||
int NET_EALARM_StartListen(NET_EHOME_ALARM_LISTEN_PARAM pAlarmListenParam);
|
||||
|
||||
/**
|
||||
* 如果调用失败或完成,可获取错误码
|
||||
*
|
||||
* @return 返回值是错误码
|
||||
*/
|
||||
int NET_EALARM_GetLastError();
|
||||
|
||||
/**
|
||||
* 停止报警管理服务器(AMS)的监听
|
||||
*
|
||||
* @param iListenHandle 报警监听句柄,由 {@link HCISUPAlarm#NET_EALARM_StartListen} 返回
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败。如果返回 FALSE,请调用 {@link HCISUPAlarm#NET_EALARM_GetLastError} 获取错误码
|
||||
*/
|
||||
boolean NET_EALARM_StopListen(int iListenHandle);
|
||||
|
||||
/**
|
||||
* 为设备设置会话密钥
|
||||
*
|
||||
* @param pDeviceKey 支持 5.0 版本 ISUP 设备的会话密钥信息,详情参见 NET_EHOME_DEV_SESSIONKEY
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败。如果返回 FALSE,请调用 {@link HCISUPAlarm#NET_EALARM_GetLastError} 获取错误码
|
||||
*/
|
||||
boolean NET_EALARM_SetDeviceSessionKey(Pointer pDeviceKey);
|
||||
|
||||
/**
|
||||
* 设置参数以启用报警管理服务器(AMS)的日志功能
|
||||
*
|
||||
* @param iLogLevel 日志类型。0-启用日志功能(默认),1-错误日志,2-错误和调试日志,3-错误、调试和信息日志。
|
||||
* @param strLogDir 日志文件保存路径。Windows 操作系统中的默认保存路径为“C:\\SdkLog\\”,Linux 操作系统中的默认保存路径为“/home/sdklog/”。如果要使用默认保存路径,请将该参数设置为“NULL”。
|
||||
* @param bAutoDel 是否在一段时间后自动删除日志文件:“TRUE”-是(默认),“FALSE”-否。当为“FALSE”时,会启动日志压缩,每生成 50 个日志文件时,将会进行一次日志压缩(将这生成的 50 个日志文件压缩成一个压缩文件)
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败。如果返回 FALSE,请调用 {@link HCISUPAlarm#NET_EALARM_GetLastError} 获取错误码
|
||||
*/
|
||||
boolean NET_EALARM_SetLogToFile(int iLogLevel, String strLogDir, boolean bAutoDel);
|
||||
|
||||
/**
|
||||
* 设置报警管理服务器(AMS)的初始化参数
|
||||
*
|
||||
* @param enumType 初始化配置类型,详见枚举 NET_EHOME_EALARM_INIT_CFG_TYPE
|
||||
* @param lpInBuff 初始化配置参数,取决于配置类型(enumType)
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败
|
||||
*/
|
||||
boolean NET_EALARM_SetSDKInitCfg(int enumType, Pointer lpInBuff);
|
||||
}
|
1018
src/main/java/net/javase/hksup/starter/sdk/HCISUPCMS.java
Executable file
1018
src/main/java/net/javase/hksup/starter/sdk/HCISUPCMS.java
Executable file
File diff suppressed because it is too large
Load Diff
429
src/main/java/net/javase/hksup/starter/sdk/HCISUPSS.java
Executable file
429
src/main/java/net/javase/hksup/starter/sdk/HCISUPSS.java
Executable file
|
@ -0,0 +1,429 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package net.javase.hksup.starter.sdk;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import net.javase.hksup.starter.utils.CommonMethod;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public interface HCISUPSS extends Library {
|
||||
|
||||
/***宏定义***/
|
||||
//常量
|
||||
|
||||
public static final int MAX_URL_LEN_SS = 4096; //图片服务器回调URL长度
|
||||
public static final int MAX_KMS_USER_LEN = 512; //KMS用户名最大长度
|
||||
public static final int MAX_KMS_PWD_LEN = 512; //KMS密码最大长度
|
||||
public static final int MAX_CLOUD_AK_SK_LEN = 64; //EHome5.0存储协议AK SK最大长度
|
||||
public static final int MAX_PATH = 260; //设备ID长度
|
||||
|
||||
/**
|
||||
* 数据库密钥(字符串类型),最大长度32
|
||||
*/
|
||||
int SS_DB_KEY_MAX_LEN = 32;
|
||||
public static final int NET_EHOME_SERIAL_LEN = 12; //设备序列号长度
|
||||
|
||||
//NET_EHOME_SS_MSG_TYPE
|
||||
public static final int NET_EHOME_SS_MSG_TOMCAT = 1;//Tomcat回调函数
|
||||
public static final int NET_EHOME_SS_MSG_KMS_USER_PWD = 2;//KMS用户名密码校验
|
||||
public static final int NET_EHOME_SS_MSG_CLOUD_AK = 3;//EHome5.0存储协议AK回调
|
||||
|
||||
//NET_EHOME_SS_CLIENT_TYPE
|
||||
public static final int NET_EHOME_SS_CLIENT_TYPE_TOMCAT = 1; //Tomcat图片上传客户端
|
||||
public static final int NET_EHOME_SS_CLIENT_TYPE_VRB = 2;//VRB图片上传客户端
|
||||
public static final int NET_EHOME_SS_CLIENT_TYPE_KMS = 3;//KMS图片上传客户端
|
||||
public static final int NET_EHOME_SS_CLIENT_TYPE_CLOUD = 4;//EHome5.0存储协议客户端
|
||||
|
||||
//NET_EHOME_SS_INIT_CFG_TYPE
|
||||
public static final int NET_EHOME_SS_INIT_CFG_SDK_PATH = 1;//设置SS组件加载路径(仅Linux版本支持)
|
||||
public static final int NET_EHOME_SS_INIT_CFG_CLOUD_TIME_DIFF = 2;//设置运存储的请求时间差值,默认15分钟,最小5分钟,最大60分钟
|
||||
|
||||
public enum NET_EHOME_SS_MSG_TYPE {
|
||||
NET_EHOME_SS_MSG_TOMCAT, //Tomcat回调函数
|
||||
NET_EHOME_SS_MSG_KMS_USER_PWD, //KMS用户名密码校验
|
||||
NET_EHOME_SS_MSG_CLOUD_AK //EHome5.0存储协议AK回调
|
||||
}
|
||||
|
||||
public enum NET_EHOME_SS_CLIENT_TYPE {
|
||||
NET_EHOME_SS_CLIENT_TYPE_TOMCAT, //Tomcat图片上传客户端
|
||||
NET_EHOME_SS_CLIENT_TYPE_VRB, //VRB图片上传客户端
|
||||
NET_EHOME_SS_CLIENT_TYPE_KMS, //KMS图片上传客户端
|
||||
NET_EHOME_SS_CLIENT_TYPE_CLOUD //EHome5.0存储协议客户端
|
||||
}
|
||||
|
||||
public enum NET_EHOME_SS_INIT_CFG_TYPE {
|
||||
NET_EHOME_SS_INIT_CFG_SDK_PATH, //设置SS组件加载路径(仅Linux版本支持)
|
||||
NET_EHOME_SS_INIT_CFG_CLOUD_TIME_DIFF //设置运存储的请求时间差值,默认15分钟,最小5分钟,最大60分钟
|
||||
}
|
||||
|
||||
/**
|
||||
* Tomcat图片服务器回调信息
|
||||
*/
|
||||
public static class NET_EHOME_SS_TOMCAT_MSG extends Structure {
|
||||
public byte[] szDevUri = new byte[MAX_URL_LEN_SS]; //设备请求的URI
|
||||
public int dwPicNum; //图片数
|
||||
public String pPicURLs; //图片URL,每个URL MAX_URL_LEN_SS长度
|
||||
public byte[] byRes = new byte[64];
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听参数
|
||||
*/
|
||||
public static class NET_EHOME_SS_LISTEN_PARAM extends Structure {
|
||||
public NET_EHOME_IPADDRESS struAddress = new NET_EHOME_IPADDRESS(); //本地监听信息,IP为0.0.0.0的情况下,默认为本地地址,多个网卡的情况下,默认为从操作系统获取到的第一个
|
||||
public byte[] szKMS_UserName = new byte[MAX_KMS_USER_LEN]; //KMS用户名
|
||||
public byte[] szKMS_Password = new byte[MAX_KMS_PWD_LEN]; //KMS用户名
|
||||
public EHomeSSStorageCallBack fnSStorageCb;//图片服务器信息存储回调函数
|
||||
public EHomeSSMsgCallBack fnSSMsgCb; //图片服务器信息Tomcat回调函数
|
||||
public byte[] szAccessKey = new byte[MAX_CLOUD_AK_SK_LEN]; //EHome5.0存储协议AK
|
||||
public byte[] szSecretKey = new byte[MAX_CLOUD_AK_SK_LEN]; //EHome5.0存储协议SK
|
||||
public Pointer pUserData; //用户参数
|
||||
public byte byHttps; //是否启用HTTPs
|
||||
public byte[] byRes1 = new byte[3];
|
||||
public EHomeSSRWCallBack fnSSRWCb;//读写回调函数
|
||||
public EHomeSSRWCallBackEx fnSSRWCbEx;
|
||||
public byte bySecurityMode;
|
||||
public byte[] byRes = new byte[51];
|
||||
}
|
||||
|
||||
/**
|
||||
* IP地址结构体
|
||||
*/
|
||||
public static class NET_EHOME_IPADDRESS extends Structure {
|
||||
public byte[] szIP = new byte[128]; //IP地址
|
||||
public short wPort; //端口号
|
||||
public byte[] byRes = new byte[2]; //保留,置为0
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听Https参数
|
||||
*/
|
||||
public static class NET_EHOME_SS_LISTEN_HTTPS_PARAM extends Structure {
|
||||
public byte byHttps; //0-不启用HTTPS 1-启用HTTPS
|
||||
public byte byVerifyMode; //0-单向认证(暂只支持单向认证)
|
||||
public byte byCertificateFileType; //证书类型0-pem, 1-ANS1
|
||||
public byte byPrivateKeyFileType; //私钥类型0-pem, 1-ANS1
|
||||
public byte[] szUserCertificateFile = new byte[MAX_PATH]; //用户名
|
||||
public byte[] szUserPrivateKeyFile = new byte[32]; //密码
|
||||
public int dwSSLVersion;//SSL Method版本
|
||||
//0 - SSL23, 1 - SSL2, 2 - SSL3, 3 - TLS1.0, 4 - TLS1.1, 5 - TLS1.2
|
||||
//SSL23是兼容模式,会协商客户端和服务端使用的最高版本
|
||||
public byte[] byRes3 = new byte[360];
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片上传客户端参数
|
||||
*/
|
||||
public static class NET_EHOME_SS_CLIENT_PARAM extends Structure {
|
||||
public int enumType; //图片上传客户端类型 NET_EHOME_SS_CLIENT_TYPE
|
||||
public NET_EHOME_IPADDRESS struAddress; //图片服务器地址
|
||||
public byte byHttps;//是否启用HTTPs
|
||||
public byte[] byRes = new byte[63];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_SS_LOCAL_SDK_PATH extends Structure {
|
||||
public byte[] sPath = new byte[MAX_PATH];
|
||||
public byte[] byRes = new byte[128];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_SS_RW_PARAM extends Structure {
|
||||
public Pointer pFileName; //文件名
|
||||
public Pointer pFileBuf; //文件内容
|
||||
public IntByReference dwFileLen; //文件大小
|
||||
public Pointer pFileUrl; //文件url
|
||||
public Pointer pUser; //
|
||||
public byte byAct; //读写操作:0-写文件,1-读文件
|
||||
public byte byUseRetIndex; //是否使用上层返回的pRetIndex:0-不使用,1-使用
|
||||
public byte[] byRes1 = new byte[2];
|
||||
public Pointer pRetIndex; //上层设置的索引,pRetIndex为0时,可不设置,pRetIndex为1时候,设置
|
||||
public byte[] byRes = new byte[56];
|
||||
}
|
||||
|
||||
public static class StringPointer extends Structure {
|
||||
public byte[] sData;
|
||||
|
||||
public StringPointer() {
|
||||
}
|
||||
|
||||
public StringPointer(int dwLength) {
|
||||
if (dwLength == 0) {
|
||||
throw new NullPointerException("Data length can`t be zero");
|
||||
}
|
||||
|
||||
this.sData = new byte[dwLength];
|
||||
}
|
||||
|
||||
public StringPointer(String sContent) {
|
||||
if (sContent == null) {
|
||||
throw new NullPointerException("Content can`t be null");
|
||||
}
|
||||
|
||||
this.sData = new byte[256];
|
||||
System.arraycopy(sContent.getBytes(), 0, this.sData, 0, sContent.length());
|
||||
}
|
||||
|
||||
public StringPointer(byte[] byData) {
|
||||
this.sData = new byte[256];
|
||||
System.arraycopy(byData, 0, this.sData, 0, byData.length);
|
||||
}
|
||||
|
||||
public String GetString() {
|
||||
return CommonMethod.byteToString(this.sData);
|
||||
}
|
||||
|
||||
public byte[] GetByteArray() {
|
||||
return this.sData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("sData");
|
||||
}
|
||||
}
|
||||
|
||||
public static class NET_EHOME_SS_EX_PARAM extends Structure {
|
||||
public byte byProtoType;
|
||||
public byte[] byRes = new byte[23];
|
||||
public NET_EHOME_SS_Union unionStoreInfo = new NET_EHOME_SS_Union();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化参数结构体
|
||||
*/
|
||||
class NET_EHOME_SS_INIT_PARAM extends Structure {
|
||||
/**
|
||||
* 数据库密钥
|
||||
*/
|
||||
public byte[] szKey = new byte[SS_DB_KEY_MAX_LEN];
|
||||
public byte[] byRes = new byte[224];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_SS_Union extends Union {
|
||||
public NET_EHOME_SS_CLOUD_PARAM struCloud = new NET_EHOME_SS_CLOUD_PARAM();
|
||||
}
|
||||
|
||||
public static class NET_EHOME_SS_CLOUD_PARAM extends Structure {
|
||||
public String pPoolId;
|
||||
public byte byPoolIdLength;
|
||||
public int dwErrorCode;
|
||||
public byte[] byRes = new byte[503];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化存储管理模块库
|
||||
*
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败
|
||||
*/
|
||||
boolean NET_ESS_Init();
|
||||
|
||||
/**
|
||||
* 反初始化存储管理库并释放存储服务器(SS)占用的资源
|
||||
*
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败
|
||||
*/
|
||||
boolean NET_ESS_Fini();
|
||||
|
||||
/**
|
||||
* 文件信息回调函数
|
||||
*/
|
||||
public static interface EHomeSSMsgCallBack extends Callback {
|
||||
|
||||
/**
|
||||
* 文件信息回调
|
||||
*
|
||||
* @param iHandle [OUT]句柄
|
||||
* @param enumType 回调数据类型
|
||||
* @param pOutBuffer [OUT]保存输出参数的缓冲区,取决于被回调的数据的类型(enumType)
|
||||
* @param dwOutLen [OUT]输出缓冲区大小
|
||||
* @param pInBuffer 保存输入参数的缓冲区,取决于被回调的数据的类型(enumType)
|
||||
* @param dwInLen 输入缓冲区大小
|
||||
* @param pUser [OUT]用户参数
|
||||
* @return
|
||||
*/
|
||||
public boolean invoke(int iHandle, int enumType, Pointer pOutBuffer, int dwOutLen, Pointer pInBuffer, int dwInLen, Pointer pUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储回调函数
|
||||
*/
|
||||
public static interface EHomeSSStorageCallBack extends Callback {
|
||||
|
||||
/**
|
||||
* 存储信息回调函数
|
||||
*
|
||||
* @param iHandle [OUT] 存储句柄
|
||||
* @param pFileName [OUT] 文件名
|
||||
* @param pFileBuf [OUT] 保存文件的缓冲区大小
|
||||
* @param dwOutLen [OUT] 文件保存路径
|
||||
* @param pFilePath [IN] 输入缓冲区大小
|
||||
* @param pUser [OUT] 用户参数
|
||||
*/
|
||||
public boolean invoke(int iHandle, String pFileName, Pointer pFileBuf, int dwOutLen, Pointer pFilePath, Pointer pUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读写回调函数 byAct 0-读 1-写 2-删
|
||||
*/
|
||||
public static interface EHomeSSRWCallBack extends Callback {
|
||||
/**
|
||||
* 读写回调
|
||||
*
|
||||
* @param iHandle [OUT] 句柄
|
||||
* @param byAct [OUT] 操作类型:0-写,1-读,2-删除
|
||||
* @param pFileName [OUT] 文件名
|
||||
* @param pFileBuf [IN][OUT] 保存文件的缓冲区
|
||||
* @param dwFileLen [IN][OUT] 文件大小
|
||||
* @param pFileUrl [OUT] 文件 URL
|
||||
* @param pUser [OUT] 用户参数
|
||||
* @return
|
||||
*/
|
||||
public boolean invoke(int iHandle, byte byAct, String pFileName, Pointer pFileBuf, int dwFileLen, String pFileUrl, Pointer pUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读写回调函数扩展
|
||||
*/
|
||||
public static interface EHomeSSRWCallBackEx extends Callback {
|
||||
|
||||
/**
|
||||
* 回调
|
||||
*
|
||||
* @param iHandle 存储组件服务端监听句柄, NET_ESS_StartListen 的返回值
|
||||
* @param pRwParam 用于传递四种存储协议共用字段, 参见 NET_EHOME_SS_RW_PARAM
|
||||
* @param pExStruct 用于传递存储协议特有字段, 参见 NET_EHOME_SS_EX_PARAM
|
||||
* @return
|
||||
*/
|
||||
public boolean invoke(int iHandle, NET_EHOME_SS_RW_PARAM pRwParam, NET_EHOME_SS_EX_PARAM pExStruct);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取错误码
|
||||
*/
|
||||
int NET_ESS_GetLastError();
|
||||
|
||||
/**
|
||||
* 日志
|
||||
*
|
||||
* @param iLogLevel
|
||||
* @param strLogDir
|
||||
* @param bAutoDel
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_SetLogToFile(int iLogLevel, String strLogDir, boolean bAutoDel);
|
||||
|
||||
boolean NET_ESS_SetSDKInitCfg(int enumType, Pointer lpInBuff);
|
||||
|
||||
/**
|
||||
* 获取版本号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int NET_ESS_GetBuildVersion();
|
||||
|
||||
/**
|
||||
* 设置HTTP监听的Https参数
|
||||
*
|
||||
* @param pSSHttpsParam
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_SetListenHttpsParam(NET_EHOME_SS_LISTEN_HTTPS_PARAM pSSHttpsParam);
|
||||
|
||||
/**
|
||||
* 开启监听
|
||||
*
|
||||
* @param pSSListenParam
|
||||
* @return
|
||||
*/
|
||||
int NET_ESS_StartListen(NET_EHOME_SS_LISTEN_PARAM pSSListenParam);
|
||||
|
||||
/**
|
||||
* 关闭监听
|
||||
*
|
||||
* @param lListenHandle
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_StopListen(int lListenHandle);
|
||||
|
||||
/**
|
||||
* 设置初始化参数
|
||||
*/
|
||||
boolean NET_ESS_Init_V11(NET_EHOME_SS_INIT_PARAM pParam);
|
||||
|
||||
/**
|
||||
* 创建图片上传/下载客户端
|
||||
*
|
||||
* @param pClientParam
|
||||
* @return
|
||||
*/
|
||||
int NET_ESS_CreateClient(NET_EHOME_SS_CLIENT_PARAM pClientParam);
|
||||
|
||||
/**
|
||||
* 设置图片上传/下载客户端超时时间,单位ms,默认为5s
|
||||
*
|
||||
* @param lHandle
|
||||
* @param dwSendTimeout
|
||||
* @param dwRecvTimeout
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_ClientSetTimeout(int lHandle, int dwSendTimeout, int dwRecvTimeout);
|
||||
|
||||
/**
|
||||
* 设置图片上传/下载客户端参数
|
||||
*
|
||||
* @param lHandle
|
||||
* @param strParamName
|
||||
* @param strParamVal
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_ClientSetParam(int lHandle, String strParamName, String strParamVal);
|
||||
|
||||
/**
|
||||
* 图片上传/下载客户端执行上传
|
||||
*
|
||||
* @param lHandle
|
||||
* @param strUrl
|
||||
* @param dwUrlLen
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_ClientDoUpload(int lHandle, byte[] strUrl, int dwUrlLen);
|
||||
|
||||
/**
|
||||
* 图片上传/下载客户端执行下载
|
||||
*
|
||||
* @param lHandle
|
||||
* @param strUrl
|
||||
* @param pFileContent
|
||||
* @param dwContentLen
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_ClientDoDownload(int lHandle, String strUrl, PointerByReference pFileContent, IntByReference dwContentLen);
|
||||
|
||||
/**
|
||||
* 销毁客户端
|
||||
*
|
||||
* @param lHandle [IN] 客户端句柄,由 {@link HCISUPSS#NET_ESS_CreateClient} 返回
|
||||
* @return
|
||||
*/
|
||||
boolean NET_ESS_DestroyClient(int lHandle);
|
||||
|
||||
/**
|
||||
* 计算 HMAC-SHA256 的值
|
||||
*
|
||||
* @param pSrc [IN] 输入数据,一般指向设备 ID
|
||||
* @param pSecretKey [IN] 密钥,一般指向 EHomeKey
|
||||
* @param pSingatureOut [IN/OUT] 目的数据缓冲区
|
||||
* @param dwSingatureLen [IN] 目的数据缓冲区长度
|
||||
* @return 返回 TRUE 表示成功,返回 FALSE 表示失败 如果返回 FALSE,请调用 {@link HCISUPSS#NET_ESS_GetLastError} 获取错误码
|
||||
*/
|
||||
boolean NET_ESS_HAMSHA256(String pSrc, String pSecretKey, String pSingatureOut, int dwSingatureLen);
|
||||
|
||||
}
|
227
src/main/java/net/javase/hksup/starter/sdk/HCISUPStream.java
Executable file
227
src/main/java/net/javase/hksup/starter/sdk/HCISUPStream.java
Executable file
|
@ -0,0 +1,227 @@
|
|||
package net.javase.hksup.starter.sdk;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public interface HCISUPStream extends Library {
|
||||
|
||||
|
||||
public static class BYTE_ARRAY extends Structure {
|
||||
public byte[] byValue;
|
||||
|
||||
public BYTE_ARRAY(int iLen) {
|
||||
byValue = new byte[iLen];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
// TODO Auto-generated method stub
|
||||
return Arrays.asList("byValue");
|
||||
}
|
||||
}
|
||||
|
||||
public class NET_EHOME_PLAYBACK_LISTEN_PARAM extends Structure {
|
||||
public HCISUPCMS.NET_EHOME_IPADDRESS struIPAdress; //本地监听信息,IP为0.0.0.0的情况下,默认为本地地址,多个网卡的情况下,默认为从操作系统获取到的第一个
|
||||
public PLAYBACK_NEWLINK_CB fnNewLinkCB; //预览请求回调函数,当收到预览连接请求后,SDK会回调该回调函数。
|
||||
public Pointer pUser; // 用户参数,在fnNewLinkCB中返回出来
|
||||
public byte byLinkMode; //0:TCP,1:UDP 2: HRUDP方式
|
||||
public byte[] byRes = new byte[127];
|
||||
}
|
||||
|
||||
|
||||
public class NET_EHOME_LISTEN_PREVIEW_CFG extends Structure {
|
||||
public HCISUPCMS.NET_EHOME_IPADDRESS struIPAdress; //本地监听信息,IP为0.0.0.0的情况下,默认为本地地址,多个网卡的情况下,默认为从操作系统获取到的第一个
|
||||
public PREVIEW_NEWLINK_CB fnNewLinkCB; //预览请求回调函数,当收到预览连接请求后,SDK会回调该回调函数。
|
||||
public Pointer pUser; // 用户参数,在fnNewLinkCB中返回出来
|
||||
public byte byLinkMode; //0:TCP,1:UDP 2: HRUDP方式
|
||||
public byte[] byRes = new byte[127];
|
||||
}
|
||||
|
||||
public class NET_EHOME_NEWLINK_CB_MSG extends Structure {
|
||||
public byte[] szDeviceID = new byte[HCISUPCMS.MAX_DEVICE_ID_LEN]; //设备标示符
|
||||
public int iSessionID; //设备分配给该取流会话的ID
|
||||
public int dwChannelNo; //设备通道号
|
||||
public byte byStreamType; //0-主码流,1-子码流
|
||||
public byte[] byRes1 = new byte[3];
|
||||
public byte[] sDeviceSerial = new byte[HCISUPCMS.NET_EHOME_SERIAL_LEN]; //设备序列号,数字序列号
|
||||
public byte[] byRes = new byte[112];
|
||||
}
|
||||
|
||||
public class NET_EHOME_PREVIEW_CB_MSG extends Structure {
|
||||
public byte byDataType; //NET_DVR_SYSHEAD(1)-码流头,NET_DVR_STREAMDATA(2)-码流数据
|
||||
public byte[] byRes1 = new byte[3];
|
||||
public Pointer pRecvdata; //码流头或者数据
|
||||
public int dwDataLen; //数据长度
|
||||
public byte[] byRes2 = new byte[128];
|
||||
}
|
||||
|
||||
public class NET_EHOME_PREVIEW_DATA_CB_PARAM extends Structure {
|
||||
public PREVIEW_DATA_CB fnPreviewDataCB; //数据回调函数
|
||||
public Pointer pUserData; //用户参数, 在fnPreviewDataCB回调出来
|
||||
public byte[] byRes = new byte[128]; //保留
|
||||
}
|
||||
|
||||
public static final int NET_EHOME_DEVICEID_LEN = 256; //设备ID长度
|
||||
public static final int NET_EHOME_SERIAL_LEN = 12;
|
||||
|
||||
public class NET_EHOME_PLAYBACK_NEWLINK_CB_INFO extends Structure {
|
||||
public byte[] szDeviceID = new byte[NET_EHOME_DEVICEID_LEN];
|
||||
public int lSessionID; //设备分配给该回放会话的ID,0表示无效(出参)
|
||||
public int dwChannelNo; //设备通道号,0表示无效(出参)
|
||||
public byte[] sDeviceSerial = new byte[NET_EHOME_SERIAL_LEN/*12*/]; //设备序列号,数字序列号(出参)
|
||||
public byte byStreamFormat; //码流封装格式:0-PS 1-RTP(入参)
|
||||
public byte[] byRes1 = new byte[3];
|
||||
public PLAYBACK_DATA_CB fnPlayBackDataCB;
|
||||
public Pointer pUserData;
|
||||
public byte[] byRes = new byte[88];
|
||||
}
|
||||
|
||||
|
||||
public class NET_EHOME_PLAYBACK_DATA_CB_PARAM extends Structure
|
||||
{
|
||||
public PLAYBACK_DATA_CB fnPlayBackDataCB; //数据回调函数
|
||||
public Pointer pUserData; //用户参数, 在fnPlayBackDataCB回调出来
|
||||
public byte byStreamFormat; //码流封装格式:0-PS 1-RTP
|
||||
public byte[] byRes=new byte[127]; //保留
|
||||
}
|
||||
|
||||
public class NET_EHOME_PLAYBACK_DATA_CB_INFO extends Structure {
|
||||
public int dwType; //类型 1-头信息 2-码流数据
|
||||
public Pointer pData; //数据指针
|
||||
public int dwDataLen; //数据长度
|
||||
public byte[] byRes = new byte[128]; //保留
|
||||
}
|
||||
|
||||
|
||||
public interface PLAYBACK_DATA_CB extends Callback {
|
||||
public boolean invoke(int iPlayBackLinkHandle, NET_EHOME_PLAYBACK_DATA_CB_INFO pDataCBInfo, Pointer pUserData);
|
||||
}
|
||||
|
||||
public interface PREVIEW_NEWLINK_CB extends Callback {
|
||||
public boolean invoke(int lLinkHandle, NET_EHOME_NEWLINK_CB_MSG pNewLinkCBMsg, Pointer pUserData);
|
||||
}
|
||||
|
||||
public interface PLAYBACK_NEWLINK_CB extends Callback {
|
||||
public boolean invoke(int lPlayBackLinkHandle, NET_EHOME_PLAYBACK_NEWLINK_CB_INFO pNewLinkCBMsg, Pointer pUserData);
|
||||
}
|
||||
|
||||
|
||||
public interface PREVIEW_DATA_CB extends Callback {
|
||||
public void invoke(int iPreviewHandle, NET_EHOME_PREVIEW_CB_MSG pPreviewCBMsg, Pointer pUserData);
|
||||
}
|
||||
|
||||
public interface fExceptionCallBack extends Callback {
|
||||
public void invoke(int dwType, int iUserID, int iHandle, Pointer pUser);
|
||||
}
|
||||
|
||||
public interface VOICETALK_NEWLINK_CB extends Callback {
|
||||
public boolean invoke(int lHandle, NET_EHOME_VOICETALK_NEWLINK_CB_INFO pNewLinkCBInfo, Pointer pUserData);
|
||||
}
|
||||
|
||||
public interface VOICETALK_DATA_CB extends Callback {
|
||||
public boolean invoke(int lHandle, NET_EHOME_VOICETALK_DATA_CB_INFO pNewLinkCBInfo, Pointer pUserData);
|
||||
}
|
||||
|
||||
|
||||
public static class StringPointer extends Structure {
|
||||
public byte[] data;
|
||||
|
||||
public StringPointer() {
|
||||
}
|
||||
|
||||
public StringPointer(String sInput) {
|
||||
this.data = new byte[sInput.length()];
|
||||
this.data = sInput.getBytes();
|
||||
}
|
||||
}
|
||||
|
||||
public static class NET_EHOME_LISTEN_VOICETALK_CFG extends Structure {
|
||||
public HCISUPCMS.NET_EHOME_IPADDRESS struIPAdress; //本地监听信息,IP为0.0.0.0的情况下,默认为本地地址,
|
||||
//多个网卡的情况下,默认为从操作系统获取到的第一个
|
||||
public VOICETALK_NEWLINK_CB fnNewLinkCB; //新连接回调函数
|
||||
public Pointer pUser; //用户参数,在fnNewLinkCB中返回出来
|
||||
public byte byLinkMode; //0:TCP,1:UDP (UDP保留)
|
||||
public byte byLinkEncrypt; //是否启用链路加密,TCP通过TLS传输,UDP(包括NPQ)使用DTLS传输,0-不启用,1-启用
|
||||
public byte[] byRes = new byte[126];
|
||||
}
|
||||
|
||||
public static class NET_EHOME_VOICETALK_NEWLINK_CB_INFO extends Structure {
|
||||
public byte[] szDeviceID = new byte[NET_EHOME_DEVICEID_LEN/*256*/]; //设备标示符(出参)
|
||||
public int dwEncodeType; // //SDK赋值,当前对讲设备的语音编码类型,0- G722_1,1-G711U,2-G711A,3-G726,4-AAC,5-MP2L2,6-PCM, 7-MP3, 8-G723, 9-MP1L2, 10-ADPCM, 99-RAW(未识别类型)(出参)
|
||||
public byte[] sDeviceSerial = new byte[NET_EHOME_SERIAL_LEN/*12*/]; //设备序列号,数字序列号(出参)
|
||||
public int dwAudioChan; //对讲通道(出参)
|
||||
public int lSessionID; //设备分配给该回放会话的ID,0表示无效(出参)
|
||||
public byte[] byToken = new byte[64];
|
||||
public VOICETALK_DATA_CB fnVoiceTalkDataCB; //数据回调函数(入参)
|
||||
public Pointer pUserData; //用户参数, 在fnVoiceTalkDataCB回调出来(入参)
|
||||
public byte[] byRes = new byte[48];
|
||||
}
|
||||
|
||||
|
||||
public static class NET_EHOME_VOICETALK_DATA_CB_PARAM extends Structure {
|
||||
public VOICETALK_DATA_CB fnVoiceTalkDataCB; //数据回调函数
|
||||
public Pointer pUserData; //用户参数, 在fnVoiceTalkDataCB回调出来
|
||||
public byte[] byRes = new byte[128]; //保留
|
||||
}
|
||||
|
||||
public static class NET_EHOME_VOICETALK_DATA_CB_INFO extends Structure {
|
||||
public Pointer pData; //数据指针
|
||||
public int dwDataLen; //数据长度
|
||||
public byte[] byRes = new byte[128]; //保留
|
||||
}
|
||||
|
||||
|
||||
public static class NET_EHOME_VOICETALK_DATA extends Structure {
|
||||
public Pointer pData; //数据指针
|
||||
public int dwDataLen; //数据长度
|
||||
public byte[] byRes = new byte[128]; //保留
|
||||
}
|
||||
|
||||
|
||||
public boolean NET_ESTREAM_Init();
|
||||
|
||||
public boolean NET_ESTREAM_SetSDKLocalCfg(int enumType, Pointer lpInBuff);
|
||||
|
||||
public boolean NET_ESTREAM_SetSDKInitCfg(int enumType, Pointer lpInBuff);
|
||||
|
||||
|
||||
public boolean NET_ESTREAM_Fini();
|
||||
|
||||
public int NET_ESTREAM_GetLastError();
|
||||
|
||||
public boolean NET_ESTREAM_SetExceptionCallBack(int dwMessage, int hWnd, fExceptionCallBack cbExceptionCallBack, Pointer pUser);
|
||||
|
||||
public boolean NET_ESTREAM_SetLogToFile(int iLogLevel, String strLogDir, boolean bAutoDel);
|
||||
|
||||
//获取版本号
|
||||
public int NET_ESTREAM_GetBuildVersion();
|
||||
|
||||
public int NET_ESTREAM_StartListenPreview(NET_EHOME_LISTEN_PREVIEW_CFG pListenParam);
|
||||
|
||||
public int NET_ESTREAM_StartListenPlayBack(NET_EHOME_PLAYBACK_LISTEN_PARAM pListenParam);
|
||||
public boolean NET_ESTREAM_SetPlayBackDataCB(int iPlayBackLinkHandle, NET_EHOME_PLAYBACK_DATA_CB_PARAM pDataCBParam);
|
||||
|
||||
public boolean NET_ESTREAM_StopListenPreview(int iListenHandle);
|
||||
|
||||
public boolean NET_ESTREAM_StopListenVoiceTalk(int lListenHandle);
|
||||
|
||||
public boolean NET_ESTREAM_StopPreview(int iPreviewHandle);
|
||||
|
||||
public boolean NET_ESTREAM_StopVoiceTalk(int lHandle);
|
||||
|
||||
public boolean NET_ESTREAM_SetPreviewDataCB(int iHandle, NET_EHOME_PREVIEW_DATA_CB_PARAM pStruCBParam);
|
||||
boolean NET_ESTREAM_StopPlayBack(int iPlayBackLinkHandle);
|
||||
boolean NET_ESTREAM_StopListenPlayBack(int iPlaybackListenHandle);
|
||||
public int NET_ESTREAM_StartListenVoiceTalk(NET_EHOME_LISTEN_VOICETALK_CFG pListenParam);
|
||||
|
||||
public boolean NET_ESTREAM_SetVoiceTalkDataCB(int lHandle, NET_EHOME_VOICETALK_DATA_CB_PARAM pStruCBParam);
|
||||
|
||||
public int NET_ESTREAM_SendVoiceTalkData(int lHandle, NET_EHOME_VOICETALK_DATA pVoicTalkData);
|
||||
|
||||
|
||||
}
|
10533
src/main/java/net/javase/hksup/starter/sdk/HCNetSDK.java
Executable file
10533
src/main/java/net/javase/hksup/starter/sdk/HCNetSDK.java
Executable file
File diff suppressed because it is too large
Load Diff
580
src/main/java/net/javase/hksup/starter/service/CmsServer.java
Normal file
580
src/main/java/net/javase/hksup/starter/service/CmsServer.java
Normal file
|
@ -0,0 +1,580 @@
|
|||
package net.javase.hksup.starter.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sun.jna.Native;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javase.hksup.starter.config.HkSupSdkProperties;
|
||||
import net.javase.hksup.starter.model.FaceInfoParam;
|
||||
import net.javase.hksup.starter.model.SearchFaceInfoParam;
|
||||
import net.javase.hksup.starter.model.UserInfo;
|
||||
import net.javase.hksup.starter.model.UserInfoDetail;
|
||||
import net.javase.hksup.starter.sdk.HCISUPCMS;
|
||||
import net.javase.hksup.starter.utils.SystemUtil;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* CmsServer
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Slf4j
|
||||
public class CmsServer {
|
||||
|
||||
|
||||
private final HkSupSdkProperties supSdkProperties;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
|
||||
public HCISUPCMS hcisupcms = null;
|
||||
private int CmsHandle = -1; //CMS监听句柄
|
||||
private HCISUPCMS.DEVICE_REGISTER_CB deviceRegisterCb;
|
||||
HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM struCMSListenPara = new HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM();
|
||||
|
||||
public CmsServer(HkSupSdkProperties supSdkProperties, ApplicationContext applicationContext) {
|
||||
this.supSdkProperties = supSdkProperties;
|
||||
this.applicationContext = applicationContext;
|
||||
createSDKInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同操作系统选择不同的库文件和库路径
|
||||
*/
|
||||
private boolean createSDKInstance() {
|
||||
if (hcisupcms == null) {
|
||||
String libPath = libPath();
|
||||
synchronized (HCISUPCMS.class) {
|
||||
String strDllPath = "";
|
||||
try {
|
||||
SystemUtil.jnaDebugLoad(supSdkProperties.getJnaDebug());
|
||||
if (SystemUtil.isWindows()) {
|
||||
strDllPath = libPath + "HCISUPCMS.dll";
|
||||
} else if (SystemUtil.isLinux()) {
|
||||
strDllPath = libPath + "libHCISUPCMS.so";
|
||||
}
|
||||
log.info("loadLibrary: {}", strDllPath);
|
||||
hcisupcms = (HCISUPCMS) Native.loadLibrary(strDllPath, HCISUPCMS.class);
|
||||
} catch (Exception ex) {
|
||||
log.error("loadLibrary: {}, Error: {}", strDllPath, ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* cms服务初始化,开启监听
|
||||
*/
|
||||
public void cmsInit() {
|
||||
if (hcisupcms == null) {
|
||||
if (!createSDKInstance()) {
|
||||
throw new RuntimeException("Load CMS SDK fail!");
|
||||
}
|
||||
}
|
||||
String libPath = libPath();
|
||||
if (SystemUtil.isWindows()) {
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCrypto = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathCrypto = libPath + "libeay32.dll"; //Linux版本是libcrypto.so库文件的路径
|
||||
System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, strPathCrypto.length());
|
||||
ptrByteArrayCrypto.write();
|
||||
hcisupcms.NET_ECMS_SetSDKInitCfg(0, ptrByteArrayCrypto.getPointer());
|
||||
|
||||
//设置libssl.so所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraySsl = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathSsl = libPath + "ssleay32.dll"; //Linux版本是libssl.so库文件的路径
|
||||
System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, strPathSsl.length());
|
||||
ptrByteArraySsl.write();
|
||||
hcisupcms.NET_ECMS_SetSDKInitCfg(1, ptrByteArraySsl.getPointer());
|
||||
//注册服务初始化
|
||||
boolean binit = hcisupcms.NET_ECMS_Init();
|
||||
//设置HCAapSDKCom组件库文件夹所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCom = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathCom = libPath + "HCAapSDKCom"; //只支持绝对路径,建议使用英文路径
|
||||
System.arraycopy(strPathCom.getBytes(), 0, ptrByteArrayCom.byValue, 0, strPathCom.length());
|
||||
ptrByteArrayCom.write();
|
||||
hcisupcms.NET_ECMS_SetSDKLocalCfg(5, ptrByteArrayCom.getPointer());
|
||||
|
||||
} else if (SystemUtil.isLinux()) {
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCrypto = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathCrypto = libPath + "libcrypto.so"; //Linux版本是libcrypto.so库文件的路径
|
||||
System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, strPathCrypto.length());
|
||||
ptrByteArrayCrypto.write();
|
||||
hcisupcms.NET_ECMS_SetSDKInitCfg(0, ptrByteArrayCrypto.getPointer());
|
||||
|
||||
//设置libssl.so所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraySsl = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathSsl = libPath + "libssl.so"; //Linux版本是libssl.so库文件的路径
|
||||
System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, strPathSsl.length());
|
||||
ptrByteArraySsl.write();
|
||||
hcisupcms.NET_ECMS_SetSDKInitCfg(1, ptrByteArraySsl.getPointer());
|
||||
//注册服务初始化
|
||||
boolean binit = hcisupcms.NET_ECMS_Init();
|
||||
//设置HCAapSDKCom组件库文件夹所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCom = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathCom = libPath + "HCAapSDKCom/"; //只支持绝对路径,建议使用英文路径
|
||||
System.arraycopy(strPathCom.getBytes(), 0, ptrByteArrayCom.byValue, 0, strPathCom.length());
|
||||
ptrByteArrayCom.write();
|
||||
hcisupcms.NET_ECMS_SetSDKLocalCfg(5, ptrByteArrayCom.getPointer());
|
||||
|
||||
}
|
||||
hcisupcms.NET_ECMS_SetLogToFile(3, logPath(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启监听
|
||||
*/
|
||||
public void startCmsListen() {
|
||||
if (deviceRegisterCb == null) {
|
||||
Map<String, HCISUPCMS.DEVICE_REGISTER_CB> beansOfType = applicationContext.getBeansOfType(HCISUPCMS.DEVICE_REGISTER_CB.class);
|
||||
if (beansOfType.size() < 1) {
|
||||
throw new RuntimeException("not found device register callback implement!");
|
||||
}
|
||||
beansOfType.forEach((k, v) -> deviceRegisterCb = v);
|
||||
}
|
||||
System.arraycopy(supSdkProperties.getCmsServerIp().getBytes(), 0, struCMSListenPara.struAddress.szIP, 0, supSdkProperties.getCmsServerIp().length());
|
||||
struCMSListenPara.struAddress.wPort = Short.parseShort(supSdkProperties.getCmsServerPort().toString());
|
||||
struCMSListenPara.fnCB = deviceRegisterCb;
|
||||
struCMSListenPara.write();
|
||||
//启动监听,接收设备注册信息
|
||||
CmsHandle = hcisupcms.NET_ECMS_StartListen(struCMSListenPara);
|
||||
if (CmsHandle < -1) {
|
||||
log.info("NET_ECMS_StartListen failed, error code: {}", hcisupcms.NET_ECMS_GetLastError());
|
||||
hcisupcms.NET_ECMS_Fini();
|
||||
return;
|
||||
}
|
||||
String CmsListenInfo = new String(struCMSListenPara.struAddress.szIP).trim() + "_" + struCMSListenPara.struAddress.wPort;
|
||||
log.info("注册服务器: {}, NET_ECMS_StartListen succeed!\n", CmsListenInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化CMS服务
|
||||
*/
|
||||
void startCmsServer() {
|
||||
try {
|
||||
cmsInit();
|
||||
startCmsListen();
|
||||
} catch (Exception ex) {
|
||||
log.error("启动CMS注册服务失败: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止CMS服务,回收资源
|
||||
*/
|
||||
void stopCmsServer() {
|
||||
try {
|
||||
if (CmsHandle >= 0) {
|
||||
log.info("开始停止CMS注册服务");
|
||||
hcisupcms.NET_ECMS_StopListen(CmsHandle);
|
||||
hcisupcms.NET_ECMS_Fini();
|
||||
log.info("停止CMS注册服务成功!");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("停止CMS注册服务失败: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加人员工号信息
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param userInfo 人员信息
|
||||
*/
|
||||
public String addEmployeeInfo(int loginID, UserInfo userInfo) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "POST /ISAPI/AccessControl/UserInfo/Record?format=json"; //添加人员URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,下发人员信息json报文
|
||||
Map<String, Object> parameter = new HashMap<>();
|
||||
parameter.put("UserInfo", userInfo); // 员工ID
|
||||
String input = JSONObject.toJSONString(parameter);
|
||||
log.info("添加人员信息json报文: {}", input);
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("添加人员失败,NET_ECMS_ISAPIPassThrough failed,error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除人员工号信息
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param employeeNos 员工编号
|
||||
*/
|
||||
public String deleteEmployeeInfo(int loginID, String... employeeNos) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "PUT /ISAPI/AccessControl/UserInfoDetail/Delete?format=json"; //删除人员URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,删除人员信息json报文
|
||||
Map<String, Object> parameter = new HashMap<>();
|
||||
parameter.put("mode", "byEmployeeNo"); // 删除方式, byEmployeeNo: 按员工ID号
|
||||
UserInfoDetail detail = new UserInfoDetail();
|
||||
detail.setMode("byEmployeeNo");
|
||||
List<UserInfoDetail.EmployeeNo> list = new ArrayList<>();
|
||||
for (String no : employeeNos) {
|
||||
list.add(new UserInfoDetail.EmployeeNo(no));
|
||||
}
|
||||
detail.setEmployeeNoList(list);
|
||||
parameter.put("UserInfoDetail", detail);
|
||||
|
||||
String input = JSONObject.toJSONString(parameter);
|
||||
log.info("删除人员信息json报文: {}", input);
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("删除人员失败,NET_ECMS_ISAPIPassThrough failed,error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n删除人员成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询人员工号信息
|
||||
*
|
||||
* @param loginID 设备登录句柄ID
|
||||
*/
|
||||
public void searchEmployeeInfo(int loginID) {
|
||||
searchEmployeeInfo(loginID, 30);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询人员工号信息
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
*/
|
||||
public String searchEmployeeInfo(int loginID, int maxResults) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "POST /ISAPI/AccessControl/UserInfo/Search?format=json"; //查询人员URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
//输入参数,XML或者JSON数据,查询多条人员信息json报文
|
||||
Map<String, Object> parameter = new HashMap<>();
|
||||
Map<String, Object> userInfoSearchCond = new HashMap<>();
|
||||
userInfoSearchCond.put("searchID", uuid); // 查询id
|
||||
userInfoSearchCond.put("searchResultPosition", 0);
|
||||
userInfoSearchCond.put("maxResults", 30); // 最大查询数量
|
||||
parameter.put("UserInfoSearchCond", userInfoSearchCond);
|
||||
String input = JSONObject.toJSONString(parameter);
|
||||
|
||||
//输入参数,XML或者JSON数据,指定人员工号查询json报文
|
||||
log.info("查询人员工号信息json报文: {}", input);
|
||||
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("查询人员失败,NET_ECMS_ISAPIPassThrough failed, error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed!\n查询人员成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下发门禁人脸图片数据
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param param 人脸数据
|
||||
*/
|
||||
public String addFacePicInfo(int loginID, FaceInfoParam param) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "POST /ISAPI/Intelligent/FDLib/FaceDataRecord?format=json"; //添加人脸URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,添加人脸图片json报文
|
||||
String input = JSONObject.toJSONString(param);
|
||||
log.info("下发门禁人脸图片 json报文: {}", input);
|
||||
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("下发门禁人脸失败,NET_ECMS_ISAPIPassThrough failed,error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n下发门禁人脸成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改门禁人脸图片数据
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param param 人脸数据
|
||||
*/
|
||||
public String modifyFacePicInfo(int loginID, FaceInfoParam param) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
// 透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "PUT /ISAPI/Intelligent/FDLib/FDModify?format=json"; //修改人脸URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,添加人脸图片json报文
|
||||
String input = JSONObject.toJSONString(param);
|
||||
log.info("修改门禁人脸图片 json报文: {}", input);
|
||||
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("修改门禁人脸失败,NET_ECMS_ISAPIPassThrough failed,error:" + hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n修改门禁人脸成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除人脸图片数据
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param employeeNo 人员工号,按照指定人员删除关联人脸图片
|
||||
*/
|
||||
public String deleteFacePicInfo(int loginID, String employeeNo) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "PUT /ISAPI/Intelligent/FDLib/FDSearch/Delete?format=json&FDID=1&faceLibType=blackFD"; //删除人脸URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,删除人脸图片json报文
|
||||
Map<String, Object> parameter = new HashMap<>();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("value", employeeNo);
|
||||
list.add(map);
|
||||
parameter.put("FPID", list);
|
||||
|
||||
String input = JSONObject.toJSONString(parameter);
|
||||
log.info("删除人脸图片数据 json报文: {}", input);
|
||||
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("删除门禁人脸失败,NET_ECMS_ISAPIPassThrough failed,error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n删除门禁人脸成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询门禁人脸图片
|
||||
*
|
||||
* @param loginID 登录设备句柄ID
|
||||
* @param employeeNo 人员工号,按照指定人员查询关联人脸图片
|
||||
*/
|
||||
public String searchFacePicInfo(int loginID, String employeeNo) {
|
||||
HCISUPCMS.NET_EHOME_PTXML_PARAM m_struParam2 = new HCISUPCMS.NET_EHOME_PTXML_PARAM();
|
||||
m_struParam2.read();
|
||||
//透传URL,不同功能对应不同的URL,完整协议报文说明需要参考ISAPI协议文档
|
||||
String urlInBuffer = "POST /ISAPI/Intelligent/FDLib/FDSearch?format=json"; //查询人脸URL
|
||||
HCISUPCMS.BYTE_ARRAY ptrurlInBuffer = new HCISUPCMS.BYTE_ARRAY(urlInBuffer.length() + 1);
|
||||
System.arraycopy(urlInBuffer.getBytes(), 0, ptrurlInBuffer.byValue, 0, urlInBuffer.length());
|
||||
ptrurlInBuffer.write();
|
||||
m_struParam2.pRequestUrl = ptrurlInBuffer.getPointer();
|
||||
m_struParam2.dwRequestUrlLen = urlInBuffer.length();
|
||||
|
||||
//输入参数,XML或者JSON数据,查询人脸图片json报文
|
||||
SearchFaceInfoParam param = new SearchFaceInfoParam(employeeNo);
|
||||
String input = JSONObject.toJSONString(param);
|
||||
//批量查询人脸图片json报文
|
||||
log.info("查询门禁人脸图片 json报文: {}", input);
|
||||
|
||||
byte[] byInbuffer = input.getBytes(StandardCharsets.UTF_8);
|
||||
int iInBufLen = byInbuffer.length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrInBuffer = new HCISUPCMS.BYTE_ARRAY(iInBufLen);
|
||||
ptrInBuffer.read();
|
||||
System.arraycopy(byInbuffer, 0, ptrInBuffer.byValue, 0, iInBufLen);
|
||||
ptrInBuffer.write();
|
||||
m_struParam2.pInBuffer = ptrInBuffer.getPointer();//GET获取时不需要输入参数,输入为null
|
||||
m_struParam2.dwInSize = iInBufLen;
|
||||
//输出参数,分配的内存用于存储返回的数据,需要大于等于实际内容大小
|
||||
int iOutSize2 = 2 * 1024 * 1024;
|
||||
HCISUPCMS.BYTE_ARRAY ptrOutByte2 = new HCISUPCMS.BYTE_ARRAY(iOutSize2);
|
||||
m_struParam2.pOutBuffer = ptrOutByte2.getPointer();
|
||||
m_struParam2.dwOutSize = iOutSize2;
|
||||
m_struParam2.dwRecvTimeOut = 5000; //接收超时时间,单位毫秒
|
||||
m_struParam2.write();
|
||||
if (!hcisupcms.NET_ECMS_ISAPIPassThrough(loginID, m_struParam2)) {
|
||||
log.info("查询门禁人脸失败,NET_ECMS_ISAPIPassThrough failed,error:{}", hcisupcms.NET_ECMS_GetLastError());
|
||||
return null;
|
||||
} else {
|
||||
m_struParam2.read();
|
||||
ptrOutByte2.read();
|
||||
String res = new String(ptrOutByte2.byValue).trim();
|
||||
log.info("NET_ECMS_ISAPIPassThrough succeed\n查询门禁人脸成功, 输出报文: {}", res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lib根目录
|
||||
*/
|
||||
private String libPath() {
|
||||
String libPath = supSdkProperties.getLibPath();
|
||||
if (!StringUtils.hasText(libPath)) {
|
||||
return SystemUtil.userDir() + File.separator + "lib" + File.separator;
|
||||
}
|
||||
return libPath.endsWith(File.separator) ? libPath : libPath + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志根目录
|
||||
*/
|
||||
private String logPath() {
|
||||
String logPath = supSdkProperties.getSdkLogPath();
|
||||
return StringUtils.hasText(logPath) ?
|
||||
logPath :
|
||||
SystemUtil.userDir() + File.separator + "EHomeSDKLog";
|
||||
}
|
||||
|
||||
}
|
373
src/main/java/net/javase/hksup/starter/service/SsServer.java
Normal file
373
src/main/java/net/javase/hksup/starter/service/SsServer.java
Normal file
|
@ -0,0 +1,373 @@
|
|||
package net.javase.hksup.starter.service;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javase.hksup.starter.config.HkSupSdkProperties;
|
||||
import net.javase.hksup.starter.sdk.HCISUPCMS;
|
||||
import net.javase.hksup.starter.sdk.HCISUPSS;
|
||||
import net.javase.hksup.starter.utils.SystemUtil;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SsServer
|
||||
*
|
||||
* @author Frank
|
||||
*/
|
||||
@Slf4j
|
||||
public class SsServer {
|
||||
|
||||
public HCISUPSS hCEhomeSS = null;
|
||||
String PSS_CLIENT_FILE_PATH_PARAM_NAME = "File-Path"; //图片文件路径
|
||||
String PSS_CLIENT_VRB_FILENAME_CODE = "Filename-Code";//VRB协议的FilenameCode
|
||||
String PSS_CLIENT_KMS_USER_NAME = "KMS-Username"; //KMS图片服务器用户名
|
||||
String PSS_CLIENT_KMS_PASSWORD = "KMS-Password"; //KMS图片服务器密码
|
||||
String PSS_CLIENT_CLOUD_AK_NAME = "Access-Key"; //云存储协议AcessKey
|
||||
String PSS_CLIENT_CLOUD_SK_NAME = "Secret-Key"; //云存储协议SecretKey
|
||||
|
||||
private HCISUPSS.EHomeSSMsgCallBack eHomeSSMsgCallBack;// 信息回调函数(上报)
|
||||
private HCISUPSS.EHomeSSStorageCallBack eHomeSSStorageCallBack;// 文件保存回调函数(下载)
|
||||
private HCISUPSS.EHomeSSRWCallBackEx eHomeSSRWCallBackEx; //读写扩展回调函数
|
||||
private HCISUPSS.NET_EHOME_SS_LISTEN_PARAM pSSListenParam = new HCISUPSS.NET_EHOME_SS_LISTEN_PARAM();
|
||||
public static int ssHandle = -1; //存储服务监听句柄
|
||||
int client = -1;
|
||||
static int iCount = 0;
|
||||
byte[] szUrl = new byte[HCISUPSS.MAX_URL_LEN_SS];
|
||||
String url = "";
|
||||
|
||||
private final HkSupSdkProperties hkSupSdkProperties;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public SsServer(HkSupSdkProperties hkSupSdkProperties, ApplicationContext applicationContext) {
|
||||
this.hkSupSdkProperties = hkSupSdkProperties;
|
||||
this.applicationContext = applicationContext;
|
||||
createSDKInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同操作系统选择不同的库文件和库路径
|
||||
*/
|
||||
private boolean createSDKInstance() {
|
||||
String libPath = libPath();
|
||||
if (hCEhomeSS == null) {
|
||||
synchronized (HCISUPSS.class) {
|
||||
String strDllPath = "";
|
||||
try {
|
||||
SystemUtil.jnaDebugLoad(hkSupSdkProperties.getJnaDebug());
|
||||
if (SystemUtil.isWindows()) {
|
||||
strDllPath = libPath + "HCISUPSS.dll";
|
||||
} else if (SystemUtil.isLinux()) {
|
||||
strDllPath = libPath + "libHCISUPSS.so";
|
||||
}
|
||||
log.info("loadLibrary: {}", strDllPath);
|
||||
hCEhomeSS = (HCISUPSS) Native.loadLibrary(strDllPath, HCISUPSS.class);
|
||||
} catch (Exception ex) {
|
||||
log.error("loadLibrary: {}, Error: {}", strDllPath, ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void eSSInit() {
|
||||
if (hCEhomeSS == null) {
|
||||
if (!createSDKInstance()) {
|
||||
throw new RuntimeException("Load SS SDK fail");
|
||||
}
|
||||
}
|
||||
String libPath = libPath();
|
||||
if (SystemUtil.isWindows()) {
|
||||
String strPathCrypto = libPath + "libeay32.dll"; //Linux版本是libcrypto.so库文件的路径
|
||||
int iPathCryptoLen = strPathCrypto.getBytes().length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCrypto = new HCISUPCMS.BYTE_ARRAY(iPathCryptoLen + 1);
|
||||
System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, iPathCryptoLen);
|
||||
ptrByteArrayCrypto.write();
|
||||
log.info(new String(ptrByteArrayCrypto.byValue));
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(4, ptrByteArrayCrypto.getPointer());
|
||||
|
||||
//设置libssl.so所在路径
|
||||
String strPathSsl = libPath + "ssleay32.dll"; //Linux版本是libssl.so库文件的路径
|
||||
int iPathSslLen = strPathSsl.getBytes().length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraySsl = new HCISUPCMS.BYTE_ARRAY(iPathSslLen + 1);
|
||||
System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, iPathSslLen);
|
||||
ptrByteArraySsl.write();
|
||||
log.info(new String(ptrByteArraySsl.byValue));
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(5, ptrByteArraySsl.getPointer());
|
||||
|
||||
//设置sqlite3库的路径
|
||||
String strPathSqlite = libPath + "sqlite3.dll";
|
||||
int iPathSqliteLen = strPathSqlite.getBytes().length;
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraySqlite = new HCISUPCMS.BYTE_ARRAY(iPathSqliteLen + 1);
|
||||
System.arraycopy(strPathSqlite.getBytes(), 0, ptrByteArraySqlite.byValue, 0, iPathSqliteLen);
|
||||
ptrByteArraySqlite.write();
|
||||
log.info(new String(ptrByteArraySqlite.byValue));
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(6, ptrByteArraySqlite.getPointer());
|
||||
//SDK初始化
|
||||
boolean sinit = hCEhomeSS.NET_ESS_Init();
|
||||
if (!sinit) {
|
||||
log.info("NET_ESS_Init失败,错误码:{}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
//设置图片存储服务器公网地址 (当存在内外网映射时使用
|
||||
HCISUPCMS.NET_EHOME_IPADDRESS ipaddress = new HCISUPCMS.NET_EHOME_IPADDRESS();
|
||||
String ServerIP = hkSupSdkProperties.getPicServerIp();
|
||||
System.arraycopy(ServerIP.getBytes(), 0, ipaddress.szIP, 0, ServerIP.length());
|
||||
ipaddress.wPort = Short.parseShort(hkSupSdkProperties.getPicServerPort().toString());
|
||||
ipaddress.write();
|
||||
boolean b = hCEhomeSS.NET_ESS_SetSDKInitCfg(3, ipaddress.getPointer());
|
||||
if (!b) {
|
||||
log.info("NET_ESS_SetSDKInitCfg失败,错误码:{}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
|
||||
} else if (SystemUtil.isLinux()) {
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArrayCrypto = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathCrypto = libPath + "libcrypto.so"; //Linux版本是libcrypto.so库文件的路径
|
||||
log.info(strPathCrypto);
|
||||
System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, strPathCrypto.length());
|
||||
ptrByteArrayCrypto.write();
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(4, ptrByteArrayCrypto.getPointer());
|
||||
|
||||
//设置libssl.so所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraySsl = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathSsl = libPath + "libssl.so"; //Linux版本是libssl.so库文件的路径
|
||||
log.info(strPathSsl);
|
||||
System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, strPathSsl.length());
|
||||
ptrByteArraySsl.write();
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(5, ptrByteArraySsl.getPointer());
|
||||
|
||||
//设置splite3.so所在路径
|
||||
HCISUPCMS.BYTE_ARRAY ptrByteArraysplite = new HCISUPCMS.BYTE_ARRAY(256);
|
||||
String strPathsplite = libPath + "libsqlite3.so"; //Linux版本是libsqlite3.so库文件的路径
|
||||
log.info(strPathsplite);
|
||||
System.arraycopy(strPathsplite.getBytes(), 0, ptrByteArraysplite.byValue, 0, strPathsplite.length());
|
||||
ptrByteArraysplite.write();
|
||||
hCEhomeSS.NET_ESS_SetSDKInitCfg(6, ptrByteArraysplite.getPointer());
|
||||
//SDK初始化
|
||||
boolean sinit = hCEhomeSS.NET_ESS_Init();
|
||||
if (!sinit) {
|
||||
log.info("NET_ESS_Init失败,错误码:{}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
//设置图片存储服务器公网地址 (当存在内外网映射时使用
|
||||
HCISUPCMS.NET_EHOME_IPADDRESS ipaddress = new HCISUPCMS.NET_EHOME_IPADDRESS();
|
||||
String ServerIP = hkSupSdkProperties.getPicServerIp();
|
||||
System.arraycopy(ServerIP.getBytes(), 0, ipaddress.szIP, 0, ServerIP.length());
|
||||
ipaddress.wPort = Short.parseShort(hkSupSdkProperties.getPicServerPort().toString());
|
||||
ipaddress.write();
|
||||
boolean b = hCEhomeSS.NET_ESS_SetSDKInitCfg(3, ipaddress.getPointer());
|
||||
if (!b) {
|
||||
log.info("NET_ESS_SetSDKInitCfg失败,错误码:{}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
|
||||
}
|
||||
//启用SDK写日志
|
||||
boolean logToFile = hCEhomeSS.NET_ESS_SetLogToFile(3, logPath(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启存储服务监听
|
||||
*/
|
||||
private void startSsListen() {
|
||||
String SSIP = hkSupSdkProperties.getPicServerListenIp();
|
||||
System.arraycopy(SSIP.getBytes(), 0, pSSListenParam.struAddress.szIP, 0, SSIP.length());
|
||||
pSSListenParam.struAddress.wPort = Short.parseShort(hkSupSdkProperties.getPicServerListenPort().toString());
|
||||
String strKMS_UserName = hkSupSdkProperties.getKmsUsername();
|
||||
System.arraycopy(strKMS_UserName.getBytes(), 0, pSSListenParam.szKMS_UserName, 0, strKMS_UserName.length());
|
||||
String strKMS_Password = hkSupSdkProperties.getKmsPassword();
|
||||
System.arraycopy(strKMS_Password.getBytes(), 0, pSSListenParam.szKMS_Password, 0, strKMS_Password.length());
|
||||
String strAccessKey = hkSupSdkProperties.getSzAk();
|
||||
System.arraycopy(strAccessKey.getBytes(), 0, pSSListenParam.szAccessKey, 0, strAccessKey.length());
|
||||
String strSecretKey = hkSupSdkProperties.getSzSk();
|
||||
System.arraycopy(strSecretKey.getBytes(), 0, pSSListenParam.szSecretKey, 0, strSecretKey.length());
|
||||
pSSListenParam.byHttps = 0;
|
||||
/******************************************************************
|
||||
* 存储信息回调
|
||||
*/
|
||||
if (eHomeSSMsgCallBack == null) {
|
||||
Map<String, HCISUPSS.EHomeSSMsgCallBack> beansOfType = applicationContext.getBeansOfType(HCISUPSS.EHomeSSMsgCallBack.class);
|
||||
if (beansOfType.size() < 1) {
|
||||
throw new RuntimeException("not found EHomeSSMsgCallBack implement!");
|
||||
}
|
||||
beansOfType.forEach((k, v) -> eHomeSSMsgCallBack = v);
|
||||
}
|
||||
pSSListenParam.fnSSMsgCb = eHomeSSMsgCallBack;
|
||||
|
||||
/******************************************************************
|
||||
* 存储数据回调
|
||||
* fnSStorageCb或者fnSSRWCbEx,只需要设置一种回调函数
|
||||
* 简单功能测试可以使用存储回调(SDK底层使用db数据库自动存取数据,因此会受到db数据库的性能瓶颈影响)
|
||||
* 需要自定义URL或者自己读写图片数据,则使用读写扩展回调(推荐)
|
||||
*/
|
||||
//存储信息回调
|
||||
if (eHomeSSStorageCallBack == null) {
|
||||
Map<String, HCISUPSS.EHomeSSStorageCallBack> beansOfType = applicationContext.getBeansOfType(HCISUPSS.EHomeSSStorageCallBack.class);
|
||||
if (beansOfType.size() < 1) {
|
||||
throw new RuntimeException("not found eHomeSSStorageCallBack implement!");
|
||||
}
|
||||
beansOfType.forEach((k, v) -> eHomeSSStorageCallBack = v);
|
||||
}
|
||||
pSSListenParam.fnSStorageCb = eHomeSSStorageCallBack;
|
||||
//读写扩展回调
|
||||
// if (eHomeSSRWCallBackEx == null) {
|
||||
// eHomeSSRWCallBackEx = new cbEHomeSSRWCallBackEx();
|
||||
// }
|
||||
// pSSListenParam.fnSSRWCbEx = eHomeSSRWCallBackEx;
|
||||
|
||||
pSSListenParam.bySecurityMode = 1;
|
||||
pSSListenParam.write();
|
||||
ssHandle = hCEhomeSS.NET_ESS_StartListen(pSSListenParam);
|
||||
if (ssHandle == -1) {
|
||||
int err = hCEhomeSS.NET_ESS_GetLastError();
|
||||
log.info("NET_ESS_StartListen failed,error: {}", err);
|
||||
hCEhomeSS.NET_ESS_Fini();
|
||||
} else {
|
||||
String SsListenInfo = new String(pSSListenParam.struAddress.szIP).trim() + "_" + pSSListenParam.struAddress.wPort;
|
||||
log.info("存储服务器:{}, NET_ESS_StartListen succeed!\n", SsListenInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建存储客户端
|
||||
*/
|
||||
private void ssCreateClient(String filePath) {
|
||||
HCISUPSS.NET_EHOME_SS_CLIENT_PARAM pClientParam = new HCISUPSS.NET_EHOME_SS_CLIENT_PARAM();
|
||||
//存储服务器类型
|
||||
switch (hkSupSdkProperties.getPicServerType()) {
|
||||
case 1:
|
||||
pClientParam.enumType = HCISUPSS.NET_EHOME_SS_CLIENT_TYPE_VRB;
|
||||
break;
|
||||
case 2:
|
||||
pClientParam.enumType = HCISUPSS.NET_EHOME_SS_CLIENT_TYPE_CLOUD;
|
||||
break;
|
||||
case 3:
|
||||
pClientParam.enumType = HCISUPSS.NET_EHOME_SS_CLIENT_TYPE_KMS;
|
||||
break;
|
||||
default:
|
||||
log.info("存储服务器类型选择错误");
|
||||
break;
|
||||
}
|
||||
pClientParam.struAddress.szIP = hkSupSdkProperties.getPicServerIp().getBytes();
|
||||
pClientParam.struAddress.wPort = Short.parseShort(hkSupSdkProperties.getPicServerPort().toString());
|
||||
pClientParam.byHttps = 0;
|
||||
pClientParam.write();
|
||||
|
||||
client = hCEhomeSS.NET_ESS_CreateClient(pClientParam);
|
||||
if (client < 0) {
|
||||
int err = hCEhomeSS.NET_ESS_GetLastError();
|
||||
log.warn("创建图片上传/下载客户端出错,错误号:{}, client={}", err, client);
|
||||
} else {
|
||||
if (!hCEhomeSS.NET_ESS_ClientSetTimeout(client, 6000, 6000)) {
|
||||
int err = hCEhomeSS.NET_ESS_GetLastError();
|
||||
log.warn("NET_ESS_ClientSetTimeout失败,错误号:{}", err);
|
||||
}
|
||||
boolean bSetParam = hCEhomeSS.NET_ESS_ClientSetParam(client, PSS_CLIENT_FILE_PATH_PARAM_NAME, filePath);
|
||||
boolean bKMS_UserName = hCEhomeSS.NET_ESS_ClientSetParam(client, "SS_CLIENT_KMS_USER_NAME", hkSupSdkProperties.getKmsUsername());
|
||||
if (!bKMS_UserName) {
|
||||
log.warn("NET_ESS_ClientSetParam失败\n err: {}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
boolean bKMS_PassWord = hCEhomeSS.NET_ESS_ClientSetParam(client, "SS_CLIENT_KMS_PASSWIRD", hkSupSdkProperties.getKmsPassword());
|
||||
if(!bKMS_PassWord) {
|
||||
log.warn("NET_ESS_ClientSetParam失败\n err: {}", hCEhomeSS.NET_ESS_GetLastError());
|
||||
}
|
||||
boolean bCloud_AK = hCEhomeSS.NET_ESS_ClientSetParam(client, PSS_CLIENT_CLOUD_AK_NAME, hkSupSdkProperties.getSzAk());
|
||||
boolean bCloud_SK = hCEhomeSS.NET_ESS_ClientSetParam(client, PSS_CLIENT_CLOUD_SK_NAME, hkSupSdkProperties.getSzSk());
|
||||
log.info("ssCreateClient: bSetParam: {},bKMS_UserName: {}, bKMS_PassWord: {}, bCloud_AK: {}, bCloud_SK: {}",
|
||||
bSetParam, bKMS_UserName, bKMS_PassWord, bCloud_AK, bCloud_SK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片到存储服务,返回URL
|
||||
*/
|
||||
private String ssUploadPic() {
|
||||
iCount++;
|
||||
szUrl = new byte[HCISUPSS.MAX_URL_LEN_SS];
|
||||
|
||||
boolean doUpload = hCEhomeSS.NET_ESS_ClientDoUpload(client, szUrl, HCISUPSS.MAX_URL_LEN_SS - 1);
|
||||
if (!doUpload) {
|
||||
int err = hCEhomeSS.NET_ESS_GetLastError();
|
||||
log.warn("NET_ESS_ClientDoUpload失败,错误号:{}", err);
|
||||
return null;
|
||||
} else {
|
||||
url = "http://" + hkSupSdkProperties.getPicServerIp() + ":" + hkSupSdkProperties.getPicServerPort() + new String(szUrl).trim();
|
||||
log.info("NET_ESS_ClientDoUpload succeed, Count: {}, Pic Url: {}", iCount, url);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁存储客户端
|
||||
*/
|
||||
private void ssDestroyClient() {
|
||||
if (hCEhomeSS.NET_ESS_DestroyClient(client))//释放资源
|
||||
{
|
||||
client = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片返回url
|
||||
*
|
||||
* @param fileAbsPath 文件路径
|
||||
* @return url
|
||||
*/
|
||||
public String uploadPic(String fileAbsPath) {
|
||||
ssCreateClient(fileAbsPath);
|
||||
String url = ssUploadPic();
|
||||
ssDestroyClient();
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动服务
|
||||
*/
|
||||
void startSsServer() {
|
||||
try {
|
||||
eSSInit();
|
||||
startSsListen();
|
||||
} catch (Exception ex) {
|
||||
log.error("启动SS存储服务失败: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止服务, 销毁
|
||||
*/
|
||||
void stopSsServer() {
|
||||
if (ssHandle >= 0) {
|
||||
try {
|
||||
log.info("开始停止存储SS服务");
|
||||
hCEhomeSS.NET_ESS_StopListen(ssHandle);
|
||||
hCEhomeSS.NET_ESS_Fini();
|
||||
log.info("停止存储SS服务成功!");
|
||||
} catch (Exception ex) {
|
||||
log.error("停止存储SS服务失败: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lib根目录
|
||||
*/
|
||||
private String libPath() {
|
||||
String libPath = hkSupSdkProperties.getLibPath();
|
||||
if (!StringUtils.hasText(libPath)) {
|
||||
return SystemUtil.userDir() + File.separator + "lib" + File.separator;
|
||||
}
|
||||
return libPath.endsWith(File.separator) ? libPath : libPath + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志根目录
|
||||
*/
|
||||
private String logPath() {
|
||||
String logPath = hkSupSdkProperties.getSdkLogPath();
|
||||
return StringUtils.hasText(logPath) ?
|
||||
logPath :
|
||||
SystemUtil.userDir() + File.separator + "EHomeSDKLog";
|
||||
}
|
||||
|
||||
}
|
63
src/main/java/net/javase/hksup/starter/utils/CommonMethod.java
Executable file
63
src/main/java/net/javase/hksup/starter/utils/CommonMethod.java
Executable file
|
@ -0,0 +1,63 @@
|
|||
package net.javase.hksup.starter.utils;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class CommonMethod {
|
||||
public static void WriteBuffToPointer(byte[] byData, Pointer pInBuffer) {
|
||||
pInBuffer.write(0, byData, 0, byData.length);
|
||||
}
|
||||
|
||||
public static String byteToString(byte[] bytes) {
|
||||
if (null == bytes || bytes.length == 0) {
|
||||
return "";
|
||||
}
|
||||
int iLengthOfBytes = 0;
|
||||
for (byte st : bytes) {
|
||||
if (st != 0) {
|
||||
iLengthOfBytes++;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
String strContent = "";
|
||||
strContent = new String(bytes, 0, iLengthOfBytes, StandardCharsets.UTF_8);
|
||||
return strContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* utf8字节数组转gbk字节数组
|
||||
*
|
||||
* @param utf8Bytes utf8字节数组
|
||||
* @return gbk字节数组
|
||||
*/
|
||||
public static byte[] UTF8toGBK(byte[] utf8Bytes) {
|
||||
String utf8Str = new String(utf8Bytes, StandardCharsets.UTF_8);
|
||||
return utf8Str.getBytes(Charset.forName("GBK"));
|
||||
}
|
||||
|
||||
/**
|
||||
* utf8字节数组转gbk字符串
|
||||
*
|
||||
* @param utf8Bytes
|
||||
* @return
|
||||
*/
|
||||
public static String UTF8toGBKStr(byte[] utf8Bytes) {
|
||||
return new String(UTF8toGBK(utf8Bytes), Charset.forName("GBK"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取resource文件夹下的文件绝对路径
|
||||
*
|
||||
* @param filePath 文件相对于resources文件夹的相对路径, 格式描述举例为 conf/XX/XX.json
|
||||
* @return
|
||||
*/
|
||||
public static String getResFileAbsPath(String filePath) {
|
||||
if (filePath == null) {
|
||||
throw new RuntimeException("filePath null error!");
|
||||
}
|
||||
return System.getProperty("user.dir") + "\\resources\\" + filePath;
|
||||
}
|
||||
|
||||
}
|
83
src/main/java/net/javase/hksup/starter/utils/ConfigFileUtil.java
Executable file
83
src/main/java/net/javase/hksup/starter/utils/ConfigFileUtil.java
Executable file
|
@ -0,0 +1,83 @@
|
|||
package net.javase.hksup.starter.utils;
|
||||
|
||||
import org.apache.commons.text.StrSubstitutor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhengxiaohui
|
||||
* @date 2023/8/15 19:07
|
||||
* @desc 配置文件处理工具
|
||||
*/
|
||||
public class ConfigFileUtil {
|
||||
|
||||
/**
|
||||
* 获取请求数据报文内容
|
||||
*
|
||||
* @param templateFilePath 报文模板格式文件位置,位于resources文件夹下面(conf/--/--.xx)
|
||||
* @param parameter 模板中可以替换的占位参数信息
|
||||
* @return
|
||||
*/
|
||||
public static String getReqBodyFromTemplate(String templateFilePath, Map<String, Object> parameter) {
|
||||
String templateContent = ConfigFileUtil.readFileContent(templateFilePath);
|
||||
return ConfigFileUtil.replace(templateContent, parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取xml配置文件
|
||||
*
|
||||
* @param filePath 文件相对于resources文件夹的相对路径
|
||||
* @return
|
||||
*/
|
||||
public static String readFileContent(String filePath) {
|
||||
String resourcePath = CommonMethod.getResFileAbsPath(filePath);
|
||||
|
||||
// 读取指定文件路径的文件内容
|
||||
String contentStr = "";
|
||||
try {
|
||||
Path path = Paths.get(resourcePath);
|
||||
contentStr = new String(Files.readAllBytes(path));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return contentStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 占位符变量固定为 ${}格式
|
||||
*
|
||||
* @param source 源内容
|
||||
* @param parameter 占位符参数
|
||||
* <p>
|
||||
* 转义符默认为'$'。如果这个字符放在一个变量引用之前,这个引用将被忽略,不会被替换 如$${a}将直接输出${a}
|
||||
* @return
|
||||
*/
|
||||
public static String replace(String source, Map<String, Object> parameter) {
|
||||
return replace(source, parameter, "${", "}", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换
|
||||
*
|
||||
* @param source 源内容
|
||||
* @param parameter 占位符参数
|
||||
* @param prefix 占位符前缀 例如:${
|
||||
* @param suffix 占位符后缀 例如:}
|
||||
* @param enableSubstitutionInVariables 是否在变量名称中进行替换 例如:${system-${版本}}
|
||||
* <p>
|
||||
* 转义符默认为'$'。如果这个字符放在一个变量引用之前,这个引用将被忽略,不会被替换 如$${a}将直接输出${a}
|
||||
* @return
|
||||
*/
|
||||
public static String replace(String source, Map<String, Object> parameter, String prefix, String suffix, boolean enableSubstitutionInVariables) {
|
||||
//StrSubstitutor不是线程安全的类
|
||||
StrSubstitutor strSubstitutor = new StrSubstitutor(parameter, prefix, suffix);
|
||||
//是否在变量名称中进行替换
|
||||
strSubstitutor.setEnableSubstitutionInVariables(enableSubstitutionInVariables);
|
||||
return strSubstitutor.replace(source);
|
||||
}
|
||||
|
||||
}
|
24
src/main/java/net/javase/hksup/starter/utils/SystemUtil.java
Executable file
24
src/main/java/net/javase/hksup/starter/utils/SystemUtil.java
Executable file
|
@ -0,0 +1,24 @@
|
|||
package net.javase.hksup.starter.utils;
|
||||
|
||||
public class SystemUtil {
|
||||
|
||||
public static final String OS_NAME = System.getProperty("os.name");
|
||||
|
||||
public static boolean isLinux() {
|
||||
return OS_NAME.toLowerCase().contains("linux");
|
||||
}
|
||||
|
||||
public static boolean isWindows() {
|
||||
return OS_NAME.toLowerCase().contains("windows");
|
||||
}
|
||||
|
||||
public static String userDir() {
|
||||
return System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
public static void jnaDebugLoad(boolean flag) {
|
||||
if (flag) {
|
||||
System.setProperty("jna.debug_load", "true");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user