qzyReal 1 year ago
commit
f573ee7c98
51 changed files with 2492 additions and 0 deletions
  1. 33 0
      .gitignore
  2. BIN
      .mvn/wrapper/maven-wrapper.jar
  3. 18 0
      .mvn/wrapper/maven-wrapper.properties
  4. 316 0
      mvnw
  5. 188 0
      mvnw.cmd
  6. 111 0
      pom.xml
  7. 72 0
      src/main/java/com/gzlh/WeighbridgeServerApplication.java
  8. 67 0
      src/main/java/com/gzlh/api/CheckCarNumberBO.java
  9. 23 0
      src/main/java/com/gzlh/api/OpenApi.java
  10. 14 0
      src/main/java/com/gzlh/config/ApplicationConfig.java
  11. 18 0
      src/main/java/com/gzlh/config/ModuleEnum.java
  12. 5 0
      src/main/java/com/gzlh/led/LedServer.java
  13. 17 0
      src/main/java/com/gzlh/led/brand/LedBrandType.java
  14. 38 0
      src/main/java/com/gzlh/led/client/LedClientHandler.java
  15. 109 0
      src/main/java/com/gzlh/led/client/LedNettyConfig.java
  16. 21 0
      src/main/java/com/gzlh/led/factory/LedFactory.java
  17. 13 0
      src/main/java/com/gzlh/led/handler/ILedHandler.java
  18. 42 0
      src/main/java/com/gzlh/led/handler/impl/LedHandlerYangBandV4d2.java
  19. 15 0
      src/main/java/com/gzlh/led/properties/LedPropertiesConfig.java
  20. 39 0
      src/main/java/com/gzlh/led/utils/CRC16.java
  21. 15 0
      src/main/java/com/gzlh/led/utils/ColorConver.java
  22. 50 0
      src/main/java/com/gzlh/led/utils/YangBandPackage.java
  23. 20 0
      src/main/java/com/gzlh/red/brand/RedBrandType.java
  24. 47 0
      src/main/java/com/gzlh/red/client/RedClientHandler.java
  25. 98 0
      src/main/java/com/gzlh/red/client/RedNettyConfig.java
  26. 18 0
      src/main/java/com/gzlh/red/config/RedPropertiesConfig.java
  27. 21 0
      src/main/java/com/gzlh/red/factory/RedFactory.java
  28. 10 0
      src/main/java/com/gzlh/red/handler/IRedHandler.java
  29. 62 0
      src/main/java/com/gzlh/red/handler/impl/RedHandlerSoarDAM0404.java
  30. 22 0
      src/main/java/com/gzlh/task/BeatTask.java
  31. 30 0
      src/main/java/com/gzlh/task/CleanTask.java
  32. 25 0
      src/main/java/com/gzlh/task/UploadTask.java
  33. 24 0
      src/main/java/com/gzlh/utils/NettyDecoder.java
  34. 41 0
      src/main/java/com/gzlh/utils/ResultJson.java
  35. 8 0
      src/main/java/com/gzlh/utils/WeightCacheManager.java
  36. 100 0
      src/main/java/com/gzlh/utils/WordHandlerUtils.java
  37. 26 0
      src/main/java/com/gzlh/utils/XorUtils.java
  38. 20 0
      src/main/java/com/gzlh/weighbridge/brand/WeighbridgeBrandType.java
  39. 42 0
      src/main/java/com/gzlh/weighbridge/client/WeighbridgeClientHandler.java
  40. 96 0
      src/main/java/com/gzlh/weighbridge/client/WeighbridgeNettyConfig.java
  41. 18 0
      src/main/java/com/gzlh/weighbridge/config/WeighbridgePropertiesConfig.java
  42. 18 0
      src/main/java/com/gzlh/weighbridge/factory/WeighbridgeFactory.java
  43. 12 0
      src/main/java/com/gzlh/weighbridge/handler/IWeighbridgeHandler.java
  44. 79 0
      src/main/java/com/gzlh/weighbridge/handler/impl/WeighbridgeHandlerKeLi.java
  45. 84 0
      src/main/java/com/gzlh/weighbridge/server/CacheManager.java
  46. 43 0
      src/main/java/com/gzlh/weighbridge/server/CheckManager.java
  47. 10 0
      src/main/java/com/gzlh/weighbridge/server/Count.java
  48. 61 0
      src/main/java/com/gzlh/weighbridge/server/StartHandler.java
  49. 86 0
      src/main/java/com/gzlh/weighbridge/server/WeighbridgeReqService.java
  50. 22 0
      src/main/resources/application.yml
  51. 125 0
      src/main/resources/logback.xml

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

BIN
.mvn/wrapper/maven-wrapper.jar


+ 18 - 0
.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

+ 316 - 0
mvnw

@@ -0,0 +1,316 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+  if [ -f /usr/local/etc/mavenrc ] ; then
+    . /usr/local/etc/mavenrc
+  fi
+
+  if [ -f /etc/mavenrc ] ; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ] ; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  MINGW*) mingw=true;;
+  Darwin*) darwin=true
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+    if [ -z "$JAVA_HOME" ]; then
+      if [ -x "/usr/libexec/java_home" ]; then
+        export JAVA_HOME="`/usr/libexec/java_home`"
+      else
+        export JAVA_HOME="/Library/Java/Home"
+      fi
+    fi
+    ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+      PRG="$link"
+    else
+      PRG="`dirname "$PRG"`/$link"
+    fi
+  done
+
+  saveddir=`pwd`
+
+  M2_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  M2_HOME=`cd "$M2_HOME" && pwd`
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="`which javac`"
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=`which readlink`
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+      if $darwin ; then
+        javaHome="`dirname \"$javaExecutable\"`"
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+      else
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
+      fi
+      javaHome="`dirname \"$javaExecutable\"`"
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="`\\unset -f command; \\command -v java`"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+  if [ -z "$1" ]
+  then
+    echo "Path not specified to find_maven_basedir"
+    return 1
+  fi
+
+  basedir="$1"
+  wdir="$1"
+  while [ "$wdir" != '/' ] ; do
+    if [ -d "$wdir"/.mvn ] ; then
+      basedir=$wdir
+      break
+    fi
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+    if [ -d "${wdir}" ]; then
+      wdir=`cd "$wdir/.."; pwd`
+    fi
+    # end of workaround
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' < "$1")"
+  fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+  exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
+    fi
+else
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+    fi
+    if [ -n "$MVNW_REPOURL" ]; then
+      jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+    else
+      jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+    fi
+    while IFS="=" read key value; do
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+      esac
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Downloading from: $jarUrl"
+    fi
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+    if $cygwin; then
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+    fi
+
+    if command -v wget > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found wget ... using wget"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+        else
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+        fi
+    elif command -v curl > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found curl ... using curl"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            curl -o "$wrapperJarPath" "$jarUrl" -f
+        else
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+        fi
+
+    else
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Falling back to using Java to download"
+        fi
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        # For Cygwin, switch paths to Windows format before running javac
+        if $cygwin; then
+          javaClass=`cygpath --path --windows "$javaClass"`
+        fi
+        if [ -e "$javaClass" ]; then
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Compiling MavenWrapperDownloader.java ..."
+                fi
+                # Compiling the Java class
+                ("$JAVA_HOME/bin/javac" "$javaClass")
+            fi
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                # Running the downloader
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Running MavenWrapperDownloader.java ..."
+                fi
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+            fi
+        fi
+    fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+  echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  $MAVEN_DEBUG_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" \
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 188 - 0
mvnw.cmd

@@ -0,0 +1,188 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Found %WRAPPER_JAR%
+    )
+) else (
+    if not "%MVNW_REPOURL%" == "" (
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+    )
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
+        echo Downloading from: %DOWNLOAD_URL%
+    )
+
+    powershell -Command "&{"^
+		"$webclient = new-object System.Net.WebClient;"^
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+		"}"^
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+		"}"
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Finished downloading %WRAPPER_JAR%
+    )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+  %JVM_CONFIG_MAVEN_PROPS% ^
+  %MAVEN_OPTS% ^
+  %MAVEN_DEBUG_OPTS% ^
+  -classpath %WRAPPER_JAR% ^
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%

