Commit 1a58ea4e by 毛树良

<feat>:增加繁星同步gb1400协议

1 parent 2e054773
Showing 64 changed files with 6442 additions and 0 deletions
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/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
#!/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 "$@"
@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%
<?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.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.viontech</groupId>
<artifactId>fanxing-docking-gb1400</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>fanxing-docking-gb1400</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.72</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
</dependencies>
<build>
<finalName>fanxing-docking-gb1400</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
package com.viontech;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@MapperScan("com.viontech.mapper")
@EnableScheduling
@SpringBootApplication
public class FanxingDockingGb1400Application {
public static void main(String[] args) {
SpringApplication.run(FanxingDockingGb1400Application.class, args);
}
}
package com.viontech;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInit extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(FanxingDockingGb1400Application.class);
}
}
package com.viontech.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@Getter
@Setter
@ConfigurationProperties(prefix = "gb1400")
public class Gb1400Config {
//同步1400开关:1:开启,0:未开启
private String enable;
private String username;
private String password;
private String userIdentify;
private String ipPort;
}
package com.viontech.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
/**
* @author vion
**/
@Component
@Slf4j
public class Gb1400RestTemplate {
@Autowired
private RestTemplate restTemplate;
@Autowired
private Gb1400Config gb1400Config;
public String doPost(String userIdentify, String uri, String content) {
HttpHeaders httpHeaders = setHeader(userIdentify);
if (!uri.startsWith("/")) {
uri = "/" + uri;
}
String url = "http://" + gb1400Config.getIpPort() + uri;
HttpEntity<String> entity = new HttpEntity<>(content, httpHeaders);
if (content.length() > 500) {
// log.info("1400:{} data docking,params:{}", uri, content.substring(0, 500));
log.info("1400:{} data docking,params:{}", uri, content);
} else {
log.info("1400:{} data docking,params:{}", uri, content);
}
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, entity, String.class);
String result = responseEntity.getBody();
log.info("1400:{} data docking,result:{}", uri, result);
return result;
}
private HttpHeaders setHeader(String userIdentify) {
HttpHeaders headers = new HttpHeaders();
headers.add("User-Identify", userIdentify);
headers.add("Content-Type", "application/VIID+JSON;charset=utf-8");
// String currentTime = DateUtil.getCurrentTime(DateUtil.TIMESTAMP_NO_DELIMITER);
// headers.add("User-SendTime", currentTime);
return headers;
}
}
\ No newline at end of file \ No newline at end of file
package com.viontech.config;
import com.viontech.interceptor.Gb1400AuthInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author vion
**/
@Component
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
InterceptorRegistration registration = registry.addInterceptor(new Gb1400AuthInterceptor());
registration.addPathPatterns("/VIID/**");
}
}
\ No newline at end of file \ No newline at end of file
package com.viontech.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.InputStream;
import java.util.Properties;
@Configuration
@Slf4j
public class PropertiesConfiguration {
@Bean(name = "wflxProperties")
public Properties wflxProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/wflx.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 wflx.properties 失败", e);
}
return properties;
}
@Bean(name = "hpysProperties")
public Properties hpysProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/hpys.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 hpys.properties 失败", e);
}
return properties;
}
@Bean(name = "hpzlProperties")
public Properties hpzlProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/hpzl.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 hpzl.properties 失败", e);
}
return properties;
}
@Bean(name = "csysProperties")
public Properties csysProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/csys.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 csys.properties 失败", e);
}
return properties;
}
@Bean(name = "cllxProperties")
public Properties cllxProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/cllx.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 cllx.properties 失败", e);
}
return properties;
}
@Bean(name = "clppProperties")
public Properties clppProperties() {
Properties properties = new Properties();
try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/clpp.properties")) {
properties.load(inputStream);
} catch (Exception e) {
log.error("读取 clpp.properties 失败", e);
}
return properties;
}
}
package com.viontech.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* @Author: zhaibailin
* @Date: 2020/7/16.
* @Description:
*/
@Configuration
public class RedisConfiguration {
@Autowired
private RedisConnectionFactory factory;
@Bean
public RedisTemplate<String,Object> redisTemplate(){
RedisTemplate<String,Object> redisTemplate=new RedisTemplate<>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer=new Jackson2JsonRedisSerializer(Object.class);
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
}
package com.viontech.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory simpleClientHttpRequestFactory) {
RestTemplate restTemplate = new RestTemplate(simpleClientHttpRequestFactory);
restTemplate.setMessageConverters(getConverts());
return restTemplate;
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setReadTimeout(20000);//ms
factory.setConnectTimeout(20000);//ms
return factory;
}
private List<HttpMessageConverter<?>> getConverts() {
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
StringHttpMessageConverter stringConvert = new StringHttpMessageConverter();
List<MediaType> stringMediaTypes = new ArrayList<MediaType>() {{
add(MediaType.TEXT_PLAIN);
add(MediaType.TEXT_HTML);
add(MediaType.APPLICATION_JSON);
add(new MediaType("application", "VIID+JSON"));
}};
stringConvert.setSupportedMediaTypes(stringMediaTypes);
messageConverters.add(stringConvert);
return messageConverters;
}
}
package com.viontech.constant;
public class Gb1400Constants {
public volatile static Boolean LinkStatus= false;
}
package com.viontech.constant;
/**
* @author vion
**/
public class Gb1400UriConstants {
/** 注册 */
public static final String LOGIN = "/VIID/System/Register";
/** 保活 */
public static final String KEEPALIVE = "/VIID/System/Keepalive";
/** 校时 */
public static final String CHECKTIME = "/VIID/Time";
/** 通知 */
public static final String SUBSCRIBENOTIFICATIONS = "/VIID/SubscribeNotifications";
/** 上传设备信息(上传电子警察主机配置信息) */
public static final String TOLLGATES = "/VIID/Tollgates";
/** 上传车道信息(上传电子警察主机关联的车道配置信息) */
public static final String LANES = "/VIID/Lanes";
/** 上传机动车对象(上传过车数据(含过车图片url链接与违法图片数据)) */
public static final String MOTORVEHICLES = "/VIID/MotorVehicles";
/** 上传摄像机对象(上传电子警察主机关联的摄像机配置信息) */
public static final String APES = "/VIID/APEs";
}
\ No newline at end of file \ No newline at end of file
package com.viontech.constant;
/**
* @Author: msl
* @Description:
*/
public class RedisConstants {
/**
* 上次同步到的时间点
*/
public static final String FANXING_TO_GB1400_LASTTIME = "fanxing:to:gb1400:lasttime";
/**
* 国标1400注册auth
*/
public static final String GB1400_REGISTER_AUTH = "fanxing:to:gb1400:register:auth";
/**
* 已订阅数据的集合
*/
public static final String GB1400_SUBSCRIBES_HASH = "fanxing:to:gb1400:subscribes";
/**
* 取消订阅数据的集合
*/
public static final String GB1400_UNSUBSCRIBES_HASH = "fanxing:to:gb1400:unsubscribes";
/**
* 其他系统的注册信息集合
*/
public static final String GB1400_REGISTER_TO_MYSYSTEM_SET = "fanxing:to:gb1400:registertoour";
}
package com.viontech.constant;
import org.springframework.stereotype.Component;
@Component
public class SystemConstants {
public static final int APP_CODE_SUCCESS = 200;
public static final int APP_CODE_ERROR = 500;
//--------------------------------------------------
//交通类型
public static final String CATE_TRAFFIC = "traffic";
//事件类型
public static final String CATE_BEHAVIOR = "behavior";
//交通过车
public static final String TYPE_VEHICLE = "vehicle";
//交通非机动车
public static final String TYPE_XCYCLE = "xcycle";
//交通行人
public static final String TYPE_PEDESTRIAN = "pedestrian";
//违法类型
public static final String TYPE_ILLEGAL = "illegal";
//交通流量
public static final String TYPE_TFLOW = "tflow";
//行人流量
public static final String TYPE_PFLOW = "pflow";
//区域人流密度
public static final String TYPE_PDENSITY = "pdensity";
public static final String REDIS_KEY_EVENT_ID_SET = "eventIdSet";
}
package com.viontech.controller;
import com.alibaba.fastjson.JSONObject;
import com.viontech.constant.SystemConstants;
import com.viontech.service.Gb1400Service;
import com.viontech.utils.Gb1400ResponseUtil;
import com.viontech.utils.JsonMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/VIID")
public class Gb1400Controller {
@Resource
private Gb1400Service gb1400Service;
/**
* 批量订阅
* @param params
* @return
*/
@RequestMapping(value = "/Subscribes" ,method = RequestMethod.POST)
@ResponseBody
public JSONObject subscribes(@RequestBody String params){
log.info("收到请求[Subscribes.request]:{}", params);
JsonMessage vo = gb1400Service.subscribes(params);
log.info("响应[Subscribes.request]:{}", JSONObject.toJSONString(vo));
if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
return Gb1400ResponseUtil.responseStatusListObject((List<JSONObject>) vo.getData());
} else {
return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes");
}
}
/**
* 取消订阅
* @param ID
* @return
*/
@RequestMapping(value = "/Subscribes/{ID}" ,method = RequestMethod.PUT)
@ResponseBody
public JSONObject unSubscribes(@PathVariable String ID, @RequestBody String params){
log.info("收到请求[unSubscribes.request]:{}-{}", ID, params);
JsonMessage vo = gb1400Service.unSubscribes(ID, params);
log.info("响应[unSubscribes.request]:{}-{}", ID, JSONObject.toJSONString(vo));
if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
return Gb1400ResponseUtil.success("/VIID/Subscribes/" + ID);
} else {
return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes/" + ID);
}
}
/**
* 注册接口
* @param params
* @return
*/
@RequestMapping(value = "/System/Register" ,method = RequestMethod.POST)
@ResponseBody
public JSONObject Register(@RequestBody String params){
log.info("收到请求[Register.request]:{}", params);
JsonMessage vo = gb1400Service.registerToMySystem(params);
log.info("响应[Register.request]:{}", JSONObject.toJSONString(vo));
if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
return Gb1400ResponseUtil.success("/VIID/System/Register");
} else {
return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/System/Register");
}
}
}
package com.viontech.controller;
import com.viontech.service.TransferService;
import com.viontech.vo.FxData;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
//@RestController
//@RequestMapping("/api/v1/gb1400_recv")
public class ReceiveDataController {
@Resource
private TransferService transferService;
@PostMapping(value = "/event_data", name = "接收繁星数据")
@ResponseBody
public Object saveData(@RequestBody FxData eventData) throws Exception {
transferService.receiveData(eventData);
Map map=new HashMap();
map.put("code", "200");
map.put("note", "success");
return map;
}
}
package com.viontech.handler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Date;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import com.viontech.utils.DateUtil;
@MappedJdbcTypes({JdbcType.TIMESTAMP})
@MappedTypes({Date.class})
public class MilliDateTypeHandler extends BaseTypeHandler<String> {
@Override
public void setNonNullParameter(PreparedStatement arg0, int arg1,
String arg2, JdbcType arg3) throws SQLException {
Date time = new Date();
try {
time = DateUtil.dateFormat(arg2);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(time.getTime());
arg0.setTimestamp(arg1, sqlTimestamp);
}
@Override
public String getNullableResult(ResultSet arg0, String arg1)
throws SQLException {
// TODO Auto-generated method stub
return arg0.getString(arg1);
}
@Override
public String getNullableResult(ResultSet arg0, int arg1)
throws SQLException {
// TODO Auto-generated method stub
return arg0.getString(arg1);
}
@Override
public String getNullableResult(CallableStatement arg0, int arg1)
throws SQLException {
// TODO Auto-generated method stub
return arg0.getString(arg1);
}
}
package com.viontech.handler;
import com.alibaba.fastjson.JSONObject;
import com.viontech.constant.RedisConstants;
import com.viontech.utils.DateUtil;
import com.viontech.utils.Gb1400GenerateIDUtil;
import com.viontech.vo.gb1400.MotorVehicleObj;
import com.viontech.vo.gb1400.SubscribeNotificationsObj;
import com.viontech.vo.traffic.TrafficMongoModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import java.util.*;
@Slf4j
@Component
public class TrafficDataConvertHandler {
@Value("${fanxing.getPicInfo.url:}")
private String getPicInfoUrl;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private RestTemplate restTemplate;
@Autowired
private Gb1400GenerateIDUtil gb1400GenerateIDUtil;
@Autowired
private Properties wflxProperties;
@Autowired
private Properties csysProperties;
@Autowired
private Properties cllxProperties;
@Autowired
private Properties clppProperties;
@Autowired
private Properties hpzlProperties;
@Autowired
private Properties hpysProperties;
public SubscribeNotificationsObj trafficIllegalToSubscribeNotifications(List<TrafficMongoModel> trafficMongoModels) {
if (CollectionUtils.isEmpty(trafficMongoModels)) {
log.warn("trafficMongoModels isEmpty");
return null;
}
SubscribeNotificationsObj result = new SubscribeNotificationsObj();
SubscribeNotificationsObj.SubscribeNotificationListObject resultListObject = new SubscribeNotificationsObj.SubscribeNotificationListObject();
List<SubscribeNotificationsObj.SubscribeNotificationObject> subNotifList = new ArrayList<>();
SubscribeNotificationsObj.SubscribeNotificationObject subNotifObj = new SubscribeNotificationsObj.SubscribeNotificationObject();
JSONObject subscribeInfo = getIllegalSubscribeInfo();
if (StringUtils.isBlank(subscribeInfo.getString("SubscribeID"))) {
log.warn("未查询到订阅信息!");
return null;
}
subNotifObj.setNotificationID(gb1400GenerateIDUtil.generateNotificationID());
subNotifObj.setSubscribeID(subscribeInfo.getString("SubscribeID"));
subNotifObj.setTitle(subscribeInfo.getString("Title"));
subNotifObj.setTriggerTime(DateUtil.format(new Date(), DateUtil.DATE_TIME_FORMAT_NO_DELIMITER));
MotorVehicleObj vehicleObj = new MotorVehicleObj();
List<MotorVehicleObj.MotorVehicleObject> vehicleList = new ArrayList<>();
StringBuilder infoIds = new StringBuilder();
//设置违法数据
for (TrafficMongoModel trafficMongoModel : trafficMongoModels) {
MotorVehicleObj.MotorVehicleObject vehicle = tranferToMotorVehicleObject(trafficMongoModel);
vehicleList.add(vehicle);
if ("".equals(infoIds.toString())) {
infoIds.append(vehicle.getMotorVehicleID());
} else {
infoIds.append("," + vehicle.getMotorVehicleID());
}
}
vehicleObj.setMotorVehicleObject(vehicleList);
subNotifObj.setInfoIDs(infoIds.toString());
subNotifObj.setMotorVehicleObjectList(vehicleObj);
subNotifList.add(subNotifObj);
resultListObject.setSubscribeNotificationObjects(subNotifList);
result.setSubscribeNotificationListObject(resultListObject);
return result;
}
/**
* 转成MotorVehicleObject对象
* @param trafficMongoModel
* @return
*/
private MotorVehicleObj.MotorVehicleObject tranferToMotorVehicleObject(TrafficMongoModel trafficMongoModel) {
String passTime = "";
String picUrl = "";
String illCode = "";
String deviceID = "";
Map eventData = trafficMongoModel.getEvent_data();
List pics = trafficMongoModel.getPics();
if (eventData == null || eventData.get("device") == null || eventData.get("illegal") == null || CollectionUtils.isEmpty(pics)) {
log.warn("缺少必填数据!");
return null;
}
try {
String eventDateStr = trafficMongoModel.getEvent_dt();
Date eventDateUtc = DateUtil.parse(eventDateStr, DateUtil.TIMESTAMP_FORMAT);
passTime = DateUtil.format(DateUtil.addHours(eventDateUtc, 8), DateUtil.DATE_TIME_FORMAT_NO_DELIMITER);
//图片
Map picMap = (Map) pics.get(0);
String pic_unid = (String) picMap.get("pic_unid");
picUrl = getPicUrlByPicUnid(pic_unid);
// Map object_rect = (Map) picMap.get("object_rect");
//设备信息
Map deviceMap = (Map) eventData.get("device");
deviceID = (String) deviceMap.get("code");
//违法代码
Map illegalMap = (Map) eventData.get("illegal");
illCode = (String) illegalMap.get("code");
} catch (Exception e) {
log.error("获取必须字段异常Exception", e);
}
if (StringUtils.isBlank(picUrl) || StringUtils.isBlank(illCode) || StringUtils.isBlank(deviceID) || StringUtils.isBlank(passTime)) {
log.warn("获取必填数据失败!");
return null;
}
Integer laneNo = 1;
String hasPlate = "1";
String plateNo = "-";
String plateClass = "99";
String plateColor = "99";
String csys = "";
String cllx = "";
String clpp = "";
try {
//车道
Map laneMap = (Map) eventData.get("lane");
if (laneMap != null) {
laneNo = (Integer) laneMap.get("number");
}
//车牌
Map vehicleMap = (Map) eventData.get("vehicle");
if (vehicleMap != null) {
Map plateMap = (Map) vehicleMap.get("plate");
if (plateMap != null) {
String text = (String) plateMap.get("text");
if (StringUtils.isBlank(text) || "无牌".equals(text)) {
hasPlate = "0";
} else {
plateNo = text;
}
plateColor = hpysProperties.getProperty((String) plateMap.getOrDefault("color_code", "9"), "99");
plateClass = hpzlProperties.getProperty((String) plateMap.getOrDefault("type_code", "99"), "99");
}
//车辆信息
Map bodyMap = (Map) vehicleMap.get("body");
if (bodyMap != null) {
csys = getCsysByVehicleBody(bodyMap, "");
cllx = getCllxByVehicleBody(bodyMap, "");
clpp = getClppByVehicleBody(bodyMap, "");
}
}
} catch (Exception e) {
log.error("获取车辆信息异常", e);
}
MotorVehicleObj.MotorVehicleObject vehicle = new MotorVehicleObj.MotorVehicleObject();
//基本信息
vehicle.setInfoKind(1);
vehicle.setDeviceID(deviceID);
vehicle.setPassTime(passTime);
vehicle.setSourceID(gb1400GenerateIDUtil.generateSourceID(vehicle.getDeviceID(), "02", vehicle.getPassTime()));
vehicle.setMotorVehicleID(gb1400GenerateIDUtil.generateMotorVehicleID(vehicle.getSourceID(), "02"));
vehicle.setBreakRuleMode(wflxProperties.getProperty(illCode, illCode));
vehicle.setStorageUrl1(picUrl);
vehicle.setLeftTopX(0);
vehicle.setLeftTopY(0);
vehicle.setRightBtmX(0);
vehicle.setRightBtmY(0);
vehicle.setLaneNo(laneNo);
vehicle.setHasPlate(hasPlate);
vehicle.setPlateClass(plateClass);
vehicle.setPlateColor(plateColor);
vehicle.setPlateNo(plateNo);
// vehicle.setDirection("");
vehicle.setVehicleClass(cllx);
vehicle.setVehicleBrand(clpp);
// vehicle.setVehicleStyles("");
vehicle.setVehicleColor(csys);
return vehicle;
}
/**
* 获取图片url
* @param pic_unid
* @return
*/
private String getPicUrlByPicUnid(String pic_unid) {
String geturl = getPicInfoUrl + pic_unid;
ResponseEntity<String> responseEntity = restTemplate.getForEntity(geturl, String.class);
if (responseEntity.getStatusCodeValue() == 200) {
String picget = responseEntity.getBody();
log.info("图片服务查询响应videoget={}", picget);
if (StringUtils.isNotBlank(picget)) {
JSONObject picJson = JSONObject.parseObject(picget);
if (picJson != null && StringUtils.isNotBlank(picJson.getString("pic_url"))) {
return picJson.getString("pic_url");
}
}
} else {
log.info("error-------------图片服务查询响应失败");
}
return "";
}
/**
* 获取违法数据的订阅信息
* @return
*/
private JSONObject getIllegalSubscribeInfo() {
List<Object> values = redisTemplate.opsForHash().values(RedisConstants.GB1400_SUBSCRIBES_HASH);
if (!CollectionUtils.isEmpty(values)) {
for (Object value : values) {
String data = (String) value;
JSONObject dataObj = JSONObject.parseObject(data);
String subscribeDetail = dataObj.getString("SubscribeDetail");
if (StringUtils.isBlank(subscribeDetail)) {
continue;
}
String[] subArr = subscribeDetail.split(",");
List<String> subList = Arrays.asList(subArr);
if (subList.contains("50")) {
return dataObj;
}
}
}
return new JSONObject();
}
private String getCsysByVehicleBody(Map bodyMap, String defaultValue) {
try {
Map colorMap = (Map) bodyMap.get("color");
String csys = (String) colorMap.getOrDefault("code", "Z");
return csysProperties.getProperty(csys, defaultValue);
} catch (Exception e) {
log.error("getCsysByVehicleBody.Exception:{}", e.getMessage());
}
return defaultValue;
}
private String getCllxByVehicleBody(Map bodyMap, String defaultValue) {
try {
Map typeMap = (Map) bodyMap.get("type");
String cllx = (String) typeMap.getOrDefault("code", defaultValue);
return cllxProperties.getProperty(cllx, defaultValue);
} catch (Exception e) {
log.error("getCllxByVehicleBody.Exception:{}", e.getMessage());
}
return defaultValue;
}
private String getClppByVehicleBody(Map bodyMap, String defaultValue) {
try {
Map logoMap= (Map) bodyMap.get("logo");
String clpp = (String) logoMap.getOrDefault("code", defaultValue);
return clppProperties.getProperty(clpp, defaultValue);
} catch (Exception e) {
log.error("getClppByVehicleBody.Exception:{}", e.getMessage());
}
return defaultValue;
}
public static void main(String[] args) {
Integer laneNo = 1;
String xxx = "";
Map eventData = new HashMap();
Map laneMap = new HashMap();
laneNo = (Integer) laneMap.get("number");
xxx = (String) laneMap.getOrDefault("xxx", "99");
System.out.println(laneNo);
}
}
package com.viontech.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author vion
**/
public class Gb1400AuthInterceptor implements HandlerInterceptor {
private Logger log = LoggerFactory.getLogger(Gb1400AuthInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//拦截国标1400相关接口
String servletPath = request.getServletPath();
if(!servletPath.contains("/VIID/System/Register")){
return true;
}
String authorization = request.getHeader("Authorization");
if(StringUtils.isEmpty(authorization)){
response.addHeader("WWW-Authenticate","Digest realm=\"viid\",qop=\"auth\",nonce=\"123456\",opaque=\"654321\"");
response.setStatus(HttpStatus.UNAUTHORIZED.value());
return false;
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
\ No newline at end of file \ No newline at end of file
package com.viontech.mapper;
import com.viontech.vo.traffic.TrafficModel;
import java.util.List;
public interface TrafficEventMapper {
List<Object> selectJsonDatas(TrafficModel trafficModel);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.viontech.mapper.TrafficEventMapper">
<!-- fetchSize="5000" -->
<select id="selectJsonDatas" parameterType="com.viontech.vo.traffic.TrafficModel"
resultType="java.lang.String" fetchSize="5000">
<!-- select json_data from tb_traffic-->
select json_data
<!--||(select '{"unid":"'||unid||'"}' from tb_traffic as t1 where t1.unid=t2.unid )::jsonb as json_data -->
from tb_traffic as t2
<where>
<!-- <if test="event_type != null and (event_type == 'pedestrian' or event_type == 'xcycle')">-->
<if test="(sex != null and sex != '') or (upbody_color != null and upbody_color != '') or (lobody_color != null and lobody_color != '')">
and unid in(
select tb_face.traffic_unid
from tb_face where 1 = 1
<if test="sex != null and sex != ''">
and tb_face.sex = #{sex}
</if>
<if test="upbody_color != null and upbody_color != ''">
and tb_face.upbody_color = #{upbody_color}
</if>
<if test="lobody_color != null and lobody_color != ''">
and tb_face.lobody_color = #{lobody_color}
</if>)
</if>
<if test="subtaskIds != null and subtaskIds != ''">
and EXISTS(select 1
from (values
${subtaskIds}
) as tt(ids)
where tt.ids = tb_traffic.subtask_id)
</if>
<if test="event_type != null and event_type != ''">
and event_type = #{event_type}
</if>
<if test="with_hats != null">
and with_hats = #{with_hats}
</if>
<if test="event_types != null">
and event_type in
<foreach item="item" index="index" collection="event_types"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="task_id != null and task_id != ''">
and task_id = #{task_id}
</if>
<if test="subtask_id != null and subtask_id != ''">
and subtask_id = #{subtask_id}
</if>
<if test="plate_text != null and plate_text != ''">
and plate_text like '%' || #{plate_text} || '%'
</if>
<if test="task_type != null and task_type != ''">
and task_type = #{task_type}
</if>
<if test="dev_unid != null and dev_unid != ''">
and dev_unid = #{dev_unid}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and vchan_refid = #{vchan_refid}
</if>
<if test="xcycle_type != null and xcycle_type != ''">
and xcycle_type = #{xcycle_type}
</if>
<if test="vchan_duid != null and vchan_duid != ''">
and vchan_duid = #{vchan_duid}
</if>
<if test="plate_color_code != null and plate_color_code != ''">
and plate_color_code = #{plate_color_code}
</if>
<if test="location_code != null and location_code != ''">
and location_code = #{location_code}
</if>
<if test="lane_code != null and lane_code != ''">
and lane_code = #{lane_code}
</if>
<if test="direction_code != null and direction_code != ''">
and direction_code = #{direction_code}
</if>
<if test="location_name != null and location_name != ''">
and location_name = #{location_name}
</if>
<if test="body_type_code != null">
and body_type_code = #{body_type_code}
</if>
<if test="body_type_codes != null">
and body_type_code in
<foreach item="item" index="index" collection="body_type_codes"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="device_name != null and device_name != ''">
and device_name like '%' || #{device_name} || '%'
</if>
<if test="illegal_code != null and illegal_code != ''">
and illegal_code = #{illegal_code}
</if>
<if test="illegal_codes != null">
and illegal_code in
<foreach item="item" index="index" collection="illegal_codes"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="illegal_state != null">
and illegal_state = #{illegal_state}
</if>
<if test="body_color_code != null and body_color_code != ''">
and body_color_code = #{body_color_code}
</if>
<if test="body_logo_code != null and body_logo_code != ''">
and body_logo_code = #{body_logo_code}
</if>
<if test="refinedFeature_rAnnualInspection != null">
and "refinedFeature_rAnnualInspection" = #{refinedFeature_rAnnualInspection}
</if>
<if test="refinedFeature_rDecoration != null">
and "refinedFeature_rDecoration" = #{refinedFeature_rDecoration}
</if>
<if test="refinedFeature_rPendant != null">
and "refinedFeature_rPendant" = #{refinedFeature_rPendant}
</if>
<if test="refinedFeature_rSunshading != null">
and "refinedFeature_rSunshading" = #{refinedFeature_rSunshading}
</if>
<if test="company != null">
and "company" = #{company}
</if>
and is_active = 'true'
<if test="special_type != null and special_type != ''">
and special_type = #{special_type}
</if>
<if test="event_dt__gte != null and event_dt__gte != ''">
and shoot_dt > #{event_dt__gte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime >= #{event_dt__gte}-->
</if>
<if test="event_dt__lt != null and event_dt__lt != ''">
and shoot_dt <![CDATA[<=]]> #{event_dt__lt,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime <![CDATA[<]]> #{event_dt__lt}-->
</if>
</where>
order by shoot_dt asc
<if test="limit != null and offset != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
package com.viontech.runner;
import com.alibaba.fastjson.JSONObject;
import com.viontech.config.Gb1400Config;
import com.viontech.constant.RedisConstants;
import com.viontech.service.Gb1400Service;
import com.viontech.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* @author vion
**/
@Component
@Slf4j
public class Gb1400RegisterRunner implements CommandLineRunner {
@Autowired
private Gb1400Config gb1400Config;
@Resource
private Gb1400Service gb1400Service;
@Override
public void run(String... args) {
if("1".equals(gb1400Config.getEnable()) && !StringUtils.isEmpty(gb1400Config.getUserIdentify())){
log.info("准备注册平台");
new Thread(new Runnable() {
@Override
public void run() {
gb1400Service.register(gb1400Config.getUserIdentify());
}
}).start();
}
}
public static void main(String[] args) {
String body = "{\"ResponseStatusObject\":{\"RequestURL\":\"/VIID/System/Keepalive\",\"StatusCode\":0,\"StatusString\":\"保活成功\",\"Id\":\"41011000005038163699\",\"LocalTime\":\"20220422105631\"}}";
JSONObject registerResult = JSONObject.parseObject(body);
System.out.println("x");
}
}
\ No newline at end of file \ No newline at end of file
package com.viontech.scheduled;
import com.viontech.config.Gb1400Config;
import com.viontech.constant.Gb1400Constants;
import com.viontech.service.Gb1400Service;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
@Slf4j
@Component
public class Gb1400KeepAlive {
@Autowired
private Gb1400Config gb1400Config;
@Autowired
private RestTemplate restTemplate;
@Resource
private Gb1400Service gb1400Service;
private String registerLock = new String("REGISTERLOCK");
@Scheduled(cron = "10 * * * * ?")
public void keepalive() {
if("0".equals(gb1400Config.getEnable())){
return;
}
if (!Gb1400Constants.LinkStatus) {
return;
}
//保活
String lkh = gb1400Config.getUserIdentify();
if(StringUtils.isBlank(lkh)){
return;
}
try{
HttpHeaders headers = new HttpHeaders();
headers.add("User-Identify",lkh);
headers.add("Content-Type","application/VIID+JSON;charset=utf-8");
// String currentTime = DateUtil.getCurrentTime(DateUtil.TIMESTAMP_NO_DELIMITER);
// headers.add("User-SendTime", currentTime);
// String content = "{\"DeviceID\":\""+lkh+"\"}";
String content = "{\"KeepaliveObject\":{\"DeviceID\":\""+lkh+"\"}}";
HttpEntity<String> entity = new HttpEntity<>(content, headers);
String url = "http://"+gb1400Config.getIpPort()+"/VIID/System/Keepalive";
ResponseEntity<String> postForEntity = restTemplate.postForEntity(url, entity, String.class);
String body = postForEntity.getBody();
log.info("keepalive.result:{}", body);
}catch (Exception e){
log.error("keepalive.Exception",e);
}
}
@Scheduled(cron = "0/30 * * * * ? ")
public void register() throws Exception{
if("0".equals(gb1400Config.getEnable())){
return;
}
synchronized (registerLock) {
if(!Gb1400Constants.LinkStatus) {
gb1400Service.register(gb1400Config.getUserIdentify());
} else {
return;
}
}
}
}
package com.viontech.scheduled;
import com.viontech.constant.Gb1400Constants;
import com.viontech.constant.RedisConstants;
import com.viontech.constant.SystemConstants;
import com.viontech.handler.TrafficDataConvertHandler;
import com.viontech.service.Gb1400Service;
import com.viontech.service.TrafficEventService;
import com.viontech.utils.DateUtil;
import com.viontech.utils.JavaBean2Json;
import com.viontech.utils.JsonMessage;
import com.viontech.vo.gb1400.SubscribeNotificationsObj;
import com.viontech.vo.traffic.TrafficModel;
import com.viontech.vo.traffic.TrafficMongoModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Component
public class TrafficIllegalScheduled {
@Resource
private TrafficEventService trafficEventService;
@Resource
private Gb1400Service gb1400Service;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private TrafficDataConvertHandler trafficDataConvertHandler;
@Scheduled(cron = "0/5 * * * * ?")
public void handleIllegal() {
log.info("开始处理违法数据");
if (!Gb1400Constants.LinkStatus) {
return;
}
Object o = redisTemplate.opsForValue().get(RedisConstants.FANXING_TO_GB1400_LASTTIME);
//上次对接到的违法记录时间
String lastTimeUtc = "";
if (o == null) {
//查询一小时前的数据,-1,-8:转UTC时间,总-9
lastTimeUtc = DateUtil.formatDate(DateUtil.addHours(new Date(), -9), DateUtil.TIMESTAMP_FORMAT);
} else {
lastTimeUtc = (String) o;
}
String currentTimeUtc = DateUtil.formatDate(DateUtil.addHours(new Date(), -8), DateUtil.TIMESTAMP_FORMAT);
if (StringUtils.isBlank(lastTimeUtc) || StringUtils.isBlank(currentTimeUtc)) {
log.warn("lastTimeUtc or currentTimeUtc isBlank");
return;
}
int offset = 0;
int limit = 10;
//utc时间,当前时间减8小时
String event_dt__gte = lastTimeUtc;
String event_dt__lt = currentTimeUtc;
TrafficModel trafficQry = new TrafficModel();
trafficQry.setEvent_cate("traffic");
trafficQry.setEvent_type("vehicle");
trafficQry.setIllegal_state("true");
trafficQry.setEvent_dt__gte(event_dt__gte);
trafficQry.setEvent_dt__lt(event_dt__lt);
trafficQry.setLimit(limit);
trafficQry.setOffset(offset);
List<Object> trafficModels = trafficEventService.selectJsonDatas(trafficQry);
log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次待同步数据总{}条。", lastTimeUtc, currentTimeUtc, trafficModels.size());
if (!CollectionUtils.isEmpty(trafficModels)) {
List<TrafficMongoModel> trafficMongoModels = new ArrayList<>();
for (Object model : trafficModels) {
trafficMongoModels.add(JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(model), TrafficMongoModel.class));
}
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.trafficIllegalToSubscribeNotifications(trafficMongoModels);
//将违法数据同步gb1400
if (subscribeNotificationsObj != null) {
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj);
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_LASTTIME, trafficMongoModels.get(trafficMongoModels.size() - 1).getEvent_dt());
}
} else {
log.error("trafficDataConvertHandler.trafficIllegalToSubscribeNotifications is null");
}
}
log.info("结束处理违法数据");
}
}
package com.viontech.service;
import com.viontech.utils.JsonMessage;
import com.viontech.vo.gb1400.SubscribeNotificationsObj;
public interface Gb1400Service {
JsonMessage registerToMySystem(String params);
void register(String userIdentify);
JsonMessage subscribes(String params);
JsonMessage unSubscribes(String subscribeId, String params);
JsonMessage subscribeNotifications(SubscribeNotificationsObj subscribeNotificationsObj);
}
package com.viontech.service;
import com.viontech.vo.traffic.TrafficModel;
import java.util.List;
public interface TrafficEventService {
List<Object> selectJsonDatas(TrafficModel trafficModel);
}
package com.viontech.service;
import com.viontech.vo.FxData;
public interface TransferService {
void receiveData(FxData fxdata);
}
package com.viontech.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.config.Gb1400Config;
import com.viontech.config.Gb1400RestTemplate;
import com.viontech.constant.Gb1400Constants;
import com.viontech.constant.Gb1400UriConstants;
import com.viontech.constant.RedisConstants;
import com.viontech.service.Gb1400Service;
import com.viontech.utils.DateUtil;
import com.viontech.utils.Gb1400ResponseUtil;
import com.viontech.utils.JsonMessage;
import com.viontech.utils.JsonMessageUtil;
import com.viontech.vo.gb1400.MotorVehicleObj;
import com.viontech.vo.gb1400.SubscribeNotificationsObj;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.DigestUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service
public class Gb1400ServiceImpl implements Gb1400Service {
@Autowired
private Gb1400Config gb1400Config;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private RestTemplate restTemplate;
@Autowired
private Gb1400RestTemplate gb1400RestTemplate;
@Override
public JsonMessage registerToMySystem(String params) {
JSONObject registerJson = JSONObject.parseObject(params);
JSONObject registerObject = registerJson.getJSONObject("RegisterObject");
String deviceID = registerObject.getString("DeviceID");
redisTemplate.opsForSet().add(RedisConstants.GB1400_REGISTER_TO_MYSYSTEM_SET, deviceID);
return JsonMessageUtil.getSuccessJsonMsg("success");
}
@Override
public void register(String userIdentify) {
registerHttp(userIdentify);
}
@Override
public JsonMessage subscribes(String params) {
if (StringUtils.isBlank(params)) {
return JsonMessageUtil.getErrorJsonMsg("订阅对象不能为空!");
}
//单个订阅
/*try {
JSONObject paramObj = JSONObject.parseObject(params);
if (paramObj == null) {
return JsonMessageUtil.getErrorJsonMsg("订阅对象不能为空!");
}
if (StringUtils.isBlank(paramObj.getString("SubscribeID"))) {
return JsonMessageUtil.getErrorJsonMsg("SubscribeID不能为空!");
}
if (!"50".equals(paramObj.getString("SubscribeDetail"))) {
return JsonMessageUtil.getErrorJsonMsg("订阅类别暂不支持!");
}
String subscribeId = paramObj.getString("SubscribeID");
redisTemplate.opsForHash().put(RedisConstants.GB1400_SUBSCRIBES_HASH, subscribeId, params);
} catch (Exception e) {
log.error("subscribes.Exception", e);
return JsonMessageUtil.getErrorJsonMsg(e.getMessage());
}*/
List<JSONObject> list = new ArrayList<>();
//批量订阅
try {
JSONObject paramObj = JSONObject.parseObject(params);
if (paramObj == null) {
return JsonMessageUtil.getErrorJsonMsg("订阅对象不能为空!");
}
JSONObject subscribeList = paramObj.getJSONObject("SubscribeListObject");
if (subscribeList == null) {
return JsonMessageUtil.getErrorJsonMsg("订阅对象不能为空!");
}
JSONArray objArr = subscribeList.getJSONArray("SubscribeObject");
if (objArr == null || objArr.size() <= 0) {
return JsonMessageUtil.getErrorJsonMsg("订阅对象不能为空!");
}
for (int i = 0; i < objArr.size(); i++) {
JSONObject item = (JSONObject) objArr.get(i);
if (item == null || StringUtils.isBlank(item.getString("SubscribeID"))) {
list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "SubscribeID不能为空"));
continue;
}
if (!"50".equals(item.getString("SubscribeDetail"))) {
list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "订阅类别暂不支持"));
continue;
}
String subscribeId = item.getString("SubscribeID");
// String subscribeDetail = item.getString("SubscribeDetail");
redisTemplate.opsForHash().put(RedisConstants.GB1400_SUBSCRIBES_HASH, subscribeId, item.toJSONString());
list.add(Gb1400ResponseUtil.buildResponseStatusObject(subscribeId, "/VIID/Subscribes", 0, "成功"));
}
} catch (Exception e) {
if (CollectionUtils.isEmpty(list)) {
list.add(Gb1400ResponseUtil.buildResponseStatusObject(null, "/VIID/Subscribes", 1, "异常:"+e.getMessage()));
}
log.error("subscribes.Exception", e);
}
return JsonMessageUtil.getSuccessJsonMsg(list);
}
@Override
public JsonMessage unSubscribes(String subscribeId, String params) {
if (StringUtils.isBlank(subscribeId)) {
return JsonMessageUtil.getErrorJsonMsg("SubscribeID不能为空!");
}
try {
synchronized (this) {
if (!redisTemplate.opsForHash().hasKey(RedisConstants.GB1400_SUBSCRIBES_HASH, subscribeId)) {
return JsonMessageUtil.getErrorJsonMsg("SubscribeID不存在无需取消订阅!");
}
redisTemplate.opsForHash().delete(RedisConstants.GB1400_SUBSCRIBES_HASH, subscribeId);
redisTemplate.opsForHash().put(RedisConstants.GB1400_UNSUBSCRIBES_HASH, subscribeId, params);
}
} catch (Exception e) {
log.error("unSubscribes.Exception", e);
return JsonMessageUtil.getErrorJsonMsg(e.getMessage());
}
return JsonMessageUtil.getSuccessJsonMsg("success");
}
@Override
public JsonMessage subscribeNotifications(SubscribeNotificationsObj subscribeNotificationsObj) {
if (subscribeNotificationsObj == null) {
return JsonMessageUtil.getErrorJsonMsg("SubscribeNotificationsObj不能为空!");
}
String notificationsData = JSONObject.toJSONString(subscribeNotificationsObj);
String sendResult = gb1400RestTemplate.doPost(gb1400Config.getUserIdentify(), Gb1400UriConstants.SUBSCRIBENOTIFICATIONS, notificationsData);
return JsonMessageUtil.getSuccessJsonMsg("success", sendResult);
}
private String getRedisAuth(){
Object auth = redisTemplate.opsForHash().get(RedisConstants.GB1400_REGISTER_AUTH, gb1400Config.getIpPort());
return auth == null ? null : String.valueOf(auth);
}
private void registerHttp(String lkh) {
try {
HttpHeaders headers = new HttpHeaders();
headers.add("User-Identify", lkh);
headers.add("Content-Type", "application/VIID+JSON;charset=utf-8");
String redisAuth = getRedisAuth();
if (!org.springframework.util.StringUtils.isEmpty(redisAuth)) {
headers.add("Authorization", redisAuth);
}
// String currentTime = DateUtil.getCurrentTime(DateUtil.TIMESTAMP_NO_DELIMITER);
// headers.add("User-SendTime", currentTime);
// String content = "{\"DeviceID\":\""+lkh+"\"}";
String content = "{\"RegisterObject\":{\"DeviceID\":\""+lkh+"\"}}";
HttpEntity<String> entity = new HttpEntity<>(content, headers);
String url = "http://"+gb1400Config.getIpPort()+"/VIID/System/Register";
ResponseEntity<String> postForEntity = restTemplate.postForEntity(url, entity, String.class);
String body = postForEntity.getBody();
log.info("register.result[{}]:{}", lkh, body);
//{"ResponseStatusObject":{"RequestURL":"/VIID/System/Register","StatusCode":0,"StatusString":null,"Id":null,"LocalTime":"20210202170607"}}
JSONObject registerResult = JSONObject.parseObject(body);
if (registerResult != null && registerResult.getJSONObject("ResponseStatusObject") != null) {
JSONObject responseStatusObject = registerResult.getJSONObject("ResponseStatusObject");
if (!"0".equals(responseStatusObject.getString("StatusCode"))) {
try {
TimeUnit.SECONDS.sleep(60);
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
redisTemplate.opsForHash().delete(RedisConstants.GB1400_REGISTER_AUTH, gb1400Config.getIpPort());
registerHttp(lkh);
} else {
Gb1400Constants.LinkStatus = true;
}
} else {
try {
TimeUnit.SECONDS.sleep(60);
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
redisTemplate.opsForHash().delete(RedisConstants.GB1400_REGISTER_AUTH, gb1400Config.getIpPort());
registerHttp(lkh);
}
} catch (HttpClientErrorException e) {
int rawStatusCode = e.getRawStatusCode();
if (rawStatusCode == 401) {
HttpHeaders responseHeaders = e.getResponseHeaders();
if (responseHeaders == null) {
throw new RuntimeException("1400 register 401 error,", e);
}
log.info("register.responseHeaders={}", JSONObject.toJSONString(responseHeaders));
List<String> strings = responseHeaders.get("WWW-Authenticate");
String auth = "";
if (strings == null || strings.size() == 0 || org.springframework.util.StringUtils.isEmpty(strings.get(0))) {
throw new RuntimeException("1400 register 401 error,", e);
} else {
auth = strings.get(0);
log.info("401auth:" + auth);
String authStr = getAuth(auth);
redisTemplate.opsForHash().put(RedisConstants.GB1400_REGISTER_AUTH, gb1400Config.getIpPort(), authStr);
registerHttp(lkh);
}
} else {
log.error("register.HttpClientErrorException", e);
try {
TimeUnit.SECONDS.sleep(60);
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
registerHttp(lkh);
}
} catch (Exception e){
log.error("register.Exception",e);
try {
TimeUnit.SECONDS.sleep(60);
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
registerHttp(lkh);
}
}
private String getAuth(String digest) {
String substring = "{" + digest.substring(7) + "}";
String s = substring.trim().replaceAll("=", ":");
JSONObject digestJson = JSONObject.parseObject(s);
String qop = digestJson.getString("qop");
String opaque = digestJson.getString("opaque");
String realm = digestJson.getString("realm");
String nonce = digestJson.getString("nonce");
String cnonce = UUID.randomUUID().toString().replaceAll("-", "");
//HA1=MD5(username:realm:password)
String HA1 = DigestUtils.md5DigestAsHex((gb1400Config.getUsername()+":" + realm + ":"+gb1400Config.getPassword()).getBytes());
//HA2=MD5(method:uri) and toHex
String HA2 = DigestUtils.md5DigestAsHex(("POST:/VIID/System/Register").getBytes());
//HD=nonce:noncecount:cnonce:qop
String HD = nonce + ":00000001:" + cnonce + ":" + qop;
//response=MD5(HA1:HD:HA2)
String response = DigestUtils.md5DigestAsHex((HA1 + ":" + HD + ":" + HA2).getBytes());
StringBuilder sb = new StringBuilder("Digest username=\"");
sb.append(gb1400Config.getUsername()).append("\",realm=\"").append(realm).append("\", nonce=\"").append(nonce)
.append("\", uri=\"/VIID/System/Register\", response=\"").append(response)
.append("\", opaque=\"").append(opaque).append("\", qop=\"").append(qop)
.append("\", nc=00000001, cnonce=\"").append(cnonce).append("\"");
return sb.toString();
}
public static void main(String[] args) {
SubscribeNotificationsObj subscribeNotificationsObj = new SubscribeNotificationsObj();
SubscribeNotificationsObj.SubscribeNotificationListObject subscribeNotificationListObject = new SubscribeNotificationsObj.SubscribeNotificationListObject();
List<SubscribeNotificationsObj.SubscribeNotificationObject> subscribeNotificationObjects = new ArrayList<>();
SubscribeNotificationsObj.SubscribeNotificationObject obj1 = new SubscribeNotificationsObj.SubscribeNotificationObject();
obj1.setTitle("测试tile");
obj1.setNotificationID("123456");
obj1.setSubscribeID("789");
MotorVehicleObj motorVehicleObjectList = new MotorVehicleObj();
List<MotorVehicleObj.MotorVehicleObject> motorVehicleList = new ArrayList<>();
MotorVehicleObj.MotorVehicleObject motorVehicle = new MotorVehicleObj.MotorVehicleObject();
motorVehicle.setDeviceID("ididi123");
motorVehicle.setLaneNo(2);
motorVehicle.setBreakRuleMode("17170");
motorVehicleList.add(motorVehicle);
MotorVehicleObj.MotorVehicleObject motorVehicle2 = new MotorVehicleObj.MotorVehicleObject();
motorVehicle2.setDeviceID("nsl123");
motorVehicle2.setLaneNo(1);
motorVehicleList.add(motorVehicle2);
motorVehicleObjectList.setMotorVehicleObject(motorVehicleList);
obj1.setMotorVehicleObjectList(motorVehicleObjectList);
subscribeNotificationObjects.add(obj1);
subscribeNotificationListObject.setSubscribeNotificationObjects(subscribeNotificationObjects);
subscribeNotificationsObj.setSubscribeNotificationListObject(subscribeNotificationListObject);
log.info(JSONObject.toJSONString(subscribeNotificationsObj));
}
}
package com.viontech.service.impl;
import com.viontech.mapper.TrafficEventMapper;
import com.viontech.service.TrafficEventService;
import com.viontech.vo.traffic.TrafficModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class TrafficEventServiceImpl implements TrafficEventService {
@Autowired
private TrafficEventMapper trafficEventMapper;
@Override
public List<Object> selectJsonDatas(TrafficModel trafficModel) {
return trafficEventMapper.selectJsonDatas(trafficModel);
}
}
package com.viontech.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.viontech.constant.SystemConstants;
import com.viontech.service.TransferService;
import com.viontech.vo.FxData;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service
public class TransferServiceImpl implements TransferService {
private final ThreadPoolExecutor recvDataTaskAsyncPool = new ThreadPoolExecutor(5, 10, 8l, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadPoolExecutor.CallerRunsPolicy());
@Override
public void receiveData(FxData fxdata) {
try {
String event_cate = fxdata.getEvent_cate();
if (!event_cate.equals(SystemConstants.CATE_TRAFFIC)) {
log.warn("event_cate与traffic不匹配,跳过");
return;
}
String event_type = fxdata.getEvent_type();
if (StringUtils.isBlank(event_type)) {
log.warn("event_type为空,跳过");
return;
}
recvDataTaskAsyncPool.submit(new Runnable() {
@Override
public void run() {
switch (event_cate) {
case SystemConstants.CATE_TRAFFIC:
switch (event_type) {
case SystemConstants.TYPE_VEHICLE:
String ID = fxdata.getEvent_data().getID();
String startDt = fxdata.getEvent_data().getStart_dt();
String endDt = fxdata.getEvent_data().getEnd_dt();
String deviceCode = fxdata.getEvent_data().getDevice().getCode();
String vchanRefid = fxdata.getVchan_refid();
Map vehicle = JSONObject.parseObject(JSONObject.toJSONString(fxdata.getEvent_data().getVehicle()), Map.class);
Map illegal = JSONObject.parseObject(JSONObject.toJSONString(fxdata.getEvent_data().getIllegal()), Map.class);
String state = (String) illegal.get("state");
String base64 = fxdata.getPics().get(0).getPic_base64();
Map lane = JSONObject.parseObject(JSONObject.toJSONString(fxdata.getEvent_data().getLane()), Map.class);
try {
if ("1".equals(state)) {
// iilleProcessor.addIill(ID, startDt, endDt, deviceCode, vchanRefid, vehicle, illegal, base64);
} else {
return;
}
} catch (Exception e) {
log.error("handle.Exception", e);
}
break;
default:
log.warn("event_type类型无法判断:{},跳过处理", event_type);
break;
}
break;
default:
log.warn("event_cate类型无法判断:{}跳过处理", event_cate);
break;
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
fxdata.setPics(null);
}
}
package com.viontech.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class DateUtil extends DateUtils {
private static final String[] weekDays = {"(周日)", "(周一)", "(周二)", "(周三)", "(周四)", "(周五)", "(周六)"};
private final static Logger logger = LoggerFactory.getLogger(DateUtil.class);
private DateUtil() {
throw new IllegalStateException("请勿实例化工具类");
}
private static ThreadLocal<Map<String, SimpleDateFormat>> local = new ThreadLocal<>();
public static final String DATE_FORMAT = "yyyy-MM-dd";
public static final String DATE_MONTH_FORMAT = "yyyy-MM";
public static final String DATE_FORMAT_NO_DELIMITER = "yyyyMMdd";
public static final String TIME_FORMAT = "HH:mm:ss";
public static final String TIME_FORMAT_NO_SEC = "HH:mm";
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public static final String DATE_TIME_FORMAT_NO_SEC = "yyyy-MM-dd HH:mm";
public static final String DATE_TIME_FORMAT_NO_DELIMITER = "yyyyMMddHHmmss";
public static final String TIMESTAMP_NO_DELIMITER = "yyyyMMddHHmmssSSS";
public static final String DATE_PRECISE_TO_MINUTE = "yyyyMMddHHmm";
public static final String[] WEEKS = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
public static final String[] DEFAULT_FORMATS = {TIMESTAMP_FORMAT, DATE_TIME_FORMAT, DATE_FORMAT, TIME_FORMAT, DATE_PRECISE_TO_MINUTE};
public static final String DAY_BEGIN_TIME = " 00:00:00";
public static final String DAY_END_TIME = " 23:59:59";
/**
* 精确到毫秒的完整UTC时间 如:2017-07-04T15:50:18.223
*/
public static SimpleDateFormat FORMAT_YYYY_MM_DD_HH_MM_SS_S_UTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
/**
* 精确到毫秒的完整时间 如:2010-12-01 23:15:06.999
*/
public static SimpleDateFormat FORMAT_YYYY_MM_DD_HH_MM_SS_S = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
/**
* 英文全称 如:2010-12-01 23:15:06
*/
public static SimpleDateFormat FORMAT_YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 英文全称 如:2010-12-01 23:15
*/
public static SimpleDateFormat FORMAT_YYYY_MM_DD_HH_MM = new SimpleDateFormat("yyyy-MM-dd HH:mm");
/**
* 英文简写(默认)如:2010-12-01
*/
public static SimpleDateFormat FORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
private static SimpleDateFormat getDateFormat(String format) {
Map<String, SimpleDateFormat> map = local.get();
if (map == null) {
map = new HashMap<>();
local.set(map);
}
SimpleDateFormat sdf = map.get(format);
if (sdf == null) {
sdf = new SimpleDateFormat(format);
map.put(format, sdf);
}
return sdf;
}
private static SimpleDateFormat getDateFormatDefault() {
return getDateFormat(DATE_TIME_FORMAT);
}
private static SimpleDateFormat getDateFormatDate() {
return getDateFormat(DATE_FORMAT);
}
private static SimpleDateFormat getDateFormatTime() {
return getDateFormat(TIME_FORMAT);
}
/**
* 自动判断日期字符串的格式,返回Date对象
*
* @param dateString 日期字符串
* @param dateFormat 格式字符串数组。为空时使用<code>DateUtil.DEFAULT_FORMATS</code>
* @return 日期Date对象
* @throws ParseException
* @see DateUtils#parseDate
*/
public static Date parse(String dateString, String... dateFormat) throws ParseException {
if (StringUtils.isEmpty(dateString)) {
return null;
}
if (dateFormat == null || dateFormat.length == 0) {
return DateUtils.parseDate(dateString, DEFAULT_FORMATS);
} else {
return DateUtils.parseDate(dateString, dateFormat);
}
}
/**
* 取指定格式的当前时间字符串
*
* @param dateFormat
* @return
*/
public static String getCurrentTime(String dateFormat) {
Date date = new Date();
return format(date, dateFormat);
}
/**
* 将字符串转换成Date类型
*
* @param dateString
* @param dateFormat
* @return
*/
public static Date parse(String dateString, String dateFormat) {
if (StringUtils.isEmpty(dateString)) {
return null;
}
try {
return DateUtils.parseDate(dateString, dateFormat);
} catch (ParseException e) {
logger.error("日期格式化异常", e);
return null;
}
}
/**
* 将Date类型转化成字符串
*
* @param date
* @param dateFormat
* @return
*/
public static String format(Date date, String dateFormat) {
if (date == null) {
return "";
} else {
return DateFormatUtils.format(date, dateFormat);
}
}
/**
* 在传入的日期基础上往后加n天
*
* @param date
* @param n 要加的天数
* @return
*/
public static Date addDay(Date date, int n) {
return DateUtils.addDays(date, n);
}
/**
* 在传入的日期基础上往后加n天
*
* @param dateStr
* @param n 要加的天数
* @return
*/
public static String addDay(String dateStr, String dateFormat, int n) {
if (StringUtils.isBlank(dateStr) || StringUtils.isBlank(dateFormat)) {
return "";
}
Date date = parse(dateStr, dateFormat);
Date newDate = addDay(date, n);
return format(newDate, dateFormat);
}
/**
* 判断当前时间是否在开始时间与结束时间之间
*
* @param time 当前时间
* @param begin 开始时间
* @param end 结束时间
* @return boolen类型,true表示在两者间,false表示不在两者之间
*/
public static boolean isTimeIn(Date time, Date begin, Date end) {
return time.getTime() >= begin.getTime() && time.getTime() <= end.getTime();
}
/**
* 判断当前时间是否在开始时间与结束时间之间
*
* @param time 当前时间
* @param begin 开始时间
* @param end 结束时间
* @return boolen类型,true表示在两者间,false表示不在两者之间(time和end相同时,为false)
*/
public static boolean isTimeIn1(Date time, Date begin, Date end) {
return time.getTime() >= begin.getTime() && time.getTime() < end.getTime();
}
/**
* 判断指定日期是星期几
*
* @param time 要判断的日期
* @param format 输入的日期格式
* @return 返回数字[1:星期一,2:星期二,....,7:星期日]
* @throws ParseException
*/
public static int getWeek(String time, String format) throws ParseException {
return getWeek(DateUtils.parseDate(time, format));
}
/**
* 判断指定日期是星期几
*
* @param date 要判断的日期
* @return 返回数字[1:星期一,2:星期二,....,7:星期日]
* @throws ParseException
*/
public static int getWeek(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int week = 0;
if (c.get(Calendar.DAY_OF_WEEK) == 1) {
week = 7;
} else {
week = c.get(Calendar.DAY_OF_WEEK) - 1;
}
return week;
}
/**
* 获取一年的第几周,默认周一是第一天(按中国习惯)
*
* @param date -
* @param isInternational - 是否国际化,true:周日为第一天,false:周一为第一天,即周日会比国际通用的weekofyear值少1
* @return -
*/
public static int getWeekOfYear(Date date, Boolean isInternational) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int i = c.get(Calendar.WEEK_OF_YEAR);
int week = getWeek(date);
if (isInternational != null && !isInternational && week == 7) {
i = i - 1;
}
return i;
}
/**
* 获取一年的第几周
*
* @param time -
* @param format -
* @param isInternational - 是否国际化,true:周日为第一天,false:周一为第一天
* @return -
*/
public static int getWeekOfYear(String time, String format, Boolean isInternational) {
return getWeekOfYear(parse(time, format), isInternational);
}
/**
* 判断是否为有效的身份证日期
*
* @param date
* @return
*/
public static boolean isIdDate(String date) {
return isDateFormat(date, "yyyyMMdd");
}
/**
* 判断传入的字符串dateStr是否是日期格式patternStr的字符串 @author yejg
*
* @param dateStr
* @param patternStr
* @return
*/
public static boolean isDateFormat(String dateStr, String patternStr) {
Date date = null;
try {
date = parse(dateStr, patternStr);
} catch (Exception e) {
}
return date == null ? false : true;
}
/**
* 将字符串日期转成Timestamp类型
*
* @param dateString 字符串类型的时间
* @param format 字符串类型的时间要转换的格式
* @return Timestamp类型的时间戳
* @throws ParseException
*/
public static java.sql.Timestamp parse2Timestamp(String dateString, String format) throws ParseException {
return new java.sql.Timestamp(DateUtils.parseDate(dateString, format).getTime());
}
/**
* 获取两个时间的间隔,字符串表示
*
* @param start
* @param end
* @return
* @author huadi
*/
public static String getDiffTimeStr(Date start, Date end) {
String time = "";
if (start != null && end != null) {
int t = (int) (end.getTime() - start.getTime()) / 1000;
String h = "";
String m = "";
String s = "";
h = (int) t / 3600 + "";
m = (int) (t % 3600) / 60 + "";
s = t % 60 + "";
if (h.length() <= 1) {
h = "0" + h;
}
if (m.length() <= 1) {
m = "0" + m;
}
if (s.length() <= 1) {
s = "0" + s;
}
time = h + ":" + m + ":" + s;
}
return time;
}
/**
* 获取两个日期之间间隔的分钟数
*
* @param startDate
* @param endDate
* @return
* @author zhougz
*/
public static int getIntervalMinute(Date startDate, Date endDate) {
int min = 0;
if (null != startDate && null != endDate) {
long end = endDate.getTime();
long start = startDate.getTime();
long betweenDate = (end - start) / (60 * 1000);
min = Long.valueOf(betweenDate).intValue();
}
return min;
}
/**
* 获取两个日期之间间隔的天数
*
* @param start_date
* @param end_date
* @return
* @author sunyy
*/
public static int getIntervalDay(Date start_date, Date end_date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
start_date = sdf.parse(sdf.format(start_date));
end_date = sdf.parse(sdf.format(end_date));
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(start_date);
long time1 = cal.getTimeInMillis();
cal.setTime(end_date);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
/**
* 星期转换为星期索引
*
* @param week
* @return
*/
public static int weekToNum(String week) {
int weekNum = -1;
for (int i = 0, j = WEEKS.length; i < j; i++) {
if (week != null && WEEKS[i].toLowerCase().contains(week.toLowerCase())) {
weekNum = i + 1;
break;
}
}
return weekNum;
}
/**
* 获取日期所在周的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfWeek(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);//时
cal.set(Calendar.MINUTE, 0);//分
cal.set(Calendar.SECOND, 0);//秒
int d = 0;
if (cal.get(Calendar.DAY_OF_WEEK) == 1) {
d = -6;
} else {
d = 2 - cal.get(Calendar.DAY_OF_WEEK);
}
cal.add(Calendar.DAY_OF_WEEK, d);
Date resultDate = cal.getTime();
return resultDate;
}
/**
* 获取日期所在周的最后一天
*
* @param date
* @return
*/
public static Date getLastDayOfWeek(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 23);//时
cal.set(Calendar.MINUTE, 59);//分
cal.set(Calendar.SECOND, 59);//秒
int d = 0;
if (cal.get(Calendar.DAY_OF_WEEK) == 1) {
d = -6;
} else {
d = 2 - cal.get(Calendar.DAY_OF_WEEK);
}
cal.add(Calendar.DAY_OF_WEEK, 6);
cal.add(Calendar.DAY_OF_WEEK, d);
Date resultDate = cal.getTime();
return resultDate;
}
/**
* 获取日期当月第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfMonth(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, 0);//时
c.set(Calendar.MINUTE, 0);//分
c.set(Calendar.SECOND, 0);//秒
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
Date resultDate = c.getTime();
return resultDate;
}
/**
* 获取日期当月最后一天
*
* @param date
* @return
*/
public static Date getLastDayOfMonth(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, 23);//时
c.set(Calendar.MINUTE, 59);//分
c.set(Calendar.SECOND, 59);//秒
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
Date resultDate = c.getTime();
return resultDate;
}
/**
* 获取今天剩余秒数
*
* @return
*/
public static int getTodaySeconds() {
Calendar curDate = Calendar.getInstance();
Calendar tommorowDate = new GregorianCalendar(curDate
.get(Calendar.YEAR), curDate.get(Calendar.MONTH), curDate
.get(Calendar.DATE) + 1, 0, 0, 0);
return (int) (tommorowDate.getTimeInMillis() - curDate.getTimeInMillis()) / 1000;
}
/**
* 获取当前时间字符串(yyyy-MM-dd HH:mm:ss)
*
* @return 当前时间字符串
*/
public static String getNowStr() {
return getDatetimeStr(new Date());
}
/**
* Date转String
*
* @param date 时间
* @return 字符串(yyyy-MM-dd HH:mm:ss)
*/
public static String getDatetimeStr(Date date) {
return getDateFormatDefault().format(date);
}
/**
* 获取当前时间字符串(yyyy-MM-dd)
*
* @return 当前时间字符串
*/
public static String getNowDateStr() {
return getDateFormatDate().format(new Date());
}
/**
* 获取当前时间字符串(HH:mm:ss)
*
* @return 当前时间字符串
*/
public static String getNowTimeStr() {
return getDateFormatTime().format(new Date());
}
/**
* 计算今天到指定时间的剩余天数
* <p>1.不足一天按一天算;</p>
* <p>2.指定时间是过去时间,返回0;</p>
*
* @param date 指定时间
* @return 剩余天数
*/
public static Integer decorateDays(Date date) {
Long d = date.getTime() - new Date().getTime();
if (d < 0L) {
return 0;
}
d = d / 3600_000L / 24L;
return d.intValue() + 1;
}
/**
* Date转String
*
* @param date 时间
* @param format 格式
* @return 时间字符串
*/
public static String formatDate(Date date, String format) {
SimpleDateFormat dateFormat = getDateFormat(format);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
return dateFormat.format(date);
}
/**
* Date转String
*
* @param date 时间
* @return 时间字符串(yyyy-MM-dd HH:mm:ss)
*/
public static String formatDate(Date date) {
return formatDate(date, DATE_TIME_FORMAT);
}
/**
* String转Date
*
* @param dateStr 时间字符串
* @param format 格式
* @return Date 时间
* @throws ParseException
*/
public static Date parseDate(String dateStr, String format) throws ParseException {
return getDateFormat(format).parse(dateStr);
}
/**
* String转Date
*
* @param dateStr 时间字符串(yyyy-MM-dd HH:mm:ss)
* @return Date 时间
* @throws ParseException
*/
public static Date parseDate(String dateStr) throws ParseException {
return parseDate(dateStr, DATE_TIME_FORMAT);
}
/**
* 计算时间差(毫秒)
*
* @param d1 第一个时间
* @param d2 第二个时间
* @return d1.getTime() - d2.getTime()
*/
public static long calcTimeDifference(Date d1, Date d2) {
return d1.getTime() - d2.getTime();
}
/**
* 计算传入时间和当前时间相比已经过去了多少分钟
*
* @param date 传入时间
* @return 传入时间和当前时间相比已经过去了多少分钟
*/
public static long calcPastMinute(Date date) {
long diffMillisecond = calcTimeDifference(new Date(), date);
return diffMillisecond / 60_000L;
}
/**
* 计算传入时间和当前时间相比已经过去了多少分钟
*
* @param dateStr 传入时间字符串(yyyy-MM-dd HH:mm:ss)
* @return 传入时间和当前时间相比已经过去了多少分钟
*/
public static long calcPastMinute(String dateStr) throws ParseException {
long diffMillisecond = calcTimeDifference(new Date(), parseDate(dateStr));
return diffMillisecond / 60_000L;
}
/**
* 获取N分钟之前的时间
*
* @param minute 单位分钟
* @return N分钟之前的时间
*/
public static Date getMinuteAgoDate(long minute) {
long agoTimestamp = System.currentTimeMillis() - minute * 60_000L;
return new Date(agoTimestamp);
}
/**
* 获取之前的时间
*
* @param day N天
* @param hour N小时
* @param minute N分钟
* @param second N秒
* @return 之前的时间
*/
public static Date getAgoDate(long day, long hour, long minute, long second) {
long agoTimestamp = System.currentTimeMillis() - (((day * 24 + hour) * 60 + minute) * 60 + second) * 1000L;
return new Date(agoTimestamp);
}
/**
* 获取基准时间之前的时间
*
* @param baseDate 基准时间
* @param day N天
* @param hour N小时
* @param minute N分钟
* @param second N秒
* @return 之后的时间
*/
public static Date getAfterDate(Date baseDate, long day, long hour, long minute, long second) {
long currTimestamp = baseDate.getTime();
long afterTimestamp = currTimestamp + (((day * 24 + hour) * 60 + minute) * 60 + second) * 1000L;
return new Date(afterTimestamp);
}
/**
* 获取指定月份第一天Date
*
* @param dateStr yyyy-MM
* @return Date类型时间
*/
public static Date getFirstDayByMonth(String dateStr) throws Exception {
dateStr = dateStr + "-01";
return parseDate(dateStr, "yyyy-MM-dd");
}
/**
* 获取指定月份下个月第一天Date
*
* @param dateStr
* @return
*/
public static Date getNextFirstDayByMonth(String dateStr) throws Exception {
Date date = getFirstDayByMonth(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, 1);
return calendar.getTime();
}
/**
* 获取指定月份最后一天Date
*
* @param dateStr yyyy-MM
* @return Date类型时间
*/
public static Date getLastDayByMonth(String dateStr) throws Exception {
Date date = getFirstDayByMonth(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, 1);
calendar.add(Calendar.DATE, -1);
return calendar.getTime();
}
/**
* <p>功能描述: 获取当前时间距离一天结束的剩余秒数</p>
*
* @param currentDate -
* @return <p>修改履历:</p>
* @date 2019/9/5 19:28
*/
public static Integer getRemainSecondsOneDay(Date currentDate) {
Calendar midnight = Calendar.getInstance();
midnight.setTime(currentDate);
midnight.add(Calendar.DAY_OF_MONTH, 1);
midnight.set(Calendar.HOUR_OF_DAY, 0);
midnight.set(Calendar.MINUTE, 0);
midnight.set(Calendar.SECOND, 0);
midnight.set(Calendar.MILLISECOND, 0);
return Long.valueOf((midnight.getTime().getTime() - currentDate.getTime()) / 1000).intValue();
}
/**
* <p>功能描述: 转换两个时间的时间差为天时分秒</p>
*
* @param beginDate -计算开始时间
* @param endDate -计算结束时间
* @return <p>修改履历:</p>
* @author jishu
* @date 2019/9/24 10:18
*/
public static Map<String, Integer> parseDayHourMinuteSecond(Date beginDate, Date endDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - beginDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
long sec = diff % nd % nh % nm / ns;
Map<String, Integer> resultMap = new HashMap<>();
resultMap.put("day", Long.valueOf(day).intValue());
resultMap.put("hour", Long.valueOf(hour).intValue());
resultMap.put("minute", Long.valueOf(min).intValue());
resultMap.put("second", Long.valueOf(sec).intValue());
return resultMap;
}
/**
* 通过日期获取周几,格式如:7-08(周三)
*
* @param date -
* @return -
*/
public static String dateToDayOfWeekStr(Date date) {
Calendar calendar = Calendar.getInstance();
StringBuilder sb = new StringBuilder();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;
if (month < 10) {
sb.append("0");
}
int day = calendar.get(Calendar.DAY_OF_MONTH);
sb.append(month).append("-").append(day);
int i = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (i < 0) {
i = 0;
}
sb.append(weekDays[i]);
return sb.toString();
}
/**
* 通过日期获取一年中的第几周
*
* @param date -
* @return -
*/
public static String dateToWeekOfYearStr(Date date) {
Calendar calendar = Calendar.getInstance();
StringBuilder sb = new StringBuilder();
calendar.setTime(date);
int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR);
sb.append("第").append(weekOfYear).append("周");
return sb.toString();
}
/**
* 通过日期获取几月
*
* @param date -
* @return -
*/
public static String dateToMonthOfYear(Date date) {
Calendar calendar = Calendar.getInstance();
StringBuilder sb = new StringBuilder();
calendar.setTime(date);
int month1 = calendar.get(Calendar.MONTH) + 1;
sb.append("第").append(month1).append("月");
return sb.toString();
}
/**
* 转yyyy-MM-dd 为yyyy-MM-dd HH:mm:ss
*
* @param date -
* @param type - 1.每天的开始 2.每天的结束
* @return -
*/
public static String transDateToDateTime(String date, Integer type) {
if (StringUtils.length(date) == 10) {
if (type == 1) {
return date + DAY_BEGIN_TIME;
} else {
return date + DAY_END_TIME;
}
}else{
return date;
}
}
public static Date getFirstDateOfYear(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_YEAR, c.getActualMinimum(Calendar.DAY_OF_YEAR));
return setDayMinTime(c.getTime());
}
public static Date setDayMinTime(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, c.getActualMinimum(Calendar.HOUR_OF_DAY));
c.set(Calendar.MINUTE, c.getActualMinimum(Calendar.MINUTE));
c.set(Calendar.SECOND, c.getActualMinimum(Calendar.SECOND));
c.set(Calendar.MILLISECOND, c.getActualMinimum(Calendar.MILLISECOND));
return c.getTime();
}
public static List<Date> getDaysBetweenDates(Date startDate,Date endDate) {
List<Date> dates = new ArrayList<>();
Calendar c = Calendar.getInstance();
c.setTime(startDate);
while (c.getTime().before(endDate)) {
dates.add(c.getTime());
c.add(Calendar.DAY_OF_MONTH, 1);
}
dates.add(endDate);
return dates;
}
public static List<String> getDaysStrBetweenDates(Date startDate,Date endDate) {
List<String> dates = new ArrayList<>();
Calendar c = Calendar.getInstance();
c.setTime(startDate);
while (c.getTime().before(endDate)) {
dates.add(formatDate(c.getTime(),DATE_FORMAT));
c.add(Calendar.DAY_OF_MONTH, 1);
}
dates.add(formatDate(endDate,DATE_FORMAT));
return dates;
}
/**
* String转Date
* 支持:2010-12-01 23:15:06.999
* 2010-12-01 23:15:06
* 2010-12-01 23:15
* 2010-12-01
*
* @param dateStr
* @return
* @throws ParseException
*/
public static Date dateFormat(String dateStr) throws ParseException {
if (dateStr.length() == 23||dateStr.length() ==22 || dateStr.length() ==21){
if(dateStr.contains("T")){
return DateUtil.FORMAT_YYYY_MM_DD_HH_MM_SS_S_UTC.parse(dateStr);
}
return DateUtil.FORMAT_YYYY_MM_DD_HH_MM_SS_S.parse(dateStr);
}
if (dateStr.length() == 19)
return DateUtil.FORMAT_YYYY_MM_DD_HH_MM_SS.parse(dateStr);
else if (dateStr.length() == 16)
return DateUtil.FORMAT_YYYY_MM_DD_HH_MM.parse(dateStr);
else if (dateStr.length() == 10)
return DateUtil.FORMAT_YYYY_MM_DD.parse(dateStr);
else
return null;
}
}
package com.viontech.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class Gb1400GenerateIDUtil {
//公安机关机构代码
@Value("${gb1400.gongan.orgcode:}")
private String gonganOrgcode;
//
private volatile Long notificationSequence = 0L;
private volatile Long sourceIdSequence = 0L;
private volatile Long motorVehicleIDSequence = 0L;
// 序列号的最大值
private final int sequenceMax = 99999;
/**
* 自动生成NotificationID
* @return NotificationID
*/
public String generateNotificationID() {
StringBuilder idstr = new StringBuilder();
String currentTime = DateUtil.format(new Date(), DateUtil.DATE_TIME_FORMAT_NO_DELIMITER);
idstr.append(gonganOrgcode);
idstr.append("04");
idstr.append(currentTime);
idstr.append(nextNotificationId());
return idstr.toString();
}
/**
* 自动生成SourceID
* @return SourceID
*/
public String generateSourceID(String DeviceID, String type, String PassTime) {
StringBuilder idstr = new StringBuilder();
idstr.append(DeviceID);
idstr.append(type);
idstr.append(PassTime);
idstr.append(nextSourceId());
return idstr.toString();
}
/**
* 自动生成MotorVehicleID
* @return MotorVehicleID
*/
public String generateMotorVehicleID(String SourceID, String type) {
StringBuilder idstr = new StringBuilder();
idstr.append(SourceID);
idstr.append(type);
idstr.append(nextMotorVehicleId());
return idstr.toString();
}
public String nextNotificationId(){
synchronized (this.notificationSequence) {
this.notificationSequence = (this.notificationSequence + 1) % this.sequenceMax;
return String.format("%05d", this.notificationSequence.longValue());
}
}
public String nextSourceId(){
synchronized (this.sourceIdSequence) {
this.sourceIdSequence = (this.sourceIdSequence + 1) % this.sequenceMax;
return String.format("%05d", this.sourceIdSequence.longValue());
}
}
public String nextMotorVehicleId(){
synchronized (this.motorVehicleIDSequence) {
this.motorVehicleIDSequence = (this.motorVehicleIDSequence + 1) % this.sequenceMax;
return String.format("%05d", this.motorVehicleIDSequence.longValue());
}
}
public static void main(String[] args) {
Gb1400GenerateIDUtil xx = new Gb1400GenerateIDUtil();
for (int i = 0; i < 10; i++) {
System.out.println(xx.generateNotificationID());
}
}
}
package com.viontech.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.List;
/**
* @author vion
**/
public class Gb1400ResponseUtil {
public static JSONObject success(String id, String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", id);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", 0);
response.put("StatusString", "成功");
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
public static JSONObject success(String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", null);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", 0);
response.put("StatusString", "成功");
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
public static JSONObject successList(String requestURL) {
JSONObject item = new JSONObject();
item.put("Id", null);
item.put("LocalTime", new Date());
item.put("RequestURL", requestURL);
item.put("StatusCode", 0);
item.put("StatusString", "成功");
JSONArray items = new JSONArray();
items.add(item);
JSONObject object = new JSONObject();
object.put("ResponseStatusObject", items);
JSONObject result = new JSONObject();
result.put("ResponseStatusListObject", object);
return result;
}
public static JSONObject responseStatusListObject(List<JSONObject> list) {
JSONObject object = new JSONObject();
object.put("ResponseStatusObject", list);
JSONObject result = new JSONObject();
result.put("ResponseStatusListObject", object);
return result;
}
public static JSONObject buildResponseStatusObject(String id, String requestURL, Integer StatusCode, String StatusString) {
JSONObject response = new JSONObject();
response.put("Id", id);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", StatusCode);
response.put("StatusString", StatusString);
return response;
}
public static JSONObject error(Integer errorNo, String errorMsg, String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", null);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", errorNo);
response.put("StatusString", errorMsg);
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
}
\ No newline at end of file \ No newline at end of file
package com.viontech.utils;
import java.util.*;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;
public class JavaBean2Json {
public static String javaBean2Json(Object obj) {
return JSONObject.fromObject(obj,getJsonConfig()).toString();
}
public static <T> T Json2JavaBean(String json,Class<T> clas) {
try {
ObjectMapper om = new ObjectMapper();
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return om.readValue(json, clas);
} catch (Exception e) {
JSONObject jsb = new JSONObject();
return (T) jsb.toBean(JSONObject.fromObject(json), clas, getJsonConfig());
}
}
/**
* json转List
* @param json
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> json2List(String json,Class<T> clazz) {
if(json.startsWith("[")){//json.indexOf("[")==0
JSONArray array = JSONArray.fromObject(json);
List<T> list = JSONArray.toList(array, clazz);
return list;
}
return null;
}
/**
* json转Array
* @param json
* @param clazz
* @param <T>
* @return
*/
public static <T> T[] json2Array(String json,Class<T> clazz) {
if(json.indexOf("[")==0){
JSONArray array = JSONArray.fromObject(json);
T[] ray = (T[]) JSONArray.toArray(array, clazz);
return ray;
}
return null;
}
private static JsonConfig getJsonConfig(){
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object source/* 属性的拥有者 */, String name /* 属性名字 */,Object value/* 属性值 */) {
if(value instanceof List){
List<Object> list = (List<Object>) value;
if (list == null || list.size()==0) {
return true;
}
}else if(value instanceof Map){
Map map = (Map) value;
if (map == null || map.size() == 0) {
return true;
}
}
return null == value || "".equals(value);
}
});
return jsonConfig;
}
public static void jsonToMap(String json, Map map) {
JSONObject jsonObject = JSONObject.fromObject(json);
populate(jsonObject, map);
}
private static void populate(JSONObject jsonObject, Map map) {
for (Iterator iterator = jsonObject.entrySet().iterator(); iterator
.hasNext();) {
String entryStr = String.valueOf(iterator.next());
String key = entryStr.substring(0, entryStr.indexOf("="));
String value = entryStr.substring(entryStr.indexOf("=") + 1,entryStr.length());
if (jsonObject.get(key).getClass().equals(JSONObject.class)) {
HashMap _map = new HashMap();
map.put(key, _map);
populate(jsonObject.getJSONObject(key), ((Map) (_map)));
} else if (jsonObject.get(key).getClass().equals(JSONArray.class)) {
ArrayList list = new ArrayList();
map.put(key, list);
populateArray(jsonObject.getJSONArray(key), list);
} else {
map.put(key, jsonObject.get(key));
}
}
}
private static void populateArray(JSONArray jsonArray, List list) {
for (int i = 0; i < jsonArray.size(); i++)
if (jsonArray.get(i).getClass().equals(JSONArray.class)) {
ArrayList _list = new ArrayList();
list.add(_list);
populateArray(jsonArray.getJSONArray(i), _list);
} else if (jsonArray.get(i).getClass().equals(JSONObject.class)) {
HashMap _map = new HashMap();
list.add(_map);
populate(jsonArray.getJSONObject(i), _map);
} else {
list.add(jsonArray.get(i));
}
}
/***
* 判断发过来的信息是否是json格式
*
* @param json
* @return
*/
public static boolean isJson(String json) {
try {
JSONObject.fromObject(json);
return true;
} catch (Exception e) {
return false;
}
}
}
package com.viontech.utils;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class JsonMessage<T> {
private boolean success;
private int code;
private String msg;
private T data;
public JsonMessage() {
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return JSONObject.toJSONString(this, SerializerFeature.WriteMapNullValue);
}
}
package com.viontech.utils;
import com.viontech.constant.SystemConstants;
public class JsonMessageUtil {
/**
* 返回成功json信息
*
* @param msg
* 成功信息
* @param data
* 对应的数据
* @return json消息对象
*/
public static <T> JsonMessage<T> getSuccessJsonMsg(String msg, T data) {
JsonMessage jsonMessage = getJsonMessageInstance();
jsonMessage.setSuccess(true);
jsonMessage.setCode(SystemConstants.APP_CODE_SUCCESS);
jsonMessage.setMsg(msg);
jsonMessage.setData(data);
return jsonMessage;
}
public static<T> JsonMessage<T> getSuccessJsonMsg(T data) {
return getSuccessJsonMsg("", data);
}
public static JsonMessage getSuccessJsonMsg(String msg) {
return getSuccessJsonMsg(msg, null);
}
/**
* 返回失败json信息
*
* @param msg
* 成功信息
* @return json消息对象
*/
public static JsonMessage getErrorJsonMsg(String msg) {
JsonMessage jsonMessage = getJsonMessageInstance();
jsonMessage.setSuccess(false);
jsonMessage.setCode(SystemConstants.APP_CODE_ERROR);
jsonMessage.setMsg(msg);
jsonMessage.setData(null);
return jsonMessage;
}
/**
* 返回失败json信息
*
* @param msg
* 成功信息
* @return json消息对象
*/
public static JsonMessage getErrorJsonMsg(Integer code,String msg) {
JsonMessage jsonMessage = getJsonMessageInstance();
jsonMessage.setSuccess(false);
jsonMessage.setCode(code);
jsonMessage.setMsg(msg);
jsonMessage.setData(null);
return jsonMessage;
}
/**
* Json消息对象,用来返回给前台json
*
* @author suman 2016年8月15日 上午10:55:05
*/
public static JsonMessage getJsonMessageInstance(){
return new JsonMessage();
}
}
package com.viontech.vo;
import java.util.List;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/9.
* @Description:
*/
public class DriverDataVo {
private Map holdingchild;
private List<Map> safe_belt;
private String image;
private List<FaceDataVo> face;
private Map phone;
public Map getHoldingchild() {
return holdingchild;
}
public void setHoldingchild(Map holdingchild) {
this.holdingchild = holdingchild;
}
public List<Map> getSafe_belt() {
return safe_belt;
}
public void setSafe_belt(List<Map> safe_belt) {
this.safe_belt = safe_belt;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public List<FaceDataVo> getFace() {
return face;
}
public void setFace(List<FaceDataVo> face) {
this.face = face;
}
public Map getPhone() {
return phone;
}
public void setPhone(Map phone) {
this.phone = phone;
}
}
package com.viontech.vo;
import java.util.Map;
public class FaceDataVo {
private String state;
private Map rect;
private String with_hats;
private String sex;
private Map upbody;
private Map lobody;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Map getRect() {
return rect;
}
public void setRect(Map rect) {
this.rect = rect;
}
public String getWith_hats() {
return with_hats;
}
public void setWith_hats(String with_hats) {
this.with_hats = with_hats;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Map getUpbody() {
return upbody;
}
public void setUpbody(Map upbody) {
this.upbody = upbody;
}
public Map getLobody() {
return lobody;
}
public void setLobody(Map lobody) {
this.lobody = lobody;
}
}
package com.viontech.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class FxData{
private String event_cate;
private String event_type;
private String event_refid;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
private String event_dt;
private String dev_unid;
private String vdev_unid;
private String vchan_duid;
private String vchan_refid;
private Map aux_dev_info;
private TrafficDataVo event_data;
private List<PicDataVo> pics;
private List<VideoDataVo> video;
private String task_type;
private String task_id;
private String subtask_id;
private String source_type;
private String test_pic_file;
private String test_frame_no;
public String getEvent_cate() {
return event_cate;
}
public void setEvent_cate(String event_cate) {
this.event_cate = event_cate;
}
public String getEvent_type() {
return event_type;
}
public void setEvent_type(String event_type) {
this.event_type = event_type;
}
public String getEvent_refid() {
return event_refid;
}
public void setEvent_refid(String event_refid) {
this.event_refid = event_refid;
}
public String getEvent_dt() {
return event_dt;
}
public void setEvent_dt(String event_dt) {
this.event_dt = event_dt;
}
public String getDev_unid() {
return dev_unid;
}
public void setDev_unid(String dev_unid) {
this.dev_unid = dev_unid;
}
public String getVdev_unid() {
return vdev_unid;
}
public void setVdev_unid(String vdev_unid) {
this.vdev_unid = vdev_unid;
}
public String getVchan_duid() {
return vchan_duid;
}
public void setVchan_duid(String vchan_duid) {
this.vchan_duid = vchan_duid;
}
public String getVchan_refid() {
return vchan_refid;
}
public void setVchan_refid(String vchan_refid) {
this.vchan_refid = vchan_refid;
}
public Map getAux_dev_info() {
return aux_dev_info;
}
public void setAux_dev_info(Map aux_dev_info) {
this.aux_dev_info = aux_dev_info;
}
public TrafficDataVo getEvent_data() {
return event_data;
}
public void setEvent_data(TrafficDataVo event_data) {
this.event_data = event_data;
}
public List<PicDataVo> getPics() {
return pics;
}
public void setPics(List<PicDataVo> pics) {
this.pics = pics;
}
public List<VideoDataVo> getVideo() {
return video;
}
public void setVideo(List<VideoDataVo> video) {
this.video = video;
}
public String getTask_type() {
return task_type;
}
public void setTask_type(String task_type) {
this.task_type = task_type;
}
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getSubtask_id() {
return subtask_id;
}
public void setSubtask_id(String subtask_id) {
this.subtask_id = subtask_id;
}
public String getSource_type() {
return source_type;
}
public void setSource_type(String source_type) {
this.source_type = source_type;
}
public String getTest_pic_file() {
return test_pic_file;
}
public void setTest_pic_file(String test_pic_file) {
this.test_pic_file = test_pic_file;
}
public String getTest_frame_no() {
return test_frame_no;
}
public void setTest_frame_no(String test_frame_no) {
this.test_frame_no = test_frame_no;
}
}
package com.viontech.vo;
import java.util.List;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class IllegalDataVo {
private String state;
private String code;
private Detail detail;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Detail getDetail() {
return detail;
}
public void setDetail(Detail detail) {
this.detail = detail;
}
public class Detail{
private String limit_speed;
private String spark_speed;
private String over_speed_rate;
private String start_dt;
private String end_dt;
private List<Map> limit_time;
public String getLimit_speed() {
return limit_speed;
}
public void setLimit_speed(String limit_speed) {
this.limit_speed = limit_speed;
}
public String getSpark_speed() {
return spark_speed;
}
public void setSpark_speed(String spark_speed) {
this.spark_speed = spark_speed;
}
public String getOver_speed_rate() {
return over_speed_rate;
}
public void setOver_speed_rate(String over_speed_rate) {
this.over_speed_rate = over_speed_rate;
}
public String getStart_dt() {
return start_dt;
}
public void setStart_dt(String start_dt) {
this.start_dt = start_dt;
}
public String getEnd_dt() {
return end_dt;
}
public void setEnd_dt(String end_dt) {
this.end_dt = end_dt;
}
public List<Map> getLimit_time() {
return limit_time;
}
public void setLimit_time(List<Map> limit_time) {
this.limit_time = limit_time;
}
}
}
package com.viontech.vo;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class PicDataVo {
private String pic_base64;
private String src_url;
private String format;
private String pic_unid;
private String shoot_dt;
private String width;
private String hight;
private String ofilename;
private String type;
private Map object_rect;
private Map feature_rect;
public String getPic_base64() {
return pic_base64;
}
public void setPic_base64(String pic_base64) {
this.pic_base64 = pic_base64;
}
public String getSrc_url() {
return src_url;
}
public void setSrc_url(String src_url) {
this.src_url = src_url;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getPic_unid() {
return pic_unid;
}
public void setPic_unid(String pic_unid) {
this.pic_unid = pic_unid;
}
public String getShoot_dt() {
return shoot_dt;
}
public void setShoot_dt(String shoot_dt) {
this.shoot_dt = shoot_dt;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getHight() {
return hight;
}
public void setHight(String hight) {
this.hight = hight;
}
public String getOfilename() {
return ofilename;
}
public void setOfilename(String ofilename) {
this.ofilename = ofilename;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map getObject_rect() {
return object_rect;
}
public void setObject_rect(Map object_rect) {
this.object_rect = object_rect;
}
public Map getFeature_rect() {
return feature_rect;
}
public void setFeature_rect(Map feature_rect) {
this.feature_rect = feature_rect;
}
}
package com.viontech.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.viontech.vo.VehicleDataVo;
import org.springframework.context.annotation.Conditional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class TrafficDataVo {
private String version;
private String speed;
private String model;
private String start_dt;
private String end_dt;
@JsonProperty(value = "ID")
private String ID;
private Location location;
private Device device;
private Lane lane;
@JsonProperty(value = "vehicle")
private VehicleDataVo vehicle;
private Map RefinedFeature;
@JsonProperty(value = "driver")
private DriverDataVo driver;
@JsonProperty(value = "illegal")
private IllegalDataVo illegal;
private String xcycle_type;
@JsonProperty(value = "xcycle")
private Object xcycle;
@JsonProperty(value = "pedestrian")
private Object pedestrian;
private Map xcycleData;
private Map pedestrianData;
private List<VehicleFlowVo> xcycleFlow;
private List<VehicleFlowVo> pedestrianFlow;
@JsonProperty(value = "big_vehicle")
private List<VehicleFlowVo> big_vehicle;
@JsonProperty(value = "small_vehicle")
private List<VehicleFlowVo> small_vehicle;
public List<VehicleFlowVo> getBig_vehicle() {
return big_vehicle;
}
public void setBig_vehicle(List<VehicleFlowVo> big_vehicle) {
this.big_vehicle = big_vehicle;
}
public List<VehicleFlowVo> getSmall_vehicle() {
return small_vehicle;
}
public void setSmall_vehicle(List<VehicleFlowVo> small_vehicle) {
this.small_vehicle = small_vehicle;
}
public Map getXcycleData() {
if(xcycle instanceof Map){
xcycleData= (Map) xcycle;
}
return xcycleData;
}
public void setXcycleData(Map xcycleData) {
this.xcycleData = xcycleData;
}
public Map getPedestrianData() {
if(pedestrian instanceof Map){
pedestrianData= (Map) pedestrian;
}
return pedestrianData;
}
public void setPedestrianData(Map pedestrianData) {
this.pedestrianData = pedestrianData;
}
public List<VehicleFlowVo> getXcycleFlow() {
if(xcycle instanceof Map){
xcycleFlow= (List<VehicleFlowVo>) xcycle;
}
return xcycleFlow;
}
public void setXcycleFlow(List<VehicleFlowVo> xcycleFlow) {
this.xcycleFlow = xcycleFlow;
}
public List<VehicleFlowVo> getPedestrianFlow() {
if(pedestrian instanceof List){
pedestrianFlow=(List<VehicleFlowVo>) pedestrian;
}
return pedestrianFlow;
}
public void setPedestrianFlow(List<VehicleFlowVo> pedestrianFlow) {
this.pedestrianFlow = pedestrianFlow;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getStart_dt() {
return start_dt;
}
public void setStart_dt(String start_dt) {
this.start_dt = start_dt;
}
public String getEnd_dt() {
return end_dt;
}
public void setEnd_dt(String end_dt) {
this.end_dt = end_dt;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public Device getDevice() {
return device;
}
public void setDevice(Device device) {
this.device = device;
}
public Lane getLane() {
return lane;
}
public void setLane(Lane lane) {
this.lane = lane;
}
public VehicleDataVo getVehicle() {
return vehicle;
}
public void setVehicle(VehicleDataVo vehicle) {
this.vehicle = vehicle;
}
public Map getRefinedFeature() {
return RefinedFeature;
}
public void setRefinedFeature(Map refinedFeature) {
RefinedFeature = refinedFeature;
}
public DriverDataVo getDriver() {
return driver;
}
public void setDriver(DriverDataVo driver) {
this.driver = driver;
}
public IllegalDataVo getIllegal() {
return illegal;
}
public void setIllegal(IllegalDataVo illegal) {
this.illegal = illegal;
}
public String getXcycle_type() {
return xcycle_type;
}
public void setXcycle_type(String xcycle_type) {
this.xcycle_type = xcycle_type;
}
public Object getXcycle() {
return xcycle;
}
public void setXcycle(Object xcycle) {
this.xcycle = xcycle;
}
public Object getPedestrian() {
return pedestrian;
}
public void setPedestrian(Object pedestrian) {
this.pedestrian = pedestrian;
}
public class Location{
private String name;
private String code;
private Map department;
private Map direction;
private Map drive_direction;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Map getDepartment() {
return department;
}
public void setDepartment(Map department) {
this.department = department;
}
public Map getDirection() {
return direction;
}
public void setDirection(Map direction) {
this.direction = direction;
}
public Map getDrive_direction() {
return drive_direction;
}
public void setDrive_direction(Map drive_direction) {
this.drive_direction = drive_direction;
}
}
public class Device{
private String name;
private String code;
private String ip;
private String model;
private String host;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
}
public class Lane{
private String code;
private String number;
private String description;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
}
package com.viontech.vo;
import java.util.List;
import java.util.Map;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class VehicleDataVo {
private String image;
private Map global_feature;
private Map local_feature;
private Map rect;
private Map plate;
private Map body;
private Map driver;
private List<Map> tracks;
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public Map getGlobal_feature() {
return global_feature;
}
public void setGlobal_feature(Map global_feature) {
this.global_feature = global_feature;
}
public Map getLocal_feature() {
return local_feature;
}
public void setLocal_feature(Map local_feature) {
this.local_feature = local_feature;
}
public Map getRect() {
return rect;
}
public void setRect(Map rect) {
this.rect = rect;
}
public Map getPlate() {
return plate;
}
public void setPlate(Map plate) {
this.plate = plate;
}
public Map getBody() {
return body;
}
public void setBody(Map body) {
this.body = body;
}
public Map getDriver() {
return driver;
}
public void setDriver(Map driver) {
this.driver = driver;
}
public List<Map> getTracks() {
return tracks;
}
public void setTracks(List<Map> tracks) {
this.tracks = tracks;
}
}
package com.viontech.vo;
/**
* @Author: zhaibailin
* @Date: 2020/7/20.
* @Description:
*/
public class VehicleFlowVo {
private String road;
private String direction;
private Integer sample_dura;
private Integer sample_num;
private Integer velocity;
private String velocity_unit;
private Float occupy;
private Float distance;
private Integer queue_length;
public String getRoad() {
return road;
}
public void setRoad(String road) {
this.road = road;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public Integer getSample_dura() {
return sample_dura;
}
public void setSample_dura(Integer sample_dura) {
this.sample_dura = sample_dura;
}
public Integer getSample_num() {
return sample_num;
}
public void setSample_num(Integer sample_num) {
this.sample_num = sample_num;
}
public Integer getVelocity() {
return velocity;
}
public void setVelocity(Integer velocity) {
this.velocity = velocity;
}
public String getVelocity_unit() {
return velocity_unit;
}
public void setVelocity_unit(String velocity_unit) {
this.velocity_unit = velocity_unit;
}
public Float getOccupy() {
return occupy;
}
public void setOccupy(Float occupy) {
this.occupy = occupy;
}
public Float getDistance() {
return distance;
}
public void setDistance(Float distance) {
this.distance = distance;
}
public Integer getQueue_length() {
return queue_length;
}
public void setQueue_length(Integer queue_length) {
this.queue_length = queue_length;
}
}
package com.viontech.vo;
/**
* @Author: zhaibailin
* @Date: 2020/7/8.
* @Description:
*/
public class VideoDataVo {
private String video_base64;
private String src_url;
private String start_dt;
private String end_dt;
private String format;
private String unid;
private String width;
private String height;
private String fps;
private String ofilename;
public String getVideo_base64() {
return video_base64;
}
public void setVideo_base64(String video_base64) {
this.video_base64 = video_base64;
}
public String getSrc_url() {
return src_url;
}
public void setSrc_url(String src_url) {
this.src_url = src_url;
}
public String getStart_dt() {
return start_dt;
}
public void setStart_dt(String start_dt) {
this.start_dt = start_dt;
}
public String getEnd_dt() {
return end_dt;
}
public void setEnd_dt(String end_dt) {
this.end_dt = end_dt;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getHeight() {
return height;
}
public void setHeight(String height) {
this.height = height;
}
public String getFps() {
return fps;
}
public void setFps(String fps) {
this.fps = fps;
}
public String getOfilename() {
return ofilename;
}
public void setOfilename(String ofilename) {
this.ofilename = ofilename;
}
}
package com.viontech.vo.gb1400;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.List;
@Data
public class MotorVehicleObj {
@JSONField(name = "MotorVehicleObject")
private List<MotorVehicleObject> motorVehicleObject;
@Data
public static class MotorVehicleObject {
@JSONField(name = "MotorVehicleID")
private String MotorVehicleID;
@JSONField(name = "InfoKind")
private Integer InfoKind;
@JSONField(name = "SourceID")
private String SourceID;
@JSONField(name = "TollgateID")
private String TollgateID;
@JSONField(name = "PassTime")
private String PassTime;
@JSONField(name = "DeviceID")
private String DeviceID;
@JSONField(name = "StorageUrl1")
private String StorageUrl1;
@JSONField(name = "StorageUrl2")
private String StorageUrl2;
@JSONField(name = "LeftTopX")
private Integer LeftTopX;
@JSONField(name = "LeftTopY")
private Integer LeftTopY;
@JSONField(name = "RightBtmX")
private Integer RightBtmX;
@JSONField(name = "RightBtmY")
private Integer RightBtmY;
@JSONField(name = "LaneNo")
private Integer LaneNo;
@JSONField(name = "HasPlate")
private String HasPlate;
@JSONField(name = "PlateClass")
private String PlateClass;
@JSONField(name = "PlateColor")
private String PlateColor;
@JSONField(name = "PlateNo")
private String PlateNo;
@JSONField(name = "Direction")
private String Direction;
@JSONField(name = "VehicleClass")
private String VehicleClass;
@JSONField(name = "VehicleBrand")
private String VehicleBrand;
@JSONField(name = "VehicleStyles")
private String VehicleStyles;
@JSONField(name = "VehicleColor")
private String VehicleColor;
@JSONField(name = "Sunvisor")
private Integer Sunvisor;
@JSONField(name = "SafetyBelt")
private Integer SafetyBelt;
@JSONField(name = "Calling")
private Integer Calling;
//违法过车类型
@JSONField(name = "BreakRuleMode")
private String BreakRuleMode;
}
}
package com.viontech.vo.gb1400;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.List;
@Data
public class SubscribeNotificationsObj {
@JSONField(name = "SubscribeNotificationListObject")
private SubscribeNotificationListObject subscribeNotificationListObject;
@Data
public static class SubscribeNotificationListObject {
@JSONField(name = "SubscribeNotificationObject")
private List<SubscribeNotificationObject> subscribeNotificationObjects;
}
@Data
public static class SubscribeNotificationObject {
@JSONField(name = "NotificationID")
private String NotificationID;
@JSONField(name = "SubscribeID")
private String SubscribeID;
@JSONField(name = "Title")
private String Title;
@JSONField(name = "TriggerTime")
private String TriggerTime;
@JSONField(name = "InfoIDs")
private String InfoIDs;
@JSONField(name = "MotorVehicleObjectList")
private MotorVehicleObj MotorVehicleObjectList;
}
}
package com.viontech.vo.traffic;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class FaceModel {
private String unid;
private String traffic_unid;
private String state;
private String sex;
private String upbody_color;
private String lobody_color;
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid;
}
public String getTraffic_unid() {
return traffic_unid;
}
public void setTraffic_unid(String traffic_unid) {
this.traffic_unid = traffic_unid;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getUpbody_color() {
return upbody_color;
}
public void setUpbody_color(String upbody_color) {
this.upbody_color = upbody_color;
}
public String getLobody_color() {
return lobody_color;
}
public void setLobody_color(String lobody_color) {
this.lobody_color = lobody_color;
}
}
package com.viontech.vo.traffic;
public class TrafficBaseModel {
private String event_cate;
private String task_id;
private String task_type;
private String subtask_id;
private String source_type;
private String event_type;
private String dev_unid;
private String vchan_refid;
private String vdev_unid;
private String vchan_duid;
private String event_dt;
private String event_data;
private String device_name;
private String location_name;
private String device_code;
private String location_code;
public String getEvent_cate() {
return event_cate;
}
public void setEvent_cate(String event_cate) {
this.event_cate = event_cate;
}
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getTask_type() {
return task_type;
}
public void setTask_type(String task_type) {
this.task_type = task_type;
}
public String getSubtask_id() {
return subtask_id;
}
public void setSubtask_id(String subtask_id) {
this.subtask_id = subtask_id;
}
public String getSource_type() {
return source_type;
}
public void setSource_type(String source_type) {
this.source_type = source_type;
}
public String getEvent_type() {
return event_type;
}
public void setEvent_type(String event_type) {
this.event_type = event_type;
}
public String getDev_unid() {
return dev_unid;
}
public void setDev_unid(String dev_unid) {
this.dev_unid = dev_unid;
}
public String getVchan_refid() {
return vchan_refid;
}
public void setVchan_refid(String vchan_refid) {
this.vchan_refid = vchan_refid;
}
public String getVdev_unid() {
return vdev_unid;
}
public void setVdev_unid(String vdev_unid) {
this.vdev_unid = vdev_unid;
}
public String getVchan_duid() {
return vchan_duid;
}
public void setVchan_duid(String vchan_duid) {
this.vchan_duid = vchan_duid;
}
public String getEvent_dt() {
return event_dt;
}
public void setEvent_dt(String event_dt) {
this.event_dt = event_dt;
}
public String getEvent_data() {
return event_data;
}
public void setEvent_data(String event_data) {
this.event_data = event_data;
}
public String getDevice_name() {
return device_name;
}
public void setDevice_name(String device_name) {
this.device_name = device_name;
}
public String getLocation_name() {
return location_name;
}
public void setLocation_name(String location_name) {
this.location_name = location_name;
}
public String getDevice_code() {
return device_code;
}
public void setDevice_code(String device_code) {
this.device_code = device_code;
}
public String getLocation_code() {
return location_code;
}
public void setLocation_code(String location_code) {
this.location_code = location_code;
}
}
package com.viontech.vo.traffic;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class TrafficModel extends TrafficBaseModel {
private String unid;
private String plate_color_code;
private String plate_text;
private String location_code;
private String lane_code;
private String direction_code;
private String body_type_code;
private String illegal_code;
private String[] illegal_codes;
private String illegal_state;
private String body_color_code;
private String body_logo_code;
private Boolean refinedFeature_rAnnualInspection;
private Boolean refinedFeature_rDecoration;
private Boolean refinedFeature_rPendant;
private Boolean refinedFeature_rSunshading;
private String event_dt__gte;
private String event_dt__lt;
private List location_codes;
private List body_type_codes;
private List task_ids;
// 行人事件
private String sex;
private String upbody_color;
private String lobody_color;
private List<FaceModel> faces;
// 非机动车事件 车辆类型,motorcycle, bicycle, tricycle共三种
private String xcycle_type;
private List event_types;
private List unids;
private String event_id;
private Integer offset;
private Integer limit;
private String shoot_dt;
private String special_type;
private String subtaskIds;
private Object json_data;
private String pic_name;
private String video_name;
private Integer with_hats;
private String shoot_dtime;
private Integer company;
public Integer getCompany() {
return company;
}
public TrafficModel setCompany(Integer company) {
this.company = company;
return this;
}
public String getPic_name() {
return pic_name;
}
public void setPic_name(String pic_name) {
this.pic_name = pic_name;
}
public String getVideo_name() {
return video_name;
}
public void setVideo_name(String video_name) {
this.video_name = video_name;
}
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid;
}
public String getPlate_color_code() {
return plate_color_code;
}
public void setPlate_color_code(String plate_color_code) {
this.plate_color_code = plate_color_code;
}
public String getPlate_text() {
return plate_text;
}
public void setPlate_text(String plate_text) {
this.plate_text = plate_text;
}
public String getLocation_code() {
return location_code;
}
public void setLocation_code(String location_code) {
this.location_code = location_code;
}
public String getLane_code() {
return lane_code;
}
public void setLane_code(String lane_code) {
this.lane_code = lane_code;
}
public String getDirection_code() {
return direction_code;
}
public void setDirection_code(String direction_code) {
this.direction_code = direction_code;
}
public String getBody_type_code() {
return body_type_code;
}
public void setBody_type_code(String body_type_code) {
this.body_type_code = body_type_code;
}
public String getIllegal_code() {
return illegal_code;
}
public void setIllegal_code(String illegal_code) {
this.illegal_code = illegal_code;
}
public String getIllegal_state() {
return illegal_state;
}
public void setIllegal_state(String illegal_state) {
this.illegal_state = illegal_state;
}
public String getBody_color_code() {
return body_color_code;
}
public void setBody_color_code(String body_color_code) {
this.body_color_code = body_color_code;
}
public String getBody_logo_code() {
return body_logo_code;
}
public void setBody_logo_code(String body_logo_code) {
this.body_logo_code = body_logo_code;
}
public Boolean getRefinedFeature_rAnnualInspection() {
return refinedFeature_rAnnualInspection;
}
public void setRefinedFeature_rAnnualInspection(Boolean refinedFeature_rAnnualInspection) {
this.refinedFeature_rAnnualInspection = refinedFeature_rAnnualInspection;
}
public Boolean getRefinedFeature_rDecoration() {
return refinedFeature_rDecoration;
}
public void setRefinedFeature_rDecoration(Boolean refinedFeature_rDecoration) {
this.refinedFeature_rDecoration = refinedFeature_rDecoration;
}
public Boolean getRefinedFeature_rPendant() {
return refinedFeature_rPendant;
}
public void setRefinedFeature_rPendant(Boolean refinedFeature_rPendant) {
this.refinedFeature_rPendant = refinedFeature_rPendant;
}
public Boolean getRefinedFeature_rSunshading() {
return refinedFeature_rSunshading;
}
public void setRefinedFeature_rSunshading(Boolean refinedFeature_rSunshading) {
this.refinedFeature_rSunshading = refinedFeature_rSunshading;
}
public String getEvent_dt__gte() {
return event_dt__gte;
}
public void setEvent_dt__gte(String event_dt__gte) {
this.event_dt__gte = event_dt__gte;
}
public String getEvent_dt__lt() {
return event_dt__lt;
}
public void setEvent_dt__lt(String event_dt__lt) {
this.event_dt__lt = event_dt__lt;
}
public List getLocation_codes() {
return location_codes;
}
public void setLocation_codes(List location_codes) {
this.location_codes = location_codes;
}
public List getBody_type_codes() {
return body_type_codes;
}
public void setBody_type_codes(List body_type_codes) {
this.body_type_codes = body_type_codes;
}
public List getTask_ids() {
return task_ids;
}
public void setTask_ids(List task_ids) {
this.task_ids = task_ids;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getUpbody_color() {
return upbody_color;
}
public void setUpbody_color(String upbody_color) {
this.upbody_color = upbody_color;
}
public String getLobody_color() {
return lobody_color;
}
public void setLobody_color(String lobody_color) {
this.lobody_color = lobody_color;
}
public List<FaceModel> getFaces() {
return faces;
}
public void setFaces(List<FaceModel> faces) {
this.faces = faces;
}
public String getXcycle_type() {
return xcycle_type;
}
public void setXcycle_type(String xcycle_type) {
this.xcycle_type = xcycle_type;
}
public List getEvent_types() {
return event_types;
}
public void setEvent_types(List event_types) {
this.event_types = event_types;
}
public List getUnids() {
return unids;
}
public void setUnids(List unids) {
this.unids = unids;
}
public String getEvent_id() {
return event_id;
}
public void setEvent_id(String event_id) {
this.event_id = event_id;
}
public Integer getOffset() {
return offset;
}
public void setOffset(Integer offset) {
this.offset = offset;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public String getShoot_dt() {
return shoot_dt;
}
public void setShoot_dt(String shoot_dt) {
this.shoot_dt = shoot_dt;
}
public String[] getIllegal_codes() {
return illegal_codes;
}
public void setIllegal_codes(String[] illegal_codes) {
this.illegal_codes = illegal_codes;
}
public String getSpecial_type() {
return special_type;
}
public void setSpecial_type(String special_type) {
this.special_type = special_type;
}
public String getSubtaskIds() {
return subtaskIds;
}
public void setSubtaskIds(String subtaskIds) {
this.subtaskIds = subtaskIds;
}
public Object getJson_data() {
return json_data;
}
public void setJson_data(Object json_data) {
this.json_data = json_data;
}
public Integer getWith_hats() {
return with_hats;
}
public void setWith_hats(Integer with_hats) {
this.with_hats = with_hats;
}
public String getShoot_dtime() {
return shoot_dtime;
}
public void setShoot_dtime(String shoot_dtime) {
this.shoot_dtime = shoot_dtime;
}
}
package com.viontech.vo.traffic;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.springframework.data.annotation.Id;
import java.util.List;
import java.util.Map;
@JsonInclude(value = Include.NON_NULL)
//@Document(collection = "tb_traffic")
public class TrafficMongoModel implements Comparable<TrafficMongoModel> {
@Id
private String id;
// @Indexed(direction = IndexDirection.DESCENDING)
private String task_type;
// @Indexed(direction = IndexDirection.DESCENDING)
private String task_id;
// @Indexed(direction = IndexDirection.DESCENDING)
private String event_type;
// @Indexed(direction = IndexDirection.DESCENDING)
private String event_refid;
// @Indexed(direction = IndexDirection.DESCENDING)
private String event_dt;
// @Indexed(direction = IndexDirection.DESCENDING)
private String dev_unid;
private Map aux_dev_info;
private Map event_data;
private List pics;
private String event_cate;
private String vdev_unid;
private String vchan_duid;
private String vchan_refid;
private List video;
private String test_pic_file;
private String test_frame_no;
private String subtask_id;
private String source_type;
/***
* 相识度
*/
private Double similarity;
private String pic_name;
private String video_name;
private String unid;
public String getPic_name() {
return pic_name;
}
public void setPic_name(String pic_name) {
this.pic_name = pic_name;
}
public String getVideo_name() {
return video_name;
}
public void setVideo_name(String video_name) {
this.video_name = video_name;
}
public String getTask_type() {
return task_type;
}
public void setTask_type(String task_type) {
this.task_type = task_type;
}
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getEvent_type() {
return event_type;
}
public void setEvent_type(String event_type) {
this.event_type = event_type;
}
public String getEvent_refid() {
return event_refid;
}
public void setEvent_refid(String event_refid) {
this.event_refid = event_refid;
}
public String getEvent_dt() {
return event_dt;
}
public void setEvent_dt(String event_dt) {
this.event_dt = event_dt;
}
public String getDev_unid() {
return dev_unid;
}
public void setDev_unid(String dev_unid) {
this.dev_unid = dev_unid;
}
public Map getAux_dev_info() {
return aux_dev_info;
}
public void setAux_dev_info(Map aux_dev_info) {
this.aux_dev_info = aux_dev_info;
}
public Map getEvent_data() {
return event_data;
}
public void setEvent_data(Map event_data) {
this.event_data = event_data;
}
public List getPics() {
return pics;
}
public void setPics(List pics) {
this.pics = pics;
}
public String getEvent_cate() {
return event_cate;
}
public void setEvent_cate(String event_cate) {
this.event_cate = event_cate;
}
public String getVdev_unid() {
return vdev_unid;
}
public void setVdev_unid(String vdev_unid) {
this.vdev_unid = vdev_unid;
}
public String getVchan_duid() {
return vchan_duid;
}
public void setVchan_duid(String vchan_duid) {
this.vchan_duid = vchan_duid;
}
public String getVchan_refid() {
return vchan_refid;
}
public void setVchan_refid(String vchan_refid) {
this.vchan_refid = vchan_refid;
}
public List getVideo() {
return video;
}
public void setVideo(List video) {
this.video = video;
}
public String getTest_pic_file() {
return test_pic_file;
}
public void setTest_pic_file(String test_pic_file) {
this.test_pic_file = test_pic_file;
}
public String getTest_frame_no() {
return test_frame_no;
}
public void setTest_frame_no(String test_frame_no) {
this.test_frame_no = test_frame_no;
}
public String getSubtask_id() {
return subtask_id;
}
public void setSubtask_id(String subtask_id) {
this.subtask_id = subtask_id;
}
public String getSource_type() {
return source_type;
}
public void setSource_type(String source_type) {
this.source_type = source_type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Double getSimilarity() {
return similarity;
}
public void setSimilarity(Double similarity) {
this.similarity = similarity;
}
@Override
public int compareTo(TrafficMongoModel o) {
return -1 * this.getSimilarity().compareTo(o.getSimilarity());
}
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid;
}
@Override
public String toString() {
return "TrafficMongoModel{" +
"id='" + id + '\'' +
", task_type='" + task_type + '\'' +
", task_id='" + task_id + '\'' +
", event_type='" + event_type + '\'' +
", event_refid='" + event_refid + '\'' +
", event_dt='" + event_dt + '\'' +
", dev_unid='" + dev_unid + '\'' +
", aux_dev_info=" + aux_dev_info +
", event_data=" + event_data +
", pics=" + pics +
", event_cate='" + event_cate + '\'' +
", vdev_unid='" + vdev_unid + '\'' +
", vchan_duid='" + vchan_duid + '\'' +
", vchan_refid='" + vchan_refid + '\'' +
", video=" + video +
", test_pic_file='" + test_pic_file + '\'' +
", test_frame_no='" + test_frame_no + '\'' +
", subtask_id='" + subtask_id + '\'' +
", source_type='" + source_type + '\'' +
", similarity=" + similarity +
'}';
}
}
server.port=30101
spring.application.name=fanxing-docking-gb1400
### 繁星postgresDB
########################################################
spring.datasource.url=jdbc:postgresql://192.168.1.64:5432/traffic
spring.datasource.username=postgres
spring.datasource.password=VIONauthpass
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.max-active=20
spring.datasource.druid.max-idle=8
spring.datasource.druid.min-idle=8
spring.datasource.druid.initial-size=10
spring.datasource.druid.max-wait=60000
mybatis.mapper-locations=classpath:com/viontech/mapping/*.xml
#redis
spring.redis.host=192.168.1.16
spring.redis.port=7379
spring.redis.password=vionredis
spring.redis.timeout=5000
spring.redis.jedis.pool.max-active=100
spring.redis.jedis.pool.max-idle=20
spring.redis.jedis.pool.min-idle=1
#获取图片地址的url
fanxing.getPicInfo.url=http://192.168.1.64:20080/api/v1/web/pics/
#gb1400配置
gb1400.enable=0
gb1400.gongan.orgcode=321283170000
gb1400.username=huawei
gb1400.password=huawei123
gb1400.userIdentify=32128317051310778562
gb1400.ipPort=32.165.198.11:8120
\ No newline at end of file \ No newline at end of file
02=M20
B10=B10
B11=B11
B12=B12
B13=B13
B14=B14
B15=B15
B16=B16
B17=B17
B18=B18
B19=B19
B1A=B1A
B1B=B1B
B20=B20
B21=B21
B22=B22
B23=B23
B24=B24
B25=B25
B26=B26
B27=B27
B28=B28
B29=B29
B2A=B2A
B2B=B2B
B30=B30
B31=B31
B32=B32
B33=B33
B34=B34
B35=B35
B36=B36
B37=B37
B38=B38
B39=B39
D11=D11
D12=D12
G10=G10
G11=G11
G12=G12
G13=G13
G14=G14
G15=G15
G16=G16
G17=G17
G18=G18
G19=G19
G20=G20
G21=G21
G22=G22
G23=G23
G24=G24
G25=G25
G26=G26
G27=G27
G28=G28
G29=G29
G30=G30
G31=G31
G32=G32
G33=G33
G34=G34
G35=G35
G36=G36
G37=G37
G38=G38
H10=H10
H11=H11
H12=H12
H13=H13
H14=H14
H15=H15
H16=H16
H17=H17
H18=H18
H19=H19
H20=H20
H21=H21
H22=H22
H23=H23
H24=H24
H25=H25
H26=H26
H27=H27
H28=H28
H29=H29
H30=H30
H31=H31
H32=H32
H33=H33
H34=H34
H35=H35
H37=H37
H38=H38
H39=H39
H40=H40
H41=H41
H42=H42
H43=H43
H44=H44
H45=H45
H46=H46
H47=H47
H50=H50
H51=H51
H52=H52
H53=H53
H54=H54
H55=H55
J11=J11
J12=J12
J13=J13
K10=K10
K11=K11
K12=K12
K13=K13
K14=K14
K15=K15
K16=K16
K17=K17
K20=K20
K21=K21
K22=K22
K23=K23
K24=K24
K25=K25
K27=K27
K30=K30
K31=K31
K32=K32
K33=K33
K34=K34
K40=K40
K41=K41
K42=K42
K43=K43
M10=M10
M11=M11
M12=M12
M13=M13
M14=M14
M15=M15
M20=M20
M21=M21
M22=M22
N11=N11
Q10=Q10
Q11=Q11
Q12=Q12
Q20=Q20
Q21=Q21
Q22=Q22
Q30=Q30
Q31=Q31
Q32=Q32
T11=T11
T20=T20
T21=T21
T22=T22
T23=T23
X99=X99
Z11=Z11
Z21=Z21
Z31=Z31
Z41=Z41
Z51=Z51
Z71=Z71
\ No newline at end of file \ No newline at end of file
0=0
1=1
2=13
3=6
4=4
5=38
6=30
7=2
8=8
9=12
10=9
11=14
12=40
13=15
14=7
15=11
16=26
17=34
18=19
19=27
20=25
21=10
22=18
23=42
24=17
25=3
26=41
27=5
28=29
29=35
30=45
31=31
32=28
33=20
34=52
35=16
36=21
37=24
38=32
39=37
40=70
41=39
42=22
43=0
44=68
45=62
46=108
47=95
48=96
49=67
50=51
51=122
52=47
53=66
54=53
55=69
56=124
57=90
58=121
59=107
60=87
61=44
62=109
63=92
64=49
65=110
66=104
67=23
68=33
69=0
70=0
71=0
72=0
73=0
74=0
75=0
76=0
77=128
78=0
79=0
80=65
81=25
82=43
83=71
84=191
85=230
88=58
89=36
110=0
111=81
112=0
113=155
90=0
91=56
92=0
93=0
94=0
95=0
96=0
97=0
98=0
99=0
100=0
101=0
102=0
103=0
104=0
105=57
106=86
107=0
108=0
109=0
86=0
87=0
114=0
115=112
116=0
117=0
118=0
119=0
120=117
121=0
122=0
123=0
124=103
125=0
126=0
127=0
128=0
129=0
130=0
131=0
132=83
133=0
134=0
135=0
136=0
137=0
\ No newline at end of file \ No newline at end of file
A=2
B=3
C=6
D=12
E=4
F=10
G=9
H=5
I=8
J=1
K=99
Z=99
\ No newline at end of file \ No newline at end of file
0=99
1=6
2=5
3=1
5=2
6=9
7=9
9=99
\ No newline at end of file \ No newline at end of file
00=99
01=01
02=02
03=03
04=04
05=05
06=06
07=07
08=08
09=09
10=10
11=11
12=12
13=13
14=14
15=15
16=16
17=17
18=99
19=99
20=20
21=21
22=22
23=23
24=24
25=25
31=99
32=99
99=99
\ No newline at end of file \ No newline at end of file
59=59
47=47
60=60
17=17
01=01
40=40
55=55
58=58
20=20
65=65
66=66
67=67
69=69
46=46
12=12
05=1345
53=53
25=1345
68=1345
45=45
56=56
29=29
10=1625
02=02
21=21
24=24
09=1625
31=31
54=54
26=26
13=6095
11=6095
28=28
18=18
03=03
06=1117
61=61
52=52
15=15
64=64
49=49
19=19
41=41
42=1625
43=1625
44=1625
38=1223
36=1240
27=27
57=57
51=51
33=33
14=6095
16=16
04=10396
23=23
37=37
07=07
48=48
50=50
22=22
30=10396
62=62
63=63
70=1719
71=71
72=72
73=73
74=74
75=75
76=76
77=1119
78=78
08=1625
79=79
83=70112
82=82
80=80
81=81
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="logs" />
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS,GMT+8}] [%-5level] [%thread] %logger{50} - %msg%n" />
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
<!-- 设置字符集 -->
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 记录XML数据 -->
<appender name="XML_DATA_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/send_jgj_kafka.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] - %msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/send_jgj_kafka/data-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 记录繁星错误数据 -->
<appender name="FANXING_ERROR_DATA_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/fanxing_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] - %msg%n</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/fanxing_error/data-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="XML_DATA_LOGGER">
<appender-ref ref="XML_DATA_APPENDER" />
</logger>
<logger name="FANXING_ERROR_DATA_LOGGER">
<appender-ref ref="FANXING_ERROR_DATA_APPENDER" />
</logger>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
package com.viontech;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class FanxingDockingGb1400ApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!