commit
bc06e0e301
85 changed files with 8767 additions and 0 deletions
@ -0,0 +1,33 @@
|
||||
read.md |
||||
target/ |
||||
!.mvn/wrapper/maven-wrapper.jar |
||||
!**/src/main/**/target/ |
||||
!**/src/test/**/target/ |
||||
|
||||
### STS ### |
||||
.apt_generated |
||||
.classpath |
||||
.factorypath |
||||
.project |
||||
.settings |
||||
.springBeans |
||||
.sts4-cache |
||||
|
||||
### IntelliJ IDEA ### |
||||
.idea |
||||
*.iws |
||||
*.iml |
||||
*.ipr |
||||
|
||||
### NetBeans ### |
||||
/nbproject/private/ |
||||
/nbbuild/ |
||||
/dist/ |
||||
/nbdist/ |
||||
/.nb-gradle/ |
||||
build/ |
||||
!**/src/main/**/build/ |
||||
!**/src/test/**/build/ |
||||
|
||||
### VS Code ### |
||||
.vscode/ |
@ -0,0 +1,117 @@
|
||||
/* |
||||
* Copyright 2007-present 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.6"; |
||||
/** |
||||
* 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(); |
||||
} |
||||
|
||||
} |
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip |
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar |
@ -0,0 +1,2 @@
|
||||
alter table MeterInstall add PlateformType int default 0; |
||||
exec sp_addextendedproperty N'MS_Description', N'平台类型:0-OC平台,1:AEP平台', N'schema', N'dbo', N'table', N'MeterInstall', N'column', N'PlateformType'; |
@ -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. |
||||
# ---------------------------------------------------------------------------- |
||||
|
||||
# ---------------------------------------------------------------------------- |
||||
# Maven Start Up Batch script |
||||
# |
||||
# Required ENV vars: |
||||
# ------------------ |
||||
# JAVA_HOME - location of a JDK home dir |
||||
# |
||||
# Optional ENV vars |
||||
# ----------------- |
||||
# M2_HOME - location of maven2's installed home dir |
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven |
||||
# e.g. to debug Maven itself, use |
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files |
||||
# ---------------------------------------------------------------------------- |
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then |
||||
|
||||
if [ -f /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.6/maven-wrapper-0.5.6.jar" |
||||
else |
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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 "$@" |
@ -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 Maven Start Up Batch script |
||||
@REM |
||||
@REM Required ENV vars: |
||||
@REM JAVA_HOME - location of a JDK home dir |
||||
@REM |
||||
@REM Optional ENV vars |
||||
@REM M2_HOME - location of maven2's installed home dir |
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands |
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending |
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven |
||||
@REM e.g. to debug Maven itself, use |
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files |
||||
@REM ---------------------------------------------------------------------------- |
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' |
||||
@echo off |
||||
@REM set title of command window |
||||
title %0 |
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' |
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% |
||||
|
||||
@REM set %HOME% to equivalent of $HOME |
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") |
||||
|
||||
@REM Execute a user defined script before this one |
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre |
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending |
||||
if exist "%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.6/maven-wrapper-0.5.6.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.6/maven-wrapper-0.5.6.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% |
@ -0,0 +1,114 @@
|
||||
<?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.3.1.RELEASE</version> |
||||
<relativePath/> <!-- lookup parent from repository --> |
||||
</parent> |
||||
<groupId>com.mh</groupId> |
||||
<artifactId>garrison</artifactId> |
||||
<version>1.0.0</version> |
||||
<packaging>war</packaging> |
||||
<name>garrison</name> |
||||
<description>Demo project for Spring Boot</description> |
||||
|
||||
<properties> |
||||
<java.version>1.8</java.version> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.mybatis.spring.boot</groupId> |
||||
<artifactId>mybatis-spring-boot-starter</artifactId> |
||||
<version>2.1.3</version> |
||||
</dependency> |
||||
<!-- 定时执行包 --> |
||||
<!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz --> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>org.quartz-scheduler</groupId>--> |
||||
<!-- <artifactId>quartz</artifactId>--> |
||||
<!-- </dependency>--> |
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/druid --> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>druid</artifactId> |
||||
<version>1.1.22</version> |
||||
</dependency> |
||||
<!-- <!– https://mvnrepository.com/artifact/org.wso2.apache.httpcomponents/httpclient –>--> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>org.wso2.apache.httpcomponents</groupId>--> |
||||
<!-- <artifactId>httpclient</artifactId>--> |
||||
<!-- <version>4.3.1.wso2v1</version>--> |
||||
<!-- </dependency>--> |
||||
<!-- <!– https://mvnrepository.com/artifact/org.wso2.apache.httpcomponents/httpmime –>--> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>org.wso2.apache.httpcomponents</groupId>--> |
||||
<!-- <artifactId>httpmime</artifactId>--> |
||||
<!-- <version>4.3.1.wso2v1</version>--> |
||||
<!-- </dependency> --> |
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>fastjson</artifactId> |
||||
<version>1.2.72</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.microsoft.sqlserver</groupId> |
||||
<artifactId>mssql-jdbc</artifactId> |
||||
<scope>runtime</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-tomcat</artifactId> |
||||
<scope>provided</scope> |
||||
</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> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-configuration-processor</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<!-- 电信AEP平台SDK方式--> |
||||
<dependency> |
||||
<groupId>com.ctg.ag</groupId> |
||||
<artifactId>ag-sdk-biz-60039.tar.gz</artifactId> |
||||
<version>20210518.165353-SNAPSHOT</version> |
||||
</dependency> |
||||
<!-- 电信AEP平台SDK--> |
||||
<dependency> |
||||
<groupId>com.ctg.ag</groupId> |
||||
<artifactId>ctg-ag-sdk-core</artifactId> |
||||
<version>2.5.0-SNAPSHOT</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,15 @@
|
||||
package com.mh.garrison; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
||||
@SpringBootApplication |
||||
@EnableScheduling |
||||
public class GarrisonApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(GarrisonApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.mh.garrison; |
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer { |
||||
|
||||
@Override |
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
||||
return application.sources(GarrisonApplication.class); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.mh.garrison.config; |
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource; |
||||
import com.alibaba.druid.support.http.StatViewServlet; |
||||
import com.alibaba.druid.support.http.WebStatFilter; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.servlet.Filter; |
||||
import javax.servlet.Servlet; |
||||
import javax.sql.DataSource; |
||||
import java.sql.SQLException; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-03-13 |
||||
* @throws : |
||||
*/ |
||||
@Configuration |
||||
@EnableConfigurationProperties({DruidDataSourceProperties.class}) |
||||
public class DruidConfig { |
||||
|
||||
private final DruidDataSourceProperties properties; |
||||
@Autowired |
||||
public DruidConfig(DruidDataSourceProperties properties) { |
||||
this.properties = properties; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public DataSource druidDataSource() { |
||||
DruidDataSource druidDataSource = new DruidDataSource(); |
||||
druidDataSource.setDriverClassName(properties.getDriverClassName()); |
||||
druidDataSource.setUrl(properties.getUrl()); |
||||
druidDataSource.setUsername(properties.getUsername()); |
||||
druidDataSource.setPassword(properties.getPassword()); |
||||
druidDataSource.setInitialSize(properties.getInitialSize()); |
||||
druidDataSource.setMinIdle(properties.getMinIdle()); |
||||
druidDataSource.setMaxActive(properties.getMaxActive()); |
||||
druidDataSource.setMaxWait(properties.getMaxWait()); |
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); |
||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); |
||||
druidDataSource.setValidationQuery(properties.getValidationQuery()); |
||||
druidDataSource.setTestWhileIdle(properties.isTestWhileIdle()); |
||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow()); |
||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn()); |
||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements()); |
||||
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize()); |
||||
|
||||
try { |
||||
druidDataSource.setFilters(properties.getFilters()); |
||||
druidDataSource.init(); |
||||
} catch (SQLException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
return druidDataSource; |
||||
} |
||||
|
||||
/** |
||||
* 注册Servlet信息, 配置监控视图 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public ServletRegistrationBean<Servlet> druidServlet() { |
||||
ServletRegistrationBean<Servlet> servletRegistrationBean = new ServletRegistrationBean<Servlet>(new StatViewServlet(), "/druid/*"); |
||||
|
||||
//白名单:
|
||||
servletRegistrationBean.addInitParameter("allow","127.0.0.1,139.196.87.48,134.175.248.88"); |
||||
//IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
|
||||
servletRegistrationBean.addInitParameter("deny","192.168.1.223"); |
||||
//登录查看信息的账号密码, 用于登录Druid监控后台
|
||||
servletRegistrationBean.addInitParameter("loginUsername", "admin"); |
||||
servletRegistrationBean.addInitParameter("loginPassword", "admin"); |
||||
//是否能够重置数据.
|
||||
servletRegistrationBean.addInitParameter("resetEnable", "true"); |
||||
return servletRegistrationBean; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 注册Filter信息, 监控拦截器 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public FilterRegistrationBean<Filter> filterRegistrationBean() { |
||||
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>(); |
||||
filterRegistrationBean.setFilter(new WebStatFilter()); |
||||
filterRegistrationBean.addUrlPatterns("/*"); |
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); |
||||
return filterRegistrationBean; |
||||
} |
||||
} |
@ -0,0 +1,172 @@
|
||||
package com.mh.garrison.config; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-03-13 |
||||
* @throws : |
||||
*/ |
||||
@ConfigurationProperties(prefix = "spring.datasource.druid") |
||||
public class DruidDataSourceProperties { |
||||
|
||||
// jdbc
|
||||
private String driverClassName; |
||||
private String url; |
||||
private String username; |
||||
private String password; |
||||
// jdbc connection pool
|
||||
private int initialSize; |
||||
private int minIdle; |
||||
private int maxActive = 100; |
||||
private long maxWait; |
||||
private long timeBetweenEvictionRunsMillis; |
||||
private long minEvictableIdleTimeMillis; |
||||
private String validationQuery; |
||||
private boolean testWhileIdle; |
||||
private boolean testOnBorrow; |
||||
private boolean testOnReturn; |
||||
private boolean poolPreparedStatements; |
||||
private int maxPoolPreparedStatementPerConnectionSize; |
||||
// filter
|
||||
private String filters; |
||||
|
||||
public int getInitialSize() { |
||||
return initialSize; |
||||
} |
||||
|
||||
public void setInitialSize(int initialSize) { |
||||
this.initialSize = initialSize; |
||||
} |
||||
|
||||
public int getMinIdle() { |
||||
return minIdle; |
||||
} |
||||
|
||||
public void setMinIdle(int minIdle) { |
||||
this.minIdle = minIdle; |
||||
} |
||||
|
||||
public int getMaxActive() { |
||||
return maxActive; |
||||
} |
||||
|
||||
public void setMaxActive(int maxActive) { |
||||
this.maxActive = maxActive; |
||||
} |
||||
|
||||
public long getMaxWait() { |
||||
return maxWait; |
||||
} |
||||
|
||||
public void setMaxWait(long maxWait) { |
||||
this.maxWait = maxWait; |
||||
} |
||||
|
||||
public long getTimeBetweenEvictionRunsMillis() { |
||||
return timeBetweenEvictionRunsMillis; |
||||
} |
||||
|
||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { |
||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; |
||||
} |
||||
|
||||
public long getMinEvictableIdleTimeMillis() { |
||||
return minEvictableIdleTimeMillis; |
||||
} |
||||
|
||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { |
||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; |
||||
} |
||||
|
||||
public String getValidationQuery() { |
||||
return validationQuery; |
||||
} |
||||
|
||||
public void setValidationQuery(String validationQuery) { |
||||
this.validationQuery = validationQuery; |
||||
} |
||||
|
||||
public boolean isTestWhileIdle() { |
||||
return testWhileIdle; |
||||
} |
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) { |
||||
this.testWhileIdle = testWhileIdle; |
||||
} |
||||
|
||||
public boolean isTestOnBorrow() { |
||||
return testOnBorrow; |
||||
} |
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) { |
||||
this.testOnBorrow = testOnBorrow; |
||||
} |
||||
|
||||
public boolean isTestOnReturn() { |
||||
return testOnReturn; |
||||
} |
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) { |
||||
this.testOnReturn = testOnReturn; |
||||
} |
||||
|
||||
public boolean isPoolPreparedStatements() { |
||||
return poolPreparedStatements; |
||||
} |
||||
|
||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) { |
||||
this.poolPreparedStatements = poolPreparedStatements; |
||||
} |
||||
|
||||
public int getMaxPoolPreparedStatementPerConnectionSize() { |
||||
return maxPoolPreparedStatementPerConnectionSize; |
||||
} |
||||
|
||||
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) { |
||||
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; |
||||
} |
||||
|
||||
public String getFilters() { |
||||
return filters; |
||||
} |
||||
|
||||
public void setFilters(String filters) { |
||||
this.filters = filters; |
||||
} |
||||
|
||||
public String getDriverClassName() { |
||||
return driverClassName; |
||||
} |
||||
|
||||
public void setDriverClassName(String driverClassName) { |
||||
this.driverClassName = driverClassName; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
public void setUrl(String url) { |
||||
this.url = url; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.mh.garrison.constant; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project garrison |
||||
* @description 常量 |
||||
* @date 2024-12-05 15:00:08 |
||||
*/ |
||||
public class Constants { |
||||
|
||||
// 测试
|
||||
// public static final String NEW_NB_METER_FILE = "D:\\ljf\\项目文档以及资料\\物数和\\警备区\\MeterLogDatas\\";
|
||||
// 生产
|
||||
public static final String NEW_NB_METER_FILE = "E:\\MH_NB\\jingbeiqu\\AEP\\MeterLogDatas\\"; |
||||
|
||||
public static final String SUCCESS = "success"; |
||||
} |
@ -0,0 +1,246 @@
|
||||
package com.mh.garrison.controller; |
||||
|
||||
import java.io.BufferedWriter; |
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.OutputStreamWriter; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
|
||||
import com.mh.garrison.constant.Constants; |
||||
import com.mh.garrison.mhutils.UUid; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DeviceController |
||||
* @Description:TODO(设备服务调用接口) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午11:15:10 |
||||
* |
||||
*/ |
||||
@RestController |
||||
public class DeviceController { |
||||
|
||||
/** |
||||
* 单个设备数据变化:水表数据变化 |
||||
* @param jsonParam |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
@ResponseBody |
||||
@RequestMapping(value = "/na/iocm/devNotify/v1.1.0/updateDeviceData", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") |
||||
public String getByJSON1(@RequestBody JSONObject jsonParam) throws IOException { |
||||
|
||||
// 直接将json信息打印出来
|
||||
System.out.println("单个设备数据变化————" + jsonParam.toJSONString() + ",大小长度:" + jsonParam.toJSONString().length()); |
||||
|
||||
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss-SSS"); |
||||
String formatStr2 = formatter2.format(new Date()); |
||||
// System.out.println(formatStr2);// 2017-09-15
|
||||
UUid uid = new UUid(); // 生成全球唯一标识
|
||||
String uidStr = uid.uuid(); |
||||
|
||||
// FileOutputStream fileOutputStream = null;
|
||||
// 把报文保存在本地
|
||||
int length = jsonParam.toJSONString().length(); |
||||
File file; |
||||
if (length > 500) { |
||||
file = new File( Constants.NEW_NB_METER_FILE + formatStr2 + "_" + uidStr + ".txt"); |
||||
if (!file.exists()) { |
||||
try { |
||||
file.createNewFile(); |
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
BufferedWriter out = null; |
||||
try { |
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); |
||||
out.write(jsonParam.toJSONString() + "\r\n"); |
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} finally { |
||||
try { |
||||
out.close(); |
||||
} catch (IOException e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} |
||||
} |
||||
// else {
|
||||
// file = new File("E:\\MH_NB\\jingbeiqu\\MeterLogDatas\\" + formatStr2 + "_" + uidStr + ".txt");
|
||||
// }
|
||||
// File file = new File("E:\\EEMS_NB\\XT_DBC\\LogDatas\\" + formatStr2 + "_" + uidStr + ".txt");
|
||||
// File file = new File("E:\\GZ_WATER\\TEST\\LogDatas\\" + formatStr2 + "_" + uidStr + ".txt");
|
||||
|
||||
|
||||
|
||||
// 创建线程,读取本地报文文件
|
||||
// 创建线程
|
||||
// ThreadUtil threadUtil = new ThreadUtil();
|
||||
// Thread thread = new Thread(threadUtil);
|
||||
// if (thread.isAlive() == false) {
|
||||
// thread.start();
|
||||
// }else {
|
||||
// System.out.println("线程已启动");
|
||||
// }
|
||||
|
||||
// 将获取的json数据封装一层,然后在给返回
|
||||
JSONObject result = new JSONObject(); |
||||
result.put("msg", "ok"); |
||||
|
||||
return result.toJSONString(); |
||||
} |
||||
|
||||
/** |
||||
* 批量设备数据变化:主要是电表 |
||||
* |
||||
* @param jsonParam |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
@ResponseBody |
||||
@RequestMapping(value = "/na/iocm/devNotify/v1.1.0/updateDeviceDatas", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") |
||||
public String getByJSON(@RequestBody JSONObject jsonParam) throws IOException, InterruptedException { |
||||
|
||||
// 直接将json信息打印出来
|
||||
System.out.println("多个设备数据变化————" + jsonParam.toJSONString() + ",大小长度: " + jsonParam.toJSONString().length()); |
||||
|
||||
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss-SSS"); |
||||
String formatStr2 = formatter2.format(new Date()); |
||||
System.out.println(formatStr2);// 2017-09-15
|
||||
UUid uid = new UUid(); // 生成全球唯一标识
|
||||
String uidStr = uid.uuid(); |
||||
|
||||
// FileOutputStream fileOutputStream = null;
|
||||
// 把报文保存在本地
|
||||
// D:\MH_NB\test\SingleMeterLogDatas
|
||||
int length = jsonParam.toJSONString().length(); |
||||
File file = null; |
||||
if (length > 500) { |
||||
System.out.println("保存水表记录值"); |
||||
// file = new File("E:\\MH_NB\\jingbeiqu\\WaterLogDatas\\" + formatStr2 + "_" + uidStr + ".txt");
|
||||
} else { |
||||
file = new File("E:\\MH_NB\\jingbeiqu\\MeterLogDatas\\" + formatStr2 + "_" + uidStr + ".txt"); |
||||
} |
||||
// File file = new File("D:\\NB_Project\\xiamenshuangqiao\\MeterDataLogs\\" + formatStr2 + "_" + uidStr + ".txt");
|
||||
assert file != null; |
||||
if (!file.exists()) { |
||||
try { |
||||
file.createNewFile(); |
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} |
||||
BufferedWriter out = null; |
||||
try { |
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); |
||||
out.write(jsonParam.toJSONString() + "\r\n"); |
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} finally { |
||||
try { |
||||
out.close(); |
||||
} catch (IOException e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} |
||||
|
||||
// Thread.sleep(300);
|
||||
// 创建线程,读取本地报文文件
|
||||
// 创建线程
|
||||
// ThreadUtil threadUtil = new ThreadUtil();
|
||||
// Thread thread = new Thread(threadUtil);
|
||||
// if (thread.isAlive() == false) {
|
||||
// thread.start();
|
||||
// }else {
|
||||
// System.out.println("线程已启动");
|
||||
// }
|
||||
|
||||
|
||||
// // 文件
|
||||
// String fileStr = "D:\\MH_NB\\test\\SingleMeterLogDatas\\" + formatStr2 + "_" + uidStr + ".txt";
|
||||
// ThreadUtil.GetTxts(fileStr);
|
||||
|
||||
// 将获取的json数据封装一层,然后在给返回
|
||||
JSONObject result = new JSONObject(); |
||||
result.put("msg", "ok"); |
||||
|
||||
return result.toJSONString(); |
||||
} |
||||
|
||||
/** |
||||
* 发送指令回返接收指令 add by ljf on 2018-10-12 |
||||
* |
||||
* @param jsonParam |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
@ResponseBody |
||||
@RequestMapping(value = "/na/iocm/devNotify/v1.1.0/reportCmdExecResult", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") |
||||
public String getCMDResult(@RequestBody JSONObject jsonParam) throws IOException { |
||||
|
||||
// 创建线程
|
||||
// ThreadUtil threadUtil = new ThreadUtil();
|
||||
|
||||
// 直接将json信息打印出来
|
||||
System.out.println("发送命令返回" + jsonParam.toJSONString()); |
||||
|
||||
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss-SSS"); |
||||
String formatStr2 = formatter2.format(new Date()); |
||||
System.out.println(formatStr2);// 2017-09-15
|
||||
UUid uid = new UUid(); // 生成全球唯一标识
|
||||
String uidStr = uid.uuid(); |
||||
|
||||
// FileOutputStream fileOutputStream = null;
|
||||
// 把报文保存在本地
|
||||
File file = new File("E:\\MH_NB\\jingbeiqu\\MeterCMDDatas\\" + formatStr2 + "_" + uidStr + ".txt"); |
||||
if (!file.exists()) { |
||||
try { |
||||
file.createNewFile(); |
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
BufferedWriter out = null; |
||||
try { |
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); |
||||
out.write(jsonParam.toJSONString() + "\r\n"); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} finally { |
||||
try { |
||||
out.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
// // 创建线程,读取本地报文文件
|
||||
// Thread thread = new Thread(threadUtil);
|
||||
// thread.start();
|
||||
|
||||
// 将获取的json数据封装一层,然后在给返回
|
||||
JSONObject result = new JSONObject(); |
||||
result.put("msg", "ok"); |
||||
|
||||
return result.toJSONString(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.mh.garrison.controller; |
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
public class HelloController { |
||||
|
||||
@GetMapping |
||||
public String Hello() { |
||||
return "Hello World"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,82 @@
|
||||
package com.mh.garrison.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.mh.garrison.constant.Constants; |
||||
import com.mh.garrison.mhutils.UUid; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.io.*; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DeviceController |
||||
* @Description:TODO(设备服务调用接口) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2024年7月20日 上午11:15:10 |
||||
* |
||||
*/ |
||||
@RestController |
||||
public class NewDeviceController { |
||||
|
||||
/** |
||||
* 批量设备数据变化:主要是电表 |
||||
* |
||||
* @param jsonParam |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
@ResponseBody |
||||
@RequestMapping(value = "/na/iocm/devNotify/v1.1.1/updateDeviceDatas", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") |
||||
public String getByJSON(@RequestBody JSONObject jsonParam) throws IOException, InterruptedException { |
||||
|
||||
// 直接将json信息打印出来
|
||||
System.out.println("多个设备数据变化————" + jsonParam.toJSONString() + ",大小长度: " + jsonParam.toJSONString().length()); |
||||
|
||||
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss-SSS"); |
||||
String formatStr2 = formatter2.format(new Date()); |
||||
System.out.println(formatStr2);// 2017-09-15
|
||||
UUid uid = new UUid(); // 生成全球唯一标识
|
||||
String uidStr = uid.uuid(); |
||||
|
||||
// FileOutputStream fileOutputStream = null;
|
||||
// 把报文保存在本地
|
||||
// D:\MH_NB\test\SingleMeterLogDatas
|
||||
int length = jsonParam.toJSONString().length(); |
||||
File file = new File(Constants.NEW_NB_METER_FILE + formatStr2 + "_" + uidStr + ".txt"); |
||||
if (!file.exists()) { |
||||
try { |
||||
file.createNewFile(); |
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} |
||||
BufferedWriter out = null; |
||||
try { |
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); |
||||
out.write(jsonParam.toJSONString() + "\r\n"); |
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} finally { |
||||
try { |
||||
if (out != null) { |
||||
out.close(); |
||||
} |
||||
} catch (IOException e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} |
||||
|
||||
// 将获取的json数据封装一层,然后在给返回
|
||||
JSONObject result = new JSONObject(); |
||||
result.put("msg", "ok"); |
||||
|
||||
return result.toJSONString(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
/** |
||||
* @author 铭汉科技——LJL |
||||
* @date 2021-06-04 14:22 |
||||
* @Description AEP电信产品、设备组实体类 |
||||
*/ |
||||
public class AEPEntity { |
||||
private Integer productId; |
||||
private Integer deviceGroupId; |
||||
private String masterAPIKey; |
||||
|
||||
public AEPEntity() { |
||||
} |
||||
|
||||
public AEPEntity(Integer productId, Integer deviceGroupId, String masterAPIKey) { |
||||
this.productId = productId; |
||||
this.deviceGroupId = deviceGroupId; |
||||
this.masterAPIKey = masterAPIKey; |
||||
} |
||||
|
||||
public Integer getProductId() { |
||||
return productId; |
||||
} |
||||
|
||||
public void setProductId(Integer productId) { |
||||
this.productId = productId; |
||||
} |
||||
|
||||
public Integer getDeviceGroupId() { |
||||
return deviceGroupId; |
||||
} |
||||
|
||||
public void setDeviceGroupId(Integer deviceGroupId) { |
||||
this.deviceGroupId = deviceGroupId; |
||||
} |
||||
|
||||
public String getMasterAPIKey() { |
||||
return masterAPIKey; |
||||
} |
||||
|
||||
public void setMasterAPIKey(String masterAPIKey) { |
||||
this.masterAPIKey = masterAPIKey; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "AEPEntity{" + |
||||
"productId=" + productId + |
||||
", deviceGroupId=" + deviceGroupId + |
||||
", masterAPIKey='" + masterAPIKey + '\'' + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DataBean |
||||
* @Description:TODO 解析电信平台回来Json数据的第三层数据 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月1日 下午3:03:39 |
||||
* |
||||
*/ |
||||
public class DataBean { |
||||
|
||||
private String MeterId; |
||||
private String onlineType; |
||||
private String onlineCode; |
||||
private Map<Integer, Object> MHMeterData; |
||||
// private String MHMeterData;
|
||||
|
||||
public String getMeterId() { |
||||
return MeterId; |
||||
} |
||||
public void setMeterId(String meterId) { |
||||
MeterId = meterId; |
||||
} |
||||
public String getOnlineType() { |
||||
return onlineType; |
||||
} |
||||
public void setOnlineType(String onlineType) { |
||||
this.onlineType = onlineType; |
||||
} |
||||
public String getOnlineCode() { |
||||
return onlineCode; |
||||
} |
||||
public void setOnlineCode(String onlineCode) { |
||||
this.onlineCode = onlineCode; |
||||
} |
||||
public Map<Integer, Object> getMHMeterData() { |
||||
return MHMeterData; |
||||
} |
||||
public void setMHMeterData(Map<Integer, Object> mHMeterData) { |
||||
MHMeterData = mHMeterData; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "DataBean [MeterId=" + MeterId + ", onlineType=" + onlineType + ", onlineCode=" + onlineCode |
||||
+ ", MHMeterData=" + MHMeterData + "]"; |
||||
} |
||||
} |
@ -0,0 +1,201 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class DeviceInfo { |
||||
|
||||
// "nodeId":"865352032588559",
|
||||
// "name":"865352032588559",
|
||||
// "description":null,
|
||||
// "manufacturerId":"MH",
|
||||
// "manufacturerName":"MH",
|
||||
// "mac":null,
|
||||
// "location":"Shenzhen",
|
||||
// "deviceType":"MHMeter",
|
||||
// "model":"DDS3666",
|
||||
// "swVersion":null,
|
||||
// "fwVersion":null,
|
||||
// "hwVersion":null,
|
||||
// "protocolType":"CoAP",
|
||||
// "bridgeId":null,
|
||||
// "status":"OFFLINE",
|
||||
// "statusDetail":"NOT_ACTIVE",
|
||||
// "mute":"FALSE",
|
||||
// "supportedSecurity":null,
|
||||
// "isSecurity":null,
|
||||
// "signalStrength":null,
|
||||
// "sigVersion":null,
|
||||
// "serialNumber":null,
|
||||
// "batteryLevel":null
|
||||
private String nodeId; |
||||
private String name; |
||||
private String description; |
||||
private String manufactureId; |
||||
private String manufacturerName; |
||||
private String mac; |
||||
private String location; |
||||
private String deviceType; |
||||
private String model; |
||||
private String swVersion; |
||||
private String fwVersion; |
||||
private String hwVersion; |
||||
private String protocolType; |
||||
private String bridgeId; |
||||
private String status; |
||||
private String statusDetail; |
||||
private String mute; |
||||
private String supportedSecurity; |
||||
private String isSecurity; |
||||
private String signalStrength; |
||||
private String sigVersion; |
||||
private String serialNumber; |
||||
private String batteryLevel; |
||||
public String getNodeId() { |
||||
return nodeId; |
||||
} |
||||
public void setNodeId(String nodeId) { |
||||
this.nodeId = nodeId; |
||||
} |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
public void setDescription(String description) { |
||||
this.description = description; |
||||
} |
||||
public String getManufactureId() { |
||||
return manufactureId; |
||||
} |
||||
public void setManufactureId(String manufactureId) { |
||||
this.manufactureId = manufactureId; |
||||
} |
||||
public String getManufacturerName() { |
||||
return manufacturerName; |
||||
} |
||||
public void setManufacturerName(String manufacturerName) { |
||||
this.manufacturerName = manufacturerName; |
||||
} |
||||
public String getMac() { |
||||
return mac; |
||||
} |
||||
public void setMac(String mac) { |
||||
this.mac = mac; |
||||
} |
||||
public String getLocation() { |
||||
return location; |
||||
} |
||||
public void setLocation(String location) { |
||||
this.location = location; |
||||
} |
||||
public String getDeviceType() { |
||||
return deviceType; |
||||
} |
||||
public void setDeviceType(String deviceType) { |
||||
this.deviceType = deviceType; |
||||
} |
||||
public String getModel() { |
||||
return model; |
||||
} |
||||
public void setModel(String model) { |
||||
this.model = model; |
||||
} |
||||
public String getSwVersion() { |
||||
return swVersion; |
||||
} |
||||
public void setSwVersion(String swVersion) { |
||||
this.swVersion = swVersion; |
||||
} |
||||
public String getFwVersion() { |
||||
return fwVersion; |
||||
} |
||||
public void setFwVersion(String fwVersion) { |
||||
this.fwVersion = fwVersion; |
||||
} |
||||
public String getHwVersion() { |
||||
return hwVersion; |
||||
} |
||||
public void setHwVersion(String hwVersion) { |
||||
this.hwVersion = hwVersion; |
||||
} |
||||
public String getProtocolType() { |
||||
return protocolType; |
||||
} |
||||
public void setProtocolType(String protocolType) { |
||||
this.protocolType = protocolType; |
||||
} |
||||
public String getBridgeId() { |
||||
return bridgeId; |
||||
} |
||||
public void setBridgeId(String bridgeId) { |
||||
this.bridgeId = bridgeId; |
||||
} |
||||
public String getStatus() { |
||||
return status; |
||||
} |
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
public String getStatusDetail() { |
||||
return statusDetail; |
||||
} |
||||
public void setStatusDetail(String statusDetail) { |
||||
this.statusDetail = statusDetail; |
||||
} |
||||
public String getMute() { |
||||
return mute; |
||||
} |
||||
public void setMute(String mute) { |
||||
this.mute = mute; |
||||
} |
||||
public String getSupportedSecurity() { |
||||
return supportedSecurity; |
||||
} |
||||
public void setSupportedSecurity(String supportedSecurity) { |
||||
this.supportedSecurity = supportedSecurity; |
||||
} |
||||
public String getIsSecurity() { |
||||
return isSecurity; |
||||
} |
||||
public void setIsSecurity(String isSecurity) { |
||||
this.isSecurity = isSecurity; |
||||
} |
||||
public String getSignalStrength() { |
||||
return signalStrength; |
||||
} |
||||
public void setSignalStrength(String signalStrength) { |
||||
this.signalStrength = signalStrength; |
||||
} |
||||
public String getSigVersion() { |
||||
return sigVersion; |
||||
} |
||||
public void setSigVersion(String sigVersion) { |
||||
this.sigVersion = sigVersion; |
||||
} |
||||
public String getSerialNumber() { |
||||
return serialNumber; |
||||
} |
||||
public void setSerialNumber(String serialNumber) { |
||||
this.serialNumber = serialNumber; |
||||
} |
||||
public String getBatteryLevel() { |
||||
return batteryLevel; |
||||
} |
||||
public void setBatteryLevel(String batteryLevel) { |
||||
this.batteryLevel = batteryLevel; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "DeviceInfo [nodeId=" + nodeId + ", name=" + name + ", description=" + description + ", manufactureId=" |
||||
+ manufactureId + ", manufacturerName=" + manufacturerName + ", mac=" + mac + ", location=" + location |
||||
+ ", deviceType=" + deviceType + ", model=" + model + ", swVersion=" + swVersion + ", fwVersion=" |
||||
+ fwVersion + ", hwVersion=" + hwVersion + ", protocolType=" + protocolType + ", bridgeId=" + bridgeId |
||||
+ ", status=" + status + ", statusDetail=" + statusDetail + ", mute=" + mute + ", supportedSecurity=" |
||||
+ supportedSecurity + ", isSecurity=" + isSecurity + ", signalStrength=" + signalStrength |
||||
+ ", sigVersion=" + sigVersion + ", serialNumber=" + serialNumber + ", batteryLevel=" + batteryLevel |
||||
+ "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class DeviceMessage { |
||||
|
||||
private String deviceId; |
||||
private String gatewayId; |
||||
private String nodeType; |
||||
private String createTime; |
||||
private String lastModifiedTime; |
||||
private String deviceInfo; |
||||
private String services; |
||||
private String connectionInfo; |
||||
private String devGroupIds; |
||||
|
||||
public String getDeviceId() { |
||||
return deviceId; |
||||
} |
||||
public void setDeviceId(String deviceId) { |
||||
this.deviceId = deviceId; |
||||
} |
||||
public String getGatewayId() { |
||||
return gatewayId; |
||||
} |
||||
public void setGatewayId(String gatewayId) { |
||||
this.gatewayId = gatewayId; |
||||
} |
||||
public String getNodeType() { |
||||
return nodeType; |
||||
} |
||||
public void setNodeType(String nodeType) { |
||||
this.nodeType = nodeType; |
||||
} |
||||
public String getCreateTime() { |
||||
return createTime; |
||||
} |
||||
public void setCreateTime(String createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
public String getLastModifiedTime() { |
||||
return lastModifiedTime; |
||||
} |
||||
public void setLastModifiedTime(String lastModifiedTime) { |
||||
this.lastModifiedTime = lastModifiedTime; |
||||
} |
||||
public String getDeviceInfo() { |
||||
return deviceInfo; |
||||
} |
||||
public void setDeviceInfo(String deviceInfo) { |
||||
this.deviceInfo = deviceInfo; |
||||
} |
||||
|
||||
public String getServices() { |
||||
return services; |
||||
} |
||||
public void setServices(String services) { |
||||
this.services = services; |
||||
} |
||||
public String getConnectionInfo() { |
||||
return connectionInfo; |
||||
} |
||||
public void setConnectionInfo(String connectionInfo) { |
||||
this.connectionInfo = connectionInfo; |
||||
} |
||||
public String getDevGroupIds() { |
||||
return devGroupIds; |
||||
} |
||||
public void setDevGroupIds(String devGroupIds) { |
||||
this.devGroupIds = devGroupIds; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "DeviceMessage [deviceId=" + deviceId + ", gatewayId=" + gatewayId + ", nodeType=" + nodeType |
||||
+ ", createTime=" + createTime + ", lastModifiedTime=" + lastModifiedTime + ", deviceInfo=" + deviceInfo |
||||
+ ", services=" + services + ", connectionInfo=" + connectionInfo + ", devGroupIds=" + devGroupIds |
||||
+ "]"; |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DeviceMessage |
||||
* @Description:解析电信平台返回来的json第一层 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月1日 下午3:01:22 |
||||
* |
||||
*/ |
||||
public class DeviceMessageBean { |
||||
|
||||
private String notiFyType; |
||||
private String serviceBean; |
||||
private String deviceId; |
||||
private String gatewayId; |
||||
|
||||
public String getNotiFyType() { |
||||
return notiFyType; |
||||
} |
||||
public void setNotiFyType(String notiFyType) { |
||||
this.notiFyType = notiFyType; |
||||
} |
||||
public String getServiceBean() { |
||||
return serviceBean; |
||||
} |
||||
public void setServiceBean(String serviceBean) { |
||||
this.serviceBean = serviceBean; |
||||
} |
||||
public String getDeviceId() { |
||||
return deviceId; |
||||
} |
||||
public void setDeviceId(String deviceId) { |
||||
this.deviceId = deviceId; |
||||
} |
||||
public String getGatewayId() { |
||||
return gatewayId; |
||||
} |
||||
public void setGatewayId(String gatewayId) { |
||||
this.gatewayId = gatewayId; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DeviceMessage [notiFyType=" + notiFyType + ", serviceBean=" + serviceBean + ", deviceId=" + deviceId |
||||
+ ", gatewayId=" + gatewayId + "]"; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class DevicesBean { |
||||
|
||||
private long totalCount; |
||||
private long pageNo; |
||||
private long pageSize; |
||||
private String devices; |
||||
|
||||
public long getTotalCount() { |
||||
return totalCount; |
||||
} |
||||
public void setTotalCount(long totalCount) { |
||||
this.totalCount = totalCount; |
||||
} |
||||
public long getPageNo() { |
||||
return pageNo; |
||||
} |
||||
public void setPageNo(long pageNo) { |
||||
this.pageNo = pageNo; |
||||
} |
||||
public long getPageSize() { |
||||
return pageSize; |
||||
} |
||||
public void setPageSize(long pageSize) { |
||||
this.pageSize = pageSize; |
||||
} |
||||
public String getDevices() { |
||||
return devices; |
||||
} |
||||
public void setDevices(String devices) { |
||||
this.devices = devices; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "DevicesBean [totalCount=" + totalCount + ", pageNo=" + pageNo + ", pageSize=" + pageSize + ", devices=" |
||||
+ devices + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MSGEntity |
||||
* @Description:TODO(查询短信需要的信息实体类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:22:24 |
||||
* |
||||
*/ |
||||
public class MSGEntity { |
||||
|
||||
private String houseNum; // 房间号
|
||||
private String cellphoneNum; // 手机号码
|
||||
private String balanceMoney; // 余额
|
||||
private String remark; // 备注或者是短信信息内容
|
||||
private int sendTime; // 发送次数
|
||||
private String createDate; // 创建时间
|
||||
private String sendMsg; // 短信内容
|
||||
|
||||
public String getHouseNum() { |
||||
return houseNum; |
||||
} |
||||
public void setHouseNum(String houseNum) { |
||||
this.houseNum = houseNum; |
||||
} |
||||
public String getCellphoneNum() { |
||||
return cellphoneNum; |
||||
} |
||||
public void setCellphoneNum(String cellphoneNum) { |
||||
this.cellphoneNum = cellphoneNum; |
||||
} |
||||
public String getBalanceMoney() { |
||||
return balanceMoney; |
||||
} |
||||
public void setBalanceMoney(String balanceMoney) { |
||||
this.balanceMoney = balanceMoney; |
||||
} |
||||
public String getRemark() { |
||||
return remark; |
||||
} |
||||
public void setRemark(String remark) { |
||||
this.remark = remark; |
||||
} |
||||
public int getSendTime() { |
||||
return sendTime; |
||||
} |
||||
public void setSendTime(int sendTime) { |
||||
this.sendTime = sendTime; |
||||
} |
||||
|
||||
public String getCreateDate() { |
||||
return createDate; |
||||
} |
||||
|
||||
public void setCreateDate(String createDate) { |
||||
this.createDate = createDate; |
||||
} |
||||
|
||||
public String getSendMsg() { |
||||
return sendMsg; |
||||
} |
||||
|
||||
public void setSendMsg(String sendMsg) { |
||||
this.sendMsg = sendMsg; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "MSGEntity{" + |
||||
"houseNum='" + houseNum + '\'' + |
||||
", cellphoneNum='" + cellphoneNum + '\'' + |
||||
", balanceMoney='" + balanceMoney + '\'' + |
||||
", remark='" + remark + '\'' + |
||||
", sendTime=" + sendTime + |
||||
", createDate='" + createDate + '\'' + |
||||
", sendMsg='" + sendMsg + '\'' + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class MeterHistoryBean { |
||||
|
||||
private long id; // id
|
||||
private String mt_num; // 电表账号
|
||||
private String mt_electric; // 电表读数
|
||||
private String mt_state; // 电表状态
|
||||
private String mt_device_id; // 设备在电信平台上的ID号
|
||||
private String mt_time; // 电表上来时间
|
||||
private String house_num; // 房间号
|
||||
private String building_name; // 建筑名
|
||||
private int grade; // 标志位
|
||||
public long getId() { |
||||
return id; |
||||
} |
||||
public void setId(long id) { |
||||
this.id = id; |
||||
} |
||||
public String getMt_num() { |
||||
return mt_num; |
||||
} |
||||
public void setMt_num(String mt_num) { |
||||
this.mt_num = mt_num; |
||||
} |
||||
public String getMt_electric() { |
||||
return mt_electric; |
||||
} |
||||
public void setMt_electric(String mt_electric) { |
||||
this.mt_electric = mt_electric; |
||||
} |
||||
public String getMt_state() { |
||||
return mt_state; |
||||
} |
||||
public void setMt_state(String mt_state) { |
||||
this.mt_state = mt_state; |
||||
} |
||||
public String getMt_time() { |
||||
return mt_time; |
||||
} |
||||
public void setMt_time(String mt_time) { |
||||
this.mt_time = mt_time; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getBuilding_name() { |
||||
return building_name; |
||||
} |
||||
public void setBuilding_name(String building_name) { |
||||
this.building_name = building_name; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
public String getMt_device_id() { |
||||
return mt_device_id; |
||||
} |
||||
public void setMt_device_id(String mt_device_id) { |
||||
this.mt_device_id = mt_device_id; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "MeterHistoryBean [id=" + id + ", mt_num=" + mt_num + ", mt_electric=" + mt_electric + ", mt_state=" |
||||
+ mt_state + ", mt_device_id=" + mt_device_id + ", mt_time=" + mt_time + ", house_num=" + house_num |
||||
+ ", building_name=" + building_name + ", grade=" + grade + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class MeterNowBean { |
||||
|
||||
private long id; // id号
|
||||
private String mt_num; // 电表表号
|
||||
private String mt_electric; // 电表读数
|
||||
private String mt_state; // 电表状态
|
||||
private String mt_device_id; // 电表在电信平台上的ID号,发送指令需要
|
||||
private String mt_time; // 电表数据上来的时间
|
||||
private String limited_power; // 限容功率
|
||||
private String house_num; // 房间号
|
||||
private String building_name; // 所属楼层
|
||||
private int grade; // 标志位
|
||||
|
||||
public long getId() { |
||||
return id; |
||||
} |
||||
public void setId(long id) { |
||||
this.id = id; |
||||
} |
||||
public String getMt_num() { |
||||
return mt_num; |
||||
} |
||||
public void setMt_num(String mt_num) { |
||||
this.mt_num = mt_num; |
||||
} |
||||
public String getMt_electric() { |
||||
return mt_electric; |
||||
} |
||||
public void setMt_electric(String mt_electric) { |
||||
this.mt_electric = mt_electric; |
||||
} |
||||
public String getMt_state() { |
||||
return mt_state; |
||||
} |
||||
public void setMt_state(String mt_state) { |
||||
this.mt_state = mt_state; |
||||
} |
||||
public String getMt_time() { |
||||
return mt_time; |
||||
} |
||||
public void setMt_time(String mt_time) { |
||||
this.mt_time = mt_time; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getBuilding_name() { |
||||
return building_name; |
||||
} |
||||
public void setBuilding_name(String building_name) { |
||||
this.building_name = building_name; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
public String getLimited_power() { |
||||
return limited_power; |
||||
} |
||||
public void setLimited_power(String limited_power) { |
||||
this.limited_power = limited_power; |
||||
} |
||||
|
||||
public String getMt_device_id() { |
||||
return mt_device_id; |
||||
} |
||||
public void setMt_device_id(String mt_device_id) { |
||||
this.mt_device_id = mt_device_id; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "MeterNowBean [id=" + id + ", mt_num=" + mt_num + ", mt_electric=" + mt_electric + ", mt_state=" |
||||
+ mt_state + ", mt_device_id=" + mt_device_id + ", mt_time=" + mt_time + ", limited_power=" |
||||
+ limited_power + ", house_num=" + house_num + ", building_name=" + building_name + ", grade=" + grade |
||||
+ "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,64 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: OrderEntity |
||||
* @Description:TODO(指令实体类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午10:37:44 |
||||
* |
||||
*/ |
||||
public class OrderEntity { |
||||
|
||||
private String houseNum; |
||||
private String deviceNum; |
||||
private String imeiNum; |
||||
private String deviceId; |
||||
private String sendOrder; |
||||
private Date createDate; |
||||
|
||||
public String getHouseNum() { |
||||
return houseNum; |
||||
} |
||||
public void setHouseNum(String houseNum) { |
||||
this.houseNum = houseNum; |
||||
} |
||||
public String getDeviceNum() { |
||||
return deviceNum; |
||||
} |
||||
public void setDeviceNum(String deviceNum) { |
||||
this.deviceNum = deviceNum; |
||||
} |
||||
public String getImeiNum() { |
||||
return imeiNum; |
||||
} |
||||
public void setImeiNum(String imeiNum) { |
||||
this.imeiNum = imeiNum; |
||||
} |
||||
public String getDeviceId() { |
||||
return deviceId; |
||||
} |
||||
public void setDeviceId(String deviceId) { |
||||
this.deviceId = deviceId; |
||||
} |
||||
public String getSendOrder() { |
||||
return sendOrder; |
||||
} |
||||
public void setSendOrder(String sendOrder) { |
||||
this.sendOrder = sendOrder; |
||||
} |
||||
public Date getCreateDate() { |
||||
return createDate; |
||||
} |
||||
public void setCreateDate(Date createDate) { |
||||
this.createDate = createDate; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "OrderEntity [houseNum=" + houseNum + ", deviceNum=" + deviceNum + ", imeiNum=" + imeiNum + ", deviceId=" |
||||
+ deviceId + ", sendOrder=" + sendOrder + ", createDate=" + createDate + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: ServiceBean |
||||
* @Description:解析返回来Json数据第二层 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月1日 下午3:02:59 |
||||
* |
||||
*/ |
||||
public class ServiceBean { |
||||
|
||||
private String serviceId; |
||||
private String serviceType; |
||||
private String dataBean; |
||||
private String eventTime; |
||||
|
||||
public String getServiceId() { |
||||
return serviceId; |
||||
} |
||||
public void setServiceId(String serviceId) { |
||||
this.serviceId = serviceId; |
||||
} |
||||
public String getServiceType() { |
||||
return serviceType; |
||||
} |
||||
public void setServiceType(String serviceType) { |
||||
this.serviceType = serviceType; |
||||
} |
||||
public String getDataBean() { |
||||
return dataBean; |
||||
} |
||||
public void setDataBean(String dataBean) { |
||||
this.dataBean = dataBean; |
||||
} |
||||
|
||||
|
||||
public String getEventTime() { |
||||
return eventTime; |
||||
} |
||||
public void setEventTime(String eventTime) { |
||||
this.eventTime = eventTime; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "ServiceBean [serviceId=" + serviceId + ", serviceType=" + serviceType + ", dataBean=" + dataBean |
||||
+ ", eventTime=" + eventTime + "]"; |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class ThreeMeterBean { |
||||
|
||||
private long id; // id
|
||||
private String mt_num; // 电表账号
|
||||
private Double mt_electric; // 电表读数
|
||||
private String mt_state; // 电表状态
|
||||
private String mt_time; // 电表上来时间
|
||||
private String house_num; // 房间号
|
||||
private String building_name; // 建筑名
|
||||
private int grade; // 标志位
|
||||
|
||||
public long getId() { |
||||
return id; |
||||
} |
||||
public void setId(long id) { |
||||
this.id = id; |
||||
} |
||||
public String getMt_num() { |
||||
return mt_num; |
||||
} |
||||
public void setMt_num(String mt_num) { |
||||
this.mt_num = mt_num; |
||||
} |
||||
public Double getMt_electric() { |
||||
return mt_electric; |
||||
} |
||||
public void setMt_electric(Double mt_electric) { |
||||
this.mt_electric = mt_electric; |
||||
} |
||||
public String getMt_state() { |
||||
return mt_state; |
||||
} |
||||
public void setMt_state(String mt_state) { |
||||
this.mt_state = mt_state; |
||||
} |
||||
public String getMt_time() { |
||||
return mt_time; |
||||
} |
||||
public void setMt_time(String mt_time) { |
||||
this.mt_time = mt_time; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getBuilding_name() { |
||||
return building_name; |
||||
} |
||||
public void setBuilding_name(String building_name) { |
||||
this.building_name = building_name; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "ThreeMeterBean [id=" + id + ", mt_num=" + mt_num + ", mt_electric=" + mt_electric + ", mt_state=" |
||||
+ mt_state + ", mt_time=" + mt_time + ", house_num=" + house_num + ", building_name=" + building_name |
||||
+ ", grade=" + grade + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,84 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class ThreeMeterNowBean { |
||||
|
||||
private long id; // id号
|
||||
private String mt_num; // 电表表号
|
||||
private Double mt_electric; // 电表读数
|
||||
private String mt_state; // 电表状态
|
||||
private String mt_device_id; // 电表在电信平台的ID号
|
||||
private String mt_time; // 电表数据上来的时间
|
||||
private String limited_power; // 限容功率
|
||||
private String house_num; // 房间号
|
||||
private String building_name; // 所属楼层
|
||||
private int grade; // 标志位
|
||||
|
||||
public long getId() { |
||||
return id; |
||||
} |
||||
public void setId(long id) { |
||||
this.id = id; |
||||
} |
||||
public String getMt_num() { |
||||
return mt_num; |
||||
} |
||||
public void setMt_num(String mt_num) { |
||||
this.mt_num = mt_num; |
||||
} |
||||
public Double getMt_electric() { |
||||
return mt_electric; |
||||
} |
||||
public void setMt_electric(Double mt_electric) { |
||||
this.mt_electric = mt_electric; |
||||
} |
||||
public String getMt_state() { |
||||
return mt_state; |
||||
} |
||||
public void setMt_state(String mt_state) { |
||||
this.mt_state = mt_state; |
||||
} |
||||
public String getMt_device_id() { |
||||
return mt_device_id; |
||||
} |
||||
public void setMt_device_id(String mt_device_id) { |
||||
this.mt_device_id = mt_device_id; |
||||
} |
||||
public String getMt_time() { |
||||
return mt_time; |
||||
} |
||||
public void setMt_time(String mt_time) { |
||||
this.mt_time = mt_time; |
||||
} |
||||
public String getLimited_power() { |
||||
return limited_power; |
||||
} |
||||
public void setLimited_power(String limited_power) { |
||||
this.limited_power = limited_power; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getBuilding_name() { |
||||
return building_name; |
||||
} |
||||
public void setBuilding_name(String building_name) { |
||||
this.building_name = building_name; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "ThreeMeterNowBean [id=" + id + ", mt_num=" + mt_num + ", mt_electric=" + mt_electric + ", mt_state=" |
||||
+ mt_state + ", mt_device_id=" + mt_device_id + ", mt_time=" + mt_time + ", limited_power=" |
||||
+ limited_power + ", house_num=" + house_num + ", building_name=" + building_name + ", grade=" + grade |
||||
+ "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class WaterBean { |
||||
private String wt_num; |
||||
private String house_num; |
||||
private String IMEI; |
||||
private String IMSI; |
||||
private String cur_flow; |
||||
private String cur_date; |
||||
private String manufacture_id; |
||||
private int grade; |
||||
|
||||
// add new params update by ljf on 2019-12-12
|
||||
private Double voltage; // 电池电压
|
||||
private int contra_flow; // 逆流标志
|
||||
private int push_button; // 按键异常标志
|
||||
private int store; // 存储故障标志
|
||||
private int valve_status; // 阀门状态标志
|
||||
private int valve_unusual; // 阀门异常标志
|
||||
private int communication_status;// 通信标志
|
||||
private int sos_key; // 应急按键标志
|
||||
// 添加累计逆流量
|
||||
private Double reflux_flow; // 累计逆流量
|
||||
|
||||
public Double getVoltage() { |
||||
return voltage; |
||||
} |
||||
public void setVoltage(Double voltage) { |
||||
this.voltage = voltage; |
||||
} |
||||
public int getContra_flow() { |
||||
return contra_flow; |
||||
} |
||||
public void setContra_flow(int contra_flow) { |
||||
this.contra_flow = contra_flow; |
||||
} |
||||
public int getPush_button() { |
||||
return push_button; |
||||
} |
||||
public void setPush_button(int push_button) { |
||||
this.push_button = push_button; |
||||
} |
||||
public int getStore() { |
||||
return store; |
||||
} |
||||
public void setStore(int store) { |
||||
this.store = store; |
||||
} |
||||
public int getValve_status() { |
||||
return valve_status; |
||||
} |
||||
public void setValve_status(int valve_status) { |
||||
this.valve_status = valve_status; |
||||
} |
||||
public int getValve_unusual() { |
||||
return valve_unusual; |
||||
} |
||||
public void setValve_unusual(int valve_unusual) { |
||||
this.valve_unusual = valve_unusual; |
||||
} |
||||
public int getCommunication_status() { |
||||
return communication_status; |
||||
} |
||||
public void setCommunication_status(int communication_status) { |
||||
this.communication_status = communication_status; |
||||
} |
||||
public int getSos_key() { |
||||
return sos_key; |
||||
} |
||||
public void setSos_key(int sos_key) { |
||||
this.sos_key = sos_key; |
||||
} |
||||
public Double getReflux_flow() { |
||||
return reflux_flow; |
||||
} |
||||
public void setReflux_flow(Double reflux_flow) { |
||||
this.reflux_flow = reflux_flow; |
||||
} |
||||
public String getWt_num() { |
||||
return wt_num; |
||||
} |
||||
public void setWt_num(String wt_num) { |
||||
this.wt_num = wt_num; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getIMEI() { |
||||
return IMEI; |
||||
} |
||||
public void setIMEI(String iMEI) { |
||||
IMEI = iMEI; |
||||
} |
||||
public String getIMSI() { |
||||
return IMSI; |
||||
} |
||||
public void setIMSI(String iMSI) { |
||||
IMSI = iMSI; |
||||
} |
||||
public String getCur_flow() { |
||||
return cur_flow; |
||||
} |
||||
public void setCur_flow(String cur_flow) { |
||||
this.cur_flow = cur_flow; |
||||
} |
||||
public String getCur_date() { |
||||
return cur_date; |
||||
} |
||||
public void setCur_date(String cur_date) { |
||||
this.cur_date = cur_date; |
||||
} |
||||
public String getManufacture_id() { |
||||
return manufacture_id; |
||||
} |
||||
public void setManufacture_id(String manufacture_id) { |
||||
this.manufacture_id = manufacture_id; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "WaterBean [wt_num=" + wt_num + ", house_num=" + house_num + ", IMEI=" + IMEI + ", IMSI=" + IMSI |
||||
+ ", cur_flow=" + cur_flow + ", cur_date=" + cur_date + ", manufacture_id=" + manufacture_id |
||||
+ ", grade=" + grade + ", voltage=" + voltage + ", contra_flow=" + contra_flow + ", push_button=" |
||||
+ push_button + ", store=" + store + ", valve_status=" + valve_status + ", valve_unusual=" |
||||
+ valve_unusual + ", communication_status=" + communication_status + ", sos_key=" + sos_key |
||||
+ ", reflux_flow=" + reflux_flow + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : 水表返回报文 |
||||
* @description : |
||||
* @updateTime 2020-07-23 |
||||
* @throws : |
||||
*/ |
||||
public class WaterDataBean { |
||||
|
||||
private String MeterId; |
||||
private String onlineType; |
||||
private String onlineCode; |
||||
|
||||
public String getMeterId() { |
||||
return MeterId; |
||||
} |
||||
public void setMeterId(String meterId) { |
||||
MeterId = meterId; |
||||
} |
||||
public String getOnlineType() { |
||||
return onlineType; |
||||
} |
||||
public void setOnlineType(String onlineType) { |
||||
this.onlineType = onlineType; |
||||
} |
||||
public String getOnlineCode() { |
||||
return onlineCode; |
||||
} |
||||
public void setOnlineCode(String onlineCode) { |
||||
this.onlineCode = onlineCode; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "DataBean [MeterId=" + MeterId + ", onlineType=" + onlineType + ", onlineCode=" + onlineCode + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,105 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class WaterDayBean { |
||||
|
||||
private long id; |
||||
private String house_num; |
||||
private String wt_num; |
||||
private String last_flow; |
||||
private String cur_flow; |
||||
private String calc_flow; |
||||
private String true_flow; |
||||
private String wt_ratio; |
||||
private String used_money; |
||||
private String after_money; |
||||
private String cur_date; |
||||
private String building_name; |
||||
// private int grade;
|
||||
public long getId() { |
||||
return id; |
||||
} |
||||
public void setId(long id) { |
||||
this.id = id; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getWt_num() { |
||||
return wt_num; |
||||
} |
||||
public void setWt_num(String wt_num) { |
||||
this.wt_num = wt_num; |
||||
} |
||||
public String getLast_flow() { |
||||
return last_flow; |
||||
} |
||||
public void setLast_flow(String last_flow) { |
||||
this.last_flow = last_flow; |
||||
} |
||||
public String getCur_flow() { |
||||
return cur_flow; |
||||
} |
||||
public void setCur_flow(String cur_flow) { |
||||
this.cur_flow = cur_flow; |
||||
} |
||||
public String getCalc_flow() { |
||||
return calc_flow; |
||||
} |
||||
public void setCalc_flow(String calc_flow) { |
||||
this.calc_flow = calc_flow; |
||||
} |
||||
public String getTrue_flow() { |
||||
return true_flow; |
||||
} |
||||
public void setTrue_flow(String true_flow) { |
||||
this.true_flow = true_flow; |
||||
} |
||||
public String getWt_ratio() { |
||||
return wt_ratio; |
||||
} |
||||
public void setWt_ratio(String wt_ratio) { |
||||
this.wt_ratio = wt_ratio; |
||||
} |
||||
public String getUsed_money() { |
||||
return used_money; |
||||
} |
||||
public void setUsed_money(String used_money) { |
||||
this.used_money = used_money; |
||||
} |
||||
public String getAfter_money() { |
||||
return after_money; |
||||
} |
||||
public void setAfter_money(String after_money) { |
||||
this.after_money = after_money; |
||||
} |
||||
public String getCur_date() { |
||||
return cur_date; |
||||
} |
||||
public void setCur_date(String cur_date) { |
||||
this.cur_date = cur_date; |
||||
} |
||||
public String getBuilding_name() { |
||||
return building_name; |
||||
} |
||||
public void setBuilding_name(String building_name) { |
||||
this.building_name = building_name; |
||||
} |
||||
// public int getGrade() {
|
||||
// return grade;
|
||||
// }
|
||||
// public void setGrade(int grade) {
|
||||
// this.grade = grade;
|
||||
// }
|
||||
@Override |
||||
public String toString() { |
||||
return "WaterDayBean [id=" + id + ", house_num=" + house_num + ", wt_num=" + wt_num + ", last_flow=" + last_flow |
||||
+ ", cur_flow=" + cur_flow + ", calc_flow=" + calc_flow + ", true_flow=" + true_flow + ", wt_ratio=" |
||||
+ wt_ratio + ", used_money=" + used_money + ", after_money=" + after_money + ", cur_date=" + cur_date |
||||
+ ", building_name=" + building_name + "]"; |
||||
// + ", grade=" + grade + "]";
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
package com.mh.garrison.entity; |
||||
|
||||
public class WaterHistoryBean { |
||||
|
||||
private String wt_num; |
||||
private String house_num; |
||||
private String IMEI; |
||||
private String IMSI; |
||||
private String cur_flow; |
||||
private String cur_date; |
||||
private String manufacture_id; |
||||
private int grade; |
||||
|
||||
public String getWt_num() { |
||||
return wt_num; |
||||
} |
||||
public void setWt_num(String wt_num) { |
||||
this.wt_num = wt_num; |
||||
} |
||||
public String getHouse_num() { |
||||
return house_num; |
||||
} |
||||
public void setHouse_num(String house_num) { |
||||
this.house_num = house_num; |
||||
} |
||||
public String getIMEI() { |
||||
return IMEI; |
||||
} |
||||
public void setIMEI(String iMEI) { |
||||
IMEI = iMEI; |
||||
} |
||||
public String getIMSI() { |
||||
return IMSI; |
||||
} |
||||
public void setIMSI(String iMSI) { |
||||
IMSI = iMSI; |
||||
} |
||||
public String getCur_flow() { |
||||
return cur_flow; |
||||
} |
||||
public void setCur_flow(String cur_flow) { |
||||
this.cur_flow = cur_flow; |
||||
} |
||||
public String getCur_date() { |
||||
return cur_date; |
||||
} |
||||
public void setCur_date(String cur_date) { |
||||
this.cur_date = cur_date; |
||||
} |
||||
public String getManufacture_id() { |
||||
return manufacture_id; |
||||
} |
||||
public void setManufacture_id(String manufacture_id) { |
||||
this.manufacture_id = manufacture_id; |
||||
} |
||||
public int getGrade() { |
||||
return grade; |
||||
} |
||||
public void setGrade(int grade) { |
||||
this.grade = grade; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "WaterDayBean [wt_num=" + wt_num + ", house_num=" + house_num + ", IMEI=" + IMEI + ", IMSI=" + IMSI |
||||
+ ", cur_flow=" + cur_flow + ", cur_date=" + cur_date + ", manufacture_id=" + manufacture_id |
||||
+ ", grade=" + grade + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,121 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.InputStreamReader; |
||||
|
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import com.mh.garrison.mhutils.FastJson; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DealMeterLog |
||||
* @Description:TODO(定时处理电表数据) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 下午1:37:23 |
||||
* |
||||
*/ |
||||
@Component |
||||
public class DealMeterLogJob { |
||||
|
||||
// @Scheduled(cron = "0 0/30 * * * ? *")
|
||||
@Scheduled(cron = "0/30 * * * * ? ") |
||||
public void dealMeterLogJob() { |
||||
String filePath = "E:\\MH_NB\\jingbeiqu\\MeterLogDatas\\"; |
||||
GetTxts(filePath); |
||||
} |
||||
|
||||
public static void GetTxts(String filePath) { |
||||
FastJson fastJson = new FastJson(); |
||||
File rootFile = new File(filePath); |
||||
if (!rootFile.isDirectory()) { |
||||
// System.out.println("文件名----" + rootFile.getAbsolutePath());
|
||||
// 读取文件内容
|
||||
try { // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw
|
||||
/* 读入TXT文件 */ |
||||
String line; |
||||
String jsonStr = null; |
||||
|
||||
String pathname = rootFile.getAbsolutePath(); // 绝对路径或相对路径都可以,写入文件时演示相对路径
|
||||
File filename = new File(pathname); // 要读取以上路径的input.txt文件
|
||||
if (filename.length()>0) { |
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(filename)); // 建立一个输入流对象reader
|
||||
BufferedReader br = new BufferedReader(reader); // 建立一个对象,它把文件内容转成计算机能读懂的语言
|
||||
|
||||
// 网友推荐更加简洁的写法
|
||||
System.out.println("文件内容:" + br.lines()); |
||||
|
||||
while ((line = br.readLine()) != null) { |
||||
// 一次读入一行数据
|
||||
// System.out.println(line);
|
||||
// try {
|
||||
// DBIdentifier.setProjectCode("NB网络电表");
|
||||
//// DBIdentifier.setProjectCode("NB网络电表");
|
||||
// // DBIdentifier.setProjectCode("本地NB网络电表");
|
||||
// } catch (Exception e) {
|
||||
// // TODO: handle exception
|
||||
// String causeStr = e.getCause().getMessage();
|
||||
// System.out.println(">>>>>>>-------------" + causeStr);
|
||||
// }
|
||||
// 获取电表数据内容
|
||||
jsonStr = fastJson.analysisMeterFastJson(line); |
||||
if (jsonStr.equals("success")) { |
||||
System.out.println("解析成功"); |
||||
} else { |
||||
System.out.println("解析失败"); |
||||
} |
||||
// System.out.println(jsonStr);
|
||||
// for(int i = 1; i<=jsonStr.size();i++) {
|
||||
// System.out.println(jsonStr.get(i).toString());
|
||||
//
|
||||
// meterUtils.analysisMeter(jsonStr.get(i).toString(), line);
|
||||
// }
|
||||
} |
||||
reader.close(); |
||||
br.close(); |
||||
assert jsonStr != null; |
||||
if (jsonStr.equals("success")) { |
||||
// 删除filename
|
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println("删除成功"); |
||||
} |
||||
} |
||||
} else { |
||||
// 删除filename
|
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println("删除成功"); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} else { |
||||
// 递归查询文件内容
|
||||
String[] fileList = rootFile.list(); |
||||
assert fileList != null; |
||||
for (String s : fileList) { |
||||
filePath = rootFile.getAbsolutePath() + "\\" + s; |
||||
System.out.println("文件路径:" + filePath); |
||||
try { |
||||
GetTxts(filePath); |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
// 删除filename
|
||||
File rootFile1 = new File(filePath); |
||||
if (rootFile1.exists()) { |
||||
rootFile1.delete(); |
||||
System.out.println("出现异常,删除成功"); |
||||
} |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.InputStreamReader; |
||||
|
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import com.mh.garrison.mhutils.ByteUtilsWater; |
||||
import com.mh.garrison.mhutils.FastJson; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DealWaterLogJob |
||||
* @Description:TODO(定时处理接收到的水表报文记录) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 下午1:56:31 |
||||
* |
||||
*/ |
||||
@Component |
||||
public class DealWaterLogJob { |
||||
|
||||
@Scheduled(cron = "0 0/30 * * * ? ") |
||||
public void dealMeterLogJob() { |
||||
String filePath = "E:\\MH_NB\\jingbeiqu\\WaterLogDatas\\"; |
||||
GetTxts1(filePath); |
||||
} |
||||
|
||||
private static void GetTxts1(String filePath) { |
||||
// TODO Auto-generated method stub
|
||||
FastJson fastJson = new FastJson(); |
||||
File rootFile = new File(filePath); |
||||
String receive_result = null ; |
||||
if (! rootFile.isDirectory()) { |
||||
System.out.println("文件名----" + rootFile.getAbsolutePath()); |
||||
// 读取文件内容
|
||||
try { // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw
|
||||
/* 读入TXT文件 */ |
||||
String pathname = rootFile.getAbsolutePath(); // 绝对路径或相对路径都可以,写入文件时演示相对路径
|
||||
File filename = new File(pathname); // 要读取以上路径的input.txt文件
|
||||
if (filename.length() > 0){ |
||||
InputStreamReader reader = new InputStreamReader( |
||||
new FileInputStream(filename)); // 建立一个输入流对象reader
|
||||
BufferedReader br = new BufferedReader(reader); // 建立一个对象,它把文件内容转成计算机能读懂的语言
|
||||
String line; |
||||
//网友推荐更加简洁的写法
|
||||
while ((line = br.readLine()) != null) { |
||||
try { |
||||
|
||||
// 一次读入一行数据
|
||||
// System.out.println(line);
|
||||
String jsonStr = fastJson.analysisFastJson(line); |
||||
// System.out.println(jsonStr);
|
||||
|
||||
// 解析onlineCode
|
||||
ByteUtilsWater byteUtils = new ByteUtilsWater(); |
||||
receive_result = byteUtils.analysisFastJson1(jsonStr); |
||||
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
reader.close(); |
||||
br.close(); |
||||
|
||||
// 删除filename
|
||||
if (receive_result.equals("success")) { |
||||
System.out.println("------------------------解析成功------------------"); |
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println(filename + "删除成功"); |
||||
} |
||||
}else { |
||||
System.out.println("------------------------解析失败------------------"); |
||||
} |
||||
} else { |
||||
// 删除filename
|
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println("删除成功"); |
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
}else { |
||||
// 递归查询文件内容
|
||||
String[] fileList = rootFile.list(); |
||||
assert fileList != null; |
||||
for (String s : fileList) { |
||||
filePath = rootFile.getAbsolutePath() + "\\" + s; |
||||
try { |
||||
GetTxts1(filePath); |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
e.printStackTrace(); |
||||
// continue;
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import com.alibaba.druid.util.StringUtils; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.mh.garrison.constant.Constants; |
||||
import com.mh.garrison.mhutils.FastJson; |
||||
import com.mh.garrison.mhutils.StringUtil; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.InputStreamReader; |
||||
import java.nio.file.Files; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DealMeterLog |
||||
* @Description:TODO(定时处理电表数据) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 下午1:37:23 |
||||
* |
||||
*/ |
||||
@Component |
||||
public class NewDealMeterLogJob { |
||||
|
||||
// 5秒处理一次
|
||||
@Scheduled(cron = "0/5 * * * * ? ") |
||||
public void dealMeterLogJob() { |
||||
GetTxts(Constants.NEW_NB_METER_FILE); |
||||
} |
||||
|
||||
public static void GetTxts(String filePath) { |
||||
FastJson fastJson = new FastJson(); |
||||
File rootFile = new File(filePath); |
||||
if (!rootFile.isDirectory()) { |
||||
// System.out.println("文件名----" + rootFile.getAbsolutePath());
|
||||
// 读取文件内容
|
||||
try { // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw
|
||||
/* 读入TXT文件 */ |
||||
String line; |
||||
String jsonStr = null; |
||||
|
||||
String pathname = rootFile.getAbsolutePath(); // 绝对路径或相对路径都可以,写入文件时演示相对路径
|
||||
File filename = new File(pathname); // 要读取以上路径的input.txt文件
|
||||
if (filename.length()>0) { |
||||
InputStreamReader reader = new InputStreamReader(Files.newInputStream(filename.toPath())); // 建立一个输入流对象reader
|
||||
BufferedReader br = new BufferedReader(reader); // 建立一个对象,它把文件内容转成计算机能读懂的语言
|
||||
|
||||
// 网友推荐更加简洁的写法
|
||||
System.out.println("文件内容:" + br.lines()); |
||||
|
||||
while ((line = br.readLine()) != null) { |
||||
String payload = JSONObject.parseObject(line).getString("payload"); |
||||
if (!payload.isEmpty()){ |
||||
//走AEP平台解析
|
||||
jsonStr = fastJson.analysisEleFastJsonByAEPProfile(line); |
||||
} else { |
||||
//OC
|
||||
jsonStr = fastJson.analysisMeterFastJson(line); |
||||
} |
||||
} |
||||
reader.close(); |
||||
br.close(); |
||||
if (!StringUtils.isEmpty(jsonStr)){ |
||||
if (jsonStr.equals("success")) { |
||||
// 删除filename
|
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println("删除成功"); |
||||
} |
||||
} |
||||
} |
||||
} else { |
||||
// 删除filename
|
||||
if (filename.exists()) { |
||||
filename.delete(); |
||||
System.out.println("删除成功"); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
} |
||||
} else { |
||||
// 递归查询文件内容
|
||||
String[] fileList = rootFile.list(); |
||||
assert fileList != null; |
||||
for (String s : fileList) { |
||||
filePath = rootFile.getAbsolutePath() + "\\" + s; |
||||
System.out.println("文件路径:" + filePath); |
||||
try { |
||||
GetTxts(filePath); |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
// 删除filename
|
||||
File rootFile1 = new File(filePath); |
||||
if (rootFile1.exists()) { |
||||
rootFile1.delete(); |
||||
System.out.println("出现异常,删除成功"); |
||||
} |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,236 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import java.text.ParseException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import com.mh.garrison.mhutils.*; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: QueryDeviceJob |
||||
* @Description:TODO(定时查询状态设备信息) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:06:07 |
||||
* |
||||
*/ |
||||
@Component |
||||
public class QueryDeviceJob { |
||||
|
||||
@Scheduled(cron = "0 0 0-4 * * ? ") |
||||
public void queryDevice() { |
||||
System.out.println("每四个小时定时查询设备状态值"); |
||||
// TODO Auto-generated method stub
|
||||
// TODO Auto-generated method stub
|
||||
// Two-Way Authentication
|
||||
HttpsUtil httpsUtil = new HttpsUtil(); |
||||
try { |
||||
httpsUtil.initSSLConfigForTwoWay(); |
||||
} catch (Exception e2) { |
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace(); |
||||
} |
||||
|
||||
// Authentication,get token
|
||||
String accessToken = null; |
||||
try { |
||||
accessToken = login(httpsUtil); |
||||
} catch (Exception e1) { |
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace(); |
||||
} |
||||
|
||||
// Please make sure that the following parameter values have been modified in
|
||||
// the Constant file.
|
||||
String appId = Constant.APPID; |
||||
String urlQueryDevices = Constant.QUERY_DEVICES; |
||||
|
||||
// please replace the pageNo and pageSize, when you use the demo.
|
||||
Integer pageNo = 0; |
||||
Integer pageSize = 500; |
||||
|
||||
Map<String, String> paramQueryDevices = new HashMap<String, String>(); |
||||
paramQueryDevices.put("appId", appId); |
||||
paramQueryDevices.put("pageNo", pageNo.toString()); |
||||
paramQueryDevices.put("pageSize", pageSize.toString()); |
||||
|
||||
Map<String, String> header = new HashMap<String, String>(); |
||||
header.put(Constant.HEADER_APP_KEY, appId); |
||||
header.put(Constant.HEADER_APP_AUTH, "Bearer" + " " + accessToken); |
||||
|
||||
StreamClosedHttpResponse bodyQueryDevices = null; |
||||
try { |
||||
bodyQueryDevices = httpsUtil.doGetWithParasGetStatusLine(urlQueryDevices, paramQueryDevices, header); |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
// System.out.println("请求地址----" + urlQueryDevices);
|
||||
// System.out.println("请求参数----" + paramQueryDevices);
|
||||
// System.out.println("请求头部----" + header);
|
||||
|
||||
System.out.println("QueryDevices, response content:"); |
||||
System.out.println(bodyQueryDevices.getStatusLine()); |
||||
System.out.println(bodyQueryDevices.getContent()); |
||||
System.out.println(); |
||||
|
||||
String state; |
||||
try { |
||||
|
||||
FastJsonUtil fastJsonUtil = new FastJsonUtil(); |
||||
state = fastJsonUtil.analysisFastJson(bodyQueryDevices.getContent()); |
||||
if (state.equals("success")) { |
||||
System.out.println("查询设备信息成功!!"); |
||||
} else { |
||||
System.out.println("查询设备信息失败!!"); |
||||
} |
||||
// String deviceMessage = jsonNode.get("devices").toString();
|
||||
// System.out.println(deviceMessage);
|
||||
// List<DeviceMessage> beanList = objectMapper.readValue(deviceMessage, new
|
||||
// TypeReference<List<DeviceMessage>>() {});
|
||||
// System.out.println(beanList);
|
||||
} catch (ParseException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Authentication,get token |
||||
*/ |
||||
@SuppressWarnings("unchecked") |
||||
public static String login(HttpsUtil httpsUtil) throws Exception { |
||||
|
||||
String appId = Constant.APPID; |
||||
String secret = Constant.SECRET; |
||||
String urlLogin = Constant.APP_AUTH; |
||||
|
||||
Map<String, String> paramLogin = new HashMap<String, String>(); |
||||
paramLogin.put("appId", appId); |
||||
paramLogin.put("secret", secret); |
||||
|
||||
StreamClosedHttpResponse responseLogin = httpsUtil.doPostFormUrlEncodedGetStatusLine(urlLogin, paramLogin); |
||||
|
||||
System.out.println("app auth success,return accessToken:"); |
||||
System.out.print(responseLogin.getStatusLine()); |
||||
System.out.println(responseLogin.getContent()); |
||||
System.out.println(); |
||||
|
||||
Map<String, String> data = new HashMap<String, String>(); |
||||
data = JsonUtil.jsonString2SimpleObj(responseLogin.getContent(), data.getClass()); |
||||
return data.get("accessToken"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询水表状态值 |
||||
*/ |
||||
@Scheduled(cron = "0 0 0-4 * * ? ") |
||||
public void queryWaterDevice() { |
||||
System.out.println("每四个小时定时查询设备状态值"); |
||||
// TODO Auto-generated method stub
|
||||
// TODO Auto-generated method stub
|
||||
// Two-Way Authentication
|
||||
HttpsUtil httpsUtil = new HttpsUtil(); |
||||
try { |
||||
httpsUtil.initSSLConfigForTwoWay(); |
||||
} catch (Exception e2) { |
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace(); |
||||
} |
||||
|
||||
// Authentication,get token
|
||||
String accessToken = null; |
||||
try { |
||||
accessToken = loginWater(httpsUtil); |
||||
} catch (Exception e1) { |
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace(); |
||||
} |
||||
|
||||
// Please make sure that the following parameter values have been modified in
|
||||
// the Constant file.
|
||||
String appId = ConstantWater.APPID; |
||||
String urlQueryDevices = ConstantWater.QUERY_DEVICES; |
||||
|
||||
// please replace the pageNo and pageSize, when you use the demo.
|
||||
Integer pageNo = 0; |
||||
Integer pageSize = 500; |
||||
|
||||
Map<String, String> paramQueryDevices = new HashMap<String, String>(); |
||||
paramQueryDevices.put("appId", appId); |
||||
paramQueryDevices.put("pageNo", pageNo.toString()); |
||||
paramQueryDevices.put("pageSize", pageSize.toString()); |
||||
|
||||
Map<String, String> header = new HashMap<String, String>(); |
||||
header.put(Constant.HEADER_APP_KEY, appId); |
||||
header.put(Constant.HEADER_APP_AUTH, "Bearer" + " " + accessToken); |
||||
|
||||
StreamClosedHttpResponse bodyQueryDevices = null; |
||||
try { |
||||
bodyQueryDevices = httpsUtil.doGetWithParasGetStatusLine(urlQueryDevices, paramQueryDevices, header); |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
// System.out.println("请求地址----" + urlQueryDevices);
|
||||
// System.out.println("请求参数----" + paramQueryDevices);
|
||||
// System.out.println("请求头部----" + header);
|
||||
|
||||
System.out.println("QueryDevices, response content:"); |
||||
System.out.println(bodyQueryDevices.getStatusLine()); |
||||
System.out.println(bodyQueryDevices.getContent()); |
||||
System.out.println(); |
||||
|
||||
String state; |
||||
try { |
||||
|
||||
FastJsonUtil fastJsonUtil = new FastJsonUtil(); |
||||
state = fastJsonUtil.analysisFastJson(bodyQueryDevices.getContent()); |
||||
if (state.equals("success")) { |
||||
System.out.println("查询设备信息成功!!"); |
||||
} else { |
||||
System.out.println("查询设备信息失败!!"); |
||||
} |
||||
// String deviceMessage = jsonNode.get("devices").toString();
|
||||
// System.out.println(deviceMessage);
|
||||
// List<DeviceMessage> beanList = objectMapper.readValue(deviceMessage, new
|
||||
// TypeReference<List<DeviceMessage>>() {});
|
||||
// System.out.println(beanList);
|
||||
} catch (ParseException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
} |
||||
/** |
||||
* Authentication,get token |
||||
*/ |
||||
@SuppressWarnings("unchecked") |
||||
public static String loginWater(HttpsUtil httpsUtil) throws Exception { |
||||
|
||||
String appId = ConstantWater.APPID; |
||||
String secret = ConstantWater.SECRET; |
||||
String urlLogin = ConstantWater.APP_AUTH; |
||||
|
||||
Map<String, String> paramLogin = new HashMap<String, String>(); |
||||
paramLogin.put("appId", appId); |
||||
paramLogin.put("secret", secret); |
||||
|
||||
StreamClosedHttpResponse responseLogin = httpsUtil.doPostFormUrlEncodedGetStatusLine(urlLogin, paramLogin); |
||||
|
||||
System.out.println("app auth success,return accessToken:"); |
||||
System.out.print(responseLogin.getStatusLine()); |
||||
System.out.println(responseLogin.getContent()); |
||||
System.out.println(); |
||||
|
||||
Map<String, String> data = new HashMap<String, String>(); |
||||
data = JsonUtil.jsonString2SimpleObj(responseLogin.getContent(), data.getClass()); |
||||
return data.get("accessToken"); |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URLEncoder; |
||||
import java.util.List; |
||||
|
||||
import com.mh.garrison.mhutils.MSGClient; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import com.mh.garrison.entity.MSGEntity; |
||||
import com.mh.garrison.service.MSGService; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: SendMSGJob |
||||
* @Description:TODO(定时发送短信信息) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:00:39 |
||||
* |
||||
*/ |
||||
@Component |
||||
public class SendMSGJob { |
||||
|
||||
private final MSGService msgService; |
||||
|
||||
public SendMSGJob(MSGService msgService) { |
||||
// TODO Auto-generated constructor stub
|
||||
this.msgService = msgService; |
||||
} |
||||
|
||||
// @Scheduled(cron = "0 0 0/1 * * ? ")
|
||||
public void sendMSG() { |
||||
System.out.println("每小时执行一次定时发送短信提醒指令"); |
||||
try { |
||||
boolean result = sendCellphoneMessage(); |
||||
if (result) { |
||||
System.out.println("---------------已发送手机短信---------------"); |
||||
} else { |
||||
System.out.println("---------未发送手机短信或者没有结果集-----------"); |
||||
} |
||||
} catch (InterruptedException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public boolean sendCellphoneMessage() throws InterruptedException { |
||||
boolean returnResult = false; |
||||
String userName = "jbqznjf"; |
||||
String password = "dT6pH6rQ1"; |
||||
List<MSGEntity> msgEntities = msgService.queryMSGList(); |
||||
|
||||
for (int i = 0; i < msgEntities.size(); i++) { |
||||
// String content = "尊敬的" + msgEntities.get(i).getHouseNum() + "房客户,您好,您目前"+ msgEntities.get(i).getRemark()+"余额为 "
|
||||
// + msgEntities.get(i).getBalanceMoney() + " 元,为了您的正常使用,请您尽快到指定站点充值,谢谢!" + "【校园电表系统】";
|
||||
String content = msgEntities.get(i).getSendMsg(); |
||||
String mobile = msgEntities.get(i).getCellphoneNum(); |
||||
int send_time = msgEntities.get(i).getSendTime() + 1; |
||||
String remark = msgEntities.get(i).getRemark(); |
||||
String createDate = msgEntities.get(i).getCreateDate(); |
||||
// String content1 = "你好!【校园电表系统】,电费!【校园电表系统】";
|
||||
// String mobile = "18011970201,15277338501,18922383731";
|
||||
MSGClient msgClient = null; |
||||
String result = null; |
||||
try { |
||||
msgClient = new MSGClient(userName, password); |
||||
result = msgClient.mt(URLEncoder.encode(content, "UTF-8"), mobile, "", "", "", ""); |
||||
System.out.println("发送结果--------" + result); |
||||
} catch (UnsupportedEncodingException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
Thread.sleep(200); |
||||
String strCode = result.split("\n")[0]; |
||||
long code = 0; |
||||
code = Long.parseLong(strCode); |
||||
String Info = null; |
||||
if (code > 0) {// 成功提交
|
||||
String sendStatus = msgService.updateSysSms("已发送",mobile, send_time, createDate); |
||||
if (sendStatus.equalsIgnoreCase("success")) { |
||||
Info = "发送成功"; |
||||
System.out.println("返回信息:" + Info + "--" + code + "--" + msgClient.getPwd()); |
||||
returnResult = true; |
||||
} else { |
||||
Info = "发送失败"; |
||||
returnResult = false; |
||||
} |
||||
} else { |
||||
msgService.updateSysSms("未发送",mobile, send_time, createDate); |
||||
returnResult = false; |
||||
if (code == 0) { |
||||
Info = "发送失败"; |
||||
} else if (code == -1) { // 用户名密码不正确
|
||||
Info = "用户名密码不正确"; |
||||
} else if (code == -2) { // 必填选项为空
|
||||
Info = "必填选项为空"; |
||||
} else if (code == -3) { // 短信内容0个字节
|
||||
Info = "短信内容0个字节"; |
||||
} else if (code == -4) { // 0个有效号码
|
||||
Info = "0个有效号码"; |
||||
} else if (code == -5) { // 余额不够
|
||||
Info = "余额不够"; |
||||
} else if (code == -10) { // 用户被禁用
|
||||
Info = "用户被禁用"; |
||||
} else if (code == -11) { // 短信内容过长
|
||||
Info = "短信内容过长"; |
||||
} else if (code == -12) { // 用户无扩展权限
|
||||
Info = "无扩展权限"; |
||||
} else if (code == -13) { // IP地址校验错
|
||||
Info = "IP校验错误"; |
||||
} else if (code == -14) { // 内容解析异常
|
||||
Info = "内容解析异常"; |
||||
} else { |
||||
Info = "未知错误"; |
||||
} |
||||
} |
||||
assert msgClient != null; |
||||
System.out.println("返回信息:" + Info + "--" + code + "--" + msgClient.getPwd()); |
||||
} |
||||
return returnResult; |
||||
} |
||||
} |
@ -0,0 +1,216 @@
|
||||
package com.mh.garrison.job; |
||||
|
||||
import java.io.IOException; |
||||
import java.sql.SQLException; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import com.mh.garrison.entity.AEPEntity; |
||||
import com.mh.garrison.mhutils.*; |
||||
import com.mh.garrison.service.MeterService; |
||||
import org.apache.http.HttpResponse; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode; |
||||
import com.mh.garrison.entity.OrderEntity; |
||||
import com.mh.garrison.service.OrderService; |
||||
|
||||
/** |
||||
* @ClassName: SendOrderJob |
||||
* @Description:TODO(定时发送指令) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:08:28 |
||||
*/ |
||||
@Component |
||||
public class SendOrderJob { |
||||
|
||||
private final OrderService orderService; |
||||
|
||||
private final MeterService meterService; |
||||
|
||||
public SendOrderJob(OrderService orderService, MeterService meterService) { |
||||
// TODO Auto-generated constructor stub
|
||||
this.orderService = orderService; |
||||
this.meterService = meterService; |
||||
} |
||||
|
||||
@Scheduled(cron = "0/30 * * * * ? ") |
||||
public void sendOrder() { |
||||
System.out.println("每30秒定时发送指令状态值"); |
||||
try { |
||||
if (sendOrderJob()) { |
||||
System.out.println("------------已发送报文-------------"); |
||||
} else { |
||||
System.out.println("------------未发送报文-------------"); |
||||
} |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private boolean sendOrderJob() { |
||||
// TODO Auto-generated method stub
|
||||
/* |
||||
* the device must connect to IoT platform before na post asyn command to device |
||||
*/ |
||||
// {
|
||||
// "_class" : "com.huawei.iom.iocm.domain.nsse.NsseRoute",
|
||||
// "deviceId" : "8c23b6b4-ea68-48fb-9c2f-90452a81ebb1",
|
||||
// "appId" : "pAw9x9zinQnQkYSLWbiGI_O6iBUa",
|
||||
// "nsseId" : "http://185.11.1.43:8096",
|
||||
// "edgeGwId" : "MeterCig",
|
||||
// "edgeGwType" : "CoAP",
|
||||
// "status" : "ONLINE"
|
||||
// }
|
||||
// Double test = 9.9;
|
||||
|
||||
Boolean send_sms = false; |
||||
try { |
||||
List<OrderEntity> orderEntities = orderService.queryOrderList(); |
||||
if (orderEntities.size() != 0) { |
||||
for (int i = 0; i < orderEntities.size(); i++) { |
||||
// 判断当前电表平台类型
|
||||
OrderEntity orderEntity = orderEntities.get(i); |
||||
// 0:默认OC平台,1:AEP平台
|
||||
Integer platformType = meterService.selectPlatformType(orderEntity.getHouseNum(), orderEntity.getDeviceNum()); |
||||
if (platformType == 1) { |
||||
System.out.println("------------发送AEP平台-------------"); |
||||
sendAEPOrder(orderEntity); |
||||
Thread.sleep(3000); // 发送命令之后延时3秒钟
|
||||
send_sms = true; |
||||
continue; |
||||
} |
||||
// Two-Way Authentication
|
||||
HttpsUtil httpsUtil = new HttpsUtil(); |
||||
httpsUtil.initSSLConfigForTwoWay(); |
||||
|
||||
// Authentication,get token
|
||||
String accessToken = login(httpsUtil); |
||||
|
||||
// Please make sure that the following parameter values have been modified in
|
||||
// the Constant file.
|
||||
String urlPostAsynCmd = Constant.POST_ASYN_CMD; |
||||
String appId = Constant.APPID; |
||||
|
||||
// please replace the deviceId, when you use the demo.
|
||||
// String deviceId = "e86be9aa-d61b-428f-9d3f-f0dcef365308";
|
||||
String deviceId = null; |
||||
try { |
||||
deviceId = orderEntities.get(i).getDeviceId(); |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
deviceId = "空值"; |
||||
} |
||||
|
||||
|
||||
if (deviceId != null) { |
||||
String callbackUrl = Constant.REPORT_CMD_EXEC_RESULT_CALLBACK_URL; |
||||
|
||||
// please replace the following parameter values, when you use the demo.
|
||||
// And those parameter values must be consistent with the content of profile
|
||||
// that have been preset to IoT platform.
|
||||
// The following parameter values of this demo are use the watermeter profile
|
||||
// that already initialized to IoT platform.
|
||||
String serviceId = "MHMeterData"; |
||||
String method = "COMMAND"; |
||||
String sendOrder = orderEntities.get(i).getSendOrder(); |
||||
// ObjectNode paras =
|
||||
// ObjectNode paras = JsonUtil.convertObject2ObjectNode("{\"value\":\"689999999999996804085BF33333333388667A16\"}"); // 拉闸
|
||||
// ObjectNode paras = JsonUtil.convertObject2ObjectNode("{\"value\":\"689999999999996804085BF33333333399CCF116\"}"); // 合闸
|
||||
// JsonUtil.convertObject2ObjectNode("{\"value\":\"689999999999996804085BF33333333388667A16\"}");
|
||||
// // 拉闸
|
||||
ObjectNode paras = JsonUtil.convertObject2ObjectNode("{\"value\":\"" + sendOrder + "\"}"); // 合闸
|
||||
|
||||
Map<String, Object> paramCommand = new HashMap<String, Object>(); |
||||
paramCommand.put("serviceId", serviceId); |
||||
paramCommand.put("method", method); |
||||
paramCommand.put("paras", paras); |
||||
|
||||
Map<String, Object> paramPostAsynCmd = new HashMap<String, Object>(); |
||||
paramPostAsynCmd.put("deviceId", deviceId); |
||||
paramPostAsynCmd.put("command", paramCommand); |
||||
paramPostAsynCmd.put("callbackUrl", callbackUrl); // 设置回调地址
|
||||
paramPostAsynCmd.put("expireTime", "0"); // 设置发送时间
|
||||
|
||||
String jsonRequest = JsonUtil.jsonObj2Sting(paramPostAsynCmd); |
||||
|
||||
Map<String, String> header = new HashMap<String, String>(); |
||||
header.put(Constant.HEADER_APP_KEY, appId); |
||||
header.put(Constant.HEADER_APP_AUTH, "Bearer" + " " + accessToken); |
||||
|
||||
HttpResponse responsePostAsynCmd = httpsUtil.doPostJson(urlPostAsynCmd, header, jsonRequest); |
||||
|
||||
String responseBody = httpsUtil.getHttpResponseBody(responsePostAsynCmd); |
||||
|
||||
System.out.println("PostAsynCommand, response content:"); |
||||
System.out.print(responsePostAsynCmd.getStatusLine()); |
||||
System.out.println(responseBody); |
||||
System.out.println(); |
||||
Thread.sleep(3000); // 发送命令之后延时3秒钟
|
||||
send_sms = true; |
||||
} |
||||
} |
||||
} |
||||
} catch (IOException e) { |
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
System.out.println("----------------" + e.getMessage().toString() + "---------------------"); |
||||
return send_sms; |
||||
} catch (SQLException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} catch (Throwable e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
return send_sms; |
||||
|
||||
} |
||||
|
||||
private void sendAEPOrder(OrderEntity orderEntity) { |
||||
try { |
||||
String deviceId = orderEntity.getDeviceId(); |
||||
Integer groupId = 153097; |
||||
Integer productNum = 17171214; |
||||
String masterAPIkey = "72a2c789bb3f4f90b6e5bbffbe6e86b7"; |
||||
AEPEntity aepEntity = new AEPEntity(); |
||||
aepEntity.setDeviceGroupId(groupId); |
||||
aepEntity.setMasterAPIKey(masterAPIkey); |
||||
aepEntity.setProductId(productNum); |
||||
PostCmdUtils.postAsyncCmdAEPV1ByProfile(deviceId, orderEntity.getSendOrder(), aepEntity); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
System.out.println("----------------" + e.getMessage() + "---------------------"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Authentication,get token |
||||
*/ |
||||
@SuppressWarnings("unchecked") |
||||
public static String login(HttpsUtil httpsUtil) throws Exception { |
||||
|
||||
String appId = Constant.APPID; |
||||
String secret = Constant.SECRET; |
||||
String urlLogin = Constant.APP_AUTH; |
||||
|
||||
Map<String, String> paramLogin = new HashMap<String, String>(); |
||||
paramLogin.put("appId", appId); |
||||
paramLogin.put("secret", secret); |
||||
|
||||
StreamClosedHttpResponse responseLogin = httpsUtil.doPostFormUrlEncodedGetStatusLine(urlLogin, paramLogin); |
||||
|
||||
System.out.println("app auth success,return accessToken:"); |
||||
System.out.print(responseLogin.getStatusLine()); |
||||
System.out.println(responseLogin.getContent()); |
||||
System.out.println(); |
||||
|
||||
Map<String, String> data = new HashMap<String, String>(); |
||||
data = JsonUtil.jsonString2SimpleObj(responseLogin.getContent(), data.getClass()); |
||||
return data.get("accessToken"); |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import org.apache.ibatis.annotations.*; |
||||
import org.apache.ibatis.mapping.StatementType; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DeviceMapper |
||||
* @Description:TODO(修改更新发送拉合闸命令和读取数据状态命令) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年10月15日 下午5:17:31 |
||||
* |
||||
*/ |
||||
@Mapper |
||||
public interface DeviceMapper { |
||||
|
||||
@Select({"exec pro_update_order #{device_num,mode=IN,jdbcType=VARCHAR},#{remark,mode=IN,jdbcType=VARCHAR}," |
||||
+ "#{state,mode=OUT,jdbcType=VARCHAR}"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
List<Map<String,Object>> exeProcedure(Map<String,Object> params); |
||||
|
||||
@Select("select top 1 PlateformType from MeterInstall where MeterID = #{meterId} ") |
||||
Integer findPlatform(@Param("meterId") String meterID); |
||||
|
||||
@Update("update MeterInstall set PlateformType = 1 where MeterID = #{meterId} ") |
||||
void updatePlatform(@Param("meterId") String meterID); |
||||
|
||||
@Select({"exec pro_add_state #{device_id,mode=IN,jdbcType=VARCHAR},#{create_date,mode=IN,jdbcType=VARCHAR},#{lastModifiedTime,mode=IN,jdbcType=VARCHAR},#{device_imei,mode=IN,jdbcType=VARCHAR}," |
||||
+ "#{device_state,mode=IN,jdbcType=VARCHAR}"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
List<Map<String,Object>> exeAddStateProcedure(Map<String,Object> params); |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Result; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.Update; |
||||
|
||||
import com.mh.garrison.entity.MSGEntity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MSGMapper |
||||
* @Description:TODO(查询需要发送短信的客户) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:20:46 |
||||
* |
||||
*/ |
||||
@Mapper |
||||
public interface MSGMapper { |
||||
|
||||
@Results({ |
||||
@Result(property = "houseNum", column = "house_num"), |
||||
@Result(property = "cellphoneNum", column = "cellphone_num"), |
||||
@Result(property = "balanceMoney", column = "balance_money"), |
||||
@Result(property = "remark", column = "remark"), |
||||
@Result(property = "sendTime", column = "send_time"), |
||||
@Result(property = "createDate", column = "create_date"), |
||||
@Result(property = "sendMsg", column = "send_msg") |
||||
}) |
||||
@Select("select house_num, cellphone_num, balance_money, remark, send_time, convert(varchar(25),create_date,121) as create_date, send_msg from sys_sms where is_send = '未发送' and send_time < 3 order by create_date desc") |
||||
List<MSGEntity> queryMSGList(); |
||||
|
||||
// @Update("update sys_sms set is_send = '已发送', send_time = #{sendTime} where cellphone_num = #{cellphone} and convert(varchar(25),create_date,121) = #{createDate}")
|
||||
// int updateSysSms(@Param("cellphone") String cellphone,@Param("sendTime") int sendTime , @Param("createDate") String createDate);
|
||||
|
||||
@Update("update sys_sms set is_send = #{isSend}, send_time = #{sendTime} where cellphone_num = #{cellphone} and convert(varchar(25),create_date,121) = #{createDate}") |
||||
int updateSysSms(@Param("isSend") String isSend,@Param("cellphone") String cellphone,@Param("sendTime") int sendTime , @Param("createDate") String createDate); |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import com.mh.garrison.entity.MeterHistoryBean; |
||||
|
||||
@Mapper |
||||
public interface MeterHistoryMapper { |
||||
|
||||
// 增加数据内容到mt_now表中
|
||||
@Insert("insert into mt_history(mt_num,mt_electric,mt_state,mt_device_id,mt_time,house_num,building_name,grade)" |
||||
+ " values (#{mt_num},#{mt_electric},#{mt_state},#{mt_device_id},#{mt_time},#{house_num},#{building_name},#{grade})") |
||||
int insertAll(MeterHistoryBean meterHistoryBean); |
||||
|
||||
@Select("select top 1 count(mt_num) from mt_history where mt_num = #{mt_num} and mt_time = #{mt_time}") |
||||
int checkHistory(MeterHistoryBean meterHistoryBean); |
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import com.mh.garrison.entity.MeterNowBean; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MeterMapper |
||||
* @Description:TODO(对电表数据增删查改) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年9月4日 下午5:04:37 |
||||
* |
||||
*/ |
||||
@Mapper |
||||
public interface MeterMapper { |
||||
|
||||
//对电表查询全部
|
||||
@Select("select id,mt_num,mt_electric,mt_state,mt_time,areas_name from mt_now") |
||||
List<MeterNowBean> findAllMeterNow(); |
||||
|
||||
@Select("select top 1 PlateformType from MeterInstall where HouseNo = #{houseNum} and MeterId = #{deviceNum} ") |
||||
Integer selectPlatformType(@Param("houseNum") String houseNum, |
||||
@Param("deviceNum") String deviceNum); |
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.mapping.StatementType; |
||||
|
||||
import com.mh.garrison.entity.MeterNowBean; |
||||
|
||||
@Mapper |
||||
public interface MeterNowMapper { |
||||
|
||||
// 查询房间号 2018-09-28 by ljf
|
||||
// @Select("select house_num from house where id = (select parent_id from house where device_num = #{device_num})")
|
||||
// 查询房间号 2018-12-18 by ljf
|
||||
@Select("select top 1 HouseNo from MeterInstall where MeterID = #{device_num}") |
||||
String findHouse(@Param("device_num") String device_num); |
||||
|
||||
// 厦门双桥查询电表名称
|
||||
@Select("select top 1 ISNULL(MeterName,'') from MeterInstall where MeterID = #{device_num}") |
||||
String findHouse1(@Param("device_num") String device_num); |
||||
@Select("select top 1 isnull(building_name,'') from MeterInstall where MeterID = #{device_num}") |
||||
String findBuildingName1(@Param("device_num") String device_num); |
||||
|
||||
// 查询楼层建筑 2018-09-28 by ljf
|
||||
@Select("select top 1 house_num from house where id = (select parent_id from house where house_num = #{house_num})") |
||||
String findBuilding(@Param("house_num") String house_num); |
||||
|
||||
// 由于数据库修改,从而查询楼栋建筑2018-12-18 by ljf
|
||||
// @Select("select house_num from house where id = "
|
||||
// + "(select parent_id from house where id = (select parent_id from house where house_num = #{house_num}))")
|
||||
@Select("select top 1 building_name from MeterInstall where MeterID = #{device_num}") |
||||
String findBuildingName(@Param("device_num") String device_num); |
||||
|
||||
// 检查是否有数值
|
||||
@Select("select top 1 count(mt_num) from mt_now where mt_time = #{mt_time}") |
||||
int checkMeterNow(MeterNowBean meterNowBean); |
||||
|
||||
// 检查是否有对应的表号
|
||||
@Select("select top 1 count(mt_num) from mt_now where mt_num = #{mt_num}") |
||||
<T> int checkMeterId(T meterNowBean); |
||||
|
||||
// 增加数据内容到mt_now表中 update by ljf on 2018-11-12
|
||||
@Insert("insert into mt_now(mt_num,mt_electric,mt_state,mt_device_id,limited_power,mt_time,house_num,building_name,grade)" |
||||
+ " values (#{mt_num},#{mt_electric},#{mt_state},#{mt_device_id},#{limited_power},#{mt_time},#{house_num},#{building_name},#{grade})") |
||||
<T> int insertAll(T meterNowBean); |
||||
|
||||
// 当电表发生数据变化时,更新数据内容到meter_now表中
|
||||
@Update("update mt_now set mt_electric=#{mt_electric}, mt_time=#{mt_time}, mt_state=#{mt_state}, limited_power=#{limited_power}" |
||||
+ " where mt_num = #{mt_num}") |
||||
<T> int updateAll(T meterNowBean); |
||||
|
||||
// 执行存储过程,计算电表以及地区的值
|
||||
@Select({"exec pro_calc_hoursmeter"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
String exePro_calc_Meter(); |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Result; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import com.mh.garrison.entity.OrderEntity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: OrderMapper |
||||
* @Description:TODO(指令mapper) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午10:32:35 |
||||
* |
||||
*/ |
||||
@Mapper |
||||
public interface OrderMapper { |
||||
|
||||
@Results({ |
||||
@Result(column = "house_num", property = "houseNum"), |
||||
@Result(column = "device_num", property = "deviceNum"), |
||||
@Result(column = "imei_num", property = "imeiNum"), |
||||
@Result(column = "device_id", property = "deviceId"), |
||||
@Result(column = "send_order", property = "sendOrder"), |
||||
@Result(column = "crate_date", property = "createDate") |
||||
}) |
||||
@Select("select house_num,device_num,imei_num,device_id,send_order,create_date from sys_order where send_state = '未发送' order by create_date") |
||||
List<OrderEntity> queryOrderList(); |
||||
|
||||
} |
@ -0,0 +1,87 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.mapping.StatementType; |
||||
import org.springframework.dao.DataAccessException; |
||||
|
||||
import com.mh.garrison.entity.WaterDayBean; |
||||
import com.mh.garrison.entity.WaterHistoryBean; |
||||
|
||||
@Mapper |
||||
public interface WaterDayMapper { |
||||
|
||||
@Select("select id,wt_num,true_flow,cur_date from wt_day where grade = 0 order by cur_date desc") |
||||
List<WaterDayBean> findAllWaterDay(); |
||||
|
||||
@Select ("select count(id) as tatol_num from wt_day where grade = 0") |
||||
int findNotUploadNum(); |
||||
|
||||
@Select("select id,wt_num,true_flow,cur_date from wt_day where wt_num = #{wt_num} and grade = 0 order by cur_date desc") |
||||
List<WaterDayBean> findByWaterId(@Param("wt_num") String wt_num); |
||||
|
||||
/** |
||||
* 按照表号,时间查询 |
||||
* @param wt_num |
||||
* @return |
||||
*/ |
||||
@Select("select id,wt_num,true_flow,cur_date from wt_day where wt_num = #{wt_num} and convert(varchar(10), cur_date,121) = #{cur_date} and grade = 0 order by cur_date desc") |
||||
List<WaterDayBean> findByDate(@Param("wt_num") String wt_num, @Param("cur_date") String dateString); |
||||
|
||||
/** |
||||
* 按照时间查询 |
||||
* @param wt_num |
||||
* @return |
||||
*/ |
||||
@Select("select id,wt_num,true_flow,cur_date from wt_day where convert(varchar(10), cur_date,121) = #{cur_date} and grade = 0 order by cur_date desc") |
||||
List<WaterDayBean> findByTime(@Param("cur_date") String dateString); |
||||
|
||||
@Select("select top 1 COUNT(*) as sum1 from t_users_day where users_name = #{users_name} and cur_date = #{cur_date}") |
||||
int checkSame(WaterHistoryBean waterDayBean); |
||||
|
||||
@Insert("insert into t_water_day(users_name) values (#{users_name})") |
||||
int insert(@Param("users_name") String users_name); |
||||
|
||||
@Insert("insert into t_users_day(users_name, currentFlow, cur_date, year_date, month_date, grade)" |
||||
+ " values (#{users_name}, #{currentFlow}, #{cur_date}, #{year_date}, #{month_date}, #{grade})") |
||||
int insertAll(WaterHistoryBean waterDayBean) throws DataAccessException; |
||||
|
||||
@Update("update t_users_day set currentFlow=#{currentFlow} where users_name=#{users_name} and cur_date=#{cur_date}") |
||||
int update(WaterHistoryBean waterDayBean); |
||||
|
||||
// 更新grade为1
|
||||
@Update("update wt_day set grade = 1 where wt_num = #{wt_num} and cur_date = #{cur_date}") |
||||
boolean updateGrade(WaterDayBean waterDayBean); |
||||
|
||||
@Delete("delete from t_users_day where users_name=#{users_name}") |
||||
int delete(String users_name); |
||||
|
||||
// 执行存储过程,计算出每天的用量
|
||||
/* @Select({"exec proc_calc_flow #{users_name,mode=IN,jdbcType=VARCHAR}," |
||||
+ "#{date,mode=IN,jdbcType=VARCHAR}"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
String exeProcedure1(WaterDayBean waterDayBean); |
||||
*/ |
||||
@Select({"exec calculate_cursor #{users_name,mode=IN,jdbcType=VARCHAR}," |
||||
+ "#{cur_date,mode=IN,jdbcType=VARCHAR}"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
String exeProcedure(WaterHistoryBean waterDayBean); |
||||
|
||||
// 更新水表属于什么地方或者地区小区
|
||||
@Select({"exec pro_check_areas #{users_name,mode=IN,jdbcType=VARCHAR}"}) |
||||
@Options(statementType=StatementType.CALLABLE) |
||||
String execPro_Cheack_Areas(@Param("users_name") String users_name); |
||||
|
||||
|
||||
// 查询是否已计算
|
||||
@Select("Select calculateFlow from t_users_day where users_name = #{users_name} and cur_date = #{cur_date}") |
||||
String checkCalc(WaterHistoryBean waterDayBean); |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.Update; |
||||
|
||||
import com.mh.garrison.entity.WaterHistoryBean; |
||||
|
||||
@Mapper |
||||
public interface WaterHistoryMapper { |
||||
|
||||
// 查询是否有相同数据内容
|
||||
@Select("select top 1 COUNT(id) as sum1 from wt_history where wt_num = #{wt_num} and CONVERT(varchar(10),cur_date,23) = #{cur_date}") |
||||
// @Select("select top 1 COUNT(id) as sum1 from wt_history where wt_num = #{wt_num} and CONVERT(varchar(25),cur_date,121) = #{cur_date}")
|
||||
int checkSame(WaterHistoryBean waterHistoryBean); |
||||
|
||||
// 插入数据
|
||||
@Insert("insert into wt_history(wt_num,house_num,IMEI,IMSI,cur_flow,cur_date,manufacture_id,grade)" |
||||
+ "values(#{wt_num},#{house_num},#{IMEI},#{IMSI},#{cur_flow},#{cur_date},#{manufacture_id},#{grade})") |
||||
// @Options(useGeneratedKeys=true,keyProperty="id")
|
||||
int insertAll(WaterHistoryBean waterHistoryBean); |
||||
|
||||
// 更新数据
|
||||
@Update("update wt_history set cur_flow=#{cur_flow} where wt_num=#{wt_num} and cur_date=#{cur_date}") |
||||
int update(WaterHistoryBean waterHistoryBean); |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
package com.mh.garrison.mapper; |
||||
|
||||
import com.mh.garrison.entity.WaterBean; |
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.springframework.dao.DataAccessException; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface WaterMapper { |
||||
|
||||
@Select("select * from t_water") |
||||
List<WaterBean> findAllWater(); |
||||
|
||||
@Select("select * from t_water where waterId = #{waterId}") |
||||
WaterBean findByWaterId(@Param("waterId") String waterId); |
||||
|
||||
@Select("select * from t_water where waterId = #{waterId}") |
||||
int findByWaterId1(@Param("waterId") String waterId); |
||||
|
||||
@Insert("insert into t_water(waterId) values (#{waterId})") |
||||
int insert(@Param("waterId") String waterId); |
||||
|
||||
@Insert("insert into t_water(waterId, imsi, imei, currentFlow, currentDate, manufacturerId)" |
||||
+ " values (#{waterId}, #{imsi}, #{imei}, #{currentFlow}, #{currentDate}, #{manufacturerId})") |
||||
int insertAll(WaterBean waterBean) throws DataAccessException; |
||||
|
||||
@Update("update t_water set currentFlow=#{currentFlow}, currentDate=#{currentDate} where waterId=#{waterId}") |
||||
int update(WaterBean waterBean); |
||||
|
||||
@Delete("delete from t_water where waterId=#{waterId}") |
||||
int delete(String waterId); |
||||
|
||||
// 查询IMEI号
|
||||
@Select("select imei_num from house where device_num = #{device_num}") |
||||
String findImei(@Param("device_num") String device_num); |
||||
|
||||
// 查询房间号
|
||||
@Select("select house_num from house where id = (select parent_id from house where device_num = #{device_num})") |
||||
String findHouse1(@Param("device_num") String device_num); |
||||
|
||||
// 查询房间号 update on 2018-12-25 by ljf
|
||||
@Select("select top 1 HouseNo from MeterInstall where MeterID = #{device_num}") |
||||
String findHouse(@Param("device_num") String device_num); |
||||
|
||||
// 查询是否有实时的记录
|
||||
@Select("select top 1 count(id) from wt_now where wt_num = #{wt_num}") |
||||
int findResult(@Param("wt_num") String wt_num); |
||||
|
||||
// 插入水表实时数据 update by ljf on 2019-12-24
|
||||
@Insert("insert into wt_now(wt_num,house_num,IMEI,IMSI,cur_flow,cur_date,manufacture_id,grade)" + |
||||
" values(#{wt_num},#{house_num},#{IMEI},#{IMSI},#{cur_flow},#{cur_date},#{manufacture_id},#{grade})") |
||||
int insertWtNowAll(WaterBean waterBean); |
||||
// @Insert("insert into wt_now(wt_num,house_num,IMEI,IMSI,cur_flow,cur_date,manufacture_id,grade,contra_flow,push_button,store,valve_status,valve_unusual,communication_status,sos_key,voltage,reflux_flow)" +
|
||||
// " values(#{wt_num},#{house_num},#{IMEI},#{IMSI},#{cur_flow},#{cur_date},#{manufacture_id},#{grade},#{contra_flow},#{push_button},#{store},#{valve_status},#{valve_unusual},#{communication_status},#{sos_key},#{voltage},#{reflux_flow})")
|
||||
// int insertWtNowAll(WaterBean waterBean);
|
||||
|
||||
// 水表实时表存在相同的数据,则进行更新,update by ljf on 2019-12-24
|
||||
@Update("update wt_now set cur_flow = #{cur_flow}, cur_date = #{cur_date} where wt_num=#{wt_num}") |
||||
int updateWtNow(WaterBean waterBean); |
||||
// @Update("update wt_now set cur_flow = #{cur_flow}, cur_date = #{cur_date},voltage = #{voltage}, contra_flow = #{contra_flow},push_button = #{push_button},store = #{store},valve_status = #{valve_status},valve_unusual = #{valve_unusual},communication_status = #{communication_status},sos_key = #{sos_key},reflux_flow = #{reflux_flow} where wt_num=#{wt_num}")
|
||||
// int updateWtNow(WaterBean waterBean);
|
||||
|
||||
} |
@ -0,0 +1,784 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
|
||||
import org.springframework.context.ApplicationContext; |
||||
|
||||
import com.mh.garrison.entity.WaterBean; |
||||
import com.mh.garrison.entity.WaterHistoryBean; |
||||
import com.mh.garrison.service.WaterHistoryService; |
||||
import com.mh.garrison.service.WaterServices; |
||||
|
||||
public class ByteUtilsWater { |
||||
|
||||
// 添加之后能够对mapper调用
|
||||
private ApplicationContext applicationContext = SpringUtils.getApplicationContext(); |
||||
|
||||
private WaterServices waterService = applicationContext.getBean(WaterServices.class); |
||||
|
||||
private WaterHistoryService waterHistoryService = applicationContext.getBean(WaterHistoryService.class); |
||||
|
||||
WaterBean water = new WaterBean(); |
||||
WaterHistoryBean wtHistoryBean = new WaterHistoryBean(); |
||||
|
||||
/** |
||||
* 十进制转成十六进制: Integer.toHexString(int i) 十进制转成八进制: Integer.toOctalString(int i) |
||||
* 十进制转成二进制 Integer.toBinaryString(int i) 十六进制转成十进制: |
||||
* Integer.valueOf("FFFF",16).toString() 八进制转成十进制: |
||||
* Integer.valueOf("876",8).toString() 二进制转十进制:* |
||||
* Integer.valueOf("0101",2).toString() |
||||
*/ |
||||
// 光电直读水表解析报文
|
||||
public String analysisFastJson(String receiveData) throws Exception { |
||||
|
||||
// SqlSession session = SQLDataSourceConfig.openSession();
|
||||
String return_result = "success"; |
||||
// // 水表ID
|
||||
// String WaterID = receiveData.substring(14, 24);
|
||||
// WaterID = changePosition(WaterID);
|
||||
// // System.out.println("水表ID——————" + WaterID);
|
||||
// water.setWt_num(WaterID);
|
||||
//
|
||||
// // 厂商ID
|
||||
// String manufactureID = receiveData.substring(24, 28);
|
||||
// manufactureID = changePosition(manufactureID);
|
||||
// // System.out.println("厂商ID——————" + manufactureID);
|
||||
// water.setManufacture_id(manufactureID);;
|
||||
|
||||
// 水表ID
|
||||
String WaterID = receiveData.substring(14, 24); |
||||
WaterID = changePosition(WaterID); |
||||
// System.out.println("水表ID——————" + WaterID);
|
||||
|
||||
// 厂商ID
|
||||
String manufactureID = receiveData.substring(24, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
// System.out.println("厂商ID——————" + manufactureID);
|
||||
|
||||
// 增加水表号为12位数 update by ljf on 2019-08-27
|
||||
String is_status = manufactureID.substring(2, 4); |
||||
System.out.println(is_status); |
||||
if (is_status.equals("06")) { |
||||
WaterID = receiveData.substring(14, 24); |
||||
WaterID = changePosition(WaterID); |
||||
System.out.println("水表ID——————" + WaterID); |
||||
water.setWt_num(WaterID); |
||||
|
||||
manufactureID = receiveData.substring(24, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
System.out.println("厂商ID——————" + manufactureID); |
||||
water.setManufacture_id(manufactureID); |
||||
} else { |
||||
WaterID = receiveData.substring(14, 26); |
||||
WaterID = changePosition(WaterID); |
||||
System.out.println("水表ID——————" + WaterID); |
||||
water.setWt_num(WaterID); |
||||
|
||||
manufactureID = receiveData.substring(26, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
System.out.println("厂商ID——————" + manufactureID); |
||||
water.setManufacture_id(manufactureID); |
||||
} |
||||
|
||||
// 时间
|
||||
String dateString = receiveData.substring(28, 42); |
||||
dateString = dateString.substring(0, 4) + "-" + dateString.substring(4, 6) + "-" + dateString.substring(6, 8) |
||||
+ " " + dateString.substring(8, 10) + ":" + dateString.substring(10, 12) + ":" |
||||
+ dateString.substring(12, 14); |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
||||
Date date = sdf.parse(dateString); |
||||
dateString = sdf.format(date); |
||||
// System.out.println("时间————————" + dateString);
|
||||
water.setCur_date(dateString); |
||||
|
||||
// 按日
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
||||
Date date1 = sdf1.parse(dateString); |
||||
String dateString1 = sdf1.format(date1); |
||||
|
||||
// 电池电压
|
||||
String Battery = receiveData.substring(44, 48); |
||||
Battery = changePosition(Battery); |
||||
Battery = hex2Binary(Battery); |
||||
Battery = Integer.valueOf(Battery, 2).toString(); |
||||
double voltage = Double.parseDouble(Battery) / 100; |
||||
// 2019-12-06 update by ljf
|
||||
water.setVoltage(voltage); |
||||
System.out.println("电池电压————" + voltage + " V"); |
||||
|
||||
// 累计上线成功次数
|
||||
String onlineSum = receiveData.substring(48, 52); |
||||
onlineSum = changePosition(onlineSum); |
||||
onlineSum = hex2Binary(onlineSum); |
||||
onlineSum = Integer.valueOf(onlineSum, 2).toString(); |
||||
// System.out.println("累计上线成功次数——" + onlineSum);
|
||||
|
||||
// 累计上线失败次数
|
||||
String failedSum = receiveData.substring(52, 56); |
||||
failedSum = changePosition(failedSum); |
||||
failedSum = hex2Binary(failedSum); |
||||
failedSum = Integer.valueOf(failedSum, 2).toString(); |
||||
// System.out.println("累计上线失败次数——" + failedSum);
|
||||
|
||||
// 状态字
|
||||
String stateStr = receiveData.substring(56, 64); |
||||
// System.out.println("状态字————————" + stateStr);
|
||||
// update by ljf on 2019-12-24
|
||||
// 状态字
|
||||
System.out.println("状态字————————" + stateStr); |
||||
System.out.println("状态字1--------------------" + hex2Binary(stateStr.substring(0, 2))); |
||||
System.out.println("状态字1.0:逆流标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(7, 8).equalsIgnoreCase("0") ? "正常" : "逆流")); |
||||
System.out.println("状态字1.1:按键异常标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(6, 7).equalsIgnoreCase("0") ? "正常" : "故障")); |
||||
System.out.println("状态字1.3:存储故障标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(5, 6).equalsIgnoreCase("0") ? "正常" : "故障")); |
||||
System.out.println("状态字2--------------------" + hex2Binary(stateStr.substring(2, 4))); |
||||
System.out.println("状态字2.7:阀门状态 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(0, 1).equalsIgnoreCase("0") ? "开阀" : "关阀")); |
||||
System.out.println("状态字2.6:阀门异常 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(1, 2).equalsIgnoreCase("0") ? "正常" : "异常")); |
||||
System.out.println("状态字2.5:流量通讯异常标志 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(2, 3).equalsIgnoreCase("0") ? "正常" : "异常")); |
||||
System.out.println("状态字3--------------------" + hex2Binary(stateStr.substring(4, 6))); |
||||
System.out.println("状态字3.4:应急按键标志 " |
||||
+ (hex2Binary(stateStr.substring(4, 6)).substring(3, 4).equalsIgnoreCase("0") ? "正常" : "已关阀三天")); |
||||
System.out.println("状态字4-------" + hex2Binary(stateStr.substring(6, 8))); |
||||
|
||||
water.setContra_flow(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(7, 8))); |
||||
water.setPush_button(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(6, 7))); |
||||
water.setStore(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(5, 6))); |
||||
water.setValve_status(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(0, 1))); |
||||
water.setValve_unusual(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(1, 2))); |
||||
water.setCommunication_status(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(2, 3))); |
||||
water.setSos_key(Integer.parseInt(hex2Binary(stateStr.substring(4, 6)).substring(3, 4))); |
||||
|
||||
// 软件版本
|
||||
String SofewareStr = receiveData.substring(82, 86); |
||||
SofewareStr = changePosition(SofewareStr); |
||||
SofewareStr = hex2Binary(SofewareStr); |
||||
SofewareStr = Integer.valueOf(SofewareStr, 2).toString(); // 主版本
|
||||
String SofewareStr1 = receiveData.substring(86, 88); |
||||
SofewareStr1 = hex2Binary(SofewareStr1); |
||||
SofewareStr1 = Integer.valueOf(SofewareStr1, 2).toString(); // 子版本
|
||||
// System.out.println("软件主版本——" + SofewareStr + ",软件子版本——" + SofewareStr1);
|
||||
|
||||
// IMSI 号
|
||||
String IMSIStr = receiveData.substring(88, 104); |
||||
water.setIMSI(IMSIStr); |
||||
|
||||
// 当前累计流量
|
||||
String totalFlow = receiveData.substring(104, 114); |
||||
totalFlow = changePosition(totalFlow); |
||||
totalFlow = hex2Binary(totalFlow); |
||||
totalFlow = Integer.valueOf(totalFlow, 2).toString(); |
||||
Double flow = Double.parseDouble(totalFlow) / 10; |
||||
// System.out.println("当前累计流量————" + flow + " L");
|
||||
water.setCur_flow(String.valueOf(flow / 1000)); |
||||
|
||||
// 当前累计逆流量
|
||||
String reverseFlow = receiveData.substring(114, 124); |
||||
reverseFlow = changePosition(reverseFlow); |
||||
reverseFlow = hex2Binary(reverseFlow); |
||||
reverseFlow = Integer.valueOf(reverseFlow, 2).toString(); |
||||
Double flow1 = Double.parseDouble(reverseFlow) / 10; |
||||
System.out.println("当前累计逆流量————" + flow1 + " L"); |
||||
water.setReflux_flow(flow1 / 1000); |
||||
|
||||
// imei号
|
||||
String imei = waterService.findImei(WaterID); |
||||
water.setIMEI(imei); |
||||
|
||||
// 房间号
|
||||
String house_num = waterService.findHouse(WaterID); |
||||
water.setHouse_num(house_num); |
||||
water.setGrade(0); |
||||
|
||||
int nowSum = waterService.findResult(WaterID); |
||||
|
||||
if (nowSum != 0) { |
||||
System.out.println("已存在水表"); |
||||
int updateResult = waterService.updateWtNow(water); |
||||
if (updateResult == 1) { |
||||
System.out.println("更新水表成功"); |
||||
} else { |
||||
System.out.println("更新水表失败"); |
||||
} |
||||
} else { |
||||
// 插入数据库
|
||||
int result = waterService.insertWtNowAll(water); |
||||
if (result == 1) { |
||||
System.out.println("新增水表成功"); |
||||
} else { |
||||
System.out.println("新增水表失败"); |
||||
} |
||||
} |
||||
// wtHistoryBean.setWt_num(WaterID);
|
||||
// wtHistoryBean.setHouse_num(house_num);
|
||||
// wtHistoryBean.setIMEI(imei);
|
||||
// wtHistoryBean.setIMSI(IMSIStr);
|
||||
// wtHistoryBean.setCur_flow(flow/1000);
|
||||
// wtHistoryBean.setCur_date(dateString1); //2018-07-01
|
||||
// wtHistoryBean.setManufacture_id(manufactureID);
|
||||
// wtHistoryBean.setGrade(0);
|
||||
// wtHistoryBean.setYear_date(dateString1.substring(0, 4));
|
||||
// waterDayBean.setMonth_date(dateString1.substring(0,7));
|
||||
// int a1 = waterHistoryMapper.checkSame(wtHistoryBean);
|
||||
// if (a1 == 0) {
|
||||
// waterHistoryMapper.insertAll(wtHistoryBean);
|
||||
//// System.out.println("插入第 " + (i+1) + " 日数据成功");
|
||||
// }else {
|
||||
// // 更新当天水表的日结数
|
||||
// waterHistoryMapper.update(wtHistoryBean);
|
||||
// }
|
||||
|
||||
// 日结数组
|
||||
String dateReport = receiveData.substring(124, 126); |
||||
dateReport = hex2Binary(dateReport); |
||||
dateReport = Integer.valueOf(dateReport, 2).toString(); |
||||
// System.out.println("日结数组数————" + dateReport);
|
||||
|
||||
// 日结数据
|
||||
int days = Integer.parseInt(dateReport); |
||||
|
||||
String dateString2 = dateString1; |
||||
SimpleDateFormat sj = new SimpleDateFormat("yyyy-MM-dd"); |
||||
Date d = sj.parse(dateString2); |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(d); |
||||
// calendar.add(Calendar.DATE, -27);
|
||||
// update by ljf on 2019-10-16 解决存储数据库出现超出当前报文的时间
|
||||
calendar.add(Calendar.DATE, -Integer.parseInt(dateReport)); |
||||
dateString2 = sj.format(calendar.getTime()); |
||||
long dif; |
||||
Date date2 = new Date(); |
||||
// System.out.println("29天前:" + sj.format(calendar.getTime()));
|
||||
for (int i = 0; i < days; i++) { |
||||
String dayReport = receiveData.substring((128 + i * 10), (128 + (i + 1) * 10)); |
||||
dayReport = changePosition(dayReport); |
||||
if (dayReport.equals("ffffffffff")) { |
||||
dif = sdf1.parse(dateString2).getTime() + 86400 * 1000; // 加一天
|
||||
date2.setTime(dif); |
||||
dateString2 = sdf1.format(date2); |
||||
continue; |
||||
} |
||||
dayReport = hex2Binary(dayReport); |
||||
dayReport = Integer.valueOf(dayReport, 2).toString(); |
||||
Double dayflow = Double.parseDouble(dayReport) / 10; |
||||
|
||||
// 加一天时间
|
||||
try { |
||||
dif = sdf1.parse(dateString2).getTime() + 86400 * 1000; // 加一天
|
||||
date2.setTime(dif); |
||||
dateString2 = sdf1.format(date2); |
||||
System.out.println("加一天之后: " + i + "、" + dateString2 + "/" + (dayflow / 1000)); |
||||
System.out.println("第 " + dateString2 + " 日的数据————" + dayflow + " L"); |
||||
wtHistoryBean.setWt_num(WaterID); |
||||
wtHistoryBean.setHouse_num(house_num); |
||||
wtHistoryBean.setIMEI(imei); |
||||
wtHistoryBean.setIMSI(IMSIStr); |
||||
wtHistoryBean.setCur_flow(String.valueOf(dayflow / 1000)); |
||||
wtHistoryBean.setCur_date(dateString2); // 2018-07-01
|
||||
wtHistoryBean.setManufacture_id(manufactureID); |
||||
wtHistoryBean.setGrade(0); |
||||
|
||||
System.out.println("水表表号-------------" + WaterID); |
||||
int a3 = waterHistoryService.insertAll(wtHistoryBean); |
||||
// int a3 = waterHistoryMapper.insertAll(wtHistoryBean);
|
||||
System.out.println("-----------------" + a3 + "--------------------------"); |
||||
if (a3 == 1) { |
||||
// session.commit();
|
||||
// System.out.println(wtHistoryBean.toString());
|
||||
// Thread.sleep(5000);
|
||||
int a2 = waterHistoryService.checkSame(wtHistoryBean); |
||||
System.out.println("-----------------" + a2 + "--------------------------"); |
||||
if (a2 == 1) { |
||||
// System.out.println(wtHistoryBean.toString());
|
||||
System.out.println("插入历史流水表成功"); |
||||
} else { |
||||
return_result = "fail"; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
continue; |
||||
} |
||||
} |
||||
// String dateString3 = dateString1;
|
||||
// for (int i = 0; i < days; i++) {
|
||||
//// if (i == 28) {
|
||||
//// break;
|
||||
//// }
|
||||
// String dayReport = receiveData.substring((128 + i*10), (128 + (i+1)*10));
|
||||
// dayReport = changePosition(dayReport);
|
||||
// dayReport = hex2Binary(dayReport);
|
||||
// dayReport = Integer.valueOf(dayReport,2).toString();
|
||||
// Double dayflow = Double.parseDouble(dayReport)/10;
|
||||
//
|
||||
// // 前一天的水表读数
|
||||
//// String lastDayReport = receiveData.substring((128 + (i+1)*10), endIndex);
|
||||
//
|
||||
//// System.out.println("第 " + dateString1 + " 日的数据————" + dayflow + " L");
|
||||
//
|
||||
// //减一天时间
|
||||
// try {
|
||||
// long dif = sdf1.parse(dateString3).getTime()-86400*1000; // 减一天
|
||||
// Date date2 = new Date();
|
||||
// date2.setTime(dif);
|
||||
// dateString3 = sdf1.format(date2);
|
||||
//// System.out.println("减少一天之后: " + sdf1.format(date2));
|
||||
// } catch (Exception e) {
|
||||
// // TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// waterDayBean.setWater_id(WaterID);
|
||||
// waterDayBean.setCurrentFlow(dayflow);
|
||||
// waterDayBean.setGrade(0);
|
||||
// waterDayBean.setDate(dateString3);
|
||||
//
|
||||
// String a3 = waterDayMapper.checkCalc(waterDayBean);
|
||||
// if (a3 == null) {
|
||||
// // 执行存储过程,计算用量
|
||||
// waterDayMapper.exeProcedure(waterDayBean);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 更新当天的计算值
|
||||
// waterDayBean.setWater_id(WaterID);
|
||||
// waterDayBean.setCurrentFlow(flow);
|
||||
// waterDayBean.setGrade(0);
|
||||
// waterDayBean.setCur_date(dateString1);
|
||||
// waterDayMapper.exeProcedure(waterDayBean);
|
||||
//
|
||||
// // 更新地区
|
||||
// waterDayMapper.execPro_Cheack_Areas(WaterID);
|
||||
|
||||
System.out.println("解析成功"); |
||||
return return_result; |
||||
} |
||||
|
||||
// 无磁水表解析报文
|
||||
public String analysisFastJson1(String receiveData) throws Exception { |
||||
|
||||
// SqlSession session = SQLDataSourceConfig.openSession();
|
||||
String return_result = "success"; |
||||
|
||||
// 水表ID
|
||||
String WaterID = receiveData.substring(14, 24); |
||||
WaterID = changePosition(WaterID); |
||||
// System.out.println("水表ID——————" + WaterID);
|
||||
|
||||
// 厂商ID
|
||||
String manufactureID = receiveData.substring(24, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
// System.out.println("厂商ID——————" + manufactureID);
|
||||
|
||||
// 增加水表号为12位数 update by ljf on 2019-08-27
|
||||
String is_status = manufactureID.substring(2, 4); |
||||
System.out.println(is_status); |
||||
if (is_status.equals("06")) { |
||||
WaterID = receiveData.substring(14, 24); |
||||
WaterID = changePosition(WaterID); |
||||
System.out.println("水表ID——————" + WaterID); |
||||
water.setWt_num(WaterID); |
||||
|
||||
manufactureID = receiveData.substring(24, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
System.out.println("厂商ID——————" + manufactureID); |
||||
water.setManufacture_id(manufactureID); |
||||
} else { |
||||
WaterID = receiveData.substring(14, 26); |
||||
WaterID = changePosition(WaterID); |
||||
System.out.println("水表ID——————" + WaterID); |
||||
water.setWt_num(WaterID); |
||||
|
||||
manufactureID = receiveData.substring(26, 28); |
||||
manufactureID = changePosition(manufactureID); |
||||
System.out.println("厂商ID——————" + manufactureID); |
||||
water.setManufacture_id(manufactureID); |
||||
} |
||||
|
||||
// 时间
|
||||
String dateString = receiveData.substring(28, 42); |
||||
dateString = dateString.substring(0, 4) + "-" + dateString.substring(4, 6) + "-" + dateString.substring(6, 8) |
||||
+ " " + dateString.substring(8, 10) + ":" + dateString.substring(10, 12) + ":" |
||||
+ dateString.substring(12, 14); |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
||||
Date date = sdf.parse(dateString); |
||||
dateString = sdf.format(date); |
||||
water.setCur_date(dateString); |
||||
|
||||
// 按日
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
||||
Date date1 = sdf1.parse(dateString); |
||||
String dateString1 = sdf1.format(date1); |
||||
|
||||
// 加一天是上传当前累计流量时间
|
||||
// 按小时
|
||||
// Calendar c = Calendar.getInstance();
|
||||
// c.setTime(sdf.parse(dateString));
|
||||
// c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天
|
||||
// Date tomorrow = c.getTime();
|
||||
// String upDate = sdf.format(tomorrow);
|
||||
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH");
|
||||
// Date date1 = sdf1.parse(upDate);
|
||||
// String dateString1 = sdf1.format(date1);
|
||||
|
||||
// update by ljf on 2020-01-03上线帧指令,判断指令是否会有发生变化
|
||||
String onlineStatus = receiveData.substring(42,44); |
||||
onlineStatus = hex2Binary(onlineStatus); |
||||
System.out.println("上线帧指令-------"+onlineStatus); |
||||
String onlineType = onlineStatus.substring(7,8); |
||||
System.out.println("上线类型---------"+(onlineType.equals("1")?"一天一次":"其他")); |
||||
String moduleType = onlineStatus.substring(4,7); |
||||
System.out.println("模组类型---------"+moduleType); |
||||
String upTem = onlineStatus.substring(3,4); |
||||
System.out.println("是否上报PCI和内部温度---------"+(upTem.equals("1")?"上传":"不上传")); |
||||
String upImei = onlineStatus.substring(2,3); |
||||
System.out.println("是否上报IMEI号---------"+(upImei.equals("1")?"上传":"不上传")); |
||||
String upPre = onlineStatus.substring(1,2); |
||||
System.out.println("是否上报压力值---------"+(upPre.equals("1")?"上传":"不上传")); |
||||
String upOnlineStatus2 = onlineStatus.substring(0,1); |
||||
System.out.println("是否存在上线帧指示2---------"+(upOnlineStatus2.equals("1")?"上传":"不上传")); |
||||
|
||||
// 电池电压
|
||||
String Battery = receiveData.substring(44, 48); |
||||
Battery = changePosition(Battery); |
||||
Battery = hex2Binary(Battery); |
||||
Battery = Integer.valueOf(Battery, 2).toString(); |
||||
double voltage = Double.parseDouble(Battery) / 100; |
||||
// 2019-12-06 update by ljf
|
||||
water.setVoltage(voltage); |
||||
System.out.println("电池电压————" + voltage + " V"); |
||||
|
||||
// 累计上线成功次数
|
||||
String onlineSum = receiveData.substring(48, 52); |
||||
onlineSum = changePosition(onlineSum); |
||||
onlineSum = hex2Binary(onlineSum); |
||||
onlineSum = Integer.valueOf(onlineSum, 2).toString(); |
||||
// System.out.println("累计上线成功次数——" + onlineSum);
|
||||
|
||||
// 累计上线失败次数
|
||||
String failedSum = receiveData.substring(52, 56); |
||||
failedSum = changePosition(failedSum); |
||||
failedSum = hex2Binary(failedSum); |
||||
failedSum = Integer.valueOf(failedSum, 2).toString(); |
||||
// System.out.println("累计上线失败次数——" + failedSum);
|
||||
|
||||
// 状态字
|
||||
String stateStr = receiveData.substring(56, 64); |
||||
// System.out.println("状态字————————" + stateStr);
|
||||
// update by ljf on 2019-12-24
|
||||
// 状态字
|
||||
System.out.println("状态字————————" + stateStr); |
||||
System.out.println("状态字1--------------------" + hex2Binary(stateStr.substring(0, 2))); |
||||
System.out.println("状态字1.0:逆流标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(7, 8).equalsIgnoreCase("0") ? "正常" : "逆流")); |
||||
System.out.println("状态字1.1:按键异常标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(6, 7).equalsIgnoreCase("0") ? "正常" : "故障")); |
||||
System.out.println("状态字1.3:存储故障标志 " |
||||
+ (hex2Binary(stateStr.substring(0, 2)).substring(5, 6).equalsIgnoreCase("0") ? "正常" : "故障")); |
||||
System.out.println("状态字2--------------------" + hex2Binary(stateStr.substring(2, 4))); |
||||
System.out.println("状态字2.7:阀门状态 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(0, 1).equalsIgnoreCase("0") ? "开阀" : "关阀")); |
||||
System.out.println("状态字2.6:阀门异常 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(1, 2).equalsIgnoreCase("0") ? "正常" : "异常")); |
||||
System.out.println("状态字2.5:流量通讯异常标志 " |
||||
+ (hex2Binary(stateStr.substring(2, 4)).substring(2, 3).equalsIgnoreCase("0") ? "正常" : "异常")); |
||||
System.out.println("状态字3--------------------" + hex2Binary(stateStr.substring(4, 6))); |
||||
System.out.println("状态字3.4:应急按键标志 " |
||||
+ (hex2Binary(stateStr.substring(4, 6)).substring(3, 4).equalsIgnoreCase("0") ? "正常" : "已关阀三天")); |
||||
System.out.println("状态字4-------" + hex2Binary(stateStr.substring(6, 8))); |
||||
|
||||
water.setContra_flow(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(7, 8))); |
||||
water.setPush_button(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(6, 7))); |
||||
water.setStore(Integer.parseInt(hex2Binary(stateStr.substring(0, 2)).substring(5, 6))); |
||||
water.setValve_status(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(0, 1))); |
||||
water.setValve_unusual(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(1, 2))); |
||||
water.setCommunication_status(Integer.parseInt(hex2Binary(stateStr.substring(2, 4)).substring(2, 3))); |
||||
water.setSos_key(Integer.parseInt(hex2Binary(stateStr.substring(4, 6)).substring(3, 4))); |
||||
|
||||
// 软件版本
|
||||
String SofewareStr = receiveData.substring(82, 86); |
||||
SofewareStr = changePosition(SofewareStr); |
||||
SofewareStr = hex2Binary(SofewareStr); |
||||
SofewareStr = Integer.valueOf(SofewareStr, 2).toString(); // 主版本
|
||||
String SofewareStr1 = receiveData.substring(86, 88); |
||||
SofewareStr1 = hex2Binary(SofewareStr1); |
||||
SofewareStr1 = Integer.valueOf(SofewareStr1, 2).toString(); // 子版本
|
||||
// System.out.println("软件主版本——" + SofewareStr + ",软件子版本——" + SofewareStr1);
|
||||
|
||||
// IMSI 号
|
||||
String IMSIStr = receiveData.substring(88, 104); |
||||
water.setIMSI(IMSIStr); |
||||
|
||||
//添加判断是否上传了IMEI号 update by ljf on 2020-01-03
|
||||
int j = 0; |
||||
// 判断是否有IMEI号
|
||||
if(upImei.equals("1")) { |
||||
String IMEI = receiveData.substring(104, 120); |
||||
System.out.println("IMEI号——————" + IMEI); |
||||
j = 16; |
||||
} |
||||
|
||||
// 当前累计流量
|
||||
String totalFlow = receiveData.substring(104+j, 114+j); |
||||
totalFlow = changePosition(totalFlow); |
||||
System.out.println(totalFlow); |
||||
totalFlow = hex2Binary(totalFlow); |
||||
System.out.println(totalFlow); |
||||
totalFlow = Integer.valueOf(totalFlow, 2).toString(); |
||||
Double flow = Double.parseDouble(totalFlow)/10; |
||||
System.out.println("当前累计流量————" + flow + " L"); |
||||
water.setCur_flow(String.valueOf(flow / 1000)); |
||||
|
||||
// 当前累计逆流量
|
||||
String reverseFlow = receiveData.substring(114+j, 124+j); |
||||
reverseFlow = changePosition(reverseFlow); |
||||
reverseFlow = hex2Binary(reverseFlow); |
||||
reverseFlow = Integer.valueOf(reverseFlow, 2).toString(); |
||||
Double flow1 = Double.parseDouble(reverseFlow) / 10 / 1000; |
||||
System.out.println("当前累计逆流量————" + flow1 + " 立方"); |
||||
water.setReflux_flow(flow1); |
||||
|
||||
String imei = ""; |
||||
water.setIMEI(imei); |
||||
|
||||
// 房间号
|
||||
String house_num = waterService.findHouse(WaterID); |
||||
water.setHouse_num(house_num); |
||||
water.setGrade(0); |
||||
|
||||
int nowSum = waterService.findResult(WaterID); |
||||
|
||||
if (nowSum != 0) { |
||||
System.out.println("已存在水表"); |
||||
int updateResult = waterService.updateWtNow(water); |
||||
if (updateResult == 1) { |
||||
System.out.println("更新水表成功"); |
||||
} else { |
||||
System.out.println("更新水表失败"); |
||||
} |
||||
} else { |
||||
// 插入数据库
|
||||
int result = waterService.insertWtNowAll(water); |
||||
if (result == 1) { |
||||
System.out.println("新增水表成功"); |
||||
} else { |
||||
System.out.println("新增水表失败"); |
||||
} |
||||
} |
||||
System.out.println(water.toString()); |
||||
// Thread.sleep(500);
|
||||
// // update by ljf on 2020-01-03
|
||||
// wtHistoryBean.setWt_num(WaterID);
|
||||
// wtHistoryBean.setHouse_num(house_num);
|
||||
// wtHistoryBean.setIMEI(imei);
|
||||
// wtHistoryBean.setIMSI(IMSIStr);
|
||||
// wtHistoryBean.setCur_flow(String.valueOf(flow / 1000));
|
||||
// wtHistoryBean.setCur_date(dateString1); // 按天
|
||||
//// wtHistoryBean.setCur_date(dateString1+":00:00.000"); // 2018-07-01 00 按小时
|
||||
// wtHistoryBean.setManufacture_id(manufactureID);
|
||||
// wtHistoryBean.setGrade(0);
|
||||
//
|
||||
// System.out.println("水表表号-------------" + WaterID);
|
||||
// System.out.println(wtHistoryBean.toString());
|
||||
//
|
||||
// int a2 = waterHistoryService.checkSame(wtHistoryBean);
|
||||
// if (a2 == 1) {
|
||||
// System.out.println("历史记录已存在");
|
||||
// return_result = "success";
|
||||
// } else {
|
||||
// int a3 = waterHistoryService.insertAll(wtHistoryBean);
|
||||
// if (a3 == 1) {
|
||||
// // System.out.println(wtHistoryBean.toString());
|
||||
// int a4 = waterHistoryService.checkSame(wtHistoryBean);
|
||||
// if (a4 == 1) {
|
||||
// System.out.println("历史记录已存在");
|
||||
// }
|
||||
// } else {
|
||||
// return_result = "fail";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 日结数组
|
||||
String dateReport = receiveData.substring(124+j, 126+j); |
||||
dateReport = hex2Binary(dateReport); |
||||
dateReport = Integer.valueOf(dateReport, 2).toString(); |
||||
// System.out.println("日结数组数————" + dateReport);
|
||||
|
||||
// 日结数据
|
||||
int days = Integer.parseInt(dateReport); |
||||
|
||||
String dateString2 = dateString1; |
||||
SimpleDateFormat sj = new SimpleDateFormat("yyyy-MM-dd"); |
||||
Date d = sj.parse(dateString2); |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(d); |
||||
// calendar.add(Calendar.DATE, -27);
|
||||
// update by ljf on 2019-10-16 解决存储数据库出现超出当前报文的时间
|
||||
calendar.add(Calendar.DATE, -Integer.parseInt(dateReport)); |
||||
dateString2 = sj.format(calendar.getTime()); |
||||
long dif; |
||||
Date date2 = new Date(); |
||||
// System.out.println("29天前:" + sj.format(calendar.getTime()));
|
||||
for (int i = 0; i < days; i++) { |
||||
String dayReport = receiveData.substring((128 + j + i * 10), (128 + j + (i + 1) * 10)); |
||||
dayReport = changePosition(dayReport); |
||||
if (dayReport.equals("ffffffffff")) { |
||||
dif = sdf1.parse(dateString2).getTime() + 86400 * 1000; // 加一天
|
||||
date2.setTime(dif); |
||||
dateString2 = sdf1.format(date2); |
||||
continue; |
||||
} |
||||
dayReport = hex2Binary(dayReport); |
||||
dayReport = Integer.valueOf(dayReport, 2).toString(); |
||||
Double dayflow = Double.parseDouble(dayReport) / 10; |
||||
|
||||
// 加一天时间
|
||||
try { |
||||
dif = sdf1.parse(dateString2).getTime() + 86400 * 1000; // 加一天
|
||||
date2.setTime(dif); |
||||
dateString2 = sdf1.format(date2); |
||||
System.out.println("加一天之后: " + i + "、" + dateString2 + "/" + (dayflow / 1000)); |
||||
System.out.println("第 " + dateString2 + " 日的数据————" + dayflow + " L"); |
||||
wtHistoryBean.setWt_num(WaterID); |
||||
wtHistoryBean.setHouse_num(house_num); |
||||
wtHistoryBean.setIMEI(imei); |
||||
wtHistoryBean.setIMSI(IMSIStr); |
||||
wtHistoryBean.setCur_flow(String.valueOf(dayflow / 1000)); |
||||
wtHistoryBean.setCur_date(dateString2); // 2018-07-01
|
||||
wtHistoryBean.setManufacture_id(manufactureID); |
||||
wtHistoryBean.setGrade(0); |
||||
|
||||
System.out.println("水表表号-------------" + WaterID); |
||||
// int a3 = waterHistoryService.insertAll(wtHistoryBean);
|
||||
// // int a3 = waterHistoryMapper.insertAll(wtHistoryBean);
|
||||
// System.out.println("-----------------" + a3 + "--------------------------");
|
||||
// if (a3 == 1) {
|
||||
// // session.commit();
|
||||
// // System.out.println(wtHistoryBean.toString());
|
||||
// // Thread.sleep(5000);
|
||||
// int a2 = waterHistoryService.checkSame(wtHistoryBean);
|
||||
// System.out.println("-----------------" + a2 + "--------------------------");
|
||||
// if (a2 == 1) {
|
||||
// // System.out.println(wtHistoryBean.toString());
|
||||
// System.out.println("插入历史流水表成功");
|
||||
// } else {
|
||||
// return_result = "fail";
|
||||
// }
|
||||
// }
|
||||
int a3 = waterHistoryService.checkSame(wtHistoryBean); |
||||
|
||||
// int a3 = waterHistoryMapper.insertAll(wtHistoryBean);
|
||||
System.out.println("-----------------" + a3 + "--------------------------"); |
||||
if (a3 == 1) { |
||||
System.out.println("-----------------已存在历史记录--------------------------"); |
||||
// session.commit();
|
||||
// System.out.println(wtHistoryBean.toString());
|
||||
// Thread.sleep(5000);
|
||||
} else { |
||||
int a4 = waterHistoryService.insertAll(wtHistoryBean); |
||||
if (a4 == 1) { |
||||
int a21 = waterHistoryService.checkSame(wtHistoryBean); |
||||
System.out.println("-----------------" + a21 + "--------------------------"); |
||||
if (a21 == 1) { |
||||
// System.out.println(wtHistoryBean.toString());
|
||||
System.out.println("插入历史流水表成功"); |
||||
} else { |
||||
return_result = "fail"; |
||||
} |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
System.out.println("解析成功"); |
||||
System.out.println("返回值"+return_result); |
||||
return return_result; |
||||
} |
||||
|
||||
// 转换位置
|
||||
private static String changePosition(String changeStr) { |
||||
StringBuffer s1 = new StringBuffer(); |
||||
for (int i = changeStr.length(); i >= 2; i = i - 2) { |
||||
s1 = s1.append(changeStr.substring(i - 2, i)); |
||||
} |
||||
return s1.toString(); |
||||
} |
||||
|
||||
// 16进制转换成二进制
|
||||
private static String hex2Binary(String string) { |
||||
// TODO Auto-generated method stub
|
||||
String s = ""; |
||||
for (int i = 0; i < string.length(); i++) { |
||||
s += char2Binary(string.charAt(i)); |
||||
} |
||||
return s; |
||||
} |
||||
|
||||
private static String char2Binary(char charAt) { |
||||
// TODO Auto-generated method stub
|
||||
switch (charAt) { |
||||
case '0': |
||||
return "0000"; |
||||
case '1': |
||||
return "0001"; |
||||
case '2': |
||||
return "0010"; |
||||
case '3': |
||||
return "0011"; |
||||
case '4': |
||||
return "0100"; |
||||
case '5': |
||||
return "0101"; |
||||
case '6': |
||||
return "0110"; |
||||
case '7': |
||||
return "0111"; |
||||
case '8': |
||||
return "1000"; |
||||
case '9': |
||||
return "1001"; |
||||
case 'a': |
||||
return "1010"; |
||||
case 'b': |
||||
return "1011"; |
||||
case 'c': |
||||
return "1100"; |
||||
case 'd': |
||||
return "1101"; |
||||
case 'e': |
||||
return "1110"; |
||||
case 'f': |
||||
return "1111"; |
||||
case 'A': |
||||
return "1010"; |
||||
case 'B': |
||||
return "1011"; |
||||
case 'C': |
||||
return "1100"; |
||||
case 'D': |
||||
return "1101"; |
||||
case 'E': |
||||
return "1110"; |
||||
case 'F': |
||||
return "1111"; |
||||
|
||||
} |
||||
return null; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,198 @@
|
||||
/* |
||||
* File Name: com.huawei.utils.Constant.java |
||||
* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
package com.mh.garrison.mhutils; |
||||
|
||||
|
||||
public class Constant { |
||||
|
||||
//please replace the IP and Port, when you use the demo.
|
||||
public static final String BASE_URL = "https://device.api.ct10649.com:8743"; |
||||
//
|
||||
// //please replace the appId and secret, when you use the demo.
|
||||
// public static final String APPID = "bKt6QbQBou8L9fvlILMzNPkMPnoa";
|
||||
// public static final String SECRET = "MIN_w5uAphyo6S1rOEfsswwNu8Ma";
|
||||
// public static final String BASE_URL = "https://180.101.147.89:8743";
|
||||
|
||||
//please replace the appId and secret, when you use the demo.
|
||||
// 测试平台测试app应用
|
||||
// public static final String APPID = "3q0WU53HTdRdAF25CcHH56JItK8a";
|
||||
// public static final String SECRET = "KAMFe5LhF6qAG7u5IWyowL0Clssa";
|
||||
|
||||
// 正式平台WaterMeter应用
|
||||
// public static final String APPID = "rqqlzFc4N28B4XQ6FModBl5_hiAa";
|
||||
// public static final String SECRET = "9R7UMMXFkYar0uYJKESgT8S_QhQa";
|
||||
//
|
||||
//警备区电表
|
||||
public static final String APPID = "ohF8udKDcQ0hfO3VFn441L7a5lQa"; |
||||
public static final String SECRET = "UAApfey8u_JfD2X18nvJ28lSQyQa"; |
||||
|
||||
// 警备区水表
|
||||
// public static final String APPID = "259iInhJm7EDOGit_FJ0tKKKdSga";
|
||||
// public static final String SECRET = "JZyWnfHICXncrukvRYhuSzujQJwa";
|
||||
|
||||
// //正式平台测试APP应用
|
||||
// public static final String APPID = "bKt6QbQBou8L9fvlILMzNPkMPnoa";
|
||||
// public static final String SECRET = "J89WSfT7_KQcHJjveJ2WasptE2Ea";
|
||||
|
||||
// 正式应用狮山自来水
|
||||
// public static final String APPID = "zUc2S0RXYjwVAVMKQ5DmI_Ytx5Ya";
|
||||
// public static final String SECRET = "OJ2UwZw3VGWxEYMIbg1K3SPuO3wa";
|
||||
|
||||
//星海大学城APP应用
|
||||
// public static final String APPID = "PP3BawdAEHWFkYavAINEPEaG7fca";
|
||||
// public static final String SECRET = "SPsIfz0CPIQ8cGQYIfjwBSF9DZIa";
|
||||
// MHMETER
|
||||
// public static final String APPID = "zqMXFzwKaJY75T0H6kG7ibKc4Ika";
|
||||
// public static final String SECRET = "XQJstspwfTlPwrF7vFQgQrBjdS8a";
|
||||
|
||||
/* |
||||
*IP and port of callback url. |
||||
*please replace the IP and Port of your Application deployment environment address, when you use the demo. |
||||
*/ |
||||
// public static final String CALLBACK_BASE_URL = "http://120.25.220.177:8686";
|
||||
|
||||
//警备区电表 端口号10000 水表:10001
|
||||
public static final String CALLBACK_BASE_URL = "http://134.175.248.88:8091"; |
||||
|
||||
// //测试项目地址
|
||||
// 测试项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://xiaoer.free.idcfengye.com";
|
||||
|
||||
//狮山自来水项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://134.175.248.88:8083";
|
||||
|
||||
//星海大学城项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://134.175.248.88:10002";
|
||||
|
||||
/* |
||||
* complete callback url: |
||||
* please replace uri, when you use the demo. |
||||
*/ |
||||
public static final String DEVICE_ADDED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/addDevice"; |
||||
public static final String DEVICE_INFO_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceInfo"; |
||||
public static final String DEVICE_DATA_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceData"; |
||||
public static final String DEVICE_DELETED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/deletedDevice"; |
||||
public static final String MESSAGE_CONFIRM_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/commandConfirmData"; |
||||
public static final String SERVICE_INFO_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateServiceInfo"; |
||||
public static final String COMMAND_RSP_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/commandRspData"; |
||||
public static final String DEVICE_EVENT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/DeviceEvent"; |
||||
public static final String RULE_EVENT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/RulEevent"; |
||||
public static final String DEVICE_DATAS_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceDatas"; |
||||
|
||||
|
||||
/* |
||||
* Specifies the callback URL for the command execution result notification. |
||||
* For details about the execution result notification definition. |
||||
* |
||||
* please replace uri, when you use the demo. |
||||
*/ |
||||
public static final String REPORT_CMD_EXEC_RESULT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/reportCmdExecResult"; |
||||
|
||||
|
||||
//Paths of certificates.
|
||||
public static String SELFCERTPATH = "/src/main/resources/cert/outgoing.CertwithKey.pkcs12"; |
||||
public static String TRUSTCAPATH = "/src/main/resources/cert/ca.jks"; |
||||
|
||||
//Password of certificates.
|
||||
public static String SELFCERTPWD = "IoM@1234"; |
||||
public static String TRUSTCAPWD = "Huawei@123"; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*************************** The following constants do not need to be modified *********************************//
|
||||
|
||||
/* |
||||
* request header |
||||
* 1. HEADER_APP_KEY |
||||
* 2. HEADER_APP_AUTH |
||||
*/ |
||||
public static final String HEADER_APP_KEY = "app_key"; |
||||
public static final String HEADER_APP_AUTH = "Authorization"; |
||||
|
||||
/* |
||||
* Application Access Security: |
||||
* 1. APP_AUTH |
||||
* 2. REFRESH_TOKEN |
||||
*/ |
||||
public static final String APP_AUTH = BASE_URL + "/iocm/app/sec/v1.1.0/login"; |
||||
public static final String REFRESH_TOKEN = BASE_URL + "/iocm/app/sec/v1.1.0/refreshToken"; |
||||
|
||||
|
||||
/* |
||||
* Device Management: |
||||
* 1. REGISTER_DEVICE |
||||
* 2. MODIFY_DEVICE_INFO |
||||
* 3. QUERY_DEVICE_ACTIVATION_STATUS |
||||
* 4. DELETE_DEVICE |
||||
* 5. DISCOVER_INDIRECT_DEVICE |
||||
* 6. REMOVE_INDIRECT_DEVICE |
||||
*/ |
||||
public static final String REGISTER_DEVICE = BASE_URL + "/iocm/app/reg/v1.1.0/devices"; |
||||
public static final String MODIFY_DEVICE_INFO = BASE_URL + "/iocm/app/dm/v1.1.0/devices"; |
||||
public static final String QUERY_DEVICE_ACTIVATION_STATUS = BASE_URL + "/iocm/app/reg/v1.1.0/devices"; |
||||
public static final String DELETE_DEVICE = BASE_URL + "/iocm/app/dm/v1.1.0/devices"; |
||||
public static final String DISCOVER_INDIRECT_DEVICE = BASE_URL + "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand"; |
||||
public static final String REMOVE_INDIRECT_DEVICE = BASE_URL + "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand"; |
||||
|
||||
/* |
||||
* Data Collection: |
||||
* 1. QUERY_DEVICES |
||||
* 2. QUERY_DEVICE_DATA |
||||
* 3. QUERY_DEVICE_HISTORY_DATA |
||||
* 4. QUERY_DEVICE_CAPABILITIES |
||||
* 5. SUBSCRIBE_NOTIFYCATION |
||||
*/ |
||||
public static final String QUERY_DEVICES = BASE_URL + "/iocm/app/dm/v1.3.0/devices"; |
||||
public static final String QUERY_DEVICE_DATA = BASE_URL + "/iocm/app/dm/v1.3.0/devices"; |
||||
public static final String QUERY_DEVICE_HISTORY_DATA = BASE_URL + "/iocm/app/data/v1.1.0/deviceDataHistory"; |
||||
public static final String QUERY_DEVICE_CAPABILITIES = BASE_URL + "/iocm/app/data/v1.1.0/deviceCapabilities"; |
||||
public static final String SUBSCRIBE_NOTIFYCATION = BASE_URL + "/iocm/app/sub/v1.1.0/subscribe"; |
||||
public static final String SUBSCRIBE_NOTIFYCATIONS = BASE_URL + "/iocm/app/sub/v1.2.0/subscriptions"; |
||||
|
||||
|
||||
/* |
||||
* Signaling Delivery: |
||||
* 1. POST_ASYN_CMD |
||||
* 2. QUERY_DEVICE_CMD |
||||
* 3. UPDATE_ASYN_COMMAND |
||||
* 4. CREATE_DEVICECMD_CANCEL_TASK |
||||
* 5. QUERY_DEVICECMD_CANCEL_TASK |
||||
* |
||||
*/ |
||||
public static final String POST_ASYN_CMD = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands"; |
||||
public static final String QUERY_DEVICE_CMD = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands"; |
||||
public static final String UPDATE_ASYN_COMMAND = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands/%s"; |
||||
public static final String CREATE_DEVICECMD_CANCEL_TASK = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks"; |
||||
public static final String QUERY_DEVICECMD_CANCEL_TASK = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks"; |
||||
|
||||
|
||||
/* |
||||
* notify Type |
||||
* serviceInfoChanged|deviceInfoChanged|LocationChanged|deviceDataChanged|deviceDatasChanged |
||||
* deviceAdded|deviceDeleted|messageConfirm|commandRsp|deviceEvent|ruleEvent |
||||
*/ |
||||
public static final String DEVICE_ADDED = "deviceAdded"; |
||||
public static final String DEVICE_INFO_CHANGED = "deviceInfoChanged"; |
||||
public static final String DEVICE_DATA_CHANGED = "deviceDataChanged"; |
||||
public static final String DEVICE_DELETED = "deviceDeleted"; |
||||
public static final String MESSAGE_CONFIRM = "messageConfirm"; |
||||
public static final String SERVICE_INFO_CHANGED = "serviceInfoChanged"; |
||||
public static final String COMMAND_RSP = "commandRsp"; |
||||
public static final String DEVICE_EVENT = "deviceEvent"; |
||||
public static final String RULE_EVENT = "ruleEvent"; |
||||
public static final String DEVICE_DATAS_CHANGED = "deviceDatasChanged"; |
||||
|
||||
} |
@ -0,0 +1,198 @@
|
||||
/* |
||||
* File Name: com.huawei.utils.Constant.java |
||||
* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
package com.mh.garrison.mhutils; |
||||
|
||||
|
||||
public class ConstantWater { |
||||
|
||||
//please replace the IP and Port, when you use the demo.
|
||||
public static final String BASE_URL = "https://device.api.ct10649.com:8743"; |
||||
//
|
||||
// //please replace the appId and secret, when you use the demo.
|
||||
// public static final String APPID = "bKt6QbQBou8L9fvlILMzNPkMPnoa";
|
||||
// public static final String SECRET = "MIN_w5uAphyo6S1rOEfsswwNu8Ma";
|
||||
// public static final String BASE_URL = "https://180.101.147.89:8743";
|
||||
|
||||
//please replace the appId and secret, when you use the demo.
|
||||
// 测试平台测试app应用
|
||||
// public static final String APPID = "3q0WU53HTdRdAF25CcHH56JItK8a";
|
||||
// public static final String SECRET = "KAMFe5LhF6qAG7u5IWyowL0Clssa";
|
||||
|
||||
// 正式平台WaterMeter应用
|
||||
// public static final String APPID = "rqqlzFc4N28B4XQ6FModBl5_hiAa";
|
||||
// public static final String SECRET = "9R7UMMXFkYar0uYJKESgT8S_QhQa";
|
||||
//
|
||||
//警备区电表
|
||||
// public static final String APPID = "ohF8udKDcQ0hfO3VFn441L7a5lQa";
|
||||
// public static final String SECRET = "UAApfey8u_JfD2X18nvJ28lSQyQa";
|
||||
|
||||
// 警备区水表
|
||||
public static final String APPID = "259iInhJm7EDOGit_FJ0tKKKdSga"; |
||||
public static final String SECRET = "JZyWnfHICXncrukvRYhuSzujQJwa"; |
||||
|
||||
// //正式平台测试APP应用
|
||||
// public static final String APPID = "bKt6QbQBou8L9fvlILMzNPkMPnoa";
|
||||
// public static final String SECRET = "J89WSfT7_KQcHJjveJ2WasptE2Ea";
|
||||
|
||||
// 正式应用狮山自来水
|
||||
// public static final String APPID = "zUc2S0RXYjwVAVMKQ5DmI_Ytx5Ya";
|
||||
// public static final String SECRET = "OJ2UwZw3VGWxEYMIbg1K3SPuO3wa";
|
||||
|
||||
//星海大学城APP应用
|
||||
// public static final String APPID = "PP3BawdAEHWFkYavAINEPEaG7fca";
|
||||
// public static final String SECRET = "SPsIfz0CPIQ8cGQYIfjwBSF9DZIa";
|
||||
// MHMETER
|
||||
// public static final String APPID = "zqMXFzwKaJY75T0H6kG7ibKc4Ika";
|
||||
// public static final String SECRET = "XQJstspwfTlPwrF7vFQgQrBjdS8a";
|
||||
|
||||
/* |
||||
*IP and port of callback url. |
||||
*please replace the IP and Port of your Application deployment environment address, when you use the demo. |
||||
*/ |
||||
// public static final String CALLBACK_BASE_URL = "http://120.25.220.177:8686";
|
||||
|
||||
//警备区电表 端口号10000 水表:10001
|
||||
public static final String CALLBACK_BASE_URL = "http://134.175.248.88:8091"; |
||||
|
||||
// //测试项目地址
|
||||
// 测试项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://xiaoer.free.idcfengye.com";
|
||||
|
||||
//狮山自来水项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://134.175.248.88:8083";
|
||||
|
||||
//星海大学城项目地址
|
||||
// public static final String CALLBACK_BASE_URL = "http://134.175.248.88:10002";
|
||||
|
||||
/* |
||||
* complete callback url: |
||||
* please replace uri, when you use the demo. |
||||
*/ |
||||
public static final String DEVICE_ADDED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/addDevice"; |
||||
public static final String DEVICE_INFO_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceInfo"; |
||||
public static final String DEVICE_DATA_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceData"; |
||||
public static final String DEVICE_DELETED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/deletedDevice"; |
||||
public static final String MESSAGE_CONFIRM_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/commandConfirmData"; |
||||
public static final String SERVICE_INFO_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateServiceInfo"; |
||||
public static final String COMMAND_RSP_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/commandRspData"; |
||||
public static final String DEVICE_EVENT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/DeviceEvent"; |
||||
public static final String RULE_EVENT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/RulEevent"; |
||||
public static final String DEVICE_DATAS_CHANGED_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/updateDeviceDatas"; |
||||
|
||||
|
||||
/* |
||||
* Specifies the callback URL for the command execution result notification. |
||||
* For details about the execution result notification definition. |
||||
* |
||||
* please replace uri, when you use the demo. |
||||
*/ |
||||
public static final String REPORT_CMD_EXEC_RESULT_CALLBACK_URL = CALLBACK_BASE_URL + "/na/iocm/devNotify/v1.1.0/reportCmdExecResult"; |
||||
|
||||
|
||||
//Paths of certificates.
|
||||
public static String SELFCERTPATH = "/src/main/resources/cert/outgoing.CertwithKey.pkcs12"; |
||||
public static String TRUSTCAPATH = "/src/main/resources/cert/ca.jks"; |
||||
|
||||
//Password of certificates.
|
||||
public static String SELFCERTPWD = "IoM@1234"; |
||||
public static String TRUSTCAPWD = "Huawei@123"; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*************************** The following constants do not need to be modified *********************************//
|
||||
|
||||
/* |
||||
* request header |
||||
* 1. HEADER_APP_KEY |
||||
* 2. HEADER_APP_AUTH |
||||
*/ |
||||
public static final String HEADER_APP_KEY = "app_key"; |
||||
public static final String HEADER_APP_AUTH = "Authorization"; |
||||
|
||||
/* |
||||
* Application Access Security: |
||||
* 1. APP_AUTH |
||||
* 2. REFRESH_TOKEN |
||||
*/ |
||||
public static final String APP_AUTH = BASE_URL + "/iocm/app/sec/v1.1.0/login"; |
||||
public static final String REFRESH_TOKEN = BASE_URL + "/iocm/app/sec/v1.1.0/refreshToken"; |
||||
|
||||
|
||||
/* |
||||
* Device Management: |
||||
* 1. REGISTER_DEVICE |
||||
* 2. MODIFY_DEVICE_INFO |
||||
* 3. QUERY_DEVICE_ACTIVATION_STATUS |
||||
* 4. DELETE_DEVICE |
||||
* 5. DISCOVER_INDIRECT_DEVICE |
||||
* 6. REMOVE_INDIRECT_DEVICE |
||||
*/ |
||||
public static final String REGISTER_DEVICE = BASE_URL + "/iocm/app/reg/v1.1.0/devices"; |
||||
public static final String MODIFY_DEVICE_INFO = BASE_URL + "/iocm/app/dm/v1.1.0/devices"; |
||||
public static final String QUERY_DEVICE_ACTIVATION_STATUS = BASE_URL + "/iocm/app/reg/v1.1.0/devices"; |
||||
public static final String DELETE_DEVICE = BASE_URL + "/iocm/app/dm/v1.1.0/devices"; |
||||
public static final String DISCOVER_INDIRECT_DEVICE = BASE_URL + "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand"; |
||||
public static final String REMOVE_INDIRECT_DEVICE = BASE_URL + "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand"; |
||||
|
||||
/* |
||||
* Data Collection: |
||||
* 1. QUERY_DEVICES |
||||
* 2. QUERY_DEVICE_DATA |
||||
* 3. QUERY_DEVICE_HISTORY_DATA |
||||
* 4. QUERY_DEVICE_CAPABILITIES |
||||
* 5. SUBSCRIBE_NOTIFYCATION |
||||
*/ |
||||
public static final String QUERY_DEVICES = BASE_URL + "/iocm/app/dm/v1.3.0/devices"; |
||||
public static final String QUERY_DEVICE_DATA = BASE_URL + "/iocm/app/dm/v1.3.0/devices"; |
||||
public static final String QUERY_DEVICE_HISTORY_DATA = BASE_URL + "/iocm/app/data/v1.1.0/deviceDataHistory"; |
||||
public static final String QUERY_DEVICE_CAPABILITIES = BASE_URL + "/iocm/app/data/v1.1.0/deviceCapabilities"; |
||||
public static final String SUBSCRIBE_NOTIFYCATION = BASE_URL + "/iocm/app/sub/v1.1.0/subscribe"; |
||||
public static final String SUBSCRIBE_NOTIFYCATIONS = BASE_URL + "/iocm/app/sub/v1.2.0/subscriptions"; |
||||
|
||||
|
||||
/* |
||||
* Signaling Delivery: |
||||
* 1. POST_ASYN_CMD |
||||
* 2. QUERY_DEVICE_CMD |
||||
* 3. UPDATE_ASYN_COMMAND |
||||
* 4. CREATE_DEVICECMD_CANCEL_TASK |
||||
* 5. QUERY_DEVICECMD_CANCEL_TASK |
||||
* |
||||
*/ |
||||
public static final String POST_ASYN_CMD = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands"; |
||||
public static final String QUERY_DEVICE_CMD = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands"; |
||||
public static final String UPDATE_ASYN_COMMAND = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommands/%s"; |
||||
public static final String CREATE_DEVICECMD_CANCEL_TASK = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks"; |
||||
public static final String QUERY_DEVICECMD_CANCEL_TASK = BASE_URL + "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks"; |
||||
|
||||
|
||||
/* |
||||
* notify Type |
||||
* serviceInfoChanged|deviceInfoChanged|LocationChanged|deviceDataChanged|deviceDatasChanged |
||||
* deviceAdded|deviceDeleted|messageConfirm|commandRsp|deviceEvent|ruleEvent |
||||
*/ |
||||
public static final String DEVICE_ADDED = "deviceAdded"; |
||||
public static final String DEVICE_INFO_CHANGED = "deviceInfoChanged"; |
||||
public static final String DEVICE_DATA_CHANGED = "deviceDataChanged"; |
||||
public static final String DEVICE_DELETED = "deviceDeleted"; |
||||
public static final String MESSAGE_CONFIRM = "messageConfirm"; |
||||
public static final String SERVICE_INFO_CHANGED = "serviceInfoChanged"; |
||||
public static final String COMMAND_RSP = "commandRsp"; |
||||
public static final String DEVICE_EVENT = "deviceEvent"; |
||||
public static final String RULE_EVENT = "ruleEvent"; |
||||
public static final String DEVICE_DATAS_CHANGED = "deviceDatasChanged"; |
||||
|
||||
} |
@ -0,0 +1,259 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.mh.garrison.constant.Constants; |
||||
import com.mh.garrison.entity.*; |
||||
|
||||
public class FastJson { |
||||
|
||||
// 添加之后能够对mapper调用
|
||||
// private ApplicationContext applicationContext =
|
||||
// SpringUtils.getApplicationContext();
|
||||
// private MeterNowMapper meterNowMapper =
|
||||
// applicationContext.getBean(MeterNowMapper.class);
|
||||
|
||||
public String analysisFastJson(String receiveData) { |
||||
|
||||
DeviceMessageBean deviceMessageBean = new DeviceMessageBean(); |
||||
ServiceBean serviceBean = new ServiceBean(); |
||||
WaterDataBean dataBean = new WaterDataBean(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(receiveData); |
||||
|
||||
if (receiveData.contains("services")) { |
||||
|
||||
// 解析第一层
|
||||
deviceMessageBean.setNotiFyType(jsonObject.getString("notifyType")); |
||||
deviceMessageBean.setServiceBean(jsonObject.getString("service")); |
||||
deviceMessageBean.setDeviceId(jsonObject.getString("deviceId")); |
||||
deviceMessageBean.setGatewayId(jsonObject.getString("gatewayId")); |
||||
|
||||
// 解析第二层
|
||||
JSONArray array = jsonObject.getJSONArray("services"); |
||||
for (int i = 0; i < array.size(); i++) { |
||||
JSONObject serviceJson = array.getJSONObject(i); |
||||
serviceBean.setServiceId(serviceJson.getString("serviceId")); |
||||
serviceBean.setServiceType(serviceJson.getString("serviceType")); |
||||
serviceBean.setDataBean(serviceJson.getString("data")); |
||||
serviceBean.setEventTime(serviceJson.getString("eventTime")); |
||||
// 解析第三层
|
||||
JSONObject dataJson = serviceJson.getJSONObject("data"); |
||||
dataBean.setMeterId(dataJson.getString("meterId")); |
||||
dataBean.setOnlineType(dataJson.getString("onlineType")); |
||||
dataBean.setOnlineCode(dataJson.getString("onlineCode")); |
||||
} |
||||
|
||||
} else { |
||||
|
||||
// 解析第一层
|
||||
deviceMessageBean.setNotiFyType(jsonObject.getString("notifyType")); |
||||
deviceMessageBean.setServiceBean(jsonObject.getString("service")); |
||||
deviceMessageBean.setDeviceId(jsonObject.getString("deviceId")); |
||||
deviceMessageBean.setGatewayId(jsonObject.getString("gatewayId")); |
||||
|
||||
// 解析第二层
|
||||
JSONObject serviceJson = jsonObject.getJSONObject("service"); |
||||
serviceBean.setServiceId(serviceJson.getString("serviceId")); |
||||
serviceBean.setServiceType(serviceJson.getString("serviceType")); |
||||
serviceBean.setDataBean(serviceJson.getString("data")); |
||||
serviceBean.setEventTime(serviceJson.getString("eventTime")); |
||||
|
||||
// 解析第三层
|
||||
JSONObject dataJson = serviceJson.getJSONObject("data"); |
||||
dataBean.setMeterId(dataJson.getString("meterId")); |
||||
dataBean.setOnlineType(dataJson.getString("onlineType")); |
||||
dataBean.setOnlineCode(dataJson.getString("onlineCode")); |
||||
} |
||||
|
||||
return dataBean.getOnlineCode(); |
||||
} |
||||
|
||||
public String analysisMeterFastJson(String receiveData) { |
||||
|
||||
DeviceMessageBean deviceMessageBean = new DeviceMessageBean(); |
||||
// ServiceBean serviceBean = new ServiceBean();
|
||||
// DataBean dataBean = new DataBean();
|
||||
|
||||
String result = ""; |
||||
|
||||
Map<Integer, Object> map = new HashMap<>(); |
||||
|
||||
MeterUtils meterUtils = new MeterUtils(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(receiveData); |
||||
String deviceId; |
||||
|
||||
// 解析第一层
|
||||
deviceMessageBean.setNotiFyType(jsonObject.getString("notifyType")); |
||||
deviceMessageBean.setServiceBean(jsonObject.getString("services")); |
||||
deviceMessageBean.setDeviceId(jsonObject.getString("deviceId")); |
||||
deviceMessageBean.setGatewayId(jsonObject.getString("gatewayId")); |
||||
|
||||
deviceId = jsonObject.getString("deviceId"); // 设备ID,发送指令的时候需要
|
||||
|
||||
// 解析第二层
|
||||
JSONArray array = jsonObject.getJSONArray("services"); |
||||
for (int i = 0; i < array.size(); i++) { |
||||
JSONObject temp = array.getJSONObject(i); |
||||
String serviceId = temp.getString("serviceId"); |
||||
// String serviceType = temp.getString("serviceType");
|
||||
// String data = temp.getString("data");
|
||||
// String evenTime = temp.getString("eventTime");
|
||||
if (serviceId.equals("MHMeterData")) { |
||||
|
||||
// 插入电表用量上报时间
|
||||
String evenTime1 = temp.getString("eventTime"); |
||||
try { |
||||
evenTime1 = TimeUtils.UTCToCST(evenTime1, "yyyy-MM-dd'T'HH:mm:ss'Z'"); |
||||
} catch (ParseException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
// meterNowBean.setMeter_time(evenTime1);
|
||||
// if (meterNowMapper.checkMeterNow(meterNowBean) != 0) {
|
||||
// meterNowMapper.updateAll(meterNowBean);
|
||||
// } else {
|
||||
// meterNowMapper.insertAll(meterNowBean);
|
||||
// }
|
||||
|
||||
// 解析第三层
|
||||
JSONObject dataJson = temp.getJSONObject("data"); |
||||
String data = dataJson.getString("MHMeterData"); |
||||
map.put(i, data); |
||||
System.out.println("数据————" + data); |
||||
|
||||
// 插入数据进行再次判断 by ljf on 2018-12-08
|
||||
if (data.length() == 24) { |
||||
// 解析发送命令后返回的数据
|
||||
result = meterUtils.analysisSendOrder(data); |
||||
} else if (data.length() == 126) { |
||||
// 解析三相电表数据返回的报文
|
||||
result = meterUtils.analysisThreeMeter(data, evenTime1, deviceId); |
||||
} else { |
||||
// 解析单相电表具体电表数据
|
||||
result = meterUtils.analysisMeter(data, evenTime1, deviceId); |
||||
} |
||||
} |
||||
} |
||||
// dataBean.setMHMeterData(map);
|
||||
// JSONObject serviceJson = jsonObject.getJSONObject("services");
|
||||
// serviceBean.setServiceId(serviceJson.getString("serviceId"));
|
||||
// serviceBean.setServiceType(serviceJson.getString("serviceType"));
|
||||
// serviceBean.setDataBean(serviceJson.getString("data"));
|
||||
// serviceBean.setEventTime(serviceJson.getString("eventTime"));
|
||||
if (result.equals("success")) { |
||||
return "success"; |
||||
} else { |
||||
return "fail"; |
||||
} |
||||
|
||||
// return dataBean.getMHMeterData();
|
||||
} |
||||
|
||||
/** |
||||
* 解析电表数据(永阳)AEP平台带profile文件解析 |
||||
*/ |
||||
public String analysisEleFastJsonByAEPProfile(String receiveData) { |
||||
|
||||
MeterUtils meterUtils = new MeterUtils(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(receiveData); |
||||
//1.解析第一层
|
||||
String productId = jsonObject.getString("productId"); |
||||
String imei = jsonObject.getString("IMEI"); |
||||
String deviceId = jsonObject.getString("deviceId"); |
||||
String protocol = jsonObject.getString("protocol"); |
||||
String messageType = jsonObject.getString("messageType"); |
||||
String payload = jsonObject.getString("payload"); |
||||
|
||||
String assocAssetId = jsonObject.getString("assocAssetId"); |
||||
String tenantId = jsonObject.getString("tenantId"); |
||||
String imsi = jsonObject.getString("IMSI"); |
||||
String serviceId = jsonObject.getString("serviceId"); |
||||
String timestamp = jsonObject.getString("timestamp"); |
||||
if ("Connectivity".equalsIgnoreCase(serviceId)) { |
||||
//设备连接信息,直接结束
|
||||
return Constants.SUCCESS; |
||||
} |
||||
|
||||
//2.解析第二层数据
|
||||
JSONObject payloadJson = JSONObject.parseObject(payload); |
||||
String serviceData = payloadJson.getString("serviceData"); |
||||
|
||||
//3.解析第三层数据
|
||||
JSONObject serviceDataJson = JSONObject.parseObject(serviceData); |
||||
String mhMeterData = serviceDataJson.getString("MHMeterData"); |
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
Date date = new Date(Long.parseLong(timestamp)); |
||||
String evenTime = format.format(date); |
||||
|
||||
String result; |
||||
|
||||
if (mhMeterData == null || mhMeterData.length() == 24 || mhMeterData.length() == 26) { |
||||
//命令回调
|
||||
return meterUtils.analysisSendOrder(mhMeterData); |
||||
} else if (mhMeterData.isEmpty()) { |
||||
//查询的连接状态返回
|
||||
return "success"; |
||||
} else { |
||||
//解析数据
|
||||
result = meterUtils.analysisAEPMeter(mhMeterData, evenTime, deviceId, imei); |
||||
} |
||||
|
||||
if (result.equalsIgnoreCase("success")) { |
||||
return "success"; |
||||
} else { |
||||
return "fail"; |
||||
} |
||||
|
||||
} |
||||
|
||||
// public static void main(String[] args) {
|
||||
// // String jsonData =
|
||||
// // "{\"notifyType\":\"deviceDataChanged\",\"service\":{\"serviceId\":\"WaterMeter\",\"serviceType\":\"WaterMeter\",\"data\":{\"meterId\":\"3606180679020130\",\"onlineType\":\"1100\",\"onlineCode\":\"6800da681100300102790618063620180731143012106b0178026a01d0000000c4ff1201002d00ff7f661b090460111172577161102700000000000000001c001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000102700000010270000001027000000000600021807310000000000000000000000e916\"},\"eventTime\":\"20180801T063016Z\"},\"deviceId\":\"1ea8360f-8d9b-4ef9-b3f5-68b7453a3994\",\"gatewayId\":\"1ea8360f-8d9b-4ef9-b3f5-68b7453a3994\"}";
|
||||
// // String jsonData =
|
||||
// // "{\"notifyType\":\"deviceDatasChanged\",\"services\":[{\"serviceId\":\"Connectivity\",\"serviceType\":\"Connectivity\",\"data\":{\"signalStrength\":0,\"linkQuality\":0,\"cellId\":0},\"eventTime\":\"20180825T064033Z\"},{\"serviceId\":\"MHMeterData\",\"serviceType\":\"MHMeterData\",\"data\":{\"MHMeterData\":\"680002050800006881183232866833334455a77b33333333543c36833333333333333216\"},\"eventTime\":\"20180825T064033Z\"}],\"deviceId\":\"06812a58-48ea-4c2f-b228-e9dc86e8e71e\",\"gatewayId\":\"06812a58-48ea-4c2f-b228-e9dc86e8e71e\"}\r\n";
|
||||
// // FastJson fastJson = new FastJson();
|
||||
// // String string = fastJson.analysisMeterFastJson(jsonData);
|
||||
// // System.out.println(string);
|
||||
//
|
||||
// String string = "689603019000006881333232b87953333656c855c4553a4b333a4b333a4b33c34434366b33b76933346a33453c463c3b3c473cca7c34336f3333333333fe16";
|
||||
// String teString = string.substring(110, 114);
|
||||
// String newData = "";
|
||||
// for (int i = teString.length() / 2; i > 0; i--) {
|
||||
// newData = newData + teString.substring(2 * i - 2, 2 * i);
|
||||
// // System.out.println(newData);
|
||||
// }
|
||||
// String nString = "";
|
||||
// int b = Integer.parseInt("33", 16); // 33值
|
||||
// for (int i = 0; i < newData.length() / 2; i++) {
|
||||
// String cutString = newData.substring(2 * i, 2 * i + 2);
|
||||
// // System.out.println("截取的字符——" + cutString);
|
||||
// int a1 = Integer.parseInt(cutString, 16);
|
||||
// int b1 = a1 - b;
|
||||
// if (b1 < 0) {
|
||||
// System.out.println("数据格式有误");
|
||||
// } else {
|
||||
// b1 = b1 % 256;
|
||||
// String hexString = Integer.toHexString(b1);
|
||||
// if (hexString.length() < 2) {
|
||||
// hexString = "0" + hexString;
|
||||
// // System.out.println(hexString);
|
||||
// nString = nString + hexString;
|
||||
// } else {
|
||||
// nString = nString + hexString;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// System.out.println("定时上传时间 " + Integer.valueOf(nString,16));
|
||||
// }
|
||||
|
||||
} |
@ -0,0 +1,206 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.sql.CallableStatement; |
||||
import java.sql.Connection; |
||||
import java.sql.DriverManager; |
||||
import java.text.ParseException; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.mh.garrison.entity.DeviceInfo; |
||||
import com.mh.garrison.entity.DeviceMessage; |
||||
import com.mh.garrison.entity.DevicesBean; |
||||
|
||||
|
||||
public class FastJsonUtil { |
||||
|
||||
public String analysisFastJson(String receiveData) throws ParseException { |
||||
|
||||
String stateMessage = "fail"; |
||||
|
||||
DevicesBean devicesBean = new DevicesBean(); |
||||
DeviceMessage deviceMessage = new DeviceMessage(); |
||||
DeviceInfo deviceInfo = new DeviceInfo(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(receiveData); |
||||
|
||||
// 解析第一层
|
||||
devicesBean.setTotalCount(jsonObject.getLongValue("totalCount")); |
||||
devicesBean.setPageNo(jsonObject.getLongValue("pageNo")); |
||||
devicesBean.setPageSize(jsonObject.getLongValue("pageSize")); |
||||
devicesBean.setDevices(jsonObject.getString("devices")); |
||||
|
||||
// 解析第二层
|
||||
JSONArray devices = jsonObject.getJSONArray("devices"); |
||||
// System.out.println("--------------设备使用量------------" + devices.size());
|
||||
for (int i = 0; i < devices.size(); i++) { |
||||
|
||||
JSONObject jsonObject2 = devices.getJSONObject(i); |
||||
|
||||
String deviceId = jsonObject2.getString("deviceId"); // 设备ID号
|
||||
deviceMessage.setDeviceId(deviceId); |
||||
|
||||
deviceMessage.setGatewayId(jsonObject2.getString("gatewayId")); |
||||
deviceMessage.setNodeType(jsonObject2.getString("nodeType")); |
||||
String createTime = jsonObject2.getString("createTime"); // 设备注册时间
|
||||
createTime = TimeUtils.UTCToCST(createTime, "yyyy-MM-dd'T'HH:mm:ss'Z'"); |
||||
deviceMessage.setCreateTime(createTime); |
||||
|
||||
String lastModifiedTime = jsonObject2.getString("lastModifiedTime"); // 设备最近连接上来的时间
|
||||
lastModifiedTime = TimeUtils.UTCToCST(lastModifiedTime, "yyyy-MM-dd'T'HH:mm:ss'Z'"); |
||||
|
||||
deviceMessage.setLastModifiedTime(lastModifiedTime); |
||||
|
||||
deviceMessage.setDeviceInfo(jsonObject2.getString("deviceInfo")); |
||||
deviceMessage.setServices(jsonObject2.getString("services")); |
||||
deviceMessage.setConnectionInfo(jsonObject2.getString("connectionInfo")); |
||||
deviceMessage.setDevGroupIds(jsonObject2.getString("devGroupIds")); |
||||
System.out.println("--------------------------第二层-------------------------"); |
||||
System.out.println(deviceMessage.toString()); |
||||
|
||||
// 解析第三层
|
||||
JSONObject jsonObject3 = JSONObject.parseObject(jsonObject2.getString("deviceInfo")); |
||||
|
||||
String IMEI = jsonObject3.getString("nodeId"); // 设备IMEI号
|
||||
deviceInfo.setNodeId(IMEI); |
||||
|
||||
deviceInfo.setName(jsonObject3.getString("name")); |
||||
deviceInfo.setManufactureId(jsonObject3.getString("manufacturerId")); |
||||
deviceInfo.setManufacturerName(jsonObject3.getString("manufacturerName")); |
||||
deviceInfo.setDeviceType(jsonObject3.getString("deviceType")); |
||||
|
||||
String state = jsonObject3.getString("status"); // 设备状态
|
||||
deviceInfo.setStatus(state); |
||||
System.out.println("--------------------------第三层-------------------------"); |
||||
System.out.println(deviceInfo.toString()); |
||||
|
||||
// String address = "jdbc:sqlserver://134.175.248.88:2008;Databasename=NB_SHZLS";
|
||||
// String dbuser = "sa";
|
||||
// String dbpasswd = "mhtech@803";
|
||||
// String database = "NB_SHZLS";
|
||||
|
||||
String address = "jdbc:sqlserver://134.175.248.88:2008;Databasename=yjc_jingbeiqu"; |
||||
String dbuser = "sa"; |
||||
String dbpasswd = "mhtech@803"; |
||||
String database = "yjc_jingbeiqu"; |
||||
|
||||
// String address = "jdbc:sqlserver://193.112.131.36";
|
||||
// String dbuser = "sa";
|
||||
// String dbpasswd = "mhtech@803";
|
||||
// String database = "yjc_jingbeiqu";
|
||||
// String database = "yjc_xinghai_dxc";
|
||||
try { |
||||
// System.out.println("计算值>>>>>>>>>>>>>>>>>>>>>>>>>" + i);
|
||||
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); |
||||
Connection con = DriverManager.getConnection(address, dbuser, dbpasswd); |
||||
con.setCatalog(database); |
||||
CallableStatement proc = con.prepareCall("{call pro_add_state(?,?,?,?,?)}"); |
||||
proc.setString(1, deviceId); |
||||
proc.setString(2, createTime); |
||||
proc.setString(3, lastModifiedTime); |
||||
proc.setString(4, IMEI); |
||||
proc.setString(5, state); |
||||
proc.execute(); |
||||
proc.close(); |
||||
con.close(); |
||||
stateMessage = "success"; |
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
stateMessage = "fail"; |
||||
// String causeStr = e.getCause().getMessage();
|
||||
// System.out.println(">>>>>>>-------------" + causeStr);
|
||||
} |
||||
|
||||
} |
||||
// JSONObject.parseArray(jsonObject.getString("devices"));
|
||||
|
||||
// JSONArray deviceMessageJson = jsonObject.getJSONObject("devices");
|
||||
// serviceBean.setServiceId(deviceMessageJson.getString("serviceId"));
|
||||
// serviceBean.setServiceType(serviceJson.getString("serviceType"));
|
||||
// serviceBean.setDataBean(serviceJson.getString("data"));
|
||||
// serviceBean.setEventTime(serviceJson.getString("eventTime"));
|
||||
//
|
||||
// // 解析第三层
|
||||
// JSONObject dataJson = serviceJson.getJSONObject("data");
|
||||
// dataBean.setMeterId(dataJson.getString("meterId"));
|
||||
// dataBean.setOnlineType(dataJson.getString("onlineType"));
|
||||
// dataBean.setOnlineCode(dataJson.getString("onlineCode"));
|
||||
|
||||
return stateMessage; |
||||
} |
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// String jsonData = "{\r\n" +
|
||||
// " \"totalCount\":1,\r\n" +
|
||||
// " \"pageNo\":0,\r\n" +
|
||||
// " \"pageSize\":10,\r\n" +
|
||||
// " \"devices\":[\r\n" +
|
||||
// " {\r\n" +
|
||||
// " \"deviceId\":\"9e22e475-89a7-4b36-9462-ee61b1000c20\",\r\n" +
|
||||
// " \"gatewayId\":\"9e22e475-89a7-4b36-9462-ee61b1000c20\",\r\n" +
|
||||
// " \"nodeType\":\"GATEWAY\",\r\n" +
|
||||
// " \"createTime\":\"20181013T062538Z\",\r\n" +
|
||||
// " \"lastModifiedTime\":\"20181013T070436Z\",\r\n" +
|
||||
// " \"deviceInfo\":{\r\n" +
|
||||
// " \"nodeId\":\"865352033012310\",\r\n" +
|
||||
// " \"name\":\"865352033012310\",\r\n" +
|
||||
// " \"description\":null,\r\n" +
|
||||
// " \"manufacturerId\":\"MH\",\r\n" +
|
||||
// " \"manufacturerName\":\"MH\",\r\n" +
|
||||
// " \"mac\":null,\r\n" +
|
||||
// " \"location\":\"Shenzhen\",\r\n" +
|
||||
// " \"deviceType\":\"MHMeter\",\r\n" +
|
||||
// " \"model\":\"DDS3666\",\r\n" +
|
||||
// " \"swVersion\":null,\r\n" +
|
||||
// " \"fwVersion\":\"Neul@Hi12RM0-B5@B657R5Lierda1200104,V100R100C10B657SP5,V100R100C10B657SP5@5\",\r\n" +
|
||||
// " \"hwVersion\":null,\r\n" +
|
||||
// " \"protocolType\":\"CoAP\",\r\n" +
|
||||
// " \"bridgeId\":null,\r\n" +
|
||||
// " \"status\":\"ONLINE\",\r\n" +
|
||||
// " \"statusDetail\":\"NONE\",\r\n" +
|
||||
// " \"mute\":\"FALSE\",\r\n" +
|
||||
// " \"supportedSecurity\":null,\r\n" +
|
||||
// " \"isSecurity\":null,\r\n" +
|
||||
// " \"signalStrength\":null,\r\n" +
|
||||
// " \"sigVersion\":null,\r\n" +
|
||||
// " \"serialNumber\":null,\r\n" +
|
||||
// " \"batteryLevel\":null\r\n" +
|
||||
// " },\r\n" +
|
||||
// " \"services\":[\r\n" +
|
||||
// " {\r\n" +
|
||||
// " \"serviceId\":\"Connectivity\",\r\n" +
|
||||
// " \"serviceType\":\"Connectivity\",\r\n" +
|
||||
// " \"data\":{\r\n" +
|
||||
// " \"signalStrength\":0,\r\n" +
|
||||
// " \"linkQuality\":0,\r\n" +
|
||||
// " \"cellId\":0\r\n" +
|
||||
// " },\r\n" +
|
||||
// " \"eventTime\":\"20181013T070436Z\",\r\n" +
|
||||
// " \"serviceInfo\":null\r\n" +
|
||||
// " },\r\n" +
|
||||
// " {\r\n" +
|
||||
// " \"serviceId\":\"MHMeterData\",\r\n" +
|
||||
// " \"serviceType\":\"MHMeterData\",\r\n" +
|
||||
// " \"data\":{\r\n" +
|
||||
// " \"MHMeterData\":\"68000000000000688118323236333333ca5633333333333333433583334b343333336716\"\r\n" +
|
||||
// " },\r\n" +
|
||||
// " \"eventTime\":\"20181013T070436Z\",\r\n" +
|
||||
// " \"serviceInfo\":null\r\n" +
|
||||
// " }\r\n" +
|
||||
// " ],\r\n" +
|
||||
// " \"connectionInfo\":{\r\n" +
|
||||
// " \"cellId\":\"******\"\r\n" +
|
||||
// " },\r\n" +
|
||||
// " \"devGroupIds\":[\r\n" +
|
||||
// "\r\n" +
|
||||
// " ]\r\n" +
|
||||
// " }\r\n" +
|
||||
// " ]\r\n" +
|
||||
// "}";
|
||||
// FastJsonUtil fastJson = new FastJsonUtil();
|
||||
// String string = fastJson.analysisFastJson(jsonData);
|
||||
// System.out.println(string);
|
||||
//
|
||||
// }
|
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
|
||||
/** |
||||
* 查询余额 |
||||
* |
||||
* @author acer |
||||
* |
||||
*/ |
||||
public class GetBalance { |
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException { |
||||
|
||||
String userName = "jbqznjf";// 用户名
|
||||
String password = "dT6pH6rQ1";// 密码
|
||||
MSGClient client = new MSGClient(userName, password); |
||||
|
||||
// 查询余额
|
||||
String result_balance = client.getBalance(); |
||||
|
||||
if (result_balance.startsWith("-")) { |
||||
System.out.print("发送失败!返回值为:" + result_balance + "请查看HTTP返回值对照表"); |
||||
return; |
||||
} |
||||
|
||||
System.out.print("您的余额为 : " + result_balance); |
||||
} |
||||
} |
@ -0,0 +1,360 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.net.URISyntaxException; |
||||
import java.security.KeyStore; |
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
import javax.net.ssl.KeyManagerFactory; |
||||
import javax.net.ssl.SSLContext; |
||||
import javax.net.ssl.TrustManagerFactory; |
||||
|
||||
import org.apache.http.HttpEntity; |
||||
import org.apache.http.HttpResponse; |
||||
import org.apache.http.NameValuePair; |
||||
import org.apache.http.client.HttpClient; |
||||
import org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
import org.apache.http.client.methods.HttpDelete; |
||||
import org.apache.http.client.methods.HttpGet; |
||||
import org.apache.http.client.methods.HttpPost; |
||||
import org.apache.http.client.methods.HttpPut; |
||||
import org.apache.http.client.methods.HttpUriRequest; |
||||
import org.apache.http.client.utils.URIBuilder; |
||||
import org.apache.http.conn.ClientConnectionManager; |
||||
import org.apache.http.conn.scheme.Scheme; |
||||
import org.apache.http.conn.scheme.SchemeRegistry; |
||||
import org.apache.http.conn.ssl.SSLSocketFactory; |
||||
import org.apache.http.entity.ContentType; |
||||
import org.apache.http.entity.StringEntity; |
||||
import org.apache.http.impl.client.DefaultHttpClient; |
||||
import org.apache.http.message.BasicNameValuePair; |
||||
|
||||
|
||||
@SuppressWarnings("deprecation") |
||||
public class HttpsUtil extends DefaultHttpClient { |
||||
public final static String HTTPGET = "GET"; |
||||
|
||||
public final static String HTTPPUT = "PUT"; |
||||
|
||||
public final static String HTTPPOST = "POST"; |
||||
|
||||
public final static String HTTPDELETE = "DELETE"; |
||||
|
||||
public final static String HTTPACCEPT = "Accept"; |
||||
|
||||
public final static String CONTENT_LENGTH = "Content-Length"; |
||||
|
||||
public final static String CHARSET_UTF8 = "UTF-8"; |
||||
|
||||
private static HttpClient httpClient; |
||||
|
||||
/** |
||||
* Two-Way Authentication In the two-way authentication, the client needs: 1 |
||||
* Import your own certificate for server verification; 2 Import the CA |
||||
* certificate of the server, and use the CA certificate to verify the |
||||
* certificate sent by the server; 3 Set the domain name to not verify |
||||
* (Non-commercial IoT platform, no use domain name access.) |
||||
* */ |
||||
public void initSSLConfigForTwoWay() throws Exception { |
||||
// 1 Import your own certificate
|
||||
String demo_base_Path = System.getProperty("user.dir"); |
||||
String selfcertpath = demo_base_Path + Constant.SELFCERTPATH; |
||||
String trustcapath = demo_base_Path + Constant.TRUSTCAPATH; |
||||
|
||||
KeyStore selfCert = KeyStore.getInstance("pkcs12"); |
||||
selfCert.load(new FileInputStream(selfcertpath), |
||||
Constant.SELFCERTPWD.toCharArray()); |
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance("sunx509"); |
||||
kmf.init(selfCert, Constant.SELFCERTPWD.toCharArray()); |
||||
|
||||
// 2 Import the CA certificate of the server,
|
||||
KeyStore caCert = KeyStore.getInstance("jks"); |
||||
caCert.load(new FileInputStream(trustcapath), Constant.TRUSTCAPWD.toCharArray()); |
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance("sunx509"); |
||||
tmf.init(caCert); |
||||
|
||||
SSLContext sc = SSLContext.getInstance("TLS"); |
||||
sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); |
||||
|
||||
// 3 Set the domain name to not verify
|
||||
// (Non-commercial IoT platform, no use domain name access generally.)
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(sc, |
||||
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
||||
|
||||
// If the platform has already applied for a domain name which matches
|
||||
// the domain name in the certificate information, the certificate
|
||||
// domain name check can be enabled (open by default)
|
||||
// SSLSocketFactory ssf = new SSLSocketFactory(sc);
|
||||
|
||||
ClientConnectionManager ccm = this.getConnectionManager(); |
||||
SchemeRegistry sr = ccm.getSchemeRegistry(); |
||||
sr.register(new Scheme("https", 8743, ssf)); |
||||
|
||||
httpClient = new DefaultHttpClient(ccm); |
||||
} |
||||
|
||||
/** |
||||
* One-Way Authentication In the One-way authentication, the client needs: 1 |
||||
* Import the CA certificate of the server, and use the CA certificate to |
||||
* verify the certificate sent by the server; 2 Set the domain name to not |
||||
* verify (Non-commercial IoT platform, no use domain name access.) |
||||
* */ |
||||
/* |
||||
* public void initSSLConfigForOneWay() throws Exception { |
||||
* |
||||
* // 1 Import the CA certificate of the server, KeyStore caCert =
|
||||
* KeyStore.getInstance("jks"); caCert.load(new |
||||
* FileInputStream(TRUSTCAPATH), TRUSTCAPWD.toCharArray()); |
||||
* TrustManagerFactory tmf = TrustManagerFactory.getInstance("sunx509"); |
||||
* tmf.init(caCert); |
||||
* |
||||
* SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, |
||||
* tmf.getTrustManagers(), null); |
||||
* |
||||
* // 2 Set the domain name to not verify // (Non-commercial IoT platform,
|
||||
* no use domain name access generally.) SSLSocketFactory ssf = new |
||||
* SSLSocketFactory(sc, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
||||
* |
||||
* //If the platform has already applied for a domain name which matches the
|
||||
* domain name in the certificate information, the certificate //domain name
|
||||
* check can be enabled (open by default) // SSLSocketFactory ssf = new
|
||||
* SSLSocketFactory(sc); |
||||
* |
||||
* ClientConnectionManager ccm = this.getConnectionManager(); SchemeRegistry |
||||
* sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", 8743, |
||||
* ssf)); |
||||
* |
||||
* httpClient = new DefaultHttpClient(ccm); } |
||||
*/ |
||||
|
||||
public HttpResponse doPostJson(String url, Map<String, String> headerMap, |
||||
String content) { |
||||
HttpPost request = new HttpPost(url); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
request.setEntity(new StringEntity(content, |
||||
ContentType.APPLICATION_JSON)); |
||||
|
||||
return executeHttpRequest(request); |
||||
} |
||||
|
||||
// public StreamClosedHttpResponse doPostMultipartFile(String url, Map<String, String> headerMap,
|
||||
// File file) {
|
||||
// HttpPost request = new HttpPost(url);
|
||||
// addRequestHeader(request, headerMap);
|
||||
//
|
||||
// FileBody fileBody = new FileBody(file);
|
||||
// // Content-Type:multipart/form-data; boundary=----WebKitFormBoundarypJTQXMOZ3dLEzJ4b
|
||||
// HttpEntity reqEntity = (HttpEntity) MultipartEntityBuilder.create().addPart("file", fileBody).build();
|
||||
// request.setEntity(reqEntity);
|
||||
//
|
||||
// return (StreamClosedHttpResponse) executeHttpRequest(request);
|
||||
// }
|
||||
|
||||
public StreamClosedHttpResponse doPostJsonGetStatusLine( |
||||
String url, Map<String, String> headerMap, String content) { |
||||
HttpPost request = new HttpPost(url); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
request.setEntity(new StringEntity(content, |
||||
ContentType.APPLICATION_JSON)); |
||||
|
||||
HttpResponse response = executeHttpRequest(request); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
public StreamClosedHttpResponse doPostJsonGetStatusLine(String url, String content) { |
||||
HttpPost request = new HttpPost(url); |
||||
|
||||
request.setEntity(new StringEntity(content, |
||||
ContentType.APPLICATION_JSON)); |
||||
|
||||
HttpResponse response = executeHttpRequest(request); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
private List<NameValuePair> paramsConverter(Map<String, String> params) { |
||||
List<NameValuePair> nvps = new LinkedList<NameValuePair>(); |
||||
Set<Map.Entry<String, String>> paramsSet = params.entrySet(); |
||||
for (Map.Entry<String, String> paramEntry : paramsSet) { |
||||
nvps.add(new BasicNameValuePair(paramEntry.getKey(), paramEntry |
||||
.getValue())); |
||||
} |
||||
|
||||
return nvps; |
||||
} |
||||
|
||||
|
||||
public StreamClosedHttpResponse doPostFormUrlEncodedGetStatusLine( |
||||
String url, Map<String, String> formParams) throws Exception { |
||||
HttpPost request = new HttpPost(url); |
||||
|
||||
request.setEntity(new UrlEncodedFormEntity(paramsConverter(formParams))); |
||||
|
||||
HttpResponse response = executeHttpRequest(request); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
throw new Exception(); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
public HttpResponse doPutJson(String url, Map<String, String> headerMap, |
||||
String content) { |
||||
HttpPut request = new HttpPut(url); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
request.setEntity(new StringEntity(content, |
||||
ContentType.APPLICATION_JSON)); |
||||
|
||||
return executeHttpRequest(request); |
||||
} |
||||
|
||||
public HttpResponse doPut(String url, Map<String, String> headerMap) { |
||||
HttpPut request = new HttpPut(url); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
return executeHttpRequest(request); |
||||
} |
||||
|
||||
public StreamClosedHttpResponse doPutJsonGetStatusLine(String url, Map<String, String> headerMap, |
||||
String content) { |
||||
HttpResponse response = doPutJson(url, headerMap, content); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
public StreamClosedHttpResponse doPutGetStatusLine(String url, Map<String, String> headerMap) { |
||||
HttpResponse response = doPut(url, headerMap); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
public HttpResponse doGetWithParas(String url, |
||||
Map<String, String> queryParams, Map<String, String> headerMap) |
||||
throws Exception { |
||||
HttpGet request = new HttpGet(); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
URIBuilder builder; |
||||
try { |
||||
builder = new URIBuilder(url); |
||||
} catch (URISyntaxException e) { |
||||
System.out.printf("URISyntaxException: {}", e); |
||||
throw new Exception(e); |
||||
|
||||
} |
||||
|
||||
if (queryParams != null && !queryParams.isEmpty()) { |
||||
builder.setParameters(paramsConverter(queryParams)); |
||||
} |
||||
request.setURI(builder.build()); |
||||
|
||||
return executeHttpRequest(request); |
||||
} |
||||
|
||||
public StreamClosedHttpResponse doGetWithParasGetStatusLine(String url, |
||||
Map<String, String> queryParams, Map<String, String> headerMap) |
||||
throws Exception { |
||||
HttpResponse response = doGetWithParas(url, queryParams, headerMap); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
public HttpResponse doDelete(String url, Map<String, String> headerMap) { |
||||
HttpDelete request = new HttpDelete(url); |
||||
addRequestHeader(request, headerMap); |
||||
|
||||
return executeHttpRequest(request); |
||||
} |
||||
|
||||
public StreamClosedHttpResponse doDeleteGetStatusLine(String url, |
||||
Map<String, String> headerMap) { |
||||
HttpResponse response = doDelete(url, headerMap); |
||||
if (null == response) { |
||||
System.out.println("The response body is null."); |
||||
} |
||||
|
||||
return (StreamClosedHttpResponse) response; |
||||
} |
||||
|
||||
private static void addRequestHeader(HttpUriRequest request, |
||||
Map<String, String> headerMap) { |
||||
if (headerMap == null) { |
||||
return; |
||||
} |
||||
|
||||
for (String headerName : headerMap.keySet()) { |
||||
if (CONTENT_LENGTH.equalsIgnoreCase(headerName)) { |
||||
continue; |
||||
} |
||||
|
||||
String headerValue = headerMap.get(headerName); |
||||
request.addHeader(headerName, headerValue); |
||||
} |
||||
} |
||||
|
||||
private HttpResponse executeHttpRequest(HttpUriRequest request) { |
||||
HttpResponse response = null; |
||||
|
||||
try { |
||||
response = httpClient.execute(request); |
||||
} catch (Exception e) { |
||||
System.out.println("executeHttpRequest failed."); |
||||
} finally { |
||||
try { |
||||
response = new StreamClosedHttpResponse(response); |
||||
} catch (IOException e) { |
||||
System.out.println("IOException: " + e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
return response; |
||||
} |
||||
|
||||
public String getHttpResponseBody(HttpResponse response) |
||||
throws UnsupportedOperationException, IOException { |
||||
if (response == null) { |
||||
return null; |
||||
} |
||||
|
||||
String body = null; |
||||
|
||||
if (response instanceof StreamClosedHttpResponse) { |
||||
body = ((StreamClosedHttpResponse) response).getContent(); |
||||
} else { |
||||
HttpEntity entity = response.getEntity(); |
||||
if (entity != null && entity.isStreaming()) { |
||||
String encoding = entity.getContentEncoding() != null ? entity |
||||
.getContentEncoding().getValue() : null; |
||||
body = StreamUtil.inputStream2String(entity.getContent(), |
||||
encoding); |
||||
} |
||||
} |
||||
|
||||
return body; |
||||
} |
||||
} |
@ -0,0 +1,139 @@
|
||||
/* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.databind.SerializationFeature; |
||||
import com.fasterxml.jackson.databind.node.ObjectNode; |
||||
|
||||
public class JsonUtil { |
||||
|
||||
private static ObjectMapper objectMapper; |
||||
|
||||
static { |
||||
objectMapper = new ObjectMapper(); |
||||
|
||||
// 设置FAIL_ON_EMPTY_BEANS属性,当序列化空对象不要抛异常
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
||||
|
||||
// 设置FAIL_ON_UNKNOWN_PROPERTIES属性,当JSON字符串中存在Java对象没有的属性,忽略
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
||||
} |
||||
|
||||
/** |
||||
* Convert Object to JsonString |
||||
* |
||||
* @param jsonObj |
||||
* @return |
||||
*/ |
||||
public static String jsonObj2Sting(Object jsonObj) { |
||||
String jsonString = null; |
||||
|
||||
try { |
||||
jsonString = objectMapper.writeValueAsString(jsonObj); |
||||
} catch (IOException e) { |
||||
System.out.printf("pasre json Object[{}] to string failed.",jsonString); |
||||
} |
||||
|
||||
return jsonString; |
||||
} |
||||
|
||||
/** |
||||
* Convert JsonString to Simple Object |
||||
* |
||||
* @param jsonString |
||||
* @param cls |
||||
* @return |
||||
*/ |
||||
public static <T> T jsonString2SimpleObj(String jsonString, Class<T> cls) { |
||||
T jsonObj = null; |
||||
|
||||
try { |
||||
jsonObj = objectMapper.readValue(jsonString, cls); |
||||
} catch (IOException e) { |
||||
System.out.printf("pasre json Object[{}] to string failed.",jsonString); |
||||
} |
||||
|
||||
return jsonObj; |
||||
} |
||||
|
||||
/** |
||||
* Method that will convert object to the ObjectNode. |
||||
* |
||||
* @param value |
||||
* the source data; if null, will return null. |
||||
* @return the ObjectNode data after converted. |
||||
* @throws JsonException |
||||
*/ |
||||
public static <T> ObjectNode convertObject2ObjectNode(T object) |
||||
throws Exception { |
||||
if (null == object) { |
||||
return null; |
||||
} |
||||
|
||||
ObjectNode objectNode = null; |
||||
|
||||
if (object instanceof String) { |
||||
objectNode = convertJsonStringToObject((String) object, |
||||
ObjectNode.class); |
||||
} else { |
||||
objectNode = convertValue(object, ObjectNode.class); |
||||
} |
||||
|
||||
return objectNode; |
||||
} |
||||
|
||||
/** |
||||
* Method that will convert the json string to destination by the type(cls). |
||||
* |
||||
* @param jsonString |
||||
* the source json string; if null, will return null. |
||||
* @param cls |
||||
* the destination data type. |
||||
* @return |
||||
* @throws JsonException |
||||
*/ |
||||
public static <T> T convertJsonStringToObject(String jsonString, |
||||
Class<T> cls) throws Exception { |
||||
if (StringUtil.strIsNullOrEmpty(jsonString)) { |
||||
return null; |
||||
} |
||||
|
||||
try { |
||||
T object = objectMapper.readValue(jsonString, cls); |
||||
return object; |
||||
} catch (Exception e) { |
||||
throw new Exception(e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Method that will convert from given value into instance of given value |
||||
* type. |
||||
* |
||||
* @param fromValue |
||||
* @param toValueType |
||||
* @return |
||||
* @throws JsonException |
||||
*/ |
||||
private static <T> T convertValue(Object fromValue, Class<T> toValueType) |
||||
throws Exception { |
||||
try { |
||||
return objectMapper.convertValue(fromValue, toValueType); |
||||
} catch (IllegalArgumentException e) { |
||||
throw new Exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.security.MessageDigest; |
||||
|
||||
import java.security.NoSuchAlgorithmException; |
||||
|
||||
public class MD5Utils { |
||||
|
||||
/** |
||||
* 27 md5加密产生,产生128位(bit)的mac 28 将128bit Mac转换成16进制代码 29 |
||||
* |
||||
* @param strSrc |
||||
* 30 |
||||
* @param key |
||||
* 31 |
||||
* @return 32 |
||||
*/ |
||||
public static String MD5Encode(String strSrc) { |
||||
return MD5Encode(strSrc, ""); |
||||
} |
||||
|
||||
/** |
||||
* 27 md5加密产生,产生128位(bit)的mac 28 将128bit Mac转换成16进制代码 29 |
||||
* |
||||
* @param strSrc |
||||
* 30 |
||||
* @param key |
||||
* 31 |
||||
* @return 32 |
||||
*/ |
||||
public static String MD5Encode(String strSrc, String key) { |
||||
|
||||
try { |
||||
MessageDigest md5 = MessageDigest.getInstance("MD5"); |
||||
md5.update(strSrc.getBytes("UTF8")); |
||||
StringBuilder result = new StringBuilder(32); |
||||
byte[] temp; |
||||
temp = md5.digest(key.getBytes("UTF8")); |
||||
for (int i = 0; i < temp.length; i++) { |
||||
result.append(Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6)); |
||||
} |
||||
return result.toString(); |
||||
} catch (NoSuchAlgorithmException e) { |
||||
e.printStackTrace(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return ""; |
||||
|
||||
} |
||||
|
||||
public static void main(String[] args) throws Exception { |
||||
String aaa = "wtjn168"; |
||||
String mac128byte = MD5Encode(aaa, ""); |
||||
System.out.println("md5加密结果32 bit------------->:" + mac128byte); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,260 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.BufferedReader; |
||||
import java.io.InputStreamReader; |
||||
import java.io.OutputStreamWriter; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URL; |
||||
import java.net.URLConnection; |
||||
|
||||
public class MSGClient { |
||||
|
||||
/** |
||||
* http post方式提交 |
||||
*/ |
||||
private String HttpURL = "http://120.79.165.170:9001/"; |
||||
private String userName = "jbqznjf"; |
||||
private String password = "dT6pH6rQ1"; |
||||
private String pwd = ""; |
||||
|
||||
public MSGClient() { |
||||
}; |
||||
|
||||
/** |
||||
* 构造函数 |
||||
* |
||||
* @param username |
||||
* @param password |
||||
* @throws UnsupportedEncodingException |
||||
*/ |
||||
public MSGClient(String username, String password) throws UnsupportedEncodingException { |
||||
this.userName = username; |
||||
this.password = password; |
||||
this.pwd = MD5Utils.MD5Encode(username + MD5Utils.MD5Encode(password)); |
||||
} |
||||
|
||||
/** |
||||
* 方法名称:getBalance 功 能:获取余额 参 数:无 返 回 值:余额(String) |
||||
*/ |
||||
public String getBalance() { |
||||
String result = ""; |
||||
OutputStreamWriter out = null; |
||||
BufferedReader in = null; |
||||
StringBuilder params = new StringBuilder(); |
||||
params.append("username=").append(userName).append("&password=").append(this.getPwd()); |
||||
try { |
||||
URL realUrl = new URL(HttpURL + "balanceQuery.do"); |
||||
URLConnection conn = realUrl.openConnection(); |
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); |
||||
out.write(params.toString()); |
||||
out.flush(); |
||||
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8")); |
||||
String line = ""; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line + "\n"; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 方法名称:mt 功 能:发送短信 |
||||
* |
||||
* @param content |
||||
* 发送内容 |
||||
* @param mobile |
||||
* 发送的手机号码,多个手机号为用半角 , 分开 |
||||
* @param dstime |
||||
* 定时时间 ,为空时表示立即发送,格式:yyyy-MM-dd HH:mm:ss |
||||
* @param msgid |
||||
* 客户自定义消息ID |
||||
* @param ext |
||||
* 用户自定义扩展 |
||||
* @param msgfmt |
||||
* 提交消息编码格式(UTF-8/GBK)置空时默认是UTF-8 返 回 |
||||
* 值:若用户自定义消息ID,则返回用户的ID,否则系统随机生成一个任务ID |
||||
* @throws UnsupportedEncodingException |
||||
*/ |
||||
public String mt(String content, String mobile, String dstime, String msgid, String ext, String msgfmt) |
||||
throws UnsupportedEncodingException { |
||||
String result = ""; |
||||
OutputStreamWriter out = null; |
||||
BufferedReader in = null; |
||||
StringBuilder params = new StringBuilder(); |
||||
params.append("username=").append(userName).append("&password=").append(this.getPwd()).append("&mobile=") |
||||
.append(mobile).append("&content=").append(content).append("&ext=").append(ext); |
||||
try { |
||||
URL realUrl = new URL(HttpURL + "smsSend.do"); // 单发短信
|
||||
// URL realUrl = new URL(HttpURL + "sendData.do"); // 群发短信
|
||||
URLConnection conn = realUrl.openConnection(); |
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); |
||||
out.write(params.toString()); |
||||
out.flush(); |
||||
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8")); |
||||
String line = ""; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line + "\n"; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 方法名称:mtData 功 能:发送个性短信(一个号码对应一条内容) 参数: |
||||
* |
||||
* @param content |
||||
* 发送内容,同号码个数一致,内容单条编码之后用英文逗号(,)隔开变成串,之后再对整个串进行二次编码,编码方式为UTF-8 |
||||
* @param mobile |
||||
* 发送的号码,多个号码用英文,分隔 |
||||
* @param dstime |
||||
* 定时时间 |
||||
* @param ext |
||||
* 用户自定义扩展 |
||||
* @param msgid |
||||
* 用户自定义消息ID |
||||
* @param msgfmt |
||||
* 提交消息编码格式 |
||||
* @return |
||||
*/ |
||||
public String mtData(String content, String mobile, String dstime, String ext, String msgid, String msgfmt) { |
||||
String result = ""; |
||||
OutputStreamWriter out = null; |
||||
BufferedReader in = null; |
||||
StringBuilder params = new StringBuilder(); |
||||
params.append("username=").append(userName).append("&password=").append(this.getPwd()).append("&mobile=") |
||||
.append(mobile).append("&content=").append(content).append("&dstime=").append(dstime).append("&ext=") |
||||
.append(ext).append("&msgid=").append(msgid).append("&msgfmt=").append(msgfmt); |
||||
try { |
||||
URL realUrl = new URL(HttpURL + "sendData.do"); |
||||
URLConnection conn = realUrl.openConnection(); |
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); |
||||
out.write(params.toString()); |
||||
out.flush(); |
||||
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8")); |
||||
String line = ""; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line + "\n"; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 方法名称:UpdatePassword 功 能:修改密码 参 数:newPassword(新密码) 返 回 值:状态报告(string) |
||||
*/ |
||||
public String UpdatePassword(String newPassword) { |
||||
String result = ""; |
||||
OutputStreamWriter out = null; |
||||
BufferedReader in = null; |
||||
StringBuilder params = new StringBuilder(); |
||||
params.append("username=").append(userName).append("&password=").append(this.getPwd()).append("&newpassword=") |
||||
.append(newPassword); |
||||
try { |
||||
URL realUrl = new URL(HttpURL + "passwordUpdate.do"); |
||||
URLConnection conn = realUrl.openConnection(); |
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); |
||||
out.write(params.toString()); |
||||
out.flush(); |
||||
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8")); |
||||
String line = ""; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line + "\n"; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 方法名称: getDigest 功 能:数字签名(明文MD5加密) 参数: |
||||
* |
||||
* @param plaintext |
||||
* 明文 返回参数:MD5密文 |
||||
*/ |
||||
public String getDigest(String plaintext) { |
||||
String result = ""; |
||||
OutputStreamWriter out = null; |
||||
BufferedReader in = null; |
||||
StringBuilder params = new StringBuilder(); |
||||
params.append("plaintext=").append(plaintext); |
||||
try { |
||||
URL realUrl = new URL(HttpURL + "md5Digest.do"); |
||||
URLConnection conn = realUrl.openConnection(); |
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestProperty("connection", "Keep-Alive"); |
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); |
||||
out.write(params.toString()); |
||||
out.flush(); |
||||
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8")); |
||||
String line = ""; |
||||
while ((line = in.readLine()) != null) { |
||||
result += line + "\n"; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public String getHttpURL() { |
||||
return HttpURL; |
||||
} |
||||
|
||||
public void setHttpURL(String httpURL) { |
||||
HttpURL = httpURL; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
public String getPwd() { |
||||
return pwd; |
||||
} |
||||
|
||||
public void setPwd(String pwd) { |
||||
this.pwd = pwd; |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
public class Md5Digest { |
||||
|
||||
/** |
||||
* 数字签名(明文MD5加密) |
||||
* |
||||
* @param args |
||||
*/ |
||||
public static void main(String[] args) { |
||||
MSGClient client = new MSGClient(); |
||||
|
||||
String plaintext = "123456"; |
||||
|
||||
String result = client.getDigest(plaintext); |
||||
|
||||
System.out.println(result); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,909 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.context.ApplicationContext; |
||||
|
||||
import com.mh.garrison.entity.MeterHistoryBean; |
||||
import com.mh.garrison.entity.MeterNowBean; |
||||
import com.mh.garrison.entity.ThreeMeterNowBean; |
||||
import com.mh.garrison.mapper.DeviceMapper; |
||||
import com.mh.garrison.mapper.MeterHistoryMapper; |
||||
import com.mh.garrison.mapper.MeterNowMapper; |
||||
import com.mh.garrison.service.DeviceService; |
||||
import com.mh.garrison.service.MeterHistoryService; |
||||
import com.mh.garrison.service.MeterNowService; |
||||
|
||||
public class MeterUtils { |
||||
|
||||
// 添加之后能够对mapper调用
|
||||
public ApplicationContext applicationContext = SpringUtils.getApplicationContext(); |
||||
|
||||
public MeterNowService meterNowService = applicationContext.getBean(MeterNowService.class); |
||||
public MeterHistoryService meterHistoryService = applicationContext.getBean(MeterHistoryService.class); |
||||
|
||||
public MeterNowMapper meterNowMapper = applicationContext.getBean(MeterNowMapper.class); |
||||
public MeterHistoryMapper meterHistoryMapper = applicationContext.getBean(MeterHistoryMapper.class); |
||||
|
||||
// 添加之后能够对mapper调用
|
||||
public DeviceMapper deviceMapper = applicationContext.getBean(DeviceMapper.class); |
||||
public DeviceService deviceService = applicationContext.getBean(DeviceService.class); |
||||
|
||||
/** |
||||
* 校验和 |
||||
* |
||||
* @param data |
||||
* @return |
||||
*/ |
||||
private static String makeChecksum(String data) { |
||||
if (data == null || data.equals("")) { |
||||
return ""; |
||||
} |
||||
int total = 0; |
||||
int len = data.length(); |
||||
int num = 0; |
||||
while (num < len) { |
||||
String s = data.substring(num, num + 2); |
||||
// System.out.println(s);
|
||||
total += Integer.parseInt(s, 16); |
||||
num = num + 2; |
||||
} |
||||
/** |
||||
* 用256求余最大是255,即16进制的FF |
||||
*/ |
||||
int mod = total % 256; |
||||
String hex = Integer.toHexString(mod); |
||||
len = hex.length(); |
||||
// 如果不够校验位的长度,补0,这里用的是两位校验
|
||||
if (len < 2) { |
||||
hex = "0" + hex; |
||||
} |
||||
return hex; |
||||
} |
||||
|
||||
/** |
||||
* 转换位置 |
||||
* |
||||
* @param data |
||||
* @return |
||||
*/ |
||||
private static String changePosition(String data) { |
||||
String newData = ""; |
||||
for (int i = data.length() / 2; i > 0; i--) { |
||||
newData = newData + data.substring(2 * i - 2, 2 * i); |
||||
// System.out.println(newData);
|
||||
} |
||||
return newData; |
||||
} |
||||
|
||||
/** |
||||
* 减33操作 |
||||
* |
||||
* @param data |
||||
* @return |
||||
*/ |
||||
private static String minusThree(String data) { |
||||
int b = Integer.parseInt("33", 16); // 33值
|
||||
String newData = ""; // 新返回值
|
||||
for (int i = 0; i < data.length() / 2; i++) { |
||||
String cutString = data.substring(2 * i, 2 * i + 2); |
||||
// System.out.println("截取的字符——" + cutString);
|
||||
int a1 = Integer.parseInt(cutString, 16); |
||||
int b1 = a1 - b; |
||||
if (b1 < 0) { |
||||
System.out.println("数据格式有误"); |
||||
return "数据格式有误"; |
||||
} else { |
||||
b1 = b1 % 256; |
||||
String hexString = Integer.toHexString(b1); |
||||
if (hexString.length() < 2) { |
||||
hexString = "0" + hexString; |
||||
// System.out.println(hexString);
|
||||
newData = newData + hexString; |
||||
} else { |
||||
newData = newData + hexString; |
||||
} |
||||
} |
||||
} |
||||
return newData; |
||||
} |
||||
|
||||
public String analysisSendOrder(String data) { |
||||
|
||||
// 68563412000000688400F016
|
||||
String state = "fail"; |
||||
int len = data.length(); |
||||
|
||||
// 校验和
|
||||
String checkSum = MeterUtils.makeChecksum(data.substring(0, len - 4)); |
||||
System.out.println("计算后校验和 " + checkSum); |
||||
|
||||
// 比较校验和
|
||||
String check = data.substring(len - 4, len - 2); |
||||
System.out.println("计算前校验和 " + check); |
||||
|
||||
if (checkSum.equals(check)) { |
||||
System.out.println("校验和对比正常"); |
||||
|
||||
// 表号
|
||||
String meterID = data.substring(2, 14); |
||||
meterID = MeterUtils.changePosition(meterID); |
||||
System.out.println("表号 " + meterID); |
||||
|
||||
String passBack = data.substring(16, 20); |
||||
if (passBack.equals("8400")) { |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("device_num", meterID); |
||||
params.put("remark", "命令"); |
||||
List<Map<String, Object>> list = deviceService.exeProcedure(params); |
||||
for (Map<String, Object> map : list) { |
||||
System.out.println(map); |
||||
} |
||||
Object result = params.get("state"); |
||||
if (result.equals("没有命令待发") || result.equals("已发送")) { |
||||
state = "success"; |
||||
} |
||||
} else { |
||||
state = "fail"; |
||||
} |
||||
} |
||||
|
||||
return state; |
||||
|
||||
} |
||||
|
||||
public String analysisAEPMeter(String data, String eventTime, String deviceId, String imei) { |
||||
|
||||
MeterNowBean meterNowBean = new MeterNowBean(); |
||||
MeterHistoryBean meterHistoryBean = new MeterHistoryBean(); |
||||
|
||||
int len = data.length(); |
||||
|
||||
// 校验和
|
||||
String checkSum = MeterUtils.makeChecksum(data.substring(0, len - 4)); |
||||
System.out.println("计算后校验和 " + checkSum); |
||||
|
||||
// 比较校验和
|
||||
String check = data.substring(len - 4, len - 2); |
||||
System.out.println("计算前校验和 " + check); |
||||
|
||||
if (checkSum.equals(check)) { |
||||
System.out.println("校验和对比正常"); |
||||
// 表号
|
||||
String meterID = data.substring(2, 14); |
||||
meterID = MeterUtils.changePosition(meterID); |
||||
System.out.println("表号 " + meterID); |
||||
|
||||
// 电量
|
||||
String meterValue = data.substring(24, 32); |
||||
// System.out.println(meterValue);
|
||||
meterValue = MeterUtils.changePosition(meterValue); |
||||
meterValue = MeterUtils.minusThree(meterValue); |
||||
meterValue = meterValue.substring(0, 6) + "." + meterValue.substring(6, meterValue.length()); |
||||
System.out.println("电量 " + meterValue); |
||||
|
||||
// 电压
|
||||
String voltage = data.substring(32, 36); |
||||
// System.out.println(voltage);
|
||||
voltage = MeterUtils.changePosition(voltage); |
||||
voltage = MeterUtils.minusThree(voltage); |
||||
voltage = voltage.substring(0, 3) + "." + voltage.substring(3, 4); |
||||
System.out.println("电压 " + voltage); |
||||
|
||||
// 电流
|
||||
String current = data.substring(36, 42); |
||||
// System.out.println(current);
|
||||
current = MeterUtils.changePosition(current); |
||||
current = MeterUtils.minusThree(current); |
||||
current = current.substring(0, 3) + "." + current.substring(3, current.length()); |
||||
System.out.println("电流 " + current); |
||||
|
||||
// 功率
|
||||
String power = data.substring(42, 48); |
||||
// System.out.println(power);
|
||||
power = MeterUtils.changePosition(power); |
||||
power = MeterUtils.minusThree(power); |
||||
power = power.substring(0, 2) + "." + power.substring(2, power.length()); |
||||
System.out.println("功率 " + power); |
||||
|
||||
// 功率因数
|
||||
String powerFactor = data.substring(48, 52); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor = MeterUtils.changePosition(powerFactor); |
||||
powerFactor = MeterUtils.minusThree(powerFactor); |
||||
powerFactor = powerFactor.substring(0, 1) + "." + powerFactor.substring(1, powerFactor.length()); |
||||
System.out.println("功率因数" + powerFactor); |
||||
|
||||
// 频率
|
||||
String frequency = data.substring(52, 56); |
||||
// System.out.println(frequency);
|
||||
frequency = MeterUtils.changePosition(frequency); |
||||
frequency = MeterUtils.minusThree(frequency); |
||||
frequency = frequency.substring(0, 2) + "." + frequency.substring(2, frequency.length()); |
||||
System.out.println("频率 " + frequency); |
||||
|
||||
// 状态
|
||||
String state = data.substring(56, 58); |
||||
// System.out.println(state);
|
||||
state = MeterUtils.changePosition(state); |
||||
state = MeterUtils.minusThree(state); |
||||
Integer num = Integer.parseInt(state, 16); |
||||
if (num == 0) { |
||||
state = "合闸"; |
||||
} else if (num == 1) { |
||||
state = "拉闸"; |
||||
} else if (num == 2) { |
||||
state = "合闸,功率超限"; |
||||
} else if (num == 3) { |
||||
state = "拉闸,功率超限"; |
||||
} |
||||
// if (state.equals("00")) {
|
||||
// state = "合闸";
|
||||
// } else if (state.equals("01")) {
|
||||
// state = "拉闸";
|
||||
// }
|
||||
System.out.println("状态 " + state); |
||||
|
||||
// 网络信号
|
||||
String netSignal = data.substring(58, 60); |
||||
// System.out.println(netSignal);
|
||||
netSignal = MeterUtils.changePosition(netSignal); |
||||
netSignal = MeterUtils.minusThree(netSignal); |
||||
System.out.println("网络信号" + netSignal); |
||||
|
||||
// 定时上传时间
|
||||
String timeUpload = data.substring(60, 64); |
||||
// System.out.println(timeUpload);
|
||||
timeUpload = MeterUtils.changePosition(timeUpload); |
||||
timeUpload = MeterUtils.minusThree(timeUpload); |
||||
System.out.println("定时上传时间" + timeUpload); |
||||
|
||||
// 限容功率
|
||||
String spare = data.substring(64, 68); |
||||
// System.out.println(spare);
|
||||
spare = MeterUtils.changePosition(spare); |
||||
spare = MeterUtils.minusThree(spare); |
||||
spare = spare.substring(0, 2) + "." + spare.substring(2, spare.length()); |
||||
System.out.println("限容功率 " + spare); |
||||
|
||||
// 查询基表安装表是否是对应的平台
|
||||
Integer platform = deviceService.findPlatform(meterID); |
||||
if (platform == null || platform == 0 ) { |
||||
// 更新变成AEP平台
|
||||
deviceService.updatePlatform(meterID); |
||||
} |
||||
// 插入表状态
|
||||
Map<String, Object> maps = new HashMap<>(); |
||||
maps.put("device_id", deviceId); |
||||
maps.put("create_date", eventTime); |
||||
maps.put("lastModifiedTime", eventTime); |
||||
maps.put("device_imei", imei); |
||||
maps.put("device_state", "ONLINE"); |
||||
deviceService.exeAddStateProcedure(maps); |
||||
|
||||
// 房间号
|
||||
String house_num = null; |
||||
|
||||
// 楼栋
|
||||
String building_name = null; |
||||
try { |
||||
house_num = meterNowService.findHouse(meterID); |
||||
// Thread.sleep(200);
|
||||
building_name = meterNowService.findBuildingName(meterID); |
||||
// building_name = meterNowMapper.findBuilding(house_num);// 查询楼层
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
e.printStackTrace(); |
||||
// house_num = "";
|
||||
// building_name = "";
|
||||
} |
||||
|
||||
meterNowBean.setMt_num(meterID); |
||||
meterNowBean.setMt_electric(meterValue); |
||||
meterNowBean.setMt_state(state); |
||||
meterNowBean.setMt_device_id(deviceId); |
||||
meterNowBean.setMt_time(eventTime); |
||||
meterNowBean.setLimited_power(spare); |
||||
meterNowBean.setHouse_num(house_num); |
||||
meterNowBean.setBuilding_name(building_name); |
||||
meterNowBean.setGrade(0); |
||||
|
||||
try { |
||||
|
||||
if (meterNowService.checkMeterId(meterNowBean) != 0) { |
||||
meterNowService.updateAll(meterNowBean); |
||||
System.out.println("-----------更新实时表成功-----------"); |
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} else { |
||||
meterNowService.insertAll(meterNowBean); |
||||
System.out.println("-----------插入实时表成功-----------"); |
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} |
||||
|
||||
// 插入到历史流水表中
|
||||
meterHistoryBean.setMt_num(meterID); |
||||
meterHistoryBean.setMt_electric(meterValue); |
||||
meterHistoryBean.setMt_state(state); |
||||
meterHistoryBean.setMt_device_id(deviceId); |
||||
meterHistoryBean.setMt_time(eventTime); |
||||
meterHistoryBean.setHouse_num(house_num); |
||||
meterHistoryBean.setBuilding_name(building_name); |
||||
meterHistoryBean.setGrade(0); |
||||
// Thread.sleep(300);
|
||||
int b = meterHistoryService.insertAll(meterHistoryBean); |
||||
if (b == 1) { |
||||
System.out.println(meterHistoryBean.toString()); |
||||
// Thread.sleep(500);
|
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
} |
||||
int c = meterHistoryService.checkHistory(meterHistoryBean); |
||||
if (c != 0) { |
||||
//防止是否存在数据库内,继续查询对应的数据,如果存在则返回成功,不存在返回失败
|
||||
System.out.println("-----------插入历史表成功-----------"); |
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
return "fail"; |
||||
} |
||||
// Thread.sleep(300);
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
boolean status = causeStr.contains("违反了 UNIQUE KEY 约束"); |
||||
if (status) { |
||||
return "success"; |
||||
} |
||||
return "fail"; |
||||
} |
||||
// 更新发送命令状态表
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("device_num", meterID); |
||||
params.put("remark", "读取数据状态"); |
||||
List<Map<String, Object>> list = deviceService.exeProcedure(params); |
||||
for (Map<String, Object> map : list) { |
||||
System.out.println(map.get("state").toString()); |
||||
} |
||||
Object result = params.get("state"); |
||||
String state1 = null; |
||||
if (result.equals("没有命令待发") || result.equals("已发送")) { |
||||
state1 = "success"; |
||||
} |
||||
return state1; |
||||
} else { |
||||
System.out.println("校验和对比错误"); |
||||
return "fail"; |
||||
} |
||||
} |
||||
|
||||
public String analysisMeter(String data, String eventTime, String deviceId) { |
||||
|
||||
MeterNowBean meterNowBean = new MeterNowBean(); |
||||
MeterHistoryBean meterHistoryBean = new MeterHistoryBean(); |
||||
|
||||
int len = data.length(); |
||||
|
||||
// 校验和
|
||||
String checkSum = MeterUtils.makeChecksum(data.substring(0, len - 4)); |
||||
System.out.println("计算后校验和 " + checkSum); |
||||
|
||||
// 比较校验和
|
||||
String check = data.substring(len - 4, len - 2); |
||||
System.out.println("计算前校验和 " + check); |
||||
|
||||
if (checkSum.equals(check)) { |
||||
System.out.println("校验和对比正常"); |
||||
// 表号
|
||||
String meterID = data.substring(2, 14); |
||||
meterID = MeterUtils.changePosition(meterID); |
||||
System.out.println("表号 " + meterID); |
||||
|
||||
// 电量
|
||||
String meterValue = data.substring(24, 32); |
||||
// System.out.println(meterValue);
|
||||
meterValue = MeterUtils.changePosition(meterValue); |
||||
meterValue = MeterUtils.minusThree(meterValue); |
||||
meterValue = meterValue.substring(0, 6) + "." + meterValue.substring(6, meterValue.length()); |
||||
System.out.println("电量 " + meterValue); |
||||
|
||||
// 电压
|
||||
String voltage = data.substring(32, 36); |
||||
// System.out.println(voltage);
|
||||
voltage = MeterUtils.changePosition(voltage); |
||||
voltage = MeterUtils.minusThree(voltage); |
||||
voltage = voltage.substring(0, 3) + "." + voltage.substring(3, 4); |
||||
System.out.println("电压 " + voltage); |
||||
|
||||
// 电流
|
||||
String current = data.substring(36, 42); |
||||
// System.out.println(current);
|
||||
current = MeterUtils.changePosition(current); |
||||
current = MeterUtils.minusThree(current); |
||||
current = current.substring(0, 3) + "." + current.substring(3, current.length()); |
||||
System.out.println("电流 " + current); |
||||
|
||||
// 功率
|
||||
String power = data.substring(42, 48); |
||||
// System.out.println(power);
|
||||
power = MeterUtils.changePosition(power); |
||||
power = MeterUtils.minusThree(power); |
||||
power = power.substring(0, 2) + "." + power.substring(2, power.length()); |
||||
System.out.println("功率 " + power); |
||||
|
||||
// 功率因数
|
||||
String powerFactor = data.substring(48, 52); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor = MeterUtils.changePosition(powerFactor); |
||||
powerFactor = MeterUtils.minusThree(powerFactor); |
||||
powerFactor = powerFactor.substring(0, 1) + "." + powerFactor.substring(1, powerFactor.length()); |
||||
System.out.println("功率因数" + powerFactor); |
||||
|
||||
// 频率
|
||||
String frequency = data.substring(52, 56); |
||||
// System.out.println(frequency);
|
||||
frequency = MeterUtils.changePosition(frequency); |
||||
frequency = MeterUtils.minusThree(frequency); |
||||
frequency = frequency.substring(0, 2) + "." + frequency.substring(2, frequency.length()); |
||||
System.out.println("频率 " + frequency); |
||||
|
||||
// 状态
|
||||
String state = data.substring(56, 58); |
||||
// System.out.println(state);
|
||||
state = MeterUtils.changePosition(state); |
||||
state = MeterUtils.minusThree(state); |
||||
Integer num = Integer.parseInt(state, 16); |
||||
if (num == 0) { |
||||
state = "合闸"; |
||||
} else if (num == 1) { |
||||
state = "拉闸"; |
||||
} else if (num == 2) { |
||||
state = "合闸,功率超限"; |
||||
} else if (num == 3) { |
||||
state = "拉闸,功率超限"; |
||||
} |
||||
// if (state.equals("00")) {
|
||||
// state = "合闸";
|
||||
// } else if (state.equals("01")) {
|
||||
// state = "拉闸";
|
||||
// }
|
||||
System.out.println("状态 " + state); |
||||
|
||||
// 网络信号
|
||||
String netSignal = data.substring(58, 60); |
||||
// System.out.println(netSignal);
|
||||
netSignal = MeterUtils.changePosition(netSignal); |
||||
netSignal = MeterUtils.minusThree(netSignal); |
||||
System.out.println("网络信号" + netSignal); |
||||
|
||||
// 定时上传时间
|
||||
String timeUpload = data.substring(60, 64); |
||||
// System.out.println(timeUpload);
|
||||
timeUpload = MeterUtils.changePosition(timeUpload); |
||||
timeUpload = MeterUtils.minusThree(timeUpload); |
||||
System.out.println("定时上传时间" + timeUpload); |
||||
|
||||
// 限容功率
|
||||
String spare = data.substring(64, 68); |
||||
// System.out.println(spare);
|
||||
spare = MeterUtils.changePosition(spare); |
||||
spare = MeterUtils.minusThree(spare); |
||||
spare = spare.substring(0, 2) + "." + spare.substring(2, spare.length()); |
||||
System.out.println("限容功率 " + spare); |
||||
|
||||
// 房间号
|
||||
String house_num = null; |
||||
|
||||
// 楼栋
|
||||
String building_name = null; |
||||
try { |
||||
house_num = meterNowService.findHouse(meterID); |
||||
// Thread.sleep(200);
|
||||
building_name = meterNowService.findBuildingName(meterID); |
||||
// building_name = meterNowMapper.findBuilding(house_num);// 查询楼层
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
e.printStackTrace(); |
||||
// house_num = "";
|
||||
// building_name = "";
|
||||
} |
||||
|
||||
meterNowBean.setMt_num(meterID); |
||||
meterNowBean.setMt_electric(meterValue); |
||||
meterNowBean.setMt_state(state); |
||||
meterNowBean.setMt_device_id(deviceId); |
||||
meterNowBean.setMt_time(eventTime); |
||||
meterNowBean.setLimited_power(spare); |
||||
meterNowBean.setHouse_num(house_num); |
||||
meterNowBean.setBuilding_name(building_name); |
||||
meterNowBean.setGrade(0); |
||||
|
||||
try { |
||||
|
||||
if (meterNowService.checkMeterId(meterNowBean) != 0) { |
||||
meterNowService.updateAll(meterNowBean); |
||||
System.out.println("-----------更新实时表成功-----------"); |
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} else { |
||||
meterNowService.insertAll(meterNowBean); |
||||
System.out.println("-----------插入实时表成功-----------"); |
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} |
||||
|
||||
// 插入到历史流水表中
|
||||
meterHistoryBean.setMt_num(meterID); |
||||
meterHistoryBean.setMt_electric(meterValue); |
||||
meterHistoryBean.setMt_state(state); |
||||
meterHistoryBean.setMt_device_id(deviceId); |
||||
meterHistoryBean.setMt_time(eventTime); |
||||
meterHistoryBean.setHouse_num(house_num); |
||||
meterHistoryBean.setBuilding_name(building_name); |
||||
meterHistoryBean.setGrade(0); |
||||
// Thread.sleep(300);
|
||||
int b = meterHistoryService.insertAll(meterHistoryBean); |
||||
if (b == 1) { |
||||
System.out.println(meterHistoryBean.toString()); |
||||
// Thread.sleep(500);
|
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
} |
||||
int c = meterHistoryService.checkHistory(meterHistoryBean); |
||||
if (c != 0) { |
||||
//防止是否存在数据库内,继续查询对应的数据,如果存在则返回成功,不存在返回失败
|
||||
System.out.println("-----------插入历史表成功-----------"); |
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
return "fail"; |
||||
} |
||||
// Thread.sleep(300);
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(">>>>>>>-------------" + causeStr); |
||||
boolean status = causeStr.contains("违反了 UNIQUE KEY 约束"); |
||||
if (status) { |
||||
return "success"; |
||||
} |
||||
return "fail"; |
||||
} |
||||
// 更新发送命令状态表
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("device_num", meterID); |
||||
params.put("remark", "读取数据状态"); |
||||
List<Map<String, Object>> list = deviceService.exeProcedure(params); |
||||
for (Map<String, Object> map : list) { |
||||
System.out.println(map.get("state").toString()); |
||||
} |
||||
Object result = params.get("state"); |
||||
String state1 = null; |
||||
if (result.equals("没有命令待发") || result.equals("已发送")) { |
||||
state1 = "success"; |
||||
} |
||||
return state1; |
||||
} else { |
||||
System.out.println("校验和对比错误"); |
||||
return "fail"; |
||||
} |
||||
} |
||||
|
||||
public String analysisThreeMeter(String threeMeterStr, String eventTime, String device_id) { |
||||
|
||||
ThreeMeterNowBean threeMeterNowBean = new ThreeMeterNowBean(); |
||||
MeterHistoryBean meterHistoryBean = new MeterHistoryBean(); |
||||
|
||||
int len = threeMeterStr.length(); |
||||
|
||||
System.out.println("三相电表数据报文长度----------" + len); |
||||
|
||||
// 计算的检验和
|
||||
String checkSum = MeterUtils.makeChecksum(threeMeterStr.substring(0, len - 4)); |
||||
System.out.println("计算后的校验和----" + checkSum); |
||||
|
||||
// 数据本身的校验和
|
||||
String check = threeMeterStr.substring(len - 4, len - 2); |
||||
System.out.println("计算前的校验和----" + check); |
||||
|
||||
System.out.println(checkSum.equalsIgnoreCase(check)); |
||||
// 比较校验和
|
||||
if (checkSum.equalsIgnoreCase(check)) { |
||||
|
||||
System.out.println("检验和正常"); |
||||
|
||||
// 表号
|
||||
String meterID = threeMeterStr.substring(2, 14); |
||||
meterID = MeterUtils.changePosition(meterID); |
||||
System.out.println("表号----------" + meterID); |
||||
|
||||
// 电量
|
||||
String meterValue = threeMeterStr.substring(24, 32); |
||||
meterValue = MeterUtils.changePosition(meterValue); |
||||
meterValue = MeterUtils.minusThree(meterValue); |
||||
meterValue = meterValue.substring(0, 6) + "." + meterValue.substring(6, meterValue.length()); |
||||
System.out.println("电量 " + meterValue); |
||||
|
||||
// 电压A
|
||||
String voltage_a = threeMeterStr.substring(32, 36); |
||||
// System.out.println(voltage);
|
||||
voltage_a = MeterUtils.changePosition(voltage_a); |
||||
voltage_a = MeterUtils.minusThree(voltage_a); |
||||
voltage_a = voltage_a.substring(0, 3) + "." + voltage_a.substring(3, 4); |
||||
System.out.println("电压 A " + voltage_a); |
||||
|
||||
// 电压B
|
||||
String voltage_b = threeMeterStr.substring(34, 40); |
||||
// System.out.println(voltage);
|
||||
voltage_b = MeterUtils.changePosition(voltage_b); |
||||
voltage_b = MeterUtils.minusThree(voltage_b); |
||||
voltage_b = voltage_b.substring(0, 3) + "." + voltage_b.substring(3, 4); |
||||
System.out.println("电压 B " + voltage_b); |
||||
|
||||
// 电压C
|
||||
String voltage_c = threeMeterStr.substring(40, 44); |
||||
// System.out.println(voltage);
|
||||
voltage_c = MeterUtils.changePosition(voltage_c); |
||||
voltage_c = MeterUtils.minusThree(voltage_c); |
||||
voltage_c = voltage_c.substring(0, 3) + "." + voltage_c.substring(3, 4); |
||||
System.out.println("电压 C " + voltage_c); |
||||
|
||||
// 电流A
|
||||
String current_a = threeMeterStr.substring(44, 50); |
||||
// System.out.println(current);
|
||||
current_a = MeterUtils.changePosition(current_a); |
||||
current_a = MeterUtils.minusThree(current_a); |
||||
current_a = current_a.substring(0, 3) + "." + current_a.substring(3, current_a.length()); |
||||
System.out.println("电流A " + current_a); |
||||
|
||||
// 电流B
|
||||
String current_b = threeMeterStr.substring(50, 56); |
||||
// System.out.println(current);
|
||||
current_b = MeterUtils.changePosition(current_b); |
||||
current_b = MeterUtils.minusThree(current_b); |
||||
current_b = current_b.substring(0, 3) + "." + current_b.substring(3, current_b.length()); |
||||
System.out.println("电流B " + current_b); |
||||
|
||||
// 电流C
|
||||
String current_c = threeMeterStr.substring(56, 62); |
||||
// System.out.println(current);
|
||||
current_c = MeterUtils.changePosition(current_c); |
||||
current_c = MeterUtils.minusThree(current_c); |
||||
current_c = current_c.substring(0, 3) + "." + current_c.substring(3, current_c.length()); |
||||
System.out.println("电流C " + current_c); |
||||
|
||||
// 功率总
|
||||
String power_total = threeMeterStr.substring(62, 68); |
||||
// System.out.println(power);
|
||||
power_total = MeterUtils.changePosition(power_total); |
||||
power_total = MeterUtils.minusThree(power_total); |
||||
power_total = power_total.substring(0, 2) + "." + power_total.substring(2, power_total.length()); |
||||
System.out.println("功率总 " + power_total); |
||||
|
||||
// 功率a
|
||||
String power_a = threeMeterStr.substring(68, 74); |
||||
// System.out.println(power);
|
||||
power_a = MeterUtils.changePosition(power_a); |
||||
power_a = MeterUtils.minusThree(power_a); |
||||
power_a = power_a.substring(0, 2) + "." + power_a.substring(2, power_a.length()); |
||||
System.out.println("功率A " + power_a); |
||||
|
||||
// 功率B
|
||||
String power_b = threeMeterStr.substring(74, 80); |
||||
// System.out.println(power);
|
||||
power_b = MeterUtils.changePosition(power_b); |
||||
power_b = MeterUtils.minusThree(power_b); |
||||
power_b = power_b.substring(0, 2) + "." + power_b.substring(2, power_b.length()); |
||||
System.out.println("功率B " + power_b); |
||||
|
||||
// 功率C
|
||||
String power_c = threeMeterStr.substring(80, 86); |
||||
// System.out.println(power);
|
||||
power_c = MeterUtils.changePosition(power_c); |
||||
power_c = MeterUtils.minusThree(power_c); |
||||
power_c = power_c.substring(0, 2) + "." + power_c.substring(2, power_c.length()); |
||||
System.out.println("功率C " + power_c); |
||||
|
||||
// 功率因数总
|
||||
String powerFactor_total = threeMeterStr.substring(86, 90); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor_total = MeterUtils.changePosition(powerFactor_total); |
||||
powerFactor_total = MeterUtils.minusThree(powerFactor_total); |
||||
powerFactor_total = powerFactor_total.substring(0, 1) + "." |
||||
+ powerFactor_total.substring(1, powerFactor_total.length()); |
||||
System.out.println("功率因数总 " + powerFactor_total); |
||||
|
||||
// 功率因数A
|
||||
String powerFactor_a = threeMeterStr.substring(90, 94); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor_a = MeterUtils.changePosition(powerFactor_a); |
||||
powerFactor_a = MeterUtils.minusThree(powerFactor_a); |
||||
powerFactor_a = powerFactor_a.substring(0, 1) + "." + powerFactor_a.substring(1, powerFactor_a.length()); |
||||
System.out.println("功率因数A " + powerFactor_a); |
||||
|
||||
// 功率因数B
|
||||
String powerFactor_b = threeMeterStr.substring(94, 98); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor_b = MeterUtils.changePosition(powerFactor_b); |
||||
powerFactor_b = MeterUtils.minusThree(powerFactor_b); |
||||
powerFactor_b = powerFactor_b.substring(0, 1) + "." + powerFactor_b.substring(1, powerFactor_b.length()); |
||||
System.out.println("功率因数B " + powerFactor_b); |
||||
|
||||
// 功率因数C
|
||||
String powerFactor_c = threeMeterStr.substring(98, 102); |
||||
// System.out.println(powerFactor);
|
||||
powerFactor_c = MeterUtils.changePosition(powerFactor_c); |
||||
powerFactor_c = MeterUtils.minusThree(powerFactor_c); |
||||
powerFactor_c = powerFactor_c.substring(0, 1) + "." + powerFactor_c.substring(1, powerFactor_c.length()); |
||||
System.out.println("功率因数C " + powerFactor_c); |
||||
|
||||
// 频率
|
||||
String frequency = threeMeterStr.substring(102, 106); |
||||
// System.out.println(frequency);
|
||||
frequency = MeterUtils.changePosition(frequency); |
||||
frequency = MeterUtils.minusThree(frequency); |
||||
frequency = frequency.substring(0, 2) + "." + frequency.substring(2, frequency.length()); |
||||
System.out.println("频率 " + frequency); |
||||
|
||||
// 状态
|
||||
String state = threeMeterStr.substring(106, 108); |
||||
// System.out.println(state);
|
||||
state = MeterUtils.changePosition(state); |
||||
state = MeterUtils.minusThree(state); |
||||
Integer num = Integer.parseInt(state, 16); |
||||
if (num == 0) { |
||||
state = "合闸"; |
||||
} else if (num == 1) { |
||||
state = "拉闸"; |
||||
} else if (num == 2) { |
||||
state = "合闸,功率超限"; |
||||
} else if (num == 3) { |
||||
state = "拉闸,功率超限"; |
||||
} |
||||
System.out.println("状态 " + state); |
||||
|
||||
// 网络信号
|
||||
String netSignal = threeMeterStr.substring(108, 110); |
||||
// System.out.println(netSignal);
|
||||
netSignal = MeterUtils.changePosition(netSignal); |
||||
netSignal = MeterUtils.minusThree(netSignal); |
||||
System.out.println("网络信号 " + netSignal); |
||||
|
||||
// 定时上传时间
|
||||
String timeUpload = threeMeterStr.substring(110, 114); |
||||
// System.out.println(timeUpload);
|
||||
timeUpload = MeterUtils.changePosition(timeUpload); |
||||
timeUpload = MeterUtils.minusThree(timeUpload); |
||||
System.out.println("定时上传时间 " + timeUpload); |
||||
|
||||
// 限容功率
|
||||
String limited_power = threeMeterStr.substring(114, 118); |
||||
// System.out.println(timeUpload);
|
||||
limited_power = MeterUtils.changePosition(limited_power); |
||||
limited_power = MeterUtils.minusThree(limited_power); |
||||
limited_power = limited_power.substring(0, 2) + "." + limited_power.substring(2, limited_power.length()); |
||||
System.out.println("限容功率 " + limited_power); |
||||
|
||||
// 备用
|
||||
String spare = threeMeterStr.substring(118, 122); |
||||
// System.out.println(spare);
|
||||
spare = MeterUtils.changePosition(spare); |
||||
spare = MeterUtils.minusThree(spare); |
||||
System.out.println("备用 " + spare); |
||||
try { |
||||
// 如果是厦门双桥三相电表
|
||||
// 房间号
|
||||
String house_num = meterNowService.findHouse1(meterID); |
||||
System.out.println("房间号:"+house_num); |
||||
Thread.sleep(200); |
||||
// 楼栋
|
||||
// String building_name = meterNowMapper.findBuilding(house_num); // 楼层
|
||||
String building_name = meterNowService.findBuildingName1(meterID); |
||||
System.out.println("楼栋:"+building_name); |
||||
|
||||
// // 房间号
|
||||
// String house_num = meterNowService.findHouse(meterID);
|
||||
//// Thread.sleep(200);
|
||||
// // 楼栋
|
||||
//// String building_name = meterNowMapper.findBuilding(house_num); // 楼层
|
||||
// String building_name = meterNowService.findBuildingName(meterID);
|
||||
// if (building_name == null) {
|
||||
// building_name = meterNowService.findBuildingName(meterID);
|
||||
// }
|
||||
|
||||
|
||||
threeMeterNowBean.setMt_num(meterID); |
||||
threeMeterNowBean.setMt_electric(Double.parseDouble(meterValue)); |
||||
threeMeterNowBean.setMt_state(state); |
||||
threeMeterNowBean.setMt_device_id(device_id); |
||||
threeMeterNowBean.setMt_time(eventTime); |
||||
threeMeterNowBean.setLimited_power(limited_power); |
||||
threeMeterNowBean.setHouse_num(house_num); |
||||
threeMeterNowBean.setBuilding_name(building_name); |
||||
threeMeterNowBean.setGrade(0); |
||||
|
||||
// 插入到历史流水表中
|
||||
meterHistoryBean.setMt_num(meterID); |
||||
meterHistoryBean.setMt_electric(meterValue); |
||||
meterHistoryBean.setMt_state(state); |
||||
meterHistoryBean.setMt_device_id(device_id); |
||||
meterHistoryBean.setMt_time(eventTime); |
||||
meterHistoryBean.setHouse_num(house_num); |
||||
meterHistoryBean.setBuilding_name(building_name); |
||||
meterHistoryBean.setGrade(0); |
||||
|
||||
// Thread.sleep(300);
|
||||
// 直接插入数据库
|
||||
int his = meterHistoryService.insertAll(meterHistoryBean); |
||||
if (his == 1) { |
||||
// System.out.println(meterHistoryBean.toString());
|
||||
//防止是否存在数据库内,继续查询对应的数据,如果存在则返回成功,不存在返回失败
|
||||
int c = meterHistoryService.checkHistory(meterHistoryBean); |
||||
if (c != 0) { |
||||
System.out.println("-----------插入历史表成功-----------"); |
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
return "fail"; |
||||
} |
||||
} else { |
||||
System.out.println("-----------插入历史表失败-----------"); |
||||
} |
||||
|
||||
// Thread.sleep(300);
|
||||
if (meterNowService.checkMeterId(threeMeterNowBean) != 0) { |
||||
meterNowService.updateAll(threeMeterNowBean); |
||||
|
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} else { |
||||
meterNowService.insertAll(threeMeterNowBean); |
||||
|
||||
// meterNowMapper.exePro_calc_Meter(); // 开始计算电表数据
|
||||
} |
||||
|
||||
|
||||
|
||||
// Thread.sleep(300);
|
||||
|
||||
} catch (Exception e) { |
||||
// TODO: handle exception
|
||||
String causeStr = e.getCause().getMessage(); |
||||
System.out.println(causeStr); |
||||
boolean status = causeStr.contains("违反了 UNIQUE KEY 约束"); |
||||
if (status) { |
||||
return "success"; |
||||
} |
||||
return "fail"; |
||||
} |
||||
// 更新发送命令状态表
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("device_num", meterID); |
||||
params.put("remark", "读取数据状态"); |
||||
List<Map<String, Object>> list = deviceMapper.exeProcedure(params); |
||||
for (Map<String, Object> map : list) { |
||||
System.out.println(map.get("state").toString()); |
||||
} |
||||
Object result = params.get("state"); |
||||
String state1 = null; |
||||
if (result.equals("没有命令待发") || result.equals("已发送")) { |
||||
state1 = "success"; |
||||
} |
||||
return state1; |
||||
} else { |
||||
System.out.println("校验和对比错误"); |
||||
return "fail"; |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
// 68000205080000688118323237333333b554333333333333334335833433333333334816
|
||||
|
||||
String string = "689603019000006881333232b87953333656c855c4553a4b333a4b333a4b33c34434366b33b76933346a33453c463c3b3c473cca7c34336f3333333333fe16"; |
||||
|
||||
MeterUtils meterUtils = new MeterUtils(); |
||||
|
||||
// String result = meterUtils.analysisSendOrder(string);
|
||||
String result = meterUtils.analysisThreeMeter(string, "", ""); |
||||
|
||||
System.out.println(result); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
|
||||
public class PasswordUpdate { |
||||
|
||||
/** |
||||
* 修改密码 |
||||
* |
||||
* @param args |
||||
* @throws UnsupportedEncodingException |
||||
*/ |
||||
public static void main(String[] args) throws UnsupportedEncodingException { |
||||
String userName = ""; |
||||
String password = ""; |
||||
String newPassword = ""; |
||||
|
||||
MSGClient client = new MSGClient(userName, password); |
||||
String result = client.UpdatePassword(newPassword); |
||||
System.out.println("返回结果:" + result); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,185 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.ctg.ag.sdk.biz.AepDeviceCommandLwmProfileClient; |
||||
import com.ctg.ag.sdk.biz.aep_device_command_lwm_profile.CreateCommandLwm2mProfileRequest; |
||||
import com.mh.garrison.entity.AEPEntity; |
||||
|
||||
/** |
||||
* @author 铭汉科技——LJL |
||||
* @date 2022-07-25 10:58 |
||||
* @Description |
||||
*/ |
||||
public class PostCmdUtils { |
||||
|
||||
/** |
||||
* 永阳电表 |
||||
* 指令发送至AEP平台执行操作,带profile模型 |
||||
*/ |
||||
public static void postAsyncCmdAEPV1ByProfile(String deviceId, String sendOrderStr, AEPEntity aepEntity) throws Exception { |
||||
|
||||
AepDeviceCommandLwmProfileClient client = AepDeviceCommandLwmProfileClient.newClient().appKey("eP618B5xol5").appSecret("EdaE776fG6").build(); |
||||
|
||||
{ |
||||
|
||||
CreateCommandLwm2mProfileRequest request = new CreateCommandLwm2mProfileRequest(); |
||||
|
||||
JSONObject jsonObject = new JSONObject(); |
||||
JSONObject jsonObject1 = new JSONObject(); |
||||
JSONObject jsonObject2 = new JSONObject(); |
||||
|
||||
jsonObject2.put("value", sendOrderStr); |
||||
|
||||
/**可以去电信指定下发一个设备时选择的各项参数,或者查看AEP文档,又或者查看产品模型*/ |
||||
jsonObject1.put("serviceId", "MHMeterData"); |
||||
jsonObject1.put("method", "COMMAND"); |
||||
jsonObject1.put("paras", jsonObject2); |
||||
|
||||
jsonObject.put("command", jsonObject1); |
||||
jsonObject.put("deviceId", deviceId); |
||||
jsonObject.put("operator", "admin"); |
||||
jsonObject.put("productId", aepEntity.getProductId()); |
||||
jsonObject.put("ttl", 7200); |
||||
jsonObject.put("deviceGroupId", aepEntity.getDeviceGroupId()); |
||||
jsonObject.put("level", 1); |
||||
|
||||
request.setBody(jsonObject.toString().getBytes()); |
||||
System.out.println(jsonObject.toString()); |
||||
System.out.println(client.CreateCommandLwm2mProfile(request)); |
||||
} |
||||
client.shutdown(); |
||||
} |
||||
|
||||
/** |
||||
* 创建修改表号指令 |
||||
* 永阳电表专用 |
||||
* @param meterNum |
||||
* @return |
||||
*/ |
||||
private static String createUpdateMeter(String meterNum) { |
||||
StringBuilder cmd = new StringBuilder(); |
||||
cmd.append("68AAAAAAAAAAAA681506"); |
||||
//转换位置
|
||||
String afterChange = changePosition(meterNum); |
||||
//加33操作
|
||||
String finalMeterNum = addThree(afterChange); |
||||
cmd.append(finalMeterNum); |
||||
//校验码
|
||||
String checksum = makeChecksum(cmd.toString()); |
||||
cmd.append(checksum); |
||||
//结束符
|
||||
cmd.append("16"); |
||||
return cmd.toString().toUpperCase(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 转换位置 |
||||
*/ |
||||
private static String changePosition(String data) { |
||||
String newData = ""; |
||||
for (int i = data.length() / 2; i > 0; i--) { |
||||
newData = newData + data.substring(2 * i - 2, 2 * i); |
||||
} |
||||
return newData; |
||||
} |
||||
|
||||
/** |
||||
* 校验码 |
||||
*/ |
||||
private static String makeChecksum(String data) { |
||||
if (data == null || data.equals("")) { |
||||
return ""; |
||||
} |
||||
int total = 0; |
||||
int len = data.length(); |
||||
int num = 0; |
||||
while (num < len) { |
||||
String s = data.substring(num, num + 2); |
||||
total += Integer.parseInt(s, 16); |
||||
num = num + 2; |
||||
} |
||||
/** |
||||
* 用256求余最大是255,即16进制的FF |
||||
*/ |
||||
int mod = total % 256; |
||||
String hex = Integer.toHexString(mod); |
||||
len = hex.length(); |
||||
// 如果不够校验位的长度,补0,这里用的是两位校验
|
||||
if (len < 2) { |
||||
hex = "0" + hex; |
||||
} |
||||
return hex; |
||||
} |
||||
|
||||
/**十六进制补全2位*/ |
||||
private static String zeroFilling(String meterId) { |
||||
meterId = meterId.replace(" ", ""); |
||||
StringBuilder str = new StringBuilder(meterId); |
||||
while (str.length() < 2) { |
||||
str.reverse(); |
||||
str.append("0"); |
||||
str.reverse(); |
||||
} |
||||
return String.valueOf(str); |
||||
} |
||||
|
||||
/**加33操作*/ |
||||
private static String addThree(String data) { |
||||
// 33值
|
||||
int b = Integer.parseInt("33", 16); |
||||
// 新返回值
|
||||
String newData = ""; |
||||
for (int i = 0; i < data.length() / 2; i++) { |
||||
String cutString = data.substring(2 * i, 2 * i + 2); |
||||
int a1 = Integer.parseInt(cutString, 16); |
||||
int b1 = a1 + b; |
||||
if (b1 < 0) { |
||||
System.out.println("数据格式有误"); |
||||
return "数据格式有误"; |
||||
} else { |
||||
b1 = b1 % 256; |
||||
String hexString = Integer.toHexString(b1); |
||||
if (hexString.length() < 2) { |
||||
hexString = "0" + hexString; |
||||
newData = newData + hexString; |
||||
} else { |
||||
newData = newData + hexString; |
||||
} |
||||
} |
||||
} |
||||
return newData; |
||||
} |
||||
|
||||
/**生成电压功率设定值*/ |
||||
private static String createPower(double value){ |
||||
String str = String.valueOf(Math.abs(value)); |
||||
|
||||
String[] split = str.split("\\."); |
||||
System.out.println("spilt:"+split); |
||||
|
||||
String a1 = "00" + split[0]; |
||||
String b1 = a1.substring(a1.length() - 2); |
||||
String b2 = (split[1] + "00").substring(0, 2); |
||||
|
||||
System.out.println("b1:"+b1+" b2:"+b2); |
||||
System.out.println("b1+33:"+addThree(b1)); |
||||
System.out.println("b2+33:"+addThree(b2)); |
||||
|
||||
String power = (addThree(b2) + addThree(b1)).toUpperCase(); |
||||
System.out.println(power); |
||||
return power; |
||||
} |
||||
|
||||
|
||||
public static void main(String[] args) { |
||||
try { |
||||
//postAsyncSetPower("deviceId001",new AEPEntity(),3.5);
|
||||
String cmd = createUpdateMeter("000030702262"); |
||||
System.out.println("cmd = " + cmd); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import org.springframework.beans.BeansException; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.ApplicationContextAware; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
public class SpringUtils implements ApplicationContextAware{ |
||||
|
||||
private static ApplicationContext applicationContext = null; |
||||
|
||||
@Override |
||||
public void setApplicationContext(ApplicationContext arg0) throws BeansException { |
||||
// TODO Auto-generated method stub
|
||||
if (SpringUtils.applicationContext == null) { |
||||
SpringUtils.applicationContext = arg0; |
||||
} |
||||
} |
||||
|
||||
// 获取applicationContext
|
||||
public static ApplicationContext getApplicationContext() { |
||||
return applicationContext; |
||||
} |
||||
|
||||
// 通过Name获取Bean
|
||||
public static Object getBean(String name) { |
||||
return getApplicationContext().getBean(name); |
||||
} |
||||
|
||||
// 通过class获取Bean
|
||||
public static <T> T getBean(Class<T> claszz) { |
||||
return getApplicationContext().getBean(claszz); |
||||
} |
||||
|
||||
// 通过name,以及claszz返回指定的bean
|
||||
public static <T> T getBean(String name,Class<T> clazz) { |
||||
return getApplicationContext().getBean(name,clazz); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,204 @@
|
||||
/* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Locale; |
||||
|
||||
import org.apache.http.Header; |
||||
import org.apache.http.HeaderIterator; |
||||
import org.apache.http.HttpEntity; |
||||
import org.apache.http.HttpResponse; |
||||
import org.apache.http.ProtocolVersion; |
||||
import org.apache.http.StatusLine; |
||||
import org.apache.http.params.HttpParams; |
||||
|
||||
@SuppressWarnings("deprecation") |
||||
public class StreamClosedHttpResponse implements HttpResponse |
||||
{ |
||||
private final HttpResponse original; |
||||
|
||||
private final String content; |
||||
|
||||
public StreamClosedHttpResponse(final HttpResponse original) |
||||
throws UnsupportedOperationException, IOException |
||||
{ |
||||
this.original = original; |
||||
|
||||
HttpEntity entity = original.getEntity(); |
||||
if (entity != null && entity.isStreaming()) |
||||
{ |
||||
String encoding = entity.getContentEncoding() != null |
||||
? entity.getContentEncoding().getValue() : null; |
||||
content = StreamUtil.inputStream2String(entity.getContent(), |
||||
encoding); |
||||
} |
||||
else |
||||
{ |
||||
content = null; |
||||
} |
||||
} |
||||
|
||||
public StatusLine getStatusLine() |
||||
{ |
||||
return original.getStatusLine(); |
||||
} |
||||
|
||||
public void setStatusLine(final StatusLine statusline) |
||||
{ |
||||
original.setStatusLine(statusline); |
||||
} |
||||
|
||||
public void setStatusLine(final ProtocolVersion ver, final int code) |
||||
{ |
||||
original.setStatusLine(ver, code); |
||||
} |
||||
|
||||
public void setStatusLine(final ProtocolVersion ver, final int code, |
||||
final String reason) |
||||
{ |
||||
original.setStatusLine(ver, code, reason); |
||||
} |
||||
|
||||
public void setStatusCode(final int code) throws IllegalStateException |
||||
{ |
||||
original.setStatusCode(code); |
||||
} |
||||
|
||||
public void setReasonPhrase(final String reason) |
||||
throws IllegalStateException |
||||
{ |
||||
original.setReasonPhrase(reason); |
||||
} |
||||
|
||||
public HttpEntity getEntity() |
||||
{ |
||||
return original.getEntity(); |
||||
} |
||||
|
||||
public void setEntity(final HttpEntity entity) |
||||
{ |
||||
original.setEntity(entity); |
||||
} |
||||
|
||||
public Locale getLocale() |
||||
{ |
||||
return original.getLocale(); |
||||
} |
||||
|
||||
public void setLocale(final Locale loc) |
||||
{ |
||||
original.setLocale(loc); |
||||
} |
||||
|
||||
public ProtocolVersion getProtocolVersion() |
||||
{ |
||||
return original.getProtocolVersion(); |
||||
} |
||||
|
||||
public boolean containsHeader(final String name) |
||||
{ |
||||
return original.containsHeader(name); |
||||
} |
||||
|
||||
|
||||
public Header[] getHeaders(final String name) |
||||
{ |
||||
return original.getHeaders(name); |
||||
} |
||||
|
||||
public Header getFirstHeader(final String name) |
||||
{ |
||||
return original.getFirstHeader(name); |
||||
} |
||||
|
||||
public Header getLastHeader(final String name) |
||||
{ |
||||
return original.getLastHeader(name); |
||||
} |
||||
|
||||
public Header[] getAllHeaders() |
||||
{ |
||||
return original.getAllHeaders(); |
||||
} |
||||
|
||||
public void addHeader(final Header header) |
||||
{ |
||||
original.addHeader(header); |
||||
} |
||||
|
||||
public void addHeader(final String name, final String value) |
||||
{ |
||||
original.addHeader(name, value); |
||||
} |
||||
|
||||
public void setHeader(final Header header) |
||||
{ |
||||
original.setHeader(header); |
||||
} |
||||
|
||||
public void setHeader(final String name, final String value) |
||||
{ |
||||
original.setHeader(name, value); |
||||
} |
||||
|
||||
public void setHeaders(final Header[] headers) |
||||
{ |
||||
original.setHeaders(headers); |
||||
} |
||||
|
||||
public void removeHeader(final Header header) |
||||
{ |
||||
original.removeHeader(header); |
||||
} |
||||
|
||||
public void removeHeaders(final String name) |
||||
{ |
||||
original.removeHeaders(name); |
||||
} |
||||
|
||||
public HeaderIterator headerIterator() |
||||
{ |
||||
return original.headerIterator(); |
||||
} |
||||
|
||||
public HeaderIterator headerIterator(final String name) |
||||
{ |
||||
return original.headerIterator(name); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() |
||||
{ |
||||
final StringBuilder sb = new StringBuilder("HttpResponseProxy{"); |
||||
sb.append(original); |
||||
sb.append('}'); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
@Deprecated |
||||
public HttpParams getParams() |
||||
{ |
||||
return original.getParams(); |
||||
} |
||||
|
||||
@Deprecated |
||||
public void setParams(final HttpParams params) |
||||
{ |
||||
original.setParams(params); |
||||
} |
||||
|
||||
public String getContent() |
||||
{ |
||||
return content; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,76 @@
|
||||
/* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.io.Closeable; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.io.InputStreamReader; |
||||
|
||||
|
||||
public class StreamUtil |
||||
{ |
||||
|
||||
|
||||
private static final String DEFAULT_ENCODING = "utf-8"; |
||||
|
||||
public static String inputStream2String(InputStream in, String charsetName) |
||||
{ |
||||
if (in == null) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
InputStreamReader inReader = null; |
||||
|
||||
try |
||||
{ |
||||
if (StringUtil.strIsNullOrEmpty(charsetName)) |
||||
{ |
||||
inReader = new InputStreamReader(in, DEFAULT_ENCODING); |
||||
} |
||||
else |
||||
{ |
||||
inReader = new InputStreamReader(in, charsetName); |
||||
} |
||||
|
||||
int readLen = 0; |
||||
char[] buffer = new char[1024]; |
||||
StringBuffer strBuf = new StringBuffer(); |
||||
while ((readLen = inReader.read(buffer)) != -1) |
||||
{ |
||||
strBuf.append(buffer, 0, readLen); |
||||
} |
||||
|
||||
return strBuf.toString(); |
||||
} |
||||
catch (IOException e) |
||||
{ |
||||
System.out.println(e); |
||||
} |
||||
finally |
||||
{ |
||||
closeStream(inReader); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public static void closeStream(Closeable closeable) { |
||||
if (closeable != null) { |
||||
try { |
||||
closeable.close(); |
||||
} catch (IOException e) { |
||||
System.out.println(e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
/* |
||||
* Copyright Notice: |
||||
* Copyright 1998-2008, Huawei Technologies Co., Ltd. ALL Rights Reserved. |
||||
* |
||||
* Warning: This computer software sourcecode is protected by copyright law |
||||
* and international treaties. Unauthorized reproduction or distribution |
||||
* of this sourcecode, or any portion of it, may result in severe civil and |
||||
* criminal penalties, and will be prosecuted to the maximum extent |
||||
* possible under the law. |
||||
*/ |
||||
package com.mh.garrison.mhutils; |
||||
|
||||
public class StringUtil { |
||||
|
||||
public static boolean strIsNullOrEmpty(String s) { |
||||
return (null == s || s.trim().length() < 1); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
|
||||
public class TimeUtils { |
||||
|
||||
static String UTCToCST(String UTCStr, String format) throws ParseException { |
||||
Date date = null; |
||||
SimpleDateFormat sdf = new SimpleDateFormat(format); |
||||
UTCStr = UTCStr.substring(0, 4) + "-" + UTCStr.substring(4,6) + "-" + UTCStr.substring(6,7) |
||||
+ UTCStr.substring(7,11) + ":" + UTCStr.substring(11,13) + ":" + UTCStr.substring(13,UTCStr.length()); |
||||
System.out.println(UTCStr); |
||||
date = sdf.parse(UTCStr); |
||||
// System.out.println("UTC时间: " + date);
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + 8); |
||||
//calendar.getTime() 返回的是Date类型,也可以使用calendar.getTimeInMillis()获取时间戳
|
||||
// System.out.println("北京时间: " + calendar.getTime());
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
String dateString = formatter.format(calendar.getTime()); |
||||
// System.out.println(dateString);
|
||||
return dateString; |
||||
} |
||||
|
||||
public static void main(String[] args) throws ParseException { |
||||
String date = "20181013T073238Z"; |
||||
System.out.println(TimeUtils.UTCToCST(date, "yyyy-MM-dd'T'HH:mm:ss'Z'")); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: UUid |
||||
* @Description:TODO UUID是1.5中新增的一个类,在java.util下,用它可以产生一个号称全球唯一的ID |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月1日 下午4:08:58 |
||||
* |
||||
*/ |
||||
public class UUid { |
||||
|
||||
public String uuid() { |
||||
UUID uuid = UUID.randomUUID(); |
||||
return uuid.toString(); |
||||
} |
||||
|
||||
public static void main(String arg[]) { |
||||
UUid uid = new UUid(); |
||||
System.out.println(uid.uuid()); |
||||
System.out.println(System.getProperty("user.dir")); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.mh.garrison.mhutils; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.mh.garrison.entity.DataBean; |
||||
import com.mh.garrison.entity.DeviceMessageBean; |
||||
import com.mh.garrison.entity.ServiceBean; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: WaterFastJson |
||||
* @Description:TODO(解析水表报文记录) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 下午2:00:51 |
||||
* |
||||
*/ |
||||
public class WaterFastJson { |
||||
|
||||
public String analysisFastJson(String receiveData) { |
||||
|
||||
DeviceMessageBean deviceMessageBean = new DeviceMessageBean(); |
||||
ServiceBean serviceBean = new ServiceBean(); |
||||
DataBean dataBean = new DataBean(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(receiveData); |
||||
|
||||
// 解析第一层
|
||||
deviceMessageBean.setNotiFyType(jsonObject.getString("notifyType")); |
||||
deviceMessageBean.setServiceBean(jsonObject.getString("service")); |
||||
deviceMessageBean.setDeviceId(jsonObject.getString("deviceId")); |
||||
deviceMessageBean.setGatewayId(jsonObject.getString("gatewayId")); |
||||
|
||||
// 解析第二层
|
||||
JSONObject serviceJson = jsonObject.getJSONObject("service"); |
||||
serviceBean.setServiceId(serviceJson.getString("serviceId")); |
||||
serviceBean.setServiceType(serviceJson.getString("serviceType")); |
||||
serviceBean.setDataBean(serviceJson.getString("data")); |
||||
serviceBean.setEventTime(serviceJson.getString("eventTime")); |
||||
|
||||
// 解析第三层
|
||||
JSONObject dataJson = serviceJson.getJSONObject("data"); |
||||
dataBean.setMeterId(dataJson.getString("meterId")); |
||||
dataBean.setOnlineType(dataJson.getString("onlineType")); |
||||
dataBean.setOnlineCode(dataJson.getString("onlineCode")); |
||||
|
||||
return dataBean.getOnlineCode(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.mh.garrison.mapper.DeviceMapper; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: DeviceService |
||||
* @Description:TODO(修改更新发送拉合闸命令服务) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年10月15日 下午5:21:01 |
||||
* |
||||
*/ |
||||
@Service |
||||
public class DeviceService { |
||||
|
||||
@Autowired |
||||
private DeviceMapper deviceMapper; |
||||
|
||||
public List<Map<String,Object>> exeProcedure(Map<String, Object> device_num) { |
||||
return deviceMapper.exeProcedure(device_num); |
||||
} |
||||
|
||||
public Integer findPlatform(String meterID) { |
||||
return deviceMapper.findPlatform(meterID); |
||||
} |
||||
|
||||
|
||||
public void updatePlatform(String meterID) { |
||||
deviceMapper.updatePlatform(meterID); |
||||
} |
||||
|
||||
public List<Map<String,Object>> exeAddStateProcedure(Map<String, Object> maps) { |
||||
return deviceMapper.exeAddStateProcedure(maps); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.mh.garrison.entity.MSGEntity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MSGService |
||||
* @Description:TODO(短信服务接口类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:34:03 |
||||
* |
||||
*/ |
||||
public interface MSGService { |
||||
|
||||
List<MSGEntity> queryMSGList(); |
||||
|
||||
String updateSysSms(String isSend, String cellphone, int sendTime, String remark); |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.mh.garrison.entity.MeterHistoryBean; |
||||
import com.mh.garrison.mapper.MeterHistoryMapper; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MeterHistoryService |
||||
* @Description:TODO 对NB电表流水记录的插入 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年9月29日 上午8:33:03 |
||||
* |
||||
*/ |
||||
@Service |
||||
public class MeterHistoryService { |
||||
|
||||
@Autowired |
||||
private MeterHistoryMapper meterHistoryMapper; |
||||
|
||||
// 插入数据进入流水表
|
||||
public int insertAll(MeterHistoryBean meterHistoryBean) throws Exception { |
||||
int i; |
||||
i = meterHistoryMapper.insertAll(meterHistoryBean); |
||||
if (i == 1) { |
||||
// throw new IllegalArgumentException("sang已存在,数据不会回滚");
|
||||
} |
||||
return i; |
||||
} |
||||
|
||||
public int checkHistory(MeterHistoryBean meterHistoryBean) { |
||||
// TODO Auto-generated method stub
|
||||
return meterHistoryMapper.checkHistory(meterHistoryBean); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Isolation; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mh.garrison.entity.MeterNowBean; |
||||
import com.mh.garrison.mapper.MeterNowMapper; |
||||
|
||||
@Service |
||||
public class MeterNowService { |
||||
|
||||
@Autowired |
||||
private MeterNowMapper meterNowMapper; |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public int checkMeterNow(MeterNowBean meterNowBean) { |
||||
return meterNowMapper.checkMeterNow(meterNowBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public int checkMeterID(MeterNowBean meterNowBean) { |
||||
return meterNowMapper.checkMeterId(meterNowBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public <T> int insertAll(T meterNowBean) { |
||||
return meterNowMapper.insertAll(meterNowBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public <T> int updateAll(T threeMeterNowBean) { |
||||
return meterNowMapper.updateAll(threeMeterNowBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public String execPro_calc_meter() { |
||||
return meterNowMapper.exePro_calc_Meter(); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public String findHouse(String meterID) { |
||||
// TODO Auto-generated method stub
|
||||
return meterNowMapper.findHouse(meterID); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public String findHouse1(String meterID) { |
||||
// TODO Auto-generated method stub
|
||||
return meterNowMapper.findHouse1(meterID); |
||||
} |
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public String findBuildingName1(String device_num) { |
||||
// TODO Auto-generated method stub
|
||||
return meterNowMapper.findBuildingName1(device_num); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public String findBuildingName(String device_num) { |
||||
// TODO Auto-generated method stub
|
||||
return meterNowMapper.findBuildingName(device_num); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,noRollbackFor=Exception.class) |
||||
public <T> int checkMeterId(T threeMeterNowBean) { |
||||
// TODO Auto-generated method stub
|
||||
return meterNowMapper.checkMeterId(threeMeterNowBean); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Isolation; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mh.garrison.entity.MeterNowBean; |
||||
import com.mh.garrison.mapper.MeterMapper; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MeterService |
||||
* @Description:TODO(调用MeterMapper,查询出数据内容) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年9月4日 下午5:10:44 |
||||
* |
||||
*/ |
||||
@Service |
||||
public class MeterService { |
||||
|
||||
@Autowired |
||||
private MeterMapper meterMapper; |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<MeterNowBean> findAllMeterNow(){ |
||||
return meterMapper.findAllMeterNow(); |
||||
} |
||||
|
||||
|
||||
public Integer selectPlatformType(String houseNum, String deviceNum) { |
||||
return meterMapper.selectPlatformType(houseNum, deviceNum); |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.mh.garrison.entity.OrderEntity; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: OrderService |
||||
* @Description:TODO(指令服务类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午10:46:06 |
||||
* |
||||
*/ |
||||
public interface OrderService { |
||||
|
||||
List<OrderEntity> queryOrderList(); |
||||
|
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Isolation; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mh.garrison.entity.WaterDayBean; |
||||
import com.mh.garrison.entity.WaterHistoryBean; |
||||
import com.mh.garrison.mapper.WaterDayMapper; |
||||
|
||||
/** |
||||
* service 层 |
||||
* @ClassName: WaterDayService |
||||
* @Description:TODO 调用waterDayMapper,实现增删查改 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月3日 下午3:56:40 |
||||
* |
||||
*/ |
||||
@Service |
||||
public class WaterDayService { |
||||
|
||||
@Autowired |
||||
private WaterDayMapper waterDayMapper; |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<WaterDayBean> findAllWaterDay(){ |
||||
return waterDayMapper.findAllWaterDay(); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int findNotUploadNum() { |
||||
return waterDayMapper.findNotUploadNum(); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<WaterDayBean> findById(String water_id) { |
||||
return waterDayMapper.findByWaterId(water_id); |
||||
} |
||||
|
||||
// 根据时间查询
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<WaterDayBean> findByDate(String water_id, String dateString) { |
||||
return waterDayMapper.findByDate(water_id, dateString); |
||||
} |
||||
|
||||
// 根据时间查询
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<WaterDayBean> findByTime(String dateString) { |
||||
return waterDayMapper.findByTime(dateString); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insert(String water_id) { |
||||
return waterDayMapper.insert(water_id); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insertAll(WaterHistoryBean waterDayBean) { |
||||
return waterDayMapper.insertAll(waterDayBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int update(WaterHistoryBean waterDayBean) { |
||||
return waterDayMapper.update(waterDayBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public boolean updateGrade(WaterDayBean waterDayBean) { |
||||
return waterDayMapper.updateGrade(waterDayBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int delete(String water_id) { |
||||
return waterDayMapper.delete(water_id); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public String exeProcedure(WaterHistoryBean waterDayBean) { |
||||
return waterDayMapper.exeProcedure(waterDayBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public String execProCheack(String waterID) { |
||||
return waterDayMapper.execPro_Cheack_Areas(waterID); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,53 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Primary; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Isolation; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mh.garrison.entity.WaterHistoryBean; |
||||
import com.mh.garrison.mapper.WaterHistoryMapper; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @ClassName: WaterHistoryService |
||||
* @Description:TODO 对waterHistory表进行数据增删查改 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年9月28日 上午9:58:32 |
||||
* |
||||
*/ |
||||
@Service |
||||
@Primary |
||||
public class WaterHistoryService { |
||||
|
||||
@Autowired |
||||
private WaterHistoryMapper waterHistoryMapper; |
||||
|
||||
// 检查history表中是否有数据
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int checkHistorySame(WaterHistoryBean waterHistoryBean) { |
||||
return waterHistoryMapper.checkSame(waterHistoryBean); |
||||
} |
||||
|
||||
// 插入水表历史数据
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insertAll(WaterHistoryBean waterHistoryBean) { |
||||
return waterHistoryMapper.insertAll(waterHistoryBean); |
||||
} |
||||
|
||||
// 如果存在同样的数据进行数据更新
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int update(WaterHistoryBean waterHistoryBean) { |
||||
return waterHistoryMapper.update(waterHistoryBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int checkSame(WaterHistoryBean wtHistoryBean) { |
||||
// TODO Auto-generated method stub
|
||||
return waterHistoryMapper.checkSame(wtHistoryBean); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,106 @@
|
||||
package com.mh.garrison.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Primary; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Isolation; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.mh.garrison.entity.WaterBean; |
||||
import com.mh.garrison.mapper.WaterMapper; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @ClassName: WaterService |
||||
* @Description:调用WaterMapper中的方法,实现增删查改 |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2018年8月2日 下午3:10:31 |
||||
* |
||||
*/ |
||||
@Service |
||||
@Primary |
||||
public class WaterServices { |
||||
|
||||
@Autowired |
||||
private WaterMapper waterMapper; |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public List<WaterBean> findAll(){ |
||||
return waterMapper.findAllWater(); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public WaterBean findById(String waterId) { |
||||
return waterMapper.findByWaterId(waterId); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insert(String waterId) { |
||||
return waterMapper.insert(waterId); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insertAll(WaterBean waterBean) { |
||||
return waterMapper.insertAll(waterBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int update(WaterBean waterBean) { |
||||
return waterMapper.update(waterBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int delete(String waterId) { |
||||
return waterMapper.delete(waterId); |
||||
} |
||||
|
||||
// 查询IMEI号 2018-09-28 by ljf
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public String findImei(String waterId) { |
||||
return waterMapper.findImei(waterId); |
||||
} |
||||
|
||||
// 查询房间号 2018-09-28 by ljf
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public String findHouse(String waterId) { |
||||
return waterMapper.findHouse(waterId); |
||||
} |
||||
|
||||
// 查询是否有数据 2018-09-28 by ljf
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int findNowSum(String waterId) { |
||||
return waterMapper.findResult(waterId); |
||||
} |
||||
|
||||
// 往水表实时表中插入数据 2018-09-28 by ljf
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insertNow(WaterBean waterBean) { |
||||
return waterMapper.insertWtNowAll(waterBean); |
||||
} |
||||
|
||||
// 实时水表数据存在相同数据,进行更新 2018-09-28 by ljf
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int updateWtNow(WaterBean waterBean) { |
||||
System.out.println(waterBean.toString()); |
||||
return waterMapper.updateWtNow(waterBean); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int findResult(String waterID) { |
||||
// TODO Auto-generated method stub
|
||||
return waterMapper.findResult(waterID); |
||||
} |
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class) |
||||
public int insertWtNowAll(WaterBean water) { |
||||
// TODO Auto-generated method stub
|
||||
return waterMapper.insertWtNowAll(water); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.mh.garrison.service.impl; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.mh.garrison.entity.MSGEntity; |
||||
import com.mh.garrison.mapper.MSGMapper; |
||||
import com.mh.garrison.service.MSGService; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: MSGServiceImpl |
||||
* @Description:TODO(短信服务接口实现类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午9:35:02 |
||||
* |
||||
*/ |
||||
@Service |
||||
public class MSGServiceImpl implements MSGService { |
||||
|
||||
private final MSGMapper msgMapper; |
||||
|
||||
public MSGServiceImpl(MSGMapper msgMapper) { |
||||
// TODO Auto-generated constructor stub
|
||||
this.msgMapper = msgMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<MSGEntity> queryMSGList() { |
||||
// TODO Auto-generated method stub
|
||||
return msgMapper.queryMSGList(); |
||||
} |
||||
|
||||
@Override |
||||
public String updateSysSms(String isSend, String cellphone, int sendTime, String remark) { |
||||
// TODO Auto-generated method stub
|
||||
int a = msgMapper.updateSysSms(isSend,cellphone, sendTime, remark); |
||||
if (a != 0) { |
||||
return "success"; |
||||
} else { |
||||
return "fail"; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.mh.garrison.service.impl; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.mh.garrison.entity.OrderEntity; |
||||
import com.mh.garrison.mapper.OrderMapper; |
||||
import com.mh.garrison.service.OrderService; |
||||
|
||||
/** |
||||
* |
||||
* @ClassName: OrderServiceImpl |
||||
* @Description:TODO(指令服务实现类) |
||||
* @author: 铭汉科技—LJF |
||||
* @date: 2020年7月20日 上午10:47:15 |
||||
* |
||||
*/ |
||||
|
||||
@Service |
||||
public class OrderServiceImpl implements OrderService { |
||||
|
||||
private final OrderMapper orderMapper; |
||||
public OrderServiceImpl(OrderMapper orderMapper) { |
||||
// TODO Auto-generated constructor stub
|
||||
this.orderMapper = orderMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<OrderEntity> queryOrderList() { |
||||
// TODO Auto-generated method stub
|
||||
return orderMapper.queryOrderList(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
#数据库访问 |
||||
spring: |
||||
datasource: |
||||
name: druidDataSource |
||||
type: com.alibaba.druid.pool.DruidDataSource |
||||
druid: |
||||
# 生产配置 |
||||
# url: jdbc:sqlserver://134.175.248.88:2008;DatabaseName=yjc_jingbeiqu |
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
||||
# username: sa |
||||
# password: mhtech@803 |
||||
# 测试配置 |
||||
url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=yjc_jingbeiqu |
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
||||
username: sa |
||||
password: mh@803 |
||||
filters: stat,wall,config |
||||
max-active: 100 |
||||
initial-size: 1 |
||||
max-wait: 60000 |
||||
min-idle: 1 |
||||
time-between-eviction-runs-millis: 60000 |
||||
min-evictable-idle-time-millis: 300000 |
||||
validation-query: select 'x' |
||||
test-while-idle: true |
||||
test-on-borrow: false |
||||
test-on-return: false |
||||
pool-prepared-statements: true |
||||
max-pool-prepared-statement-per-connection-size: 20 |
||||
server: |
||||
port: 8764 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
package com.mh.garrison; |
||||
|
||||
import com.mh.garrison.job.NewDealMeterLogJob; |
||||
import com.mh.garrison.job.SendOrderJob; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
||||
@SpringBootTest |
||||
class GarrisonApplicationTests { |
||||
|
||||
@Test |
||||
void contextLoads() { |
||||
} |
||||
|
||||
@Autowired |
||||
private NewDealMeterLogJob newDealMeterLogJob; |
||||
|
||||
@Autowired |
||||
private SendOrderJob sendOrderJob; |
||||
|
||||
@Test |
||||
public void testNewDealMeter() { |
||||
newDealMeterLogJob.dealMeterLogJob(); |
||||
} |
||||
|
||||
@Test |
||||
public void testSendOrder() { |
||||
sendOrderJob.sendOrder(); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue