Przeglądaj źródła

测试版本1

master
bin 3 lat temu
rodzic
commit
67694049bf
99 zmienionych plików z 8548 dodań i 0 usunięć
  1. +31
    -0
      .gitignore
  2. +118
    -0
      .mvn/wrapper/MavenWrapperDownloader.java
  3. BIN
      .mvn/wrapper/maven-wrapper.jar
  4. +2
    -0
      .mvn/wrapper/maven-wrapper.properties
  5. +10
    -0
      Dockerfile
  6. +310
    -0
      mvnw
  7. +182
    -0
      mvnw.cmd
  8. +210
    -0
      pom.xml
  9. +15
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/CenterApplication.java
  10. +16
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/aop/ControllerExceptionHandle.java
  11. +60
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/aop/ControllerLogAop.java
  12. +302
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java
  13. +28
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/TestController.java
  14. +233
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/DianxinGzDeviceConfig.java
  15. +6
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDeviceFlagType.java
  16. +34
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDevicePower.java
  17. +129
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDeviceStatus.java
  18. +56
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZAskLocation.java
  19. +28
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZAskSetting.java
  20. +531
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZDeviceConfigBase.java
  21. +64
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZHeart.java
  22. +124
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocation.java
  23. +66
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationCDMA.java
  24. +62
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationExtend.java
  25. +70
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationGSM.java
  26. +114
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationInterval.java
  27. +70
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationLTE.java
  28. +67
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationWIFI.java
  29. +58
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationWIFIItem.java
  30. +136
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZPlatformCmd.java
  31. +30
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZPlatformDeviceConfig.java
  32. +31
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpDeviceConfig.java
  33. +33
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZNetType.java
  34. +117
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZRequest.java
  35. +13
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZRequestStatus.java
  36. +45
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponse.java
  37. +41
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponseStatus.java
  38. +195
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDevice.java
  39. +55
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceCommandvalue.java
  40. +125
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceConfig.java
  41. +176
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceStatus.java
  42. +11
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IMessageContent.java
  43. +24
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiActiveDevice.java
  44. +37
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiLocationMode.java
  45. +95
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiNotDisturb.java
  46. +40
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiResponse.java
  47. +88
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiSleepTime.java
  48. +128
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java
  49. +44
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTDeviceConfig.java
  50. +53
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTDeviceStatus.java
  51. +100
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTGps.java
  52. +118
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTLbs.java
  53. +178
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTWifi.java
  54. +24
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOTDevice.java
  55. +21
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZMessageContentFactory.java
  56. +63
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java
  57. +25
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZServiceFactory.java
  58. +70
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClient.java
  59. +24
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClientHandle.java
  60. +32
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClientInitilizer.java
  61. +54
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServer.java
  62. +31
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServerHandler.java
  63. +18
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServerInitializer.java
  64. +85
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java
  65. +65
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java
  66. +51
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java
  67. +21
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/RefreshAliPhotoJob.java
  68. +21
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/repository/DianxinGzDeviceConfigMapper.java
  69. +19
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceCommandvalueMapper.java
  70. +17
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceConfigMapper.java
  71. +17
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceMapper.java
  72. +19
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceStatusMapper.java
  73. +4
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZLocationService.java
  74. +4
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformCmdService.java
  75. +12
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java
  76. +6
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformSettingService.java
  77. +112
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java
  78. +178
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java
  79. +23
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/ApplicationContextProvider.java
  80. +141
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/ByteUtil.java
  81. +114
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/DateUtil.java
  82. +40
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java
  83. +272
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java
  84. +77
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/HelperUtil.java
  85. +60
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/IOTApiUtil.java
  86. +99
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/OkHttpUtil.java
  87. +30
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/RedisUtil.java
  88. +26
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/Runner.java
  89. +213
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/SnowFlakeGenerator.java
  90. +151
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/UnicodeUtil.java
  91. +57
    -0
      src/main/resources/application.properties
  92. BIN
      src/main/resources/font/NotoSerifCJKsc-Medium.otf
  93. +49
    -0
      src/main/resources/generatorConfig.xml
  94. +313
    -0
      src/main/resources/mapper/DianxinGzDeviceConfigMapper.xml
  95. +107
    -0
      src/main/resources/mapper/GpsDeviceCommandvalueMapper.xml
  96. +178
    -0
      src/main/resources/mapper/GpsDeviceConfigMapper.xml
  97. +259
    -0
      src/main/resources/mapper/GpsDeviceMapper.xml
  98. +237
    -0
      src/main/resources/mapper/GpsDeviceStatusMapper.xml
  99. +200
    -0
      src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java

+ 31
- 0
.gitignore Wyświetl plik

@@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### 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/

### VS Code ###
.vscode/

+ 118
- 0
.mvn/wrapper/MavenWrapperDownloader.java Wyświetl plik

@@ -0,0 +1,118 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed 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.
*/

import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.5";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}

BIN
.mvn/wrapper/maven-wrapper.jar Wyświetl plik


+ 2
- 0
.mvn/wrapper/maven-wrapper.properties Wyświetl plik

@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

+ 10
- 0
Dockerfile Wyświetl plik

@@ -0,0 +1,10 @@
FROM java:8

MAINTAINER telpo

VOLUME /tmp
ADD target/dianxin-guizhou-forward-telpo0.0.2.jar app.jar

EXPOSE 8102

ENTRYPOINT ["java","-jar", "/app.jar"]

+ 310
- 0
mvnw Wyświetl plik

@@ -0,0 +1,310 @@
#!/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.
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
# Maven2 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 /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="`which 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/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.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"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$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 \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 182
- 0
mvnw.cmd Wyświetl plik

@@ -0,0 +1,182 @@
@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 Maven2 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 key stroke 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"

FOR /F "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%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%

exit /B %ERROR_CODE%

+ 210
- 0
pom.xml Wyświetl plik

@@ -0,0 +1,210 @@
<?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.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ssjl.zhaobiao.guizhou</groupId>
<artifactId>dianxin-guizhou-forward</artifactId>
<version>telpo0.0.2</version>
<name>dianxin-guizhou-forward</name>
<description>convert protocol between ssjl and dianxin guizhou</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-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.paho/org.eclipse.paho.client.mqttv3 -->
<!--<dependency>-->
<!--<groupId>org.eclipse.paho</groupId>-->
<!--<artifactId>org.eclipse.paho.client.mqttv3</artifactId>-->
<!--<version>1.2.2</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>

<!--<dependency>-->
<!--<groupId>com.aliyun</groupId>-->
<!--<artifactId>aliyun-java-sdk-core</artifactId>-->
<!--<version>4.4.9</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.aliyun</groupId>-->
<!--<artifactId>aliyun-java-sdk-linkface</artifactId>-->
<!--<version>1.2.0</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.google.code.gson</groupId>-->
<!--<artifactId>gson</artifactId>-->
<!--<version>2.8.5</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.google.guava</groupId>-->
<!--<artifactId>guava</artifactId>-->
<!--<version>19.0</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<!--<dependency>-->
<!--<groupId>redis.clients</groupId>-->
<!--<artifactId>jedis</artifactId>-->
<!--<version>3.3.0</version>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/com.rabbitmq/amqp-client -->
<!--<dependency>-->
<!--<groupId>com.rabbitmq</groupId>-->
<!--<artifactId>amqp-client</artifactId>-->
<!--<version>5.9.0</version>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<!--<dependency>-->
<!--<groupId>io.netty</groupId>-->
<!--<artifactId>netty-all</artifactId>-->
<!--<version>4.1.56.Final</version>-->
<!--</dependency>-->

<!--&lt;!&ndash; https://mvnrepository.com/artifact/com.itextpdf/itext7-core &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>com.itextpdf</groupId>-->
<!--<artifactId>itext7-core</artifactId>-->
<!--<version>7.1.11</version>-->
<!--<type>pom</type>-->
<!--</dependency>-->
<!--&lt;!&ndash; https://mvnrepository.com/artifact/com.itextpdf/font-asian &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>com.itextpdf</groupId>-->
<!--<artifactId>font-asian</artifactId>-->
<!--<version>7.1.11</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->




</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--mybatis自动生成代码插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<configuration>
<!-- 是否覆盖,true表示会替换生成的JAVA文件,false则不覆盖 -->
<overwrite>false</overwrite>
</configuration>
<dependencies>
<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
</dependencies>

</plugin>
<!-- Dockerfile -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>false</skip>
<repository>${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>

+ 15
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/CenterApplication.java Wyświetl plik

@@ -0,0 +1,15 @@
package com.ssjl.zhaobiao.guizhou;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.ssjl.zhaobiao.guizhou.repository")
public class CenterApplication {

public static void main(String[] args) {
SpringApplication.run(CenterApplication.class, args);
}

}

+ 16
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/aop/ControllerExceptionHandle.java Wyświetl plik

@@ -0,0 +1,16 @@
package com.ssjl.zhaobiao.guizhou.aop;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerExceptionHandle {

@ExceptionHandler(Exception.class)
@ResponseBody
public String controllerException(Exception e) {
e.printStackTrace();
return "error";
}
}

+ 60
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/aop/ControllerLogAop.java Wyświetl plik

@@ -0,0 +1,60 @@
package com.ssjl.zhaobiao.guizhou.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

@Aspect
@Component
@Slf4j
public class ControllerLogAop {
@Pointcut("execution(public * com.ssjl.zhaobiao.guizhou.controller.*.*(..))")
public void webLog() {
}

@Before("webLog()")
public void doBefore(JoinPoint joinPoint) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
log.info("URL : " + request.getRequestURL().toString());
log.info("http_method : " + request.getMethod());
log.info("ip : " + request.getRemoteAddr());
log.info("class_method : " + joinPoint.getSignature().getDeclaringTypeName()
+ "." + joinPoint.getSignature().getName());
log.info("args : " + Arrays.toString(joinPoint.getArgs()));
}

@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) {
log.info("方法返回的值 : " + ret);
}

@AfterThrowing(throwing = "ex", pointcut = "webLog()")
public void doThrows(Exception ex) throws Throwable {
log.error("异常 : ", ex);
}

@After("webLog()")
public void doAfter(JoinPoint joinpoint) {
log.info("最后执行:");
}

// @Around("webLog()")
// public Object doAround(ProceedingJoinPoint joinPoint){
// log.info("方法环绕start……");
// try{
// Object obj = joinPoint.proceed();
// log.info("方法环绕proceed,结果是"+obj);
// return obj;
// } catch (Throwable throwable) {
// log.error("环绕异常:" + throwable.toString());
// return null;
// }
// }
}

+ 302
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java Wyświetl plik

@@ -0,0 +1,302 @@
package com.ssjl.zhaobiao.guizhou.controller;

import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
//import com.google.gson.annotations.JsonAdapter;
import com.ssjl.zhaobiao.guizhou.entity.*;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.*;
import com.ssjl.zhaobiao.guizhou.entity.IOT.*;
import com.ssjl.zhaobiao.guizhou.entity.IOT.Api.IotApiActiveDevice;
import com.ssjl.zhaobiao.guizhou.entity.IOT.Api.IotApiResponse;
import com.ssjl.zhaobiao.guizhou.handle.GZResponseHandle;
import com.ssjl.zhaobiao.guizhou.repository.DianxinGzDeviceConfigMapper;
import com.ssjl.zhaobiao.guizhou.repository.GpsDeviceStatusMapper;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformCmdService;
import com.ssjl.zhaobiao.guizhou.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/iot")
public class IotController {

@Autowired
IGZPlatformCmdService cmdService;
@Autowired
GZHttpUtil httpUtil;
@Autowired
GZResponseHandle responseHandle;
@Autowired
GpsDeviceStatusMapper gpsDeviceStatusMapper;
@Autowired
DianxinGzDeviceConfigMapper dianxinGzDeviceConfigMapper;
@Autowired
OkHttpUtil okHttpUtil;
@Autowired
IOTApiUtil iotApiUtil;
@Value("${guizhou.device.zhizhong}")
String zhizhongDevices;
@Value("${guizhou.device.zhanneng}")
String zhannengDevices;
@Value("${guizhou.device.tianbo}")
String tianboDevice;
@Value("${guizhou.http.zhizhong}")
String zhizhongUrl;
@Value("${guizhou.http.zhanneng}")
String zhannengUrl;
@Value("${guizhou.factory}")
String factory;

@RequestMapping("/online")
public String online(String imei) throws IOException {
// 接收到上线消息,则认为是开机。开机流程有两种,根据电信平台返回的情况而定
// 1.1 终端主动向平台发起数据链接, 并发送位置信息, 消息参见 4.2.8;
//1.2 平台发起立即查询, 参见 4.2.2, 发送的消息为表 4-3 中的立即上报终端信息, 需要查询的
//参数包括终端执行的协议版本号、 终端型号、 终端型号生产厂家、 终端 IMSI 号、 终端软件版本号, 为
//表 4-1-3 中的参数类型 u、 v、 x、 y、 z。 与数据库原保存数据比对;
//1.3 平台返回“转发短信到指到号码” 的指令, 数据指令参见 4.2.3, 短信内容见 5.2.1;
//1.4 终端执行“转发短信到指到号码” 的指令, 并等待 20 - 30 秒;
//1.5 终端向平台发送中 4.2.9 的指令消息;
//1.6 平台返回全部配置;
//1.7 终端上行应答指令;
//1.8 平台通过数据通道向终端发送 4.2.3 中的消息, 命令终端转发开关机提醒短信;
//1.9 终端按照步骤 1.8 中的命令, 向监护人终端发送短信提醒。
//注: 当终端没有设置本机号码时, 步骤中 1.1, 1.5 中的终端号码为终端机器 MEID 码, 见 4.1.3.7
//中的 D

// 2.1 终端主动向平台发起数据链接, 并发送位置信息, 消息参见 4.2.8;
//2.2 平台发起立即查询, 参见 4.2.2, 发送的消息为表 4-3 中的立即上报终端信息, 需要查询的
//参数包括终端执行的协议版本号、 终端型号、 终端型号生产厂家、 终端 IMSI 号、 终端软件版本号,
//为表 4-1-3 中的参数类型 u、 v、 x、 y、 z。 与数据库原保存数据比对;
//2.3 平台返回全部配置;
//2.4 终端上行应答指令;
//2.5 平台通过数据通道向终端发送 4.2.3 中的消息, 命令终端转发开关机提醒短信;
//2.6 终端按照步骤 1.8 中的命令, 向监护人终端发送短信提醒。
log.info(imei + "上线");
if(!checkImei(imei, "/online", "")){
return "success";
}
GZLocationCDMA cdma = new GZLocationCDMA();
GZLocationExtend extend = new GZLocationExtend();
extend.setNetType(GZNetType.CDMA);
extend.setData1(cdma);
byte[] bid = { 0x00, 0x02 };
cdma.setBID(bid);
byte[] sid = {0x22, 0x41};
cdma.setSID(sid);
byte[] nid = { 0x36, 0x14};
cdma.setNID(nid);

GZDeviceStatus deviceStatus = new GZDeviceStatus();
deviceStatus.setOpenFirst(true);
GZDevicePower devicePower = new GZDevicePower();
devicePower.setCharge(false);
devicePower.setPower(10);
GZAskLocation askLocation = new GZAskLocation(imei, 0,0,0,1,0,0,
0,0,0,0, deviceStatus, devicePower, 0, 0, true, extend);

GZRequest req = new GZRequest();
req.setImei(imei);
req.setIndex(GZUtil.getMessageIndex());
req.setStatus(GZRequestStatus.RESPONSE_ALL);
req.setContent(askLocation);
byte[] res = httpUtil.send(imei, "", req);
System.out.println(ByteUtil.bytesToHexString(res));
// 调用IOTAPI激活设备
log.info(imei + "激活设备");
IotApiActiveDevice active = new IotApiActiveDevice();
active.setSerialNo(imei);
active.setCommandType(1);
IotApiResponse rs = iotApiUtil.activeDevice(active);
System.out.println(JSON.toJSONString(rs));
log.info(imei + "激活返回:" + JSON.toJSONString(rs));
// 处理电信返回数据
res = (byte[]) responseHandle.process(res);
System.out.println(ByteUtil.bytesToHexString(res));
log.info(imei + "电信返回:" + ByteUtil.bytesToHexString(res));
return "success";
}

@RequestMapping("/gps")
public String gpsHandle(@RequestBody IOTGps gps, String imei) throws IOException {
log.info(imei + ":gps ");
if(!checkImei(imei, "/gps", JSON.toJSONString(gps))){
log.info(imei + ",gps not in device");
return "not in device";
}
DianxinGzDeviceConfig gzDeviceConfig = dianxinGzDeviceConfigMapper.selectByImei(imei);
if(!isAtLocationTime(gzDeviceConfig.getLocationInterval())){
log.info(imei + ",gps not in time");
return "not in time";
}
log.info(imei + ",gps ,v=" + JSON.toJSONString(gps));
// 没有基站数据,先写死
GZRequest req = new GZRequest();
gps.setImei(imei);
req.setImei(gps.getImei());
req.setIndex(GZUtil.getMessageIndex());
req.setStatus(GZRequestStatus.RESPONSE_NO);
GZLocationCDMA cdma = new GZLocationCDMA();
GZLocationExtend extend = new GZLocationExtend();
extend.setNetType(GZNetType.CDMA);
extend.setData1(cdma);
byte[] bid = { 0x00, 0x02 };
cdma.setBID(bid);
byte[] sid = {0x22, 0x41};
cdma.setSID(sid);
byte[] nid = { 0x36, 0x14};
cdma.setNID(nid);
GZDeviceStatus deviceStatus = new GZDeviceStatus();
// deviceStatus.setOpenFirst(true);
GpsDeviceStatus gpsDeviceStatus = gpsDeviceStatusMapper.selectByImei(gps.getImei());
IOTDeviceStatus iotDeviceStatus = IOTDeviceStatus.build(gpsDeviceStatus.getDeviceStatus());
GZDevicePower power = new GZDevicePower();
power.setCharge(false);
power.setPower(iotDeviceStatus.getBattery());

LocalDateTime time = LocalDateTime.now();


GZLocation location = new GZLocation(time.getHour(), time.getMinute(),time.getSecond(), time.getDayOfMonth(),
GZUtil.convertLocation(gps.getLatitude()), 0, GZUtil.convertLocation(gps.getLongitude()), 0, 0, 0,
deviceStatus, power, 70, 3, false, extend);
req.setContent(location);
byte[] b = req.toByte();
System.out.println(ByteUtil.bytesToHexString(b));
String phone = gzDeviceConfig == null ? "" : gzDeviceConfig.getPhone();
byte[] res = httpUtil.send(imei, phone, req);
log.info(imei + ",gps 电信返回:" + ByteUtil.bytesToHexString(res));
System.out.println(ByteUtil.bytesToHexString(res));
return "success";
}

@RequestMapping("/lbs")
public String lbsHandle(@RequestBody IOTLbs lbs, String imei) throws IOException {
log.info(imei + ",lbs");
if(!checkImei(imei, "/lbs", JSON.toJSONString(lbs))){
log.info(imei + ",lbs not in device");
return "not in device";
}
DianxinGzDeviceConfig gzDeviceConfig = dianxinGzDeviceConfigMapper.selectByImei(imei);
if(!isAtLocationTime(gzDeviceConfig.getLocationInterval())){
log.info(imei + ",lbs not in time");
return "not in time";
}
log.info(imei + "lbs,v=" + JSON.toJSONString(lbs));
GpsDeviceStatus gpsDeviceStatus = gpsDeviceStatusMapper.selectByImei(imei);
IOTDeviceStatus iotDeviceStatus = IOTDeviceStatus.build(gpsDeviceStatus.getDeviceStatus());
GZDevicePower power = new GZDevicePower();
power.setCharge(false);
power.setPower(iotDeviceStatus.getBattery());
GZDeviceStatus deviceStatus = new GZDeviceStatus();
LocalDateTime time = LocalDateTime.now();
GZLocationExtend extend = new GZLocationExtend();
GZLocation location;
if(lbs.getCdma().equals("0")){
// GSM
GZLocationGSM gsm = GZUtil.toGSM(lbs.getBts(), lbs.getNearbts());
extend.setNetType(GZNetType.GSM);
extend.setData1(gsm);
location = new GZLocation(time.getHour(), time.getMinute(),time.getSecond(), time.getDayOfMonth(),
0, 0, 0, 0, 0, 0,
deviceStatus, power, 70, 0, true, extend);
}else{
// CDMA
String[] bts = lbs.getBts().split(",");
GZLocationCDMA cdma = new GZLocationCDMA();
cdma.setSID(ByteUtil.toByte(Integer.parseInt(bts[0]), 2));
cdma.setNID(ByteUtil.toByte(Integer.parseInt(bts[1]), 2));
cdma.setBID(ByteUtil.toByte(Integer.parseInt(bts[2]), 2));
double lat = Double.parseDouble(Strings.isNullOrEmpty(bts[3]) ? bts[3] : "0");
double lon = Double.parseDouble(Strings.isNullOrEmpty(bts[4]) ? bts[4] : "0");
int signal = Integer.parseInt(bts[6]);
extend.setNetType(GZNetType.CDMA);
extend.setData1(cdma);
location = new GZLocation(time.getHour(), time.getMinute(),time.getSecond(), time.getDayOfMonth(),
GZUtil.convertLocation(lat), 0, GZUtil.convertLocation(lon), 0, 0, 0,
deviceStatus, power, signal, 0, true, extend);
}

byte[] res = httpUtil.send(imei, gzDeviceConfig.getPhone(), location);
System.out.println(ByteUtil.bytesToHexString(res));
log.info(imei + ",lbs 电信返回:" + ByteUtil.bytesToHexString(res));
return "success";
}

@RequestMapping("/wifi")
public String wifiHandle(@RequestBody IOTWifi wifi, String imei) throws IOException {
if(!checkImei(imei, "/wifi", JSON.toJSONString(wifi))){
log.info(imei + ",wifi not in device");
return "not in device";
}
DianxinGzDeviceConfig gzDeviceConfig = dianxinGzDeviceConfigMapper.selectByImei(imei);
if(!isAtLocationTime(gzDeviceConfig.getLocationInterval())){
log.info(imei + ",wifi not in time");
return "not in time";
}
log.info(imei + ",wifi ,v=" + JSON.toJSONString(wifi));
GpsDeviceStatus gpsDeviceStatus = gpsDeviceStatusMapper.selectByImei(imei);
IOTDeviceStatus iotDeviceStatus = IOTDeviceStatus.build(gpsDeviceStatus.getDeviceStatus());
GZDevicePower power = new GZDevicePower();
power.setCharge(false);
power.setPower(iotDeviceStatus.getBattery());
GZDeviceStatus deviceStatus = new GZDeviceStatus();
LocalDateTime time = LocalDateTime.now();
GZLocationExtend extend = new GZLocationExtend();
List<GZLocationWIFIItem> itemList = new ArrayList<>();
itemList.add(GZUtil.toWifiItem(wifi.getMmac()));
String[] macs = wifi.getMacs().split("\\|");
if(Strings.isNullOrEmpty(wifi.getMacs())){
macs = new String[0];
}
for (int i = 0; i < macs.length; i++) {
itemList.add(GZUtil.toWifiItem(macs[i]));
}
GZLocationWIFI gzWifi = new GZLocationWIFI(time.getHour(), time.getMinute(), time.getSecond(),itemList.size(), itemList);
extend.setNetType(GZNetType.WIFI);
extend.setData1(gzWifi);
GZLocation location = new GZLocation(time.getHour(), time.getMinute(),time.getSecond(), time.getDayOfMonth(),
0, 0, 0, 0, 0, 0,
deviceStatus, power, 0, 0, true, extend);
byte[] res = httpUtil.send(imei, gzDeviceConfig.getPhone(), location);
System.out.println(ByteUtil.bytesToHexString(res));
log.info(imei + ",wifi 电信返回:" + ByteUtil.bytesToHexString(res));
return "success";
}

private boolean checkImei(String imei, String api, String json) throws IOException {
if(factory.equals("telpo") && tianboDevice.indexOf(imei) > -1){
return true;
}
if(factory.equals("zhizhong") && zhizhongDevices.indexOf(imei) > -1){
return true;
}
if(factory.equals("zhanneng") && zhannengDevices.indexOf(imei) > -1){
return true;
}
// 天波服务负责转发
if(factory.equals("telpo") && zhizhongDevices.indexOf(imei) > -1){
okHttpUtil.postJson(zhizhongUrl + api + "?imei=" + imei, json);
}
if(factory.equals("telpo") && zhannengDevices.indexOf(imei) > -1){
okHttpUtil.postJson(zhannengUrl + api + "?imei=" + imei, json);
}
return false;
}

private boolean isAtLocationTime(String locationInterval){
List<GZLocationInterval> interval = GZLocationInterval.build(locationInterval);
return GZLocationInterval.isIn(LocalDateTime.now(), interval);
}
}

