浏览代码

ground_station

UI 2 年之前
当前提交
fdeff22d27
共有 100 个文件被更改,包括 12643 次插入0 次删除
  1. 34 0
      .gitignore
  2. 45 0
      config/application.properties
  3. 37 0
      config/logconfig.xml
  4. 310 0
      mvnw
  5. 182 0
      mvnw.cmd
  6. 205 0
      pom.xml
  7. 38 0
      src/main/java/com/lstznkj/groundstation/BeanFacotry.java
  8. 248 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataSourceDTO.java
  9. 48 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataSourcePoolDTO.java
  10. 183 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataTypeDTO.java
  11. 180 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/ModbusDataSourceDTO.java
  12. 4 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/ModbusDataSourcePoolDTO.java
  13. 4 0
      src/main/java/com/lstznkj/groundstation/DTO/crane_station/PLCDataSourceDTO.java
  14. 115 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/ChartDataDTO.java
  15. 147 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/CraneDTO.java
  16. 276 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/CraneSummaryDTO.java
  17. 22 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/DataSourceRequestDTO.java
  18. 386 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/DataSourceUIDTO.java
  19. 64 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/DataTypeDTO.java
  20. 50 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/DeviceDTO.java
  21. 275 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/EquipmentDTO.java
  22. 19 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/LegendDTO.java
  23. 48 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/SeriesDTO.java
  24. 614 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/TechParamsDTO.java
  25. 33 0
      src/main/java/com/lstznkj/groundstation/DTO/ui/xAxisDTO.java
  26. 39 0
      src/main/java/com/lstznkj/groundstation/DemoApplication.java
  27. 18 0
      src/main/java/com/lstznkj/groundstation/GlobalData.java
  28. 189 0
      src/main/java/com/lstznkj/groundstation/MVCConfig.java
  29. 29 0
      src/main/java/com/lstznkj/groundstation/SwaggerConfig.java
  30. 17 0
      src/main/java/com/lstznkj/groundstation/controller/AuthController.java
  31. 104 0
      src/main/java/com/lstznkj/groundstation/controller/CraneController.java
  32. 166 0
      src/main/java/com/lstznkj/groundstation/controller/DataSourceController.java
  33. 44 0
      src/main/java/com/lstznkj/groundstation/controller/DataTypeController.java
  34. 157 0
      src/main/java/com/lstznkj/groundstation/controller/DeviceController.java
  35. 141 0
      src/main/java/com/lstznkj/groundstation/controller/EquipmentController.java
  36. 16 0
      src/main/java/com/lstznkj/groundstation/controller/MainController.java
  37. 23 0
      src/main/java/com/lstznkj/groundstation/controller/RoleController.java
  38. 92 0
      src/main/java/com/lstznkj/groundstation/controller/TestController.java
  39. 155 0
      src/main/java/com/lstznkj/groundstation/controller/UltimateController.java
  40. 150 0
      src/main/java/com/lstznkj/groundstation/controller/UserController.java
  41. 190 0
      src/main/java/com/lstznkj/groundstation/model/Authority.java
  42. 34 0
      src/main/java/com/lstznkj/groundstation/model/Result.java
  43. 141 0
      src/main/java/com/lstznkj/groundstation/model/SysRole.java
  44. 173 0
      src/main/java/com/lstznkj/groundstation/model/User.java
  45. 145 0
      src/main/java/com/lstznkj/groundstation/model/crane/BaseData.java
  46. 14 0
      src/main/java/com/lstznkj/groundstation/model/crane/DataMark.java
  47. 376 0
      src/main/java/com/lstznkj/groundstation/model/crane/DataSource.java
  48. 159 0
      src/main/java/com/lstznkj/groundstation/model/crane/DataType.java
  49. 530 0
      src/main/java/com/lstznkj/groundstation/model/crane/Device.java
  50. 289 0
      src/main/java/com/lstznkj/groundstation/model/crane/LifeModel.java
  51. 78 0
      src/main/java/com/lstznkj/groundstation/model/crane/State.java
  52. 27 0
      src/main/java/com/lstznkj/groundstation/model/crane/StateLog.java
  53. 45 0
      src/main/java/com/lstznkj/groundstation/model/crane/ThreadMonitorInfo.java
  54. 24 0
      src/main/java/com/lstznkj/groundstation/model/crane/Trouble.java
  55. 193 0
      src/main/java/com/lstznkj/groundstation/model/crane/WorkLog.java
  56. 275 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/AccidentLog.java
  57. 234 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/DeviceSummary.java
  58. 216 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/Equipment.java
  59. 202 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/ExchangeLog.java
  60. 126 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckReport.java
  61. 117 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandard.java
  62. 188 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandardItem.java
  63. 104 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandardItemResult.java
  64. 41 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckTask.java
  65. 153 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/ReformLog.java
  66. 171 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/RepairStandard.java
  67. 109 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/SpecialLog.java
  68. 519 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/TechParameter.java
  69. 103 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/UnitInfo.java
  70. 85 0
      src/main/java/com/lstznkj/groundstation/model/crane/extra/WareHouse.java
  71. 97 0
      src/main/java/com/lstznkj/groundstation/mqtt/MqttFactory.java
  72. 34 0
      src/main/java/com/lstznkj/groundstation/mqtt/MqttManager.java
  73. 305 0
      src/main/java/com/lstznkj/groundstation/mqtt/MqttProvider.java
  74. 109 0
      src/main/java/com/lstznkj/groundstation/mqtt/MqttProviderCallBack.java
  75. 50 0
      src/main/java/com/lstznkj/groundstation/mqtt/MqttUtil.java
  76. 19 0
      src/main/java/com/lstznkj/groundstation/repo/AuthorityRepository.java
  77. 11 0
      src/main/java/com/lstznkj/groundstation/repo/SysRoleRepository.java
  78. 13 0
      src/main/java/com/lstznkj/groundstation/repo/UserRepository.java
  79. 20 0
      src/main/java/com/lstznkj/groundstation/repo/crane/BaseDataRepository.java
  80. 13 0
      src/main/java/com/lstznkj/groundstation/repo/crane/DataSourceRepository.java
  81. 16 0
      src/main/java/com/lstznkj/groundstation/repo/crane/DataTypeRepository.java
  82. 32 0
      src/main/java/com/lstznkj/groundstation/repo/crane/DeviceRepository.java
  83. 10 0
      src/main/java/com/lstznkj/groundstation/repo/crane/StateRepository.java
  84. 10 0
      src/main/java/com/lstznkj/groundstation/repo/crane/extra/DeviceSummaryRepository.java
  85. 18 0
      src/main/java/com/lstznkj/groundstation/repo/crane/extra/EquipmentRepository.java
  86. 14 0
      src/main/java/com/lstznkj/groundstation/repo/crane/extra/LifeModelRepository.java
  87. 9 0
      src/main/java/com/lstznkj/groundstation/repo/crane/extra/TechParameterRepository.java
  88. 94 0
      src/main/java/com/lstznkj/groundstation/security/UrlAccessDecisionManager.java
  89. 85 0
      src/main/java/com/lstznkj/groundstation/security/UserDetailsImpl.java
  90. 42 0
      src/main/java/com/lstznkj/groundstation/security/UserDetailsServiceImpl.java
  91. 73 0
      src/main/java/com/lstznkj/groundstation/security/WebSecurityConfig.java
  92. 85 0
      src/main/java/com/lstznkj/groundstation/security/jwt/JWTAuthenticationFilter.java
  93. 173 0
      src/main/java/com/lstznkj/groundstation/security/jwt/JWTLoginFilter.java
  94. 122 0
      src/main/java/com/lstznkj/groundstation/security/jwt/JWTUtils.java
  95. 161 0
      src/main/java/com/lstznkj/groundstation/service/AuthorityService.java
  96. 248 0
      src/main/java/com/lstznkj/groundstation/service/DataIntegrateService.java
  97. 157 0
      src/main/java/com/lstznkj/groundstation/service/ImageService.java
  98. 431 0
      src/main/java/com/lstznkj/groundstation/service/InitService.java
  99. 156 0
      src/main/java/com/lstznkj/groundstation/service/SysRoleService.java
  100. 68 0
      src/main/java/com/lstznkj/groundstation/service/TestService.java

+ 34 - 0
.gitignore

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

+ 45 - 0
config/application.properties

@@ -0,0 +1,45 @@
+ spring.jpa.hibernate.ddl-auto=update
+#spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.show-sql=false
+spring.jpa.properties.hibernate.event.merge.entity_copy_observer=allow
+spring.datasource.url=jdbc:mysql://192.168.56.116:3306/ground_station?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
+# spring.datasource.url=jdbc:mysql://127.0.0.1:3306/ground_station?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
+#spring.datasource.url=jdbc:mysql://192.168.56.105:3306/ground_station?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
+
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+
+spring.datasource.username=root
+#spring.datasource.password=admin.mysql
+ spring.datasource.password=123456
+
+
+data.sparseValue=0.8
+data.sparseCount=1000
+
+
+server.port=8083
+
+# demo.imgPath=F:\\uploadImg
+spring.servlet.multipart.max-file-size=10MB
+spring.servlet.multipart.max-request-size=80MB
+spring.servlet.multipart.enabled=true
+
+mqtt.url=tcp://192.168.56.105:1883
+# mqtt.url=tcp://127.0.0.1:1883
+
+#mqtt.url=ws://192.168.56.102:8083
+mqtt.username=admin
+
+mqtt.password=123456
+mqtt.client.id=ground_server
+mqtt.default.topic=topic
+
+
+
+
+logging.config=config/logconfig.xml
+
+
+
+
+

+ 37 - 0
config/logconfig.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <property name="LOG_PATTERN"
+              value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
+
+    <property name="FILE_PATH"
+              value="logs/%d{yyyy-MM-dd}.%i.log" />
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+    <appender name="rollingFile"
+        class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>
+                ${FILE_PATH}
+            </fileNamePattern>
+            <!-- keep 60 days' worth of history -->
+            <maxHistory>60</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy
+                class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder>
+            <!-- <pattern>${LOG_PATTERN}</pattern> -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <!-- project default level -->
+    <logger name="ground_station" level="INFO" />
+    <root level="INFO">
+        <appender-ref ref="console" />
+        <appender-ref ref="rollingFile" />
+    </root>
+</configuration>

+ 310 - 0
mvnw

@@ -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 "$@"

+ 182 - 0
mvnw.cmd

@@ -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%

+ 205 - 0
pom.xml

@@ -0,0 +1,205 @@
+<?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
+                             http://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.2.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+	<groupId>com.example</groupId>
+	<artifactId>demo</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>demo</name>
+	<description>Demo project for Spring Boot</description>
+
+    <!-- 配置全局的属性 -->
+    <properties>
+        <java.version>11</java.version>
+        <mybatis.version>2.1.0</mybatis.version>
+        <mysql.version>5.1.47</mysql.version>
+    </properties>
+	<dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-integration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-stream</artifactId>
+
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+
+        </dependency>
+         <dependency>
+                   <groupId>org.mariadb.jdbc</groupId>
+                   <artifactId>mariadb-java-client</artifactId>
+                   <scope>runtime</scope>
+               </dependency>
+      <!--  <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <!-- <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>3.0.0</version>
+        </dependency> -->
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.apiggs</groupId>
+            <artifactId>apiggs-maven-plugin</artifactId>
+            <version>1.6</version>
+            <type>pom</type>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>QLExpress</artifactId>
+            <version>3.2.7</version>
+          </dependency>
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.4</version>
+        </dependency>
+
+
+    </dependencies>
+
+	<build>
+        <plugins>
+            <!-- maven 打包时跳过测试 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>com.github.apiggs</groupId>
+                <artifactId>apiggs-maven-plugin</artifactId>
+                <version>1.6</version>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>apiggs</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <!-- options in there -->
+                    <id>index</id>
+                    <title>起重机智能运维系统API文档</title>
+                    <production>order</production>
+                    <out>target/docs</out>
+                    <dependency>../http-service/src/main/java</dependency>
+                    <version>1.0.0</version>
+
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+	<repositories>
+        <repository>
+            <id>central</id>
+            <name>aliyun maven</name>
+            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
+            <layout>default</layout>
+            <!-- 是否开启发布版构件下载 -->
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <!-- 是否开启快照版构件下载 -->
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+
+
+
+<!--	&lt;!&ndash; 配置依赖关系 &ndash;&gt;-->
+<!--    <dependencies>-->
+<!--        &lt;!&ndash; web启动器 &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-web</artifactId>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; mybatis启动器 &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.mybatis.spring.boot</groupId>-->
+<!--            <artifactId>mybatis-spring-boot-starter</artifactId>-->
+<!--            <version>${mybatis.version}</version>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; mysql驱动 &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>mysql</groupId>-->
+<!--            <artifactId>mysql-connector-java</artifactId>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; lombok &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.projectlombok</groupId>-->
+<!--            <artifactId>lombok</artifactId>-->
+<!--        </dependency>-->
+<!--    </dependencies>-->
+ 
+<!--	<build>-->
+<!--        <plugins>-->
+<!--            &lt;!&ndash; 配置SpringBoot的maven插件 &ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.springframework.boot</groupId>-->
+<!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
+<!--            </plugin>-->
+<!--        </plugins>-->
+<!--    </build>-->
+
+</project>

+ 38 - 0
src/main/java/com/lstznkj/groundstation/BeanFacotry.java

@@ -0,0 +1,38 @@
+package com.lstznkj.groundstation;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.lstznkj.groundstation.utils.DateUtil;
+import com.lstznkj.groundstation.utils.ObjectUtil;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+@Configuration
+public class BeanFacotry {
+    @Bean
+    public BCryptPasswordEncoder getBCryptPasswordEncoder()
+    {
+        return new BCryptPasswordEncoder();
+    }
+    @Bean
+    public JWTUtils jwtUtils()
+    {
+        return new JWTUtils();
+    }
+    @Bean
+    public ObjectMapper objectMapper()
+    {
+        return new ObjectMapper();
+    }
+    @Bean
+    public ObjectUtil objectUtil(){
+        return new ObjectUtil();
+    }
+//    @Bean
+//    public DateUtil dateUtil(){
+//        return DateUtil.getSingleInstance();
+//    }
+
+
+}

+ 248 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataSourceDTO.java