+ 111 - 0
pom.xml

@@ -0,0 +1,111 @@
+<?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.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.gzlh</groupId>
+    <artifactId>weighbridge-server</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>weighbridge-server</name>
+    <description>Demo project for Spring Boot</description>
+    <properties>
+        <java.version>8</java.version>
+        <java.run.main.class>com.gzlh.WeighbridgeServerApplication</java.run.main.class>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.logging.log4j</groupId>
+                    <artifactId>log4j-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.logging.log4j</groupId>
+                    <artifactId>log4j-to-slf4j</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+            <version>4.1.65.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.7.15</version>
+        </dependency>
+
+    </dependencies>
+
+
+    <!-- 构建配置 -->
+    <build>
+        <finalName>weighbridge-server</finalName>
+        <!-- 配置资源目录  -->
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.*</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>lib/</classpathPrefix>
+                            <mainClass>${java.run.main.class}</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <!-- 拷贝依赖的jar包到lib目录 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>
+                                ${project.build.directory}/lib
+                            </outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 72 - 0
src/main/java/com/gzlh/WeighbridgeServerApplication.java

@@ -0,0 +1,72 @@
+package com.gzlh;
+
+import cn.hutool.core.thread.ThreadUtil;
+import com.gzlh.led.client.LedNettyConfig;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.red.config.RedPropertiesConfig;
+import com.gzlh.weighbridge.client.WeighbridgeNettyConfig;
+
+import com.gzlh.red.client.RedNettyConfig;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.ApplicationPidFileWriter;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.Properties;
+
+@SpringBootApplication
+@EnableAsync
+@EnableScheduling
+@EnableConfigurationProperties
+public class WeighbridgeServerApplication implements CommandLineRunner {
+    @Resource
+    private WeighbridgeNettyConfig weighbridgeNettyConfig;
+    @Resource
+    private LedNettyConfig ledNettyConfig;
+    @Resource
+    private RedNettyConfig redNettyConfig;
+    @Resource
+    private RedPropertiesConfig redPropertiesConfig;
+    @Resource
+    private LedPropertiesConfig ledPropertiesConfig;
+    @Resource
+    private LedFactory ledFactory;
+
+
+    public static void main(String[] args) {
+        Properties properties = System.getProperties();
+        String rootPath = properties.getProperty("user.dir");
+        SpringApplication application = new SpringApplication(WeighbridgeServerApplication.class);
+        application.addListeners(new ApplicationPidFileWriter(rootPath + File.separator + "app.pid"));
+        application.run(args);
+    }
+
+
+    @Override
+    public void run(String... args) {
+        ThreadUtil.execute(() -> weighbridgeNettyConfig.connect());
+        if (ledPropertiesConfig.isEnable()) {
+            ThreadUtil.execute(() -> ledNettyConfig.connect());
+            String msg = "园内称重";
+            ledFactory.handler(ledPropertiesConfig.getBrand()).sendMsg(msg);
+        }
+        if (redPropertiesConfig.isEnable()) {
+            ThreadUtil.execute(() -> redNettyConfig.connect());
+        }
+    }
+
+    @PreDestroy
+    public void close() {
+        weighbridgeNettyConfig.close();
+        ledNettyConfig.close();
+        redNettyConfig.close();
+    }
+}

+ 67 - 0
src/main/java/com/gzlh/api/CheckCarNumberBO.java

@@ -0,0 +1,67 @@
+package com.gzlh.api;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+
+
+public class CheckCarNumberBO implements Serializable {
+    /**
+     * 当前设别车牌的通道名称
+     */
+    private String ChannelName;
+    private String CarNumber;
+    /**
+     * 1 入场 2 出场
+     */
+    private int InOrOut;
+    private String ImageData;
+    /**
+     * 操作员
+     */
+    private String OperationUserName;
+
+    @JsonProperty("ChannelName")
+    public String getChannelName() {
+        return ChannelName;
+    }
+
+    public void setChannelName(String channelName) {
+        ChannelName = channelName;
+    }
+
+    @JsonProperty("CarNumber")
+    public String getCarNumber() {
+        return CarNumber;
+    }
+
+    public void setCarNumber(String carNumber) {
+        CarNumber = carNumber;
+    }
+
+    @JsonProperty("InOrOut")
+    public int getInOrOut() {
+        return InOrOut;
+    }
+
+    public void setInOrOut(int inOrOut) {
+        InOrOut = inOrOut;
+    }
+
+    @JsonProperty("ImageData")
+    public String getImageData() {
+        return ImageData;
+    }
+
+    public void setImageData(String imageData) {
+        ImageData = imageData;
+    }
+
+    public String getOperationUserName() {
+        return OperationUserName;
+    }
+
+    public void setOperationUserName(String operationUserName) {
+        OperationUserName = operationUserName;
+    }
+}

+ 23 - 0
src/main/java/com/gzlh/api/OpenApi.java

@@ -0,0 +1,23 @@
+package com.gzlh.api;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.gzlh.weighbridge.server.WeighbridgeReqService;
+import com.gzlh.utils.ResultJson;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+@RestController
+@RequestMapping("open")
+public class OpenApi {
+    @Resource
+    private WeighbridgeReqService reqService;
+
+
+}

+ 14 - 0
src/main/java/com/gzlh/config/ApplicationConfig.java

@@ -0,0 +1,14 @@
+package com.gzlh.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@ConfigurationProperties(prefix = "application")
+@Data
+@Configuration
+public class ApplicationConfig {
+  private String serverUrl;
+  private String channelName;
+
+}

+ 18 - 0
src/main/java/com/gzlh/config/ModuleEnum.java

@@ -0,0 +1,18 @@
+package com.gzlh.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public enum ModuleEnum {
+    LED_MODULE("led显示屏","led"),
+    WEIGHBRIDGE_MODULE("地磅","weighbridge"),
+    INFRARED_MODULE("红外","infrared"),
+    TRAFFIC_MODULE("红绿灯","traffic"),
+    GATE_MODULE("道闸","gate"),
+
+    ;
+    private String moduleZh;
+    private String moduleEn;
+}

+ 5 - 0
src/main/java/com/gzlh/led/LedServer.java

@@ -0,0 +1,5 @@
+package com.gzlh.led;
+
+public class LedServer {
+
+}

+ 17 - 0
src/main/java/com/gzlh/led/brand/LedBrandType.java

@@ -0,0 +1,17 @@
+package com.gzlh.led.brand;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum  LedBrandType {
+
+    SHANGHAI_YANGBAND_BX(1000,"上海仰邦科技股份有限公司BX-5(M)K/6K(YY)-V4.2")
+
+    ;
+
+
+    private int code;
+    private String brand;
+}

+ 38 - 0
src/main/java/com/gzlh/led/client/LedClientHandler.java

@@ -0,0 +1,38 @@
+package com.gzlh.led.client;
+
+import cn.hutool.core.util.StrUtil;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@ChannelHandler.Sharable
+public class LedClientHandler extends SimpleChannelInboundHandler<String> {
+
+    private LedNettyConfig ledNettyConfig;
+
+    public LedClientHandler(LedNettyConfig ledNettyConfig) {
+        this.ledNettyConfig = ledNettyConfig;
+    }
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
+//        log.info("LED 客户端收到消息:" + msg);
+
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        log.error("led 客户端 连接断开,进行重连");
+        ledNettyConfig.connect();
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+        ctx.close();
+    }
+
+}
+

+ 109 - 0
src/main/java/com/gzlh/led/client/LedNettyConfig.java