+ 28
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/controller/TestController.java Wyświetl plik

@@ -0,0 +1,28 @@
package com.ssjl.zhaobiao.guizhou.controller;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZResponseStatus;
import com.ssjl.zhaobiao.guizhou.utils.OkHttpUtil;
import com.ssjl.zhaobiao.guizhou.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.text.ParseException;

@RestController
@RequestMapping("/test")
public class TestController {
@Autowired
OkHttpUtil httpUtil;


@RequestMapping("/test")
public String test() throws IOException, ParseException {

return "success";
}

}

+ 233
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/DianxinGzDeviceConfig.java Wyświetl plik

@@ -0,0 +1,233 @@
package com.ssjl.zhaobiao.guizhou.entity;

public class DianxinGzDeviceConfig {
private Integer id;

private String deviceImei;

private String httpIp;

private String httpUrl;

private String smsNumber;

private String locationInterval;

private String sleepTime;

private String affectionPhone;

private String sosPhone;

private String whitePhone;

private String smsWhitePhone;

private String phone;

private String clockTime;

private String smsSet;

private String addressBook;

private String syncTime;

private String tcpAddress;

private String autoShutdown;

private String callTime;

private String locationMode;

private String connectType;

private String phoneType;

private String rfid;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getDeviceImei() {
return deviceImei;
}

public void setDeviceImei(String deviceImei) {
this.deviceImei = deviceImei == null ? null : deviceImei.trim();
}

public String getHttpIp() {
return httpIp;
}

public void setHttpIp(String httpIp) {
this.httpIp = httpIp == null ? null : httpIp.trim();
}

public String getHttpUrl() {
return httpUrl;
}

public void setHttpUrl(String httpUrl) {
this.httpUrl = httpUrl == null ? null : httpUrl.trim();
}

public String getSmsNumber() {
return smsNumber;
}

public void setSmsNumber(String smsNumber) {
this.smsNumber = smsNumber == null ? null : smsNumber.trim();
}

public String getLocationInterval() {
return locationInterval;
}

public void setLocationInterval(String locationInterval) {
this.locationInterval = locationInterval == null ? null : locationInterval.trim();
}

public String getSleepTime() {
return sleepTime;
}

public void setSleepTime(String sleepTime) {
this.sleepTime = sleepTime == null ? null : sleepTime.trim();
}

public String getAffectionPhone() {
return affectionPhone;
}

public void setAffectionPhone(String affectionPhone) {
this.affectionPhone = affectionPhone == null ? null : affectionPhone.trim();
}

public String getSosPhone() {
return sosPhone;
}

public void setSosPhone(String sosPhone) {
this.sosPhone = sosPhone == null ? null : sosPhone.trim();
}

public String getWhitePhone() {
return whitePhone;
}

public void setWhitePhone(String whitePhone) {
this.whitePhone = whitePhone == null ? null : whitePhone.trim();
}

public String getSmsWhitePhone() {
return smsWhitePhone;
}

public void setSmsWhitePhone(String smsWhitePhone) {
this.smsWhitePhone = smsWhitePhone == null ? null : smsWhitePhone.trim();
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}

public String getClockTime() {
return clockTime;
}

public void setClockTime(String clockTime) {
this.clockTime = clockTime == null ? null : clockTime.trim();
}

public String getSmsSet() {
return smsSet;
}

public void setSmsSet(String smsSet) {
this.smsSet = smsSet == null ? null : smsSet.trim();
}

public String getAddressBook() {
return addressBook;
}

public void setAddressBook(String addressBook) {
this.addressBook = addressBook == null ? null : addressBook.trim();
}

public String getSyncTime() {
return syncTime;
}

public void setSyncTime(String syncTime) {
this.syncTime = syncTime == null ? null : syncTime.trim();
}

public String getTcpAddress() {
return tcpAddress;
}

public void setTcpAddress(String tcpAddress) {
this.tcpAddress = tcpAddress == null ? null : tcpAddress.trim();
}

public String getAutoShutdown() {
return autoShutdown;
}

public void setAutoShutdown(String autoShutdown) {
this.autoShutdown = autoShutdown == null ? null : autoShutdown.trim();
}

public String getCallTime() {
return callTime;
}

public void setCallTime(String callTime) {
this.callTime = callTime == null ? null : callTime.trim();
}

public String getLocationMode() {
return locationMode;
}

public void setLocationMode(String locationMode) {
this.locationMode = locationMode == null ? null : locationMode.trim();
}

public String getConnectType() {
return connectType;
}

public void setConnectType(String connectType) {
this.connectType = connectType == null ? null : connectType.trim();
}

public String getPhoneType() {
return phoneType;
}

public void setPhoneType(String phoneType) {
this.phoneType = phoneType == null ? null : phoneType.trim();
}

public String getRfid() {
return rfid;
}

public void setRfid(String rfid) {
this.rfid = rfid == null ? null : rfid.trim();
}
}

+ 6
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDeviceFlagType.java Wyświetl plik

@@ -0,0 +1,6 @@
package com.ssjl.zhaobiao.guizhou.entity;

public enum GZDeviceFlagType {
PHONE,
IMEI
}

+ 34
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDevicePower.java Wyświetl plik

@@ -0,0 +1,34 @@
package com.ssjl.zhaobiao.guizhou.entity;

import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GZDevicePower {
@Autowired
ByteUtil byteUtil;
private boolean charge;
private int power;

public boolean isCharge() {
return charge;
}

public void setCharge(boolean charge) {
this.charge = charge;
}

public int getPower() {
return power;
}

public void setPower(int power) {
this.power = power;
}

public byte toByte(){
byte b = byteUtil.toByte(power, 1)[0];
return (byte)(charge ? 0x80 | b : b);
}
}

+ 129
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZDeviceStatus.java Wyświetl plik

@@ -0,0 +1,129 @@
package com.ssjl.zhaobiao.guizhou.entity;

import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GZDeviceStatus {
@Autowired
ByteUtil byteUtil;
/**
* @description SOS告警
*/
private boolean isSOS;
/**
* 电池电压低
*/
private boolean isPowerLow;
/**
* 休眠状态
*/
private boolean isSleep;
// 电量低关机
private boolean isPowerLowShutdown;
// 主动关机 ,当终端按键关机, 置1
private boolean isManualShutdown;
// 第开机,仅在开机时的第一条上报消息中置1
private boolean isOpenFirst;
// 省电模式,
private boolean isPowerSave;
// 命令关机,当终端定时关机, 或远程关机, 置1
private boolean isCmdShutdown;

public GZDeviceStatus(){
isSOS = false;
isPowerLow = false;
isSleep = false;
isPowerLowShutdown = false;
isManualShutdown = false;
isOpenFirst = false;
isPowerSave = false;
isCmdShutdown = false;
}


public boolean isSOS() {
return isSOS;
}

public void setSOS(boolean SOS) {
isSOS = SOS;
}

public boolean isPowerLow() {
return isPowerLow;
}

public void setPowerLow(boolean powerLow) {
isPowerLow = powerLow;
}

public boolean isSleep() {
return isSleep;
}

public void setSleep(boolean sleep) {
isSleep = sleep;
}

public boolean isPowerLowShutdown() {
return isPowerLowShutdown;
}

public void setPowerLowShutdown(boolean powerLowShutdown) {
isPowerLowShutdown = powerLowShutdown;
}

public boolean isManualShutdown() {
return isManualShutdown;
}

public void setManualShutdown(boolean manualShutdown) {
isManualShutdown = manualShutdown;
}

public boolean isOpenFirst() {
return isOpenFirst;
}

public void setOpenFirst(boolean openFirst) {
isOpenFirst = openFirst;
}

public boolean isPowerSave() {
return isPowerSave;
}

public void setPowerSave(boolean powerSave) {
isPowerSave = powerSave;
}

public boolean isCmdShutdown() {
return isCmdShutdown;
}

public void setCmdShutdown(boolean cmdShutdown) {
isCmdShutdown = cmdShutdown;
}

public byte[] toBytes(){
int s = isCmdShutdown ? 1 : 0;
s = s << 1;
s = isPowerSave ? s | 1 : s;
s = s << 1;
s = isOpenFirst ? s | 1 : s;
s = s << 1;
s = isManualShutdown ? s | 1 : s;
s = s << 1;
s = isPowerLowShutdown ? s | 1 : s;
s = s << 1;
s = isSleep ? s | 1 : s;
s = s << 1;
s = isPowerLow ? s | 1 : s;
s = s << 1;
s = isSOS ? s | 1 : s;
s = s << 8;
return byteUtil.toByte(s, 2);
}
}

+ 56
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZAskLocation.java Wyświetl plik

@@ -0,0 +1,56 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZDevicePower;
import com.ssjl.zhaobiao.guizhou.entity.GZDeviceStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;

public class GZAskLocation extends GZLocation implements IMessageContent {

private String imei;

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public GZAskLocation(String imei, int hour, int minute, int second, int day, int latitude, int latitudeDirect, int longitude, int longitudeDirect,
int speed, int direct, GZDeviceStatus status, GZDevicePower power, int signalIntensity, int gpsAmount, boolean gpsRough, GZLocationExtend extend){
super(hour, minute, second, day, latitude, latitudeDirect, longitude, longitudeDirect,
speed, direct, status, power, signalIntensity, gpsAmount, gpsRough, extend);
this.imei = imei;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0x14;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] locationBytes = super.toBytes();
int length = locationBytes.length + 8;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte)getTag();
byte[] imeiBytes = GZUtil.imeiToByte(imei);
System.arraycopy(imeiBytes, 0, list, i, imeiBytes.length);
i += imeiBytes.length;
System.arraycopy(locationBytes, 1, list, i, locationBytes.length - 1);
return list;
}
}

+ 28
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZAskSetting.java Wyświetl plik

@@ -0,0 +1,28 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZAskSetting implements IMessageContent {
@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0x13;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] list = new byte[1];
list[0] = (byte)getTag();
return list;
}
}

+ 531
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZDeviceConfigBase.java Wyświetl plik

@@ -0,0 +1,531 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.google.common.base.Strings;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class GZDeviceConfigBase {
/**
* 终端管理平台HTTP/IP地址
*/
private String httpIp;
/**
* 终端管理平台HTTP域名
*/
private String httpUrl;
/**
* 终端管理平台短信接入号
*/
private String smsNo;
/**
* 位置上报间隔时间
*/
private String locationInterval;
/**
* 休眠时间
*/
private String sleepTime;
/**
* 亲情号码
*/
private String affectionPhone;
/**
* 设定SOS绑定号码
*/
private String sosPhone;
/**
* 允许呼入号码
*/
private String whiteList;
/**
* 允许接收的短信号码
*/
private String smsWhiteList;
/**
* 终端的本机号码
*/
private String devicePhone;
/**
* 闹钟时间
*/
private String clockTime;
/**
* 短信息设置
*/
private String smsSet;
/**
* 通讯录
*/
private String addressBook;
/**
* 同步平台配置时间点
*/
private String syncTime;
/**
* 终端管理平台TCP/IP地址
*/
private String tcp;
/**
* 自动开关机设置
*/
private String autoShutdownSet;
/**
* 通话分钟设置
*/
private String callTimeSet;
/**
* 定位模式设置
*/
private String locationModeSet;
/**
* TCP/HTTP通讯方式选择
*/
private String connectType;
/**
* 本机号码标识类型
*/
private String phoneNoType;
/**
* 终端rfid号
*/
private String rfid;
/**
* 运营商类型,当前接入网络制式
* 运营商类型:
* 电信为 0, 移动为 1, 联通为 2, 其它为 3
* 当前接入网络制式:
* GSM/GPRS/EDGE/HSUPA/HSDPA/WCDMA/TD-LTE/FDD-LTE
* 例: 0,WCDMA
*/
private String operator;
/**
* 终端IMEI号
*/
private String imei;
/**
* 通信协议版本号, 统一为 4 个数据, 中间加“.” 的格式: XX.X
* (必需填写, 平台对协议作兼容处理)
*/
private String protocol;
/**
* 产品型号
*/
private String deviceModel;
/**
* 终端软件 APP 版本号
*/
private String appVersion;
/**
* 生产厂家名字
*/
private String facotryName;
/**
* IMSI 号, 手机卡移动用户识别码
*/
private String imsi;
/**
* 终端系统版本号
*/
private String deviceVersion;


public String getHttpIp() {
return httpIp;
}

public void setHttpIp(String httpIp) {
this.httpIp = httpIp;
}

public String getHttpUrl() {
return httpUrl;
}

public void setHttpUrl(String httpUrl) {
this.httpUrl = httpUrl;
}

public String getSmsNo() {
return smsNo;
}

public void setSmsNo(String smsNo) {
this.smsNo = smsNo;
}

public String getLocationInterval() {
return locationInterval;
}

public void setLocationInterval(String locationInterval) {
this.locationInterval = locationInterval;
}

public String getSleepTime() {
return sleepTime;
}

public void setSleepTime(String sleepTime) {
this.sleepTime = sleepTime;
}

public String getAffectionPhone() {
return affectionPhone;
}

public void setAffectionPhone(String affectionPhone) {
this.affectionPhone = affectionPhone;
}

public String getSosPhone() {
return sosPhone;
}

public void setSosPhone(String sosPhone) {
this.sosPhone = sosPhone;
}

public String getWhiteList() {
return whiteList;
}

public void setWhiteList(String whiteList) {
this.whiteList = whiteList;
}

public String getSmsWhiteList() {
return smsWhiteList;
}

public void setSmsWhiteList(String smsWhiteList) {
this.smsWhiteList = smsWhiteList;
}

public String getDevicePhone() {
return devicePhone;
}

public void setDevicePhone(String devicePhone) {
this.devicePhone = devicePhone;
}

public String getClockTime() {
return clockTime;
}

public void setClockTime(String clockTime) {
this.clockTime = clockTime;
}

public String getSmsSet() {
return smsSet;
}

public void setSmsSet(String smsSet) {
this.smsSet = smsSet;
}

public String getAddressBook() {
return addressBook;
}

public void setAddressBook(String addressBook) {
this.addressBook = addressBook;
}

public String getSyncTime() {
return syncTime;
}

public void setSyncTime(String syncTime) {
this.syncTime = syncTime;
}

public String getTcp() {
return tcp;
}

public void setTcp(String tcp) {
this.tcp = tcp;
}

public String getAutoShutdownSet() {
return autoShutdownSet;
}

public void setAutoShutdownSet(String autoShutdownSet) {
this.autoShutdownSet = autoShutdownSet;
}

public String getCallTimeSet() {
return callTimeSet;
}

public void setCallTimeSet(String callTimeSet) {
this.callTimeSet = callTimeSet;
}

public String getLocationModeSet() {
return locationModeSet;
}

public void setLocationModeSet(String locationModeSet) {
this.locationModeSet = locationModeSet;
}

public String getConnectType() {
return connectType;
}

public void setConnectType(String connectType) {
this.connectType = connectType;
}

public String getPhoneNoType() {
return phoneNoType;
}

public void setPhoneNoType(String phoneNoType) {
this.phoneNoType = phoneNoType;
}

public String getRfid() {
return rfid;
}

public void setRfid(String rfid) {
this.rfid = rfid;
}

public String getOperator() {
return operator;
}

public void setOperator(String operator) {
this.operator = operator;
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

public String getDeviceModel() {
return deviceModel;
}

public void setDeviceModel(String deviceModel) {
this.deviceModel = deviceModel;
}

public String getAppVersion() {
return appVersion;
}

public void setAppVersion(String appVersion) {
this.appVersion = appVersion;
}

public String getFacotryName() {
return facotryName;
}

public void setFacotryName(String facotryName) {
this.facotryName = facotryName;
}

public String getImsi() {
return imsi;
}

public void setImsi(String imsi) {
this.imsi = imsi;
}

public String getDeviceVersion() {
return deviceVersion;
}

public void setDeviceVersion(String deviceVersion) {
this.deviceVersion = deviceVersion;
}

public void init(String setting){
if(Strings.isNullOrEmpty(setting)){
return;
}
String[] sets = setting.split(";");
for (int i = 0; i < sets.length; i++) {
String str = sets[i];
String tag = str.substring(0, 1);
tag = tag.toLowerCase();
String content = str.substring(1);
if(tag.equals("0")){
httpIp = content;
}else if (tag.equals("1")){
httpUrl = content;
}else if(tag.equals("2")){
smsNo = content;
}else if(tag.equals("3")){
locationInterval = content;
}else if(tag.equals("4")){
sleepTime = content;
}else if(tag.equals("5")){
affectionPhone = content;
}else if(tag.equals("6")){
sosPhone = content;
}else if(tag.equals("7")){
whiteList = content;
}else if(tag.equals("8")){
smsWhiteList = content;
}else if(tag.equals("9")){
devicePhone = content;
}else if(tag.equals("a")){
clockTime = content;
}else if(tag.equals("b")){
smsSet = content;
}else if(tag.equals("c")){
addressBook = content;
}else if(tag.equals("d")){
syncTime = content;
}else if(tag.equals("g")){
tcp = content;
}else if(tag.equals("h")){
autoShutdownSet = content;
}else if(tag.equals("j")){
callTimeSet = content;
}else if(tag.equals("l")){
locationModeSet = content;
}else if(tag.equals("m")){
connectType = content;
}else if(tag.equals("n")){
phoneNoType = content;
}else if(tag.equals("r")){
rfid = content;
}else if(tag.equals("s")){
operator = content;
}else if(tag.equals("t")){
imei = content;
}else if(tag.equals("u")){
protocol = content;
}else if(tag.equals("v")){
deviceModel = content;
}else if(tag.equals("w")){
appVersion = content;
}else if(tag.equals("x")){
facotryName = content;
}else if(tag.equals("y")){
imsi = content;
}else if(tag.equals("z")){
deviceVersion = content;
}
}
}

public byte[] toBytes(){
String setting = "";
if(httpIp != null){
setting += "0" + httpIp + ";";
}
if(httpUrl != null){
setting += "1" + httpUrl + ";";
}
if(smsNo != null){
setting += "2" + smsNo + ";";
}
if(locationInterval != null){
setting += "3" + locationInterval + ";";
}
if(sleepTime != null){
setting += "4" + sleepTime + ";";
}
if(affectionPhone != null){
setting += "5" + affectionPhone + ";";
}
if(sosPhone != null){
setting += "6" + sosPhone + ";";
}
if(whiteList != null){
setting += "7" + whiteList + ";";
}
if(smsWhiteList != null){
setting += "8" + smsWhiteList + ";";
}
if(null != devicePhone){
setting += "9" + devicePhone + ";";
}
if(clockTime != null){
setting += "a" + clockTime + ";";
}
if(smsSet != null){
setting += "b" + smsSet + ";";
}
if(addressBook != null){
setting += "c" + addressBook + ";";
}
if(syncTime != null){
setting += "d" + syncTime + ";";
}
if(tcp != null){
setting += "g" + tcp + ";";
}
if(autoShutdownSet != null){
setting += "h" + autoShutdownSet + ";";
}
if(callTimeSet != null){
setting += "j" + callTimeSet + ";";
}
if(locationModeSet != null){
setting += "l" + locationModeSet + ";";
}
if(connectType != null){
setting += "m" + connectType + ";";
}
if(phoneNoType != null){
setting += "n" + phoneNoType + ";";
}
if(rfid != null){
setting += "R" + rfid + ";";
}
if(operator != null){
setting += "S" + operator + ";";
}
if(imei != null){
setting += "T" + imei + ";";
}
if(protocol != null){
setting += "U" + protocol + ";";
}
if(deviceModel != null){
setting += "V" + deviceModel + ";";
}
if(appVersion != null){
setting += "W" + appVersion + ";";
}
if(facotryName != null){
setting += "X" + facotryName + ";";
}
if(imsi != null){
setting += "Y" + imsi + ";";
}
if(deviceVersion != null){
setting += "Z" + deviceVersion + ";";
}
if(setting.length() > 0){
setting = setting.substring(0, setting.length() - 1);
}
return setting.getBytes();
}
}

+ 64
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZHeart.java Wyświetl plik

@@ -0,0 +1,64 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZDevicePower;
import com.ssjl.zhaobiao.guizhou.entity.GZDeviceStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZHeart implements IMessageContent {
private GZDeviceStatus status;
private GZDevicePower power;
private int signalIntensity;

public GZDeviceStatus getStatus() {
return status;
}

public void setStatus(GZDeviceStatus status) {
this.status = status;
}

public GZDevicePower getPower() {
return power;
}

public void setPower(GZDevicePower power) {
this.power = power;
}

public int getSignalIntensity() {
return signalIntensity;
}

public void setSignalIntensity(int signalIntensity) {
this.signalIntensity = signalIntensity;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0x3F;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] list = new byte[5];
int i = 0;
list[i++] = (byte)getTag();
byte[] bytes = status.toBytes();
System.arraycopy(bytes, 0, list, i, bytes.length);
i+=bytes.length;
list[i++] = power.toByte();
list[i++] = (byte) signalIntensity;
return list;
}
}

+ 124
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocation.java Wyświetl plik

@@ -0,0 +1,124 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZDevicePower;
import com.ssjl.zhaobiao.guizhou.entity.GZDeviceStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import org.springframework.beans.factory.annotation.Autowired;

public class GZLocation implements IMessageContent {
private int hour;
private int minute;
private int second;
// 日期
private int day;
/**
* 纬度
*/
private int latitude;
// 0 表示北纬, 1 表示南纬
private int latitudeDirect;
/**
* 经度
*/
private int longitude;
// 0 表示东经, 1 表示西经。
private int longitudeDirect;
// 速度
private int speed;
// 方向 0 度代表正北, 顺时针方向
private int direct;
// 状态和告警
private GZDeviceStatus status;
// 电池电量
private GZDevicePower power;
// 运营商信号强度
private int signalIntensity;
// GPS 有效卫星数量
private int gpsAmount;
// 是否gps粗定位
private boolean gpsRough;

private GZLocationExtend extend;

public GZLocation(int hour, int minute, int second, int day, int latitude, int latitudeDirect, int longitude, int longitudeDirect,
int speed, int direct, GZDeviceStatus status, GZDevicePower power, int signalIntensity, int gpsAmount, boolean gpsRough, GZLocationExtend extend){
this.hour = hour;
this.minute = minute;
this.second = second;
this.day = day;
this.latitude = latitude;
this.latitudeDirect = latitudeDirect;
this.longitude = longitude;
this.longitudeDirect = longitudeDirect;
this.speed = speed;
this.direct = direct;
this.status = status;
this.power = power;
this.signalIntensity = signalIntensity;
this.gpsAmount = gpsAmount;
this.gpsRough = gpsRough;
this.extend = extend;
}



@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0x11;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] cellBytes = extend.toBytes();
int length = 20 + cellBytes.length;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte) getTag();
// 时间
byte[] timeBytes = ByteUtil.hexToByteArray(GZUtil.timeToStr(hour, minute, second));
System.arraycopy(timeBytes, 0, list, i, timeBytes.length);
i+=timeBytes.length;
// 纬度
byte[] labytes = GZUtil.toLocationBytes(latitudeDirect, gpsRough, latitude);
System.arraycopy(labytes, 0, list, i, labytes.length);
i += labytes.length;
// 经度
byte[] lonbytes = GZUtil.toLocationBytes(longitudeDirect, gpsRough, longitude);
System.arraycopy(lonbytes, 0, list, i, lonbytes.length);
i += lonbytes.length;
// 速度
list[i++] = ByteUtil.toByte(speed, 1)[0];
// 方向
list[i++] = ByteUtil.toByte(direct, 1)[0];
// 日期
list[i++] = ByteUtil.hexToByteArray(day < 10 ? "0" + day : day + "")[0];
// 状态和告警
byte[] b = status.toBytes();
System.arraycopy(b, 0, list, i, b.length);
i += b.length;
//电量
list[i++] = power.toByte();
// 信号强度
list[i++] = (byte)signalIntensity;
// 卫星数量
list[i++] = ByteUtil.toByte(gpsAmount, 1)[0];
// 扩展数据
System.arraycopy(cellBytes, 0, list, i, cellBytes.length);
// i += cellBytes.length;
return list;
}
}

+ 66
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationCDMA.java Wyświetl plik

@@ -0,0 +1,66 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

import javax.print.attribute.standard.Sides;