@@ -0,0 +1,248 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.DataType;
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+public class DataSourceDTO {
+
+    private int id;
+    private String name;
+
+    //是否启用
+    private Boolean isEnable;
+
+    //采集地址(具体寄存器地址或者PLC 数据块地址)
+    private String address;
+
+   // private int port;
+
+    private DataType dataType;
+
+
+    //偏移量
+    private int offset;
+    //读取长度
+    private int quantity;
+
+    //mqtt发布主题名称
+    private String publishTopic;
+
+    private Timestamp createTimestamp;
+
+    private Timestamp updateTimestamp;
+
+    private String createTime;
+
+    private int dataTypeId;
+
+    private String updateTime;
+
+    @JsonIgnore
+    @ManyToOne
+    private Device device;
+    @Transient
+    private String deviceInfo;
+
+    //报警阈值
+    private float threshold;
+    private float maxValue;
+    private float minValue;
+
+    private String extraInfo;
+
+    public  DataSourceDTO(){
+
+    }
+    public DataSourceDTO(DataSource dataSource){
+        this.id=dataSource.getId();
+        this.name=dataSource.getName();
+        this.isEnable=dataSource.getEnable();
+
+        //采集地址(具体寄存器地址或者PLC 数据块地址)
+        this.address=dataSource.getAddress();
+
+        this.dataType=dataSource.getDataType();
+
+        //偏移量
+        //读取长度
+        //this.quantity=dataSource.geto;
+
+        //mqtt发布主题名称
+        this.publishTopic=dataSource.getPublishTopic();
+
+        this.createTimestamp=dataSource.getCreateTimestamp();
+
+        this.updateTimestamp=dataSource.getUpdateTimestamp();
+
+        this.createTime=dataSource.getCreateTime();
+
+        this.dataTypeId=dataSource.getDataTypeId();
+
+        this.updateTime=dataSource.getUpdateTime();
+
+        this.device=dataSource.getDevice();
+        this.deviceInfo=dataSource.getDeviceInfo();
+
+        //报警阈值
+        this.threshold=dataSource.getDataTypeId();
+        this.maxValue=dataSource.getMaxValue();
+        this.minValue=dataSource.getMinValue();
+
+        //this.extraInfo=dataSource.gete;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public void setExtraInfo(String extraInfo) {
+        this.extraInfo = extraInfo;
+    }
+
+    public String getExtraInfo() {
+        return extraInfo;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setEnable(Boolean enable) {
+        isEnable = enable;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+
+    public void setQuantity(int quantity) {
+        this.quantity = quantity;
+    }
+
+    public void setPublishTopic(String publishTopic) {
+        this.publishTopic = publishTopic;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setDataTypeId(int dataTypeId) {
+        this.dataTypeId = dataTypeId;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public void setThreshold(float threshold) {
+        this.threshold = threshold;
+    }
+
+    public void setMaxValue(float maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public void setMinValue(float minValue) {
+        this.minValue = minValue;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Boolean getEnable() {
+        return isEnable;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public DataType getDataType() {
+        return dataType;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public int getQuantity() {
+        return quantity;
+    }
+
+    public String getPublishTopic() {
+        return publishTopic;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public int getDataTypeId() {
+        return dataTypeId;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public float getThreshold() {
+        return threshold;
+    }
+
+    public float getMaxValue() {
+        return maxValue;
+    }
+
+    public float getMinValue() {
+        return minValue;
+    }
+
+    public String getDeviceInfo() {
+        if(device!=null){
+            deviceInfo=device.getFullName();
+        }
+        return deviceInfo;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+    
+}

+ 48 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataSourcePoolDTO.java

@@ -0,0 +1,48 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataSourcePoolDTO {
+
+    private String name;
+
+    //协议类型,485 or PLC S7
+    private String protocolType;
+    //采集地址(IP地址)
+    private String address;
+
+    private List<DataSourceDTO> dataSourceDTOList=new ArrayList<>();
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setProtocolType(String protocolType) {
+        this.protocolType = protocolType;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setDataSourceDTOList(List<DataSourceDTO> dataSourceDTOList) {
+        this.dataSourceDTOList = dataSourceDTOList;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getProtocolType() {
+        return protocolType;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public List<DataSourceDTO> getDataSourceDTOList() {
+        return dataSourceDTOList;
+    }
+}

+ 183 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/DataTypeDTO.java

@@ -0,0 +1,183 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.DataType;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * A DTO for the {@link com.lstznkj.groundstation.model.crane.DataType} entity
+ */
+public class DataTypeDTO implements Serializable {
+    private final Integer id;
+    private final String name;
+    private final int valueType;
+    private final int method;
+    private final String expression;
+    private final List<DataSourceDTO> dataSources;
+    private final Timestamp createTimestamp;
+    private final Timestamp updateTimestamp;
+    private final String remark;
+
+    private int value;
+    private String label;
+    private List<Child> children=new ArrayList();
+
+    class Child{
+        int value;
+        String label;
+
+        public Child(int value, String label) {
+            this.value = value;
+            this.label = label;
+        }
+
+        public int getValue() {
+            return value;
+        }
+
+        public void setValue(int value) {
+            this.value = value;
+        }
+
+
+
+        public String getLabel() {
+            return label;
+        }
+
+        public void setLabel(String label) {
+            this.label = label;
+        }
+    }
+
+    public DataTypeDTO(Integer id, String name, int valueType, int method, String expression, List<DataSourceDTO> dataSources, Timestamp createTimestamp, Timestamp updateTimestamp, String remark) {
+        this.id = id;
+        this.name = name;
+        this.valueType = valueType;
+        this.method = method;
+        this.expression = expression;
+        this.dataSources = dataSources;
+        this.createTimestamp = createTimestamp;
+        this.updateTimestamp = updateTimestamp;
+        this.remark = remark;
+        this.value=id;
+        this.label=name;
+    }
+  public DataTypeDTO(DataType dataType){
+      this.id = dataType.getId();
+      this.name = dataType.getName();
+      this.valueType = dataType.getValueType();
+      this.method = dataType.getMethod();
+      this.expression = dataType.getExpression();
+      this.dataSources=new ArrayList<>();
+      for(DataSource ds: dataType.getDataSources()){
+          this.dataSources.add(new DataSourceDTO(ds));
+          this.children.add(new Child(ds.getId(),ds.getDeviceInfo()+ds.getName()));
+      }
+      this.createTimestamp = dataType.getCreateTimestamp();
+      this.updateTimestamp = dataType.getUpdateTimestamp();
+      this.remark = dataType.getRemark();
+      this.value=dataType.getId();
+      this.label=dataType.getName();
+  }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getValueType() {
+        return valueType;
+    }
+
+    public int getMethod() {
+        return method;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public List<Child> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<Child> children) {
+        this.children = children;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    public List<DataSourceDTO> getDataSources() {
+        return dataSources;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        DataTypeDTO entity = (DataTypeDTO) o;
+        return Objects.equals(this.id, entity.id) &&
+                Objects.equals(this.name, entity.name) &&
+                Objects.equals(this.valueType, entity.valueType) &&
+                Objects.equals(this.method, entity.method) &&
+                Objects.equals(this.expression, entity.expression) &&
+                Objects.equals(this.dataSources, entity.dataSources) &&
+                Objects.equals(this.createTimestamp, entity.createTimestamp) &&
+                Objects.equals(this.updateTimestamp, entity.updateTimestamp) &&
+                Objects.equals(this.remark, entity.remark);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, name, valueType, method, expression, dataSources, createTimestamp, updateTimestamp, remark);
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "(" +
+                "id = " + id + ", " +
+                "name = " + name + ", " +
+                "valueType = " + valueType + ", " +
+                "method = " + method + ", " +
+                "expression = " + expression + ", " +
+                "dataSources = " + dataSources + ", " +
+                "createTimestamp = " + createTimestamp + ", " +
+                "updateTimestamp = " + updateTimestamp + ", " +
+                "remark = " + remark + ")";
+    }
+}

+ 180 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/ModbusDataSourceDTO.java

@@ -0,0 +1,180 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+import com.lstznkj.groundstation.model.crane.DataType;
+
+import java.sql.Timestamp;
+
+public class ModbusDataSourceDTO {
+
+    private int id;
+    private String name;
+
+    //是否启用
+    private Boolean isEnable;
+
+    //采集地址(具体寄存器地址或者PLC 数据块地址)
+    private String address;
+
+    private DataType dataType;
+
+    //偏移量
+    private int offset;
+    //读取长度
+    private int quantity;
+
+    //mqtt发布主题名称
+    private String publishTopic;
+
+    private Timestamp createTimestamp;
+
+    private Timestamp updateTimestamp;
+
+    private String createTime;
+
+    private int dataTypeId;
+
+    private String updateTime;
+
+    //报警阈值
+    private float threshold;
+    private float maxValue;
+    private float minValue;
+
+    private String extraInfo;
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public void setExtraInfo(String extraInfo) {
+        this.extraInfo = extraInfo;
+    }
+
+    public String getExtraInfo() {
+        return extraInfo;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setEnable(Boolean enable) {
+        isEnable = enable;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+
+    public void setQuantity(int quantity) {
+        this.quantity = quantity;
+    }
+
+    public void setPublishTopic(String publishTopic) {
+        this.publishTopic = publishTopic;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setDataTypeId(int dataTypeId) {
+        this.dataTypeId = dataTypeId;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public void setThreshold(float threshold) {
+        this.threshold = threshold;
+    }
+
+    public void setMaxValue(float maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public void setMinValue(float minValue) {
+        this.minValue = minValue;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Boolean getEnable() {
+        return isEnable;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public DataType getDataType() {
+        return dataType;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public int getQuantity() {
+        return quantity;
+    }
+
+    public String getPublishTopic() {
+        return publishTopic;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public int getDataTypeId() {
+        return dataTypeId;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public float getThreshold() {
+        return threshold;
+    }
+
+    public float getMaxValue() {
+        return maxValue;
+    }
+
+    public float getMinValue() {
+        return minValue;
+    }
+}

+ 4 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/ModbusDataSourcePoolDTO.java

@@ -0,0 +1,4 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+public class ModbusDataSourcePoolDTO {
+}

+ 4 - 0
src/main/java/com/lstznkj/groundstation/DTO/crane_station/PLCDataSourceDTO.java

@@ -0,0 +1,4 @@
+package com.lstznkj.groundstation.DTO.crane_station;
+
+public class PLCDataSourceDTO {
+}

+ 115 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/ChartDataDTO.java

@@ -0,0 +1,115 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.model.crane.BaseData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChartDataDTO {
+    private xAxisDTO xAxis;
+    private LegendDTO legend;
+    private double maxValue;
+    private double minValue;
+    private double threshold;
+    private List<SeriesDTO> series=new ArrayList<>();
+
+    @JsonIgnore
+    private List<DataSourceUIDTO> dataSourceUIDTOList;
+
+    public ChartDataDTO(){
+        this.legend=new LegendDTO();
+        this.series=new ArrayList<>();
+        this.xAxis=new xAxisDTO();
+    }
+
+    public xAxisDTO getxAxis() {
+        return xAxis;
+    }
+
+    public void setxAxis(xAxisDTO xAxis) {
+        this.xAxis = xAxis;
+    }
+
+    public LegendDTO getLegend() {
+        return legend;
+    }
+
+    public void setLegend(LegendDTO legend) {
+        this.legend = legend;
+    }
+
+    public List<SeriesDTO> getSeries() {
+        return series;
+    }
+
+    public void setSeries(List<SeriesDTO> series) {
+        this.series = series;
+    }
+
+    public double getMaxValue() {
+        return maxValue;
+    }
+
+    public void setMaxValue(double maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public double getMinValue() {
+        return minValue;
+    }
+
+    public void setMinValue(double minValue) {
+        this.minValue = minValue;
+    }
+
+    public double getThreshold() {
+        return threshold;
+    }
+
+    public void setThreshold(double threshold) {
+        this.threshold = threshold;
+    }
+
+    public List<DataSourceUIDTO> getDataSourceUIDTOList() {
+
+
+
+
+        return dataSourceUIDTOList;
+    }
+
+
+    public void setDataSourceUIDTOList(List<DataSourceUIDTO> dataSourceUIDTOList) {
+        this.dataSourceUIDTOList = dataSourceUIDTOList;
+
+        for(DataSourceUIDTO dataSourceUIDTO:this.dataSourceUIDTOList){
+            List<String> dateList=new ArrayList<>();
+            List<Double> valueList=new ArrayList<>();
+
+            legend.getData().add(dataSourceUIDTO.getDevice().getFullName()+dataSourceUIDTO.getName());
+
+
+            SeriesDTO seriesDTO=new SeriesDTO();
+            seriesDTO.setName(dataSourceUIDTO.getDevice().getFullName()+dataSourceUIDTO.getName());
+
+
+            for(BaseData baseData:dataSourceUIDTO.getBaseDataList()){
+                dateList.add(baseData.getCollectTimeStr());
+
+                valueList.add(baseData.getValue());
+
+            }
+            seriesDTO.setData(valueList);
+            this.series.add(seriesDTO);
+            this.xAxis.setData(dateList);
+            this.xAxis.setType("category");
+
+
+        }
+
+
+
+
+    }
+}

+ 147 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/CraneDTO.java

@@ -0,0 +1,147 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.State;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+import org.springframework.security.core.parameters.P;
+
+import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
+import java.sql.Timestamp;
+
+public class CraneDTO {
+
+    private Integer id;
+
+    private String createTime;
+
+    private String updateTime;
+    private String name;
+    private String remark;
+
+    private String fullName;
+    private String extra;
+
+    private int value;
+
+
+    //设备现有状态: 正常、报警、预警、故障……
+
+    private State state;
+
+    private CraneSummaryDTO craneSummaryDTO;
+    private TechParamsDTO techParamsDTO;
+
+
+    public CraneDTO(CraneSummaryDTO craneSummaryDTO, TechParamsDTO techParamsDTO) {
+        this.craneSummaryDTO = craneSummaryDTO;
+        this.techParamsDTO = techParamsDTO;
+
+    }
+
+    public CraneDTO() {
+
+    }
+
+    public CraneDTO(Device crane){
+        if(crane==null){
+            return;
+        }
+        this.id=crane.getId();
+        this.createTime=crane.getCreateTime();
+        this.updateTime=crane.getUpdateTime();
+        this.name=crane.getName();
+        this.remark=crane.getRemark();
+        this.extra=crane.getExtra();
+        this.value=this.id;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getExtra() {
+        return extra;
+    }
+
+    public void setExtra(String extra) {
+        this.extra = extra;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getFullName() {
+        return fullName;
+    }
+
+    public void setFullName(String fullName) {
+        this.fullName = fullName;
+    }
+
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    public CraneSummaryDTO getCraneSummaryDTO() {
+        return craneSummaryDTO;
+    }
+
+    public void setCraneSummaryDTO(CraneSummaryDTO craneSummaryDTO) {
+        this.craneSummaryDTO = craneSummaryDTO;
+    }
+
+    public TechParamsDTO getTechParamsDTO() {
+        return techParamsDTO;
+    }
+
+    public void setTechParamsDTO(TechParamsDTO techParamsDTO) {
+        this.techParamsDTO = techParamsDTO;
+    }
+}

+ 276 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/CraneSummaryDTO.java

@@ -0,0 +1,276 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.lstznkj.groundstation.model.crane.extra.DeviceSummary;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+import java.sql.Timestamp;
+
+public class CraneSummaryDTO {
+
+    //数据库唯一标识符
+    private Integer id;
+
+
+    private Timestamp createTimestamp;
+
+    private Timestamp updateTimestamp;
+
+
+    private String createTime;
+
+    private String updateTime;
+    private String name;
+
+    //规格
+    private String specification;
+
+    //制造厂家
+    private String produceCompany;
+
+    //制造编号
+    private String produceNumber;
+
+    //制造日期
+    private String produceTime;
+    //安装日期
+    private String  installTime;
+    //开始使用日期
+    private String startTime;
+
+    //设备原值
+    private double originPrice;
+    private String originPriceUnit;
+
+    //设备使用年限
+    private long ageLimit;
+
+    //外形尺寸
+    private String profile;
+
+    //图号
+    private String imageNumber;
+
+    //使用单位
+    private String usedUnit;
+
+    //简介
+    private String introduction;
+
+
+    public  CraneSummaryDTO(){
+
+    }
+    public CraneSummaryDTO(DeviceSummary deviceSummary){
+
+        if(deviceSummary==null){
+            return;
+        }
+        this.id=deviceSummary.getId();
+
+
+        this.createTimestamp=deviceSummary.getCreateTimestamp();
+
+        this.updateTimestamp=deviceSummary.getUpdateTimestamp();
+
+
+        this.createTime=deviceSummary.getCreateTime();
+
+        this.updateTime=deviceSummary.getUpdateTime();
+        this.name= deviceSummary.getName();
+
+        //规格
+        this.specification= deviceSummary.getSpecification();
+
+        //制造厂家
+        this.produceCompany= deviceSummary.getProduceCompany();
+
+        //制造编号
+        this.produceNumber=deviceSummary.getProduceNumber();
+
+        //制造日期
+        this.produceTime= DateUtil.getSingleInstance().formatToSecond(deviceSummary.getProduceTime());
+        //安装日期
+        this.installTime=DateUtil.getInstance().formatToSecond(deviceSummary.getInstallTime());
+        //开始使用日期
+        this.startTime=DateUtil.getInstance().formatToSecond(deviceSummary.getStartTime());
+
+        //设备原值
+        this.originPrice=deviceSummary.getOriginPrice();
+        this.originPriceUnit=deviceSummary.getOriginPriceUnit();
+
+        //设备使用年限
+        this.ageLimit=deviceSummary.getAgeLimit();
+
+        //外形尺寸
+        this.profile= deviceSummary.getProfile();
+
+        //图号
+        this.imageNumber= deviceSummary.getImageNumber();
+
+        //使用单位
+        this.usedUnit= deviceSummary.getUsedUnit();
+
+        //简介
+        this.introduction=deviceSummary.getIntroduction();
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+    public String getProduceCompany() {
+        return produceCompany;
+    }
+
+    public void setProduceCompany(String produceCompany) {
+        this.produceCompany = produceCompany;
+    }
+
+
+
+    public long getAgeLimit() {
+        return ageLimit;
+    }
+
+    public void setAgeLimit(long ageLimit) {
+        this.ageLimit = ageLimit;
+    }
+
+    public String getProfile() {
+        return profile;
+    }
+
+    public void setProfile(String profile) {
+        this.profile = profile;
+    }
+
+    public String getImageNumber() {
+        return imageNumber;
+    }
+
+    public void setImageNumber(String imageNumber) {
+        this.imageNumber = imageNumber;
+    }
+
+    public String getUsedUnit() {
+        return usedUnit;
+    }
+
+    public void setUsedUnit(String usedUnit) {
+        this.usedUnit = usedUnit;
+    }
+
+    public String getIntroduction() {
+        return introduction;
+    }
+
+    public void setIntroduction(String introduction) {
+        this.introduction = introduction;
+    }
+
+    public String getProduceTime() {
+        return produceTime;
+    }
+
+    public void setProduceTime(String produceTime) {
+        this.produceTime = produceTime;
+    }
+
+    public String getInstallTime() {
+        return installTime;
+    }
+
+    public void setInstallTime(String installTime) {
+        this.installTime = installTime;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public double getOriginPrice() {
+        return originPrice;
+    }
+
+    public void setOriginPrice(double originPrice) {
+        this.originPrice = originPrice;
+    }
+
+    public String getOriginPriceUnit() {
+        return originPriceUnit;
+    }
+
+    public void setOriginPriceUnit(String originPriceUnit) {
+        this.originPriceUnit = originPriceUnit;
+    }
+
+    public String getProduceNumber() {
+        return produceNumber;
+    }
+
+    public void setProduceNumber(String produceNumber) {
+        this.produceNumber = produceNumber;
+    }
+}

+ 22 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/DataSourceRequestDTO.java

@@ -0,0 +1,22 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+public class DataSourceRequestDTO {
+    private int id;
+    private String name;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 386 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/DataSourceUIDTO.java

@@ -0,0 +1,386 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.model.crane.BaseData;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.DataType;
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * A DTO for the {@link DataSource} entity
+ */
+public class DataSourceUIDTO implements Serializable {
+
+    private int id;
+    private String name;
+
+    //是否启用
+    private Boolean isEnable;
+
+    //采集地址
+    private String address;
+
+
+
+
+
+
+    //mqtt发布主题名称
+    private String publishTopic;
+    private Timestamp createTimestamp;
+
+    private Timestamp updateTimestamp;
+
+    private String createTime;
+
+    private int dataTypeId;
+
+    private String updateTime;
+
+    private List<String> valueList=new ArrayList<>();
+
+
+    private List<String> dateList=new ArrayList<>();
+    //报警阈值
+    private float threshold;
+    private float maxValue;
+    private float minValue;
+
+
+    //稀疏差异值(大于等于稀疏差异值 才存储到数据库),-1时,不进行稀疏存储
+    private double differSparseValue;
+
+
+    private int sparseCount;
+
+    //累计 稀疏值,(超过累计稀疏值后 存储到数据库)
+
+    private double totalSparseValue;
+
+
+    private int tmpSparseCount;
+
+
+
+    private BaseData lastBaseData;
+
+    private double differTotalValue;
+
+    private List<BaseData> baseDataList;
+
+    private DataType dataType;
+    private Device device;
+
+    private String deviceInfo;
+
+    private String dataTypeInfo;
+
+
+    private int deviceId;
+    private int oldDeviceId;
+
+    private String remark;
+
+    private String deviceName;
+
+    public DataSourceUIDTO(){}
+
+
+    public DataSourceUIDTO(DataSource dataSource) {
+        this.id = dataSource.getId();
+        this.name =dataSource.getName();
+        this.isEnable = dataSource.getEnable();
+
+      //  this.dataType = dataSource.getDataType();
+
+        this.threshold = dataSource.getThreshold();
+        this.maxValue = dataSource.getMaxValue();
+        this.minValue = dataSource.getMinValue();
+        this.device = dataSource.getDevice();
+
+       // this.baseDataList = dataSource.getBaseDataList();
+        this.deviceId=dataSource.getDeviceId();
+        this.dataTypeId=dataSource.getDataTypeId();
+        this.publishTopic=dataSource.getPublishTopic();
+
+        this.differSparseValue=dataSource.getDifferSparseValue();
+        this.baseDataList=dataSource.getBaseDataList();
+
+        this.sparseCount=dataSource.getSparseCount();
+
+        //累计 稀疏值,(超过累计稀疏值后 存储到数据库)
+
+        this.totalSparseValue=dataSource.getTotalSparseValue();
+
+
+        this.tmpSparseCount=dataSource.getTmpSparseCount();
+
+
+
+        this.lastBaseData=dataSource.getLastBaseData();
+
+        this.differTotalValue=dataSource.getDifferTotalValue();
+
+
+        this.deviceInfo=dataSource.getDeviceInfo();
+
+        this.dataTypeInfo=dataSource.getDataTypeInfo();
+        this.dataType=dataSource.getDataType();
+
+        this.deviceId=dataSource.getDeviceId();
+
+        this.remark=dataSource.getRemark();
+        this.deviceName=dataSource.getDeviceName();
+
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDeviceName() {
+        return deviceName;
+    }
+
+    public void setDeviceName(String deviceName) {
+        this.deviceName = deviceName;
+    }
+
+    public DataType getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public List<BaseData> getBaseDataList() {
+        return baseDataList;
+    }
+
+    public void setBaseDataList(List<BaseData> baseDataList) {
+        this.baseDataList = baseDataList;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return isEnable;
+    }
+
+    public void setEnable(Boolean enable) {
+        isEnable = enable;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+
+    public int getOldDeviceId() {
+        return oldDeviceId;
+    }
+
+    public void setOldDeviceId(int oldDeviceId) {
+        this.oldDeviceId = oldDeviceId;
+    }
+
+    public String getPublishTopic() {
+        return publishTopic;
+    }
+
+    public void setPublishTopic(String publishTopic) {
+        this.publishTopic = publishTopic;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public int getDataTypeId() {
+        return dataTypeId;
+    }
+
+    public void setDataTypeId(int dataTypeId) {
+        this.dataTypeId = dataTypeId;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public List<String> getValueList() {
+        return valueList;
+    }
+
+    public void setValueList(List<String> valueList) {
+        this.valueList = valueList;
+    }
+
+    public List<String> getDateList() {
+        return dateList;
+    }
+
+    public void setDateList(List<String> dateList) {
+        this.dateList = dateList;
+    }
+
+    public float getThreshold() {
+        return threshold;
+    }
+
+    public void setThreshold(float threshold) {
+        this.threshold = threshold;
+    }
+
+    public float getMaxValue() {
+        return maxValue;
+    }
+
+    public void setMaxValue(float maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public float getMinValue() {
+        return minValue;
+    }
+
+    public void setMinValue(float minValue) {
+        this.minValue = minValue;
+    }
+
+    public double getDifferSparseValue() {
+        return differSparseValue;
+    }
+
+    public void setDifferSparseValue(double differSparseValue) {
+        this.differSparseValue = differSparseValue;
+    }
+
+    public int getSparseCount() {
+        return sparseCount;
+    }
+
+    public void setSparseCount(int sparseCount) {
+        this.sparseCount = sparseCount;
+    }
+
+    public double getTotalSparseValue() {
+        return totalSparseValue;
+    }
+
+    public void setTotalSparseValue(double totalSparseValue) {
+        this.totalSparseValue = totalSparseValue;
+    }
+
+    public int getTmpSparseCount() {
+        return tmpSparseCount;
+    }
+
+    public void setTmpSparseCount(int tmpSparseCount) {
+        this.tmpSparseCount = tmpSparseCount;
+    }
+
+    public BaseData getLastBaseData() {
+        return lastBaseData;
+    }
+
+    public void setLastBaseData(BaseData lastBaseData) {
+        this.lastBaseData = lastBaseData;
+    }
+
+    public double getDifferTotalValue() {
+        return differTotalValue;
+    }
+
+    public void setDifferTotalValue(double differTotalValue) {
+        this.differTotalValue = differTotalValue;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public String getDeviceInfo() {
+        return deviceInfo;
+    }
+
+    public void setDeviceInfo(String deviceInfo) {
+        this.deviceInfo = deviceInfo;
+    }
+
+    public String getDataTypeInfo() {
+        return dataTypeInfo;
+    }
+
+    public void setDataTypeInfo(String dataTypeInfo) {
+        this.dataTypeInfo = dataTypeInfo;
+    }
+
+    public int getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(int deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 64 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/DataTypeDTO.java

@@ -0,0 +1,64 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+public class DataTypeDTO {
+
+    private Integer id;
+
+
+    private String name;
+
+    //0 模拟量(4-20mA),1开关量
+    private int valueType;
+
+    //采集方法
+    // 0 485 ,1 PLC
+    private String method;
+    private String expression;
+
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getValueType() {
+        return valueType;
+    }
+
+    public void setValueType(int valueType) {
+        this.valueType = valueType;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+}

+ 50 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/DeviceDTO.java

@@ -0,0 +1,50 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+public class DeviceDTO {
+
+    private int id;
+    private String name;
+    private String remark;
+    private int fatherId;
+    private int oldFatherId;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public int getFatherId() {
+        return fatherId;
+    }
+
+    public void setFatherId(int fatherId) {
+        this.fatherId = fatherId;
+    }
+
+    public int getOldFatherId() {
+        return oldFatherId;
+    }
+
+    public void setOldFatherId(int oldFatherId) {
+        this.oldFatherId = oldFatherId;
+    }
+}

+ 275 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/EquipmentDTO.java

@@ -0,0 +1,275 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.lstznkj.groundstation.model.crane.LifeModel;
+import com.lstznkj.groundstation.model.crane.extra.Equipment;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import java.sql.Timestamp;
+
+public class EquipmentDTO {
+    private int id;
+    private String name;
+    private String type;
+    private int deviceId;
+    private String remark;
+    private String specification;
+    private String material;
+    private String produceCompany;
+    private int updateCycle;
+    private String updateCycleUnit;
+
+    private long runTime;
+    private String runTimeUnit; // 运行时间
+
+    private long overloadTime;
+
+    private String overloadTimeUnit;
+    private int startsCount; // 启动次数
+    private int actionCount; // 动作次数
+    private int brakingCount;  // 制动次数
+
+    private String installTime;
+
+    private Timestamp createTimestamp;
+
+
+    private String partNo;
+
+    private String imageUrl;
+
+    private String uuid;
+
+    private int oldDeviceId;
+
+    public EquipmentDTO(){
+
+    }
+    public EquipmentDTO(Equipment equipment, LifeModel lifeModel){
+
+        this. id=equipment.getId();
+        this.name=equipment.getName();
+        this.type=String.valueOf(equipment.getType());
+
+        this.deviceId=equipment.getDevice().getId();
+        this.remark=equipment.getRemark();
+        this.specification=equipment.getSpecification();
+        this.material=equipment.getMaterial();
+        this.produceCompany=equipment.getProduceCompany();
+
+        this.installTime=equipment.getInstallTime();
+
+        this.partNo=equipment.getPartNo();
+
+        this.imageUrl=equipment.getName()+equipment.getUuid();
+
+        this.uuid=equipment.getUuid();
+        this.createTimestamp=equipment.getCreateTimestamp();
+
+
+        if(lifeModel!=null){
+            this.updateCycle= lifeModel.getUpdateCycle();
+
+            this.updateCycleUnit= lifeModel.getUpdateCycleUnit();
+
+            this.runTime= lifeModel.getRunTime();
+            //this.runTimeUnit=lifeModel; // 运行时间
+
+            this.overloadTime=lifeModel.getOverloadTime();
+
+            this.overloadTimeUnit=lifeModel.getOverloadTimeUnit();
+            this.startsCount=lifeModel.getStartsCount();
+
+            this.actionCount= lifeModel.getActionCount();
+
+            this.brakingCount= lifeModel.getBrakingCount();
+            this.updateCycle= lifeModel.getUpdateCycle();
+            this.updateCycleUnit=lifeModel.getUpdateCycleUnit();
+
+        }
+
+    }
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public int getOldDeviceId() {
+        return oldDeviceId;
+    }
+
+    public void setOldDeviceId(int oldDeviceId) {
+        this.oldDeviceId = oldDeviceId;
+    }
+
+    public int getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(int deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+    public String getMaterial() {
+        return material;
+    }
+
+    public void setMaterial(String material) {
+        this.material = material;
+    }
+
+    public String getProduceCompany() {
+        return produceCompany;
+    }
+
+    public void setProduceCompany(String produceCompany) {
+        this.produceCompany = produceCompany;
+    }
+
+    public int getUpdateCycle() {
+        return updateCycle;
+    }
+
+    public void setUpdateCycle(int updateCycle) {
+        this.updateCycle = updateCycle;
+    }
+
+    public String getUpdateCycleUnit() {
+        return updateCycleUnit;
+    }
+
+    public void setUpdateCycleUnit(String updateCycleUnit) {
+        this.updateCycleUnit = updateCycleUnit;
+    }
+
+    public long getRunTime() {
+        return runTime;
+    }
+
+    public void setRunTime(long runTime) {
+        this.runTime = runTime;
+    }
+
+    public String getRunTimeUnit() {
+        return runTimeUnit;
+    }
+
+    public void setRunTimeUnit(String runTimeUnit) {
+        this.runTimeUnit = runTimeUnit;
+    }
+
+    public long getOverloadTime() {
+        return overloadTime;
+    }
+
+    public void setOverloadTime(long overloadTime) {
+        this.overloadTime = overloadTime;
+    }
+
+    public String getOverloadTimeUnit() {
+        return overloadTimeUnit;
+    }
+
+    public void setOverloadTimeUnit(String overloadTimeUnit) {
+        this.overloadTimeUnit = overloadTimeUnit;
+    }
+
+    public int getStartsCount() {
+        return startsCount;
+    }
+
+    public void setStartsCount(int startsCount) {
+        this.startsCount = startsCount;
+    }
+
+    public int getActionCount() {
+        return actionCount;
+    }
+
+    public void setActionCount(int actionCount) {
+        this.actionCount = actionCount;
+    }
+
+    public int getBrakingCount() {
+        return brakingCount;
+    }
+
+    public void setBrakingCount(int brakingCount) {
+        this.brakingCount = brakingCount;
+    }
+
+    public String getInstallTime() {
+        return installTime;
+    }
+
+    public void setInstallTime(String installTime) {
+        this.installTime = installTime;
+    }
+
+    public String getPartNo() {
+        return partNo;
+    }
+
+    public void setPartNo(String partNo) {
+        this.partNo = partNo;
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+}

+ 19 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/LegendDTO.java

@@ -0,0 +1,19 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LegendDTO {
+    private List<String> data;
+
+    public LegendDTO(){
+        this.data=new ArrayList<>();
+    }
+    public List<String> getData() {
+        return data;
+    }
+
+    public void setData(List<String> data) {
+        this.data = data;
+    }
+}

+ 48 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/SeriesDTO.java

@@ -0,0 +1,48 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SeriesDTO {
+    private String name;
+    private String type;
+    private String stack;
+    private List<Double> data;
+
+    public SeriesDTO(){
+        this.data=new ArrayList<>();
+        this.type="line";
+        this.stack="Total";
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getStack() {
+        return stack;
+    }
+
+    public void setStack(String stack) {
+        this.stack = stack;
+    }
+
+    public List<Double> getData() {
+        return data;
+    }
+
+    public void setData(List<Double> data) {
+        this.data = data;
+    }
+}

+ 614 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/TechParamsDTO.java

@@ -0,0 +1,614 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.extra.TechParameter;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+public class TechParamsDTO {
+
+    private Integer id;
+
+
+    private Timestamp createTimestamp;
+
+    private Timestamp updateTimestamp;
+
+
+    private String createTime;
+
+    private String updateTime;
+
+    //长度
+    private double length;
+    //长度
+    private String lengthUnit;
+    //宽度
+    private double width;
+    private String widthUnit;
+
+    //最高点距柜面
+    private double highestValueToRail;
+    private String highestValueToRailUnit;
+
+    //轨面标高
+    private double railSurfaceHeight;
+    private String railSurfaceHeightUnit;
+
+    //大车缓冲器行程
+    private double bigCarBufferDistance;
+    private String bigCarBufferDistanceUnit;
+
+    //小车车缓冲器行程
+    private double smallCarBufferDistance;
+    private String smallCarBufferDistanceUnit;
+
+
+    //各机构电机功率总和
+    private double powerGenerationgTotalCapacity;
+    private String powerGenerationgTotalCapacityUnit;
+
+
+    //主起重量
+    private double mainHoistWeight;
+    private String mainHoistWeightUnit;
+
+    //副起重量
+    private double deputyHoistWeight;
+    private String deputyHoistWeightUnit;
+
+    //大车跨度
+    private double bigCarLength;
+    private String bigCarLengthUnit;
+
+    //小车车跨度
+    private double smallCarLength;
+    private String smallCarLengthUnit;
+
+    //工作级别(M5)
+    private String workLevel;
+
+
+
+    //主起最小速度
+    private double mainHoistMinSpeed;
+    private String mainHoistMinSpeedUnit;
+
+
+    //主起最大速度
+    private double mainHoistMaxSpeed;
+    private String mainHoistMaxSpeedUnit;
+
+    //副起升最小速度
+    private double deputyHoistMinSpeed;
+    private String deputyHoistMinSpeedUnit;
+
+    //副起升最大速度
+    private double deputyHoistMaxSpeed;
+    private String deputyHoistMaxSpeedUnit;
+
+
+    //大车最小运行速度
+    private double bigCarMinSpeed;
+    private String bigCarminSpeedUnit;
+
+    //大车最大运行速度
+    private double bigCarMaxSpeed;
+    private String bigCarMaxSpeedUnit;
+
+
+    //小车车最小运行速度
+    private double smallCarMinSpeed;
+    private String smallCarminSpeedUnit;
+
+    //小车最大运行速度
+    private double smallCarMaxSpeed;
+    private String smallCarMaxSpeedUnit;
+
+
+    private double mainHoistHeight;
+    private String mainHoistHeightUnit;
+    private double deputyHoistHeight;
+    private String deputyHoistHeightUnit;
+
+
+    public TechParamsDTO(){
+
+    }
+    public TechParamsDTO(TechParameter techParameter){
+
+        if(techParameter==null){
+            return;
+        }
+        this.id= techParameter.getId();
+
+
+        this.createTimestamp=techParameter.getCreateTimestamp();
+
+        this.updateTimestamp=techParameter.getUpdateTimestamp();
+
+
+        this.createTime=techParameter.getCreateTime();
+
+        this.updateTime=techParameter.getUpdateTime();
+
+        //长度
+        this.length=techParameter.getLength();
+        //长度
+        this.lengthUnit=techParameter.getLengthUnit();
+        //宽度
+        this.width=techParameter.getWidth();
+        this.widthUnit=techParameter.getWidthUnit();
+
+        //最高点距柜面
+        this.highestValueToRail=techParameter.getHighestValueToRail();
+        this.highestValueToRailUnit=techParameter.getHighestValueToRailUnit();
+
+        //轨面标高
+        this.railSurfaceHeight= techParameter.getRailSurfaceHeight();
+        this.railSurfaceHeightUnit=techParameter.getRailSurfaceHeightUnit();
+
+        //大车缓冲器行程
+        this.bigCarBufferDistance=techParameter.getBigCarBufferDistance();
+        this.bigCarBufferDistanceUnit=techParameter.getBigCarBufferDistanceUnit();
+
+        //小车车缓冲器行程
+        this.smallCarBufferDistance=techParameter.getSmallCarBufferDistance();
+        this.smallCarBufferDistanceUnit=techParameter.getSmallCarBufferDistanceUnit();
+
+
+        //各机构电机功率总和
+        this.powerGenerationgTotalCapacity=techParameter.getPowerGenerationgTotalCapacity();
+        this.powerGenerationgTotalCapacityUnit=techParameter.getPowerGenerationgTotalCapacityUnit();
+
+
+        //主起重量
+        this.mainHoistWeight=techParameter.getMainHoistWeight();
+        this.mainHoistWeightUnit=techParameter.getMainHoistWeightUnit();
+
+        //副起重量
+        this.deputyHoistWeight=techParameter.getDeputyHoistWeight();
+        this.deputyHoistWeightUnit=techParameter.getDeputyHoistWeightUnit();
+
+        //大车跨度
+        this.bigCarLength=techParameter.getBigCarLength();
+        this.bigCarLengthUnit=techParameter.getBigCarLengthUnit();
+
+        //小车车跨度
+        this.smallCarLength=techParameter.getSmallCarLength();
+        this.smallCarLengthUnit=techParameter.getSmallCarLengthUnit();
+
+        //工作级别(M5)
+        this.workLevel=techParameter.getWorkLevel();
+
+
+
+        //主起最小速度
+        this.mainHoistMinSpeed=techParameter.getMainHoistMinSpeed();
+        this.mainHoistMinSpeedUnit=techParameter.getMainHoistMinSpeedUnit();
+
+
+        //主起最大速度
+        this.mainHoistMaxSpeed=techParameter.getMainHoistMaxSpeed();
+        this.mainHoistMaxSpeedUnit=techParameter.getMainHoistMaxSpeedUnit();
+
+        //副起升最小速度
+        this.deputyHoistMinSpeed=techParameter.getDeputyHoistMinSpeed();
+        this.deputyHoistMinSpeedUnit=techParameter.getDeputyHoistMinSpeedUnit();
+
+        //副起升最大速度
+        this.deputyHoistMaxSpeed=techParameter.getDeputyHoistMaxSpeed();
+        this.deputyHoistMaxSpeedUnit=techParameter.getDeputyHoistMaxSpeedUnit();
+
+
+        //大车最小运行速度
+        this.bigCarMinSpeed=techParameter.getBigCarMinSpeed();
+        this.bigCarminSpeedUnit=techParameter.getBigCarminSpeedUnit();
+
+        //大车最大运行速度
+        this.bigCarMaxSpeed=techParameter.getBigCarMaxSpeed();
+        this.bigCarMaxSpeedUnit=techParameter.getBigCarMaxSpeedUnit();
+
+
+        //小车车最小运行速度
+        this.smallCarMinSpeed=techParameter.getSmallCarMinSpeed();
+        this.smallCarminSpeedUnit=techParameter.getSmallCarminSpeedUnit();
+
+        //小车最大运行速度
+        this.smallCarMaxSpeed=techParameter.getSmallCarMaxSpeed();
+        this.smallCarMaxSpeedUnit=techParameter.getSmallCarMaxSpeedUnit();
+
+
+        this.mainHoistHeight=techParameter.getMainHoistHeight();
+        this.mainHoistHeightUnit=techParameter.getMainHoistHeightUnit();
+        this.deputyHoistHeight=techParameter.getDeputyHoistHeight();
+        this.deputyHoistHeightUnit=techParameter.getDeputyHoistHeightUnit();
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public double getLength() {
+        return length;
+    }
+
+    public void setLength(double length) {
+        this.length = length;
+    }
+
+    public String getLengthUnit() {
+        return lengthUnit;
+    }
+
+    public void setLengthUnit(String lengthUnit) {
+        this.lengthUnit = lengthUnit;
+    }
+
+    public double getWidth() {
+        return width;
+    }
+
+    public void setWidth(double width) {
+        this.width = width;
+    }
+
+    public String getWidthUnit() {
+        return widthUnit;
+    }
+
+    public void setWidthUnit(String widthUnit) {
+        this.widthUnit = widthUnit;
+    }
+
+    public double getHighestValueToRail() {
+        return highestValueToRail;
+    }
+
+    public void setHighestValueToRail(double highestValueToRail) {
+        this.highestValueToRail = highestValueToRail;
+    }
+
+    public String getHighestValueToRailUnit() {
+        return highestValueToRailUnit;
+    }
+
+    public void setHighestValueToRailUnit(String highestValueToRailUnit) {
+        this.highestValueToRailUnit = highestValueToRailUnit;
+    }
+
+    public double getRailSurfaceHeight() {
+        return railSurfaceHeight;
+    }
+
+    public void setRailSurfaceHeight(double railSurfaceHeight) {
+        this.railSurfaceHeight = railSurfaceHeight;
+    }
+
+    public String getRailSurfaceHeightUnit() {
+        return railSurfaceHeightUnit;
+    }
+
+    public void setRailSurfaceHeightUnit(String railSurfaceHeightUnit) {
+        this.railSurfaceHeightUnit = railSurfaceHeightUnit;
+    }
+
+    public double getBigCarBufferDistance() {
+        return bigCarBufferDistance;
+    }
+
+    public void setBigCarBufferDistance(double bigCarBufferDistance) {
+        this.bigCarBufferDistance = bigCarBufferDistance;
+    }
+
+    public String getBigCarBufferDistanceUnit() {
+        return bigCarBufferDistanceUnit;
+    }
+
+    public void setBigCarBufferDistanceUnit(String bigCarBufferDistanceUnit) {
+        this.bigCarBufferDistanceUnit = bigCarBufferDistanceUnit;
+    }
+
+    public double getSmallCarBufferDistance() {
+        return smallCarBufferDistance;
+    }
+
+    public void setSmallCarBufferDistance(double smallCarBufferDistance) {
+        this.smallCarBufferDistance = smallCarBufferDistance;
+    }
+
+    public String getSmallCarBufferDistanceUnit() {
+        return smallCarBufferDistanceUnit;
+    }
+
+    public void setSmallCarBufferDistanceUnit(String smallCarBufferDistanceUnit) {
+        this.smallCarBufferDistanceUnit = smallCarBufferDistanceUnit;
+    }
+
+    public double getPowerGenerationgTotalCapacity() {
+        return powerGenerationgTotalCapacity;
+    }
+
+    public void setPowerGenerationgTotalCapacity(double powerGenerationgTotalCapacity) {
+        this.powerGenerationgTotalCapacity = powerGenerationgTotalCapacity;
+    }
+
+    public String getPowerGenerationgTotalCapacityUnit() {
+        return powerGenerationgTotalCapacityUnit;
+    }
+
+    public void setPowerGenerationgTotalCapacityUnit(String powerGenerationgTotalCapacityUnit) {
+        this.powerGenerationgTotalCapacityUnit = powerGenerationgTotalCapacityUnit;
+    }
+
+    public double getMainHoistWeight() {
+        return mainHoistWeight;
+    }
+
+    public void setMainHoistWeight(double mainHoistWeight) {
+        this.mainHoistWeight = mainHoistWeight;
+    }
+
+    public String getMainHoistWeightUnit() {
+        return mainHoistWeightUnit;
+    }
+
+    public void setMainHoistWeightUnit(String mainHoistWeightUnit) {
+        this.mainHoistWeightUnit = mainHoistWeightUnit;
+    }
+
+    public double getDeputyHoistWeight() {
+        return deputyHoistWeight;
+    }
+
+    public void setDeputyHoistWeight(double deputyHoistWeight) {
+        this.deputyHoistWeight = deputyHoistWeight;
+    }
+
+    public String getDeputyHoistWeightUnit() {
+        return deputyHoistWeightUnit;
+    }
+
+    public void setDeputyHoistWeightUnit(String deputyHoistWeightUnit) {
+        this.deputyHoistWeightUnit = deputyHoistWeightUnit;
+    }
+
+    public double getBigCarLength() {
+        return bigCarLength;
+    }
+
+    public void setBigCarLength(double bigCarLength) {
+        this.bigCarLength = bigCarLength;
+    }
+
+    public String getBigCarLengthUnit() {
+        return bigCarLengthUnit;
+    }
+
+    public void setBigCarLengthUnit(String bigCarLengthUnit) {
+        this.bigCarLengthUnit = bigCarLengthUnit;
+    }
+
+    public double getSmallCarLength() {
+        return smallCarLength;
+    }
+
+    public void setSmallCarLength(double smallCarLength) {
+        this.smallCarLength = smallCarLength;
+    }
+
+    public String getSmallCarLengthUnit() {
+        return smallCarLengthUnit;
+    }
+
+    public void setSmallCarLengthUnit(String smallCarLengthUnit) {
+        this.smallCarLengthUnit = smallCarLengthUnit;
+    }
+
+    public String getWorkLevel() {
+        return workLevel;
+    }
+
+    public void setWorkLevel(String workLevel) {
+        this.workLevel = workLevel;
+    }
+
+    public double getMainHoistMinSpeed() {
+        return mainHoistMinSpeed;
+    }
+
+    public void setMainHoistMinSpeed(double mainHoistMinSpeed) {
+        this.mainHoistMinSpeed = mainHoistMinSpeed;
+    }
+
+    public String getMainHoistMinSpeedUnit() {
+        return mainHoistMinSpeedUnit;
+    }
+
+    public void setMainHoistMinSpeedUnit(String mainHoistMinSpeedUnit) {
+        this.mainHoistMinSpeedUnit = mainHoistMinSpeedUnit;
+    }
+
+    public double getMainHoistMaxSpeed() {
+        return mainHoistMaxSpeed;
+    }
+
+    public void setMainHoistMaxSpeed(double mainHoistMaxSpeed) {
+        this.mainHoistMaxSpeed = mainHoistMaxSpeed;
+    }
+
+    public String getMainHoistMaxSpeedUnit() {
+        return mainHoistMaxSpeedUnit;
+    }
+
+    public void setMainHoistMaxSpeedUnit(String mainHoistMaxSpeedUnit) {
+        this.mainHoistMaxSpeedUnit = mainHoistMaxSpeedUnit;
+    }
+
+    public double getDeputyHoistMinSpeed() {
+        return deputyHoistMinSpeed;
+    }
+
+    public void setDeputyHoistMinSpeed(double deputyHoistMinSpeed) {
+        this.deputyHoistMinSpeed = deputyHoistMinSpeed;
+    }
+
+    public String getDeputyHoistMinSpeedUnit() {
+        return deputyHoistMinSpeedUnit;
+    }
+
+    public void setDeputyHoistMinSpeedUnit(String deputyHoistMinSpeedUnit) {
+        this.deputyHoistMinSpeedUnit = deputyHoistMinSpeedUnit;
+    }
+
+    public double getDeputyHoistMaxSpeed() {
+        return deputyHoistMaxSpeed;
+    }
+
+    public void setDeputyHoistMaxSpeed(double deputyHoistMaxSpeed) {
+        this.deputyHoistMaxSpeed = deputyHoistMaxSpeed;
+    }
+
+    public String getDeputyHoistMaxSpeedUnit() {
+        return deputyHoistMaxSpeedUnit;
+    }
+
+    public void setDeputyHoistMaxSpeedUnit(String deputyHoistMaxSpeedUnit) {
+        this.deputyHoistMaxSpeedUnit = deputyHoistMaxSpeedUnit;
+    }
+
+    public double getBigCarMinSpeed() {
+        return bigCarMinSpeed;
+    }
+
+    public void setBigCarMinSpeed(double bigCarMinSpeed) {
+        this.bigCarMinSpeed = bigCarMinSpeed;
+    }
+
+    public String getBigCarminSpeedUnit() {
+        return bigCarminSpeedUnit;
+    }
+
+    public void setBigCarminSpeedUnit(String bigCarminSpeedUnit) {
+        this.bigCarminSpeedUnit = bigCarminSpeedUnit;
+    }
+
+    public double getBigCarMaxSpeed() {
+        return bigCarMaxSpeed;
+    }
+
+    public void setBigCarMaxSpeed(double bigCarMaxSpeed) {
+        this.bigCarMaxSpeed = bigCarMaxSpeed;
+    }
+
+    public String getBigCarMaxSpeedUnit() {
+        return bigCarMaxSpeedUnit;
+    }
+
+    public void setBigCarMaxSpeedUnit(String bigCarMaxSpeedUnit) {
+        this.bigCarMaxSpeedUnit = bigCarMaxSpeedUnit;
+    }
+
+    public double getSmallCarMinSpeed() {
+        return smallCarMinSpeed;
+    }
+
+    public void setSmallCarMinSpeed(double smallCarMinSpeed) {
+        this.smallCarMinSpeed = smallCarMinSpeed;
+    }
+
+    public String getSmallCarminSpeedUnit() {
+        return smallCarminSpeedUnit;
+    }
+
+    public void setSmallCarminSpeedUnit(String smallCarminSpeedUnit) {
+        this.smallCarminSpeedUnit = smallCarminSpeedUnit;
+    }
+
+    public double getSmallCarMaxSpeed() {
+        return smallCarMaxSpeed;
+    }
+
+    public void setSmallCarMaxSpeed(double smallCarMaxSpeed) {
+        this.smallCarMaxSpeed = smallCarMaxSpeed;
+    }
+
+    public String getSmallCarMaxSpeedUnit() {
+        return smallCarMaxSpeedUnit;
+    }
+
+    public void setSmallCarMaxSpeedUnit(String smallCarMaxSpeedUnit) {
+        this.smallCarMaxSpeedUnit = smallCarMaxSpeedUnit;
+    }
+
+    public double getMainHoistHeight() {
+        return mainHoistHeight;
+    }
+
+    public void setMainHoistHeight(double mainHoistHeight) {
+        this.mainHoistHeight = mainHoistHeight;
+    }
+
+    public String getMainHoistHeightUnit() {
+        return mainHoistHeightUnit;
+    }
+
+    public void setMainHoistHeightUnit(String mainHoistHeightUnit) {
+        this.mainHoistHeightUnit = mainHoistHeightUnit;
+    }
+
+    public double getDeputyHoistHeight() {
+        return deputyHoistHeight;
+    }
+
+    public void setDeputyHoistHeight(double deputyHoistHeight) {
+        this.deputyHoistHeight = deputyHoistHeight;
+    }
+
+    public String getDeputyHoistHeightUnit() {
+        return deputyHoistHeightUnit;
+    }
+
+    public void setDeputyHoistHeightUnit(String deputyHoistHeightUnit) {
+        this.deputyHoistHeightUnit = deputyHoistHeightUnit;
+    }
+}

+ 33 - 0
src/main/java/com/lstznkj/groundstation/DTO/ui/xAxisDTO.java

@@ -0,0 +1,33 @@
+package com.lstznkj.groundstation.DTO.ui;
+
+import java.util.List;
+
+public class xAxisDTO {
+    private String type;
+    private  boolean boundaryGap;
+    private List<String> data;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public boolean isBoundaryGap() {
+        return boundaryGap;
+    }
+
+    public void setBoundaryGap(boolean boundaryGap) {
+        this.boundaryGap = boundaryGap;
+    }
+
+    public List<String> getData() {
+        return data;
+    }
+
+    public void setData(List<String> data) {
+        this.data = data;
+    }
+}

+ 39 - 0
src/main/java/com/lstznkj/groundstation/DemoApplication.java

@@ -0,0 +1,39 @@
+package com.lstznkj.groundstation;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.service.DataIntegrateService;
+import com.lstznkj.groundstation.service.InitService;
+import com.lstznkj.groundstation.service.TestService;
+import com.lstznkj.groundstation.service.crane.DataSourceService;
+import com.lstznkj.groundstation.utils.CalculateUtil;
+import com.lstznkj.groundstation.utils.SpringContextUtil;
+import com.ql.util.express.DefaultContext;
+import com.ql.util.express.ExpressRunner;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DemoApplication {
+
+    private static Logger logger=LoggerFactory.getLogger(DemoApplication.class);
+    public static void main(String[] args) {
+
+        SpringApplication.run(DemoApplication.class, args);
+
+        InitService initService=SpringContextUtil.getBean(InitService.class);
+        initService.init();
+       
+        DataIntegrateService dataIntegrateService= SpringContextUtil.getBean(DataIntegrateService.class);
+        dataIntegrateService.startDataCollectThreads();
+    
+        logger.info("exp stest:"+new CalculateUtil().calculate("16/3276*x/16*200-50",1300));
+
+        new TestService().tryGroup();
+
+
+    }
+
+}

+ 18 - 0
src/main/java/com/lstznkj/groundstation/GlobalData.java

@@ -0,0 +1,18 @@
+package com.lstznkj.groundstation;
+
+import com.lstznkj.groundstation.model.crane.ThreadMonitorInfo;
+import com.lstznkj.groundstation.mqtt.MqttProvider;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class GlobalData {
+    public final static String SERVER_URL="localhost:8083";
+    public static List<ThreadMonitorInfo> threadMonitorInfoList=new ArrayList<>();
+
+   // public static ExecutorService suscribeThreadPool;
+
+    public static ExecutorService DataSaveThreadPool= Executors.newCachedThreadPool();
+}

+ 189 - 0
src/main/java/com/lstznkj/groundstation/MVCConfig.java

@@ -0,0 +1,189 @@
+package com.lstznkj.groundstation;
+
+import com.lstznkj.groundstation.model.*;
+import com.lstznkj.groundstation.repo.AuthorityRepository;
+import com.lstznkj.groundstation.repo.SysRoleRepository;
+import com.lstznkj.groundstation.repo.UserRepository;
+import com.lstznkj.groundstation.service.AuthorityService;
+import com.lstznkj.groundstation.service.InitService;
+import com.lstznkj.groundstation.service.SysRoleService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import java.util.ArrayList;
+import java.util.List;
+
+@Configuration
+public class MVCConfig implements WebMvcConfigurer {
+    private Logger logger = LoggerFactory.getLogger(MVCConfig.class);
+    @Autowired
+    private UserRepository userRepository;
+    @Autowired
+    private AuthorityService authorityService;
+
+    @Autowired
+    private AuthorityRepository authorityRepository;
+
+    @Autowired
+    private SysRoleRepository sysRoleRepository;
+    @Autowired
+    private SysRoleService sysRoleService;
+    @Autowired
+    private BCryptPasswordEncoder passwordEncoder;
+    @Autowired
+    private InitService initService;
+
+    public void addViewControllers(ViewControllerRegistry registry) {
+        registry.addViewController("/home").setViewName("home");
+
+        registry.addViewController("/hello").setViewName("hello");
+        registry.addViewController("/login").setViewName("login");
+
+        initAuthority();
+        // initSysRole();
+
+        initService.initState();
+        initService.initDataTypes();
+        // initService.initAuthorities();
+        initService.initSysRoles();
+        initService.initUsers();
+
+        // initService.initTestCraneData();
+
+        initTestData();
+
+    }
+
+    private void initAuthority() {
+        // 后端添加权限-权限
+        Authority authAuthAdd = new Authority();
+        // 后端删除权限-权限
+        Authority authAuthDel = new Authority();
+        // 后端修改权限-权限
+        Authority authAuthUpd = new Authority();
+        // 后端查看权限-权限
+        Authority authAuthGet = new Authority();
+
+        Authority systemSettingAuth = new Authority();
+        systemSettingAuth.setName("系统设置菜单");
+
+    }
+
+    private void initSysRole() {
+
+        // 终极管理员,拥有修改删除所有信息权限
+        SysRole ultimateSysRole = new SysRole();
+        // 普同用户
+        SysRole userSysRole = new SysRole();
+        // 管理员
+        SysRole adminSysRole = new SysRole();
+
+        adminSysRole.setName("ROLE_ADMIN");
+        adminSysRole.setDescription("普通管理员");
+
+        userSysRole.setName("ROLE_USER");
+        userSysRole.setDescription("普通用户");
+
+        ultimateSysRole.setName(("ROLE_ULTIMATE"));
+        ultimateSysRole.setDescription("超级管理员");
+
+        //// 初始化普通用户角色
+        if (!sysRoleRepository.existsSysRoleByName(userSysRole.getName())) {
+            logger.info("user role has not been existed");
+            Authority getUserInfoAuthority = authorityRepository.findAuthorityByName("获取用户信息");
+            userSysRole.getAuthorities().add(getUserInfoAuthority);
+            getUserInfoAuthority.getSysRoles().add(userSysRole);
+
+            userSysRole = sysRoleRepository.save(userSysRole);
+
+            sysRoleRepository.save(userSysRole);
+
+        } else {
+
+            logger.info("user role has been existed");
+
+        }
+        // end-初始化普通用户角色
+
+        // 初始化超级管理员角色
+        if (!sysRoleRepository.existsSysRoleByName(ultimateSysRole.getName())) {
+            logger.info("ultimate role has not been existed");
+            // 设置权限
+
+            List<SysRole> sysRoles = new ArrayList<>();
+            sysRoles.add(ultimateSysRole);
+            List<Authority> authorityList = new ArrayList<>();
+
+            // 添加增删查改角色 权限
+            // authorityList.addAll(authorityRepository.findAuthoritiesByApiUrl("/roles/**"));
+            authorityList.addAll(authorityRepository.findAuthoritiesByApiUrl("/**"));
+
+            ultimateSysRole = sysRoleRepository.save(ultimateSysRole);
+
+            ultimateSysRole.setAuthorities(authorityList);
+
+            for (Authority auth : authorityList) {
+                auth.getSysRoles().add(ultimateSysRole);
+                // authorityRepository.save(auth);
+            }
+
+            sysRoleRepository.save(ultimateSysRole);
+
+        } else {
+            logger.info("ultimate role has  been existed");
+
+        }
+        // end-初始化超级管理员角色
+
+    }
+
+    /****
+     * 初始化用户数据,用户与角色 多对多关系 存在bug,没法通过角色获取用户
+     */
+    private void initTestData() {
+
+        User adminUlt = new User();
+        SysRole adminSysRole = sysRoleService.getAdminSysRole();
+
+        adminUlt.setName("ultimate");
+        adminUlt.setUsername("adminult");
+        adminUlt.setPassword(passwordEncoder.encode("123456"));
+
+        if (!userRepository.existsUserByUsername(adminUlt.getUsername())) {
+            adminUlt = userRepository.save(adminUlt);
+
+            List<SysRole> roles = new ArrayList<>();
+            roles.add(adminSysRole);
+            SysRole ultimateSysRole = sysRoleService.getUltimateSysRole();
+            ultimateSysRole.getUsers().add(adminUlt);
+            sysRoleRepository.save(ultimateSysRole);
+
+            roles.add(ultimateSysRole);
+
+            adminUlt.setSysRoles(roles);
+
+            userRepository.save(adminUlt);
+        }
+
+    }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+                .allowCredentials(true)
+                .allowedOrigins("*")
+                .allowedMethods("PUT", "POST", "GET", "DELETE").exposedHeaders("Authorization");
+
+        registry.addMapping("/users/**")
+                .allowCredentials(true)
+                .allowedOrigins("*")
+                .allowedMethods("PUT", "POST", "GET", "DELETE").exposedHeaders("Authorization");
+
+    }
+
+}

+ 29 - 0
src/main/java/com/lstznkj/groundstation/SwaggerConfig.java

@@ -0,0 +1,29 @@
+package com.lstznkj.groundstation;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    @Bean
+    public Docket getUserDocket(){
+        ApiInfo apiInfo=new ApiInfoBuilder()
+                .title("生产管理系统")//api标题
+                .description("生产管理系统相关接口描述")//api描述
+                .version("1.0.0")//版本号
+                .build();
+        return new Docket(DocumentationType.SWAGGER_2)//文档类型(swagger2)
+                .apiInfo(apiInfo)//设置包含在json ResourceListing响应中的api元信息
+                .select()//启动用于api选择的构建器
+                .apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))//扫描接口的包
+                .paths(PathSelectors.any())//路径过滤器(扫描所有路径)
+                .build();
+    }
+}

+ 17 - 0
src/main/java/com/lstznkj/groundstation/controller/AuthController.java

@@ -0,0 +1,17 @@
+package com.lstznkj.groundstation.controller;
+
+
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Api
+@RestController
+public class AuthController {
+
+    public Object add(HttpServletRequest request)
+    {
+        return null;
+    }
+}

+ 104 - 0
src/main/java/com/lstznkj/groundstation/controller/CraneController.java

@@ -0,0 +1,104 @@
+package com.lstznkj.groundstation.controller;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.DTO.ui.CraneDTO;
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.service.crane.CraneService;
+import com.lstznkj.groundstation.service.crane.DataSourceService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class CraneController {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private DataSourceService dataSourceService;
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private CraneService craneService;
+    @RequestMapping(method = RequestMethod.POST,value = "/cranes")
+    public Object createCrane(@RequestBody CraneDTO craneDTO){
+        Result<Device> result=new Result<>();
+        try {
+            logger.debug("start to addCrane:"+objectMapper.writeValueAsString(craneDTO));
+            result = craneService.addCrane(craneDTO);
+        }
+        catch (Exception ex){
+
+        }
+        return result;
+    }
+    @RequestMapping(method = RequestMethod.DELETE,value = "/cranes/{id}")
+    public Object deleteCrane(@PathVariable int id,@RequestBody CraneDTO craneDTO){
+        Result<Device> result=new Result<>();
+        try {
+            logger.info("start to deleteCrane:"+objectMapper.writeValueAsString(craneDTO));
+            result = craneService.deleteCraneById(id);
+        }
+        catch (Exception ex){
+
+        }
+        return result;
+    }
+    @RequestMapping(method = RequestMethod.PUT,value = "/cranes/{id}")
+    public Object update(@PathVariable int id, @RequestBody CraneDTO craneDTO){
+
+
+        Result<Device> result=new Result<>();
+
+        try {
+            logger.info("start to update crane:"+id+","+objectMapper.writeValueAsString(craneDTO));
+            result=craneService.updateCrane(id,craneDTO);
+
+        }
+        catch (Exception ex){
+
+        }
+
+        return result;
+    }
+    @RequestMapping(method = RequestMethod.GET,value = "/cranes")
+    public Object getAll(){
+        try {
+          return   craneService.getAllCranes();
+        }
+        catch (Exception ex){
+
+        }
+        return null;
+    }
+    @RequestMapping(value = "/cranes/{id}/dataSources/plc",method = RequestMethod.GET)
+    public Object getPLCDataSources(@PathVariable int id){
+        try {
+            logger.info("start to get "+id+" 's plc dataSources");
+
+            return dataSourceService.getAllPLCDataSources(id);
+        }
+        catch (Exception ex){
+
+        }
+        return null;
+    }
+    /***
+     * 获取指定起重机下 指定 名称的数据源(设备名+数据源名称区分)
+     * @param name
+     * @return
+     */
+    @RequestMapping(value = "/cranes/{id}/dataSources/{name}",method = RequestMethod.GET)
+    public Object getDataSourcesByName(@PathVariable int id, @PathVariable String name){
+        try {
+
+            logger.info("start to get craneId:"+id+",'s  dataSourceName:"+name);
+            return dataSourceService.getDataSourceByName(id,name);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return null;
+    }
+}

+ 166 - 0
src/main/java/com/lstznkj/groundstation/controller/DataSourceController.java

@@ -0,0 +1,166 @@
+package com.lstznkj.groundstation.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.DTO.ui.DataSourceRequestDTO;
+import com.lstznkj.groundstation.DTO.ui.DataSourceUIDTO;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.service.crane.DataSourceService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+public class DataSourceController {
+    @Autowired
+    private DataSourceService dataSourceService;
+    @Autowired
+    private ObjectMapper objectMapper;
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+
+    @RequestMapping(value = "/dataSources",method = RequestMethod.POST)
+    public Object add(@RequestBody DataSource dataSource){
+        try {
+            logger.info("start to add dataSource:"+objectMapper.writeValueAsString(dataSource));
+
+        }
+        catch (Exception ex){
+
+        }
+        return dataSourceService.add(dataSource);
+    }
+
+
+
+    @RequestMapping(value = "/dataSources/{id}",method = RequestMethod.PUT)
+    public Object update(@PathVariable int id, @RequestBody DataSourceUIDTO dataSourceUIDTO){
+        try {
+            logger.info("start to update dataSource:"+objectMapper.writeValueAsString(dataSourceUIDTO));
+
+        }
+        catch (Exception ex){
+
+        }
+        return dataSourceService.update(dataSourceUIDTO);
+    }
+
+    /***
+     * 获取指定id的设备的所有数据源,包括子设备
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/devices/{id}/dataSources",method = RequestMethod.GET)
+    public Object getAllDataSourcesByDeviceId(@PathVariable int id){
+        try {
+            logger.info("start to get device:"+id+" dataSources:");
+            return  dataSourceService.getAllDataSources(id);
+           //return   dataSourceService.getAllDataSourcesByDeviceId(id);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+
+
+    @RequestMapping(value = "/dataSources",method = RequestMethod.GET)
+    public Object getAll(){
+
+        return dataSourceService.getAll();
+    }
+
+    /**
+     * 查询指定id的数据源数据(限定时间段)
+     * @param id
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    @RequestMapping(value = "/chartDataDTO/{id}/{startTime}/{endTime}",method = RequestMethod.GET)
+    public Object getDataSourcesByIdAndDate(@PathVariable int id,@PathVariable String startTime,@PathVariable String endTime){
+
+        return dataSourceService.getChartDataDTO(id,startTime,endTime);
+
+    }
+
+    /**
+     * 查询图表数据,根据数据类型分组
+     * @param startTime
+     * @param endTime
+     * @param param
+     * @return
+     */
+    @RequestMapping(value = "/chartDataDTOList/{startTime}/{endTime}",method = RequestMethod.GET)
+    public Object getChartDataDTOListByDate(@PathVariable String startTime, @PathVariable String endTime,String param ){
+        List<DataSourceRequestDTO> dataSourceRequestDTOList=new ArrayList<>();
+        //@RequestBody List<DataSourceRequestDTO> dataSourceRequestDTOList
+        try {
+            String[] idList=param.split(",");
+
+
+            for(String s:idList){
+                DataSourceRequestDTO d=new DataSourceRequestDTO();
+                if(!s.equals("")){
+                    d.setId(Integer.valueOf(s));
+                    dataSourceRequestDTOList.add(d);
+                }
+                else {
+
+                }
+
+            }
+            logger.info("start to get ChartDataDTO of:"+objectMapper.writeValueAsString(idList));
+
+            logger.info("start to get ChartDataDTO of:"+objectMapper.writeValueAsString(dataSourceRequestDTOList));
+        }
+        catch (Exception ex){
+            logger.error("get ChartDataDTO error :"+ex.getMessage());
+            ex.printStackTrace();
+        }
+
+        return dataSourceService.getChartDataDTOList(startTime,endTime,dataSourceRequestDTOList);
+    }
+
+    @RequestMapping(value = "/chartDataDTO/{startTime}/{endTime}",method = RequestMethod.GET)
+    public Object getDataSourcesByDate(@PathVariable String startTime, @PathVariable String endTime,String param ){
+        List<DataSourceRequestDTO> dataSourceRequestDTOList=new ArrayList<>();
+        //@RequestBody List<DataSourceRequestDTO> dataSourceRequestDTOList
+        try {
+            String[] idList=param.split(",");
+
+            for(String s:idList){
+                DataSourceRequestDTO d=new DataSourceRequestDTO();
+                d.setId(Integer.valueOf(s));
+                dataSourceRequestDTOList.add(d);
+            }
+            logger.info("start to get ChartDataDTO of:"+objectMapper.writeValueAsString(idList));
+
+            logger.info("start to get ChartDataDTO of:"+objectMapper.writeValueAsString(dataSourceRequestDTOList));
+        }
+        catch (Exception ex){
+            logger.error("get ChartDataDTO error :"+ex.getMessage());
+            ex.printStackTrace();
+        }
+
+//        return "123";
+        return dataSourceService.getChartDataDTO(startTime,endTime,dataSourceRequestDTOList);
+
+    }
+
+
+
+
+    @RequestMapping(value = "/dataSources/{id}",method = RequestMethod.DELETE)
+    public Object deleteById(@PathVariable int id){
+        logger.info("start to delete datasource:"+id);
+        return dataSourceService.deleteById(id);
+    }
+
+
+}

+ 44 - 0
src/main/java/com/lstznkj/groundstation/controller/DataTypeController.java

@@ -0,0 +1,44 @@
+package com.lstznkj.groundstation.controller;
+
+
+import com.lstznkj.groundstation.model.crane.DataType;
+import com.lstznkj.groundstation.service.crane.DataTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class DataTypeController {
+    @Autowired
+    private DataTypeService dataTypeService;
+
+    @RequestMapping(value = "/dataTypes",method = RequestMethod.GET)
+    public Object getAllDataTypes(){
+        return dataTypeService.getAll();
+    }
+    @RequestMapping(value = "/dataTypes",method = RequestMethod.POST)
+    public Object addDataType(@RequestBody DataType dataType){
+        return dataTypeService.add(dataType);
+    }
+    @RequestMapping(value = "/dataTypes/{id}",method = RequestMethod.PUT)
+    public Object updateDataType(@PathVariable int id,@RequestBody DataType dataType){
+
+        return dataTypeService.update(dataType);
+    }
+    @RequestMapping(value = "/dataTypes/{id}",method = RequestMethod.DELETE)
+    public Object deleteById(@PathVariable int id){
+        return dataTypeService.deleteById(id);
+
+        
+    }
+
+    /***
+     * 获取指定天车的所有数据类型的数据源
+     * @return
+     */
+    @RequestMapping(value = "/cranes/{id}/dataTypeDTOs",method = RequestMethod.GET)
+    public Object getDataTypesByCraneId(@PathVariable int id){
+
+        return dataTypeService.findDataTypesByCraneId(id);
+    }
+
+}

+ 157 - 0
src/main/java/com/lstznkj/groundstation/controller/DeviceController.java

@@ -0,0 +1,157 @@
+package com.lstznkj.groundstation.controller;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.DTO.ui.DeviceDTO;
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.lstznkj.groundstation.service.crane.DataSourceService;
+import com.lstznkj.groundstation.service.crane.DeviceService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+@RestController
+public class DeviceController {
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DataSourceService dataSourceService;
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private JWTUtils jwtUtils;
+    @Deprecated
+    @RequestMapping(value = "/devices",method = RequestMethod.POST)
+    public Object addDevice(HttpServletRequest request,@RequestBody DeviceDTO deviceDTO){
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+
+        try {
+            logger.info(realUsername+" start to add device:"+objectMapper.writeValueAsString(deviceDTO));
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return deviceService.add(deviceDTO);
+    }
+    @RequestMapping(value = "/devices/{id}",method = RequestMethod.PUT)
+    public Object updateDevice(HttpServletRequest request,@PathVariable int id, @RequestBody DeviceDTO deviceDTO){
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+
+        try {
+            logger.info(realUsername+" start to update device:"+objectMapper.writeValueAsString(deviceDTO));
+            return deviceService.updateDevice(deviceDTO);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return null;
+    }
+    @RequestMapping(value = "/devices/{id}",method = RequestMethod.DELETE)
+    public Object deleteDevice(HttpServletRequest request,@PathVariable int id){
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+
+        try {
+            logger.info(realUsername+" start to delete device:"+id);
+
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return deviceService.deleteById(id);
+    }
+
+    @RequestMapping(value = "/devices/{id}/children",method = RequestMethod.GET)
+    public Object getChildrenDevice(@PathVariable int id){
+
+        return deviceService.getChildren(id);
+    }
+    @RequestMapping(value = "/devices/{id}",method = RequestMethod.GET)
+    public Object getDevice(@PathVariable int id){
+
+        return deviceService.getChildren(id);
+    }
+    @RequestMapping(value = "/devices",method = RequestMethod.GET)
+    public Object getAll(){
+
+        return deviceService.getAll();
+    }
+
+    /***
+     *获取天车列表
+     * @return
+     */
+    @RequestMapping(value = "/devices/level/0",method = RequestMethod.GET)
+    public Object getRootDevices(){
+        return deviceService.getRootDevices();
+    }
+
+    /***
+     *
+     * 获取指定id设备 下所有的 子设备数据源
+     * @param id
+     * @return
+     */
+
+    @RequestMapping(value = "/devices/{id}/childrenDataSources",method = RequestMethod.GET)
+    public Object getDataSourcesByDeviceId(HttpServletRequest request,@PathVariable int id) throws JsonProcessingException {
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+
+        logger.info(realUsername+" start to get all childrenDatasources");
+      //  Device device= deviceService.getDeviceById(id).getData();
+//        if(device==null){
+//            logger.info("device "+ id+" is null");
+//            return null;
+//        }
+//        else{
+//            //logger.info("device "+id+":"+objectMapper.writeValueAsString(device));
+//            return device.getChildrenDataSources();
+//        }
+        return dataSourceService.getAllDataSources(id);
+
+    }
+
+    /**
+     * 获取指定设备的某个数据源的历史检测数据
+     *
+     */
+    @RequestMapping(value = "/devices/{deviceId}/dataSourceUIDTOs/{sourceId}/{startTime}/{endTime}",method = RequestMethod.GET)
+    public Object getDeviceDataSourceDTO(@PathVariable int deviceId,@PathVariable int sourceId,@PathVariable String startTime,@PathVariable String endTime){
+
+        return  dataSourceService.getDataSourceUIDTO(sourceId,startTime,endTime);
+    }
+
+    /**
+     * 获取指定设备的所有数据源(包括子设备)
+     * @param id
+     * @return
+     */
+//    @RequestMapping(value = "/devices/{id}/dataSources",method = RequestMethod.GET)
+//    public Object getRootDeviceDataSourceList(@PathVariable int id){
+//
+//        return dataSourceService.getAllDataSources(id);
+//
+//    }
+
+    /**
+     * 获取指定设备的所有数据源(包括子设备)
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/devices/{id}/dataSourcePoolDTO",method = RequestMethod.GET)
+    public Object getRootDeviceDataSourceDTOList(@PathVariable int id){
+
+        return dataSourceService.getDataSourcePoolDTO(id);
+    }
+
+
+
+}

+ 141 - 0
src/main/java/com/lstznkj/groundstation/controller/EquipmentController.java

@@ -0,0 +1,141 @@
+package com.lstznkj.groundstation.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.DTO.ui.EquipmentDTO;
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.crane.extra.Equipment;
+import com.lstznkj.groundstation.service.ImageService;
+import com.lstznkj.groundstation.service.crane.extra.EquipmentService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@RestController
+public class EquipmentController {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    // @Value("${demo.imgPath}")
+    // private String imgPath;
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private EquipmentService equipmentService;
+    @Autowired
+    private ImageService imageService;
+    @RequestMapping(method = RequestMethod.POST,value = "/equipments")
+    public Object add(@RequestBody EquipmentDTO equipmentDTO){
+
+        try {
+            logger.info("start to add equipment:"+objectMapper.writeValueAsString(equipmentDTO));
+            return  equipmentService.add(equipmentDTO);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
+    @RequestMapping(method = RequestMethod.PUT,value = "/equipments/{id}")
+    public Object update(@PathVariable int id, @RequestBody EquipmentDTO equipmentDTO){
+
+        try {
+            logger.info("start to update equipment:"+objectMapper.writeValueAsString(equipmentDTO));
+            return  equipmentService.update(id,equipmentDTO);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
+
+    @RequestMapping(method = RequestMethod.DELETE,value = "/equipments/{id}")
+    public Object delete(@PathVariable int id, @RequestBody EquipmentDTO equipmentDTO){
+
+        try {
+            logger.info("start to delete equipment:"+objectMapper.writeValueAsString(equipmentDTO));
+            return  equipmentService.deleteById(id);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
+    @RequestMapping(method = RequestMethod.GET,value = "/equipments")
+    public Object getAll(){
+
+        try {
+
+            logger.info("start to get all equipment:");
+
+            return equipmentService.getAll();
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
+    @RequestMapping(method = RequestMethod.GET,value = "/cranes/{id}/equipments")
+    public Object getAllEquipmentsForCrane(@PathVariable int id){
+
+        try {
+
+            logger.info("start to get all equipment for crane:"+id);
+
+            return equipmentService.getAllEquipmentsForCrane(id);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
+
+    /**
+     * 文件上传
+     * @param img
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/equipments/{uuid}/img",method = RequestMethod.POST)
+    public Object upload(@RequestParam(value = "img") MultipartFile img,  @PathVariable String uuid, HttpServletRequest request) {
+
+       try {
+           return imageService.uploadImage(img,uuid);
+       }catch (Exception ex){
+           ex.printStackTrace();
+       }
+
+       return null;
+
+    }
+
+    /***
+     * 获取指定uuid的照片
+     * @param uuid
+     * @return
+
+     */
+    @RequestMapping(value = "/equipments/{uuid}/img",method = RequestMethod.GET)
+    public Object getImg(@PathVariable String uuid)  {
+
+        try {
+            logger.info("start to get image by uuid:"+uuid);
+            return imageService.getImageByUuid(uuid);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+}

+ 16 - 0
src/main/java/com/lstznkj/groundstation/controller/MainController.java

@@ -0,0 +1,16 @@
+package com.lstznkj.groundstation.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+@Controller
+public class MainController {
+
+    @GetMapping("/test")
+    @ResponseBody
+    public String test()
+    {
+        return "test";
+    }
+
+}

+ 23 - 0
src/main/java/com/lstznkj/groundstation/controller/RoleController.java

@@ -0,0 +1,23 @@
+package com.lstznkj.groundstation.controller;
+
+
+import com.lstznkj.groundstation.service.SysRoleService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api("角色")
+@RequestMapping(value = "roles")
+@RestController
+public class RoleController {
+
+    @Autowired
+    private SysRoleService sysRoleService;
+    @RequestMapping(method = RequestMethod.GET)
+    public Object list()
+    {
+        return sysRoleService.findAll();
+    }
+}

+ 92 - 0
src/main/java/com/lstznkj/groundstation/controller/TestController.java

@@ -0,0 +1,92 @@
+package com.lstznkj.groundstation.controller;
+
+import com.lstznkj.groundstation.DTO.ui.CraneDTO;
+import com.lstznkj.groundstation.DTO.ui.CraneSummaryDTO;
+import com.lstznkj.groundstation.DTO.ui.TechParamsDTO;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class TestController {
+
+    @RequestMapping(value = "/test/cranes",method = RequestMethod.GET)
+    public Object getCranes(){
+
+        return "getCranes";
+    }
+    @RequestMapping(value = "/test/cranes/{id}",method = RequestMethod.GET)
+    public Object getCraneById(@PathVariable int id){
+        CraneDTO craneDTO=new CraneDTO();
+        craneDTO.setName("15#天车");
+        CraneSummaryDTO craneSummaryDTO=new CraneSummaryDTO();
+        craneSummaryDTO.setName("15#天车");
+        craneSummaryDTO.setSpecification("QD20/5t-28m");
+        craneSummaryDTO.setProduceCompany("河南东升起重机械有限公司");
+        craneSummaryDTO.setProduceNumber("7030004");
+        craneSummaryDTO.setProduceTime("2007-11-01");
+        craneSummaryDTO.setInstallTime("2008-05-05");
+        craneSummaryDTO.setStartTime("2008-12-05");
+        craneSummaryDTO.setAgeLimit(20);
+        craneSummaryDTO.setOriginPrice(71.709);
+        craneSummaryDTO.setOriginPriceUnit("万元");
+        craneSummaryDTO.setProfile("跨度28米/3米");
+        craneSummaryDTO.setUsedUnit("碳钢薄板厂冷轧工序");
+        craneSummaryDTO.setIntroduction("酸轧跨1B-1C区101-105线,设计为遥控天车主要用于生产废料倒运,检修。");
+
+        TechParamsDTO techParamsDTO=new TechParamsDTO();
+
+        techParamsDTO.setLength(29000);
+        techParamsDTO.setLengthUnit("mm");
+        techParamsDTO.setWidth(7934);
+        techParamsDTO.setWidthUnit("mm");
+        techParamsDTO.setHighestValueToRail(2187);
+        techParamsDTO.setHighestValueToRailUnit("mm");
+        techParamsDTO.setBigCarBufferDistance(150);
+        techParamsDTO.setBigCarBufferDistanceUnit("mm");
+        techParamsDTO.setSmallCarBufferDistance(75);
+        techParamsDTO.setSmallCarBufferDistanceUnit("mm");
+
+        techParamsDTO.setMainHoistWeight(20);
+        techParamsDTO.setMainHoistWeightUnit("T");
+        techParamsDTO.setDeputyHoistWeight(5);
+        techParamsDTO.setDeputyHoistWeightUnit("T");
+        techParamsDTO.setBigCarLength(28);
+        techParamsDTO.setBigCarLengthUnit("米");
+        techParamsDTO.setSmallCarLength(3);
+        techParamsDTO.setSmallCarLengthUnit("米");
+        techParamsDTO.setWorkLevel("M5");
+
+
+        techParamsDTO.setMainHoistMaxSpeed(12);
+        techParamsDTO.setMainHoistMaxSpeedUnit("m/min");
+        techParamsDTO.setMainHoistMinSpeed(2);
+        techParamsDTO.setMainHoistMinSpeedUnit("m/min");
+        techParamsDTO.setDeputyHoistMinSpeed(1.95);
+        techParamsDTO.setDeputyHoistMinSpeedUnit("m/min");
+        techParamsDTO.setDeputyHoistMaxSpeed(19.5);
+        techParamsDTO.setDeputyHoistMaxSpeedUnit("m/min");
+
+        techParamsDTO.setBigCarMinSpeed(12);
+        techParamsDTO.setBigCarminSpeedUnit("m/min");
+        techParamsDTO.setBigCarMaxSpeed(120);
+        techParamsDTO.setBigCarMaxSpeedUnit("m/min");
+        techParamsDTO.setSmallCarMinSpeed(4.5);
+        techParamsDTO.setSmallCarminSpeedUnit("m/min");
+        techParamsDTO.setSmallCarMaxSpeed(45);
+        techParamsDTO.setSmallCarMaxSpeedUnit("m/min");
+
+        techParamsDTO.setMainHoistHeight(21);
+        techParamsDTO.setMainHoistHeightUnit("米");
+        techParamsDTO.setDeputyHoistHeight(23);
+        techParamsDTO.setDeputyHoistHeightUnit("米");
+
+        craneDTO.setCraneSummaryDTO(craneSummaryDTO);
+        craneDTO.setTechParamsDTO(techParamsDTO);
+
+        return craneDTO;
+    }
+
+}

+ 155 - 0
src/main/java/com/lstznkj/groundstation/controller/UltimateController.java

@@ -0,0 +1,155 @@
+package com.lstznkj.groundstation.controller;
+
+import com.lstznkj.groundstation.model.Authority;
+import com.lstznkj.groundstation.model.SysRole;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.lstznkj.groundstation.service.AuthorityService;
+import com.lstznkj.groundstation.service.SysRoleService;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.Api;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Api("超级管理员")
+@RestController
+@RequestMapping(value = "/ultimate")
+public class UltimateController {
+
+    private Logger logger= LoggerFactory.getLogger(UltimateController.class);
+    @Autowired
+    private JWTUtils jwtUtils;
+    @Autowired
+    private ObjectMapper objectMapper;
+  
+    @Autowired
+    private AuthorityService authorityService;
+    @Autowired
+    private SysRoleService sysRoleService;
+
+    @RequestMapping(value = "/roles",method = RequestMethod.GET)
+    public Object getAllRoles(HttpServletRequest request)
+    {
+        String token = request.getHeader("Authorization");
+        logger.info(jwtUtils.getUsername(token)+" start to get roles");
+
+        return  sysRoleService.findAll();
+
+    }
+    @RequestMapping(value = "/roles/{id}",method = RequestMethod.PUT)
+    public Object updateRole(HttpServletRequest request, @RequestBody SysRole role,@PathVariable int id)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to update role"+objectMapper.writeValueAsString(role));
+        }
+        catch (Exception ex)
+        {
+            logger.error(jwtUtils.getUsername(token)+" start to update role failed!");
+
+        }
+
+        return sysRoleService.update(role);
+
+    }
+    @RequestMapping(value = "/roles/{id}",method = RequestMethod.DELETE)
+    public Object deleteRole(HttpServletRequest request, @PathVariable int id)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to delete role"+id);
+        }
+        catch (Exception ex)
+        {
+            logger.error(jwtUtils.getUsername(token)+" deleted role failed!");
+
+        }
+
+        return sysRoleService.deleteById(id);
+
+    }
+
+    @RequestMapping(value = "/roles",method = RequestMethod.POST)
+    public Object addRole(HttpServletRequest request, @RequestBody SysRole role)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to add a  role:"+objectMapper.writeValueAsString(role));
+        }
+        catch (Exception ex)
+        {
+            logger.error(jwtUtils.getUsername(token)+" added role failed!");
+
+        }
+
+        return sysRoleService.save(role);
+
+    }
+
+
+    @RequestMapping(value = "/routers",method = RequestMethod.GET)
+    public  Object getAllRouters(HttpServletRequest request)
+    {
+        String token = request.getHeader("Authorization");
+
+        logger.info(jwtUtils.getUsername(token)+" start to get router");
+
+        return "routers";
+    }
+
+   @RequestMapping(value = "/authorities",method = RequestMethod.GET)
+    public  Object getAllAuthorities(HttpServletRequest request)
+    {
+        String token = request.getHeader("Authorization");
+
+        logger.info(jwtUtils.getUsername(token)+" start to get authorities");
+
+        return authorityService.findAll(token);
+    }
+    @RequestMapping(value = "/authorities",method = RequestMethod.POST)
+    public Object addAuthority(HttpServletRequest request, @RequestBody Authority authority)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to add an authority:"+objectMapper.writeValueAsString(authority));
+            return authorityService.add(authority);
+        }
+        catch (Exception ex)
+        {
+            logger.info(jwtUtils.getUsername(token)+" start to add an authority!!!");
+
+        }
+        return null;
+    }
+    @RequestMapping(value = "/authorities/{id}",method = RequestMethod.DELETE)
+    public Object deleteAuthority(HttpServletRequest request, @PathVariable int id)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to delete an authority:"+id);
+            return authorityService.deleteById(id);
+        }
+        catch (Exception ex)
+        {
+            logger.info(jwtUtils.getUsername(token)+" start to delete an authority!!!");
+
+        }
+        return null;
+    }
+    @RequestMapping(value =  "/authorities/{id}",method = RequestMethod.PUT)
+    public Object updateAuthority(HttpServletRequest request,@PathVariable int id,@RequestBody Authority authority){
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" start to update auth:"+id+": "+objectMapper.writeValueAsString(authority));
+            return authorityService.update(authority);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+}

+ 150 - 0
src/main/java/com/lstznkj/groundstation/controller/UserController.java

@@ -0,0 +1,150 @@
+package com.lstznkj.groundstation.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.lstznkj.groundstation.service.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Api("用户")
+
+@RestController
+public class UserController {
+    @Autowired
+    private JWTUtils jwtUtils;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private BCryptPasswordEncoder passwordEncoder;
+    private Logger logger= LoggerFactory.getLogger(getClass());
+
+    @ApiOperation("获取用户信息")
+    @GetMapping("/users/{username}")
+    public Object getUser(HttpServletRequest request, @PathVariable String username)
+    {
+        Result<User> result=new Result<>();
+
+
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+        if(realUsername!= username)
+        {
+            result.setSuccess(false);
+            result.setInfo("非法请求!");
+        }
+
+        return  userService.findUserByAccount(realUsername);
+
+    }
+
+    @DeleteMapping("/users/{username}")
+    public Object deleteUser(HttpServletRequest request,@PathVariable String username)
+    {
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+        Result<User> result=new Result<>();
+        logger.info(realUsername+" start to delete user:"+username);
+        result=userService.deleteUser(username);
+        return result;
+
+    }
+    @PutMapping("/users/{username}")
+    public Object updateUser(HttpServletRequest request,@PathVariable String username,@RequestBody User user){
+        String token = request.getHeader("Authorization");
+        String realUsername=jwtUtils.getUsername(token);
+        Result<User> result=new Result<>();
+
+        try {
+            logger.info(jwtUtils.getUsername(token)+" update user:"+objectMapper.writeValueAsString(user));
+            result=userService.updateUser(user);
+
+        }catch (Exception ex){
+            ex.printStackTrace();
+            result.setSuccess(false);
+            result.setInfo("修改用户信息失败!!!");
+        }
+
+        return result;
+
+    }
+    @PutMapping("/users/{username}/password")
+    public Object updateUserPassword(HttpServletRequest request,@PathVariable String username,@RequestBody User user)
+    {
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" change user:"+user.getUsername()+"'s password"+objectMapper.writeValueAsString(user));
+            return userService.adminUpdateUserPassword(user);
+
+
+        }catch (Exception ex){
+            ex.printStackTrace();
+
+        }
+        return null;
+    }
+
+    @ApiOperation("获取所有用户信息")
+    @GetMapping("/users")
+//    @PreAuthorize("hasRole('ROLE_ADMIN')")
+    public Object getAllUser(HttpServletRequest request)
+    {
+
+        return  userService.findAllUsers();
+
+    }
+
+
+
+
+    @RequestMapping(value = "/users",method = RequestMethod.POST)
+    public Object createUser(HttpServletRequest request, @RequestBody User user)
+    {
+        Result<User> result=new Result<>();
+        String token = request.getHeader("Authorization");
+        try {
+            logger.info(jwtUtils.getUsername(token)+" create user:"+objectMapper.writeValueAsString(user));
+            user.setPassword(passwordEncoder.encode(user.getPassword()));
+            result=userService.createUser(user,user.getSysRoles());
+
+        }catch (Exception ex){
+            ex.printStackTrace();
+            result.setSuccess(false);
+            result.setInfo("创建用户失败!!!");
+        }
+
+        return result;
+
+    }
+
+
+    /***
+     * 退出业务逻辑未完成
+     * @param request
+     * @return
+     */
+    @ApiOperation("用户退出登录")
+    @PostMapping("/user/logout")
+    public Object logout(HttpServletRequest request)
+    {
+        String token = request.getHeader("Authorization");
+        if(token!=null)
+        {
+            String realUsername=jwtUtils.getUsername(token);
+            logger.info(realUsername+" logout!");
+        }
+
+        return null;
+    }
+
+}

+ 190 - 0
src/main/java/com/lstznkj/groundstation/model/Authority.java

@@ -0,0 +1,190 @@
+package com.lstznkj.groundstation.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.utils.DateUtil;
+import io.swagger.annotations.ApiModel;
+import org.hibernate.annotations.CreationTimestamp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.core.GrantedAuthority;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel("后端接口权限")
+@Entity
+public class Authority  implements GrantedAuthority {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "auth_id")
+    private Integer id;
+
+
+    @Column(unique = true,length = 15,nullable = false)
+    private String name;
+
+
+    //后端接口url
+    private String apiUrl;
+    //接口方法 post get 等等
+    private String method;
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+
+    @CreationTimestamp
+    private Timestamp updateTimestamp;
+    @JsonIgnore
+    @ManyToMany(  fetch = FetchType.EAGER,cascade = CascadeType.ALL,mappedBy = "authorities")
+    private List<SysRole> sysRoles =new ArrayList<>();
+
+    //权限描述
+    private String description;
+
+    //供前端使用
+    @Transient
+    private boolean editable;
+
+
+
+
+    public Authority(){}
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public Authority(String authorityStr)
+    {
+        //需加入authorityStr 检查功能
+
+        Logger logger= LoggerFactory.getLogger( Authority.class);
+        String[] strs=authorityStr.split(";");
+        for (String s:strs)
+        {
+            logger.info("s :"+s);
+        }
+        if(strs.length>=2)
+        {
+            this.apiUrl=strs[0];
+            this.method=strs[1];
+        }
+
+
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+
+    public void setEditable(boolean editable) {
+        this.editable = editable;
+    }
+
+    public boolean isEditable() {
+        //默认不可编辑
+        return false;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    public void setSysRoles(List<SysRole> sysRoles) {
+        this.sysRoles = sysRoles;
+    }
+
+    public List<SysRole> getSysRoles() {
+        return sysRoles;
+    }
+
+
+    public void setApiUrl(String apiUrl) {
+        this.apiUrl =  apiUrl;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public void setDescription(String desc) {
+        this.description = desc;
+    }
+
+    public String getApiUrl() {
+        return apiUrl;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
+    @JsonIgnore
+    @Override
+    public String getAuthority() {
+        return this.apiUrl+";"+this.method;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+}

+ 34 - 0
src/main/java/com/lstznkj/groundstation/model/Result.java

@@ -0,0 +1,34 @@
+package com.lstznkj.groundstation.model;
+
+public class Result<T> {
+    //返回结果信息中的数据载体
+    private T data;
+    //结果具体信息,一般失败时写明失败信息
+    private String info;
+
+    private boolean success;
+
+    public T getData() {
+        return data;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+}

+ 141 - 0
src/main/java/com/lstznkj/groundstation/model/SysRole.java

@@ -0,0 +1,141 @@
+package com.lstznkj.groundstation.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.LazyCollection;
+import org.hibernate.annotations.LazyCollectionOption;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+public class SysRole {
+    @Id
+    @GeneratedValue
+    @Column(name = "role_id")
+    private Integer id;
+    @Column(unique = true)
+    private String name;
+
+    private String description;
+
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+
+    @CreationTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+
+
+    @ManyToMany(fetch = FetchType.EAGER,mappedBy = "sysRoles")
+    private List<User> users=new ArrayList<>();
+
+
+
+
+    //后端接口权限
+    @ManyToMany(cascade = CascadeType.ALL)
+    @LazyCollection(LazyCollectionOption.FALSE)
+    @JoinTable(name ="sys_role_authorities", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")},
+            inverseJoinColumns = {@JoinColumn(name = "auth_id",referencedColumnName = "auth_id")})
+    private List<Authority> authorities =new ArrayList<>();
+
+    //前端路由权限,一对多。
+
+
+    @JsonIgnore
+    public void setUsers(List<User> users) {
+        this.users = users;
+    }
+
+    @JsonIgnore
+    public List<User> getUsers() {
+        return users;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setAuthorities(List<Authority> authorities) {
+        this.authorities = authorities;
+    }
+
+
+
+    public List<Authority> getAuthorities() {
+        return authorities;
+    }
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 173 - 0
src/main/java/com/lstznkj/groundstation/model/User.java

@@ -0,0 +1,173 @@
+package com.lstznkj.groundstation.model;
+
+import com.lstznkj.groundstation.utils.DateUtil;
+import io.swagger.annotations.ApiModel;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+@ApiModel("用户")
+@Entity
+public class User {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "user_id")
+    private Integer id;
+    @Column(nullable = false)
+    private String name;
+    @Column(unique = true,length = 15,nullable = false)
+    private String username;
+
+
+    @Column(nullable = false)
+    private String password;
+
+    private boolean locked;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+    //备注
+    @Column(length = 255)
+    private String remark;
+
+    @ManyToMany(fetch = FetchType.EAGER)
+    @JoinTable(name ="user_sys_roles", joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
+            inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")})
+    private List<SysRole> sysRoles;
+
+
+    ///方便前端获取roles
+    @Transient
+    private List<String> roles=new ArrayList<>();
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+
+
+    public void setSysRoles(List<SysRole> sysRoles) {
+        this.sysRoles = sysRoles;
+    }
+
+//    @JsonIgnore
+    public List<SysRole> getSysRoles() {
+        return sysRoles;
+    }
+
+    public List<String> getRoles() {
+        if(this.roles.size()==0)
+        {
+            if(sysRoles!=null)
+            {
+                for(SysRole role : sysRoles)
+                {
+                    this.roles.add(role.getName());
+                }
+            }
+
+        }
+
+        return this.roles;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public boolean isLocked() {
+        return locked;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setLocked(boolean locked) {
+        this.locked = locked;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 145 - 0
src/main/java/com/lstznkj/groundstation/model/crane/BaseData.java

@@ -0,0 +1,145 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class BaseData {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long id;
+    private  double value;
+
+    private  int originValue;
+    private String name;
+
+
+    //数据块存储时间
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+    //采集时间
+    private long collectTime;
+    //格式化采集时间格式
+    private String collectTimeStr;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    @JsonIgnore
+    @ManyToOne
+    private DataSource dataSource;
+
+
+
+    public void setValue(double value) {
+        this.value = value;
+    }
+
+    public String getCollectTimeStr() {
+        this.collectTimeStr= DateUtil.getInstance().formatToMillisecond(this.collectTime);
+        return collectTimeStr;
+    }
+
+    public void setCollectTimeStr(String collectTimeStr) {
+        this.collectTimeStr = collectTimeStr;
+    }
+
+    public long getCollectTime() {
+        return collectTime;
+    }
+
+    public void setCollectTime(long collectTime) {
+        this.collectTime = collectTime;
+        this.collectTimeStr= DateUtil.getInstance().formatToMillisecond(this.collectTime);
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setDataSource(DataSource dataSource) {
+        this.dataSource = dataSource;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public DataSource getDataSource() {
+        return dataSource;
+    }
+
+    public double getValue() {
+        return value;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public int getOriginValue() {
+        return originValue;
+    }
+
+    public void setOriginValue(int originValue) {
+        this.originValue = originValue;
+    }
+}

+ 14 - 0
src/main/java/com/lstznkj/groundstation/model/crane/DataMark.java

@@ -0,0 +1,14 @@
+package com.lstznkj.groundstation.model.crane;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class DataMark {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long id;
+    
+}

+ 376 - 0
src/main/java/com/lstznkj/groundstation/model/crane/DataSource.java

@@ -0,0 +1,376 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+public class DataSource {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private int id;
+    private String name;
+
+    //是否启用
+    private Boolean isEnable;
+
+    //采集地址
+    private String address;
+
+
+
+
+    @ManyToOne
+    private DataType dataType;
+
+    //mqtt发布主题名称
+    private String publishTopic;
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+    @Transient
+    private String createTime;
+    @Transient
+    private int dataTypeId;
+    @Transient
+    private String updateTime;
+    @Transient
+    private List<String> valueList=new ArrayList<>();
+
+    @Transient
+    private List<String> dateList=new ArrayList<>();
+    //报警阈值
+    private float threshold;
+    private float maxValue;
+    private float minValue;
+
+
+    //稀疏差异值(大于等于稀疏差异值 才存储到数据库),-1时,不进行稀疏存储
+    private double differSparseValue;
+
+
+    private int sparseCount;
+
+    //累计 稀疏值,(超过累计稀疏值后 存储到数据库)
+
+    private double totalSparseValue;
+
+    @Transient
+    private int tmpSparseCount;
+
+
+    @Transient
+    private BaseData lastBaseData;
+
+    @Transient
+    private double differTotalValue;
+
+    @JsonIgnore
+    @ManyToOne
+    private Device device;
+    @Transient
+    private String deviceInfo;
+    @Transient
+    private String dataTypeInfo;
+
+    @Transient
+    private int deviceId;
+
+    @Transient
+    private String deviceName;
+
+    private String remark;
+
+    @JsonIgnore
+    @OneToMany(mappedBy = "dataSource",cascade = CascadeType.ALL)
+    private List<BaseData> baseDataList;
+
+
+
+    public int getDeviceId() {
+
+        if(this.device!=null){
+            return this.device.getId();
+        }
+        else {
+            return deviceId;
+        }
+
+    }
+
+    public String getDeviceName() {
+        if(this.device!=null){
+            this.deviceName=this.device.getName();
+        }
+        return deviceName;
+    }
+
+    public void setDeviceName(String deviceName) {
+        this.deviceName = deviceName;
+    }
+
+    public void setDeviceId(int deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public void setDeviceInfo(String deviceInfo) {
+        this.deviceInfo = deviceInfo;
+    }
+
+    public void setDataTypeInfo(String dataTypeInfo) {
+        this.dataTypeInfo = dataTypeInfo;
+    }
+
+    public List<String> getDateList() {
+        return dateList;
+    }
+
+    public void setDateList(List<String> dateList) {
+        this.dateList = dateList;
+    }
+
+    public void setValueList(List<String> valueList) {
+        this.valueList = valueList;
+    }
+
+    public List<String> getValueList() {
+        return valueList;
+    }
+
+    public void setMaxValue(float maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public void setMinValue(float minValue) {
+        this.minValue = minValue;
+    }
+
+    public BaseData getLastBaseData() {
+        return lastBaseData;
+    }
+
+    public void setLastBaseData(BaseData lastBaseData) {
+        this.lastBaseData = lastBaseData;
+    }
+
+    public String getDeviceInfo() {
+        if(device!=null){
+            deviceInfo=device.getFullName();
+        }
+        return deviceInfo;
+    }
+
+    public String getDataTypeInfo() {
+        if(dataType!=null){
+            dataTypeInfo=dataType.getName()+","+ dataType.getRemark();
+        }
+        return dataTypeInfo;
+    }
+
+
+    public float getMaxValue() {
+        return maxValue;
+    }
+
+    public float getMinValue() {
+        return minValue;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public void setPublishTopic(String publishTopic) {
+        this.publishTopic = publishTopic;
+    }
+
+    public String getPublishTopic() {
+        return publishTopic;
+    }
+
+    public Boolean getEnable() {
+        return isEnable;
+    }
+
+    public void setEnable(Boolean enable) {
+        isEnable = enable;
+    }
+
+    public int getDataTypeId() {
+        //return dataTypeId;
+        if(this.dataType!=null){
+            return this.dataType.getId();
+        }
+        else{
+            return  this.dataTypeId;
+        }
+
+    }
+
+    public void setDataTypeId(int dataTypeId) {
+        this.dataTypeId = dataTypeId;
+    }
+
+
+
+
+
+    public List<BaseData> getBaseDataList() {
+        return baseDataList;
+    }
+
+    
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+
+
+    public void setBaseDataList(List<BaseData> baseDataList) {
+        this.baseDataList = baseDataList;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    //报警阈值
+
+
+    public DataType getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+
+    public int getTmpSparseCount() {
+        return tmpSparseCount;
+    }
+
+    public void setTmpSparseCount(int tmpSparseCount) {
+        this.tmpSparseCount = tmpSparseCount;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setThreshold(float threshold) {
+        this.threshold = threshold;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public float getThreshold() {
+        return threshold;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public double getDifferSparseValue() {
+        return differSparseValue;
+    }
+
+    public void setDifferSparseValue(double differSparseValue) {
+        this.differSparseValue = differSparseValue;
+    }
+
+    public double getDifferTotalValue() {
+        return differTotalValue;
+    }
+
+    public void setDifferTotalValue(double differTotalValue) {
+        this.differTotalValue = differTotalValue;
+    }
+
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToSecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+
+    public int getSparseCount() {
+        return sparseCount;
+    }
+
+    public void setSparseCount(int sparseCount) {
+        this.sparseCount = sparseCount;
+    }
+
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToSecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public double getTotalSparseValue() {
+        return totalSparseValue;
+    }
+
+    public void setTotalSparseValue(double totalSparseValue) {
+        this.totalSparseValue = totalSparseValue;
+    }
+}

+ 159 - 0
src/main/java/com/lstznkj/groundstation/model/crane/DataType.java

@@ -0,0 +1,159 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+@Entity
+public class DataType {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @Column(unique = true,length = 15,nullable = false)
+    private String name;
+
+    //0 模拟量(4-20mA),1开关量
+    private int valueType;
+
+    //采集方法
+    // 0 485 ,1 PLC
+    private int method;
+    private String expression;
+
+    //单位
+    private String unit;
+
+
+    @JsonIgnore
+    @OneToMany(mappedBy = "dataType",cascade = CascadeType.ALL)
+    private List<DataSource> dataSources;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    private String remark;
+
+  
+
+    public void setDataSources(List<DataSource> dataSources) {
+        this.dataSources = dataSources;
+    }
+
+
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public List<DataSource> getDataSources() {
+        return dataSources;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setValueType(int valueType) {
+        this.valueType = valueType;
+    }
+
+    public void setMethod(int method) {
+        this.method = method;
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getValueType() {
+        return valueType;
+    }
+
+    public int getMethod() {
+        return method;
+    }
+
+    public String getExpression() {
+        return expression;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+}

+ 530 - 0
src/main/java/com/lstznkj/groundstation/model/crane/Device.java

@@ -0,0 +1,530 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.lstznkj.groundstation.model.crane.extra.*;
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+
+//机构部位
+@Entity
+public class Device {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    private String name;
+    private String remark;
+
+    @Transient
+    private String fullName;
+
+
+    //设备现有状态: 正常、报警、预警、故障……
+    @ManyToOne
+    private State state;
+
+
+    /****
+     * 工作和寿命 统计分析这块后期应单独分离
+     */
+
+    //工作运行时间
+    private long workTime;
+    //工作次数
+    private long workCount;
+    //预设寿命时长
+    private long lifeTime;
+    //寿命次数
+    private long lifeCount;
+
+    @Transient
+    private String label;
+    @Transient
+    private int value;
+
+    //额外信息,1级设备-天车存储 mqtt 服务器地址
+    private String extra;
+
+    //规格
+    private String specification;
+
+
+    //设备级别,1级设备、二级设备........
+    private int level;
+
+
+    @OneToMany(mappedBy = "father", fetch = FetchType.EAGER)
+    private List<Device> children;
+
+    @JsonIgnore
+    @OneToMany(mappedBy = "device")
+    private List<WorkLog> workLogList;
+
+    @JsonIgnore
+    @ManyToOne(cascade = CascadeType.DETACH)
+    private Device father;
+
+    @Transient
+    private int fatherId;
+
+
+    @Transient
+    private int childrenCount;
+
+
+
+
+    //设备改造记录
+    @OneToMany(mappedBy = "device",fetch = FetchType.LAZY)
+    private List<ReformLog> reformLogList;
+
+
+    //设备更换记录
+    @OneToMany(mappedBy = "device",fetch = FetchType.LAZY)
+    private List<ExchangeLog> exchangeLogList;
+
+    //事故 隐患
+    @OneToMany(mappedBy = "device",fetch = FetchType.LAZY)
+    private List<AccidentLog> accidentLogList;
+
+
+    //点检标准
+    @OneToOne(mappedBy = "device",fetch = FetchType.LAZY)
+    @JoinColumn(name = "point_check_standard_id")
+    private PointCheckStandard pointCheckStandard;
+
+
+
+
+    /**
+     * 一个设备有多种数据采集,比如振动、温度、
+     * 每个数据类型下面有单独的数据历史记录
+     */
+
+    @OneToMany(mappedBy = "device", cascade = CascadeType.ALL)
+    private List<DataSource> dataSources;
+
+//    @OneToOne
+//    private LifeModel lifeModel;
+
+
+
+
+
+
+    public long getLifeTime() {
+        return lifeTime;
+    }
+
+
+    public void setFullName(String fullName) {
+        this.fullName = fullName;
+    }
+
+    private String getFullName(Device device) {
+        StringBuffer nameBuffer = new StringBuffer();
+        nameBuffer.append(device.getName());
+        if (device.getFather() != null) {
+            nameBuffer.append("/" + getFullName(device.getFather()));
+
+            //System.out.println(device.getName()+" father is "+device.getFather().getName());
+            return nameBuffer.toString();
+
+        } else {
+            //nameBuffer.append(device.getName());
+
+            return nameBuffer.toString();
+        }
+
+
+    }
+
+    public String getFullName() {
+
+        //System.out.println("fullname : "+this.fullName);
+        String[] tmp = getFullName(this).split("/");
+        StringBuffer tmpBuffer = new StringBuffer();
+        for (int i = tmp.length - 1; i >= 0; --i) {
+            tmpBuffer.append(tmp[i] + "/");
+        }
+        this.fullName = tmpBuffer.toString();
+        return fullName;
+    }
+
+    public void setLifeTime(long lifeTime) {
+        this.lifeTime = lifeTime;
+    }
+
+    //存储所有子设备的数据源
+    @Transient
+    private List<DataSource> childrenDataSources = new ArrayList<>();
+
+    public void setWorkCount(long workCount) {
+        this.workCount = workCount;
+    }
+
+    public void setLifeCount(long lifeCount) {
+        this.lifeCount = lifeCount;
+    }
+
+    public long getWorkCount() {
+        return workCount;
+    }
+
+    public long getLifeCount() {
+        return lifeCount;
+    }
+
+    public void setExtra(String extra) {
+        this.extra = extra;
+    }
+
+    public String getExtra() {
+        return extra;
+    }
+
+
+    //所有子设备
+    @Transient
+    private List<Device> allChildren = new ArrayList<>();
+
+    public PointCheckStandard getPointCheckStandard() {
+        return pointCheckStandard;
+    }
+
+    public void setPointCheckStandard(PointCheckStandard pointCheckStandard) {
+        this.pointCheckStandard = pointCheckStandard;
+    }
+
+    private List<Device> getChildren(Device device) {
+        List<Device> deviceList = new ArrayList<>();
+        if (device.children != null) {
+            deviceList.addAll(device.children);
+            for (Device child : device.children) {
+                deviceList.addAll(getChildren(child));
+            }
+        }
+        return deviceList;
+    }
+
+    public List<Device> getAllChildren() {
+
+        allChildren = getChildren(this);
+        return allChildren;
+    }
+
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    public void setAllChildren(List<Device> allChildren) {
+        this.allChildren = allChildren;
+    }
+
+    public void setDataSources(List<DataSource> dataSources) {
+        this.dataSources = dataSources;
+    }
+
+    public void setChildrenDataSources(List<DataSource> childrenDataSources) {
+        this.childrenDataSources = childrenDataSources;
+    }
+
+
+    public void setWorkTime(long workTime) {
+        this.workTime = workTime;
+    }
+
+    public List<DataSource> getDataSources() {
+        return dataSources;
+    }
+
+
+    private List<DataSource> getChildrenDataSources(Device device) throws JsonProcessingException {
+        List<DataSource> dataSourceList = new ArrayList<>();
+        if (device.children != null) {
+            for (Device child : device.children) {
+                if (child.dataSources != null) {
+//                    System.out.println(child.getName()+" dataSources:"+new ObjectMapper().writeValueAsString(child.dataSources));
+                    dataSourceList.addAll(child.getDataSources());
+                }
+                dataSourceList.addAll(getChildrenDataSources(child));
+            }
+        }
+//        if(device.dataSources!=null){
+//            dataSourceList.addAll(device.getDataSources());
+//        }
+
+        return dataSourceList;
+    }
+    public List<DataSource> getModbusDataSources(){
+        List<DataSource> dataSourceList = new ArrayList<>();
+        if(this.getDataSources()==null){
+            return null;
+        }
+        for(DataSource dataSource:this.getDataSources()){
+            if(dataSource.getAddress().split("/")[0].equals("485")){
+                dataSourceList.add(dataSource);
+            }
+        }
+
+        return dataSourceList;
+    }
+
+    /***
+     * 获取所有子设备的485数据源
+     * @return
+     * @throws JsonProcessingException
+     */
+    public List<DataSource> getChildrenDataSources() throws JsonProcessingException {
+        if(this.childrenDataSources!=null){
+            this.childrenDataSources.clear();
+        }
+//        System.out.println(getName()+ ":children length "+ children.size());
+        List<DataSource> dataSourceList = new ArrayList<>();
+        dataSourceList.addAll(getChildrenDataSources(this));
+
+//        if(children!=null){
+//            for(Device child : children){
+//                if(child.dataSources!=null){
+//                    childrenDataSources.addAll(child.getDataSources());
+//                }
+//            }
+//        }
+        childrenDataSources.addAll(dataSourceList);
+        return childrenDataSources;
+    }
+    public List<DataSource> getChildrenModbusDataSources() throws JsonProcessingException {
+        List<DataSource> dataSourceList = new ArrayList<>();
+        List<DataSource> tmpList=this.getChildrenDataSources();
+        for(DataSource dataSource:tmpList){
+            if(dataSource.getAddress().split("/")[0].equals("485")){
+                dataSourceList.add(dataSource);
+            }
+        }
+        return dataSourceList;
+    }
+
+    public long getWorkTime() {
+        return workTime;
+    }
+
+    public List<WorkLog> getWorkLogList() {
+        return workLogList;
+    }
+
+    public void setWorkLogList(List<WorkLog> workLogList) {
+        this.workLogList = workLogList;
+    }
+
+    public int getFatherId() {
+        if (father != null) {
+            fatherId = father.getId();
+        }
+
+
+        return fatherId;
+    }
+
+    public void setFatherId(int fatherId) {
+        this.fatherId = fatherId;
+    }
+
+    public int getChildrenCount() {
+        if (this.children == null) {
+            this.childrenCount = 0;
+        } else {
+            this.childrenCount = this.children.size();
+        }
+
+        return this.childrenCount;
+    }
+
+    public int getValue() {
+        if (id != null) {
+            this.value = id;
+        } else {
+            this.value = 0;
+        }
+
+        return value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public void setChildrenCount(int childrenCount) {
+        this.childrenCount = childrenCount;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+
+    public void setChildren(List<Device> children) {
+        this.children = children;
+    }
+
+    public void setFather(Device father) {
+        this.father = father;
+    }
+
+    public List<Device> getChildren() {
+        return children;
+    }
+
+    public Device getFather() {
+        return father;
+    }
+
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getLevel() {
+//        if(this.father!=null){
+//            this.level=father.getLevel()+1;
+//        }
+        return level;
+    }
+
+
+    public String getCreateTime() {
+        if (this.createTimestamp == null) {
+            this.createTime = "";
+        } else {
+            this.createTime = DateUtil.getSingleInstance().formatToSecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+
+    public String getUpdateTime() {
+        if (this.updateTimestamp == null) {
+            this.updateTime = "";
+        } else {
+            this.updateTime = DateUtil.getSingleInstance().formatToSecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    /**
+     * 供前端树形控件使用
+     *
+     * @return
+     */
+    public String getLabel() {
+        this.label = this.name;
+        return label;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+
+
+    public List<ReformLog> getReformLogList() {
+        return reformLogList;
+    }
+
+    public void setReformLogList(List<ReformLog> reformLogList) {
+        this.reformLogList = reformLogList;
+    }
+
+    public List<ExchangeLog> getExchangeLogList() {
+        return exchangeLogList;
+    }
+
+    public void setExchangeLogList(List<ExchangeLog> exchangeLogList) {
+        this.exchangeLogList = exchangeLogList;
+    }
+
+    public List<AccidentLog> getAccidentLogList() {
+        return accidentLogList;
+    }
+
+    public void setAccidentLogList(List<AccidentLog> accidentLogList) {
+        this.accidentLogList = accidentLogList;
+    }
+}

+ 289 - 0
src/main/java/com/lstznkj/groundstation/model/crane/LifeModel.java

@@ -0,0 +1,289 @@
+package com.lstznkj.groundstation.model.crane;
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class LifeModel {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+
+    //工作运行时间
+    private long runTime;
+
+
+    private long overloadTime;
+
+    private String overloadTimeUnit;
+
+    private int startsCount; // 启动次数
+    private int actionCount; // 动作次数
+    private int brakingCount;  // 制动次数
+    private long runMaxTime;    //运行时间(寿命)
+    private int startsMaxCount; // 启动次数(寿命)
+    private int actionMaxCount; // 动作次数(寿命)
+    private int brakingMAxCount;  // 制动次数(寿命)
+
+    //寿命值
+    private long lifeValue;
+    private String lifeValueUnit;
+
+
+    //保养值
+    private long maintainValue;
+    private String maintainValueUnit;
+
+    //保养周期
+    private long maintainCycle;
+    private String maintainCycleUnit;
+
+    //更换
+    private int updateCycle;
+    private String updateCycleUnit;
+
+    private int equipmentId;
+
+    private int oldDeviceId;
+
+    private int dataSourceId;
+
+
+
+
+    @OneToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+
+    public int getDataSourceId() {
+        return dataSourceId;
+    }
+
+    public void setDataSourceId(int dataSourceId) {
+        this.dataSourceId = dataSourceId;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public long getRunTime() {
+        return runTime;
+    }
+
+    public void setRunTime(long runTime) {
+        this.runTime = runTime;
+    }
+
+    public int getStartsCount() {
+        return startsCount;
+    }
+
+    public void setStartsCount(int startsCount) {
+        this.startsCount = startsCount;
+    }
+
+    public int getActionCount() {
+        return actionCount;
+    }
+
+    public void setActionCount(int actionCount) {
+        this.actionCount = actionCount;
+    }
+
+    public int getBrakingCount() {
+        return brakingCount;
+    }
+
+    public void setBrakingCount(int brakingCount) {
+        this.brakingCount = brakingCount;
+    }
+
+    public long getRunMaxTime() {
+        return runMaxTime;
+    }
+
+    public void setRunMaxTime(long runMaxTime) {
+        this.runMaxTime = runMaxTime;
+    }
+
+    public int getStartsMaxCount() {
+        return startsMaxCount;
+    }
+
+    public void setStartsMaxCount(int startsMaxCount) {
+        this.startsMaxCount = startsMaxCount;
+    }
+
+    public int getActionMaxCount() {
+        return actionMaxCount;
+    }
+
+    public void setActionMaxCount(int actionMaxCount) {
+        this.actionMaxCount = actionMaxCount;
+    }
+
+    public int getBrakingMAxCount() {
+        return brakingMAxCount;
+    }
+
+    public void setBrakingMAxCount(int brakingMAxCount) {
+        this.brakingMAxCount = brakingMAxCount;
+    }
+
+    public long getLifeValue() {
+        return lifeValue;
+    }
+
+    public void setLifeValue(long lifeValue) {
+        this.lifeValue = lifeValue;
+    }
+
+    public String getLifeValueUnit() {
+        return lifeValueUnit;
+    }
+
+    public void setLifeValueUnit(String lifeValueUnit) {
+        this.lifeValueUnit = lifeValueUnit;
+    }
+
+    public long getMaintainValue() {
+        return maintainValue;
+    }
+
+    public void setMaintainValue(long maintainValue) {
+        this.maintainValue = maintainValue;
+    }
+
+    public String getMaintainValueUnit() {
+        return maintainValueUnit;
+    }
+
+    public void setMaintainValueUnit(String maintainValueUnit) {
+        this.maintainValueUnit = maintainValueUnit;
+    }
+
+    public long getMaintainCycle() {
+        return maintainCycle;
+    }
+
+    public void setMaintainCycle(long maintainCycle) {
+        this.maintainCycle = maintainCycle;
+    }
+
+    public String getMaintainCycleUnit() {
+        return maintainCycleUnit;
+    }
+
+    public void setMaintainCycleUnit(String maintainCycleUnit) {
+        this.maintainCycleUnit = maintainCycleUnit;
+    }
+
+    public int getUpdateCycle() {
+        return updateCycle;
+    }
+
+    public void setUpdateCycle(int updateCycle) {
+        this.updateCycle = updateCycle;
+    }
+
+    public String getUpdateCycleUnit() {
+        return updateCycleUnit;
+    }
+
+    public void setUpdateCycleUnit(String updateCycleUnit) {
+        this.updateCycleUnit = updateCycleUnit;
+    }
+
+    public int getEquipmentId() {
+        return equipmentId;
+    }
+
+    public void setEquipmentId(int equipmentId) {
+        this.equipmentId = equipmentId;
+    }
+
+    public int getOldDeviceId() {
+        return oldDeviceId;
+    }
+
+    public void setOldDeviceId(int oldDeviceId) {
+        this.oldDeviceId = oldDeviceId;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public long getOverloadTime() {
+        return overloadTime;
+    }
+
+    public void setOverloadTime(long overloadTime) {
+        this.overloadTime = overloadTime;
+    }
+
+    public String getOverloadTimeUnit() {
+        return overloadTimeUnit;
+    }
+
+    public void setOverloadTimeUnit(String overloadTimeUnit) {
+        this.overloadTimeUnit = overloadTimeUnit;
+    }
+}

+ 78 - 0
src/main/java/com/lstznkj/groundstation/model/crane/State.java

@@ -0,0 +1,78 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+@Entity
+public class State {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @Column(unique = true,length = 15,nullable = false)
+    private String name;
+    private String remark;
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @JsonIgnore
+    @OneToMany(mappedBy = "state")
+    private List<Device> deviceList;
+
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public void setDeviceList(List<Device> deviceList) {
+        this.deviceList = deviceList;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public List<Device> getDeviceList() {
+        return deviceList;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+}

+ 27 - 0
src/main/java/com/lstznkj/groundstation/model/crane/StateLog.java

@@ -0,0 +1,27 @@
+package com.lstznkj.groundstation.model.crane;
+
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 状态记录
+ */
+@Entity
+public class StateLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @Column(unique = true,length = 15,nullable = false)
+    private String name;
+    private String remark;
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+}

+ 45 - 0
src/main/java/com/lstznkj/groundstation/model/crane/ThreadMonitorInfo.java

@@ -0,0 +1,45 @@
+package com.lstznkj.groundstation.model.crane;
+
+public class ThreadMonitorInfo {
+    private String threadId;
+    private long runTime;
+    private String extra;
+
+    private boolean isRunable;
+
+
+
+
+
+    public String getThreadId() {
+        return threadId;
+    }
+
+    public void setThreadId(String threadId) {
+        this.threadId = threadId;
+    }
+
+    public long getRunTime() {
+        return runTime;
+    }
+
+    public void setRunTime(long runTime) {
+        this.runTime = runTime;
+    }
+
+    public String getExtra() {
+        return extra;
+    }
+
+    public void setExtra(String extra) {
+        this.extra = extra;
+    }
+
+    public boolean isRunable() {
+        return isRunable;
+    }
+
+    public void setRunable(boolean runable) {
+        isRunable = runable;
+    }
+}

+ 24 - 0
src/main/java/com/lstznkj/groundstation/model/crane/Trouble.java

@@ -0,0 +1,24 @@
+package com.lstznkj.groundstation.model.crane;
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+import java.sql.Timestamp;
+
+public class Trouble {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long id;
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+}

+ 193 - 0
src/main/java/com/lstznkj/groundstation/model/crane/WorkLog.java

@@ -0,0 +1,193 @@
+package com.lstznkj.groundstation.model.crane;
+
+import com.lstznkj.groundstation.utils.DateUtil;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class WorkLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Long id;
+
+    public WorkLog(){
+        this.abnormalStop=true;
+    }
+
+    //运行记录间隔
+    @Column(name = "_interva")
+    private int interval;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    //上次启动时间
+    private Timestamp startTimestamp;
+    //上次停止时间
+    private Timestamp stopTimestamp;
+    //异常停止记录标志,默认true, 设备每次正常的运行 结束 会置为false
+    private boolean abnormalStop;
+    private String startTime;
+    private String stopTime;
+
+
+    //启动时的额外信息
+    @Lob
+    private String startExtra;
+    //停止时的额外信息
+    @Lob
+    private String stopExtra;
+
+    @ManyToOne(cascade = CascadeType.ALL)
+    private Device device;
+
+
+    public String getStartTime() {
+        if(this.startTimestamp==null){
+            this.startTime="";
+        }else {
+            this.startTime= DateUtil.getSingleInstance().formatToMillisecond(this.startTimestamp.getTime());
+        }
+
+        return this.startTime;
+    }
+
+    public String getStopTime() {
+        if(this.startTimestamp==null){
+            this.stopTime="";
+        }else {
+            this.stopTime= DateUtil.getSingleInstance().formatToMillisecond(this.stopTimestamp.getTime());
+        }
+
+        return this.startTime;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public String getCreateTime(){
+        if(this.createTimestamp==null){
+            this.createTime="";
+        }else {
+            this.createTime= DateUtil.getSingleInstance().formatToMillisecond(this.createTimestamp.getTime());
+        }
+
+        return this.createTime;
+    }
+    public String getUpdateTime(){
+        if(this.updateTimestamp==null){
+            this.updateTime="";
+        }
+        else {
+            this.updateTime= DateUtil.getSingleInstance().formatToMillisecond(this.updateTimestamp.getTime());
+        }
+
+        return this.updateTime;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public void setInterval(int interval) {
+        this.interval = interval;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public void setStartTimestamp(Timestamp startTimestamp) {
+        this.startTimestamp = startTimestamp;
+    }
+
+    public void setStopTimestamp(Timestamp stopTimestamp) {
+        this.stopTimestamp = stopTimestamp;
+    }
+
+    public void setAbnormalStop(boolean abnormalStop) {
+        this.abnormalStop = abnormalStop;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public void setStopTime(String stopTime) {
+        this.stopTime = stopTime;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public int getInterval() {
+        return interval;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public Timestamp getStartTimestamp() {
+        return startTimestamp;
+    }
+
+    public Timestamp getStopTimestamp() {
+        return stopTimestamp;
+    }
+
+    public boolean isAbnormalStop() {
+        return abnormalStop;
+    }
+
+    public String getStartExtra() {
+        return startExtra;
+    }
+
+    public void setStartExtra(String startExtra) {
+        this.startExtra = startExtra;
+    }
+
+    public String getStopExtra() {
+        return stopExtra;
+    }
+
+    public void setStopExtra(String stopExtra) {
+        this.stopExtra = stopExtra;
+    }
+
+
+}

+ 275 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/AccidentLog.java

@@ -0,0 +1,275 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+/*
+设备隐患事故记录
+ */
+@Entity
+public class AccidentLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    //故障日期
+    private Timestamp date;
+
+    //事故分级
+    private int level;
+
+    //故障记录描述
+    @Lob
+    private String  remark;
+
+    //原因
+    @Lob
+    private String reason;
+
+    //实施内容
+    private String conten;
+
+    //损失
+    private double lost;
+    private String lostUnit;
+
+
+
+    //故障专业
+    private String major;
+
+    //影响生产时间
+    private int affectTime;
+    private String affectTimeUnit;
+
+
+    //考核
+    private double fine;
+    private String fineUnit;
+
+    //责任追究人,追究人可能不在系统,采用字符串存储,逗号分隔
+    @Lob
+    private String people;
+
+    //分类
+    private String type;
+
+
+
+    //改造记录,一对多
+//    @OneToMany(mappedBy = "accidentLog",fetch = FetchType.LAZY)
+//    private List<ReformLog> reformLogList;
+
+    //设备
+    @ManyToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+
+
+
+
+    //设备记录人
+//    @OneToOne
+//    User user;
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Timestamp getDate() {
+        return date;
+    }
+
+    public void setDate(Timestamp date) {
+        this.date = date;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    public String getConten() {
+        return conten;
+    }
+
+    public void setConten(String conten) {
+        this.conten = conten;
+    }
+
+    public double getLost() {
+        return lost;
+    }
+
+    public void setLost(double lost) {
+        this.lost = lost;
+    }
+
+    public String getLostUnit() {
+        return lostUnit;
+    }
+
+    public void setLostUnit(String lostUnit) {
+        this.lostUnit = lostUnit;
+    }
+
+    public String getMajor() {
+        return major;
+    }
+
+    public void setMajor(String major) {
+        this.major = major;
+    }
+
+    public double getFine() {
+        return fine;
+    }
+
+    public void setFine(double fine) {
+        this.fine = fine;
+    }
+
+    public String getFineUnit() {
+        return fineUnit;
+    }
+
+    public void setFineUnit(String fineUnit) {
+        this.fineUnit = fineUnit;
+    }
+
+    public String getPeople() {
+        return people;
+    }
+
+    public void setPeople(String people) {
+        this.people = people;
+    }
+
+    public int getAffectTime() {
+        return affectTime;
+    }
+
+    public void setAffectTime(int affectTime) {
+        this.affectTime = affectTime;
+    }
+
+    public String getAffectTimeUnit() {
+        return affectTimeUnit;
+    }
+
+    public void setAffectTimeUnit(String affectTimeUnit) {
+        this.affectTimeUnit = affectTimeUnit;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+
+    //    public User getUser() {
+//        return user;
+//    }
+//
+//    public void setUser(User user) {
+//        this.user = user;
+//    }
+
+
+}

+ 234 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/DeviceSummary.java

@@ -0,0 +1,234 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 设备概述,根设备(天车概述)
+ */
+@Entity
+public class DeviceSummary {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    private String name;
+
+    //规格
+    private String specification;
+
+    //制造厂家
+    private String produceCompany;
+
+    //制造编号
+    private String produceNumber;
+
+    //制造日期
+    private long produceTime;
+    //安装日期
+    private long installTime;
+    //开始使用日期
+    private long startTime;
+
+    //设备原值
+    private double originPrice;
+    private String originPriceUnit;
+
+
+
+    //设备使用年限
+    private long ageLimit;
+
+    //外形尺寸
+    private String profile;
+
+    //图号
+    private String imageNumber;
+
+    //使用单位
+    private String usedUnit;
+
+    //简介
+    private String introduction;
+
+
+    @OneToOne
+    @JoinColumn(name = "crane_id")
+    private Device crane;
+
+    public Device getCrane() {
+        return crane;
+    }
+
+    public void setCrane(Device crane) {
+        this.crane = crane;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+    public String getProduceCompany() {
+        return produceCompany;
+    }
+
+    public void setProduceCompany(String produceCompany) {
+        this.produceCompany = produceCompany;
+    }
+
+    public long getProduceTime() {
+        return produceTime;
+    }
+
+    public void setProduceTime(long produceTime) {
+        this.produceTime = produceTime;
+    }
+
+    public long getInstallTime() {
+        return installTime;
+    }
+
+    public void setInstallTime(long installTime) {
+        this.installTime = installTime;
+    }
+
+    public long getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(long startTime) {
+        this.startTime = startTime;
+    }
+
+    public long getAgeLimit() {
+        return ageLimit;
+    }
+
+    public void setAgeLimit(long ageLimit) {
+        this.ageLimit = ageLimit;
+    }
+
+    public String getProfile() {
+        return profile;
+    }
+
+    public void setProfile(String profile) {
+        this.profile = profile;
+    }
+
+    public String getImageNumber() {
+        return imageNumber;
+    }
+
+    public void setImageNumber(String imageNumber) {
+        this.imageNumber = imageNumber;
+    }
+
+    public String getUsedUnit() {
+        return usedUnit;
+    }
+
+    public void setUsedUnit(String usedUnit) {
+        this.usedUnit = usedUnit;
+    }
+
+    public String getIntroduction() {
+        return introduction;
+    }
+
+    public void setIntroduction(String introduction) {
+        this.introduction = introduction;
+    }
+
+    public String getProduceNumber() {
+        return produceNumber;
+    }
+
+    public void setProduceNumber(String produceNumber) {
+        this.produceNumber = produceNumber;
+    }
+
+    public double getOriginPrice() {
+        return originPrice;
+    }
+
+    public void setOriginPrice(double originPrice) {
+        this.originPrice = originPrice;
+    }
+
+    public String getOriginPriceUnit() {
+        return originPriceUnit;
+    }
+
+    public void setOriginPriceUnit(String originPriceUnit) {
+        this.originPriceUnit = originPriceUnit;
+    }
+}

+ 216 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/Equipment.java

@@ -0,0 +1,216 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+
+//零件信息
+@Entity
+public class Equipment {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+    private String name;
+    private String remark;
+
+    private String material;
+    private String produceCompany;
+
+    private String installTime;
+
+    private String partNo;
+
+    private String imageUrl;
+
+    private int type;
+    private String uuid;
+
+    /****
+     * 工作和寿命 统计分析这块后期应单独分离
+     */
+
+
+
+//
+//    //工作运行时间
+//    private long workTime;
+//    //工作次数
+//    private long workCount;
+//
+//
+//
+//    //预设寿命时长
+//    private long lifeTime;
+//    //寿命次数
+//    private long lifeCount;
+
+
+
+    //规格
+    private String specification;
+
+
+    //与Device的对应关系
+
+    @OneToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+    //记录设备更换零件的记录
+    private int oldDeviceId;
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public String getMaterial() {
+        return material;
+    }
+
+    public void setMaterial(String material) {
+        this.material = material;
+    }
+
+    public String getProduceCompany() {
+        return produceCompany;
+    }
+
+    public void setProduceCompany(String produceCompany) {
+        this.produceCompany = produceCompany;
+    }
+
+    public String getInstallTime() {
+        return installTime;
+    }
+
+    public void setInstallTime(String installTime) {
+        this.installTime = installTime;
+    }
+
+    public String getPartNo() {
+        return partNo;
+    }
+
+    public void setPartNo(String partNo) {
+        this.partNo = partNo;
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public int getOldDeviceId() {
+        return oldDeviceId;
+    }
+
+    public void setOldDeviceId(int oldDeviceId) {
+        this.oldDeviceId = oldDeviceId;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+}

+ 202 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/ExchangeLog.java

@@ -0,0 +1,202 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+
+/**
+ * 设备更换记录
+ */
+
+@Entity
+public class ExchangeLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    //与机构的对应 ,多对一
+    @ManyToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+
+    private double price;
+    private String priceUnit;
+    private int count;
+
+    //更换周期
+    private int exchangeCycle;
+    private String exchangeCycleUnit;
+
+    @OneToOne
+    private Equipment oldEquipment;
+
+    @OneToOne
+    private Equipment newEquipment;
+
+
+    //更换时间
+    private Timestamp exchangeTime;
+
+    //更换原因
+    private String exchangeReason;
+
+    //更换分析
+    private String exchangeAnalysis;
+
+    //点检人员,多对一
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public double getPrice() {
+        return price;
+    }
+
+    public void setPrice(double price) {
+        this.price = price;
+    }
+
+    public String getPriceUnit() {
+        return priceUnit;
+    }
+
+    public void setPriceUnit(String priceUnit) {
+        this.priceUnit = priceUnit;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+    public int getExchangeCycle() {
+        return exchangeCycle;
+    }
+
+    public void setExchangeCycle(int exchangeCycle) {
+        this.exchangeCycle = exchangeCycle;
+    }
+
+    public String getExchangeCycleUnit() {
+        return exchangeCycleUnit;
+    }
+
+    public void setExchangeCycleUnit(String exchangeCycleUnit) {
+        this.exchangeCycleUnit = exchangeCycleUnit;
+    }
+
+    public Equipment getOldEquipment() {
+        return oldEquipment;
+    }
+
+    public void setOldEquipment(Equipment oldEquipment) {
+        this.oldEquipment = oldEquipment;
+    }
+
+    public Equipment getNewEquipment() {
+        return newEquipment;
+    }
+
+    public void setNewEquipment(Equipment newEquipment) {
+        this.newEquipment = newEquipment;
+    }
+
+    public Timestamp getExchangeTime() {
+        return exchangeTime;
+    }
+
+    public void setExchangeTime(Timestamp exchangeTime) {
+        this.exchangeTime = exchangeTime;
+    }
+
+    public String getExchangeReason() {
+        return exchangeReason;
+    }
+
+    public void setExchangeReason(String exchangeReason) {
+        this.exchangeReason = exchangeReason;
+    }
+
+    public String getExchangeAnalysis() {
+        return exchangeAnalysis;
+    }
+
+    public void setExchangeAnalysis(String exchangeAnalysis) {
+        this.exchangeAnalysis = exchangeAnalysis;
+    }
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+}

+ 126 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckReport.java

@@ -0,0 +1,126 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.LazyCollection;
+import org.hibernate.annotations.LazyCollectionOption;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+/***
+ * 点检报告
+ */
+
+@Entity
+public class PointCheckReport {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    @ManyToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+
+     private boolean isFinished;
+
+    //后端接口权限
+    @ManyToMany(cascade = CascadeType.ALL)
+//    @JoinTable(name ="sys_role_authorities", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")},
+//            inverseJoinColumns = {@JoinColumn(name = "auth_id",referencedColumnName = "auth_id")})
+    @JoinTable(name ="point_check_report_standard", joinColumns = {@JoinColumn(name = "point_check_report_id",referencedColumnName = "id")},
+            inverseJoinColumns = {@JoinColumn(name = "point_check_stantdard_id",referencedColumnName = "id")})
+     private List<PointCheckStandard> pointCheckStandardList;
+
+
+
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isFinished() {
+        return isFinished;
+    }
+
+    public void setFinished(boolean finished) {
+        isFinished = finished;
+    }
+
+    public List<PointCheckStandard> getPointCheckStandardList() {
+        return pointCheckStandardList;
+    }
+
+    public void setPointCheckStandardList(List<PointCheckStandard> pointCheckStandardList) {
+        this.pointCheckStandardList = pointCheckStandardList;
+    }
+}

+ 117 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandard.java

@@ -0,0 +1,117 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+/**
+ * 点检标准
+ */
+@Entity
+public class PointCheckStandard {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+    @ManyToMany(  fetch = FetchType.LAZY,cascade = CascadeType.ALL,mappedBy = "pointCheckStandardList")
+    private List<PointCheckReport> pointCheckReportList;
+
+    //对应机构
+
+    @OneToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+    @OneToMany(mappedBy ="pointCheckStandard")
+    private List<PointCheckStandardItem> itemList;
+
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<PointCheckReport> getPointCheckReportList() {
+        return pointCheckReportList;
+    }
+
+    public void setPointCheckReportList(List<PointCheckReport> pointCheckReportList) {
+        this.pointCheckReportList = pointCheckReportList;
+    }
+
+    public List<PointCheckStandardItem> getItemList() {
+        return itemList;
+    }
+
+    public void setItemList(List<PointCheckStandardItem> itemList) {
+        this.itemList = itemList;
+    }
+}

+ 188 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandardItem.java

@@ -0,0 +1,188 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import com.lstznkj.groundstation.model.SysRole;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+import java.util.List;
+
+/****
+ * 点检标准的具体条目
+ */
+@Entity
+public class PointCheckStandardItem {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+
+    @ManyToOne
+    @JoinColumn(name = "point_check_standard_id")
+    private PointCheckStandard pointCheckStandard;
+
+    //点检内容,
+    //具体点检内容为多条
+    private String conten;
+
+    //点检标准
+    private String standard;
+
+    //点检方法
+    //0-----其他
+    //1-----目视
+    //2-----手摸
+    //3-----听音
+    //4-----敲打
+    //5-----嗅觉
+    //6-----仪器
+    //7-----精密
+    private int method;
+
+    //设备状态
+    //0-----停止
+    //1-----运行
+    private int state;
+
+    @OneToMany(mappedBy = "item")
+    private List<PointCheckStandardItemResult> resultList;
+
+    public PointCheckStandard getPointCheckStandard() {
+        return pointCheckStandard;
+    }
+
+    public void setPointCheckStandard(PointCheckStandard pointCheckStandard) {
+        this.pointCheckStandard = pointCheckStandard;
+    }
+//
+//    //点检分工(岗位,运行、点检)
+//    @OneToOne
+//    @JoinColumn(name = "role_role_id")
+//    private SysRole role;
+
+
+
+    //点检周期
+
+    private int cycle;
+    private int cycleUnit;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getConten() {
+        return conten;
+    }
+
+    public void setConten(String conten) {
+        this.conten = conten;
+    }
+
+    public String getStandard() {
+        return standard;
+    }
+
+    public void setStandard(String standard) {
+        this.standard = standard;
+    }
+
+    public int getMethod() {
+        return method;
+    }
+
+    public void setMethod(int method) {
+        this.method = method;
+    }
+
+    public int getState() {
+        return state;
+    }
+
+    public void setState(int state) {
+        this.state = state;
+    }
+
+    public List<PointCheckStandardItemResult> getResultList() {
+        return resultList;
+    }
+
+    public void setResultList(List<PointCheckStandardItemResult> resultList) {
+        this.resultList = resultList;
+    }
+
+    public int getCycle() {
+        return cycle;
+    }
+
+    public void setCycle(int cycle) {
+        this.cycle = cycle;
+    }
+
+    public int getCycleUnit() {
+        return cycleUnit;
+    }
+
+    public void setCycleUnit(int cycleUnit) {
+        this.cycleUnit = cycleUnit;
+    }
+}

+ 104 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckStandardItemResult.java

@@ -0,0 +1,104 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 点检条目的结果
+ */
+@Entity
+public class PointCheckStandardItemResult {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    @ManyToOne
+    @JoinColumn(name = "item_id")
+    private PointCheckStandardItem item;
+
+
+
+    //点检结果
+    private String result;
+
+    public PointCheckStandardItem getItem() {
+        return item;
+    }
+
+    public void setItem(PointCheckStandardItem item) {
+        this.item = item;
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+}

+ 41 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/PointCheckTask.java

@@ -0,0 +1,41 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class PointCheckTask {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    @ManyToOne
+    @JoinColumn(name = "point_check_standard_id")
+    private PointCheckStandard pointCheckStandard;
+
+
+
+    public PointCheckStandard getPointCheckStandard() {
+        return pointCheckStandard;
+    }
+
+    public void setPointCheckStandard(PointCheckStandard pointCheckStandard) {
+        this.pointCheckStandard = pointCheckStandard;
+    }
+}

+ 153 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/ReformLog.java

@@ -0,0 +1,153 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 设备年修及改造记录
+ */
+@Entity
+public class ReformLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    //设备,多对一
+
+
+    //类别
+    private String type;
+
+    //改造日期
+    private Timestamp date;
+
+    //改造机构
+
+    @ManyToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+    //实施情况、改造效果
+    @Lob
+    private String result;
+
+
+    //事故、隐患、
+    @ManyToOne
+    private AccidentLog accidentLog;
+
+
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public AccidentLog getAccidentLog() {
+        return accidentLog;
+    }
+
+    public void setAccidentLog(AccidentLog accidentLog) {
+        this.accidentLog = accidentLog;
+    }
+
+    //记录人
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Timestamp getDate() {
+        return date;
+    }
+
+    public void setDate(Timestamp date) {
+        this.date = date;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+
+
+
+}

+ 171 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/RepairStandard.java

@@ -0,0 +1,171 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+@Entity
+public class RepairStandard {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    //材质、型号
+    private String type;
+
+    //图纸尺寸
+    private String drawingSize;
+
+
+
+    //劣化及允许量
+    private String degradation;
+
+
+
+
+    //技术要求
+    @Lob
+    private String techDemands;
+
+    //更换周期
+    private int exchangeCycle;
+    private String exchangeCycleUnit;
+
+    //备注
+    private String remark;
+
+
+    @OneToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getTechDemands() {
+        return techDemands;
+    }
+
+    public void setTechDemands(String techDemands) {
+        this.techDemands = techDemands;
+    }
+
+    public int getExchangeCycle() {
+        return exchangeCycle;
+    }
+
+    public void setExchangeCycle(int exchangeCycle) {
+        this.exchangeCycle = exchangeCycle;
+    }
+
+    public String getExchangeCycleUnit() {
+        return exchangeCycleUnit;
+    }
+
+    public void setExchangeCycleUnit(String exchangeCycleUnit) {
+        this.exchangeCycleUnit = exchangeCycleUnit;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getDrawingSize() {
+        return drawingSize;
+    }
+
+    public void setDrawingSize(String drawingSize) {
+        this.drawingSize = drawingSize;
+    }
+
+    public String getDegradation() {
+        return degradation;
+    }
+
+    public void setDegradation(String degradation) {
+        this.degradation = degradation;
+    }
+}

+ 109 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/SpecialLog.java

@@ -0,0 +1,109 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 特殊事项记录
+ */
+
+@Entity
+public class SpecialLog {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+
+    //变更项目名称
+    private String name ;
+
+
+    //变更记录
+    @Lob
+    private String changeLog;
+
+
+
+    @OneToOne
+    @JoinColumn(name = "device_id")
+    private Device device;
+
+    public Device getDevice() {
+        return device;
+    }
+
+    public void setDevice(Device device) {
+        this.device = device;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getChangeLog() {
+        return changeLog;
+    }
+
+    public void setChangeLog(String changeLog) {
+        this.changeLog = changeLog;
+    }
+}

+ 519 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/TechParameter.java

@@ -0,0 +1,519 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 技术参数(天车)
+ */
+@Entity
+public class TechParameter {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    //长度
+    private double length;
+    //长度
+    private String lengthUnit;
+    //宽度
+    private double width;
+    private String widthUnit;
+
+    //最高点距柜面
+    private double highestValueToRail;
+    private String highestValueToRailUnit;
+
+    //轨面标高
+    private double railSurfaceHeight;
+    private String railSurfaceHeightUnit;
+
+    //大车缓冲器行程
+    private double bigCarBufferDistance;
+    private String bigCarBufferDistanceUnit;
+
+    //小车车缓冲器行程
+    private double smallCarBufferDistance;
+    private String smallCarBufferDistanceUnit;
+
+
+    //各机构电机功率总和
+    private double powerGenerationgTotalCapacity;
+    private String powerGenerationgTotalCapacityUnit;
+
+
+
+    @OneToOne
+    @JoinColumn(name = "crane_id")
+    private Device crane;
+
+    //主起重量
+    private double mainHoistWeight;
+    private String mainHoistWeightUnit;
+
+    //副起重量
+    private double deputyHoistWeight;
+    private String deputyHoistWeightUnit;
+
+    //大车跨度
+    private double bigCarLength;
+    private String bigCarLengthUnit;
+
+    //小车车跨度
+    private double smallCarLength;
+    private String smallCarLengthUnit;
+
+    //工作级别(M5)
+    private String workLevel;
+
+
+
+    //主起最小速度
+    private double mainHoistMinSpeed;
+    private String mainHoistMinSpeedUnit;
+
+
+    //主起最大速度
+    private double mainHoistMaxSpeed;
+    private String mainHoistMaxSpeedUnit;
+
+    //副起升最小速度
+    private double deputyHoistMinSpeed;
+    private String deputyHoistMinSpeedUnit;
+
+    //副起升最大速度
+    private double deputyHoistMaxSpeed;
+    private String deputyHoistMaxSpeedUnit;
+
+
+    //大车最小运行速度
+    private double bigCarMinSpeed;
+    private String bigCarminSpeedUnit;
+
+    //大车最大运行速度
+    private double bigCarMaxSpeed;
+    private String bigCarMaxSpeedUnit;
+
+
+    //小车车最小运行速度
+    private double smallCarMinSpeed;
+    private String smallCarminSpeedUnit;
+
+    //小车最大运行速度
+    private double smallCarMaxSpeed;
+    private String smallCarMaxSpeedUnit;
+
+    private double mainHoistHeight;
+    private String mainHoistHeightUnit;
+    private double deputyHoistHeight;
+    private String deputyHoistHeightUnit;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public double getLength() {
+        return length;
+    }
+
+    public void setLength(double length) {
+        this.length = length;
+    }
+
+    public String getLengthUnit() {
+        return lengthUnit;
+    }
+
+    public void setLengthUnit(String lengthUnit) {
+        this.lengthUnit = lengthUnit;
+    }
+
+    public double getWidth() {
+        return width;
+    }
+
+    public void setWidth(double width) {
+        this.width = width;
+    }
+
+    public String getWidthUnit() {
+        return widthUnit;
+    }
+
+    public void setWidthUnit(String widthUnit) {
+        this.widthUnit = widthUnit;
+    }
+
+    public double getHighestValueToRail() {
+        return highestValueToRail;
+    }
+
+    public void setHighestValueToRail(double highestValueToRail) {
+        this.highestValueToRail = highestValueToRail;
+    }
+
+    public String getHighestValueToRailUnit() {
+        return highestValueToRailUnit;
+    }
+
+    public void setHighestValueToRailUnit(String highestValueToRailUnit) {
+        this.highestValueToRailUnit = highestValueToRailUnit;
+    }
+
+    public double getRailSurfaceHeight() {
+        return railSurfaceHeight;
+    }
+
+    public void setRailSurfaceHeight(double railSurfaceHeight) {
+        this.railSurfaceHeight = railSurfaceHeight;
+    }
+
+    public String getRailSurfaceHeightUnit() {
+        return railSurfaceHeightUnit;
+    }
+
+    public void setRailSurfaceHeightUnit(String railSurfaceHeightUnit) {
+        this.railSurfaceHeightUnit = railSurfaceHeightUnit;
+    }
+
+    public double getBigCarBufferDistance() {
+        return bigCarBufferDistance;
+    }
+
+    public void setBigCarBufferDistance(double bigCarBufferDistance) {
+        this.bigCarBufferDistance = bigCarBufferDistance;
+    }
+
+    public String getBigCarBufferDistanceUnit() {
+        return bigCarBufferDistanceUnit;
+    }
+
+    public void setBigCarBufferDistanceUnit(String bigCarBufferDistanceUnit) {
+        this.bigCarBufferDistanceUnit = bigCarBufferDistanceUnit;
+    }
+
+    public double getSmallCarBufferDistance() {
+        return smallCarBufferDistance;
+    }
+
+    public void setSmallCarBufferDistance(double smallCarBufferDistance) {
+        this.smallCarBufferDistance = smallCarBufferDistance;
+    }
+
+    public String getSmallCarBufferDistanceUnit() {
+        return smallCarBufferDistanceUnit;
+    }
+
+    public void setSmallCarBufferDistanceUnit(String smallCarBufferDistanceUnit) {
+        this.smallCarBufferDistanceUnit = smallCarBufferDistanceUnit;
+    }
+
+    public double getPowerGenerationgTotalCapacity() {
+        return powerGenerationgTotalCapacity;
+    }
+
+    public void setPowerGenerationgTotalCapacity(double powerGenerationgTotalCapacity) {
+        this.powerGenerationgTotalCapacity = powerGenerationgTotalCapacity;
+    }
+
+    public String getPowerGenerationgTotalCapacityUnit() {
+        return powerGenerationgTotalCapacityUnit;
+    }
+
+    public void setPowerGenerationgTotalCapacityUnit(String powerGenerationgTotalCapacityUnit) {
+        this.powerGenerationgTotalCapacityUnit = powerGenerationgTotalCapacityUnit;
+    }
+
+    public Device getCrane() {
+        return crane;
+    }
+
+    public void setCrane(Device crane) {
+        this.crane = crane;
+    }
+
+    public double getMainHoistWeight() {
+        return mainHoistWeight;
+    }
+
+    public void setMainHoistWeight(double mainHoistWeight) {
+        this.mainHoistWeight = mainHoistWeight;
+    }
+
+    public String getMainHoistWeightUnit() {
+        return mainHoistWeightUnit;
+    }
+
+    public void setMainHoistWeightUnit(String mainHoistWeightUnit) {
+        this.mainHoistWeightUnit = mainHoistWeightUnit;
+    }
+
+    public double getDeputyHoistWeight() {
+        return deputyHoistWeight;
+    }
+
+    public void setDeputyHoistWeight(double deputyHoistWeight) {
+        this.deputyHoistWeight = deputyHoistWeight;
+    }
+
+    public String getDeputyHoistWeightUnit() {
+        return deputyHoistWeightUnit;
+    }
+
+    public void setDeputyHoistWeightUnit(String deputyHoistWeightUnit) {
+        this.deputyHoistWeightUnit = deputyHoistWeightUnit;
+    }
+
+    public double getBigCarLength() {
+        return bigCarLength;
+    }
+
+    public void setBigCarLength(double bigCarLength) {
+        this.bigCarLength = bigCarLength;
+    }
+
+    public String getBigCarLengthUnit() {
+        return bigCarLengthUnit;
+    }
+
+    public void setBigCarLengthUnit(String bigCarLengthUnit) {
+        this.bigCarLengthUnit = bigCarLengthUnit;
+    }
+
+    public double getSmallCarLength() {
+        return smallCarLength;
+    }
+
+    public void setSmallCarLength(double smallCarLength) {
+        this.smallCarLength = smallCarLength;
+    }
+
+    public String getSmallCarLengthUnit() {
+        return smallCarLengthUnit;
+    }
+
+    public void setSmallCarLengthUnit(String smallCarLengthUnit) {
+        this.smallCarLengthUnit = smallCarLengthUnit;
+    }
+
+    public String getWorkLevel() {
+        return workLevel;
+    }
+
+    public void setWorkLevel(String workLevel) {
+        this.workLevel = workLevel;
+    }
+
+    public double getMainHoistMinSpeed() {
+        return mainHoistMinSpeed;
+    }
+
+    public void setMainHoistMinSpeed(double mainHoistMinSpeed) {
+        this.mainHoistMinSpeed = mainHoistMinSpeed;
+    }
+
+    public String getMainHoistMinSpeedUnit() {
+        return mainHoistMinSpeedUnit;
+    }
+
+    public void setMainHoistMinSpeedUnit(String mainHoistMinSpeedUnit) {
+        this.mainHoistMinSpeedUnit = mainHoistMinSpeedUnit;
+    }
+
+    public double getMainHoistMaxSpeed() {
+        return mainHoistMaxSpeed;
+    }
+
+    public void setMainHoistMaxSpeed(double mainHoistMaxSpeed) {
+        this.mainHoistMaxSpeed = mainHoistMaxSpeed;
+    }
+
+    public String getMainHoistMaxSpeedUnit() {
+        return mainHoistMaxSpeedUnit;
+    }
+
+    public void setMainHoistMaxSpeedUnit(String mainHoistMaxSpeedUnit) {
+        this.mainHoistMaxSpeedUnit = mainHoistMaxSpeedUnit;
+    }
+
+    public double getDeputyHoistMinSpeed() {
+        return deputyHoistMinSpeed;
+    }
+
+    public void setDeputyHoistMinSpeed(double deputyHoistMinSpeed) {
+        this.deputyHoistMinSpeed = deputyHoistMinSpeed;
+    }
+
+    public String getDeputyHoistMinSpeedUnit() {
+        return deputyHoistMinSpeedUnit;
+    }
+
+    public void setDeputyHoistMinSpeedUnit(String deputyHoistMinSpeedUnit) {
+        this.deputyHoistMinSpeedUnit = deputyHoistMinSpeedUnit;
+    }
+
+    public double getDeputyHoistMaxSpeed() {
+        return deputyHoistMaxSpeed;
+    }
+
+    public void setDeputyHoistMaxSpeed(double deputyHoistMaxSpeed) {
+        this.deputyHoistMaxSpeed = deputyHoistMaxSpeed;
+    }
+
+    public String getDeputyHoistMaxSpeedUnit() {
+        return deputyHoistMaxSpeedUnit;
+    }
+
+    public void setDeputyHoistMaxSpeedUnit(String deputyHoistMaxSpeedUnit) {
+        this.deputyHoistMaxSpeedUnit = deputyHoistMaxSpeedUnit;
+    }
+
+    public double getBigCarMinSpeed() {
+        return bigCarMinSpeed;
+    }
+
+    public void setBigCarMinSpeed(double bigCarMinSpeed) {
+        this.bigCarMinSpeed = bigCarMinSpeed;
+    }
+
+    public String getBigCarminSpeedUnit() {
+        return bigCarminSpeedUnit;
+    }
+
+    public void setBigCarminSpeedUnit(String bigCarminSpeedUnit) {
+        this.bigCarminSpeedUnit = bigCarminSpeedUnit;
+    }
+
+    public double getBigCarMaxSpeed() {
+        return bigCarMaxSpeed;
+    }
+
+    public void setBigCarMaxSpeed(double bigCarMaxSpeed) {
+        this.bigCarMaxSpeed = bigCarMaxSpeed;
+    }
+
+    public String getBigCarMaxSpeedUnit() {
+        return bigCarMaxSpeedUnit;
+    }
+
+    public void setBigCarMaxSpeedUnit(String bigCarMaxSpeedUnit) {
+        this.bigCarMaxSpeedUnit = bigCarMaxSpeedUnit;
+    }
+
+    public double getSmallCarMinSpeed() {
+        return smallCarMinSpeed;
+    }
+
+    public void setSmallCarMinSpeed(double smallCarMinSpeed) {
+        this.smallCarMinSpeed = smallCarMinSpeed;
+    }
+
+    public String getSmallCarminSpeedUnit() {
+        return smallCarminSpeedUnit;
+    }
+
+    public void setSmallCarminSpeedUnit(String smallCarminSpeedUnit) {
+        this.smallCarminSpeedUnit = smallCarminSpeedUnit;
+    }
+
+    public double getSmallCarMaxSpeed() {
+        return smallCarMaxSpeed;
+    }
+
+    public void setSmallCarMaxSpeed(double smallCarMaxSpeed) {
+        this.smallCarMaxSpeed = smallCarMaxSpeed;
+    }
+
+    public String getSmallCarMaxSpeedUnit() {
+        return smallCarMaxSpeedUnit;
+    }
+
+    public void setSmallCarMaxSpeedUnit(String smallCarMaxSpeedUnit) {
+        this.smallCarMaxSpeedUnit = smallCarMaxSpeedUnit;
+    }
+
+    public double getMainHoistHeight() {
+        return mainHoistHeight;
+    }
+
+    public void setMainHoistHeight(double mainHoistHeight) {
+        this.mainHoistHeight = mainHoistHeight;
+    }
+
+    public String getMainHoistHeightUnit() {
+        return mainHoistHeightUnit;
+    }
+
+    public void setMainHoistHeightUnit(String mainHoistHeightUnit) {
+        this.mainHoistHeightUnit = mainHoistHeightUnit;
+    }
+
+    public double getDeputyHoistHeight() {
+        return deputyHoistHeight;
+    }
+
+    public void setDeputyHoistHeight(double deputyHoistHeight) {
+        this.deputyHoistHeight = deputyHoistHeight;
+    }
+
+    public String getDeputyHoistHeightUnit() {
+        return deputyHoistHeightUnit;
+    }
+
+    public void setDeputyHoistHeightUnit(String deputyHoistHeightUnit) {
+        this.deputyHoistHeightUnit = deputyHoistHeightUnit;
+    }
+}

+ 103 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/UnitInfo.java

@@ -0,0 +1,103 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/***
+ * 设备信息等使用的单位,例如 速度、高度、跨度、重量等
+ */
+
+
+@Deprecated
+@Entity
+public class UnitInfo {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name;
+    //值
+    private double value;
+    //单位
+    private String unit;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public double getValue() {
+        return value;
+    }
+
+    public void setValue(double value) {
+        this.value = value;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+}

+ 85 - 0
src/main/java/com/lstznkj/groundstation/model/crane/extra/WareHouse.java

@@ -0,0 +1,85 @@
+package com.lstznkj.groundstation.model.crane.extra;
+
+
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * 仓库
+ */
+@Entity
+public class WareHouse {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    //数据库唯一标识符
+    private Integer id;
+
+    @CreationTimestamp
+    private Timestamp createTimestamp;
+    @UpdateTimestamp
+    private Timestamp updateTimestamp;
+
+    @Transient
+    private String createTime;
+    @Transient
+    private String updateTime;
+
+    private String name ;
+
+    //设备备件列表,一对多。
+
+
+    //更换记录,一对多
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Timestamp getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Timestamp createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    public Timestamp getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Timestamp updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 97 - 0
src/main/java/com/lstznkj/groundstation/mqtt/MqttFactory.java

@@ -0,0 +1,97 @@
+package com.lstznkj.groundstation.mqtt;
+
+import com.lstznkj.groundstation.GlobalData;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+
+public class MqttFactory {
+    private static MqttClient mqttClient;
+    public static void setInstance(MqttClient client){
+        mqttClient=client;
+    }
+    public static MqttClient getInstance(){
+        return mqttClient;
+    }
+    public static MqttProvider createMqttProvider(String username,String password,String url,String id){
+        MqttProvider mqttProvider=new MqttProvider();
+
+
+        try{
+            //创建MQTT客户端对象
+            MqttClient  client = new MqttClient(url,id,new MemoryPersistence());
+            //连接设置
+            MqttConnectOptions options = new MqttConnectOptions();
+            //是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
+            //设置为true表示每次连接服务器都是以新的身份
+            options.setCleanSession(true);
+
+            //设置连接用户名
+            options.setUserName(username);
+            //设置连接密码
+            options.setPassword(password.toCharArray());
+            //设置超时时间,单位为秒
+            options.setConnectionTimeout(100);
+            //设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
+            options.setKeepAliveInterval(20);
+            //设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
+            options.setWill("willTopic",(id + "与服务器断开连接").getBytes(),0,false);
+            //设置回调
+           // client.setCallback(new MqttProviderCallBack());
+            mqttProvider.setClientId(id);
+            MqttProviderCallBack callBack=new MqttProviderCallBack();
+            callBack.setClientId(id);
+            mqttProvider.setClient(client);
+            mqttProvider.setCallBack(callBack);
+            mqttProvider.connect(options);
+
+           // client.connect(options);
+
+
+            mqttProvider.setConnected(true);
+
+        } catch(MqttException e){
+            mqttProvider.setConnected(false);
+            e.printStackTrace();
+        }
+
+        return mqttProvider;
+    }
+
+    public static MqttClient createInstance(String username,String password,String url,String id){
+        MqttClient client=null;
+        try {
+            client =new MqttClient(url,id,new MemoryPersistence() );
+            MqttConnectOptions options = new MqttConnectOptions();
+            //是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
+            //设置为true表示每次连接服务器都是以新的身份
+//            options.setCleanSession(true);
+            options.setCleanSession(false);
+            //设置连接用户名
+            options.setUserName(username);
+            //设置连接密码
+            options.setPassword(password.toCharArray());
+            //设置超时时间,单位为秒
+            options.setConnectionTimeout(100);
+            //设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
+            options.setKeepAliveInterval(20);
+
+            options.setAutomaticReconnect(true);
+            //设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
+            options.setWill("willTopic",(id + "与服务器断开连接").getBytes(),0,false);
+            //设置回调
+            MqttProviderCallBack callBack=new MqttProviderCallBack();
+            callBack.setOptions(options);
+            callBack.setClientId(id);
+            client.setCallback(callBack);
+            client.connect(options);
+            callBack.setClient(client);
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+        return client;
+
+    }
+}

+ 34 - 0
src/main/java/com/lstznkj/groundstation/mqtt/MqttManager.java

@@ -0,0 +1,34 @@
+package com.lstznkj.groundstation.mqtt;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MqttManager {
+    public static List<MqttProvider> mqttProviderList =new ArrayList<>();
+    private static Logger logger= LoggerFactory.getLogger(MqttManager.class);
+    public static boolean addMqttProvider(MqttProvider mqttProvider){
+        boolean isExisted=false;
+        for(MqttProvider provider:mqttProviderList){
+            if(provider.getClientId().equals(mqttProvider)){
+                isExisted=true;
+                logger.error(mqttProvider.getClientId()+" is already existed!!!!");
+                return false;
+            }
+        }
+        if(!isExisted){
+            mqttProviderList.add(mqttProvider);
+        }
+        return true;
+    }
+    public static MqttProvider findMqttProvider(String id){
+        for(MqttProvider provider: mqttProviderList){
+            if(provider.getClientId().equals(id)){
+                return provider;
+            }
+        }
+        return null;
+    }
+}

+ 305 - 0
src/main/java/com/lstznkj/groundstation/mqtt/MqttProvider.java

@@ -0,0 +1,305 @@
+package com.lstznkj.groundstation.mqtt;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.GlobalData;
+import com.lstznkj.groundstation.model.crane.BaseData;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.service.crane.BaseDataService;
+import com.lstznkj.groundstation.utils.SpringContextUtil;
+import org.eclipse.paho.client.mqttv3.*;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+
+@Configuration
+public class MqttProvider {
+
+    private Logger logger= LoggerFactory.getLogger(getClass());
+
+    private String username;
+    private boolean isConnected;
+
+
+
+    private  MqttConnectOptions options;
+
+    private String password;
+
+
+    private String hostUrl;
+
+
+    private String clientId;
+
+
+    private String defaultTopic;
+    private MqttProviderCallBack callBack;
+
+
+    List<DataSource> dataSourceList;
+
+    /**
+     * 客户端对象
+     */
+    private MqttClient client;
+
+    /**
+     * 在bean初始化后连接到服务器
+     */
+//    @PostConstruct
+    @Deprecated
+    public void init(){
+        logger.info("mqqtt init ");
+//        System.out.println("mqtt init");
+        connect();
+        MqttFactory.setInstance(client);
+    }
+
+    public void connect(MqttConnectOptions options){
+        try {
+            client.setCallback(callBack);
+
+            client.connect(options);
+
+        }
+        catch (Exception ex){
+            logger.error(clientId+ "connected error:"+ex.getMessage());
+        }
+
+
+    }
+
+    /***
+     * 订阅所有数据源主题
+     */
+    public void subscribeDataSource(){
+
+        for(DataSource dataSource:this.dataSourceList){
+            try {
+            this.client.subscribe(dataSource.getPublishTopic(), new IMqttMessageListener() {
+                @Override
+                public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
+
+                    Thread tmpThread=new Thread(new Runnable() {
+
+
+
+                        @Override
+                        public void run() {
+                            try {
+
+                                BaseDataService baseDataService= SpringContextUtil.getBean(BaseDataService.class);
+
+                                //差异原始数据(为数据库最后一条记录),当差异数据累计到指定值时 存储到数据库,
+                                //private BaseData originDifferData=baseDataService.findTheLast(dataSource);
+
+                                 double differTotalValue= dataSource.getDifferTotalValue();
+
+                                 int sparseCount= dataSource.getTmpSparseCount();
+
+                                //private BaseData lastData;
+                                ObjectMapper objectMapper=new ObjectMapper();
+
+                                logger.info("originDifferData:"+objectMapper.writeValueAsString(dataSource.getLastBaseData()));
+
+                                BaseData baseData=new BaseData();
+                                JsonNode mqttNode=objectMapper.readTree(mqttMessage.toString());
+                                baseData.setName(mqttNode.get("name").asText());
+                                baseData.setValue(mqttNode.get("value").asDouble());
+
+                                baseData.setOriginValue(mqttNode.get("originValue").asInt());
+                                baseData.setCollectTime(mqttNode.get("createTime").asLong());
+
+//                                double differValue=Math.abs(baseData.getValue()-dataSource.getLastBaseData().getValue());
+                                double differValue=Math.abs(baseData.getValue()-dataSource.getLastBaseData().getValue());
+
+                                differTotalValue=dataSource.getDifferTotalValue()+differValue;
+
+                                dataSource.setDifferTotalValue(differTotalValue);
+                                logger.info("differTotalValue:"+dataSource.getDifferTotalValue()+";sparseValue:"+dataSource.getDifferSparseValue());
+
+                                if(dataSource.getDifferTotalValue()>=dataSource.getTotalSparseValue()||sparseCount<=0||differValue>=dataSource.getDifferSparseValue()){
+                                    baseData=baseDataService.add(baseData).getData();
+                                    baseData.setDataSource(dataSource);
+                                    baseData=baseDataService.add(baseData).getData();
+                                    dataSource.setLastBaseData(baseData);
+                                    dataSource.setDifferTotalValue(0);
+                                    logger.info("dataSource:"+dataSource.getName()+","+dataSource.getId()+ "baseData is saved:"+objectMapper.writeValueAsString(baseData));
+                                    //reset tmpSparseCount
+                                    dataSource.setTmpSparseCount(dataSource.getSparseCount());
+                                }
+                                else {
+                                    sparseCount--;
+                                    dataSource.setTmpSparseCount(sparseCount);
+                                    logger.info("dataSource:"+dataSource.getName()+","+dataSource.getId()+ ",baseData is sparsed,sparseCount:"+sparseCount+";"+objectMapper.writeValueAsString(baseData));
+
+                                }
+
+
+
+                            }
+                            catch (Exception ex){
+                                logger.error("base data save to database error :"+ex.getMessage());
+                                ex.printStackTrace();
+                            }
+
+                        }
+                    });
+                    GlobalData.DataSaveThreadPool.submit(tmpThread);
+                    logger.info("topic:"+s+": "+mqttMessage.toString());
+                }
+            });
+            }
+            catch (Exception ex){
+                logger.error("errors in subsribeDatasource "+clientId+":"+ex.getMessage());
+            }
+
+        }
+    }
+
+    /**
+     * 客户端连接服务端
+     */
+    @Deprecated
+    public void connect(){
+        try{
+            //创建MQTT客户端对象
+            client = new MqttClient(hostUrl,clientId,new MemoryPersistence());
+            //连接设置
+            MqttConnectOptions options = new MqttConnectOptions();
+            //是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
+            //设置为true表示每次连接服务器都是以新的身份
+            options.setCleanSession(true);
+            //设置连接用户名
+            options.setUserName(username);
+            //设置连接密码
+            options.setPassword(password.toCharArray());
+            //设置超时时间,单位为秒
+            options.setConnectionTimeout(100);
+            //设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
+            options.setKeepAliveInterval(20);
+            //设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
+            options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false);
+            //设置回调
+            client.setCallback(new MqttProviderCallBack());
+
+            client.connect(options);
+        } catch(MqttException e){
+            e.printStackTrace();
+        }
+
+    }
+
+    /***
+     *
+     * QoS 0 至多一次
+     *  QoS 1 最少一次
+     * QoS 1 承诺消息将至少传送一次给订阅者。
+     *  QoS 2 只有一次
+     * 使用 QoS 2,我们保证消息仅传送到目的地一次。为此,带有唯一消息 ID 的消息会存储两次,
+     * 首先来自发送者,然后是接收者。QoS 级别 2 在网络中具有最高的开销,因为在发送方和接收方之间需要两个流。
+     * 这一级别会发生消息丢失或重复,消息发布依赖于底层TCP/IP网络。即:<=1
+     * @param qos
+     *
+     * @param retained
+     * @param topic
+     * @param message
+     */
+    public void publish(int qos,boolean retained,String topic,String message){
+        MqttMessage mqttMessage = new MqttMessage();
+        mqttMessage.setQos(qos);
+        mqttMessage.setRetained(retained);
+        mqttMessage.setPayload(message.getBytes());
+        //主题的目的地,用于发布/订阅信息
+        MqttTopic mqttTopic = client.getTopic(topic);
+        //提供一种机制来跟踪消息的传递进度
+        //用于在以非阻塞方式(在后台运行)执行发布是跟踪消息的传递进度
+        MqttDeliveryToken token;
+        try {
+            //将指定消息发布到主题,但不等待消息传递完成,返回的token可用于跟踪消息的传递状态
+            //一旦此方法干净地返回,消息就已被客户端接受发布,当连接可用,将在后台完成消息传递。
+            token = mqttTopic.publish(mqttMessage);
+            token.waitForCompletion();
+        } catch (MqttException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    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 getHostUrl() {
+        return hostUrl;
+    }
+
+    public void setHostUrl(String hostUrl) {
+        this.hostUrl = hostUrl;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public boolean isConnected() {
+        return client.isConnected();
+    }
+
+    public void setConnected(boolean connected) {
+        isConnected = connected;
+    }
+
+    public MqttClient getClient() {
+        return client;
+    }
+
+    public void setClient(MqttClient client) {
+        this.client = client;
+    }
+
+    public MqttProviderCallBack getCallBack() {
+        return callBack;
+    }
+
+    public void setCallBack(MqttProviderCallBack callBack) {
+        client.setCallback(callBack);
+        this.callBack = callBack;
+    }
+
+    public MqttConnectOptions getOptions() {
+        return options;
+    }
+
+    public void setOptions(MqttConnectOptions options) {
+
+        this.options = options;
+    }
+
+    public List<DataSource> getDataSourceList() {
+        return dataSourceList;
+    }
+
+    public void setDataSourceList(List<DataSource> dataSourceList) {
+        this.dataSourceList = dataSourceList;
+    }
+}

+ 109 - 0
src/main/java/com/lstznkj/groundstation/mqtt/MqttProviderCallBack.java

@@ -0,0 +1,109 @@
+package com.lstznkj.groundstation.mqtt;
+
+import org.eclipse.paho.client.mqttv3.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MqttProviderCallBack implements MqttCallback {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    private MqttClient client;
+
+    private String clientId;
+
+    MqttConnectOptions options;
+
+
+
+    /**
+     * 与服务器断开的回调
+     */
+    @Override
+    public void connectionLost(Throwable cause) {
+      /*  Thread reconnectThread=new Thread(new Runnable() {
+            @Override
+            public void run() {
+
+            }
+        });*/
+        logger.error("mqtt server:"+clientId+" connected error :"+cause.getMessage());
+        try {
+
+            MqttProvider provider= MqttManager.findMqttProvider(this.clientId);
+            provider.setConnected(false);
+
+            while (!provider.isConnected()){
+                logger.info(clientId+" try to reconnec!!!");
+                try {
+                    provider.connect(provider.getOptions());
+                    Thread.sleep(1000);
+                    if(provider.isConnected()){
+                        logger.info(clientId+" reconnected success!!!");
+                        provider.subscribeDataSource();
+                    }
+
+                }
+                catch (Exception ex0){
+                    provider.setConnected(false);
+                    ex0.printStackTrace();
+                }
+            }
+            //client.connect(options);
+        }
+        catch (Exception ex){
+            try {
+           //     client.connect(options);
+            }catch (Exception ex1){
+                ex1.printStackTrace();
+            }
+
+        }
+
+    }
+
+
+
+    /**
+     * 消息到达的回调
+     */
+    @Override
+    public void messageArrived(String topic, MqttMessage message) throws Exception {
+
+
+    }
+
+    /**
+     * 消息发布成功的回调
+     */
+    @Override
+    public void deliveryComplete(IMqttDeliveryToken token) {
+        IMqttAsyncClient client = token.getClient();
+        System.out.println(client.getClientId()+"发布消息成功!");
+
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public MqttConnectOptions getOptions() {
+        return options;
+    }
+
+    public void setOptions(MqttConnectOptions options) {
+        this.options = options;
+    }
+
+    public MqttClient getClient() {
+        return client;
+    }
+
+    public void setClient(MqttClient client) {
+        this.client = client;
+    }
+}

+ 50 - 0
src/main/java/com/lstznkj/groundstation/mqtt/MqttUtil.java

@@ -0,0 +1,50 @@
+package com.lstznkj.groundstation.mqtt;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.StandardCharsets;
+
+
+public class MqttUtil {
+    private static Logger logger= LoggerFactory.getLogger(MqttUtil.class);
+    /**
+     *   发送消息
+     *   @param topic 主题
+     *   @param data 消息内容
+     */
+    public static void send(String topic, Object data) {
+        // 获取客户端实例
+        MqttClient client = MqttFactory.getInstance();
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            // 转换消息为json字符串
+            String json = mapper.writeValueAsString(data);
+            client.publish(topic, new MqttMessage(json.getBytes(StandardCharsets.UTF_8)));
+        } catch (JsonProcessingException e) {
+            logger.error(String.format("MQTT: 主题[%s]发送消息转换json失败", topic));
+        } catch (MqttException e) {
+            logger.error(String.format("MQTT: 主题[%s]发送消息失败", topic));
+        }
+    }
+
+    /**
+     * 订阅主题
+     * @param topic 主题
+     * @param listener 消息监听处理器
+     */
+    public static void subscribe(String topic, IMqttMessageListener listener) {
+        MqttClient client = MqttFactory.getInstance();
+        try {
+            client.subscribe(topic, listener);
+        } catch (MqttException e) {
+           logger.error(String.format("MQTT: 订阅主题[%s]失败", topic));
+        }
+    }
+}

+ 19 - 0
src/main/java/com/lstznkj/groundstation/repo/AuthorityRepository.java

@@ -0,0 +1,19 @@
+package com.lstznkj.groundstation.repo;
+
+import com.lstznkj.groundstation.model.Authority;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+
+public interface AuthorityRepository extends JpaRepository<Authority,Integer> {
+
+    Authority findAuthorityByName(String name);
+    Authority findById(int id);
+    List<Authority> findAuthoritiesByApiUrl(String apiUrl);
+    Authority findAuthorityByApiUrlAndMethod(String apiUrl,String mehtod);
+    boolean existsByName(String name);
+    boolean existsByApiUrlAndMethod(String apiUrl,String method);
+    boolean existsById(int id);
+    Authority deleteById(int id);
+}

+ 11 - 0
src/main/java/com/lstznkj/groundstation/repo/SysRoleRepository.java

@@ -0,0 +1,11 @@
+package com.lstznkj.groundstation.repo;
+
+import com.lstznkj.groundstation.model.SysRole;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface SysRoleRepository extends JpaRepository<SysRole, Integer> {
+    SysRole findSysRoleByName(String name);
+    boolean existsSysRoleByName(String name);
+    SysRole findSysRoleById(int id);
+}

+ 13 - 0
src/main/java/com/lstznkj/groundstation/repo/UserRepository.java

@@ -0,0 +1,13 @@
+package com.lstznkj.groundstation.repo;
+
+
+import com.lstznkj.groundstation.model.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface UserRepository extends JpaRepository<User,Integer> {
+    User findUserByUsername(String account);
+
+    int deleteUserByUsername(String account);
+    boolean existsUserByUsername(String account);
+}

+ 20 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/BaseDataRepository.java

@@ -0,0 +1,20 @@
+package com.lstznkj.groundstation.repo.crane;
+
+
+import com.lstznkj.groundstation.model.crane.BaseData;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+public interface BaseDataRepository extends JpaRepository<BaseData,Long> {
+    List<BaseData> findByDataSourceAndCreateTimestampBetween(DataSource dataSource, Timestamp createTimestampStart, Timestamp createTimestampEnd);
+
+    BaseData findFirstByAllIgnoreCaseOrderByIdDesc();
+
+    BaseData findFirstByDataSourceOrderByIdDesc(DataSource dataSource);
+
+
+}

+ 13 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/DataSourceRepository.java

@@ -0,0 +1,13 @@
+package com.lstznkj.groundstation.repo.crane;
+
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.Device;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface DataSourceRepository extends JpaRepository<DataSource,Integer> {
+    List<DataSource> findAllByDevice(Device device);
+}

+ 16 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/DataTypeRepository.java

@@ -0,0 +1,16 @@
+package com.lstznkj.groundstation.repo.crane;
+
+import com.lstznkj.groundstation.model.crane.DataType;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface DataTypeRepository extends JpaRepository<DataType,Integer> {
+    DataType findByName(String name);
+
+    Optional<DataType> findById(Integer id);
+    DataType findDataTypeById(Integer id);
+
+    List<DataType> findAll();
+}

+ 32 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/DeviceRepository.java

@@ -0,0 +1,32 @@
+package com.lstznkj.groundstation.repo.crane;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface DeviceRepository extends JpaRepository<Device,Integer> {
+
+
+
+    /**
+     * 查找指定等级的设备,0为根设备,即起重机
+     * @param level
+     * @return
+     */
+    List<Device> findByLevelIs(int level);
+
+
+    Device findDeviceById(Integer integer);
+
+    @Override
+    Optional<Device> findById(Integer integer);
+
+    @Override
+    boolean existsById(Integer integer);
+
+
+}

+ 10 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/StateRepository.java

@@ -0,0 +1,10 @@
+package com.lstznkj.groundstation.repo.crane;
+
+import com.lstznkj.groundstation.model.crane.State;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface StateRepository extends JpaRepository<State,Integer> {
+    State findByName(String name);
+
+    boolean existsByName(String name);
+}

+ 10 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/extra/DeviceSummaryRepository.java

@@ -0,0 +1,10 @@
+package com.lstznkj.groundstation.repo.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.extra.DeviceSummary;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface DeviceSummaryRepository extends JpaRepository<DeviceSummary,Integer> {
+    DeviceSummary findByCrane_Id(Integer id);
+
+}

+ 18 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/extra/EquipmentRepository.java

@@ -0,0 +1,18 @@
+package com.lstznkj.groundstation.repo.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.extra.Equipment;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface EquipmentRepository extends JpaRepository<Equipment,Integer> {
+    Equipment findByUuid(String uuid);
+
+    long deleteByUuid(String uuid);
+
+    long deleteByDevice(Device device);
+
+    Equipment findByDevice_Id(Integer id);
+
+    boolean existsByDevice_Id(Integer id);
+}

+ 14 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/extra/LifeModelRepository.java

@@ -0,0 +1,14 @@
+package com.lstznkj.groundstation.repo.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.LifeModel;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface LifeModelRepository extends JpaRepository<LifeModel,Integer> {
+    long deleteByDevice(Device device);
+
+    LifeModel findByDevice_Id(Integer id);
+
+    boolean existsByDevice_Id(Integer id);
+}

+ 9 - 0
src/main/java/com/lstznkj/groundstation/repo/crane/extra/TechParameterRepository.java

@@ -0,0 +1,9 @@
+package com.lstznkj.groundstation.repo.crane.extra;
+
+import com.lstznkj.groundstation.model.crane.extra.TechParameter;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.CrudRepository;
+
+public interface TechParameterRepository extends JpaRepository<TechParameter,Integer> {
+    TechParameter findByCrane_Id(Integer id);
+}

+ 94 - 0
src/main/java/com/lstznkj/groundstation/security/UrlAccessDecisionManager.java

@@ -0,0 +1,94 @@
+package com.lstznkj.groundstation.security;
+
+import com.lstznkj.groundstation.model.Authority;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.access.AccessDecisionManager;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.security.access.ConfigAttribute;
+import org.springframework.security.authentication.InsufficientAuthenticationException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.web.FilterInvocation;
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Collection;
+
+
+
+@Service
+public class UrlAccessDecisionManager implements AccessDecisionManager {
+    private Logger logger= LoggerFactory.getLogger(UrlAccessDecisionManager.class);
+
+    @Override
+    public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
+        HttpServletRequest request = ((FilterInvocation) object).getHttpRequest();
+        String url, method;
+        logger.info("Decision:"+authentication.getPrincipal());
+        logger.info("Decision autorities:"+authentication.getAuthorities());
+        if(matchers("/user/logout",request))
+        {
+            logger.info( "start to logout");
+            return;
+        }
+
+        if(matchers("/swagger-ui.html",request))
+        {
+            logger.info( "swagger");
+            return;
+        }
+        if(matchers("/devices/*/dataSources",request)&&request.getMethod().equals("GET")){
+            logger.info("get crane dataSources");
+            return;
+        }
+        if(matchers("/devices/*/dataSourcePoolDTO",request)&&request.getMethod().equals("GET")){
+            logger.info("get crane dataSourcesPoolDTO");
+            return;
+        }
+        if(matchers("/test/**",request)&&request.getMethod().equals("GET")){
+            logger.info("test interface");
+            return;
+        }
+        for (GrantedAuthority ga : authentication.getAuthorities()) {
+
+            if (ga instanceof Authority) {
+                Authority authority = (Authority) ga;
+                url =authority.getApiUrl();
+                method = authority.getMethod();
+                if (matchers(url, request)) {
+                    if (method.equals(request.getMethod()) || "ALL".equals(method)) {
+                        return;
+                    }
+                }
+            }
+        }
+        logger.error(authentication.getPrincipal()+" has no right to "+request);
+        throw new AccessDeniedException("no right");
+    }
+
+
+    @Override
+    public boolean supports(ConfigAttribute attribute) {
+        return true;
+    }
+
+    @Override
+    public boolean supports(Class<?> clazz) {
+        return true;
+    }
+
+
+    private boolean matchers(String url, HttpServletRequest request) {
+        AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
+        logger.info(url +" start to match "+ request.getRequestURI()+",method:"+request.getMethod());
+        if (matcher.matches(request)) {
+            logger.info(url+" matched success");
+            return true;
+        }
+        logger.info(url+" matched failed");
+
+        return false;
+    }
+}

+ 85 - 0
src/main/java/com/lstznkj/groundstation/security/UserDetailsImpl.java

@@ -0,0 +1,85 @@
+package com.lstznkj.groundstation.security;
+
+import com.lstznkj.groundstation.model.Authority;
+import com.lstznkj.groundstation.model.SysRole;
+import com.lstznkj.groundstation.model.User;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class UserDetailsImpl implements UserDetails {
+    private Logger logger= LoggerFactory.getLogger( UserDetailsImpl.class);
+
+    private User user;
+
+    private List<String> roles;
+    public UserDetailsImpl(){
+
+    }
+    public UserDetailsImpl(User user)
+    {
+        this.user=user;
+    }
+
+    @JsonIgnore
+    @Override
+    public Collection<? extends GrantedAuthority> getAuthorities() {
+
+
+        List<Authority> authorityList=new ArrayList<>();
+       // logger.info("get authorities: roles size is  "+user.getSysRoles().size());
+        for(SysRole role : user.getSysRoles())
+        {
+            logger.info(role.getName()+ "'s authorities size is "+role.getAuthorities().size());
+            for(Authority authority:role.getAuthorities())
+            {
+
+                authorityList.add(authority);
+            }
+           // authorityList.add(new SimpleGrantedAuthority((role.getName())));
+        }
+        return authorityList;
+    }
+
+
+    public List<String> getRoles() {
+       return user.getRoles();
+    }
+
+    @Override
+    @JsonIgnore
+    public String getPassword() {
+        return user.getPassword();
+    }
+
+    @Override
+    public String getUsername() {
+        return user.getUsername();
+    }
+
+    @Override
+    public boolean isAccountNonExpired() {
+        return true;
+    }
+
+    @Override
+    public boolean isAccountNonLocked() {
+        return !user.isLocked();
+    }
+
+    @Override
+    public boolean isCredentialsNonExpired() {
+        return true;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return true;
+    }
+}

+ 42 - 0
src/main/java/com/lstznkj/groundstation/security/UserDetailsServiceImpl.java

@@ -0,0 +1,42 @@
+package com.lstznkj.groundstation.security;
+
+
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.repo.UserRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserDetailsServiceImpl implements UserDetailsService {
+    @Autowired
+    private UserRepository userRepository;
+    private Logger logger=LoggerFactory.getLogger(UserDetailsServiceImpl.class);
+    /**
+     * 登录逻辑实现
+     * @param username
+     * @return
+     * @throws UsernameNotFoundException
+     */
+    @Override
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+//
+//        if(username=="")
+//        {
+//            System.out.println("username is null");
+//        }
+        logger.info("loadUserByUsername: "+username);
+        User user=userRepository.findUserByUsername(username);
+        if(user == null)
+        {
+            logger.info("no user");
+            throw new UsernameNotFoundException("没有该用户");
+        }
+        logger.info("user:"+user.getUsername());
+        return new UserDetailsImpl(user);
+    }
+}

+ 73 - 0
src/main/java/com/lstznkj/groundstation/security/WebSecurityConfig.java

@@ -0,0 +1,73 @@
+package com.lstznkj.groundstation.security;
+
+import com.lstznkj.groundstation.security.jwt.JWTAuthenticationFilter;
+import com.lstznkj.groundstation.security.jwt.JWTLoginFilter;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.lstznkj.groundstation.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+@Configuration
+@EnableWebSecurity
+
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+    @Autowired
+    UserDetailsServiceImpl userDetailsService;
+
+    @Autowired
+    UrlAccessDecisionManager accessDecisionManager;
+    @Autowired
+    UserService userService;
+
+
+    @Autowired
+    //加密方式
+    private BCryptPasswordEncoder bCryptPasswordEncoder;
+
+
+    @Override
+    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+        //注入userDetailService
+
+        auth.userDetailsService(userDetailsService)
+                .passwordEncoder(bCryptPasswordEncoder);//加密方式
+    }
+
+
+
+    @Override
+    protected void configure(HttpSecurity http) throws Exception {
+
+        http.cors().and().csrf().disable().authorizeRequests()
+                .antMatchers(HttpMethod.POST, "/login").permitAll()
+                .antMatchers(HttpMethod.POST, "/test/**").permitAll()
+                .antMatchers(HttpMethod.POST, "/devices/*/dataSources").permitAll()
+                .antMatchers(HttpMethod.POST, "/logout").permitAll()
+                .antMatchers(HttpMethod.POST,"/campus-recruitments").permitAll()
+                .antMatchers(HttpMethod.GET,"/swagger-ui.html","/swagger*/**","/v2/**","/webjars/**").permitAll()
+                .antMatchers(HttpMethod.GET,"/users/secret/**").permitAll()
+                .antMatchers(HttpMethod.PUT,"/users/secret/**").permitAll()
+                //.antMatchers(HttpMethod.GET,"/upload-dir/*").permitAll()
+                .anyRequest().authenticated()
+                .accessDecisionManager(accessDecisionManager)
+                .and()
+                .addFilter(new JWTAuthenticationFilter(authenticationManager()))
+                // .formLogin().loginProcessingUrl("/login")
+                //.successHandler(loginSuccessHandler);
+                .addFilter(new JWTLoginFilter(authenticationManager()));
+    }
+
+/*    @Bean
+    public BCryptPasswordEncoder bCryptPasswordEncoder() {
+        return new BCryptPasswordEncoder();
+    }*/
+
+
+}

+ 85 - 0
src/main/java/com/lstznkj/groundstation/security/jwt/JWTAuthenticationFilter.java

@@ -0,0 +1,85 @@
+package com.lstznkj.groundstation.security.jwt;
+
+
+import com.lstznkj.groundstation.model.Authority;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * token的校验
+ * 该类继承自BasicAuthenticationFilter,在doFilterInternal方法中,
+ * 从http头的Authorization 项读取token数据,然后用Jwts包提供的方法校验token的合法性。
+ * 如果校验通过,就认为这是一个取得授权的合法请求
+ */
+public class JWTAuthenticationFilter extends BasicAuthenticationFilter {
+
+    private Logger logger= LoggerFactory.getLogger(JWTAuthenticationFilter.class);
+
+    private JWTUtils jwtUtils=new JWTUtils();
+
+
+    public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
+        super(authenticationManager);
+    }
+
+
+
+    @Override
+    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
+        String header = request.getHeader("Authorization");
+
+        if (header == null ) {
+            chain.doFilter(request, response);
+            return;
+        }
+
+        logger.info("header ",header);
+        UsernamePasswordAuthenticationToken authentication = getAuthentication(request);
+
+
+        SecurityContextHolder.getContext().setAuthentication(authentication);
+        chain.doFilter(request, response);
+
+    }
+
+    private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest request) {
+        logger.info("username", request.getParameter("username"));
+        String token = request.getHeader("Authorization");
+        logger.info("token " + token);
+
+        if (token != null) {
+            String username = jwtUtils.getUsername(token);
+            if (username != null) {
+                logger.info("auth user is " + username);
+                String authorityStr = jwtUtils.getUserAuthority(token);
+                logger.info("role is " + authorityStr);
+                Collection<Authority> authorities = new ArrayList<>();
+                String[] authoritiesStr = authorityStr.split(" ");
+
+                for (String authority : authoritiesStr) {
+                    logger.info("autoritiesStr " + authority);
+                    authorities.add(new Authority(authority));
+                }
+
+                return new UsernamePasswordAuthenticationToken(username, null, authorities);
+
+            }
+            return null;
+        }
+
+        return null;
+    }
+
+}

+ 173 - 0
src/main/java/com/lstznkj/groundstation/security/jwt/JWTLoginFilter.java

@@ -0,0 +1,173 @@
+package com.lstznkj.groundstation.security.jwt;
+
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.security.UserDetailsImpl;
+import com.lstznkj.groundstation.service.UserService;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.AuthenticationServiceException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+
+
+/**
+ * 验证用户名密码正确后,生成一个token,并将token返回给客户端
+ * 该类继承自UsernamePasswordAuthenticationFilter,重写了其中的2个方法
+ * attemptAuthentication :接收并解析用户凭证。
+ * successfulAuthentication :用户成功登录后,这个方法会被调用,我们在这个方法里生成token。
+ */
+public class JWTLoginFilter extends UsernamePasswordAuthenticationFilter {
+
+    private AuthenticationManager authenticationManager;
+    private Logger logger= LoggerFactory.getLogger(JWTLoginFilter.class);
+
+
+    private JWTUtils jwtUtils=new JWTUtils();
+    @Autowired
+    private UserService userService;
+
+
+
+    public JWTLoginFilter(AuthenticationManager authenticationManager) {
+        //super.setFilterProcessesUrl("/login");
+
+        this.authenticationManager = authenticationManager;
+
+    }
+
+    // 接收并解析用户凭证
+    @Override
+    public Authentication attemptAuthentication(HttpServletRequest req,
+                                                HttpServletResponse res) throws AuthenticationException {
+
+
+        if (req.getContentType() == null) {
+            throw new AuthenticationServiceException("请求头类型不支持: " + req.getContentType());
+        }
+
+        User user=null;
+        try {
+            ObjectMapper objectMapper=new ObjectMapper();
+            user= objectMapper.readValue(req.getInputStream(), User.class);
+            logger.info("qstr:"+user.getUsername());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        /*String account =obtainUsername(req);
+        String password=obtainPassword(req);
+        logger.info("user: "+account+" attempt login");
+        logger.info("content type "+req.getContentType());
+        logger.info("request url "+ req.getRequestURI());
+        logger.info("test header :"+req.getHeader("test"));*/
+
+
+        logger.info("user:"+user.getUsername()+" attempt login");
+
+//        User user=userService.findUserByAccount(account);
+//
+//        logger.info("username is "+user.getUsername());
+//        for(GrantedAuthority authority :user.getAuthorities())
+//        {
+//            logger.info("authority: "+authority.getAuthority());
+//        }
+
+        return authenticationManager.authenticate(
+                new UsernamePasswordAuthenticationToken(
+                        user.getUsername(),
+                        user.getPassword(),
+                        new ArrayList<>())
+        );
+
+    }
+
+
+    @Override
+    protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse res, AuthenticationException failed) throws IOException, ServletException {
+        super.unsuccessfulAuthentication(request, res, failed);
+
+        logger.info("login failed");
+
+        res.setContentType("application/json;charset=UTF-8");
+        ObjectMapper objectMapper=new ObjectMapper();
+
+        UserDetailsImpl user=new UserDetailsImpl();
+        String value=objectMapper.writeValueAsString(user);
+        res.getWriter().write(value);
+
+
+
+    }
+
+
+
+    // 用户成功登录后,这个方法会被调用,在这个方法里生成token
+    @Override
+    protected void successfulAuthentication(HttpServletRequest req,
+                                            HttpServletResponse res,
+                                            FilterChain chain,
+                                            Authentication auth) throws IOException, ServletException {
+
+        ObjectMapper objectMapper=new ObjectMapper();
+
+        UserDetailsImpl user=(UserDetailsImpl) auth.getPrincipal();
+        if(user.isAccountNonLocked()){
+            StringBuilder roles=new StringBuilder();
+
+            StringBuilder authorities=new StringBuilder();
+
+            for (String role :user.getRoles())
+            {
+                roles.append(role+" ");
+            }
+
+            logger.info(user.getUsername()+"'s authorities are "+user.getAuthorities());
+            for(GrantedAuthority authority : user.getAuthorities())
+            {
+                authorities.append(authority.getAuthority()+" ");
+                logger.info("user authority is "+authority.getAuthority());
+
+            }
+            res.setContentType("application/json;charset=UTF-8");
+            //String value=objectMapper.writerWithView(UserDetailsImpl.UserSimpleView.class).writeValueAsString(user);
+            String value=objectMapper.writeValueAsString(user);
+
+            logger.info("login sucess "+user.getUsername());
+
+            String token=jwtUtils.createToken(user.getUsername(),roles.toString(),authorities.toString());
+            res.addHeader(jwtUtils.getHeader(),  token);
+            logger.info("JWT:"+token);
+            logger.info("loginResult:"+value);
+            res.getWriter().write(value);
+        }
+
+
+
+
+//        String token = Jwts.builder()
+//                .setSubject(user.getUsername())
+//
+//                .setExpiration(new Date(System.currentTimeMillis() + 60 * 60 * 24 * 1000))
+//                .signWith(SignatureAlgorithm.HS512, "lstlst")
+////                .setPayload(value)
+//                .compact();
+//
+//
+
+
+
+    }
+
+}

+ 122 - 0
src/main/java/com/lstznkj/groundstation/security/jwt/JWTUtils.java

@@ -0,0 +1,122 @@
+package com.lstznkj.groundstation.security.jwt;
+
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class JWTUtils {
+
+    private final String header="Authorization";
+    private final String secret="lstznkj2020";
+    private long expiration=1000 * 24 * 60 * 60 * 7;;
+
+    private Logger logger= LoggerFactory.getLogger(JWTUtils.class);
+
+    public String getHeader() {
+        return header;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public long getExpiration() {
+        return expiration;
+    }
+
+
+//    public static final String TOKEN_HEADER = "Authorization";
+//    public static final String TOKEN_PREFIX = "";
+//
+//    public static final String SUBJECT = "my";
+//
+//    public static final long EXPIRITION = 1000 * 24 * 60 * 60 * 7;
+//
+//    public static final String APPSECRET_KEY = "my_secret";
+
+//    private static final String ROLE_CLAIMS = "role";
+
+
+
+
+    /**
+     * 生成token
+     * @param username
+     * @param role
+     * @return
+     */
+    public  String createToken(String username,String role,String authority) {
+
+        logger.info("start to create token");
+
+
+        String token = Jwts
+                .builder()
+                .setSubject(username)
+                .claim("username",username)
+                .claim("role",role)
+                .claim("authority",authority)
+                .setIssuedAt(new Date())
+                .setExpiration(new Date(System.currentTimeMillis() + expiration))
+                .signWith(SignatureAlgorithm.HS512, secret).compact();
+        return token;
+    }
+
+    public Claims checkJWT(String token) {
+        try {
+            final Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+            return claims;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 获取用户名
+     * @param token
+     * @return
+     */
+    public  String getUsername(String token){
+        Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+        return claims.get("username").toString();
+    }
+
+    /**
+     * 获取用户角色
+     * @param token
+     * @return
+     */
+    public  String getUserRole(String token){
+        Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+        return claims.get("role").toString();
+    }
+
+
+    /**
+     * 获取用户权限
+     * @param token
+     * @return
+     */
+    public  String getUserAuthority(String token){
+        Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+        return claims.get("authority").toString();
+    }
+    /**
+     * 是否过期
+     * @param token
+     * @return
+     */
+    public  boolean isExpiration(String token){
+        Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+        return claims.getExpiration().before(new Date());
+    }
+
+
+}

+ 161 - 0
src/main/java/com/lstznkj/groundstation/service/AuthorityService.java

@@ -0,0 +1,161 @@
+package com.lstznkj.groundstation.service;
+
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.Authority;
+import com.lstznkj.groundstation.model.SysRole;
+import com.lstznkj.groundstation.repo.AuthorityRepository;
+import com.lstznkj.groundstation.repo.SysRoleRepository;
+import com.lstznkj.groundstation.security.jwt.JWTUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AuthorityService {
+    private Logger logger= LoggerFactory.getLogger(AuthorityService.class);
+    @Autowired
+    private AuthorityRepository authRepository;
+    @Autowired
+    private SysRoleRepository sysRoleRepository;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+
+    @Autowired
+    private JWTUtils jwtUtils;
+
+    /**
+     * 通过jwt token 解析 获取用户
+     * @param token
+     * @return
+     */
+    public Result<Iterable<Authority>> findAll(String token)
+    {
+        Result<Iterable<Authority>> result=new Result<>();
+        result.setSuccess(true);
+        result.setInfo("test result");
+        String username=jwtUtils.getUsername(token);
+        String[] roles= jwtUtils.getUserRole(token).split(" ");
+        for(String s :roles)
+        {
+            logger.info(username+"'s roles: "+s);
+        }
+
+        result.setData(authRepository.findAll());
+
+        return result;
+    }
+
+
+
+
+    /***
+     * 添加权限
+     * @param authority
+     * @return
+     */
+    public Result<Authority> add(Authority authority)
+    {
+        Result<Authority> result=new Result<>();
+        //存储前应查询是否有重复的路由
+        try {
+            if(authRepository.existsByName(authority.getName()))
+            {
+                result.setSuccess(false);
+                result.setInfo("此权限名称已经存在!!!");
+                return result;
+            }
+            if(authRepository.existsByApiUrlAndMethod(authority.getApiUrl(),authority.getMethod()))
+            {
+                result.setSuccess(false);
+                result.setInfo("此权限已经存在!!!");
+                return result;
+            }
+            authority= authRepository.save(authority);
+            result.setData(authority);
+            result.setSuccess(true);
+        }
+        catch (Exception ex)
+        {
+            ex.printStackTrace();
+            result.setInfo("未知错误!!!");
+            result.setSuccess(false);
+
+        }
+        return  result;
+    }
+
+    /***
+     * 通过id删除权限
+     * @param id
+     * @return
+     */
+    public Result<Authority> deleteById(int id)
+    {
+        Result<Authority> result=new Result<>();
+        try {
+            if(authRepository.existsById(id))
+            {
+                //删除权限时 需要将关联的外键置空
+                Authority authority=authRepository.findById(id);
+                logger.info(authority.getName()+"'s roles:"+objectMapper.writeValueAsString(authority.getSysRoles()));
+
+                for(SysRole sysRole:authority.getSysRoles())
+                {
+                    sysRole.getAuthorities().remove(authority);
+
+                    sysRoleRepository.save(sysRole);
+                }
+
+                authority.setSysRoles(null);
+                authRepository.save(authority);
+                authRepository.deleteById(id);
+                result.setSuccess(true);
+
+            }
+            else {
+                result.setInfo("不存在此权限!!!");
+                result.setSuccess(false);
+                return result;
+            }
+        }
+        catch (Exception ex ){
+            ex.printStackTrace();
+            result.setInfo("未知错误!!!");
+            result.setSuccess(false);
+        }
+        return  result;
+    }
+
+    /***
+     *更新权限信息
+     * @param authority
+     * @return
+     */
+    public Result<Authority> update(Authority authority){
+        Result<Authority> result=new Result<>();
+        try {
+            if(authRepository.existsById(authority.getId()))
+            {
+                authority=authRepository.save(authority);
+                result.setSuccess(true);
+                result.setData(authority);
+            }
+            else {
+                result.setInfo("不存在此权限!!!");
+                result.setSuccess(false);
+                return result;
+            }
+        }
+        catch (Exception ex ){
+            ex.printStackTrace();
+            result.setInfo("未知错误!!!");
+            result.setSuccess(false);
+        }
+        return result;
+    }
+}

+ 248 - 0
src/main/java/com/lstznkj/groundstation/service/DataIntegrateService.java

@@ -0,0 +1,248 @@
+package com.lstznkj.groundstation.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.lstznkj.groundstation.GlobalData;
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.crane.BaseData;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.ThreadMonitorInfo;
+import com.lstznkj.groundstation.mqtt.MqttFactory;
+import com.lstznkj.groundstation.mqtt.MqttManager;
+import com.lstznkj.groundstation.mqtt.MqttProvider;
+import com.lstznkj.groundstation.service.crane.BaseDataService;
+import com.lstznkj.groundstation.service.crane.DataSourceService;
+import com.lstznkj.groundstation.service.crane.DeviceService;
+import com.lstznkj.groundstation.utils.SpringContextUtil;
+import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 数据整合服务,订阅所有天车mqtt 主题并存储
+ */
+
+@Service
+public class DataIntegrateService {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private DataSourceService dataSourceService;
+    private boolean isRunningCollectThreads;
+//    @Autowired
+//    private BaseDataService baseDataService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    private ExecutorService suscribeThreadPool;
+
+    private ExecutorService dataSaveThreadPool;
+
+
+
+    @PostConstruct
+    public void init(){
+        dataSaveThreadPool= Executors.newCachedThreadPool();
+    }
+
+    /**
+     * 启动 数据采集线程,每台天车 启动一个采集线程
+     *
+     */
+    public void startDataCollectThreads(){
+        int threadCount=deviceService.getRootDevices().getData().size();
+        logger.info("thread pool size :"+threadCount);
+        if(threadCount==0){
+            logger.info("root devices is 0,stop to collect data");
+            return;
+        }
+        this.suscribeThreadPool = Executors.newFixedThreadPool(threadCount);
+
+        Result<List<Device>> rootDeviceList=deviceService.getRootDevices();
+
+        //start to create threadMonitor info
+
+
+        if(rootDeviceList.isSuccess()){
+            for(Device root:rootDeviceList.getData()){
+                //start to create threadMonitor info
+                ThreadMonitorInfo threadMonitorInfo=new ThreadMonitorInfo();
+                threadMonitorInfo.setRunable(true);
+                threadMonitorInfo.setRunTime(0);
+                GlobalData.threadMonitorInfoList.add(threadMonitorInfo);
+                //end create threadMonitor info
+                Thread thread=new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+
+
+                        logger.info("device id "+root.getId());
+                        String mqttURL="tcp://"+root.getExtra()+":1883";
+                        logger.info(root.getName()+":"+mqttURL+" start to collect data");
+                        MqttProvider provider=MqttFactory.createMqttProvider("admin","123456",mqttURL,root.getExtra());
+
+
+                        MqttClient client=provider.getClient();
+                       // MqttClient client= MqttFactory.createInstance("admin","123456",mqttURL,root.getExtra());
+
+
+                        logger.info(root.getName()+" mqtt client connected");
+                        Result<List<DataSource>> dataSourceList=null;
+                        try {
+                           dataSourceList=dataSourceService.getAllDataSources(root.getId());
+
+                           logger.info("dataSourceList:"+objectMapper.writeValueAsString(dataSourceList));
+
+                            provider.setDataSourceList(dataSourceList.getData());
+
+                            //inster to MqttManager list
+                            MqttManager.addMqttProvider(provider);
+
+                            provider.subscribeDataSource();
+
+
+                   /*         for(DataSource dataSource:dataSourceList.getData()){
+
+                                client.subscribe(dataSource.getPublishTopic(), new IMqttMessageListener() {
+                                    @Override
+                                    public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
+
+
+                                        Thread tmpThread=new Thread(new Runnable() {
+
+                                            private BaseDataService baseDataService= SpringContextUtil.getBean(BaseDataService.class);
+                                            @Override
+                                            public void run() {
+                                                try {
+                                                    BaseData baseData=new BaseData();
+                                                    JsonNode mqttNode=objectMapper.readTree(mqttMessage.toString());
+                                                    baseData.setName(mqttNode.get("name").asText());
+                                                    baseData.setValue(mqttNode.get("value").asDouble());
+                                                    baseData.setOriginValue(mqttNode.get("originValue").asInt());
+                                                    baseData.setCollectTime(mqttNode.get("createTime").asLong());
+                                                    baseData=baseDataService.add(baseData).getData();
+                                                    baseData.setDataSource(dataSource);
+                                                    baseData=baseDataService.add(baseData).getData();
+                                                    logger.info("baseData:"+objectMapper.writeValueAsString(baseData));
+                                                }
+                                                catch (Exception ex){
+                                                    logger.error("base data save to database error :"+ex.getMessage());
+                                                    ex.printStackTrace();
+                                                }
+
+                                            }
+                                        });
+                                        dataSaveThreadPool.submit(tmpThread);
+
+
+
+//                                           BaseData baseData=objectMapper.readValue(mqttMessage.toString(),BaseData.class);
+//                                           logger.info("subscribe: "+s+"; "+objectMapper.writeValueAsString(baseData));
+
+                                        logger.info("topic:"+s+": "+mqttMessage.toString());
+                                    }
+                                });
+                            }
+*/
+                        }
+                        catch (Exception ex){
+                            logger.error(ex.getMessage());
+                        }
+
+
+
+                  /*      while (threadMonitorInfo.isRunable()){
+                            threadMonitorInfo.setRunTime(threadMonitorInfo.getRunTime()+1);
+                           try {
+                               if(dataSourceList==null){
+                               }
+                               for(DataSource dataSource:dataSourceList.getData()){
+
+                                   client.subscribe(dataSource.getPublishTopic(), new IMqttMessageListener() {
+                                       @Override
+                                       public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
+
+
+                                           Thread tmpThread=new Thread(new Runnable() {
+
+                                               private BaseDataService baseDataService= SpringContextUtil.getBean(BaseDataService.class);
+                                               @Override
+                                               public void run() {
+                                                   try {
+                                                       BaseData baseData=new BaseData();
+                                                       JsonNode mqttNode=objectMapper.readTree(mqttMessage.toString());
+                                                       baseData.setName(mqttNode.get("name").asText());
+                                                       baseData.setValue(mqttNode.get("value").asDouble());
+                                                       baseData.setOriginValue(mqttNode.get("originValue").asInt());
+                                                       baseData.setCollectTime(mqttNode.get("createTime").asLong());
+                                                       baseData=baseDataService.add(baseData).getData();
+                                                       baseData.setDataSource(dataSource);
+                                                       baseData=baseDataService.add(baseData).getData();
+                                                       logger.info("baseData:"+objectMapper.writeValueAsString(baseData));
+                                                   }
+                                                   catch (Exception ex){
+                                                       logger.error("base data save to database error :"+ex.getMessage());
+                                                       ex.printStackTrace();
+                                                   }
+
+                                               }
+                                           });
+                                           dataSaveThreadPool.submit(tmpThread);
+
+
+
+//                                           BaseData baseData=objectMapper.readValue(mqttMessage.toString(),BaseData.class);
+//                                           logger.info("subscribe: "+s+"; "+objectMapper.writeValueAsString(baseData));
+
+                                           logger.info("topic:"+s+": "+mqttMessage.toString());
+                                       }
+                                   });
+                               }
+
+                           }
+                           catch (Exception ex){
+                               logger.error(root.getExtra()+" mqttServer  connected!!! error!"+ex.getMessage());
+//                               logger.error("start to reconnect to "+root.getExtra()+" mqttserver!!!");
+//                               client= MqttFactory.createInstance("admin","123456",mqttURL,String.valueOf(root.getId()));
+//                               logger.info(root.getName()+" mqtt client connected");
+
+                               threadMonitorInfo.setRunable(false);
+                               ex.printStackTrace();
+                           }
+
+
+                        }*/
+                        threadMonitorInfo.setRunable(false);
+                    }
+                });
+                thread.setName(root.getId()+root.getName());
+
+                suscribeThreadPool.submit(thread);
+                logger.info("create data collect thread:"+thread.getName());
+            }
+        }
+    }
+
+    public void stopDataCollectThreads(){
+        try {
+            suscribeThreadPool.shutdown();
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+    }
+
+
+
+}

+ 157 - 0
src/main/java/com/lstznkj/groundstation/service/ImageService.java

@@ -0,0 +1,157 @@
+package com.lstznkj.groundstation.service;
+
+
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.crane.extra.Equipment;
+import com.lstznkj.groundstation.service.crane.extra.EquipmentService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@Service
+public class ImageService {
+    // @Value("${demo.imgPath}")
+    // private String imgPath;
+    @Autowired
+    private EquipmentService equipmentService;
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    public byte[] getImageByUuid(String uuid) {
+        // Result<byte[]> result = new Result<>();
+
+        // FileInputStream imgInputStream;
+        // logger.info("uuid:" + uuid + " start to get image");
+        // try {
+        //     Equipment equipment = equipmentService.findByUuid(uuid);
+        //     if (equipment != null) {
+        //         String path = imgPath + "/" + uuid + ".jpg";
+        //         File imgFile = new File(path);
+        //         if (!imgFile.exists()) {
+        //             path = imgPath + "/" + uuid + ".jpeg";
+        //         }
+        //         if (!imgFile.exists()) {
+        //             path = imgPath + "/" + uuid + ".png";
+        //         }
+
+        //         logger.info("img:" + path);
+
+        //         FileInputStream inputStream = new FileInputStream(path);
+
+        //         byte[] buffer = inputStream.readAllBytes();
+
+        //         inputStream.close();
+
+        //         return buffer;
+
+        //         // result.setData(inputStream.readAllBytes());
+        //         // result.setSuccess(true);
+        //     }
+        // } catch (Exception ex) {
+        //     ex.printStackTrace();
+        //     logger.error("get equipment:" + uuid + " img error:" + ex.getMessage());
+        //     result.setInfo("此设备不存在照片信息");
+        //     result.setSuccess(false);
+        // }
+
+//        return result;
+        return null;
+    }
+
+
+    public void deleteImageByUuid(String uuid) {
+        // FileInputStream imgInputStream;
+        // logger.info("uuid:" + uuid + " start to delete image");
+        // try {
+
+        //     String path = imgPath + "/" + uuid + ".jpg";
+        //     File imgFile = new File(path);
+        //     imgFile.delete();
+
+        // } catch (Exception ex) {
+        //     ex.printStackTrace();
+        // }
+    }
+
+    public Result<String> uploadImage(MultipartFile img, @PathVariable String uuid) {
+        // Result<String> result = new Result<>();
+        // logger.info("已进入图片上传服务");
+        // logger.info("uuid:" + uuid + "start to upload img");
+        // File imgDirPath = new File(imgPath);
+        // logger.info("文件的保存路径:" + imgPath);
+
+
+        // if (!imgDirPath.exists() && !imgDirPath.isDirectory()) {
+        //     logger.info("照片目录不存在,创建目录:" + imgDirPath);
+        //     imgDirPath.mkdir();
+        // }
+        // Equipment equipment = equipmentService.findByUuid(uuid);
+        // if (equipment != null) {
+
+        //     String path = imgPath + "/" + uuid + ".jpg";
+        //     File imgFile = new File(path);
+
+
+        //     //获取原始文件名称(包含格式)
+        //     String originImageFileName = img.getOriginalFilename();
+        //     logger.info("原始文件名称:" + originImageFileName);
+        //     //获取文件类型,以最后一个`.`为标识
+        //     String imgType = originImageFileName.substring(originImageFileName.lastIndexOf(".") + 1);
+        //     //获取文件类型,以最后一个`.`为标识
+        //     logger.info("img文件类型:" + imgType);
+        //     //获取文件名称(不包含格式)
+        //     //String originName = originImageFileName.substring(0, originImageFileName.lastIndexOf("."));
+        //     String imgSaveName = equipment.getUuid() + "." + imgType;
+        //     logger.info("新文件名称:" + imgSaveName);
+        //     //在指定路径下创建一个文件
+        //     File imgTargetFile = new File(imgPath, imgSaveName);
+
+        //     logger.info("图片地址:" + imgPath + "/" + imgSaveName);
+        //     //将文件保存到服务器指定位置
+        //     try {
+        //         int imgSize, resumeSize;
+        //         imgSize = img.getBytes().length / 1024;
+        //         logger.info(" img file size:" + imgSize);
+        //         if (imgTargetFile.exists()) {
+        //             logger.info(uuid + " img  is  existed,start to delete!");
+        //             imgTargetFile.delete();
+        //             if (!imgTargetFile.exists()) {
+        //                 logger.info(uuid + " img deleted success!!!");
+        //             } else {
+        //                 logger.error(uuid + " img deleted failed!!!");
+        //             }
+        //         }
+        //         img.transferTo(imgTargetFile);
+
+
+        //         logger.info("上传成功");
+
+        //         result.setSuccess(true);
+
+        //     } catch (IOException e) {
+
+        //         if (!imgFile.exists()) {
+        //             logger.error("上传失败,开始删除之前添加的设备信息");
+        //             equipmentService.deleteByUuid(uuid);
+        //         }
+
+        //         e.printStackTrace();
+        //         result.setSuccess(false);
+
+        //     }
+        // } else {
+        //     result.setInfo("uuid error!!!");
+        //     logger.error("uuid error!!!");
+        //     result.setSuccess(false);
+        // }
+        return null;
+
+    }
+}

+ 431 - 0
src/main/java/com/lstznkj/groundstation/service/InitService.java

@@ -0,0 +1,431 @@
+package com.lstznkj.groundstation.service;
+
+import com.lstznkj.groundstation.model.Authority;
+import com.lstznkj.groundstation.model.SysRole;
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.model.crane.DataType;
+import com.lstznkj.groundstation.model.crane.Device;
+import com.lstznkj.groundstation.model.crane.DataSource;
+import com.lstznkj.groundstation.model.crane.State;
+import com.lstznkj.groundstation.repo.AuthorityRepository;
+import com.lstznkj.groundstation.repo.SysRoleRepository;
+import com.lstznkj.groundstation.repo.UserRepository;
+import com.lstznkj.groundstation.repo.crane.DataTypeRepository;
+import com.lstznkj.groundstation.repo.crane.DeviceRepository;
+import com.lstznkj.groundstation.repo.crane.DataSourceRepository;
+import com.lstznkj.groundstation.repo.crane.StateRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/***
+ * 系统用户 角色 权限 初始化
+ */
+@Service
+public class InitService {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private AuthorityRepository authorityRepository;
+    @Autowired
+    private BCryptPasswordEncoder passwordEncoder;
+    @Autowired
+    private SysRoleRepository sysRoleRepository;
+    @Autowired
+    private UserRepository userRepository;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private SysRoleService sysRoleService;
+
+    @Autowired
+    private DeviceRepository deviceRepository;
+    @Autowired
+    private DataSourceRepository dataSourceRepository;
+    @Autowired
+    private DataTypeRepository dataTypeRepository;
+    @Autowired
+    private StateRepository stateRepository;
+
+    public void init(){
+        initState();
+        initDataTypes();
+        initAuthorities();
+        initSysRoles();
+        initUsers();
+
+//       initTestCraneData1();
+      // initTestCraneData2();
+    }
+    public void initTestCraneData1(){
+        Device crane =new Device();
+        crane.setName("1#天车");
+        crane.setExtra("192.168.56.105");
+        crane.setLevel(0);
+
+        crane=deviceRepository.save(crane);
+
+        Device bigCar=new Device();
+        bigCar.setName("大车");
+        bigCar.setLevel(1);
+        bigCar.setFather(crane);
+        bigCar=deviceRepository.save(bigCar);
+
+        //deviceRepository.save(bigCar);
+        Device motor=new Device();
+        motor.setName("1#电机");
+        motor.setFather(bigCar);
+        motor.setLevel(motor.getFather().getLevel()+1);
+
+
+
+
+        motor= deviceRepository.save(motor);
+
+
+        Device motor1=new Device();
+        motor1.setName("2#电机");
+
+
+
+        motor1=deviceRepository.save(motor1);
+        motor1.setFather(motor.getFather());
+        motor1.setLevel(motor1.getFather().getLevel()+1);
+        motor1=deviceRepository.save(motor1);
+
+        List<Device> devices=new ArrayList<>();
+        devices.add(bigCar);
+
+        DataSource shockDataSource=new DataSource();
+        shockDataSource.setName("振动");
+        shockDataSource.setAddress("485/127.0.0.1/1/0");
+        shockDataSource.setPublishTopic("shock1");
+        shockDataSource.setEnable(true);
+        shockDataSource= dataSourceRepository.save(shockDataSource);
+
+        shockDataSource.setDevice(motor1);
+        shockDataSource.setDataType(dataTypeRepository.findByName("振动"));
+
+        shockDataSource= dataSourceRepository.save(shockDataSource);
+
+
+
+
+       // craneRepository.save(crane);
+
+    }
+
+    public void initTestCraneData2(){
+        Device crane =new Device();
+        crane.setName("2#天车");
+        crane.setExtra("192.168.56.105");
+        crane.setLevel(0);
+
+        crane=deviceRepository.save(crane);
+
+        Device bigCar=new Device();
+        bigCar.setName("大车");
+        bigCar.setLevel(1);
+        bigCar.setFather(crane);
+        bigCar=deviceRepository.save(bigCar);
+
+        //deviceRepository.save(bigCar);
+        Device motor=new Device();
+        motor.setName("1#电机");
+        motor.setFather(bigCar);
+        motor.setLevel(motor.getFather().getLevel()+1);
+
+
+
+
+        motor= deviceRepository.save(motor);
+
+
+        Device motor1=new Device();
+        motor1.setName("2#电机");
+
+
+
+        motor1=deviceRepository.save(motor1);
+        motor1.setFather(motor.getFather());
+        motor1.setLevel(motor1.getFather().getLevel()+1);
+        motor1=deviceRepository.save(motor1);
+
+        List<Device> devices=new ArrayList<>();
+        devices.add(bigCar);
+
+        DataSource shockDataSource=new DataSource();
+        shockDataSource.setName("振动");
+        shockDataSource.setAddress("485/127.0.0.1/1/0");
+        shockDataSource.setPublishTopic("shock222");
+        shockDataSource.setEnable(true);
+        shockDataSource= dataSourceRepository.save(shockDataSource);
+
+        shockDataSource.setDevice(motor1);
+        shockDataSource.setDataType(dataTypeRepository.findByName("振动"));
+
+        shockDataSource= dataSourceRepository.save(shockDataSource);
+
+
+
+
+       // craneRepository.save(crane);
+
+    }
+
+    public void initState(){
+        State normalState=new State();
+        //预警
+        State warningState =new State();
+        //报警
+        State alertState =new State();
+        //损坏 故障
+        State brokenState =new State();
+
+        normalState.setName("正常");
+        warningState.setName("预警");
+        alertState.setName("报警");
+        brokenState.setName("故障");
+
+        if(!stateRepository.existsByName("正常")){
+            stateRepository.save(normalState);
+        }
+        if(!stateRepository.existsByName("预警")){
+            stateRepository.save(warningState);
+        }
+        if(!stateRepository.existsByName("报警")){
+            stateRepository.save(alertState);
+        }
+        if(!stateRepository.existsByName("故障")){
+            stateRepository.save(brokenState);
+        }
+
+
+    }
+
+    public void initAuthorities(){
+
+        if(authorityRepository.findAll().size()==0){
+            initUltimateAuthority();
+            initRoleAuthority();
+            initUserAuthority();
+        }
+
+
+    }
+    public void initDataTypes(){
+        if(dataTypeRepository.findAll().size()==0){
+            DataType shockType=new DataType();
+            shockType.setName("振动");
+            shockType.setMethod(0);
+            shockType.setValueType(0);
+            shockType.setRemark("振动模拟量,4-20mA");
+            shockType.setExpression("16/3276*x/16*20");;
+
+            DataType tempratureType=new DataType();
+            tempratureType.setName("温度");
+            tempratureType.setMethod(0);
+            tempratureType.setValueType(0);
+            tempratureType.setRemark("温度模拟量.4-20mA");
+            tempratureType.setExpression("16/3276*x/16*200-50");
+
+            dataTypeRepository.save(shockType);
+            dataTypeRepository.save(tempratureType);
+        }
+
+
+    }
+    private void initUltimateAuthority(){
+        //后端超级管理员权限 ,操作/下所有资源
+        Authority ultimateAuth=new Authority();
+        ultimateAuth.setApiUrl("/**");
+        ultimateAuth.setName("超级管理员");
+        ultimateAuth.setMethod("ALL");
+        if(!authorityRepository.existsByName("超级管理员")){
+            authorityRepository.save(ultimateAuth);
+        }
+    }
+    private void initRoleAuthority(){
+        //后端添加角色权限
+        Authority roleAuthAdd=new Authority();
+        //后端删除角色权限
+        Authority roleAuthDel=new Authority();
+        //后端修改角色权限
+        Authority roleAuthUpd=new Authority();
+        //后端查看角色权限
+        Authority roleAuthGet=new Authority();
+
+        roleAuthGet.setApiUrl("/roles/**");
+        roleAuthDel.setApiUrl("/roles/**");
+        roleAuthUpd.setApiUrl("/roles/**");
+        roleAuthAdd.setApiUrl("/roles/**");
+
+        roleAuthAdd.setMethod("POST");
+        roleAuthUpd.setMethod("PUT");
+        roleAuthDel.setMethod("DELETE");
+        roleAuthGet.setMethod("GET");
+
+        roleAuthAdd.setName("添加角色");
+        roleAuthDel.setName("删除角色");
+        roleAuthGet.setName("查看角色");
+        roleAuthUpd.setName("修改角色");
+
+        if(!authorityRepository.existsByName("添加角色")){
+            authorityRepository.save(roleAuthAdd);
+        }
+        if(!authorityRepository.existsByName("查看角色")){
+            authorityRepository.save(roleAuthGet);
+        }
+        if(!authorityRepository.existsByName("修改角色")){
+            authorityRepository.save(roleAuthUpd);
+        }
+        if(!authorityRepository.existsByName("删除角色")){
+            authorityRepository.save(roleAuthDel);
+        }
+    }
+
+    /**
+     * 获取用户信息权限,登录后 获取自身信息,
+     * UserController 里 根据token识别,是否是获取自身的用户信息
+     */
+    private void initUserAuthority(){
+        //获取用户信息权限
+        Authority userInfoAuth=new Authority();
+
+        userInfoAuth.setApiUrl("/users/**");
+        userInfoAuth.setName("获取用户信息");
+        userInfoAuth.setMethod("GET");
+        if(!authorityRepository.existsByName("获取用户信息")){
+            authorityRepository.save(userInfoAuth);
+        }
+        else {
+            logger.info("获取用户信息权限已经存在!!!");
+        }
+
+
+    }
+    public void initSysRoles(){
+
+        initUserRole();
+
+
+        initAdminRole();
+
+
+        initUltimateRole();
+
+
+    }
+
+    private void initUserRole() {
+        //普同用户
+        SysRole userSysRole=new SysRole();
+
+
+        userSysRole.setName("ROLE_USER");
+        userSysRole.setDescription("普通用户");
+
+        //获取用户信息权限
+        Authority userInfoAuth=authorityRepository.findAuthorityByName("获取用户信息");
+
+        if(!sysRoleRepository.existsSysRoleByName("ROLE_USER")){
+            userSysRole=sysRoleRepository.save(userSysRole);
+            userSysRole.getAuthorities().add(userInfoAuth);
+            sysRoleRepository.save(userSysRole);
+
+//            userInfoAuth.getSysRoles().add(userSysRole);
+//            authorityRepository.save(userInfoAuth);
+        }
+        else {
+            logger.info("普通用户角色已经创建!!!");
+        }
+    }
+
+    private void initAdminRole() {
+        //管理员
+        SysRole adminSysRole=new SysRole();
+
+        adminSysRole.setName("ROLE_ADMIN");
+        adminSysRole.setDescription("管理员");
+
+        //获取用户信息权限
+        Authority userInfoAuth=authorityRepository.findAuthorityByName("获取用户信息");
+
+        //查看、添加、删除、修改 角色-权限
+        List<Authority> roleAuthorityList= authorityRepository.findAuthoritiesByApiUrl("/roles/**");
+
+
+        //**********为管理员添加 查看、添加、删除、修改角色的权限********************
+        if(!sysRoleRepository.existsSysRoleByName("ROLE_ADMIN")){
+
+            adminSysRole= sysRoleRepository.save(adminSysRole);
+            adminSysRole.setAuthorities(roleAuthorityList);
+            adminSysRole= sysRoleRepository.save(adminSysRole);
+
+
+            userInfoAuth.getSysRoles().add(adminSysRole);
+            authorityRepository.save(userInfoAuth);
+            adminSysRole.getAuthorities().add(userInfoAuth);
+            adminSysRole= sysRoleRepository.save(adminSysRole);
+
+
+            for(Authority authority:roleAuthorityList){
+                authority.getSysRoles().add(adminSysRole);
+                authorityRepository.save(authority);
+            }
+
+        }
+        else {
+            logger.info("管理员角色已经创建!!!");
+        }
+        //end**********为管理员添加 查看、添加、删除、修改角色的权限********************
+    }
+
+    /***
+     * 初始化超级管理员角色
+     *
+     */
+
+    private void initUltimateRole() {
+        //超级管理员权限
+        Authority ultimateAuth=authorityRepository.findAuthorityByName("超级管理员");
+
+        //终极管理员,拥有修改删除所有信息权限
+        SysRole ultimateSysRole=new SysRole();
+        ultimateSysRole.setName(("ROLE_ULTIMATE"));
+        ultimateSysRole.setDescription("超级管理员");
+
+        //************创建超级管理员角色*************************************
+        if(!sysRoleRepository.existsSysRoleByName("ROLE_ULTIMATE")){
+            ultimateSysRole=sysRoleRepository.save(ultimateSysRole);
+            ultimateAuth.getSysRoles().add(ultimateSysRole);
+            authorityRepository.save(ultimateAuth);
+
+            ultimateSysRole.getAuthorities().add(ultimateAuth);
+
+            sysRoleRepository.save(ultimateSysRole);
+        }
+        else {
+            logger.info("超级管理员角色已经创建!!!");
+        }
+        //end ************创建超级管理员角色*************************************
+    }
+
+    public void initUsers( ){
+
+        // sys_role_users 表中 存在重复数据 ,待修复!!!!
+
+        User adminUlt=new User();
+        adminUlt.setName("ultimate");
+        adminUlt.setUsername("adminult");
+        adminUlt.setPassword(passwordEncoder.encode("123456"));
+
+        SysRole adminSysRole = sysRoleService.getUltimateSysRole();
+
+        userService.createUser(adminUlt,adminSysRole);
+    }
+}

+ 156 - 0
src/main/java/com/lstznkj/groundstation/service/SysRoleService.java

@@ -0,0 +1,156 @@
+package com.lstznkj.groundstation.service;
+
+import com.lstznkj.groundstation.model.Authority;
+import com.lstznkj.groundstation.model.Result;
+import com.lstznkj.groundstation.model.SysRole;
+import com.lstznkj.groundstation.model.User;
+import com.lstznkj.groundstation.repo.AuthorityRepository;
+import com.lstznkj.groundstation.repo.SysRoleRepository;
+import com.lstznkj.groundstation.repo.UserRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class SysRoleService {
+    @Autowired
+    private SysRoleRepository sysRoleRepository;
+    @Autowired
+    AuthorityRepository authorityRepository;
+    @Autowired
+    UserRepository userRepository;
+
+    private Logger logger= LoggerFactory.getLogger(SysRoleService.class);
+
+    /**
+     * 查找所有角色
+     * @return
+     */
+    public Result<Iterable<SysRole>> findAll()
+    {
+        Result<Iterable<SysRole>> result=new Result<>();
+        try {
+            result.setData(sysRoleRepository.findAll());
+            result.setSuccess(true);
+        }
+        catch (Exception ex)
+        {
+            result.setSuccess(false);
+            ex.printStackTrace();
+        }
+        return result;
+    }
+    public SysRole findSysRoleByName(String name)
+    {
+        return sysRoleRepository.findSysRoleByName(name);
+    }
+
+
+    public SysRole getAdminSysRole()
+    {
+        return sysRoleRepository.findSysRoleByName("ROLE_ADMIN");
+    }
+    public SysRole getUltimateSysRole()
+    {
+        return sysRoleRepository.findSysRoleByName("ROLE_ULTIMATE");
+    }
+    public SysRole getBudgetSysRole()
+    {
+        return sysRoleRepository.findSysRoleByName("ROLE_BUDGET");
+    }
+
+
+
+    public Result<SysRole> deleteById(int id)
+    {
+        Result<SysRole> result=new Result<>();
+        try {
+            if(sysRoleRepository.existsById(id)){
+                SysRole role=sysRoleRepository.findSysRoleById(id);
+                for(Authority auth : role.getAuthorities())
+                {
+                    auth.getSysRoles().remove(role);
+                    authorityRepository.save(auth);
+                }
+                for(User user:role.getUsers()){
+                    user.getSysRoles().remove(role);
+                    userRepository.save(user);
+                }
+                role.setUsers(null);
+                role.setAuthorities(null);
+                sysRoleRepository.save(role);
+                sysRoleRepository.deleteById(id);
+                result.setSuccess(true);
+            }
+            else {
+                result.setSuccess(false);
+                result.setInfo("不存在此角色");
+            }
+        }catch (Exception ex){
+            ex.printStackTrace();
+            result.setSuccess(false);
+            result.setInfo("未知错误!!!");
+        }
+        return result;
+    }
+
+    public Result<SysRole> save(SysRole sysRole)
+    {
+        Result<SysRole> result=new Result<>();
+        try {
+            if(sysRoleRepository.existsSysRoleByName(sysRole.getName()))
+            {
+                result.setSuccess(false);
+                result.setInfo("已经存在此名称的角色!!!");
+                return result;
+            }
+            if(sysRoleRepository.save(sysRole)!=null) {
+                result.setSuccess(true);
+                return result;
+            }
+            else {
+                result.setSuccess(false);
+                result.setInfo("未知错误!!!");
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setInfo("未知错误!!!");
+            return result;
+        }
+    }
+
+    public Result<SysRole> update(SysRole sysRole)
+    {
+        Result<SysRole> result=new Result<>();
+
+        try {
+            if(sysRoleRepository.existsById(sysRole.getId()))
+            {
+                SysRole oldRole=sysRoleRepository.findSysRoleById(sysRole.getId());
+                oldRole.setDescription(sysRole.getDescription());
+                oldRole.setAuthorities(sysRole.getAuthorities());
+                oldRole.setName(sysRole.getName());
+
+                oldRole=sysRoleRepository.save(oldRole);
+                result.setData(oldRole);
+                result.setSuccess(true);
+            }else {
+                result.setSuccess(false);
+                result.setInfo("不存在此角色");
+            }
+
+        }catch (Exception ex)
+        {
+            ex.printStackTrace();
+            result.setSuccess(false);
+            result.setInfo("未知错误!!!");
+        }
+        return result;
+    }
+}

+ 68 - 0
src/main/java/com/lstznkj/groundstation/service/TestService.java

@@ -0,0 +1,68 @@
+package com.lstznkj.groundstation.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestService {
+    private Logger logger= LoggerFactory.getLogger(getClass());
+    private List<String> stringList=new ArrayList<>();
+    public void tryGroup(){
+
+        stringList.add("A");
+        stringList.add("B");
+//        stringList.add("C");
+//        stringList.add("A");
+//        stringList.add("C");
+//        stringList.add("C");
+//        stringList.add("C");
+//        stringList.add("B");
+//        stringList.add("C");
+//        stringList.add("A");
+//        stringList.add("B");
+//        stringList.add("B");
+
+        List<List<String>> group=new ArrayList<>();
+        for(int i=0;i<=stringList.size();++i){
+            List<String> list=new ArrayList<>();
+            String s=stringList.get(0);
+            list.add(s);
+            for(int j=1;j<stringList.size();++j){
+                if(s.equals(stringList.get(j))){
+                    list.add(stringList.get(j));
+                }
+            }
+            try {
+                logger.info("list:"+new ObjectMapper().writeValueAsString(list));
+
+            }
+            catch (Exception ex){
+                ex.printStackTrace();
+            }
+            group.add(list);
+            for(int k=0;k<list.size();++k){
+                logger.info("start to remove :"+list.get(k));
+                stringList.remove(list.get(k));
+
+            }
+            try {
+                logger.info("after remove:i:"+i+","+new ObjectMapper().writeValueAsString(stringList));
+
+            }
+            catch (Exception ex){
+                ex.printStackTrace();
+            }
+
+
+        }
+        try {
+            logger.info("group:"+new ObjectMapper().writeValueAsString(group));
+        }
+        catch (Exception ex){
+            ex.printStackTrace();
+        }
+    }
+}

部分文件因为文件数量过多而无法显示