@@ -0,0 +1,109 @@
+package com.gzlh.led.client;
+
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.red.config.RedPropertiesConfig;
+import com.gzlh.utils.NettyDecoder;
+import com.gzlh.utils.XorUtils;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+
+@Configuration
+@Slf4j
+public class LedNettyConfig  {
+
+    @Resource
+    private LedPropertiesConfig ledConfig;
+
+    @Autowired
+    private LedClientHandler ledClientHandler;
+    @Resource
+    LedFactory ledFactory;
+    @Resource
+    private LedPropertiesConfig ledPropertiesConfig;
+
+    private Channel channel;
+
+    @Bean("ledBootstrap")
+    public Bootstrap bootstrap() {
+       String host= ledConfig.getHost();
+       int port=ledConfig.getPort();
+        log.info("初始化 led:{},{}",host,port);
+        EventLoopGroup group = new NioEventLoopGroup();
+        return new Bootstrap()
+                .group(group)
+                .channel(NioSocketChannel.class)
+                .remoteAddress(host, port)
+                .option(ChannelOption.SO_KEEPALIVE, true)
+                .handler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    protected void initChannel(SocketChannel ch)  {
+                        try {
+                            ChannelPipeline pipeline = ch.pipeline();
+                            pipeline.addLast( new NettyDecoder());
+                            pipeline.addLast( new NettyDecoder());
+                            pipeline.addLast("handler", ledClientHandler);
+                        }catch (Exception e){
+                            log.info("error connect:{}",e.getMessage());
+                        }
+                    }
+                });
+    }
+
+    @Bean("ledClientHandler")
+    public LedClientHandler ledClientHandler() {
+        return new LedClientHandler(this);
+    }
+
+    public void connect() {
+        String host= ledConfig.getHost();
+        int port=ledConfig.getPort();
+        ChannelFuture future = bootstrap().connect();
+        future.addListener((ChannelFutureListener) future1 -> {
+            if (future1.isSuccess()) {
+                channel = future1.channel();
+                log.info("led 串口服务器连接成功,{},{}",host,port);
+            } else {
+                log.error("-------------led 连接服务器失败,{},{}-----------,进行重连",host,port);
+                future1.channel().eventLoop().schedule(this::connect, 5, TimeUnit.SECONDS);
+            }
+        });
+        try {
+            future.channel().closeFuture().sync();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+    public void send(String message) {
+        if (channel != null && channel.isActive()) {
+            ByteBuf bufff = Unpooled.buffer();
+            bufff.writeBytes(XorUtils.hexString2Bytes(message));
+            channel.writeAndFlush(bufff);
+        } else {
+            log.error("未建立连接,无法发送消息");
+        }
+    }
+
+    public void close() {
+        if (channel != null) {
+            channel.close();
+        }
+    }
+}
+

+ 21 - 0
src/main/java/com/gzlh/led/factory/LedFactory.java

@@ -0,0 +1,21 @@
+package com.gzlh.led.factory;
+
+
+
+import com.gzlh.led.handler.ILedHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class LedFactory {
+    @Autowired
+    private List<ILedHandler>handlers;
+
+    public ILedHandler handler(int code){
+       return handlers.stream().filter(h->h.brandType().getCode()==code)
+                .findAny().orElseThrow(()->new IllegalArgumentException("不支持交互"));
+    }
+
+}

+ 13 - 0
src/main/java/com/gzlh/led/handler/ILedHandler.java

@@ -0,0 +1,13 @@
+package com.gzlh.led.handler;
+
+import com.gzlh.led.brand.LedBrandType;
+
+import io.netty.channel.ChannelHandlerContext;
+
+public interface ILedHandler {
+
+    LedBrandType brandType();
+
+    void sendMsg(int positionLine, String content);
+    void sendMsg(String content);
+}

+ 42 - 0
src/main/java/com/gzlh/led/handler/impl/LedHandlerYangBandV4d2.java

@@ -0,0 +1,42 @@
+package com.gzlh.led.handler.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.gzlh.led.brand.LedBrandType;
+import com.gzlh.led.client.LedNettyConfig;
+import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.led.utils.ColorConver;
+import com.gzlh.led.utils.YangBandPackage;
+import com.gzlh.red.brand.RedBrandType;
+import com.gzlh.utils.WordHandlerUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * 上海仰邦科技股份有限公司BX-5(M)K/6K(YY)-V4.2 led发送处理器
+ */
+@Service
+@Slf4j
+public class LedHandlerYangBandV4d2 implements ILedHandler {
+
+    @Resource
+    private LedNettyConfig ledNettyConfig;
+
+    @Override
+    public LedBrandType brandType() {
+        return LedBrandType.SHANGHAI_YANGBAND_BX;
+    }
+
+    @Override
+    public void sendMsg(int positionLine,String content) {
+        //log.info(RedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "发送消息:{}", content);
+        String pack = YangBandPackage.buildPackage(positionLine,ColorConver.NU_TO_HEX.get(1) + WordHandlerUtils.msgToASCII(content));
+        pack= StrUtil.replace(pack," ","");
+        ledNettyConfig.send(pack);
+    }
+    @Override
+    public void sendMsg(String content) {
+        sendMsg(1,content);
+    }
+}

+ 15 - 0
src/main/java/com/gzlh/led/properties/LedPropertiesConfig.java

@@ -0,0 +1,15 @@
+package com.gzlh.led.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@ConfigurationProperties(prefix = "led")
+@Configuration
+@Data
+public class LedPropertiesConfig {
+    private String host;
+    private int port;
+    private int brand;
+    private boolean enable;
+}

+ 39 - 0
src/main/java/com/gzlh/led/utils/CRC16.java

@@ -0,0 +1,39 @@
+package com.gzlh.led.utils;
+
+public class CRC16 {
+    public static String crc16(int[] data, int size) {
+        char crc = 0x0;
+        int i, j;
+        int data_t;
+        for (j = 0; j < size; j++) {
+            data_t = data[j];
+            crc = (char) ((data_t & 0xFF) ^ (crc));
+            for (i = 0; i < 8; i++) {
+                if ((crc & 0x1) == 1) {
+                    crc = (char) ((crc >> 1) ^ (0xa001));
+                } else {
+                    crc >>= 1;
+                }
+            }
+        }
+        char value= (char) ((crc >> 8) | (crc << 8));
+        char m;
+        StringBuilder sb=new StringBuilder();
+        for (i = 3; i >= 0; i--) {
+            m = (char) (((value >> (i * 4)) & (0x000F)));
+            if ((m >= 0) && (m <= 9)) {
+                m += '0';
+            } else if ((m >= 10) && (m <= 15)) {
+                m = (char) (m - 10 + 'A');
+            }
+            sb.append(m);
+            if ((i % 2) == 0) {
+                System.out.print(" ");
+                if (i == 0) break;
+            }
+        }
+        return sb.toString();
+    }
+
+
+}

+ 15 - 0
src/main/java/com/gzlh/led/utils/ColorConver.java

@@ -0,0 +1,15 @@
+package com.gzlh.led.utils;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public interface ColorConver {
+    Map<Integer, String> NU_TO_HEX = new LinkedHashMap<Integer, String>() {
+        {
+            this.put(0,"5C 43 31 ");
+            this.put(1,"5C 43 32 ");
+            this.put(2,"5C 43 33 ");
+
+        }
+    };
+}

+ 50 - 0
src/main/java/com/gzlh/led/utils/YangBandPackage.java

@@ -0,0 +1,50 @@
+package com.gzlh.led.utils;
+
+import cn.hutool.core.util.StrUtil;
+
+public class YangBandPackage {
+    /**
+     * 帧头
+     */
+    private static final String HEAD = "a5 a5 a5 a5 a5 a5 a5 a5";
+    /**
+     * 帧尾
+     */
+    private static final String EXT = "5a";
+
+    public static String buildPackage(String dataView) {
+        return buildPackage(1,dataView);
+    }
+
+    public static String buildPackage(int position,String dataView) {
+
+        //包头数据= 前部分+数据域长度(两字节长度)
+        //数据包=帧头+包头数据+数据域+校验包+帧尾;
+        //包头数据=led工作模式+数据域长度(两位)
+        //数据域=显示域+数据域长度+数据设置
+        //包校验=包头数据+数据域的 CRC16校验
+        //01为屏地址
+        String packPrefix = "0"+position+" 00 00 80 00 00 00 00 00 01 51 02";
+        String dataPrefix = "a3 06 01 00 00 00 01";
+        String dataCmd = "06 00 00 00 00 0C 00 20 00 00 00 00 02 00 00 00 00 01 01 01 00 00 0a";
+        String len = Integer.toHexString(dataView.replaceAll(" ", "").length() / 2);
+        String dataLen = (len.length() == 1 ? "0" + len : len) + " 00 00 00";
+        String dataSetting = dataCmd + dataLen + dataView;
+        len = Integer.toHexString(dataSetting.replaceAll(" ", "").length() / 2);
+        String areaDataLen = (len.length() == 1 ? "0" + len : len) + " 00";
+        //数据域
+        String dataStr = dataPrefix + areaDataLen + dataCmd + dataLen + dataView;
+        len = Integer.toHexString(dataStr.replaceAll(" ", "").length() / 2);
+        String packLen = (len.length() == 1 ? "0" + len : len) + " 00";
+        String packData = packPrefix + packLen + dataStr;
+        packData = packData.replaceAll(" ", "");
+        int[] a = new int[packData.length() / 2];
+        for (int i = 0; i < packData.length(); i += 2) {
+            a[i / 2] = Integer.parseInt(packData.substring(i, i + 2), 16);
+        }
+        String crc16 = CRC16.crc16(a, a.length);
+        String str= (HEAD + packData + crc16 + EXT).replaceAll(" ", "")
+                .toLowerCase();
+        return str.replaceAll("(?<=\\G..)(?!$)", " ");
+    }
+}

+ 20 - 0
src/main/java/com/gzlh/red/brand/RedBrandType.java

@@ -0,0 +1,20 @@
+package com.gzlh.red.brand;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 红外内置支持品牌
+ */
+@Getter
+@AllArgsConstructor
+public enum RedBrandType {
+
+    SHANGHAI_YANGBAND_BX(2000,"聚英翱翔电子")
+
+    ;
+
+
+    private int code;
+    private String brand;
+}

+ 47 - 0
src/main/java/com/gzlh/red/client/RedClientHandler.java

@@ -0,0 +1,47 @@
+package com.gzlh.red.client;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.gzlh.red.config.RedPropertiesConfig;
+import com.gzlh.red.factory.RedFactory;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@ChannelHandler.Sharable
+public class RedClientHandler extends SimpleChannelInboundHandler<String> {
+
+    private RedNettyConfig redNettyConfig;
+
+    public RedClientHandler(RedNettyConfig redNettyConfig) {
+        this.redNettyConfig = redNettyConfig;
+    }
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
+      //  log.info("红外客户端收到消息:" + msg);
+        msg = StrUtil.replace(msg, "\u0003", "").replace("\u0002", "");
+        log.info("红外客户端收到消息:" + msg);
+        // 去掉开头和结尾的特殊字符
+        RedPropertiesConfig propertiesConfig = SpringUtil.getBean(RedPropertiesConfig.class);
+        RedFactory redFactory = SpringUtil.getBean(RedFactory.class);
+        redFactory.handler(propertiesConfig.getBrand()).handlerMsg(msg);
+
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        System.out.println("连接断开,进行重连");
+        redNettyConfig.connect();
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+       // ctx.close();
+    }
+
+}
+