public class GZLocationCDMA implements IMessageContent {
private byte[] SID;
private byte[] NID;
private byte[] BID;

public byte[] getSID() {
return SID;
}

public void setSID(byte[] SID) {
this.SID = SID;
}

public byte[] getNID() {
return NID;
}

public void setNID(byte[] NID) {
this.NID = NID;
}

public byte[] getBID() {
return BID;
}

public void setBID(byte[] BID) {
this.BID = BID;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0xF1;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] list = new byte[7];
int i = 0;
list[i++] = (byte) getTag();
System.arraycopy(SID, 0, list, i, SID.length);
i += SID.length;
System.arraycopy(NID, 0, list, i, NID.length);
i += NID.length;
System.arraycopy(BID, 0, list, i, BID.length);
// i += BID.length;
return list;
}
}

+ 62
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationExtend.java Wyświetl plik

@@ -0,0 +1,62 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZNetType;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZLocationExtend {
private int tag;
private GZNetType netType;
private IMessageContent data1;
private IMessageContent data2;

public GZLocationExtend(){
tag = 0xFA;
}

public GZNetType getNetType() {
return netType;
}

public void setNetType(GZNetType netType) {
this.netType = netType;
}

public IMessageContent getData1() {
return data1;
}

public void setData1(IMessageContent data1) {
this.data1 = data1;
}

public IMessageContent getData2() {
return data2;
}

public void setData2(IMessageContent data2) {
this.data2 = data2;
}

public byte[] toBytes(){
byte[] data1Bytes = data1 == null ? new byte[0] : data1.toBytes();
byte[] data2Bytes = data2 == null ? new byte[0] : data2.toBytes();
int length = 4 + data1Bytes.length + data2Bytes.length;
byte[] list = new byte[length];
int i = 0;
// 总标识
list[i++] = (byte) tag;
// 接入网络方式
list[i++] = (byte) netType.getCode();
// 数据1长度
list[i++] = (byte)(1+data1Bytes.length);
// 数据1
System.arraycopy(data1Bytes, 0, list, i, data1Bytes.length);
i += data1Bytes.length;
// 数据2长度
list[i++] = (byte)(1 + data2Bytes.length);
// 数据2
System.arraycopy(data2Bytes, 0, list, i, data2Bytes.length);
// i += data2Bytes.length;
return list;
}
}

+ 70
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationGSM.java Wyświetl plik

@@ -0,0 +1,70 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZLocationGSM implements IMessageContent {

// 国家编码
private byte[] MCC;
// 运营编码
private byte[] MNC;
// 基站小区编号,基站编号,基站信号强度,基站小区编号,基站编号,基站信号强度
// 从设备里面读取对应的 rxlev, 当不为正数时113, 然后转换为 16 进制
// 最多为 5 个
private byte[] GSMList;

public byte[] getMCC() {
return MCC;
}

public void setMCC(byte[] MCC) {
this.MCC = MCC;
}

public byte[] getMNC() {
return MNC;
}

public void setMNC(byte[] MNC) {
this.MNC = MNC;
}

public byte[] getGSMList() {
return GSMList;
}

public void setGSMList(byte[] GSMList) {
this.GSMList = GSMList;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0xF2;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
int length = 1 + MCC.length + MNC.length + GSMList.length;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte) getTag();
System.arraycopy(MCC, 0, list, i, MCC.length);
i += MCC.length;
System.arraycopy(MNC, 0, list, i, MNC.length);
i += MNC.length;
System.arraycopy(GSMList, 0, list, i, GSMList.length);
// i += GSMList.length;
return list;
}
}

+ 114
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationInterval.java Wyświetl plik

@@ -0,0 +1,114 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class GZLocationInterval {

private String weekDays;

private String times;

private int interval;

public String getWeekDays() {
return weekDays;
}

public void setWeekDays(String weekDays) {
this.weekDays = weekDays;
}

public String getTimes() {
return times;
}

public void setTimes(String times) {
this.times = times;
}

public int getInterval() {
return interval;
}

public void setInterval(int interval) {
this.interval = interval;
}

public static List<GZLocationInterval> build(String value){
List<GZLocationInterval> list = new ArrayList<>();
String[] values = value.split(",");
for (int i = 0; i < values.length; i++) {
GZLocationInterval item = new GZLocationInterval();
String[] strs = values[i].split("/");
item.setWeekDays(strs[0]);
String str = strs[1];
if(str.substring(0, 1).equals("*")){
item.setTimes("*");
item.setInterval(Integer.parseInt(str.substring(1)));
}else{
item.setTimes(str.substring(0, 8));
item.setInterval(Integer.parseInt(str.substring(8)));
}
list.add(item);
}
return list;
}

public boolean isIn(LocalDateTime time){
int day = time.getDayOfWeek().getValue();
if(weekDays.equals("*") || weekDays.indexOf(String.valueOf(day)) > -1){
if(times.equals("*")){
return true;
}else {
int hour = Integer.parseInt(times.substring(0, 2));
int minute = Integer.parseInt(times.substring(2, 4));
LocalDateTime startTime = time.withHour(hour).withMinute(minute).withSecond(0);
hour = Integer.parseInt(times.substring(4, 6));
minute = Integer.parseInt(times.substring(6, 8));
LocalDateTime endTime = time.withHour(hour).withMinute(minute).withSecond(0);
return time.isAfter(startTime) && time.isBefore(endTime) && interval > 0;
}
}
return false;
}

public static boolean isIn(LocalDateTime time, List<GZLocationInterval> list){
// 有一个是在时间范围内的,则在时间范围内
for (int i = 0; i < list.size(); i++) {
GZLocationInterval item = list.get(i);
if(item.isIn(time)){
return true;
}
}
return false;
}

public boolean isStop(){
return interval <= 0;
}

public static boolean isStop(List<GZLocationInterval> list){
// 有一个不是停止的,则不能停止
for (int i = 0; i < list.size(); i++) {
GZLocationInterval item = list.get(i);
if(!item.isStop()){
return false;
}
}
return true;
}

public static int minInterval(List<GZLocationInterval> list) {
// 最小的间隔
int min = 10;
for (int i = 0; i < list.size(); i++) {
GZLocationInterval item = list.get(i);
if(item.interval > 0 && item.interval < min){
min = item.interval;
}
}
return min;
}
}

+ 70
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationLTE.java Wyświetl plik

@@ -0,0 +1,70 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZLocationLTE implements IMessageContent {

// 国家编码
private byte[] MCC;
// 运营编码
private byte[] MNC;
// 基站小区编号,基站编号,基站信号强度,基站小区编号,基站编号,基站信号强度
// 从设备里面读取对应的 rxlev, 当不为正数时113, 然后转换为 16 进制
// 最多为 5 个
private byte[] LTEList;

public byte[] getMCC() {
return MCC;
}

public void setMCC(byte[] MCC) {
this.MCC = MCC;
}

public byte[] getMNC() {
return MNC;
}

public void setMNC(byte[] MNC) {
this.MNC = MNC;
}

public byte[] getLTEList() {
return LTEList;
}

public void setLTEList(byte[] LTEList) {
this.LTEList = LTEList;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0xF4;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
int length = 1 + MCC.length + MNC.length + LTEList.length;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte) getTag();
System.arraycopy(MCC, 0, list, i, MCC.length);
i += MCC.length;
System.arraycopy(MNC, 0, list, i, MNC.length);
i += MNC.length;
System.arraycopy(LTEList, 0, list, i, LTEList.length);
// i += GSMList.length;
return list;
}
}

+ 67
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationWIFI.java Wyświetl plik

@@ -0,0 +1,67 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;
import java.util.List;

public class GZLocationWIFI implements IMessageContent {

private int hour;
private int minute;
private int second;
private int amount;
private List<GZLocationWIFIItem> wifiList;

public GZLocationWIFI(int hour, int minute, int second, int amount, List<GZLocationWIFIItem> wifiList){
this.hour = hour;
this.minute = minute;
this.second = second;
this.amount = amount;
this.wifiList = wifiList;
}

@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0xF3;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes() {
byte[] wifiBytes = new byte[0];
int length = 0;
for (int i = 0; i < wifiList.size(); i++) {
byte[] b = wifiList.get(i).toBytes();
wifiBytes = ArrayUtils.addAll(wifiBytes, b);
}
length = 5 + wifiBytes.length;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte)getTag();
// 扫描时间
byte[] timeBytes = ByteUtil.hexToByteArray(GZUtil.timeToStr(hour, minute, second));
System.arraycopy(timeBytes, 0, list, i, timeBytes.length);
i += timeBytes.length;
// wifi 数量
list[i++] = (byte)amount;
//wifi数据
System.arraycopy(wifiBytes, 0, list, i, wifiBytes.length);
return list;
}
}

+ 58
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZLocationWIFIItem.java Wyświetl plik

@@ -0,0 +1,58 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import com.ssjl.zhaobiao.guizhou.utils.UnicodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GZLocationWIFIItem {

private String mac;
private int signalIntensity;
private String name;


public String getMac() {
return mac;
}

public void setMac(String mac) {
this.mac = mac;
}

public int getSignalIntensity() {
return signalIntensity;
}

public void setSignalIntensity(int signalIntensity) {
this.signalIntensity = signalIntensity;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public byte[] toBytes(){
byte[] nameBytes = UnicodeUtil.putString2UnicodeBytes(name);
int length = 8 + nameBytes.length;
byte[] list = new byte[length];
int i = 0;
list[i++] = (byte)(length - 1);
// mac地址
mac = mac.replaceAll(":", "");
byte[] macBytes = ByteUtil.hexToByteArray(mac);
System.arraycopy(macBytes, 0, list, i, macBytes.length);
i += macBytes.length;
// 信号强度
list[i++] = GZUtil.signalIntensity(signalIntensity);
// 名字
System.arraycopy(nameBytes, 0, list, i, nameBytes.length);
return list;
}
}

+ 136
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZPlatformCmd.java Wyświetl plik

@@ -0,0 +1,136 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZPlatformCmd implements IMessageContent {

/**
* 立即上报位置信息
*/
private String upLocation;
/**
* 立即上报设置参数
*/
private String upSetting;
/**
* 开启监听
*/
private String openListen;
/**
* 立即呼叫指定的号码
*/
private String callPhone;
/**
* 设置定位追踪模式
*/
private String locationMode;
/**
* 唤醒/休眠/恢复出厂设置/关机/重启
*/
private String shutdownCmd;
/**
* 升级系统/APP
*/
private String upApp;


public String getUpLocation() {
return upLocation;
}

public void setUpLocation(String upLocation) {
this.upLocation = upLocation;
}

public String getUpSetting() {
return upSetting;
}

public void setUpSetting(String upSetting) {
this.upSetting = upSetting;
}

public String getOpenListen() {
return openListen;
}

public void setOpenListen(String openListen) {
this.openListen = openListen;
}

public String getCallPhone() {
return callPhone;
}

public void setCallPhone(String callPhone) {
this.callPhone = callPhone;
}

public String getLocationMode() {
return locationMode;
}

public void setLocationMode(String locationMode) {
this.locationMode = locationMode;
}

public String getShutdownCmd() {
return shutdownCmd;
}

public void setShutdownCmd(String shutdownCmd) {
this.shutdownCmd = shutdownCmd;
}

public String getUpApp() {
return upApp;
}

public void setUpApp(String upApp) {
this.upApp = upApp;
}

@Override
public IMessageContent create(byte[] bytes) {
String setting = new String(bytes);
String[] sets = setting.split(";");
for (int i = 0; i < sets.length; i++) {
String item = sets[i];
String tag = item.substring(0, 1);
String content = item.length() > 1 ? item.substring(1) : "";
if(tag.equals("0")){
upLocation = content;
}else if(tag.equals("1")){
upSetting = content;
}else if(tag.equals("2")){
openListen = content;
}else if(tag.equals("5")){
callPhone = content;
}else if(tag.equals("6")){
locationMode = content;
}else if(tag.equals("7")){
shutdownCmd = content;
}else if(tag.equals("8")){
upApp = content;
}
}
return this;
}

@Override
public int getTag() {
return 0x01;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {

return new byte[0];
}

@Override
public byte[] toBytes() {
return new byte[0];
}
}

+ 30
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZPlatformDeviceConfig.java Wyświetl plik

@@ -0,0 +1,30 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZPlatformDeviceConfig extends GZDeviceConfigBase implements IMessageContent {

@Override
public IMessageContent create(byte[] bytes) {
String setting = new String(bytes);
super.init(setting);
return this;
}

@Override
public int getTag() {
return 0x00;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
// 解析当前命令
return new byte[0];
}

@Override
public byte[] toBytes() {
return super.toBytes();
}
}

+ 31
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZMessage/GZUpDeviceConfig.java Wyświetl plik

@@ -0,0 +1,31 @@
package com.ssjl.zhaobiao.guizhou.entity.GZMessage;

import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZUpDeviceConfig extends GZDeviceConfigBase implements IMessageContent {
@Override
public IMessageContent create(byte[] bytes) {
return null;
}

@Override
public int getTag() {
return 0x10;
}

@Override
public byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus) {
return new byte[0];
}

@Override
public byte[] toBytes(){
byte[] setBytes = super.toBytes();
int length = setBytes.length + 1;
byte[] list = new byte[length];
list[0] = (byte) getTag();
System.arraycopy(setBytes, 0, list, 1, setBytes.length);
return list;
}
}

+ 33
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZNetType.java Wyświetl plik

@@ -0,0 +1,33 @@
package com.ssjl.zhaobiao.guizhou.entity;

public enum GZNetType {
GSM(0x00, "GSM 接入网络"),
CDMA(0x01, "CDMA 接入网络"),
TD_LTE(0x02, "TD-LTE 接入网络"),
FDD_LTE(0x03, "FDD-LTE 接入网络"),
WIFI(0x0f, "无线 wifi 接入网络");


private int code;
private String msg;
GZNetType(int code, String msg){
this.code = code;
this.msg = msg;
}

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;
}
}

+ 117
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZRequest.java Wyświetl plik

@@ -0,0 +1,117 @@
package com.ssjl.zhaobiao.guizhou.entity;

import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
public class GZRequest {

/**
* 标识,固定为0x7E
*/
private byte tag;
/**
* 长度
*/
private int length;
/**
* 终端号码
*/
private String imei;
/**
* 消息序列号
*/
private byte index;
/**
* 属性
*/
private GZRequestStatus status;
/**
* 消息内容
*/
private IMessageContent content;
/**
* 校验和
*/
private byte check;

public GZRequest(){
tag = (byte)0x7E;
}

public int getLength() {
return length;
}

public void setLength(int length) {
this.length = length;
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public byte getIndex() {
return index;
}

public void setIndex(byte index) {
this.index = index;
}

public GZRequestStatus getStatus() {
return status;
}

public void setStatus(GZRequestStatus status) {
this.status = status;
}

public IMessageContent getContent() {
return content;
}

public void setContent(IMessageContent content) {
this.content = content;
}

public byte[] toByte(){
byte[] contentBytes = content.toBytes();
int length = 2 + 8 + 1 + 1 + contentBytes.length + 1;
byte[] list = new byte[length + 2];
int i = 0;
list[i++] = tag;
// 长度
byte[] lengthBytes = ByteUtil.toByte(length, 2);
System.arraycopy(lengthBytes, 0, list, i, lengthBytes.length);
i += lengthBytes.length;
// 终端号码
byte[] imeiBytes = GZUtil.imeiToByte(imei);
System.arraycopy(imeiBytes, 0, list, i, imeiBytes.length);
i += imeiBytes.length;
// 消息序列号
byte[] b = ByteUtil.toByte(index, 1);
list[i++] = b[0];
// 属性
list[i++] = GZUtil.requestStatus(status);
// 消息
System.arraycopy(contentBytes, 0, list, i, contentBytes.length);
i += contentBytes.length;
// 校验和
list[i++] = GZUtil.check(Arrays.copyOfRange(list, 1, length));
// 标识
list[i++] = tag;

return list;
}
}

+ 13
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZRequestStatus.java Wyświetl plik

@@ -0,0 +1,13 @@
package com.ssjl.zhaobiao.guizhou.entity;

public enum GZRequestStatus {
/**
* @description 无需应答
*/
RESPONSE_NO,
// 只在错误时应答
RESPONSE_ERROR,
// 必须应答
RESPONSE_ALL

}

+ 45
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponse.java Wyświetl plik

@@ -0,0 +1,45 @@
package com.ssjl.zhaobiao.guizhou.entity;

public class GZResponse {

private byte tag;

private byte flag;

private String imei;

private int index;

private GZResponseStatus errorCode;

private byte check;

public GZResponse(){
tag = (byte)0x7E;
flag = (byte)0xFF;
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public int getIndex() {
return index;
}

public void setIndex(int index) {
this.index = index;
}

public GZResponseStatus getErrorCode() {
return errorCode;
}

public void setErrorCode(GZResponseStatus errorCode) {
this.errorCode = errorCode;
}
}

+ 41
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GZResponseStatus.java Wyświetl plik

@@ -0,0 +1,41 @@
package com.ssjl.zhaobiao.guizhou.entity;

public enum GZResponseStatus {

RECEIVE_SUCCESS(0xf0,"消息数据包接收正确"),

RECEIVE_ERROR(0xf1,"消息数据包接收错误"),

DEVICE_BUSY(0xf2,"设备忙"),

UNKNOW(0xf3,"不认识命令"),
CONNECT_WAIT(0xf4,"应平台要求终端建立连接, 等待平台指令"),
PLATFORM_ERROR(0xfa,"平台发生错误"),
DEVICE_ERROR(0xfd,"终端状态不可用"),
DATA_ERROR(0xfe,"数据处理过程报错, 一般是数据格式分析出错"),
DEVICE_NOT_EXIST(0xff,"终端没有在平台中注册或找到");

private int code;
private String msg;

GZResponseStatus(int code, String msg){
this.code = code;
this.msg = msg;
}

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;
}
}

+ 195
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDevice.java Wyświetl plik

@@ -0,0 +1,195 @@
package com.ssjl.zhaobiao.guizhou.entity;

import java.util.Date;

public class GpsDevice {
private String deviceId;

private String deviceName;

private String serialno;

private String orgUid;

private String userUid;

private Boolean isRegister;

private Date createTime;

private Date activeTime;

private Date expireTime;

private String model;

private Boolean isOffset;

private Boolean isDeleted;

private Date modifyTime;

private String phoneNumber;

private String remarks;

private Integer activeStatus;

private Boolean lockStatus;

private Integer originalActiveStatus;

private Date lastActiveTime;

public String getDeviceId() {
return deviceId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId == null ? null : deviceId.trim();
}

public String getDeviceName() {
return deviceName;
}

public void setDeviceName(String deviceName) {
this.deviceName = deviceName == null ? null : deviceName.trim();
}

public String getSerialno() {
return serialno;
}

public void setSerialno(String serialno) {
this.serialno = serialno == null ? null : serialno.trim();
}

public String getOrgUid() {
return orgUid;
}

public void setOrgUid(String orgUid) {
this.orgUid = orgUid == null ? null : orgUid.trim();
}

public String getUserUid() {
return userUid;
}

public void setUserUid(String userUid) {
this.userUid = userUid == null ? null : userUid.trim();
}

public Boolean getIsRegister() {
return isRegister;
}

public void setIsRegister(Boolean isRegister) {
this.isRegister = isRegister;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public Date getActiveTime() {
return activeTime;
}

public void setActiveTime(Date activeTime) {
this.activeTime = activeTime;
}

public Date getExpireTime() {
return expireTime;
}

public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model == null ? null : model.trim();
}

public Boolean getIsOffset() {
return isOffset;
}

public void setIsOffset(Boolean isOffset) {
this.isOffset = isOffset;
}

public Boolean getIsDeleted() {
return isDeleted;
}

public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}

public Date getModifyTime() {
return modifyTime;
}

public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}

public String getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber == null ? null : phoneNumber.trim();
}

public String getRemarks() {
return remarks;
}

public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}

public Integer getActiveStatus() {
return activeStatus;
}

public void setActiveStatus(Integer activeStatus) {
this.activeStatus = activeStatus;
}

public Boolean getLockStatus() {
return lockStatus;
}

public void setLockStatus(Boolean lockStatus) {
this.lockStatus = lockStatus;
}

public Integer getOriginalActiveStatus() {
return originalActiveStatus;
}

public void setOriginalActiveStatus(Integer originalActiveStatus) {
this.originalActiveStatus = originalActiveStatus;
}

public Date getLastActiveTime() {
return lastActiveTime;
}

public void setLastActiveTime(Date lastActiveTime) {
this.lastActiveTime = lastActiveTime;
}
}

+ 55
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceCommandvalue.java Wyświetl plik

@@ -0,0 +1,55 @@
package com.ssjl.zhaobiao.guizhou.entity;

import java.util.Date;

public class GpsDeviceCommandvalue {
private String valueId;

private String deviceId;

private String commandCode;

private Date sentTime;

private String commandValue;

public String getValueId() {
return valueId;
}

public void setValueId(String valueId) {
this.valueId = valueId == null ? null : valueId.trim();
}

public String getDeviceId() {
return deviceId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId == null ? null : deviceId.trim();
}

public String getCommandCode() {
return commandCode;
}

public void setCommandCode(String commandCode) {
this.commandCode = commandCode == null ? null : commandCode.trim();
}

public Date getSentTime() {
return sentTime;
}

public void setSentTime(Date sentTime) {
this.sentTime = sentTime;
}

public String getCommandValue() {
return commandValue;
}

public void setCommandValue(String commandValue) {
this.commandValue = commandValue == null ? null : commandValue.trim();
}
}

+ 125
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceConfig.java Wyświetl plik

@@ -0,0 +1,125 @@
package com.ssjl.zhaobiao.guizhou.entity;

import java.util.Date;

public class GpsDeviceConfig {
private String serialno;

private String idNumber;

private Integer pressKeys;

private Date lastUpdate;

private Boolean fenceFlag;

private String deviceFunction;

private String productMode;

private String imei;

private String networkMode;

private String positionMode;

private String coding;

private String iccid;

public String getSerialno() {
return serialno;
}

public void setSerialno(String serialno) {
this.serialno = serialno == null ? null : serialno.trim();
}

public String getIdNumber() {
return idNumber;
}

public void setIdNumber(String idNumber) {
this.idNumber = idNumber == null ? null : idNumber.trim();
}

public Integer getPressKeys() {
return pressKeys;
}

public void setPressKeys(Integer pressKeys) {
this.pressKeys = pressKeys;
}

public Date getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}

public Boolean getFenceFlag() {
return fenceFlag;
}

public void setFenceFlag(Boolean fenceFlag) {
this.fenceFlag = fenceFlag;
}

public String getDeviceFunction() {
return deviceFunction;
}

public void setDeviceFunction(String deviceFunction) {
this.deviceFunction = deviceFunction == null ? null : deviceFunction.trim();
}

public String getProductMode() {
return productMode;
}

public void setProductMode(String productMode) {
this.productMode = productMode == null ? null : productMode.trim();
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei == null ? null : imei.trim();
}

public String getNetworkMode() {
return networkMode;
}

public void setNetworkMode(String networkMode) {
this.networkMode = networkMode == null ? null : networkMode.trim();
}

public String getPositionMode() {
return positionMode;
}

public void setPositionMode(String positionMode) {
this.positionMode = positionMode == null ? null : positionMode.trim();
}

public String getCoding() {
return coding;
}

public void setCoding(String coding) {
this.coding = coding == null ? null : coding.trim();
}

public String getIccid() {
return iccid;
}

public void setIccid(String iccid) {
this.iccid = iccid == null ? null : iccid.trim();
}
}

+ 176
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/GpsDeviceStatus.java Wyświetl plik

@@ -0,0 +1,176 @@
package com.ssjl.zhaobiao.guizhou.entity;

import java.math.BigDecimal;
import java.util.Date;

public class GpsDeviceStatus {
private String deviceId;

private String serialno;

private Date deviceUtcTime;

private Date lastUpdate;

private Boolean isStop;

private Integer speed;

private Integer course;

private String address;

private Integer locationType;

private BigDecimal olat;

private BigDecimal olng;

private BigDecimal glat;

private BigDecimal glng;

private BigDecimal baiduLat;

private BigDecimal baiduLng;

private String deviceStatus;

private String remarks;

public String getDeviceId() {
return deviceId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId == null ? null : deviceId.trim();
}

public String getSerialno() {
return serialno;
}

public void setSerialno(String serialno) {
this.serialno = serialno == null ? null : serialno.trim();
}

public Date getDeviceUtcTime() {
return deviceUtcTime;
}

public void setDeviceUtcTime(Date deviceUtcTime) {
this.deviceUtcTime = deviceUtcTime;
}

public Date getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}

public Boolean getIsStop() {
return isStop;
}

public void setIsStop(Boolean isStop) {
this.isStop = isStop;
}

public Integer getSpeed() {
return speed;
}

public void setSpeed(Integer speed) {
this.speed = speed;
}

public Integer getCourse() {
return course;
}

public void setCourse(Integer course) {
this.course = course;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}

public Integer getLocationType() {
return locationType;
}

public void setLocationType(Integer locationType) {
this.locationType = locationType;
}

public BigDecimal getOlat() {
return olat;
}

public void setOlat(BigDecimal olat) {
this.olat = olat;
}

public BigDecimal getOlng() {
return olng;
}

public void setOlng(BigDecimal olng) {
this.olng = olng;
}

public BigDecimal getGlat() {
return glat;
}

public void setGlat(BigDecimal glat) {
this.glat = glat;
}

public BigDecimal getGlng() {
return glng;
}

public void setGlng(BigDecimal glng) {
this.glng = glng;
}

public BigDecimal getBaiduLat() {
return baiduLat;
}

public void setBaiduLat(BigDecimal baiduLat) {
this.baiduLat = baiduLat;
}

public BigDecimal getBaiduLng() {
return baiduLng;
}

public void setBaiduLng(BigDecimal baiduLng) {
this.baiduLng = baiduLng;
}

public String getDeviceStatus() {
return deviceStatus;
}

public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus == null ? null : deviceStatus.trim();
}

public String getRemarks() {
return remarks;
}

public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}
}

+ 11
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IMessageContent.java Wyświetl plik

@@ -0,0 +1,11 @@
package com.ssjl.zhaobiao.guizhou.entity;

public interface IMessageContent {
IMessageContent create(byte[] bytes);

int getTag();

byte[] process(String deviceFlag, String flagType, byte msgIndex, GZRequestStatus requestStatus);

byte[] toBytes();
}

+ 24
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiActiveDevice.java Wyświetl plik

@@ -0,0 +1,24 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

public class IotApiActiveDevice {


private String serialNo;
private int commandType;

public String getSerialNo() {
return serialNo;
}

public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}

public int getCommandType() {
return commandType;
}

public void setCommandType(int commandType) {
this.commandType = commandType;
}
}

+ 37
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiLocationMode.java Wyświetl plik

@@ -0,0 +1,37 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

public class IotApiLocationMode {

private String serialno;

/**
* 0关闭,1普通模式,2省电模式,3性能模式,4自定义模式
*/
private int mode;

private int timeInterval;

public String getSerialno() {
return serialno;
}

public void setSerialno(String serialno) {
this.serialno = serialno;
}

public int getMode() {
return mode;
}

public void setMode(int mode) {
this.mode = mode;
}

public int getTimeInterval() {
return timeInterval;
}

public void setTimeInterval(int timeInterval) {
this.timeInterval = timeInterval;
}
}

+ 95
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiNotDisturb.java Wyświetl plik

@@ -0,0 +1,95 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

import java.util.ArrayList;
import java.util.List;

public class IotApiNotDisturb {
private String serialNo;
private List<IotApiNotDisturbItem> items;

public IotApiNotDisturb(){
items = new ArrayList<>();
}
public void addItem(String startTime, String endTime, int callIn, int callOut, String weekdays){
IotApiNotDisturbItem item = new IotApiNotDisturbItem();
item.setStartTime(startTime);
item.setEndTime(endTime);
item.setCallinFlag(callIn);
item.setCalloutFlag(callOut);
item.setWeekdays(weekdays);
items.add(item);
}

public String getSerialNo() {
return serialNo;
}

public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}

public List<IotApiNotDisturbItem> getItems() {
return items;
}

public void setItems(List<IotApiNotDisturbItem> items) {
this.items = items;
}

public class IotApiNotDisturbItem{
private String startTime;
private String endTime;
/**
* 0:代表禁止SOS号码打入,1:代表允许SOS号码打入
*/
private int callinFlag;
/**
* 0:代表禁止拨打SOS号码,1:代表允许拨打SOS号码
*/
private int calloutFlag;
/**
* 1代表周一,2代表周二,3代表周三,4代表周四,5代表周五,6代表周六,7代表周日,
*/
private String weekdays;

public String getStartTime() {
return startTime;
}

public void setStartTime(String startTime) {
this.startTime = startTime;
}

public String getEndTime() {
return endTime;
}

public void setEndTime(String endTime) {
this.endTime = endTime;
}

public int getCallinFlag() {
return callinFlag;
}

public void setCallinFlag(int callinFlag) {
this.callinFlag = callinFlag;
}

public int getCalloutFlag() {
return calloutFlag;
}

public void setCalloutFlag(int calloutFlag) {
this.calloutFlag = calloutFlag;
}

public String getWeekdays() {
return weekdays;
}

public void setWeekdays(String weekdays) {
this.weekdays = weekdays;
}
}
}

+ 40
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiResponse.java Wyświetl plik

@@ -0,0 +1,40 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

public class IotApiResponse {
private int stateCode;
private String message;
private Object data;
private String dataName;

public int getStateCode() {
return stateCode;
}

public void setStateCode(int stateCode) {
this.stateCode = stateCode;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public Object getData() {
return data;
}

public void setData(Object data) {
this.data = data;
}

public String getDataName() {
return dataName;
}

public void setDataName(String dataName) {
this.dataName = dataName;
}
}

+ 88
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiSleepTime.java Wyświetl plik

@@ -0,0 +1,88 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

import java.util.ArrayList;
import java.util.List;

public class IotApiSleepTime {
private String serialNo;
private IotApiSleepTimeDormancy dormancy;

public IotApiSleepTime(){
dormancy = new IotApiSleepTimeDormancy();
dormancy.dormancy = new ArrayList<>();
}

public void addTime(String startTime, String endTime, String weekdays){
if(dormancy == null){
dormancy = new IotApiSleepTimeDormancy();
}
if(dormancy.dormancy == null){
dormancy.dormancy = new ArrayList<>();
}
IotApiSleepTimeItem item = new IotApiSleepTimeItem();
item.setStartTime(startTime);
item.setEndTime(endTime);
item.setWeekdays(weekdays);
dormancy.dormancy.add(item);
}

public String getSerialNo() {
return serialNo;
}

public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}

public IotApiSleepTimeDormancy getDormancy() {
return dormancy;
}

public void setDormancy(IotApiSleepTimeDormancy dormancy) {
this.dormancy = dormancy;
}

public class IotApiSleepTimeDormancy{
private List<IotApiSleepTimeItem> dormancy;

public List<IotApiSleepTimeItem> getDormancy() {
return dormancy;
}

public void setDormancy(List<IotApiSleepTimeItem> dormancy) {
this.dormancy = dormancy;
}
}
public class IotApiSleepTimeItem{
private String startTime;
private String endTime;
private String weekdays;

public String getStartTime() {
return startTime;
}

public void setStartTime(String startTime) {
this.startTime = startTime;
}

public String getEndTime() {
return endTime;
}

public void setEndTime(String endTime) {
this.endTime = endTime;
}

public String getWeekdays() {
return weekdays;
}

public void setWeekdays(String weekdays) {
this.weekdays = weekdays;
}
}

}



+ 128
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/Api/IotApiWhiteList.java Wyświetl plik

@@ -0,0 +1,128 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT.Api;

import java.util.ArrayList;
import java.util.List;

public class IotApiWhiteList {
private String serialNo;

private List<IotApiWhiteListItem> whiteList;

public IotApiWhiteList(){
whiteList = new ArrayList<>();
}

public void addPhone(String phone, String relationship, String key, int isSos){
IotApiWhiteListItem item = new IotApiWhiteListItem();
item.setRelationship(relationship);
item.setPhone(phone);
item.setCallOut(2);
item.setInComing(2);
item.setLevel(1);
item.setOuttime("");
item.setPressKey(key);
item.setSos(isSos);
whiteList.add(item);

}

public String getSerialNo() {
return serialNo;
}

public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}

public List<IotApiWhiteListItem> getWhiteList() {
return whiteList;
}

public void setWhiteList(List<IotApiWhiteListItem> whiteList) {
this.whiteList = whiteList;
}

public class IotApiWhiteListItem{
private String relationship;
private String phone;
private int sos;
private String pressKey;
private int level;
private int inComing;
private int callOut;
private String incomingTime;
private String outtime;

public String getRelationship() {
return relationship;
}

public void setRelationship(String relationship) {
this.relationship = relationship;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public int getSos() {
return sos;
}

public void setSos(int sos) {
this.sos = sos;
}

public String getPressKey() {
return pressKey;
}

public void setPressKey(String pressKey) {
this.pressKey = pressKey;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

public int getInComing() {
return inComing;
}

public void setInComing(int inComing) {
this.inComing = inComing;
}

public int getCallOut() {
return callOut;
}

public void setCallOut(int callOut) {
this.callOut = callOut;
}

public String getIncomingTime() {
return incomingTime;
}

public void setIncomingTime(String incomingTime) {
this.incomingTime = incomingTime;
}

public String getOuttime() {
return outtime;
}

public void setOuttime(String outtime) {
this.outtime = outtime;
}
}
}

+ 44
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTDeviceConfig.java Wyświetl plik

@@ -0,0 +1,44 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT;

public class IOTDeviceConfig {
/**
* 设备功能集。说明:设备支持的功能,例如:deviceFunction="考勤,2.4G"分割符为逗号。
*/
private String deviceFunction;
/**
* 设备型号版本,例如:productModelVer="TPS600A,V10.16,V2.4",说明:"产品型号,硬件版本,软件版本"
*/
private String productModelVer;
/**
* 2.4G物理卡号
*/
private String idNumbid;
/**
* IMEI卡号
*/
private String IMEI;
/**
* 按键数
*/
private String PressKeys;
/**
* 电子围栏是否上报,0:不上报 1:上报
*/
private String UploadFenceFlag;
/**
* 网络制式 NetworkMode="4G,5G" 说明:支持4G和5G
*/
private String NetworkMode;
/**
* 定位方式 PositioningMode="GPS,WIFI"支持GPS和WIFI两种方式定位
*/
private String PositioningMode;
/**
* 字符编解码集Coding="Unicode,UTF-8,GBK-2312"说明:设备支持这三种字符集。
*/
private String Coding;
/**
* 设备ICCID码
*/
private String ICCID;
}

+ 53
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTDeviceStatus.java Wyświetl plik

@@ -0,0 +1,53 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT;

import com.alibaba.fastjson.JSON;

public class IOTDeviceStatus {
// online=1&battery=73&step=39
private int online;
private int battery;
private int step;

public int getOnline() {
return online;
}

public void setOnline(int online) {
this.online = online;
}

public int getBattery() {
return battery;
}

public void setBattery(int battery) {
this.battery = battery;
}

public int getStep() {
return step;
}

public void setStep(int step) {
this.step = step;
}

public IOTDeviceStatus(){

}

public static IOTDeviceStatus build(String value){
String[] stas = value.split("&");
String json = "{";
for (int i = 0; i < stas.length; i++) {
String str = stas[i];
String[] strs = str.split("=");
json +="\"" + strs[0] + "\":";
json += strs[1] + ",";
}
json = json.substring(0, json.length() - 1);
json += "}";
IOTDeviceStatus obj = JSON.parseObject(json, IOTDeviceStatus.class);
return obj;
}
}

+ 100
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTGps.java Wyświetl plik

@@ -0,0 +1,100 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT;

public class IOTGps {
/**
* 经度
*/
private double longitude;
/**
* 纬度
*/
private double latitude;
/**
* 海拔
*/
private double altitude;
/**
* 坐标系
* 1:WGS_84
* 2:GCJ_02
*/
private int coordinateSystem;
/**
* 0:代表无事件,IDNumber为空值;
* 1:sos事件ID;
* 2:Pay事件ID
* 3 : 测温事件ID
* 4 : 通话事件ID
* 说明:
* 1、求救事件ID号。详见3.1.11。
* 说明:设备端SOS求救时需要上报位置,位置上报需要带上sos报警信息ID。
* 默认为为空。
* 2、付款事件ID号。详见3.4.6。
* 说明:设备端在付款事件发生时,要上报定位信息,上报的定位信息PayID是支付ID号一一对应。正常定位默认为空。
* 3、温度上报事件ID.
* 说明:设备端在测温事件发生时,要上报定位信息,上报的定位信息TempID是测温ID号一一对应。正常定位默认为空。
* 4、通话上报事件ID.
* 说明:设备端在通话事件发生时,要上报定位信息,上报的定位信息CallID是通话ID号一一对应。
* 正常定位默认为空。
*/
private int idType;
private String idNumber;

private String imei;

public double getLongitude() {
return longitude;
}

public void setLongitude(double longitude) {
this.longitude = longitude;
}

public double getLatitude() {
return latitude;
}

public void setLatitude(double latitude) {
this.latitude = latitude;
}

public double isAltitude() {
return altitude;
}

public void setAltitude(double altitude) {
this.altitude = altitude;
}

public int getCoordinateSystem() {
return coordinateSystem;
}

public void setCoordinateSystem(int coordinateSystem) {
this.coordinateSystem = coordinateSystem;
}

public int getIdType() {
return idType;
}

public void setIdType(int idType) {
this.idType = idType;
}

public String getIdNumber() {
return idNumber;
}

public void setIdNumber(String idNumber) {
this.idNumber = idNumber;
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}
}

+ 118
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTLbs.java Wyświetl plik

@@ -0,0 +1,118 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT;

public class IOTLbs {
/**
* 手机imei号
*/
private String imei;
/**
* 手机mac码
*/
private String smac;
/**
* 移动用户识别码
*/
private String imsi;
/**
* 周边基站信息(不含接入基站信息)
*/
private String nearbts;
/**
* 是否为cdma ,0:否 ,1:是
*/
private String cdma;
/**
* 接入基站信息, 内部参数说明如下:
* 非cdma:格式为mcc,mnc,lac,cellid,signal。
* cdma:格式为sid,nid,bid,lon,lat,signal
* 其中 lon和lat可为空,则格式为sid,nid,bid,,,signal。
*/
private String bts;
/**
* 0:代表无事件,IDNumber为空值;
* 1:sos事件ID;
* 2:Pay事件ID
* 3 : 测温事件ID
* 4 : 通话事件ID
* 说明:
* 1、求救事件ID号。详见3.1.11。
* 说明:设备端SOS求救时需要上报位置,位置上报需要带上sos报警信息ID。
* 默认为为空。
* 2、付款事件ID号。详见3.4.6。
* 说明:设备端在付款事件发生时,要上报定位信息,上报的定位信息PayID是支付ID号一一对应。正常定位默认为空。
* 3、温度上报事件ID.
* 说明:设备端在测温事件发生时,要上报定位信息,上报的定位信息TempID是测温ID号一一对应。正常定位默认为空。
* 4、通话上报事件ID.
* 说明:设备端在通话事件发生时,要上报定位信息,上报的定位信息CallID是通话ID号一一对应。
* 正常定位默认为空。
*/
private int idType;
/**
*
*/
private String idNumber;

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public String getSmac() {
return smac;
}

public void setSmac(String smac) {
this.smac = smac;
}

public String getImsi() {
return imsi;
}

public void setImsi(String imsi) {
this.imsi = imsi;
}

public String getNearbts() {
return nearbts;
}

public void setNearbts(String nearbts) {
this.nearbts = nearbts;
}

public String getCdma() {
return cdma;
}

public void setCdma(String cdma) {
this.cdma = cdma;
}

public String getBts() {
return bts;
}

public void setBts(String bts) {
this.bts = bts;
}

public int getIdType() {
return idType;
}

public void setIdType(int idType) {
this.idType = idType;
}

public String getIdNumber() {
return idNumber;
}

public void setIdNumber(String idNumber) {
this.idNumber = idNumber;
}
}

+ 178
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOT/IOTWifi.java Wyświetl plik

@@ -0,0 +1,178 @@
package com.ssjl.zhaobiao.guizhou.entity.IOT;

public class IOTWifi {
/**
* 采样时间
*/
private String datetime;
/**
* 运动步数集合,按每分钟进行运动步数统计,每个统计数之间用’,’隔开;传输格式如”step”=“123,124,125”
*/
private String steps;
/**
* 已连热点mac:信息地址,信号强度,WiFi名称|
*/
private String mmac;
/**
* WiFi列表中macs: 地址,信号强度,WiFi名称
*/
private String macs;
/**
* 手机imei号
*/
private String imei;
/**
* 手机mac码
*/
private String smac;
/**
* 移动用户识别码
*/
private String imsi;
/**
* 周边基站信息(不含接入基站信息)
*/
private String nearbts;
/**
* GSM/GPRS/EDGE/HSUPA/HSDPA/WCDMA/LTE
*/
private String network;
/**
* 是否为cdma ,0:否 ,1:是
*/
private String cdma;
/**
* 接入基站信息, 内部参数说明如下:
* 非cdma:格式为mcc,mnc,lac,cellid,signal。
* cdma:格式为sid,nid,bid,lon,lat,signal
* 其中 lon和lat可为空,则格式为sid,nid,bid,,,signal。
*/
private String bts;
/**
* 0:代表无事件,IDNumber为空值;
* 1:sos事件ID;
* 2:Pay事件ID
* 3 : 测温事件ID
* 4 : 通话事件ID
* 说明:
* 1、求救事件ID号。详见3.1.11。
* 说明:设备端SOS求救时需要上报位置,位置上报需要带上sos报警信息ID。
* 默认为为空。
* 2、付款事件ID号。详见3.4.6。
* 说明:设备端在付款事件发生时,要上报定位信息,上报的定位信息PayID是支付ID号一一对应。正常定位默认为空。
* 3、温度上报事件ID.
* 说明:设备端在测温事件发生时,要上报定位信息,上报的定位信息TempID是测温ID号一一对应。正常定位默认为空。
* 4、通话上报事件ID.
* 说明:设备端在通话事件发生时,要上报定位信息,上报的定位信息CallID是通话ID号一一对应。
* 正常定位默认为空。
*/
private int idType;
/**
*
*/
private String idNumber;

public String getDatetime() {
return datetime;
}

public void setDatetime(String datetime) {
this.datetime = datetime;
}

public String getSteps() {
return steps;
}

public void setSteps(String steps) {
this.steps = steps;
}

public String getMmac() {
return mmac;
}

public void setMmac(String mmac) {
this.mmac = mmac;
}

public String getMacs() {
return macs;
}

public void setMacs(String macs) {
this.macs = macs;
}

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public String getSmac() {
return smac;
}

public void setSmac(String smac) {
this.smac = smac;
}

public String getImsi() {
return imsi;
}

public void setImsi(String imsi) {
this.imsi = imsi;
}

public String getNearbts() {
return nearbts;
}

public void setNearbts(String nearbts) {
this.nearbts = nearbts;
}

public String getNetwork() {
return network;
}

public void setNetwork(String network) {
this.network = network;
}

public String getCdma() {
return cdma;
}

public void setCdma(String cdma) {
this.cdma = cdma;
}

public String getBts() {
return bts;
}

public void setBts(String bts) {
this.bts = bts;
}

public int getIdType() {
return idType;
}

public void setIdType(int idType) {
this.idType = idType;
}

public String getIdNumber() {
return idNumber;
}

public void setIdNumber(String idNumber) {
this.idNumber = idNumber;
}
}

+ 24
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/entity/IOTDevice.java Wyświetl plik

@@ -0,0 +1,24 @@
package com.ssjl.zhaobiao.guizhou.entity;

public class IOTDevice {

private String imei;

private String phone;

public String getImei() {
return imei;
}

public void setImei(String imei) {
this.imei = imei;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}
}

+ 21
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZMessageContentFactory.java Wyświetl plik

@@ -0,0 +1,21 @@
package com.ssjl.zhaobiao.guizhou.handle;

import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZPlatformCmd;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZPlatformDeviceConfig;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

public class GZMessageContentFactory {

public static IMessageContent build(byte type, byte[] content){
IMessageContent item = null;
if(type == 0x00){
item = new GZPlatformDeviceConfig();
item.create(content);
}
else if(type == 0x01){
item = new GZPlatformCmd();
item.create(content);
}
return item;
}
}

+ 63
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZResponseHandle.java Wyświetl plik

@@ -0,0 +1,63 @@
package com.ssjl.zhaobiao.guizhou.handle;

import com.ssjl.zhaobiao.guizhou.entity.GZDeviceFlagType;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformService;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class GZResponseHandle {
@Autowired
GZServiceFactory serviceFactory;

public Object process(byte[] res) throws IOException {
if(res[1] == 0xFF){
// 常规应答

return null;
}else {
// 其他命令
// 先转码
res = GZUtil.decode(res);
// 长度
byte[] lengthBytes = new byte[2];
System.arraycopy(res, 1, lengthBytes, 0, 2);
int length = ByteUtil.toInt(lengthBytes);
// 终端号码
byte[] imeiBytes = new byte[8];
System.arraycopy(res, 3, imeiBytes, 0, 8);
String deviceFlag = GZUtil.byteToDeviceFlag(imeiBytes);
GZDeviceFlagType flagType = GZDeviceFlagType.IMEI;
String[] flags = deviceFlag.split(",");
if(flags.length > 1){
deviceFlag = flags[0];
flagType = flags[1].equals("phone") ? GZDeviceFlagType.PHONE : GZDeviceFlagType.IMEI;
}

// 消息序列号
byte msgIndex = res[11];
// 属性
GZRequestStatus status = GZUtil.parseGZRequestStatus(res[12]);
// 消息类型
byte msgType = res[13];
// 消息内容
byte[] msgBytes = new byte[length - 14];
System.arraycopy(res, 14, msgBytes, 0, msgBytes.length);
IMessageContent content = GZMessageContentFactory.build(msgType, msgBytes);
IGZPlatformService service = serviceFactory.getService(msgType);
if(service != null){
return service.process(content, deviceFlag, flagType, msgIndex, status);
}
return new byte[0];
// byte[] result = content.process(deviceFlag, flagType, msgIndex, status);

}
}
}

+ 25
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/handle/GZServiceFactory.java Wyświetl plik

@@ -0,0 +1,25 @@
package com.ssjl.zhaobiao.guizhou.handle;

import com.ssjl.zhaobiao.guizhou.service.IGZPlatformCmdService;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformService;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GZServiceFactory {
@Autowired
IGZPlatformCmdService cmdService;
@Autowired
IGZPlatformSettingService settingService;

public IGZPlatformService getService(byte tag){
if(tag == 0x00) {
return settingService;
}
else if(tag == 0x01){
return cmdService;
}
return null;
}
}

+ 70
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClient.java Wyświetl plik

@@ -0,0 +1,70 @@
package com.ssjl.zhaobiao.guizhou.netty;

//import io.netty.bootstrap.Bootstrap;
//import io.netty.channel.*;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.concurrent.TimeUnit;

@Component
@Slf4j
public class NettyClient {
@Value("${netty.host}")
private String host;
@Value(("${netty.port}"))
private int port;

// private EventLoopGroup group;
// private Channel socketChannel;
//
//
// public void start(){
// group = new NioEventLoopGroup();
// Bootstrap bootstrap = new Bootstrap();
// bootstrap.group(group)
// .channel(NioSocketChannel.class)
// .remoteAddress(host, port)
// .option(ChannelOption.SO_KEEPALIVE, true)
// .option(ChannelOption.TCP_NODELAY, true)
// .handler(new NettyClientInitilizer());
// ChannelFuture future = null;
//
// future = bootstrap.connect();
// future.addListener((ChannelFutureListener) future1 -> {
// if(future1.isSuccess()){
// log.info("连接netty服务成功");
// }else{
// log.info("连接失败,进行断线重连");
// future1.channel().eventLoop().schedule(() -> start(), 1, TimeUnit.SECONDS);
// }
// });
// socketChannel = future.channel();
//// while (true){
//// send();
//// try {
//// Thread.sleep(3000);
//// } catch (InterruptedException e) {
//// e.printStackTrace();
//// }
//// }
//
// }
//
// public void send(){
// byte[] buffer = new byte[10];
// buffer[0] = (byte)0xEF;
// buffer[1] = (byte)0x01;
// buffer[2] = (byte)0x02;
// if(socketChannel != null){
// socketChannel.writeAndFlush(buffer);
// }
//
// }
}

+ 24
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClientHandle.java Wyświetl plik

@@ -0,0 +1,24 @@
package com.ssjl.zhaobiao.guizhou.netty;
//
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NettyClientHandle { //} extends ChannelInboundHandlerAdapter {
//@Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// log.info("客户端active");
// }
//
// @Override
// public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// log.info("客户端收到消息", msg.toString());
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// cause.printStackTrace();
// ctx.close();
// }
}

+ 32
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyClientInitilizer.java Wyświetl plik

@@ -0,0 +1,32 @@
package com.ssjl.zhaobiao.guizhou.netty;

//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
//import io.netty.handler.codec.LengthFieldPrepender;
//import io.netty.handler.codec.bytes.ByteArrayDecoder;
//import io.netty.handler.codec.bytes.ByteArrayEncoder;
//import io.netty.handler.codec.string.StringDecoder;
//import io.netty.handler.codec.string.StringEncoder;
//import io.netty.util.CharsetUtil;

public class NettyClientInitilizer{
// extends ChannelInitializer<SocketChannel> {
//
// @Override
// protected void initChannel(SocketChannel socketChannel) throws Exception {
// //添加编解码
//// socketChannel.pipeline().addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
////// socketChannel.pipeline().addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
// // Decoders
//// socketChannel.pipeline().addLast("frameDecoder",
//// new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4));
// socketChannel.pipeline().addLast("bytesDecoder",
// new ByteArrayDecoder());
//
// // Encoder
//// socketChannel.pipeline().addLast("frameEncoder", new LengthFieldPrepender(4));
// socketChannel.pipeline().addLast("bytesEncoder", new ByteArrayEncoder());
// socketChannel.pipeline().addLast(new NettyClientHandle());
// }
}

+ 54
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServer.java Wyświetl plik

@@ -0,0 +1,54 @@
package com.ssjl.zhaobiao.guizhou.netty;
//
//import io.netty.bootstrap.ServerBootstrap;
//import io.netty.channel.ChannelFuture;
//import io.netty.channel.ChannelOption;
//import io.netty.channel.EventLoopGroup;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.net.InetSocketAddress;

@Slf4j
@Component
public class NettyServer {
@Value("${netty.host}")
private String host;
@Value("${netty.port}")
private int port;

//
// public void start(){
// EventLoopGroup bossGroup = new NioEventLoopGroup(1);
// EventLoopGroup workGroup = new NioEventLoopGroup(1);
// ServerBootstrap bootstrap = new ServerBootstrap()
// .group(bossGroup, workGroup)
// .channel(NioServerSocketChannel.class)
// .childHandler(new NettyServerInitializer())
//// .localAddress(new InetSocketAddress(port))
// .localAddress(host, port)
// .option(ChannelOption.SO_BACKLOG, 128)
// .childOption(ChannelOption.SO_KEEPALIVE, true);
// try {
// ChannelFuture future = bootstrap.bind().sync();
//// ChannelFuture future = bootstrap.bind();
// if(future.isSuccess()){
// log.info("server start success");
// }else{
// log.info("server start error");
// }
//
//// future.channel().closeFuture().sync();
// }catch (Exception e){
// e.printStackTrace();
// }
// finally {
//// bossGroup.shutdownGracefully();
//// workGroup.shutdownGracefully();
// }
// }
}

+ 31
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServerHandler.java Wyświetl plik

@@ -0,0 +1,31 @@
package com.ssjl.zhaobiao.guizhou.netty;

//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NettyServerHandler{
// extends
//} ChannelInboundHandlerAdapter {
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// log.info("netty server active");
// }
//
// @Override
// public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// log.info("服务器收到消息:{}", msg.toString());
// byte[] buffer = new byte[10];
// buffer[0] = (byte)0x33;
// ctx.write(buffer);
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// cause.printStackTrace();
// ctx.close();
// }
}