+ 98 - 0
src/main/java/com/gzlh/red/client/RedNettyConfig.java

@@ -0,0 +1,98 @@
+package com.gzlh.red.client;
+
+import com.gzlh.red.config.RedPropertiesConfig;
+import com.gzlh.utils.NettyDecoder;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+
+@Configuration
+@Slf4j
+public class RedNettyConfig {
+
+    @Resource
+    private RedPropertiesConfig redConfig;
+
+    @Autowired
+    private RedClientHandler redClientHandler;
+
+    private Channel channel;
+
+    @Bean("RedBoostrap")
+    public Bootstrap bootstrap() {
+       String host= redConfig.getHost();
+       int port=redConfig.getPort();
+        log.info("初始化 red:{},{}",host,port);
+        EventLoopGroup group = new NioEventLoopGroup();
+        return new Bootstrap()
+                .group(group)
+                .channel(NioSocketChannel.class)
+                .remoteAddress(host, port)
+                .option(ChannelOption.SO_KEEPALIVE, true)
+                .handler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    protected void initChannel(SocketChannel ch)  {
+                        try {
+                            ChannelPipeline pipeline = ch.pipeline();
+                            pipeline.addLast( new NettyDecoder());
+                            pipeline.addLast( new StringEncoder(StandardCharsets.UTF_8));
+                            pipeline.addLast("handler", redClientHandler);
+                        }catch (Exception e){
+                            log.info("error connect:{}",e.getMessage());
+                        }
+                    }
+                });
+    }
+
+    @Bean("RedClientHandler")
+    public RedClientHandler redClientHandler() {
+        return new RedClientHandler(this);
+    }
+
+    public void connect() {
+        String host= redConfig.getHost();
+        int port=redConfig.getPort();
+        ChannelFuture future = bootstrap().connect();
+        future.addListener((ChannelFutureListener) future1 -> {
+            if (future1.isSuccess()) {
+                channel = future1.channel();
+                log.info("红外 串口服务器连接成功 ,{},{}",host,port);
+            } else {
+                log.error("--------红外-----连接服务器失败,{},{}-----------,进行重连",host,port);
+                future1.channel().eventLoop().schedule(this::connect, 5, TimeUnit.SECONDS);
+            }
+        });
+        try {
+            future.channel().closeFuture().sync();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void send(String message) {
+        if (channel != null && channel.isActive()) {
+            channel.writeAndFlush(message);
+        } else {
+            log.error("未建立连接,无法发送消息");
+        }
+    }
+
+    public void close() {
+        if (channel != null) {
+            channel.close();
+        }
+    }
+}
+

+ 18 - 0
src/main/java/com/gzlh/red/config/RedPropertiesConfig.java

@@ -0,0 +1,18 @@
+package com.gzlh.red.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@ConfigurationProperties(prefix = "red")
+@Data
+@Configuration
+public class RedPropertiesConfig {
+    private String host;
+    private int port;
+    /**
+     * 品牌
+     */
+    private int brand;
+    private boolean enable=true;
+}

+ 21 - 0
src/main/java/com/gzlh/red/factory/RedFactory.java

@@ -0,0 +1,21 @@
+package com.gzlh.red.factory;
+
+
+
+import com.gzlh.red.handler.IRedHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class RedFactory {
+    @Autowired
+    private List<IRedHandler>handlers;
+
+    public IRedHandler handler(int code){
+       return handlers.stream().filter(h->h.brandType().getCode()==code)
+                .findAny().orElseThrow(()->new IllegalArgumentException("不支持交互"));
+    }
+
+}

+ 10 - 0
src/main/java/com/gzlh/red/handler/IRedHandler.java

@@ -0,0 +1,10 @@
+package com.gzlh.red.handler;
+
+import com.gzlh.red.brand.RedBrandType;
+
+public interface IRedHandler {
+
+    RedBrandType brandType();
+
+    void handlerMsg(String content);
+}

+ 62 - 0
src/main/java/com/gzlh/red/handler/impl/RedHandlerSoarDAM0404.java

@@ -0,0 +1,62 @@
+package com.gzlh.red.handler.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.red.brand.RedBrandType;
+import com.gzlh.red.handler.IRedHandler;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * 聚英翱翔电子 01082899821  聚英翱翔电子,按0,转技术电话
+ * dam0404d 品牌
+ */
+@Service
+@Slf4j
+public class RedHandlerSoarDAM0404 implements IRedHandler {
+    /**
+     * 断开的信号
+     */
+    private final static String FIRST_BREAK_SIGNAL = "01 02 01 02 20 49";
+    private final static String FIRST_LINK_SIGNAL = "01 02 01 03 E1 89";
+
+
+    @Resource
+    LedFactory ledFactory;
+    @Resource
+    private LedPropertiesConfig ledPropertiesConfig;
+
+    @Resource
+    WeighbridgeFactory weighbridgeFactory;
+    @Resource
+    WeighbridgePropertiesConfig weighbridgePropertiesConfig;
+
+
+    @Override
+    public RedBrandType brandType() {
+        return RedBrandType.SHANGHAI_YANGBAND_BX;
+    }
+
+    @Override
+    public void handlerMsg(String content) {
+       // log.info(RedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "对红外处理消息:{}", content);
+        ILedHandler handler = ledFactory.handler(ledPropertiesConfig.getBrand());
+        content = StrUtil.replace(content, " ", "").toUpperCase();
+        //进 被遮挡
+        if (StrUtil.equals(StrUtil.replace(FIRST_BREAK_SIGNAL, " ", ""), content)) {
+            //todo test msg
+            String msg = "请继续往前";
+            handler.sendMsg(msg);
+        }else if (StrUtil.equals(StrUtil.replace(FIRST_LINK_SIGNAL, " ", ""), content)){
+            String msg = "即将称重";
+            handler.sendMsg(msg);
+            weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).startReadMsg();
+        }
+    }
+}