+ 18
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/netty/NettyServerInitializer.java Wyświetl plik

@@ -0,0 +1,18 @@
package com.ssjl.zhaobiao.guizhou.netty;

//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.handler.codec.string.StringDecoder;
//import io.netty.handler.codec.string.StringEncoder;
//import io.netty.util.CharsetUtil;

public class NettyServerInitializer {
// extends ChannelInitializer<SocketChannel> {
// @Override
// protected void initChannel(SocketChannel socketChannel) throws Exception {
// //添加编解码
// socketChannel.pipeline().addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
// socketChannel.pipeline().addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
// socketChannel.pipeline().addLast(new NettyServerHandler());
// }
}

+ 85
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/QuartzConfig.java Wyświetl plik

@@ -0,0 +1,85 @@
package com.ssjl.zhaobiao.guizhou.quartz;

import com.ssjl.zhaobiao.guizhou.quartz.job.GZHeartJob;
import com.ssjl.zhaobiao.guizhou.quartz.job.GZSyncSetting;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {

// @Bean
// public JobDetail refreshAliPhotoTask() {
// return JobBuilder.newJob(RefreshAliPhotoJob.class)
// .withIdentity("refreshAliPhotoTask")
// .storeDurably()
// .build();
// }
// @Bean
// public Trigger refreshAliPhotoTaskTrigger() {
// return TriggerBuilder.newTrigger()
// .forJob(refreshAliPhotoTask())
// .withIdentity("refreshAliPhotoTask")
// .withSchedule(CronScheduleBuilder.cronSchedule("*/10 * * * * ?"))
// .build();
// }
//
@Bean
public JobDetail gzHeartTask() {
return JobBuilder.newJob(GZHeartJob.class)
.withIdentity("gzHeartTask")
.storeDurably()
.build();
}
@Bean
public Trigger gzHeartTaskTrigger() {
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMinutes(30)
.repeatForever();
return TriggerBuilder.newTrigger()
.forJob(gzHeartTask())
.withIdentity("gzHeartTask")
.withSchedule(scheduleBuilder)
.build();
}

@Bean
public JobDetail gzSyncTask() {
return JobBuilder.newJob(GZSyncSetting.class)
.withIdentity("gzSyncTask")
.storeDurably()
.build();
}
@Bean
public Trigger gzSyncTaskTrigger() {
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(10)
.repeatForever();
return TriggerBuilder.newTrigger()
.forJob(gzSyncTask())
.withIdentity("gzSyncTask")
.withSchedule(scheduleBuilder)
.build();
}

// @Bean
// public JobDetail temperaturePushTask(){
// return JobBuilder.newJob(TemperaturePushJob.class)
// .withIdentity("temperaturePushTask")
// .storeDurably()
// .build();
// }
// @Bean
// public Trigger temperaturePushTaskTrigger(){
// SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
// .withIntervalInSeconds(1)
// .repeatForever();
// return TriggerBuilder.newTrigger()
// .forJob(temperaturePushTask())
// .withIdentity("temperaturePushTask")
// .withSchedule(scheduleBuilder)
// .build();
// }

}

+ 65
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZHeartJob.java Wyświetl plik

@@ -0,0 +1,65 @@
package com.ssjl.zhaobiao.guizhou.quartz.job;


import com.alibaba.fastjson.JSON;
import com.ssjl.zhaobiao.guizhou.entity.*;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZHeart;
import com.ssjl.zhaobiao.guizhou.entity.IOT.IOTDeviceStatus;
import com.ssjl.zhaobiao.guizhou.repository.DianxinGzDeviceConfigMapper;
import com.ssjl.zhaobiao.guizhou.repository.GpsDeviceStatusMapper;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZHttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.io.IOException;
import java.util.List;

//此注解标记任务不并发,任务执行完后才开始下一次任务
@DisallowConcurrentExecution
@Slf4j
public class GZHeartJob extends QuartzJobBean {

@Autowired
GpsDeviceStatusMapper statusMapper;
@Autowired
DianxinGzDeviceConfigMapper configMapper;
@Autowired
GZHttpUtil httpUtil;
@Value("${guizhou.device.testList}")
String testList;

@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
List<IOTDevice> deviceList = JSON.parseArray(testList, IOTDevice.class);
for (int i = 0; i < deviceList.size(); i++) {
IOTDevice device = deviceList.get(i);
String imei = device.getImei();
String phone = device.getPhone();
GpsDeviceStatus gpsDeviceStatus = statusMapper.selectByImei(imei);
String statusStr = gpsDeviceStatus.getDeviceStatus();
IOTDeviceStatus status = IOTDeviceStatus.build(statusStr);

DianxinGzDeviceConfig config = configMapper.selectByImei(imei);
GZHeart heart = new GZHeart();
GZDevicePower power = new GZDevicePower();
power.setPower(status.getBattery());
power.setCharge(false);
heart.setPower(power);
GZDeviceStatus gzStatus = new GZDeviceStatus();
heart.setStatus(gzStatus);
heart.setSignalIntensity(50);
try {
byte[] res = httpUtil.send(imei, phone, heart);
// System.out.println(ByteUtil.bytesToHexString(res));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

+ 51
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/GZSyncSetting.java Wyświetl plik

@@ -0,0 +1,51 @@
package com.ssjl.zhaobiao.guizhou.quartz.job;

import com.alibaba.fastjson.JSON;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZAskSetting;
import com.ssjl.zhaobiao.guizhou.entity.IOTDevice;
import com.ssjl.zhaobiao.guizhou.handle.GZResponseHandle;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZHttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.io.IOException;
import java.util.List;

//此注解标记任务不并发,任务执行完后才开始下一次任务
@DisallowConcurrentExecution
@Slf4j
public class GZSyncSetting extends QuartzJobBean {

@Autowired
GZHttpUtil httpUtil;
@Value("${guizhou.device.testList}")
String testList;
@Autowired
GZResponseHandle responseHandle;

@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
//
List<IOTDevice> devices = JSON.parseArray(testList, IOTDevice.class);
for (int i = 0; i < devices.size(); i++) {
IOTDevice device = devices.get(i);
GZAskSetting askSetting = new GZAskSetting();
try {
byte[] res = httpUtil.send(device.getImei(), device.getPhone(), askSetting);
// System.out.println(ByteUtil.bytesToHexString(res));
res = (byte[]) responseHandle.process(res);
// System.out.println(ByteUtil.bytesToHexString(res));
} catch (IOException e) {
e.printStackTrace();
}
}


}
}

+ 21
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/quartz/job/RefreshAliPhotoJob.java Wyświetl plik

@@ -0,0 +1,21 @@
package com.ssjl.zhaobiao.guizhou.quartz.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

//此注解标记任务不并发,任务执行完后才开始下一次任务
@DisallowConcurrentExecution
@Slf4j
public class RefreshAliPhotoJob extends QuartzJobBean {
/*
阿里的照片有时间限制,每天集体刷新一次
*/

@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
System.out.println("照片");
}
}

+ 21
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/repository/DianxinGzDeviceConfigMapper.java Wyświetl plik

@@ -0,0 +1,21 @@
package com.ssjl.zhaobiao.guizhou.repository;

import com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig;

public interface DianxinGzDeviceConfigMapper {
int deleteByPrimaryKey(Integer id);

int insert(DianxinGzDeviceConfig record);

int insertSelective(DianxinGzDeviceConfig record);

DianxinGzDeviceConfig selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(DianxinGzDeviceConfig record);

int updateByPrimaryKey(DianxinGzDeviceConfig record);

DianxinGzDeviceConfig selectByImei(String imei);

DianxinGzDeviceConfig selectByPhone(String phone);
}

+ 19
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceCommandvalueMapper.java Wyświetl plik

@@ -0,0 +1,19 @@
package com.ssjl.zhaobiao.guizhou.repository;

import com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue;

public interface GpsDeviceCommandvalueMapper {
int deleteByPrimaryKey(String valueId);

int insert(GpsDeviceCommandvalue record);

int insertSelective(GpsDeviceCommandvalue record);

GpsDeviceCommandvalue selectByPrimaryKey(String valueId);

int updateByPrimaryKeySelective(GpsDeviceCommandvalue record);

int updateByPrimaryKeyWithBLOBs(GpsDeviceCommandvalue record);

int updateByPrimaryKey(GpsDeviceCommandvalue record);
}

+ 17
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceConfigMapper.java Wyświetl plik

@@ -0,0 +1,17 @@
package com.ssjl.zhaobiao.guizhou.repository;

import com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig;

public interface GpsDeviceConfigMapper {
int deleteByPrimaryKey(String serialno);

int insert(GpsDeviceConfig record);

int insertSelective(GpsDeviceConfig record);

GpsDeviceConfig selectByPrimaryKey(String serialno);

int updateByPrimaryKeySelective(GpsDeviceConfig record);

int updateByPrimaryKey(GpsDeviceConfig record);
}

+ 17
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceMapper.java Wyświetl plik

@@ -0,0 +1,17 @@
package com.ssjl.zhaobiao.guizhou.repository;

import com.ssjl.zhaobiao.guizhou.entity.GpsDevice;

public interface GpsDeviceMapper {
int deleteByPrimaryKey(String deviceId);

int insert(GpsDevice record);

int insertSelective(GpsDevice record);

GpsDevice selectByPrimaryKey(String deviceId);

int updateByPrimaryKeySelective(GpsDevice record);

int updateByPrimaryKey(GpsDevice record);
}

+ 19
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/repository/GpsDeviceStatusMapper.java Wyświetl plik

@@ -0,0 +1,19 @@
package com.ssjl.zhaobiao.guizhou.repository;

import com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus;

public interface GpsDeviceStatusMapper {
int deleteByPrimaryKey(String deviceId);

int insert(GpsDeviceStatus record);

int insertSelective(GpsDeviceStatus record);

GpsDeviceStatus selectByPrimaryKey(String deviceId);

int updateByPrimaryKeySelective(GpsDeviceStatus record);

int updateByPrimaryKey(GpsDeviceStatus record);

GpsDeviceStatus selectByImei(String imei);
}

+ 4
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZLocationService.java Wyświetl plik

@@ -0,0 +1,4 @@
package com.ssjl.zhaobiao.guizhou.service;

public interface IGZLocationService {
}

+ 4
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformCmdService.java Wyświetl plik

@@ -0,0 +1,4 @@
package com.ssjl.zhaobiao.guizhou.service;

public interface IGZPlatformCmdService extends IGZPlatformService {
}

+ 12
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformService.java Wyświetl plik

@@ -0,0 +1,12 @@
package com.ssjl.zhaobiao.guizhou.service;

import com.ssjl.zhaobiao.guizhou.entity.GZDeviceFlagType;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;

import java.io.IOException;

public interface IGZPlatformService {

Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException;
}

+ 6
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/IGZPlatformSettingService.java Wyświetl plik

@@ -0,0 +1,6 @@
package com.ssjl.zhaobiao.guizhou.service;

public interface IGZPlatformSettingService extends IGZPlatformService {


}

+ 112
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformCmdService.java Wyświetl plik

@@ -0,0 +1,112 @@
package com.ssjl.zhaobiao.guizhou.service.impl;

import com.ssjl.zhaobiao.guizhou.entity.*;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZPlatformCmd;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZUpDeviceConfig;
import com.ssjl.zhaobiao.guizhou.repository.DianxinGzDeviceConfigMapper;
import com.ssjl.zhaobiao.guizhou.repository.GpsDeviceConfigMapper;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformCmdService;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformService;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZHttpUtil;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class GZPlatformCmdService implements IGZPlatformCmdService {

@Value("${guizhou.protocol}")
private String gzProtocol;
@Value("${guizhou.factory}")
private String gzFactory;
@Value("${guizhou.device.model}")
private String gzDeviceModel;
@Value("${guizhou.device.version}")
private String deviceVersion;
@Autowired
private GpsDeviceConfigMapper configMapper;
@Autowired
private DianxinGzDeviceConfigMapper gzDeviceConfigMapper;
@Autowired
private GZHttpUtil httpUtil;

@Override
public Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException {
GZPlatformCmd cmd = (GZPlatformCmd) msg;
if(cmd.getUpLocation() != null){
// 上报位置信息

}
if(cmd.getUpSetting() != null){
// 上报设置参数
// 先查询参数

DianxinGzDeviceConfig gzConfig = null;
if(flagType == GZDeviceFlagType.IMEI){
gzConfig = gzDeviceConfigMapper.selectByImei(deviceFlag);
}else{
gzConfig = gzDeviceConfigMapper.selectByPhone(deviceFlag);
}
if(gzConfig == null){
gzConfig = new DianxinGzDeviceConfig();
gzConfig.setDeviceImei(flagType == GZDeviceFlagType.IMEI ? deviceFlag : "");
gzConfig.setPhone(flagType == GZDeviceFlagType.PHONE ? deviceFlag : "");
}
GpsDeviceConfig dbConfig = configMapper.selectByPrimaryKey(gzConfig.getDeviceImei());

GZUpDeviceConfig config = new GZUpDeviceConfig();
for (int i = 0; i < cmd.getUpSetting().length(); i++) {
char s = cmd.getUpSetting().charAt(i);
String item = String.valueOf(s).toUpperCase();
if(item.equals("S")){
// 终端运营商信息
// 运营商类型,当前接入网络制式
//运营商类型:
//电信为 0, 移动为 1, 联通为 2, 其它为 3
//当前接入网络制式:
//GSM/GPRS/EDGE/HSUPA/HSDPA/WCDMA/TD-LTE/FDD-LTE
//例: 0,WCDMA
config.setOperator("0,WCDMA");
}
else if(item.equals("T")){
// IMEI 号,终端机器码
config.setImei(gzConfig.getDeviceImei());
}else if(item.equals("U")){
// 通信协议版本号, 统一为 4 个数据, 中间加“.” 的格式: XX.X
//(必需填写, 平台对协议作兼容处理)
config.setProtocol(gzProtocol);
}else if(item.equals("V")){
// 产品型号
config.setDeviceModel(gzDeviceModel);
}else if(item.equals("W")){
// 终端软件 APP 版本号
config.setAppVersion("v 1.0.13");
}else if(item.equals("X")){
// 生产厂家名字
config.setFacotryName(gzFactory);
}else if(item.equals("Y")){
// IMSI 号, 手机卡移动用户识别码
config.setImsi(gzConfig.getPhone());
}else if(item.equals("Z")){
// 终端系统版本号
// config.setDeviceVersion(dbConfig == null ? "" : dbConfig.getProductMode());
config.setDeviceVersion(deviceVersion);
}else if(item.equals("R")){
// 上报2.4G卡号(RFID) , 如有RFID功能, 开机时上报本机的RFID
String rfid = dbConfig == null ? "" : dbConfig.getIdNumber();
rfid = rfid.equals("Unknown") ? "" : rfid;
config.setRfid(rfid);
}
}
System.out.println("上传终端信息");
System.out.println(ByteUtil.bytesToHexString(config.toBytes()));
return httpUtil.send(gzConfig.getDeviceImei(), gzConfig.getPhone(), config);
}
// 其他暂不实现
return null;
}
}

+ 178
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/service/impl/GZPlatformSettingService.java Wyświetl plik

@@ -0,0 +1,178 @@
package com.ssjl.zhaobiao.guizhou.service.impl;

import com.alibaba.fastjson.JSON;
import com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig;
import com.ssjl.zhaobiao.guizhou.entity.GZDeviceFlagType;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationInterval;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZPlatformDeviceConfig;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import com.ssjl.zhaobiao.guizhou.entity.IOT.Api.*;
import com.ssjl.zhaobiao.guizhou.repository.DianxinGzDeviceConfigMapper;
import com.ssjl.zhaobiao.guizhou.service.IGZPlatformSettingService;
import com.ssjl.zhaobiao.guizhou.utils.IOTApiUtil;
import com.ssjl.zhaobiao.guizhou.utils.UnicodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class GZPlatformSettingService implements IGZPlatformSettingService {

@Autowired
DianxinGzDeviceConfigMapper configMapper;
@Autowired
IOTApiUtil iotApiUtil;

@Override
public Object process(IMessageContent msg, String deviceFlag, GZDeviceFlagType flagType, byte msgIndex, GZRequestStatus requestStatus) throws IOException {
GZPlatformDeviceConfig config = (GZPlatformDeviceConfig)msg;
DianxinGzDeviceConfig dbConfig = null;
String imei = "";
boolean isUpdate = true;
if(flagType == GZDeviceFlagType.PHONE){
dbConfig = configMapper.selectByPhone(deviceFlag);

}else{
dbConfig = configMapper.selectByImei(deviceFlag);
imei = deviceFlag;
}
if(dbConfig == null){
dbConfig = new DianxinGzDeviceConfig();
dbConfig.setDeviceImei(imei);
isUpdate = false;
}else{
imei = dbConfig.getDeviceImei();
}
boolean allSuccess = true;
// 下发给iot接口
// 位置上报间隔,设备可能不在线,先每次都更新简单处理
if(dbConfig.getLocationInterval() == null || !dbConfig.getLocationInterval().equals(config.getLocationInterval())){
// if(true){
List<GZLocationInterval> list = GZLocationInterval.build(config.getLocationInterval());
if(GZLocationInterval.isStop(list)){
// 停止上报
IotApiLocationMode mode = new IotApiLocationMode();
mode.setMode(0);
mode.setSerialno(imei);
mode.setTimeInterval(300);
IotApiResponse rs = iotApiUtil.setLocationMode(mode);
System.out.println(JSON.toJSONString(rs));
if(checkOffline(rs.getMessage())){
allSuccess = false;
}
}else{
// 开启普通模式
IotApiLocationMode mode = new IotApiLocationMode();
mode.setMode(1);
mode.setSerialno(imei);
mode.setTimeInterval(GZLocationInterval.minInterval(list) * 60);
IotApiResponse rs = iotApiUtil.setLocationMode(mode);
System.out.println(JSON.toJSONString(rs));
if(checkOffline(rs.getMessage())){
allSuccess = false;
}
}
}
// 休眠免打扰时间
if(dbConfig.getSleepTime() == null || !dbConfig.getSleepTime().equals(config.getSleepTime())){
// if(true){
IotApiSleepTime sleepTime = new IotApiSleepTime();
sleepTime.setSerialNo(imei);
IotApiNotDisturb notDisturb = new IotApiNotDisturb();
notDisturb.setSerialNo(imei);
String[] strs = config.getSleepTime().split(",");
for (int i = 0; i < strs.length; i++) {
String str = strs[i];
if(str.equals("")){
continue;
}
str.replace("*", "1234567");
String[] times = str.split("/");
String timeSet = times[1];
String startTime = timeSet.substring(0, 2) +":" + timeSet.substring(2, 4);
String endTime = timeSet.substring(4, 6) +":" + timeSet.substring(6, 8);
sleepTime.addTime(startTime, endTime, times[0]);
notDisturb.addItem(startTime, endTime, 0, 1, times[0]);
// for (int j = 0; j < times[0].length(); j++) {
// char day = times[0].charAt(j);
// sleepTime.addTime(startTime, endTime, String.valueOf(day));
// }
}
System.out.println(JSON.toJSONString(sleepTime));
IotApiResponse rs = iotApiUtil.setSleepTime(sleepTime);
System.out.println(JSON.toJSONString(rs));
if(checkOffline(rs.getMessage())){
allSuccess = false;
}
IotApiResponse rs1 = iotApiUtil.setNotDisturb(notDisturb);
System.out.println(JSON.toJSONString(rs1));
if(checkOffline(rs1.getMessage())){
allSuccess = false;
}
}
// 亲情号码
if(dbConfig.getAffectionPhone() == null || !dbConfig.getAffectionPhone().equals(config.getAffectionPhone())){
// if(true){
String[] phones = config.getAffectionPhone().split(",");
IotApiWhiteList whiteList = new IotApiWhiteList();
whiteList.setSerialNo(imei);
for (int i = 0; i < phones.length; i++) {
String phone = phones[i];
String relationship = "";
if(phone.indexOf("/") > -1){
String[] pstrs = phone.split("/");
phone = pstrs[0];
relationship = UnicodeUtil.unicodeToCn(pstrs[1]);
}
whiteList.addPhone(phone, relationship, String.valueOf(i + 1), i == 0 ? 1 : 0);
}
IotApiResponse phoneRs = iotApiUtil.setWhiteList(whiteList);
System.out.println(JSON.toJSONString(phoneRs));
if(checkOffline(phoneRs.getMessage())){
allSuccess = false;
}
}

if(allSuccess){
// 存入数据库
dbConfig.setPhone(config.getDevicePhone());
dbConfig.setHttpIp(config.getHttpIp());
dbConfig.setHttpUrl(config.getHttpUrl());
dbConfig.setSmsNumber(config.getSmsNo());
dbConfig.setLocationInterval(config.getLocationInterval());
dbConfig.setSleepTime(config.getSleepTime());
dbConfig.setAffectionPhone(config.getAffectionPhone());
dbConfig.setSosPhone(config.getSosPhone());
dbConfig.setWhitePhone(config.getWhiteList());
dbConfig.setSmsWhitePhone(config.getSmsWhiteList());
dbConfig.setClockTime(config.getClockTime());
dbConfig.setSmsSet(config.getSmsSet());
dbConfig.setAddressBook(config.getAddressBook());
dbConfig.setSyncTime(config.getSyncTime());
dbConfig.setTcpAddress(config.getTcp());
dbConfig.setAutoShutdown(config.getAutoShutdownSet());
dbConfig.setCallTime(config.getCallTimeSet());
dbConfig.setLocationMode(config.getLocationModeSet());
dbConfig.setConnectType(config.getConnectType());
dbConfig.setPhoneType(config.getPhoneNoType());
dbConfig.setRfid(config.getRfid());
if(isUpdate){
configMapper.updateByPrimaryKey(dbConfig);
}else{
configMapper.insert(dbConfig);
}
}

return new byte[0];
}

private boolean checkOffline(String message){
if(message.indexOf("设备不在线") > -1 || message.indexOf("offline") > -1){
return true;
}
return false;
}
}

+ 23
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/ApplicationContextProvider.java Wyświetl plik

@@ -0,0 +1,23 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class ApplicationContextProvider implements ApplicationContextAware {

private static ApplicationContext context;

private ApplicationContextProvider(){}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}

public static <T> T getBean(String name,Class<T> aClass){
return context.getBean(name,aClass);
}
}

+ 141
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/ByteUtil.java Wyświetl plik

@@ -0,0 +1,141 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.stereotype.Component;

import java.math.BigInteger;
import java.util.Arrays;

@Component
public class ByteUtil {
/**
* 整数转成byte[],高位在前
* @param n 整数
* @return
*/
public static byte[] toByte(int n) {
byte[] b = new byte[4];
b[3] = (byte) (n & 0xff);
b[2] = (byte) (n >> 8 & 0xff);
b[1] = (byte) (n >> 16 & 0xff);
b[0] = (byte) (n >> 24 & 0xff);
return b;
}

/**
* 整数转成byte[].指定byte的位数,高位在前
* @param n
* @param len
* @return
*/
public static byte[] toByte(int n, int len) {
byte[] b = toByte(n);
int start = 4 - len;
byte[] o = Arrays.copyOfRange(b, start, 4);
return o;
}

/**
* byte[] 转 整型
* @param b
* @return
*/
public static int toInt(byte[] b){
int res = 0;
for(int i = 0;i < b.length;i++){
res = res << 8;
res = res | (b[i] & 0xFF);
}
return res;
}




/**
* hex字符串转byte数组
*
* @param inHex 待转换的Hex字符串
* @return 转换后的byte数组结果
*/
public static byte[] hexToByteArray(String inHex) {
int hexlen = inHex.length();
byte[] result;
if (hexlen % 2 == 1) {
//奇数
hexlen++;
result = new byte[(hexlen / 2)];
inHex = "0" + inHex;
} else {
//偶数
result = new byte[(hexlen / 2)];
}
int j = 0;
for (int i = 0; i < hexlen; i += 2) {
result[j] = hexToByte(inHex.substring(i, i + 2));
j++;
}
return result;
}
/**
* Hex字符串转byte
*
* @param inHex 待转换的Hex字符串
* @return 转换后的byte
*/
public static byte hexToByte(String inHex) {
return (byte) Integer.parseInt(inHex, 16);
}

/**
* 十六进制转字节数组
*
* @param src
* @return
*/
public static byte[] hexString2Bytes(String src) {
int l = src.length() / 2;
byte[] ret = new byte[l];
for (int i = 0; i < l; i++) {
ret[i] = (byte) Integer
.valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue();
}
return ret;
}

public static String bytesToHexString(byte[] bArr) {
if (bArr == null) {
return null;
}
StringBuffer sb = new StringBuffer(bArr.length);
String sTmp;

for (int i = 0; i < bArr.length; i++) {
sTmp = Integer.toHexString(0xFF & bArr[i]);
if (sTmp.length() < 2)
sb.append(0);
sb.append(sTmp);
}

return sb.toString();
}

/**
* 将字节数组转为long<br>
* 如果input为null,或offset指定的剩余数组长度不足8字节则抛出异常
* @param input
* @param offset 起始偏移量
* @param littleEndian 输入数组是否小端模式
* @return
*/
public static long byteToLong(byte[] input, int offset, boolean littleEndian){
long value=0;
// 循环读取每个字节通过移位运算完成long的8个字节拼装
for(int count=0;count<8;++count){
int shift=(littleEndian?count:(7-count))<<3;
value |=((long)0xff<< shift) & ((long)input[offset+count] << shift);
}
return value;
}


}

+ 114
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/DateUtil.java Wyświetl plik

@@ -0,0 +1,114 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
public class DateUtil {
public Date strToDate(String date) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(date);
}

public String format(Date date, String formatter){
SimpleDateFormat sdf = new SimpleDateFormat(formatter);
return sdf.format(date);
}

public String format(Date date){
return format(date, "yyyy-MM-dd HH:mm:ss");
}

public String formatDate(Date date){
return format(date, "yyyy-MM-dd");
}

public String format(LocalDate date, String formatter){
return date.format(DateTimeFormatter.ofPattern(formatter));
}

public String format(LocalDate date){
return format(date, "yyyy-MM-dd");
}

public int getMonthDays(int year, int month){
LocalDate date = LocalDate.of(year, month, 1);
date = date.plusMonths(1);
date = date.plusDays(-1);
return date.getDayOfMonth();
}

public LocalDate toLocalDate(Date date){
Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDate localDate = instant.atZone(zoneId).toLocalDate();
return localDate;
}

public String formatChineseWeek(Date date){
String[] days = { "", "一", "二", "三", "四", "五", "六", "日" };
LocalDate localDate = toLocalDate(date);
int i = localDate.getDayOfWeek().getValue();
return i < 8 ? days[i] : "";
}


/**
* 获取年龄
* @param nowStr 当前日期,以-分隔开,如2020-01-01
* @param birthdayStr 生日日期,以-分隔开,如2020-01-01
* @return 返回年龄对应的数字,固定三个元素,分别对应年月日
*/
public List<Integer> getAge(String nowStr, String birthdayStr){
LocalDate nowDate = LocalDate.parse(nowStr);
LocalDate birthday = LocalDate.parse(birthdayStr);
List<Integer> list = new ArrayList<>();
//如果截止日期小于出生日期,直接返回0
if(nowDate.isBefore(birthday))
{
list.add(0);
list.add(0);
list.add(0);
return list;
}
int intYear = 0; // 岁
int intMonth = 0; // 月
int intDay = 0; // 天

// 计算天数
intDay = nowDate.getDayOfMonth() - birthday.getDayOfMonth();
if (intDay < 0)
{
nowDate = nowDate.minusMonths(1);
intDay += nowDate.lengthOfMonth();
}

// 计算月数
intMonth = nowDate.getMonthValue() - birthday.getMonthValue();
//intMonth = dtNow.Month - dtBirthday.Month;
if (intMonth < 0)
{
intMonth += 12;
nowDate= nowDate.minusYears(1);
// dtNow = dtNow.AddYears(-1);
}

// 计算年数
intYear = nowDate.getYear() - birthday.getYear();
//intYear = dtNow.Year - dtBirthday.Year;

list.add(intYear);
list.add(intMonth);
list.add(intDay);
return list;
}
}

+ 40
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java Wyświetl plik

@@ -0,0 +1,40 @@
package com.ssjl.zhaobiao.guizhou.utils;

import com.ssjl.zhaobiao.guizhou.entity.GZRequest;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import com.ssjl.zhaobiao.guizhou.entity.IMessageContent;
import okhttp3.Headers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class GZHttpUtil {
@Autowired
OkHttpUtil httpUtil;
@Value("${guizhou.http.url}")
String url;

public byte[] send(String imei, String phone, GZRequest req) throws IOException {
Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build();
byte[] b = req.toByte();
try {
byte[] res = httpUtil.postBytes(url, b, headers);
return res;
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}

public byte[] send(String imei, String phone, IMessageContent msg) throws IOException {
GZRequest req = new GZRequest();
req.setImei(imei);
req.setIndex(GZUtil.getMessageIndex());
req.setContent(msg);
req.setStatus(GZRequestStatus.RESPONSE_ALL);
return send(imei, phone, req);
}
}

+ 272
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZUtil.java Wyświetl plik

@@ -0,0 +1,272 @@
package com.ssjl.zhaobiao.guizhou.utils;

import com.google.common.base.Strings;
import com.ssjl.zhaobiao.guizhou.entity.GZDeviceStatus;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationCDMA;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationGSM;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationWIFIItem;
import com.ssjl.zhaobiao.guizhou.entity.GZRequest;
import com.ssjl.zhaobiao.guizhou.entity.GZRequestStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Component
public class GZUtil {

private static int msgIndex = 0;
private static Lock lock = new ReentrantLock();


public static byte getMessageIndex(){
lock.lock();
try{
int i = (msgIndex + 1) & 0xFF;
msgIndex = i;
return (byte) i;
}finally {
lock.unlock();
}
}

public static byte requestStatus(GZRequestStatus status){
int s = 0x00;
switch (status){
case RESPONSE_ALL:
s = 0x03;
break;
case RESPONSE_ERROR:
s = 0x02;
break;
}
byte o = (byte)s;
o = (byte)(o << 4 | 0x08);
return o;
}

public static byte check(byte[] list){
int sum = 0;
for (int i = 0; i < list.length; i++) {
byte b = list[i];
sum += b;
sum = sum & 0xFF;
}
return (byte)sum;
}

public static byte[] encode(byte[] bytes){
// 数据通道的消息格式中除了“标识” 部分, 如果出现 0x7E, 则
// 要进行转义处理, 转义规则定义如下:
// 0x7E <----> 0x7D 后紧跟一个 0x02;
// 0x7D <----> 0x7D 后紧跟一个 0x01;
List<Byte> list = new ArrayList<>();
list.add(bytes[0]);
for (int i = 1; i < bytes.length - 1; i++) {
byte b = bytes[i];
if(b == (byte)0x7E){
list.add((byte)0x7D);
list.add((byte)0x02);
} else if(b == (byte)0x7D){
list.add((byte)0x7D);
list.add((byte)0x01);
}else{
list.add(b);
}
}
list.add(bytes[bytes.length - 1]);
return listToBytes(list);
}

public static byte[] decode(byte[] bytes){
// 数据通道的消息格式中除了“标识” 部分, 如果出现 0x7E, 则
// 要进行转义处理, 转义规则定义如下:
// 0x7E <----> 0x7D 后紧跟一个 0x02;
// 0x7D <----> 0x7D 后紧跟一个 0x01;
List<Byte> list = new ArrayList<>();
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
if(b == (byte)0x7D){
byte next = bytes[i+1];
if(next == (byte)0x02){
list.add((byte)0x7E);
}else{
list.add(b);
}
i++;
}else{
list.add(b);
}
}
return listToBytes(list);
}

public static byte[] listToBytes(List<Byte> list){
byte[] out = new byte[list.size()];
for (int i = 0; i < list.size(); i++) {
out[i] = list.get(i);
}
return out;
}

public static String timeToStr(int hour, int min, int sec){
String str = "";
str += hour < 10 ? "0" + hour : hour;
str += min < 10 ? "0" + min : min;
str += sec < 10 ? "0" + sec : sec;
return str;
}

public static byte[] toLocationBytes(int direct, boolean gpsRough, int value){
int weidu = direct;
weidu = gpsRough ? weidu << 1 : weidu << 1 | 1;
weidu = weidu << 30;
weidu = weidu | value;
byte[] bytes = ByteUtil.toByte(weidu);
return bytes;
}

/**
* 信号强度
* @param value
* @return
*/
public static byte signalIntensity(int value){
//1、 当最高位为 0 时, 信号值为百分比; 如信号 85%, 0x55
//2、 当最高位为 1 时, 信号值的范围为 0 到-113dbm, 当正数时请按照以下公式进行转换:
//获得的正信号强度 * 2 –113, 取绝对值, 转换为 16进制;
// 如-90dbm, 绝对值90, 转 十 六 进 制 ,0xDA=0x80|0x5A
int h = value >> 7 & 0x01;
if(h==0){
return (byte)value;
}else{
int i = 0;
if(value > 0){
i = Math.abs(value * 2 - 113);
}else{
i = Math.abs(value);
}
return (byte)(0x80 | i);
}
}

public static byte[] imeiToByte(String imei){
String hex;
if(imei.length() <= 15){
hex = imei + "D";
}else{
BigInteger num = new BigInteger(imei);
hex = num.toString(16);
hex += "C";
}
while (hex .length() < 16){
hex = "0" + hex;
}
return ByteUtil.hexToByteArray(hex);
}

/**
* 获得终端号码,可能是手机号,也可能是IMEI
* @param bytes
* @return
*/
public static String byteToDeviceFlag(byte[] bytes){
String byteStr = ByteUtil.bytesToHexString(bytes).toUpperCase();
String type = byteStr.substring(byteStr.length() - 1);
String flag = "";
if(type.equals("F")){
flag = byteStr.substring(0, byteStr.indexOf('F')) + ",phone";
} else if(type.equals("E")){
flag = byteStr.substring(0, byteStr.indexOf('E'));
byte[] b = ByteUtil.hexToByteArray(flag);
flag = String.valueOf(ByteUtil.byteToLong(b, 0, false)) + ",phone";
} else if(type.equals("D")){
flag = byteStr.substring(0, byteStr.length() - 1);
while (!Strings.isNullOrEmpty(flag) && flag.substring(0,1).equals("0")){
flag = flag.substring(1);
}
flag = flag + ",imei";
}else if(type.equals("C")){
flag = byteStr.substring(0, byteStr.indexOf('C'));
byte[] b = ByteUtil.hexToByteArray(flag);
flag = String.valueOf(ByteUtil.byteToLong(b, 0, false)) + ",imei";
}
return flag;
}

public static GZRequestStatus parseGZRequestStatus(byte b){
int type = b >> 4 & 0x03;
if(type == 0){
return GZRequestStatus.RESPONSE_NO;
}else if(type == 2){
return GZRequestStatus.RESPONSE_ERROR;
}else if(type == 3){
return GZRequestStatus.RESPONSE_ALL;
}
return GZRequestStatus.RESPONSE_NO;
}

public static int convertLocation(double value){
return (int) Math.round(value * 60 * 10000);
}

public static GZLocationGSM toGSM(String bts, String nearbts){
GZLocationGSM gsm = new GZLocationGSM();
String[] btss = bts.split(",");
byte[] mcc = ByteUtil.toByte(Integer.parseInt(btss[0]), 2);
byte[] mnc = ByteUtil.toByte(Integer.parseInt(btss[1]), 2);
String[] nearbtss = nearbts.split("\\|");
if(Strings.isNullOrEmpty(nearbts)){
nearbtss = new String[0];
}
byte[] gsmList = new byte[(nearbtss.length + 1) * 6];
byte[] bytes = toGSMItem(bts);
int i = 0;
System.arraycopy(bytes, 0, gsmList, i, bytes.length);
i += bytes.length;
for (int j = 0; j < nearbtss.length; j++) {
bytes = toGSMItem(nearbtss[j]);
System.arraycopy(bytes, 0, gsmList, i, bytes.length);
i += bytes.length;
}
gsm.setMCC(mcc);
gsm.setMNC(mnc);
gsm.setGSMList(gsmList);
return gsm;
}
private static byte[] toGSMItem(String bts){

String[] btss = bts.split(",");
byte[] list = new byte[6];
int i = 0;
byte[] bytes = ByteUtil.toByte(Integer.parseInt(btss[2]), 2);
System.arraycopy(bytes, 0, list, i, bytes.length);
i += bytes.length;
bytes = ByteUtil.toByte(Integer.parseInt(btss[3]), 3);
System.arraycopy(bytes, 0, list, i, bytes.length);
i += bytes.length;
list[i++] = signalIntensity(Integer.parseInt(btss[4]));
return list;
}

public static GZLocationWIFIItem toWifiItem(String mmac){
GZLocationWIFIItem item = new GZLocationWIFIItem();
String[] wifis = mmac.split(",");
item.setMac(wifis[0]);
item.setSignalIntensity(Integer.parseInt(wifis[1]));
if(wifis.length > 2){
item.setName(wifis[2]);
}else{
item.setName("");
}
return item;
}




}

+ 77
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/HelperUtil.java Wyświetl plik

@@ -0,0 +1,77 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@Component
public class HelperUtil {

public HelperUtil(){
System.out.println("HelperUtil start");
}


public void saveStringToFile(String msg, String path) throws IOException {
try{
FileOutputStream fop = null;
File file;
try {
file = new File(path);
fop = new FileOutputStream(file);
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
// get the content in bytes
byte[] contentInBytes = msg.getBytes();
fop.write(contentInBytes);
fop.flush();
fop.close();
} catch (IOException e) {
e.printStackTrace();
throw e;
} finally {
try {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
}catch (Exception ex){
throw ex;
}
}

public String currTimeStr(){
LocalDateTime time = LocalDateTime.now();
return time.format(DateTimeFormatter.ofPattern("yyyyMMddhhmmss"));
}

public Date localDateToDate(LocalDate date){
return Date.from(date.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
}

public String dateToString(Date time, String format){
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(time);
}
public String dateToString(Date time){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return dateFormat.format(time);
}



}

+ 60
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/IOTApiUtil.java Wyświetl plik

@@ -0,0 +1,60 @@
package com.ssjl.zhaobiao.guizhou.utils;

import com.alibaba.fastjson.JSON;
import com.ssjl.zhaobiao.guizhou.entity.IOT.Api.*;
import okhttp3.Headers;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class IOTApiUtil {

@Autowired
OkHttpUtil httpUtil;
@Value("${4g.api.apiUrl}")
String apiUrl;
@Value("${4g.api.token}")
String token;
@Value("${4g.api.key}")
String key;

public IotApiResponse setWhiteList(IotApiWhiteList list) throws IOException {
return send("/api/Command/SetWhiteList", JSON.toJSONString(list), AuthTye.TOKEN);
}

public IotApiResponse setSleepTime(IotApiSleepTime time) throws IOException {
return send("/api/Command/SetDormancy", JSON.toJSONString(time), AuthTye.KEY);
}

public IotApiResponse setLocationMode(IotApiLocationMode mode) throws IOException {
return send("/api/Command/SetDeviceLocateMode", JSON.toJSONString(mode), AuthTye.TOKEN);
}

public IotApiResponse setNotDisturb(IotApiNotDisturb disturb) throws IOException {
return send("/api/Command/SetNotDisturb", JSON.toJSONString(disturb), AuthTye.TOKEN);
}

public IotApiResponse activeDevice(IotApiActiveDevice active) throws IOException {
return send("/api/Command/ActivateDevice", JSON.toJSONString(active), AuthTye.TOKEN);
}

private IotApiResponse send(String url ,String json, AuthTye authType) throws IOException {
Headers headers;
if(authType == AuthTye.TOKEN){
headers = new Headers.Builder().add("AuthToken", token).build();
}else{
headers = new Headers.Builder().add("AuthKey", key).build();
}
String rs = httpUtil.postJson(apiUrl + url, json, headers);
return JSON.parseObject(rs, IotApiResponse.class);
}

enum AuthTye{
TOKEN,
KEY
}
}

+ 99
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/OkHttpUtil.java Wyświetl plik

@@ -0,0 +1,99 @@
package com.ssjl.zhaobiao.guizhou.utils;

import okhttp3.*;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class OkHttpUtil {
private OkHttpClient client;

private static final MediaType JSON = MediaType.get("application/json; charset=utf-8");

private static final MediaType WWWFORM = MediaType.get("application/x-www-form-urlencoded");

public OkHttpUtil() {
client = new OkHttpClient();
}

public String get(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}

public String postJson(String url, String json) throws IOException {
RequestBody requestBody = RequestBody.create(json, JSON);
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}

public String postJson(String url, String json, Headers headers) throws IOException {
RequestBody requestBody = RequestBody.create(json, JSON);
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.headers(headers)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}

public String postWwwForm(String url, Map<String, String> formMap) throws IOException {
FormBody.Builder formBuilder = new FormBody.Builder();
for(Map.Entry<String, String> item : formMap.entrySet()){
formBuilder.add(item.getKey(), item.getValue());
}
RequestBody requestBody = formBuilder.build();
Headers headers = new Headers.Builder().add("Content-Type", "application/x-www-form-urlencoded").build();
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.headers(headers)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}

public String postFormdata(String url, Map<String, String> formMap) throws IOException {
FormBody.Builder formBuilder = new FormBody.Builder();
for(Map.Entry<String, String> item : formMap.entrySet()){
formBuilder.add(item.getKey(), item.getValue());
}
Headers headers = new Headers.Builder().add("Content-Type", "multipart/form-data").build();
RequestBody requestBody = formBuilder.build();
Request request=new Request.Builder()
.url(url)
.post(requestBody)
.headers(headers)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}

public byte[] postBytes(String url, byte[] bytes, Headers headers) throws IOException {
MediaType mediaType = MediaType.parse("application/octet-stream;charset=UTF-8");
RequestBody requestBody = RequestBody.create(bytes, mediaType);
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.headers(headers)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().bytes();
}
}
}

+ 30
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/RedisUtil.java Wyświetl plik

@@ -0,0 +1,30 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
//import redis.clients.jedis.Jedis;


public class RedisUtil {

@Value("${redis.host}")
private String redisHost;
//
// Jedis jedis;
//
// public void init(){
// jedis = new Jedis(redisHost);
// }
//
// public void setString(String key, String value){
// jedis.set(key, value);
// }
// public void setStringWithSecond(String key, String value, int second){
// jedis.set(key, value);
// jedis.expire(key, second);
// }
//
// public String getString(String key){
// return jedis.get(key);
// }
}

+ 26
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/Runner.java Wyświetl plik

@@ -0,0 +1,26 @@
package com.ssjl.zhaobiao.guizhou.utils;

import com.ssjl.zhaobiao.guizhou.netty.NettyClient;
import com.ssjl.zhaobiao.guizhou.netty.NettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class Runner implements CommandLineRunner {

@Autowired
NettyServer nettyServer;
@Autowired
NettyClient nettyClient;


@Override
public void run(String... args) throws Exception {
// echartImage.init();
// redisUtil.init();
// mqManager.init();
// nettyServer.start();
// nettyClient.start();
}
}

+ 213
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/SnowFlakeGenerator.java Wyświetl plik

@@ -0,0 +1,213 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;

import java.net.Inet4Address;
import java.net.UnknownHostException;

/**
* SnowFlake的结构如下(每部分用-分开):<br>
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
* 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
* 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
* 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
* 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
* 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
* 加起来刚好64位,为一个Long型。<br>
* SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
**/
public class SnowFlakeGenerator {
/**
* 开始时间截 (2015-01-01)
*/
private final long twepoch = 1577934655000L;

/**
* 机器id所占的位数
*/
private final long workerIdBits = 5L;

/**
* 数据标识id所占的位数
*/
private final long dataCenterIdBits = 5L;

/**
* 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
*/
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);

/**
* 支持的最大数据标识id,结果是31
*/
private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits);

/**
* 序列在id中占的位数
*/
private final long sequenceBits = 12L;

/**
* 机器ID向左移12位
*/
private final long workerIdShift = sequenceBits;

/**
* 数据标识id向左移17位(12+5)
*/
private final long dataCenterIdShift = sequenceBits + workerIdBits;

/**
* 时间截向左移22位(5+5+12)
*/
private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;

/**
* 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
*/
private final long sequenceMask = -1L ^ (-1L << sequenceBits);

/**
* 工作机器ID(0~31)
*/
private long workerId;

/**
* 数据中心ID(0~31)
*/
private long dataCenterId;

/**
* 毫秒内序列(0~4095)
*/
private long sequence = 0L;

/**
* 上次生成ID的时间截
*/
private long lastTimestamp = -1L;

private static SnowFlakeGenerator idWorker;

static {
idWorker = new SnowFlakeGenerator(getWorkId(), getDataCenterId());
}

//==============================Constructors=====================================

/**
* 构造函数
*
* @param workerId 工作ID (0~31)
* @param dataCenterId 数据中心ID (0~31)
*/
public SnowFlakeGenerator(long workerId, long dataCenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("workerId can't be greater than %d or less than 0", maxWorkerId));
}
if (dataCenterId > maxDataCenterId || dataCenterId < 0) {
throw new IllegalArgumentException(String.format("dataCenterId can't be greater than %d or less than 0", maxDataCenterId));
}
this.workerId = workerId;
this.dataCenterId = dataCenterId;
}

// ==============================Methods==========================================

/**
* 获得下一个ID (该方法是线程安全的)
*
* @return SnowflakeId
*/
public synchronized long nextId() {
long timestamp = timeGen();

//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
throw new RuntimeException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}

//如果是同一时间生成的,则进行毫秒内序列
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
//毫秒内序列溢出
if (sequence == 0) {
//阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
}
//时间戳改变,毫秒内序列重置
else {
sequence = 0L;
}

//上次生成ID的时间截
lastTimestamp = timestamp;

//移位并通过或运算拼到一起组成64位的ID
return ((timestamp - twepoch) << timestampLeftShift)
| (dataCenterId << dataCenterIdShift)
| (workerId << workerIdShift)
| sequence;
}

/**
* 阻塞到下一个毫秒,直到获得新的时间戳
*
* @param lastTimestamp 上次生成ID的时间截
* @return 当前时间戳
*/
protected long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}

/**
* 返回以毫秒为单位的当前时间
*
* @return 当前时间(毫秒)
*/
protected long timeGen() {
return System.currentTimeMillis();
}