+ 22 - 0
src/main/java/com/gzlh/task/BeatTask.java

@@ -0,0 +1,22 @@
+package com.gzlh.task;
+
+import cn.hutool.http.HttpUtil;
+import com.gzlh.config.ApplicationConfig;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class BeatTask {
+    @Resource
+    private ApplicationConfig applicationConfig;
+
+    @Async
+    @Scheduled(fixedRate = 10000)
+    public void  beat(){
+        HttpUtil.get(applicationConfig.getServerUrl()+"/SysChannelApplication/beat?channelName="+applicationConfig.getChannelName());
+    }
+
+}

+ 30 - 0
src/main/java/com/gzlh/task/CleanTask.java

@@ -0,0 +1,30 @@
+package com.gzlh.task;
+
+import cn.hutool.extra.spring.SpringUtil;
+import cn.hutool.http.HttpUtil;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.annotation.Resource;
+
+@Slf4j
+public class CleanTask implements Runnable {
+    private String serverUrl;
+    private String channelName;
+
+    public CleanTask(String serverUrl, String channelName) {
+        this.serverUrl = serverUrl;
+        this.channelName = channelName;
+    }
+
+    @Override
+    public void run() {
+        HttpUtil.get(serverUrl + "/open/cleanWeighbridge?channel=" + channelName);
+//        log.info("clean finish");
+        LedPropertiesConfig ledPropertiesConfig = SpringUtil.getBean(LedPropertiesConfig.class);
+        LedFactory ledFactory = SpringUtil.getBean(LedFactory.class);
+        String msg = "园内称重";
+        ledFactory.handler(ledPropertiesConfig.getBrand()).sendMsg(msg);
+    }
+}

+ 25 - 0
src/main/java/com/gzlh/task/UploadTask.java

@@ -0,0 +1,25 @@
+package com.gzlh.task;
+
+import cn.hutool.http.HttpUtil;
+import cn.hutool.poi.excel.cell.setters.RichTextCellSetter;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class UploadTask implements Runnable {
+    private String serverUrl;
+    private String channelName;
+    private Integer weight;
+
+    public UploadTask(String serverUrl, String channelName, Integer weight) {
+        this.serverUrl = serverUrl;
+        this.channelName = channelName;
+        this.weight = weight;
+    }
+
+    @Override
+    public void run() {
+        log.info("upload weight req:{},{}", channelName, weight);
+        HttpUtil.get(serverUrl + "/open/reqWeighbridge?channel=" + channelName + "&weight=" + weight);
+        log.info("upload finish");
+    }
+}

+ 24 - 0
src/main/java/com/gzlh/utils/NettyDecoder.java

@@ -0,0 +1,24 @@
+package com.gzlh.utils;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+public class NettyDecoder extends ByteToMessageDecoder {
+    @Override
+    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf msg, List<Object> out) throws Exception {
+        String HEXES = "0123456789ABCDEF";
+        byte[] req = new byte[msg.readableBytes()];
+        msg.readBytes(req);
+        final StringBuilder hex = new StringBuilder(2 * req.length);
+
+        for (int i = 0; i < req.length; i++) {
+            byte b = req[i];
+            hex.append(HEXES.charAt((b & 0xF0) >> 4))
+                    .append(HEXES.charAt((b & 0x0F)));
+        }
+        out.add(hex.toString());
+    }
+}

+ 41 - 0
src/main/java/com/gzlh/utils/ResultJson.java

@@ -0,0 +1,41 @@
+package com.gzlh.utils;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@AllArgsConstructor
+@NoArgsConstructor
+public class ResultJson {
+    /**
+     * 操作状态,大于等于0 为成功
+     */
+    private int status;
+    /**
+     * 状态描述
+     */
+    private String message;
+    /**
+     * 0 不允许,1 允许
+     */
+    private int canpass;
+    /**
+     * 不允许放行的原因
+     */
+    private String reason;
+
+    public static ResultJson success() {
+        return new ResultJson(1, "ok", 1, "");
+    }
+    public static ResultJson success(String msg,String reason) {
+        return new ResultJson(1, msg, 1, reason);
+    }
+
+    public static ResultJson error(String reason) {
+        return new ResultJson(1, "ok", 0, reason);
+    }
+
+}

+ 8 - 0
src/main/java/com/gzlh/utils/WeightCacheManager.java

@@ -0,0 +1,8 @@
+package com.gzlh.utils;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+public class WeightCacheManager {
+
+}

+ 100 - 0
src/main/java/com/gzlh/utils/WordHandlerUtils.java

@@ -0,0 +1,100 @@
+package com.gzlh.utils;
+
+import cn.hutool.core.util.HexUtil;
+import cn.hutool.core.util.StrUtil;
+import com.gzlh.led.utils.CRC16;
+import com.gzlh.led.utils.ColorConver;
+import com.gzlh.led.utils.YangBandPackage;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.nio.charset.Charset;
+
+public class WordHandlerUtils {
+
+
+    public static String msgToASCII(String msg){
+        int len=msg.length();
+        StringBuilder sb=new StringBuilder();
+        for (int i=0;i<len;i++){
+            char ch=msg.charAt(i);
+            String bit =ch+"";
+            if (isChinese(ch)){//中文
+                sb.append(chineseToASCII(bit));
+            }else if (Character.isDigit(ch)){//数字
+                sb.append(Integer.parseInt(bit) + 30);
+            }else if (Character.isLetter(ch)){
+                sb.append(Integer.toHexString(ch));
+            }else if (StrUtil.equals(".", bit)) {
+                sb.append("2E");
+            }
+        }
+        return sb.toString();
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(msgToASCII("8222.2吨"));
+        String pack=YangBandPackage.buildPackage(ColorConver.NU_TO_HEX.get(1)+msgToASCII("8222.2吨"));
+        System.out.println(pack);
+    }
+
+    /**
+     * 中文转ascii
+     * @param zh
+     * @return
+     */
+    private static String chineseToASCII(String zh) {
+        byte[] gb2312Bytes = zh.getBytes(Charset.forName("GB2312"));
+        return bytesToHexString(gb2312Bytes);
+    }
+
+    /**
+     * 红色字体在文字前加代码 5C 43 31,绿色加代码5C 43 32,黄色加代码5C 43 33
+     *
+     * @param weight
+     * @return
+     */
+    private static String numToASCII(int weight) {
+        String str = BigDecimal.valueOf(weight).divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP).toString();
+        int len = str.length();
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < len - 1; i++) {
+            String bit = StrUtil.sub(str, i, i + 1);
+            if (StrUtil.equals(".", bit)) {
+                sb.append("2E").append(" ");
+                continue;
+            }
+            sb.append(Integer.parseInt(bit) + 30).append(" ");
+        }
+        return  sb.toString();
+    }
+
+    private static boolean isChinese(char ch) {
+        Character.UnicodeBlock ub = Character.UnicodeBlock.of(ch);
+        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
+                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
+                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
+                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
+                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
+                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) {
+            return true;
+        }
+        return false;
+    }
+
+
+    private static String bytesToHexString(byte[] bytes) {
+        StringBuilder sb = new StringBuilder();
+        for (byte b : bytes) {
+            String hex = Integer.toHexString(b & 0xFF);
+            if (hex.length() == 1) {
+                sb.append('0');
+            }
+            sb.append(hex.toUpperCase());
+        }
+        return sb.toString();
+    }
+}
+