private static Long getWorkId() {
try {
String hostAddress = Inet4Address.getLocalHost().getHostAddress();
int[] ints = StringUtils.toCodePoints(hostAddress);
int sums = 0;
for (int b : ints) {
sums += b;
}
return (long) (sums % 32);
} catch (UnknownHostException e) {
// 如果获取失败,则使用随机数备用
return RandomUtils.nextLong(0, 31);
}
}

private static Long getDataCenterId() {
int[] ints = StringUtils.toCodePoints("as-comment");
int sums = 0;
for (int i : ints) {
sums += i;
}
return (long) (sums % 32);
}


/**
* 静态工具类
*
* @return
*/
public static Long generateId() {
long id = idWorker.nextId();
return id;
}
}

+ 151
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/UnicodeUtil.java Wyświetl plik

@@ -0,0 +1,151 @@
package com.ssjl.zhaobiao.guizhou.utils;

import org.springframework.stereotype.Component;

@Component
public class UnicodeUtil {

/**
* 将String内容转成Unicode,且忽略\\u
*
* @param str
* @return
*/
public static byte[] putString2UnicodeBytes(String str) {
return putString2UnicodeBytes(str, true);
}

/**
* 将字符串转成unicode
*
* @param str 待转字符串
* @return unicode字符串
*/
public static byte[] putString2UnicodeBytes(String str, boolean isBig) {
str = (str == null ? "" : str);
char c;
int i, j;

byte[] strByteRes = new byte[str.length() * 2];
for (i = 0; i < str.length(); i++) {
c = str.charAt(i);

if (isBig) { // 大端
j = (c >>> 8); // 取出高8位
strByteRes[2 * i] = (byte) j;

j = (c & 0xFF); // 取出低8位
strByteRes[2 * i + 1] = (byte) j;

} else { // 小端
j = (c & 0xFF); // 取出低8位
strByteRes[2 * i] = (byte) j;

j = (c >>> 8); // 取出高8位
strByteRes[2 * i + 1] = (byte) j;
}
}

return strByteRes;
}

/**
* 将字符串转成unicode
*
* @param str
* @return
*/
public static String putString2UnicodeString(String str) {
str = (str == null ? "" : str);
String tmp;
StringBuffer sb = new StringBuffer(1000);
char c;
int i, j;
sb.setLength(0);
for (i = 0; i < str.length(); i++) {
c = str.charAt(i);
sb.append("\\u");
j = (c >>> 8); //取出高8位
tmp = Integer.toHexString(j);
if (tmp.length() == 1)
sb.append("0");
sb.append(tmp);
j = (c & 0xFF); //取出低8位
tmp = Integer.toHexString(j);
if (tmp.length() == 1)
sb.append("0");
sb.append(tmp);

}
return (new String(sb));
}




/**
* 将16进制表示的unicode转成中文,开头不含\\u
*
* @param unicodeBytes
* @return
*/
public static String unicodeBytes2Str(byte[] unicodeBytes) {
return unicodeBytes2Str(unicodeBytes, true);
}

/**
* \\u5f20 new byte[]{0x5f,0x20}
*
* @param unicodeBytes
* @param isBig
* @return
*/
public static String unicodeBytes2Str(byte[] unicodeBytes, boolean isBig) {
String strRes = "";
if (null == unicodeBytes) {
return strRes;
}

byte[] valueBytes = new byte[2];

for (int i = 0; i < unicodeBytes.length; i += 2) {
if (isBig) {
valueBytes[0] = unicodeBytes[i];
valueBytes[1] = unicodeBytes[i + 1];
// strRes += ((char) Integer.valueOf(TBaseNumber.byte2HexString(valueBytes), 16).intValue());
strRes += byte2Char(valueBytes, true);
} else {
valueBytes[0] = unicodeBytes[i + 1];
valueBytes[1] = unicodeBytes[i];
// strRes += ((char) Integer.valueOf(TBaseNumber.byte2HexString(valueBytes), 16).intValue());
strRes += byte2Char(valueBytes, true);
}

}

return strRes;
}

private static char byte2Char(byte[] b, boolean isBig) {
char c = 0;
if (isBig) {
c = (char) (((b[0] & 0xFF) << 8) | (b[1] & 0xFF));
} else {
c = (char) (((b[1] & 0xFF) << 8) | (b[0] & 0xFF));
}
return c;
}



public static String unicodeToCn(String unicode) {
/** 以 \ u 分割,因为java注释也能识别unicode,因此中间加了一个空格 */
String[] strs = unicode.split("\\\\u");
String returnStr = "";
// 由于unicode字符串以 \ u 开头,因此分割出的第一个字符是""。
for (int i = 1; i < strs.length; i++) {
returnStr += (char) Integer.valueOf(strs[i], 16).intValue();
}
return returnStr;
}
}

+ 57
- 0
src/main/resources/application.properties Wyświetl plik

@@ -0,0 +1,57 @@
server.port=8102
jdbc.type=mysql
spring.datasource.url=jdbc:mysql://183.238.195.77:23305/gps_card?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Hongkong&allowMultiQueries=true
## spring.datasource.url=jdbc:mysql://127.0.0.1:3306/lovicoco_school?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Hongkong&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=telpo#1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# mybatis
mybatis.type-aliases-package=com.ssjl.zhaobiao.guizhou.entity
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
# JWT
jwt.header=Authorization
jwt.secret=mySecret
jwt.expiration=604800
jwt.tokenHead="Bearer "
jwt.route.authentication.path=auth
jwt.route.authentication.refresh=refresh
jwt.route.authentication.register="auth/register"
jwt.access_token.expiration=6400
jwt.refresh_token_expiration=600

logging.file.path=/home/data/zhaobiao/guizhou/logs

spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss

spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8

#Netty
netty.host=127.0.0.1
netty.port=8888

4g.api.apiUrl = http://47.116.142.20/webapi
4g.api.key = 7368616e78697869616f616e746f6e67
4g.api.token = 123Te1p0Te1p0321
# \u8D35\u5DDE\u7535\u4FE1\u53C2\u6570
guizhou.protocol=T01.4
#guizhou.factory=telpo
#guizhou.device.model=TPS401
#guizhou.device.version=ACB_1001
guizhou.factory=zhizhong
guizhou.device.model=RZL600
guizhou.device.version=RZL_2021
#guizhou.factory=zhanneng
#guizhou.device.model=TPE390
#guizhou.device.version=TPE_0056
guizhou.http.url=http://202.105.147.30:24183
guizhou.device.testList= [{ "imei": "862622050253671","phone": "18664272743" },{ "imei": "862622050253358","phone": "" },{ "imei": "800115470000678","phone": "13500259054" }]
guizhou.device.zhizhong=862622050654340,862622050317740
guizhou.device.zhanneng=862622050925104,862622050927027
guizhou.device.tianbo=862622050253671,862622050253358,800115470000678
guizhou.http.zhizhong=http://139.196.198.68:8102/iot
guizhou.http.zhanneng=http://139.196.106.140:8102/iot

BIN
src/main/resources/font/NotoSerifCJKsc-Medium.otf Wyświetl plik


+ 49
- 0
src/main/resources/generatorConfig.xml Wyświetl plik

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<!-- <classPathEntry location="E:\developer\mybatis-generator-core-1.3.2\lib\mysql-connector-java-5.1.25-bin.jar"/>-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://183.238.195.77:23305/gps_card?serverTimezone=Hongkong" userId="root"
password="telpo#1234">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.ssjl.zhaobiao.guizhou.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.ssjl.zhaobiao.guizhou.repository"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->

<!--<table tableName="dianxin_gz_device_config" enableCountByExample="false" enableUpdateByExample="false"-->
<!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="gps_device" enableCountByExample="false" enableUpdateByExample="false"-->
<!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="gps_device_commandvalue" enableCountByExample="false" enableUpdateByExample="false"-->
<!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!--<table tableName="gps_device_config" enableCountByExample="false" enableUpdateByExample="false"-->
<!--enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<table tableName="gps_device_status" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>

+ 313
- 0
src/main/resources/mapper/DianxinGzDeviceConfigMapper.xml Wyświetl plik