+ 26 - 0
src/main/java/com/gzlh/utils/XorUtils.java

@@ -0,0 +1,26 @@
+package com.gzlh.utils;
+
+public class XorUtils {
+
+    /**
+     * 十六进制字符串转换成字节数组
+     * @param hexstr 十六进制字符串
+     * @return 字节数组
+     */
+    public static byte[] hexString2Bytes(String src) {
+        int l = src.length() / 2;
+
+        byte[] ret = new byte[l];
+
+        for (int i = 0; i < l; i++) {
+
+            ret[i] = (byte) Integer.valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue();
+
+        }
+
+        return ret;
+
+    }
+
+
+}

+ 20 - 0
src/main/java/com/gzlh/weighbridge/brand/WeighbridgeBrandType.java

@@ -0,0 +1,20 @@
+package com.gzlh.weighbridge.brand;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 地磅内置支持品牌
+ */
+@Getter
+@AllArgsConstructor
+public enum WeighbridgeBrandType {
+
+    NINGBO_KELI(3000,"宁波科力")
+
+    ;
+
+
+    private int code;
+    private String brand;
+}

+ 42 - 0
src/main/java/com/gzlh/weighbridge/client/WeighbridgeClientHandler.java

@@ -0,0 +1,42 @@
+package com.gzlh.weighbridge.client;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@ChannelHandler.Sharable
+public class WeighbridgeClientHandler extends SimpleChannelInboundHandler<String> {
+
+    private WeighbridgeNettyConfig nettyConfig;
+
+    public WeighbridgeClientHandler(WeighbridgeNettyConfig nettyConfig) {
+        this.nettyConfig = nettyConfig;
+    }
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
+        WeighbridgePropertiesConfig weighbridgePropertiesConfig = SpringUtil.getBean(WeighbridgePropertiesConfig.class);
+        WeighbridgeFactory weighbridgeFactory = SpringUtil.getBean(WeighbridgeFactory.class);
+        weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).handlerMsg(msg);
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        System.out.println("连接断开,进行重连");
+        nettyConfig.connect();
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        cause.printStackTrace();
+       // ctx.close();
+    }
+
+
+}
+

+ 96 - 0
src/main/java/com/gzlh/weighbridge/client/WeighbridgeNettyConfig.java

@@ -0,0 +1,96 @@
+package com.gzlh.weighbridge.client;
+
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.Resource;
+import java.util.concurrent.TimeUnit;
+
+@Configuration
+@Slf4j
+public class WeighbridgeNettyConfig {
+
+   @Resource
+   private WeighbridgePropertiesConfig propertiesConfig;
+
+    @Autowired
+    private WeighbridgeClientHandler nettyClientHandler;
+
+    private Channel channel;
+
+    @Bean("weighbridge")
+    public Bootstrap bootstrap() {
+        String host=propertiesConfig.getHost();
+        int port=propertiesConfig.getPort();
+        log.info("初始化 netty:{},{}",host,port);
+        EventLoopGroup group = new NioEventLoopGroup();
+        return new Bootstrap()
+                .group(group)
+                .channel(NioSocketChannel.class)
+                .remoteAddress(host, port)
+                .option(ChannelOption.SO_KEEPALIVE, true)
+                .handler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    protected void initChannel(SocketChannel ch)  {
+                        try {
+                            ChannelPipeline pipeline = ch.pipeline();
+                            pipeline.addLast("decoder", new StringDecoder());
+                            pipeline.addLast("encoder", new StringEncoder());
+                            pipeline.addLast("handler", nettyClientHandler);
+                        }catch (Exception e){
+                            log.info("error connect:{}",e.getMessage());
+                        }
+                    }
+                });
+    }
+
+    @Bean
+    public WeighbridgeClientHandler nettyClientHandler() {
+        return new WeighbridgeClientHandler(this);
+    }
+
+    public void connect() {
+        String host=propertiesConfig.getHost();
+        int port=propertiesConfig.getPort();
+        ChannelFuture future = bootstrap().connect();
+        future.addListener((ChannelFutureListener) future1 -> {
+            if (future1.isSuccess()) {
+                channel = future1.channel();
+                log.info("地磅 连接服务器成功,{},{}",host,port);
+            } else {
+                log.error("-------------地磅 连接服务器失败-----------,进行重连");
+                future1.channel().eventLoop().schedule(this::connect, 5, TimeUnit.SECONDS);
+            }
+        });
+        try {
+            future.channel().closeFuture().sync();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void send(String message) {
+        if (channel != null && channel.isActive()) {
+            channel.writeAndFlush(message);
+        } else {
+            log.error("未建立连接,无法发送消息");
+        }
+    }
+
+    public void close() {
+        if (channel != null) {
+            channel.close();
+        }
+    }
+}
+

+ 18 - 0
src/main/java/com/gzlh/weighbridge/config/WeighbridgePropertiesConfig.java

@@ -0,0 +1,18 @@
+package com.gzlh.weighbridge.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@ConfigurationProperties(prefix = "weighbridge")
+@Data
+@Configuration
+public class WeighbridgePropertiesConfig {
+    private String host;
+    private int port;
+    /**
+     * 品牌
+     */
+    private int brand;
+    private int minKg;
+}

+ 18 - 0
src/main/java/com/gzlh/weighbridge/factory/WeighbridgeFactory.java

@@ -0,0 +1,18 @@
+package com.gzlh.weighbridge.factory;
+import com.gzlh.weighbridge.handler.IWeighbridgeHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class WeighbridgeFactory {
+    @Autowired
+    private List<IWeighbridgeHandler>handlers;
+
+    public IWeighbridgeHandler handler(int code){
+       return handlers.stream().filter(h->h.brandType().getCode()==code)
+                .findAny().orElseThrow(()->new IllegalArgumentException("不支持地磅品牌"));
+    }
+
+}

+ 12 - 0
src/main/java/com/gzlh/weighbridge/handler/IWeighbridgeHandler.java

@@ -0,0 +1,12 @@
+package com.gzlh.weighbridge.handler;
+
+import com.gzlh.red.brand.RedBrandType;
+import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
+
+public interface IWeighbridgeHandler {
+
+    WeighbridgeBrandType brandType();
+    void startReadMsg();
+
+    void handlerMsg(String content);
+}

+ 79 - 0
src/main/java/com/gzlh/weighbridge/handler/impl/WeighbridgeHandlerKeLi.java

@@ -0,0 +1,79 @@
+package com.gzlh.weighbridge.handler.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.red.brand.RedBrandType;
+import com.gzlh.red.config.RedPropertiesConfig;
+import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import com.gzlh.weighbridge.handler.IWeighbridgeHandler;
+import com.gzlh.weighbridge.server.CheckManager;
+import com.gzlh.weighbridge.server.WeighbridgeReqService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+
+/**
+ * 宁波柯力地磅处理器
+ */
+@Service
+@Slf4j
+public class WeighbridgeHandlerKeLi implements IWeighbridgeHandler {
+    @Resource
+    private WeighbridgeReqService weighbridgeReqService;
+    @Resource
+    private RedPropertiesConfig redPropertiesConfig;
+
+    @Override
+    public WeighbridgeBrandType brandType() {
+        return WeighbridgeBrandType.NINGBO_KELI;
+    }
+
+    @Override
+    public void startReadMsg() {
+        CheckManager.setStart();
+    }
+
+    @Override
+    public void handlerMsg(String msg) {
+
+//        log.info("客户端收到消息:" + msg);
+        msg = StrUtil.replace(msg, "\u0003", "").replace("\u0002", "");
+//        log.info("转换后消息:" + msg);
+        // 去掉开头和结尾的特殊字符
+        msg = msg.substring(1, msg.length() - 1);
+//        log.info("msg:{}",msg);
+        String str="10045001";
+        // 将字符串转换成字节数组类型+10045001B
+        byte[] bytes = msg.getBytes();
+//        byte[] bytes = str.getBytes();
+        // 取出有效数据
+        byte[] validData = Arrays.copyOfRange(bytes, 0, bytes.length - 2);
+        // 将有效数据转换成实际重量值
+        int weight = Integer.parseInt(new String(validData));
+        if (redPropertiesConfig.isEnable()){
+            //如果开始读数 缓存是2秒,读2秒的数据=========>开启红外功能
+            weighbridgeReqService.handlerV2(weight);
+            return;
+        }
+        weighbridgeReqService.handler(weight);
+    }
+
+    public static void main(String[] args) {
+        String str="10045001";
+//        String str="00858001";
+        // 将字符串转换成字节数组类型+10045001B
+//        byte[] bytes = msg.getBytes();
+        byte[] bytes = str.getBytes();
+        // 取出有效数据
+        byte[] validData = Arrays.copyOfRange(bytes, 0, bytes.length - 2);
+        // 将有效数据转换成实际重量值
+        int weight = Integer.parseInt(new String(validData));
+        System.out.println(weight);
+    }
+}

+ 84 - 0
src/main/java/com/gzlh/weighbridge/server/CacheManager.java

@@ -0,0 +1,84 @@
+package com.gzlh.weighbridge.server;
+
+import cn.hutool.cache.CacheUtil;
+import cn.hutool.cache.impl.TimedCache;
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
+import com.gzlh.task.CleanTask;
+
+import java.util.Comparator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class CacheManager {
+
+
+    private final static Map<Integer, Integer> WEIGHT_COUNT_CACHE = new ConcurrentHashMap<>(1024);
+
+    public final static TimedCache<String, Boolean> STOP_MAP = CacheUtil.newTimedCache(180000);
+    //30秒清除一次
+    private final static TimedCache<String, Integer> CLEAN_REQ_CACHE = CacheUtil.newTimedCache(30000);
+    private static final String FLAG = "flag";
+
+    public static void add(int weight) {
+        Boolean stop = STOP_MAP.get(FLAG, false);
+        if (stop != null && stop && !WEIGHT_COUNT_CACHE.isEmpty()) {
+            return;
+        }
+        Integer count = WEIGHT_COUNT_CACHE.get(weight);
+        if (count == null) {
+            count = 0;
+        }
+        count++;
+        WEIGHT_COUNT_CACHE.put(weight, count);
+    }
+
+    public static Integer getMaxCountWeight() {
+        Boolean stop = STOP_MAP.get(FLAG, false);
+        if (stop != null && stop) {
+            return -1;
+        }
+        Optional<Map.Entry<Integer, Integer>> optional = WEIGHT_COUNT_CACHE.entrySet().stream().max(Comparator.comparingInt(Map.Entry::getValue));
+        if (optional.isPresent()) {
+            Map.Entry<Integer, Integer> entry = optional.get();
+            //某个磅数达到了80次
+            if (entry.getValue() > 40) {
+                STOP_MAP.put(FLAG, true);
+                return entry.getKey();
+            }
+        }
+        return -1;
+    }
+    public static Integer getWeight() {
+        StaticLog.info("list:{}", JSONUtil.toJsonStr(WEIGHT_COUNT_CACHE));
+        Optional<Map.Entry<Integer, Integer>> optional = WEIGHT_COUNT_CACHE.entrySet().stream().max(Comparator.comparingInt(Map.Entry::getValue));
+        if (optional.isPresent()) {
+            Map.Entry<Integer, Integer> entry = optional.get();
+            //某个磅数达到了80次
+            if (entry.getValue() > 40) {
+                STOP_MAP.put(FLAG, true);
+                return entry.getKey();
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * 清除缓存数据
+     *
+     * @param channel
+     * @param serverUrl
+     */
+    public static void clean(String channel, String serverUrl) {
+        STOP_MAP.put(FLAG, false);
+        WEIGHT_COUNT_CACHE.clear();
+        Integer flag = CLEAN_REQ_CACHE.get(FLAG, false);
+        if (flag == null || flag == 0) {
+            CLEAN_REQ_CACHE.put(FLAG, 1);
+            ThreadUtil.execute(new CleanTask(serverUrl, channel));
+        }
+    }
+
+}

+ 43 - 0
src/main/java/com/gzlh/weighbridge/server/CheckManager.java

@@ -0,0 +1,43 @@
+package com.gzlh.weighbridge.server;
+
+import cn.hutool.cache.CacheUtil;
+import cn.hutool.cache.impl.TimedCache;
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.log.StaticLog;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+
+public class CheckManager {
+    private static String FLAG = "flag_key";
+    //读2秒的数据
+    private static TimedCache<String, Boolean> TASK_CACHE = CacheUtil.newTimedCache(6000);
+
+    private static List<Integer> WEIGHT_LIST = new CopyOnWriteArrayList<>();
+
+    public static boolean check() {
+        Boolean result = TASK_CACHE.get(FLAG, false);
+        return result != null&&result;
+    }
+
+    public static void setStart() {
+        WEIGHT_LIST.clear();
+        TASK_CACHE.put(FLAG, true);
+        StaticLog.info("开始称重--------");
+        //读取4秒的值
+        ThreadUtil.execute(new StartHandler());
+    }
+    public static void setStop() {
+        TASK_CACHE.put(FLAG, null);
+    }
+
+    public static void add(int weight) {
+        WEIGHT_LIST.add(weight);
+
+    }
+    public static List<Integer>getWeightList(){
+        return WEIGHT_LIST;
+    }
+
+}

+ 10 - 0
src/main/java/com/gzlh/weighbridge/server/Count.java

@@ -0,0 +1,10 @@
+package com.gzlh.weighbridge.server;
+
+import lombok.Data;
+
+@Data
+public class Count {
+    private int weight;
+    private int count;
+
+}

+ 61 - 0
src/main/java/com/gzlh/weighbridge/server/StartHandler.java

@@ -0,0 +1,61 @@
+package com.gzlh.weighbridge.server;
+
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import cn.hutool.json.JSONUtil;
+import com.gzlh.config.ApplicationConfig;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.task.UploadTask;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+public class StartHandler implements Runnable{
+    private final ApplicationConfig applicationConfig=SpringUtil.getBean(ApplicationConfig.class);
+    private final WeighbridgePropertiesConfig weighbridgePropertiesConfig= SpringUtil.getBean(WeighbridgePropertiesConfig.class);
+    private final LedFactory ledFactory=SpringUtil.getBean(LedFactory.class);
+    private final LedPropertiesConfig ledPropertiesConfig=SpringUtil.getBean(LedPropertiesConfig.class);
+
+
+
+    @Override
+    public void run() {
+        long time=4000;
+        log.info("start-------");
+        while (time>=0){
+            time=time-1000;
+            ThreadUtil.sleep(1000);
+        }
+        log.info("stop-------");
+        new Thread(CheckManager::setStop).start();
+        List<Integer> list = CheckManager.getWeightList();
+        log.info("list:{}", JSONUtil.toJsonStr(list));
+        //读20个地磅数值触发上传
+        int averagingWeight = handlerWeightList(list);
+        log.info("weight:{}", averagingWeight);
+        if (averagingWeight < weighbridgePropertiesConfig.getMinKg()) {
+            return;
+        }
+        ledFactory.handler(ledPropertiesConfig.getBrand()).sendMsg("重量" + averagingWeight + "kg");
+        String serverUrl= applicationConfig.getServerUrl();
+        String channelName=applicationConfig.getChannelName();
+        ThreadUtil.execute(new UploadTask(serverUrl, channelName, averagingWeight));
+    }
+
+    private int handlerWeightList(List<Integer> list) {
+        if (list.isEmpty()) {
+            return 0;
+        }
+        list=list.stream().sorted().collect(Collectors.toList());
+        int size = list.size();
+        int index = (size * 3) / 4;
+        int weight= list.stream().collect(Collectors.averagingInt(i->i)).intValue();
+        log.info("averaging weight:{}",weight);
+        return list.get(index);
+    }
+}

+ 86 - 0
src/main/java/com/gzlh/weighbridge/server/WeighbridgeReqService.java

@@ -0,0 +1,86 @@
+package com.gzlh.weighbridge.server;
+
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONUtil;
+import com.gzlh.api.CheckCarNumberBO;
+import com.gzlh.config.ApplicationConfig;
+import com.gzlh.led.factory.LedFactory;
+import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.task.CleanTask;
+import com.gzlh.task.UploadTask;
+import com.gzlh.utils.ResultJson;
+import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
+import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+@Service
+@Slf4j
+public class WeighbridgeReqService {
+
+    @Resource
+    private ApplicationConfig applicationConfig;
+
+    @Resource
+    private WeighbridgePropertiesConfig weighbridgePropertiesConfig;
+
+    @Resource
+    private LedFactory ledFactory;
+    @Resource
+    private LedPropertiesConfig ledPropertiesConfig;
+
+
+    /**
+     * 处理磅数---单位是kg
+     *
+     * @param weight
+     */
+    public void handler(Integer weight) {
+        String channelName = applicationConfig.getChannelName();
+        String serverUrl = applicationConfig.getServerUrl();
+        if (weight == 0) {
+            //离开地磅则清除--------->
+            CacheManager.clean(channelName, serverUrl);
+            return;
+        }
+        //小于设定值则不要
+        if (weight < weighbridgePropertiesConfig.getMinKg()) {
+            return;
+        }
+        CacheManager.add(weight);
+        Integer maxCountWeight = CacheManager.getMaxCountWeight();
+        if (maxCountWeight != -1) {
+            ledFactory.handler(ledPropertiesConfig.getBrand()).sendMsg("重量" + maxCountWeight + "kg");
+            ThreadUtil.execute(new UploadTask(applicationConfig.getServerUrl(), channelName, maxCountWeight));
+        }
+    }
+
+
+    public void handlerV2(int weight) {
+        String channelName = applicationConfig.getChannelName();
+        String serverUrl = applicationConfig.getServerUrl();
+        if (weight == 0) {
+            //离开地磅则清除--------->
+            CacheManager.clean(channelName, serverUrl);
+            CheckManager.setStop();
+            return;
+        }
+        //log.info(WeighbridgeBrandType.NINGBO_KELI.getBrand() + "地磅:{}", weight);
+        //小于设定值则不要
+        if (weight < weighbridgePropertiesConfig.getMinKg()) {
+            return;
+        }
+        if (CheckManager.check()) {
+            CheckManager.add(weight);
+        }
+    }
+    }
+

+ 22 - 0
src/main/resources/application.yml

@@ -0,0 +1,22 @@
+server:
+  port: 8086
+weighbridge:
+  host: 192.168.1.169
+  port: 4005
+  brand: 3000
+  min-kg: 1000
+application:
+  server-url: http://127.0.0.1:8099/pro
+  channel-name: "A1园内地磅通道"
+
+led:
+  host: 127.0.0.1
+  port: 4008
+  brand: 1000
+  enable: false
+red:
+    host: 127.0.0.1
+    port: 4002
+    brand: 2000
+    enable: false
+

+ 125 - 0
src/main/resources/logback.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <contextName>pco</contextName>
+    <property name="LOG_PATH" value="logs"/>
+    <property name="APP_DIR" value="weighbridge"/>
+    <property name="log.maxFileSize" value="10MB"/>
+    <property name="log.maxFileCnt" value="90"/>
+    <property name="log.totalSizeCap" value="10GB"/>
+
+    <appender name="FILE_DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_PATH}/${APP_DIR}/log_debug.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/${APP_DIR}/debug/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>${log.maxFileSize}</maxFileSize>
+            <maxHistory>${log.maxFileCnt}</maxHistory>
+            <totalSizeCap>${log.totalSizeCap}</totalSizeCap>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}|%-5level{10}[%25.25thread{24}]%-40.40logger{39}|-Line:%-3L:%msg%n
+            </pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>debug</level>
+            <onMatch>ACCEPT</onMatch>
+            <!--            <onMismatch>DENY</onMismatch>-->
+        </filter>
+    </appender>
+
+    <appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_PATH}/${APP_DIR}/log_info.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/${APP_DIR}/info/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>${log.maxFileSize}</maxFileSize>
+            <maxHistory>${log.maxFileCnt}</maxHistory>
+            <totalSizeCap>${log.totalSizeCap}</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}|%-5level{10}[%25.25thread{24}]%-40.40logger{39}|-Line:%-3L:%msg%n
+            </pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>info</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <!--encoder 默认配置为PatternLayoutEncoder-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd
+                HH:mm:ss.SSS}|%highlight(%-5level{10})[%boldYellow(%25.25thread{24})]%gray(%-50.50logger{49})|-Line:%boldYellow(%-3L):%msg%n
+            </pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>info</level>
+        </filter>
+    </appender>
+
+    <appender name="COMM_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_PATH}/${APP_DIR}/comm_info.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/${APP_DIR}/comm/comm_info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>${log.maxFileSize}</maxFileSize>
+            <maxHistory>${log.maxFileCnt}</maxHistory>
+            <totalSizeCap>${log.totalSizeCap}</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>info</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+    <logger name="com.cryann.hsms.driver.netty" additivity="false">
+        <appender-ref ref="COMM_LOG"/>
+    </logger>
+
+    <appender name="SXFX_info_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_PATH}/${APP_DIR}/SxFx_info.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/${APP_DIR}/SxFx/SxFx_info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>${log.maxFileSize}</maxFileSize>
+            <maxHistory>${log.maxFileCnt}</maxHistory>
+            <totalSizeCap>${log.totalSizeCap}</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd
+                HH:mm:ss.SSS}|%highlight(%-5level{10})[%boldYellow(%25.25thread{24})]%gray(%-50.50logger{49})|-Line:%boldYellow(%-3L):%msg%n
+            </pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>info</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+
+    <logger name="org.springframework" level="WARN"/>
+    <logger name="org.hibernate" level="WARN"/>
+    <logger name="com.apache.ibatis" level="TRACE"/>
+    <logger name="java.sql.Connection" level="DEBUG"/>
+    <logger name="java.sql.Statement" level="DEBUG"/>
+    <logger name="java.sql.PreparedStatement" level="DEBUG"/>
+
+    <!-- 生产环境下,将此级别配置为适合的级别,以免日志文件太多或影响程序性能 -->
+    <root level="INFO">
+        <!-- 生产环境将请stdout,testfile去掉 -->
+        <appender-ref ref="STDOUT"/>
+        <appender-ref ref="FILE_DEBUG"/>
+        <!--<appender-ref ref="FILEWARN"/>-->
+        <appender-ref ref="FILE_INFO"/>
+    </root>
+</configuration>