@@ -0,0 +1,313 @@
<?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.ssjl.zhaobiao.guizhou.repository.DianxinGzDeviceConfigMapper">
<resultMap id="BaseResultMap" type="com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="device_imei" jdbcType="VARCHAR" property="deviceImei" />
<result column="http_ip" jdbcType="VARCHAR" property="httpIp" />
<result column="http_url" jdbcType="VARCHAR" property="httpUrl" />
<result column="sms_number" jdbcType="VARCHAR" property="smsNumber" />
<result column="location_interval" jdbcType="VARCHAR" property="locationInterval" />
<result column="sleep_time" jdbcType="VARCHAR" property="sleepTime" />
<result column="affection_phone" jdbcType="VARCHAR" property="affectionPhone" />
<result column="sos_phone" jdbcType="VARCHAR" property="sosPhone" />
<result column="white_phone" jdbcType="VARCHAR" property="whitePhone" />
<result column="sms_white_phone" jdbcType="VARCHAR" property="smsWhitePhone" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="clock_time" jdbcType="VARCHAR" property="clockTime" />
<result column="sms_set" jdbcType="VARCHAR" property="smsSet" />
<result column="address_book" jdbcType="VARCHAR" property="addressBook" />
<result column="sync_time" jdbcType="VARCHAR" property="syncTime" />
<result column="tcp_address" jdbcType="VARCHAR" property="tcpAddress" />
<result column="auto_shutdown" jdbcType="VARCHAR" property="autoShutdown" />
<result column="call_time" jdbcType="VARCHAR" property="callTime" />
<result column="location_mode" jdbcType="VARCHAR" property="locationMode" />
<result column="connect_type" jdbcType="VARCHAR" property="connectType" />
<result column="phone_type" jdbcType="VARCHAR" property="phoneType" />
<result column="rfid" jdbcType="VARCHAR" property="rfid" />
</resultMap>
<sql id="Base_Column_List">
id, device_imei, http_ip, http_url, sms_number, location_interval, sleep_time, affection_phone,
sos_phone, white_phone, sms_white_phone, phone, clock_time, sms_set, address_book,
sync_time, tcp_address, auto_shutdown, call_time, location_mode, connect_type, phone_type,
rfid
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dianxin_gz_device_config
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from dianxin_gz_device_config
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig">
insert into dianxin_gz_device_config (id, device_imei, http_ip,
http_url, sms_number, location_interval,
sleep_time, affection_phone, sos_phone,
white_phone, sms_white_phone, phone,
clock_time, sms_set, address_book,
sync_time, tcp_address, auto_shutdown,
call_time, location_mode, connect_type,
phone_type, rfid)
values (#{id,jdbcType=INTEGER}, #{deviceImei,jdbcType=VARCHAR}, #{httpIp,jdbcType=VARCHAR},
#{httpUrl,jdbcType=VARCHAR}, #{smsNumber,jdbcType=VARCHAR}, #{locationInterval,jdbcType=VARCHAR},
#{sleepTime,jdbcType=VARCHAR}, #{affectionPhone,jdbcType=VARCHAR}, #{sosPhone,jdbcType=VARCHAR},
#{whitePhone,jdbcType=VARCHAR}, #{smsWhitePhone,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
#{clockTime,jdbcType=VARCHAR}, #{smsSet,jdbcType=VARCHAR}, #{addressBook,jdbcType=VARCHAR},
#{syncTime,jdbcType=VARCHAR}, #{tcpAddress,jdbcType=VARCHAR}, #{autoShutdown,jdbcType=VARCHAR},
#{callTime,jdbcType=VARCHAR}, #{locationMode,jdbcType=VARCHAR}, #{connectType,jdbcType=VARCHAR},
#{phoneType,jdbcType=VARCHAR}, #{rfid,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig">
insert into dianxin_gz_device_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="deviceImei != null">
device_imei,
</if>
<if test="httpIp != null">
http_ip,
</if>
<if test="httpUrl != null">
http_url,
</if>
<if test="smsNumber != null">
sms_number,
</if>
<if test="locationInterval != null">
location_interval,
</if>
<if test="sleepTime != null">
sleep_time,
</if>
<if test="affectionPhone != null">
affection_phone,
</if>
<if test="sosPhone != null">
sos_phone,
</if>
<if test="whitePhone != null">
white_phone,
</if>
<if test="smsWhitePhone != null">
sms_white_phone,
</if>
<if test="phone != null">
phone,
</if>
<if test="clockTime != null">
clock_time,
</if>
<if test="smsSet != null">
sms_set,
</if>
<if test="addressBook != null">
address_book,
</if>
<if test="syncTime != null">
sync_time,
</if>
<if test="tcpAddress != null">
tcp_address,
</if>
<if test="autoShutdown != null">
auto_shutdown,
</if>
<if test="callTime != null">
call_time,
</if>
<if test="locationMode != null">
location_mode,
</if>
<if test="connectType != null">
connect_type,
</if>
<if test="phoneType != null">
phone_type,
</if>
<if test="rfid != null">
rfid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="deviceImei != null">
#{deviceImei,jdbcType=VARCHAR},
</if>
<if test="httpIp != null">
#{httpIp,jdbcType=VARCHAR},
</if>
<if test="httpUrl != null">
#{httpUrl,jdbcType=VARCHAR},
</if>
<if test="smsNumber != null">
#{smsNumber,jdbcType=VARCHAR},
</if>
<if test="locationInterval != null">
#{locationInterval,jdbcType=VARCHAR},
</if>
<if test="sleepTime != null">
#{sleepTime,jdbcType=VARCHAR},
</if>
<if test="affectionPhone != null">
#{affectionPhone,jdbcType=VARCHAR},
</if>
<if test="sosPhone != null">
#{sosPhone,jdbcType=VARCHAR},
</if>
<if test="whitePhone != null">
#{whitePhone,jdbcType=VARCHAR},
</if>
<if test="smsWhitePhone != null">
#{smsWhitePhone,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="clockTime != null">
#{clockTime,jdbcType=VARCHAR},
</if>
<if test="smsSet != null">
#{smsSet,jdbcType=VARCHAR},
</if>
<if test="addressBook != null">
#{addressBook,jdbcType=VARCHAR},
</if>
<if test="syncTime != null">
#{syncTime,jdbcType=VARCHAR},
</if>
<if test="tcpAddress != null">
#{tcpAddress,jdbcType=VARCHAR},
</if>
<if test="autoShutdown != null">
#{autoShutdown,jdbcType=VARCHAR},
</if>
<if test="callTime != null">
#{callTime,jdbcType=VARCHAR},
</if>
<if test="locationMode != null">
#{locationMode,jdbcType=VARCHAR},
</if>
<if test="connectType != null">
#{connectType,jdbcType=VARCHAR},
</if>
<if test="phoneType != null">
#{phoneType,jdbcType=VARCHAR},
</if>
<if test="rfid != null">
#{rfid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig">
update dianxin_gz_device_config
<set>
<if test="deviceImei != null">
device_imei = #{deviceImei,jdbcType=VARCHAR},
</if>
<if test="httpIp != null">
http_ip = #{httpIp,jdbcType=VARCHAR},
</if>
<if test="httpUrl != null">
http_url = #{httpUrl,jdbcType=VARCHAR},
</if>
<if test="smsNumber != null">
sms_number = #{smsNumber,jdbcType=VARCHAR},
</if>
<if test="locationInterval != null">
location_interval = #{locationInterval,jdbcType=VARCHAR},
</if>
<if test="sleepTime != null">
sleep_time = #{sleepTime,jdbcType=VARCHAR},
</if>
<if test="affectionPhone != null">
affection_phone = #{affectionPhone,jdbcType=VARCHAR},
</if>
<if test="sosPhone != null">
sos_phone = #{sosPhone,jdbcType=VARCHAR},
</if>
<if test="whitePhone != null">
white_phone = #{whitePhone,jdbcType=VARCHAR},
</if>
<if test="smsWhitePhone != null">
sms_white_phone = #{smsWhitePhone,jdbcType=VARCHAR},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="clockTime != null">
clock_time = #{clockTime,jdbcType=VARCHAR},
</if>
<if test="smsSet != null">
sms_set = #{smsSet,jdbcType=VARCHAR},
</if>
<if test="addressBook != null">
address_book = #{addressBook,jdbcType=VARCHAR},
</if>
<if test="syncTime != null">
sync_time = #{syncTime,jdbcType=VARCHAR},
</if>
<if test="tcpAddress != null">
tcp_address = #{tcpAddress,jdbcType=VARCHAR},
</if>
<if test="autoShutdown != null">
auto_shutdown = #{autoShutdown,jdbcType=VARCHAR},
</if>
<if test="callTime != null">
call_time = #{callTime,jdbcType=VARCHAR},
</if>
<if test="locationMode != null">
location_mode = #{locationMode,jdbcType=VARCHAR},
</if>
<if test="connectType != null">
connect_type = #{connectType,jdbcType=VARCHAR},
</if>
<if test="phoneType != null">
phone_type = #{phoneType,jdbcType=VARCHAR},
</if>
<if test="rfid != null">
rfid = #{rfid,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ssjl.zhaobiao.guizhou.entity.DianxinGzDeviceConfig">
update dianxin_gz_device_config
set device_imei = #{deviceImei,jdbcType=VARCHAR},
http_ip = #{httpIp,jdbcType=VARCHAR},
http_url = #{httpUrl,jdbcType=VARCHAR},
sms_number = #{smsNumber,jdbcType=VARCHAR},
location_interval = #{locationInterval,jdbcType=VARCHAR},
sleep_time = #{sleepTime,jdbcType=VARCHAR},
affection_phone = #{affectionPhone,jdbcType=VARCHAR},
sos_phone = #{sosPhone,jdbcType=VARCHAR},
white_phone = #{whitePhone,jdbcType=VARCHAR},
sms_white_phone = #{smsWhitePhone,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
clock_time = #{clockTime,jdbcType=VARCHAR},
sms_set = #{smsSet,jdbcType=VARCHAR},
address_book = #{addressBook,jdbcType=VARCHAR},
sync_time = #{syncTime,jdbcType=VARCHAR},
tcp_address = #{tcpAddress,jdbcType=VARCHAR},
auto_shutdown = #{autoShutdown,jdbcType=VARCHAR},
call_time = #{callTime,jdbcType=VARCHAR},
location_mode = #{locationMode,jdbcType=VARCHAR},
connect_type = #{connectType,jdbcType=VARCHAR},
phone_type = #{phoneType,jdbcType=VARCHAR},
rfid = #{rfid,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByImei" resultMap="BaseResultMap">
SELECT * FROM dianxin_gz_device_config WHERE device_imei=#{imei};
</select>
<select id="selectByPhone" resultMap="BaseResultMap">
SELECT * FROM dianxin_gz_device_config WHERE phone = #{phone};
</select>

</mapper>

+ 107
- 0
src/main/resources/mapper/GpsDeviceCommandvalueMapper.xml Wyświetl plik

@@ -0,0 +1,107 @@
<?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.ssjl.zhaobiao.guizhou.repository.GpsDeviceCommandvalueMapper">
<resultMap id="BaseResultMap" type="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
<id column="value_id" jdbcType="VARCHAR" property="valueId" />
<result column="device_id" jdbcType="VARCHAR" property="deviceId" />
<result column="command_code" jdbcType="VARCHAR" property="commandCode" />
<result column="sent_time" jdbcType="TIMESTAMP" property="sentTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
<result column="command_value" jdbcType="LONGVARCHAR" property="commandValue" />
</resultMap>
<sql id="Base_Column_List">
value_id, device_id, command_code, sent_time
</sql>
<sql id="Blob_Column_List">
command_value
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from gps_device_commandvalue
where value_id = #{valueId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from gps_device_commandvalue
where value_id = #{valueId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
insert into gps_device_commandvalue (value_id, device_id, command_code,
sent_time, command_value)
values (#{valueId,jdbcType=VARCHAR}, #{deviceId,jdbcType=VARCHAR}, #{commandCode,jdbcType=VARCHAR},
#{sentTime,jdbcType=TIMESTAMP}, #{commandValue,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
insert into gps_device_commandvalue
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="valueId != null">
value_id,
</if>
<if test="deviceId != null">
device_id,
</if>
<if test="commandCode != null">
command_code,
</if>
<if test="sentTime != null">
sent_time,
</if>
<if test="commandValue != null">
command_value,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="valueId != null">
#{valueId,jdbcType=VARCHAR},
</if>
<if test="deviceId != null">
#{deviceId,jdbcType=VARCHAR},
</if>
<if test="commandCode != null">
#{commandCode,jdbcType=VARCHAR},
</if>
<if test="sentTime != null">
#{sentTime,jdbcType=TIMESTAMP},
</if>
<if test="commandValue != null">
#{commandValue,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
update gps_device_commandvalue
<set>
<if test="deviceId != null">
device_id = #{deviceId,jdbcType=VARCHAR},
</if>
<if test="commandCode != null">
command_code = #{commandCode,jdbcType=VARCHAR},
</if>
<if test="sentTime != null">
sent_time = #{sentTime,jdbcType=TIMESTAMP},
</if>
<if test="commandValue != null">
command_value = #{commandValue,jdbcType=LONGVARCHAR},
</if>
</set>
where value_id = #{valueId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
update gps_device_commandvalue
set device_id = #{deviceId,jdbcType=VARCHAR},
command_code = #{commandCode,jdbcType=VARCHAR},
sent_time = #{sentTime,jdbcType=TIMESTAMP},
command_value = #{commandValue,jdbcType=LONGVARCHAR}
where value_id = #{valueId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceCommandvalue">
update gps_device_commandvalue
set device_id = #{deviceId,jdbcType=VARCHAR},
command_code = #{commandCode,jdbcType=VARCHAR},
sent_time = #{sentTime,jdbcType=TIMESTAMP}
where value_id = #{valueId,jdbcType=VARCHAR}
</update>
</mapper>

+ 178
- 0
src/main/resources/mapper/GpsDeviceConfigMapper.xml Wyświetl plik

@@ -0,0 +1,178 @@
<?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.ssjl.zhaobiao.guizhou.repository.GpsDeviceConfigMapper">
<resultMap id="BaseResultMap" type="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig">
<id column="serialno" jdbcType="VARCHAR" property="serialno" />
<result column="id_number" jdbcType="VARCHAR" property="idNumber" />
<result column="press_keys" jdbcType="INTEGER" property="pressKeys" />
<result column="last_update" jdbcType="TIMESTAMP" property="lastUpdate" />
<result column="fence_flag" jdbcType="BIT" property="fenceFlag" />
<result column="device_function" jdbcType="VARCHAR" property="deviceFunction" />
<result column="product_mode" jdbcType="VARCHAR" property="productMode" />
<result column="imei" jdbcType="VARCHAR" property="imei" />
<result column="network_mode" jdbcType="VARCHAR" property="networkMode" />
<result column="position_mode" jdbcType="VARCHAR" property="positionMode" />
<result column="coding" jdbcType="VARCHAR" property="coding" />
<result column="iccid" jdbcType="VARCHAR" property="iccid" />
</resultMap>
<sql id="Base_Column_List">
serialno, id_number, press_keys, last_update, fence_flag, device_function, product_mode,
imei, network_mode, position_mode, coding, iccid
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from gps_device_config
where serialno = #{serialno,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from gps_device_config
where serialno = #{serialno,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig">
insert into gps_device_config (serialno, id_number, press_keys,
last_update, fence_flag, device_function,
product_mode, imei, network_mode,
position_mode, coding, iccid
)
values (#{serialno,jdbcType=VARCHAR}, #{idNumber,jdbcType=VARCHAR}, #{pressKeys,jdbcType=INTEGER},
#{lastUpdate,jdbcType=TIMESTAMP}, #{fenceFlag,jdbcType=BIT}, #{deviceFunction,jdbcType=VARCHAR},
#{productMode,jdbcType=VARCHAR}, #{imei,jdbcType=VARCHAR}, #{networkMode,jdbcType=VARCHAR},
#{positionMode,jdbcType=VARCHAR}, #{coding,jdbcType=VARCHAR}, #{iccid,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig">
insert into gps_device_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="serialno != null">
serialno,
</if>
<if test="idNumber != null">
id_number,
</if>
<if test="pressKeys != null">
press_keys,
</if>
<if test="lastUpdate != null">
last_update,
</if>
<if test="fenceFlag != null">
fence_flag,
</if>
<if test="deviceFunction != null">
device_function,
</if>
<if test="productMode != null">
product_mode,
</if>
<if test="imei != null">
imei,
</if>
<if test="networkMode != null">
network_mode,
</if>
<if test="positionMode != null">
position_mode,
</if>
<if test="coding != null">
coding,
</if>
<if test="iccid != null">
iccid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="serialno != null">
#{serialno,jdbcType=VARCHAR},
</if>
<if test="idNumber != null">
#{idNumber,jdbcType=VARCHAR},
</if>
<if test="pressKeys != null">
#{pressKeys,jdbcType=INTEGER},
</if>
<if test="lastUpdate != null">
#{lastUpdate,jdbcType=TIMESTAMP},
</if>
<if test="fenceFlag != null">
#{fenceFlag,jdbcType=BIT},
</if>
<if test="deviceFunction != null">
#{deviceFunction,jdbcType=VARCHAR},
</if>
<if test="productMode != null">
#{productMode,jdbcType=VARCHAR},
</if>
<if test="imei != null">
#{imei,jdbcType=VARCHAR},
</if>
<if test="networkMode != null">
#{networkMode,jdbcType=VARCHAR},
</if>
<if test="positionMode != null">
#{positionMode,jdbcType=VARCHAR},
</if>
<if test="coding != null">
#{coding,jdbcType=VARCHAR},
</if>
<if test="iccid != null">
#{iccid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig">
update gps_device_config
<set>
<if test="idNumber != null">
id_number = #{idNumber,jdbcType=VARCHAR},
</if>
<if test="pressKeys != null">
press_keys = #{pressKeys,jdbcType=INTEGER},
</if>
<if test="lastUpdate != null">
last_update = #{lastUpdate,jdbcType=TIMESTAMP},
</if>
<if test="fenceFlag != null">
fence_flag = #{fenceFlag,jdbcType=BIT},
</if>
<if test="deviceFunction != null">
device_function = #{deviceFunction,jdbcType=VARCHAR},
</if>
<if test="productMode != null">
product_mode = #{productMode,jdbcType=VARCHAR},
</if>
<if test="imei != null">
imei = #{imei,jdbcType=VARCHAR},
</if>
<if test="networkMode != null">
network_mode = #{networkMode,jdbcType=VARCHAR},
</if>
<if test="positionMode != null">
position_mode = #{positionMode,jdbcType=VARCHAR},
</if>
<if test="coding != null">
coding = #{coding,jdbcType=VARCHAR},
</if>
<if test="iccid != null">
iccid = #{iccid,jdbcType=VARCHAR},
</if>
</set>
where serialno = #{serialno,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceConfig">
update gps_device_config
set id_number = #{idNumber,jdbcType=VARCHAR},
press_keys = #{pressKeys,jdbcType=INTEGER},
last_update = #{lastUpdate,jdbcType=TIMESTAMP},
fence_flag = #{fenceFlag,jdbcType=BIT},
device_function = #{deviceFunction,jdbcType=VARCHAR},
product_mode = #{productMode,jdbcType=VARCHAR},
imei = #{imei,jdbcType=VARCHAR},
network_mode = #{networkMode,jdbcType=VARCHAR},
position_mode = #{positionMode,jdbcType=VARCHAR},
coding = #{coding,jdbcType=VARCHAR},
iccid = #{iccid,jdbcType=VARCHAR}
where serialno = #{serialno,jdbcType=VARCHAR}
</update>

</mapper>

+ 259
- 0
src/main/resources/mapper/GpsDeviceMapper.xml Wyświetl plik

@@ -0,0 +1,259 @@
<?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.ssjl.zhaobiao.guizhou.repository.GpsDeviceMapper">
<resultMap id="BaseResultMap" type="com.ssjl.zhaobiao.guizhou.entity.GpsDevice">
<id column="device_id" jdbcType="VARCHAR" property="deviceId" />
<result column="device_name" jdbcType="VARCHAR" property="deviceName" />
<result column="serialno" jdbcType="VARCHAR" property="serialno" />
<result column="org_uid" jdbcType="VARCHAR" property="orgUid" />
<result column="user_uid" jdbcType="VARCHAR" property="userUid" />
<result column="is_register" jdbcType="BIT" property="isRegister" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="active_time" jdbcType="TIMESTAMP" property="activeTime" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="model" jdbcType="VARCHAR" property="model" />
<result column="is_offset" jdbcType="BIT" property="isOffset" />
<result column="is_deleted" jdbcType="BIT" property="isDeleted" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
<result column="active_status" jdbcType="INTEGER" property="activeStatus" />
<result column="lock_status" jdbcType="BIT" property="lockStatus" />
<result column="original_active_status" jdbcType="INTEGER" property="originalActiveStatus" />
<result column="last_active_time" jdbcType="TIMESTAMP" property="lastActiveTime" />
</resultMap>
<sql id="Base_Column_List">
device_id, device_name, serialno, org_uid, user_uid, is_register, create_time, active_time,
expire_time, model, is_offset, is_deleted, modify_time, phone_number, remarks, active_status,
lock_status, original_active_status, last_active_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from gps_device
where device_id = #{deviceId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from gps_device
where device_id = #{deviceId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDevice">
insert into gps_device (device_id, device_name, serialno,
org_uid, user_uid, is_register,
create_time, active_time, expire_time,
model, is_offset, is_deleted,
modify_time, phone_number, remarks,
active_status, lock_status, original_active_status,
last_active_time)
values (#{deviceId,jdbcType=VARCHAR}, #{deviceName,jdbcType=VARCHAR}, #{serialno,jdbcType=VARCHAR},
#{orgUid,jdbcType=VARCHAR}, #{userUid,jdbcType=VARCHAR}, #{isRegister,jdbcType=BIT},
#{createTime,jdbcType=TIMESTAMP}, #{activeTime,jdbcType=TIMESTAMP}, #{expireTime,jdbcType=TIMESTAMP},
#{model,jdbcType=VARCHAR}, #{isOffset,jdbcType=BIT}, #{isDeleted,jdbcType=BIT},
#{modifyTime,jdbcType=TIMESTAMP}, #{phoneNumber,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR},
#{activeStatus,jdbcType=INTEGER}, #{lockStatus,jdbcType=BIT}, #{originalActiveStatus,jdbcType=INTEGER},
#{lastActiveTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDevice">
insert into gps_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
device_id,
</if>
<if test="deviceName != null">
device_name,
</if>
<if test="serialno != null">
serialno,
</if>
<if test="orgUid != null">
org_uid,
</if>
<if test="userUid != null">
user_uid,
</if>
<if test="isRegister != null">
is_register,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="activeTime != null">
active_time,
</if>
<if test="expireTime != null">
expire_time,
</if>
<if test="model != null">
model,
</if>
<if test="isOffset != null">
is_offset,
</if>
<if test="isDeleted != null">
is_deleted,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="phoneNumber != null">
phone_number,
</if>
<if test="remarks != null">
remarks,
</if>
<if test="activeStatus != null">
active_status,
</if>
<if test="lockStatus != null">
lock_status,
</if>
<if test="originalActiveStatus != null">
original_active_status,
</if>
<if test="lastActiveTime != null">
last_active_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
#{deviceId,jdbcType=VARCHAR},
</if>
<if test="deviceName != null">
#{deviceName,jdbcType=VARCHAR},
</if>
<if test="serialno != null">
#{serialno,jdbcType=VARCHAR},
</if>
<if test="orgUid != null">
#{orgUid,jdbcType=VARCHAR},
</if>
<if test="userUid != null">
#{userUid,jdbcType=VARCHAR},
</if>
<if test="isRegister != null">
#{isRegister,jdbcType=BIT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="activeTime != null">
#{activeTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
#{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="model != null">
#{model,jdbcType=VARCHAR},
</if>
<if test="isOffset != null">
#{isOffset,jdbcType=BIT},
</if>
<if test="isDeleted != null">
#{isDeleted,jdbcType=BIT},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="phoneNumber != null">
#{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="activeStatus != null">
#{activeStatus,jdbcType=INTEGER},
</if>
<if test="lockStatus != null">
#{lockStatus,jdbcType=BIT},
</if>
<if test="originalActiveStatus != null">
#{originalActiveStatus,jdbcType=INTEGER},
</if>
<if test="lastActiveTime != null">
#{lastActiveTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDevice">
update gps_device
<set>
<if test="deviceName != null">
device_name = #{deviceName,jdbcType=VARCHAR},
</if>
<if test="serialno != null">
serialno = #{serialno,jdbcType=VARCHAR},
</if>
<if test="orgUid != null">
org_uid = #{orgUid,jdbcType=VARCHAR},
</if>
<if test="userUid != null">
user_uid = #{userUid,jdbcType=VARCHAR},
</if>
<if test="isRegister != null">
is_register = #{isRegister,jdbcType=BIT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="activeTime != null">
active_time = #{activeTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="model != null">
model = #{model,jdbcType=VARCHAR},
</if>
<if test="isOffset != null">
is_offset = #{isOffset,jdbcType=BIT},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted,jdbcType=BIT},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="phoneNumber != null">
phone_number = #{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="activeStatus != null">
active_status = #{activeStatus,jdbcType=INTEGER},
</if>
<if test="lockStatus != null">
lock_status = #{lockStatus,jdbcType=BIT},
</if>
<if test="originalActiveStatus != null">
original_active_status = #{originalActiveStatus,jdbcType=INTEGER},
</if>
<if test="lastActiveTime != null">
last_active_time = #{lastActiveTime,jdbcType=TIMESTAMP},
</if>
</set>
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDevice">
update gps_device
set device_name = #{deviceName,jdbcType=VARCHAR},
serialno = #{serialno,jdbcType=VARCHAR},
org_uid = #{orgUid,jdbcType=VARCHAR},
user_uid = #{userUid,jdbcType=VARCHAR},
is_register = #{isRegister,jdbcType=BIT},
create_time = #{createTime,jdbcType=TIMESTAMP},
active_time = #{activeTime,jdbcType=TIMESTAMP},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
model = #{model,jdbcType=VARCHAR},
is_offset = #{isOffset,jdbcType=BIT},
is_deleted = #{isDeleted,jdbcType=BIT},
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
remarks = #{remarks,jdbcType=VARCHAR},
active_status = #{activeStatus,jdbcType=INTEGER},
lock_status = #{lockStatus,jdbcType=BIT},
original_active_status = #{originalActiveStatus,jdbcType=INTEGER},
last_active_time = #{lastActiveTime,jdbcType=TIMESTAMP}
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
</mapper>

+ 237
- 0
src/main/resources/mapper/GpsDeviceStatusMapper.xml Wyświetl plik

@@ -0,0 +1,237 @@
<?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.ssjl.zhaobiao.guizhou.repository.GpsDeviceStatusMapper">
<resultMap id="BaseResultMap" type="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus">
<id column="device_id" jdbcType="VARCHAR" property="deviceId" />
<result column="serialno" jdbcType="VARCHAR" property="serialno" />
<result column="device_utc_time" jdbcType="TIMESTAMP" property="deviceUtcTime" />
<result column="last_update" jdbcType="TIMESTAMP" property="lastUpdate" />
<result column="is_stop" jdbcType="BIT" property="isStop" />
<result column="speed" jdbcType="INTEGER" property="speed" />
<result column="course" jdbcType="INTEGER" property="course" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="location_type" jdbcType="INTEGER" property="locationType" />
<result column="olat" jdbcType="DECIMAL" property="olat" />
<result column="olng" jdbcType="DECIMAL" property="olng" />
<result column="glat" jdbcType="DECIMAL" property="glat" />
<result column="glng" jdbcType="DECIMAL" property="glng" />
<result column="baidu_lat" jdbcType="DECIMAL" property="baiduLat" />
<result column="baidu_lng" jdbcType="DECIMAL" property="baiduLng" />
<result column="device_status" jdbcType="VARCHAR" property="deviceStatus" />
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
</resultMap>
<sql id="Base_Column_List">
device_id, serialno, device_utc_time, last_update, is_stop, speed, course, address,
location_type, olat, olng, glat, glng, baidu_lat, baidu_lng, device_status, remarks
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from gps_device_status
where device_id = #{deviceId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from gps_device_status
where device_id = #{deviceId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus">
insert into gps_device_status (device_id, serialno, device_utc_time,
last_update, is_stop, speed,
course, address, location_type,
olat, olng, glat, glng,
baidu_lat, baidu_lng, device_status,
remarks)
values (#{deviceId,jdbcType=VARCHAR}, #{serialno,jdbcType=VARCHAR}, #{deviceUtcTime,jdbcType=TIMESTAMP},
#{lastUpdate,jdbcType=TIMESTAMP}, #{isStop,jdbcType=BIT}, #{speed,jdbcType=INTEGER},
#{course,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{locationType,jdbcType=INTEGER},
#{olat,jdbcType=DECIMAL}, #{olng,jdbcType=DECIMAL}, #{glat,jdbcType=DECIMAL}, #{glng,jdbcType=DECIMAL},
#{baiduLat,jdbcType=DECIMAL}, #{baiduLng,jdbcType=DECIMAL}, #{deviceStatus,jdbcType=VARCHAR},
#{remarks,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus">
insert into gps_device_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
device_id,
</if>
<if test="serialno != null">
serialno,
</if>
<if test="deviceUtcTime != null">
device_utc_time,
</if>
<if test="lastUpdate != null">
last_update,
</if>
<if test="isStop != null">
is_stop,
</if>
<if test="speed != null">
speed,
</if>
<if test="course != null">
course,
</if>
<if test="address != null">
address,
</if>
<if test="locationType != null">
location_type,
</if>
<if test="olat != null">
olat,
</if>
<if test="olng != null">
olng,
</if>
<if test="glat != null">
glat,
</if>
<if test="glng != null">
glng,
</if>
<if test="baiduLat != null">
baidu_lat,
</if>
<if test="baiduLng != null">
baidu_lng,
</if>
<if test="deviceStatus != null">
device_status,
</if>
<if test="remarks != null">
remarks,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
#{deviceId,jdbcType=VARCHAR},
</if>
<if test="serialno != null">
#{serialno,jdbcType=VARCHAR},
</if>
<if test="deviceUtcTime != null">
#{deviceUtcTime,jdbcType=TIMESTAMP},
</if>
<if test="lastUpdate != null">
#{lastUpdate,jdbcType=TIMESTAMP},
</if>
<if test="isStop != null">
#{isStop,jdbcType=BIT},
</if>
<if test="speed != null">
#{speed,jdbcType=INTEGER},
</if>
<if test="course != null">
#{course,jdbcType=INTEGER},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="locationType != null">
#{locationType,jdbcType=INTEGER},
</if>
<if test="olat != null">
#{olat,jdbcType=DECIMAL},
</if>
<if test="olng != null">
#{olng,jdbcType=DECIMAL},
</if>
<if test="glat != null">
#{glat,jdbcType=DECIMAL},
</if>
<if test="glng != null">
#{glng,jdbcType=DECIMAL},
</if>
<if test="baiduLat != null">
#{baiduLat,jdbcType=DECIMAL},
</if>
<if test="baiduLng != null">
#{baiduLng,jdbcType=DECIMAL},
</if>
<if test="deviceStatus != null">
#{deviceStatus,jdbcType=VARCHAR},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus">
update gps_device_status
<set>
<if test="serialno != null">
serialno = #{serialno,jdbcType=VARCHAR},
</if>
<if test="deviceUtcTime != null">
device_utc_time = #{deviceUtcTime,jdbcType=TIMESTAMP},
</if>
<if test="lastUpdate != null">
last_update = #{lastUpdate,jdbcType=TIMESTAMP},
</if>
<if test="isStop != null">
is_stop = #{isStop,jdbcType=BIT},
</if>
<if test="speed != null">
speed = #{speed,jdbcType=INTEGER},
</if>
<if test="course != null">
course = #{course,jdbcType=INTEGER},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="locationType != null">
location_type = #{locationType,jdbcType=INTEGER},
</if>
<if test="olat != null">
olat = #{olat,jdbcType=DECIMAL},
</if>
<if test="olng != null">
olng = #{olng,jdbcType=DECIMAL},
</if>
<if test="glat != null">
glat = #{glat,jdbcType=DECIMAL},
</if>
<if test="glng != null">
glng = #{glng,jdbcType=DECIMAL},
</if>
<if test="baiduLat != null">
baidu_lat = #{baiduLat,jdbcType=DECIMAL},
</if>
<if test="baiduLng != null">
baidu_lng = #{baiduLng,jdbcType=DECIMAL},
</if>
<if test="deviceStatus != null">
device_status = #{deviceStatus,jdbcType=VARCHAR},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
</set>
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.ssjl.zhaobiao.guizhou.entity.GpsDeviceStatus">
update gps_device_status
set serialno = #{serialno,jdbcType=VARCHAR},
device_utc_time = #{deviceUtcTime,jdbcType=TIMESTAMP},
last_update = #{lastUpdate,jdbcType=TIMESTAMP},
is_stop = #{isStop,jdbcType=BIT},
speed = #{speed,jdbcType=INTEGER},
course = #{course,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
location_type = #{locationType,jdbcType=INTEGER},
olat = #{olat,jdbcType=DECIMAL},
olng = #{olng,jdbcType=DECIMAL},
glat = #{glat,jdbcType=DECIMAL},
glng = #{glng,jdbcType=DECIMAL},
baidu_lat = #{baiduLat,jdbcType=DECIMAL},
baidu_lng = #{baiduLng,jdbcType=DECIMAL},
device_status = #{deviceStatus,jdbcType=VARCHAR},
remarks = #{remarks,jdbcType=VARCHAR}
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
<select id="selectByImei" resultMap="BaseResultMap">
select * from gps_device_status where serialno=#{imei};
</select>
</mapper>

+ 200
- 0
src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java Wyświetl plik

@@ -0,0 +1,200 @@
package com.ssjl.zhaobiao.guizhou;

import com.ssjl.zhaobiao.guizhou.entity.*;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocation;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationCDMA;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationExtend;
import com.ssjl.zhaobiao.guizhou.entity.GZMessage.GZLocationInterval;
import com.ssjl.zhaobiao.guizhou.utils.ByteUtil;
import com.ssjl.zhaobiao.guizhou.utils.GZUtil;
import com.ssjl.zhaobiao.guizhou.utils.OkHttpUtil;
import com.ssjl.zhaobiao.guizhou.utils.UnicodeUtil;
import okhttp3.Headers;
import okhttp3.internal.http2.Header;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;

@SpringBootTest
class CenterApplicationTests {

//
// @Test
// void contextLoads() {
// }
// private String QUEUE_NAME = "TuoYuMq";
// private static final String EXCHANGE_NAME = "TuoYu";
//
// @Autowired
// TyMqManager mqManager;
//
// @Test
// void TestMq() throws IOException {
// QzhTemperatureData data = new QzhTemperatureData();
// data.setClassId(1);
// data.setDeviceId(333333);
// data.setId(1234567890);
// data.setSchId(333);
// data.setStuId(111);
// data.setTemperature(388);
// data.setTime(new Date());
// mqManager.sendData(data);
//
// int i = System.in.read();
// }
//
// @Test
// void SendToMq() throws IOException, TimeoutException {
// // 创建连接工厂
// ConnectionFactory factory = new ConnectionFactory();
//// 设置RabbitMQ地址
// factory.setHost("localhost");
//// 创建一个新的连接
// Connection connection = factory.newConnection();
//// 创建一个频道
// Channel channel = connection.createChannel();
// channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
// // 声明队列需要持久化
// boolean durable = true;
//// 声明一个队列 -- 在RabbitMQ中,队列声明是幂等性的(一个幂等操作的特点是其任意多次执行所产生的影响均与一次执行的影响相同),也就是说,如果不存在,就创建,如果存在,不会对已经存在的队列产生任何影响。
// channel.queueDeclare(QUEUE_NAME, durable, false, false, null);
// // 绑定队列与交换器
// channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "");
// for (int i = 0; i < 50; i++) {
// String message = "Hello World!" + i;
// // 发送消息到队列中
//// channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8"));
//// channel.basicPublish("", QUEUE_NAME,
//// MessageProperties.PERSISTENT_TEXT_PLAIN,
//// message.getBytes());
// channel.basicPublish(EXCHANGE_NAME, "",
// MessageProperties.PERSISTENT_TEXT_PLAIN,
// message.getBytes());
// System.out.println("P [x] Sent '" + message + "'");
// }
// // 关闭频道和连接
// channel.close();
// connection.close();
// }
// @Test
// void receiveFromMq() throws IOException, TimeoutException {
// mqReceive(1);
// mqReceive(2);
// mqReceive(3);
// mqReceive(4);
// int i = System.in.read();
// System.out.println(i);
// }
//
// private void mqReceive(int i) throws IOException, TimeoutException {
// // 创建连接工厂
// ConnectionFactory factory = new ConnectionFactory();
//// 设置RabbitMQ地址
// factory.setHost("localhost");
//// 创建一个新的连接
// final Connection connection = factory.newConnection();
//// 创建一个频道
// final Channel channel = connection.createChannel();
//// 声明要关注的队列 -- 在RabbitMQ中,队列声明是幂等性的(一个幂等操作的特点是其任意多次执行所产生的影响均与一次执行的影响相同),也就是说,如果不存在,就创建,如果存在,不会对已经存在的队列产生任何影响。
// channel.queueDeclare(QUEUE_NAME, true, false, false, null);
// System.out.println("C [*] Waiting for messages. To exit press CTRL+C");
//
// // 每次从队列中获取数量
// channel.basicQos(1);
//
//// DefaultConsumer类实现了Consumer接口,通过传入一个频道,告诉服务器我们需要那个频道的消息,如果频道中有消息,就会执行回调函数handleDelivery
// final Consumer consumer = new DefaultConsumer(channel) {
// @SneakyThrows
// @Override
// public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// String message = new String(body, "UTF-8");
// System.out.println("C " + i + " [x] Received '" + message + "'");
// try {
// Thread.sleep(1000);
// }finally {
// // 消息处理完成确认
// channel.basicAck(envelope.getDeliveryTag(), false);
// }
// }
// };
//// 自动回复队列应答 -- RabbitMQ中的消息确认机制,后面章节会详细讲解
// channel.basicConsume(QUEUE_NAME, false, consumer);
// }

@Autowired
OkHttpUtil httpUtil;
@Test
void test(){
// String imei = "A12345678901234";
// byte[] b = byteUtil.imeiToByte(imei);
// System.out.println(byteUtil.bytesToHexString(b));
// imei = "1330571234567890";
// b = byteUtil.imeiToByte(imei);
// System.out.println(byteUtil.bytesToHexString(b));
// byte b = gzUtil.requestStatus(GZRequestStatus.RESPONSE_NO);
// System.out.println(b);
// b = gzUtil.requestStatus(GZRequestStatus.RESPONSE_ALL);
// System.out.println(b);
// b = gzUtil.requestStatus(GZRequestStatus.RESPONSE_ERROR);
// System.out.println(b);
// byte[] b = new byte[10];
// b[0] = (byte)128;
// b[1] = (byte)127;
// b[2] = (byte)1;
// b[3] = (byte)256;
// b[4] = (byte)255;
// System.out.println( gzUtil.check(b));
GZRequest req = new GZRequest();
req.setImei("862622050253671");
req.setIndex(GZUtil.getMessageIndex());
req.setStatus(GZRequestStatus.RESPONSE_NO);
GZLocationCDMA cdma = new GZLocationCDMA();
GZLocationExtend extend = new GZLocationExtend();
extend.setNetType(GZNetType.CDMA);
extend.setData1(cdma);
byte[] bid = { 0x00, 0x02 };
cdma.setBID(bid);
byte[] sid = {0x22, 0x41};
cdma.setSID(sid);
byte[] nid = { 0x36, 0x14};
cdma.setNID(nid);
GZDeviceStatus deviceStatus = new GZDeviceStatus();
// deviceStatus.setOpenFirst(true);
GZDevicePower power = new GZDevicePower();
power.setCharge(false);
power.setPower(80);
GZLocation location = new GZLocation(9, 11,11, 7,
13817426, 0, 67901974, 0, 5, 90,
deviceStatus, power, 70, 3, false, extend);
req.setContent(location);
byte[] b = req.toByte();
System.out.println(ByteUtil.bytesToHexString(b));
//
// Headers headers = new Headers.Builder().add("meid-id", "862622050253671").add("imsi-id", "18664272743").build();
// try {
// byte[] res = httpUtil.postBytes("http://202.105.147.30:24183", b, headers);
// System.out.println(ByteUtil.bytesToHexString(res));
// } catch (IOException e) {
// e.printStackTrace();
// }

}
@Test
public void test2(){
String str = "52303432363131353031313b543b555430312e343b565450453430313b5874656c706f3b5931383636343237323734333b5a5450453339302c50434241302e32412e4431302c41492e302e302e322e443130";
byte[] b = ByteUtil.hexToByteArray(str);
System.out.println(new String(b));
}

@Test
public void test3(){
List<GZLocationInterval> interval = GZLocationInterval.build("1/0600220003,234567/0700160005");
boolean in = GZLocationInterval.isIn(LocalDateTime.of(2021, 1 , 13, 23,22, 49), interval);
System.out.println(in);
}

}

Ładowanie…
Anuluj
Zapisz