zhanghaijun лет назад: 2
Родитель
Сommit
945a1e4053
92 измененных файлов с 0 добавлено и 3804 удалено
  1. 0 68
      train-demo/README.md
  2. 0 83
      train-demo/pom.xml
  3. 0 57
      train-demo/src/assembly/assembly.xml
  4. 0 33
      train-demo/src/assembly/bin/date.bat
  5. 0 3
      train-demo/src/assembly/bin/msgbox.vbs
  6. 0 12
      train-demo/src/assembly/bin/run.bat
  7. 0 34
      train-demo/src/assembly/bin/start-dev.bat
  8. 0 33
      train-demo/src/assembly/bin/start.bat
  9. 0 35
      train-demo/src/assembly/bin/start.sh
  10. 0 25
      train-demo/src/assembly/bin/stop.bat
  11. 0 178
      train-demo/src/assembly/bin/wait-for-it.sh
  12. 0 16
      train-demo/src/main/java/top/haijunit/train/TrainDemoMain.java
  13. 0 18
      train-demo/src/main/java/top/haijunit/train/config/WebSocketConfig.java
  14. 0 34
      train-demo/src/main/java/top/haijunit/train/config/properties/RedisProperties.java
  15. 0 22
      train-demo/src/main/java/top/haijunit/train/config/properties/TrainProperties.java
  16. 0 36
      train-demo/src/main/java/top/haijunit/train/controller/DemoController.java
  17. 0 32
      train-demo/src/main/java/top/haijunit/train/controller/TrainController.java
  18. 0 30
      train-demo/src/main/java/top/haijunit/train/controller/WebSocketController.java
  19. 0 74
      train-demo/src/main/java/top/haijunit/train/domain/SignEntity.java
  20. 0 38
      train-demo/src/main/java/top/haijunit/train/domain/SignEnum.java
  21. 0 37
      train-demo/src/main/java/top/haijunit/train/domain/StatusEnum.java
  22. 0 28
      train-demo/src/main/java/top/haijunit/train/domain/UserEntity.java
  23. 0 37
      train-demo/src/main/java/top/haijunit/train/domain/UserStatusEnum.java
  24. 0 37
      train-demo/src/main/java/top/haijunit/train/domain/constant/ButtonStopStatus.java
  25. 0 40
      train-demo/src/main/java/top/haijunit/train/domain/constant/DirectionEnum.java
  26. 0 37
      train-demo/src/main/java/top/haijunit/train/domain/constant/RouteStatus.java
  27. 0 38
      train-demo/src/main/java/top/haijunit/train/domain/constant/SelectionStatus.java
  28. 0 38
      train-demo/src/main/java/top/haijunit/train/domain/constant/SignalStatus.java
  29. 0 37
      train-demo/src/main/java/top/haijunit/train/domain/constant/StationDoorStatus.java
  30. 0 38
      train-demo/src/main/java/top/haijunit/train/domain/constant/SwitchStatus.java
  31. 0 20
      train-demo/src/main/java/top/haijunit/train/domain/constant/TrainConstant.java
  32. 0 20
      train-demo/src/main/java/top/haijunit/train/domain/dto/PlatformDto.java
  33. 0 33
      train-demo/src/main/java/top/haijunit/train/domain/dto/RouteDto.java
  34. 0 20
      train-demo/src/main/java/top/haijunit/train/domain/dto/TrainDto.java
  35. 0 21
      train-demo/src/main/java/top/haijunit/train/domain/dto/TravelDto.java
  36. 0 23
      train-demo/src/main/java/top/haijunit/train/domain/entity/EmergencyStopEntity.java
  37. 0 24
      train-demo/src/main/java/top/haijunit/train/domain/entity/PlatformEntity.java
  38. 0 34
      train-demo/src/main/java/top/haijunit/train/domain/entity/RouteEntity.java
  39. 0 34
      train-demo/src/main/java/top/haijunit/train/domain/entity/SelectionEntity.java
  40. 0 26
      train-demo/src/main/java/top/haijunit/train/domain/entity/SignStopEntity.java
  41. 0 30
      train-demo/src/main/java/top/haijunit/train/domain/entity/SignalEntity.java
  42. 0 22
      train-demo/src/main/java/top/haijunit/train/domain/entity/StationDoorEntity.java
  43. 0 20
      train-demo/src/main/java/top/haijunit/train/domain/entity/StationEntity.java
  44. 0 32
      train-demo/src/main/java/top/haijunit/train/domain/entity/SwitchEntity.java
  45. 0 27
      train-demo/src/main/java/top/haijunit/train/domain/entity/TrainEntity.java
  46. 0 16
      train-demo/src/main/java/top/haijunit/train/domain/mapper/EmergencyStopMapper.java
  47. 0 14
      train-demo/src/main/java/top/haijunit/train/domain/mapper/PlatformMapper.java
  48. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/RouteMapper.java
  49. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/SelectionMapper.java
  50. 0 14
      train-demo/src/main/java/top/haijunit/train/domain/mapper/SignStopMapper.java
  51. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/SignalMapper.java
  52. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/StationDoorMapper.java
  53. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/StationMapper.java
  54. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/SwitchMapper.java
  55. 0 15
      train-demo/src/main/java/top/haijunit/train/domain/mapper/TrainMapper.java
  56. 0 15
      train-demo/src/main/java/top/haijunit/train/mapper/SignMapper.java
  57. 0 15
      train-demo/src/main/java/top/haijunit/train/mapper/UserMapper.java
  58. 0 36
      train-demo/src/main/java/top/haijunit/train/service/RouteService.java
  59. 0 27
      train-demo/src/main/java/top/haijunit/train/service/TrainApplication.java
  60. 0 32
      train-demo/src/main/java/top/haijunit/train/service/UserService.java
  61. 0 39
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/TrainGlobalHolder.java
  62. 0 152
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/TrainTravel.java
  63. 0 31
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainDate.java
  64. 0 20
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainDateStatus.java
  65. 0 42
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainRoute.java
  66. 0 50
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/service/RouteService.java
  67. 0 42
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/train.txt
  68. 0 19
      train-demo/src/main/java/top/haijunit/train/service/simulation/train/utils/RouteUtil.java
  69. 0 48
      train-demo/src/main/java/top/haijunit/train/utils/CalculateUtil.java
  70. 0 487
      train-demo/src/main/java/top/haijunit/train/utils/RedisManage.java
  71. 0 165
      train-demo/src/main/java/top/haijunit/train/websocket/WebSocketServer.java
  72. 0 71
      train-demo/src/main/resources/application-demo.yml
  73. 0 97
      train-demo/src/main/resources/application.yml
  74. 0 210
      train-demo/src/main/resources/db/changelog/db-server-train-1.xml
  75. 0 55
      train-demo/src/main/resources/db/changelog/db-server-train.xml
  76. 0 52
      train-demo/src/main/resources/db/changelog/db-server.xml
  77. 0 17
      train-demo/src/main/resources/db/changelog/db_sign.txt
  78. 0 2
      train-demo/src/main/resources/db/changelog/信号灯-signal.txt
  79. 0 3
      train-demo/src/main/resources/db/changelog/停车标-stopSign.txt
  80. 0 2
      train-demo/src/main/resources/db/changelog/列车-train.txt
  81. 0 3
      train-demo/src/main/resources/db/changelog/区段-selection.txt
  82. 0 2
      train-demo/src/main/resources/db/changelog/站台-platform.txt
  83. 0 2
      train-demo/src/main/resources/db/changelog/站台门-stationDoor.txt
  84. 0 3
      train-demo/src/main/resources/db/changelog/紧急停车按钮-emergencyStop.txt
  85. 0 2
      train-demo/src/main/resources/db/changelog/车站-station.txt
  86. 0 3
      train-demo/src/main/resources/db/changelog/进路-route.txt
  87. 0 2
      train-demo/src/main/resources/db/changelog/道岔-switch.txt
  88. 0 106
      train-demo/src/main/resources/logback.xml
  89. 0 10
      train-demo/src/main/resources/static/index.html
  90. 0 75
      train-demo/src/main/resources/templates/webSocket.html
  91. 0 13
      train-demo/src/test/java/top/haijunit/train/TrainDemoMainTests.java
  92. 0 91
      train-demo/src/test/java/top/haijunit/train/mapper/UserMapperTest.java

+ 0 - 68
train-demo/README.md

@@ -1,68 +0,0 @@
-## 硬件设备
-- 信号灯 signal
-    - 编号 id
-    - 名称 name
-    - 公里标 kilometer
-    - 状态:红、绿、黄、红黄 colorState
-    - 区段号 selectionId
-    - 类型:上行、下行 direction
-    - 车站编号 stationId
-- 道岔 switch
-    - 编号 id
-    - 名称 name
-    - 公里标 kilometer
-    - 类型 type
-    - 岔前区段号 preSelectionId
-    - 岔后区段号 nextSelectionId
-    - 岔后侧向区段号 nextSideSelectionId
-    - 所属车站编号 stationId
-
-
-- 车站 station
-  - 编号 id
-  - 名称 name
-- 站台 platform
-  - 编号 id
-  - 所属车站 stationId
-  - 上下行 direction
-  - 默认停站时间 stopTime
-- 区段 selection
-    - 编号 id
-    - 名称 name
-    - 起始公里标 startKilometer
-    - 长度 length
-    - 前一区段号 preId
-    - 后一区段号 nextId
-    - 上下行 direction
-    - 折返标志 zfState
-    - 所属车站编号 stationId
-- 站台门 stationDoor
-    - 编号 id 
-    - 所属站台 stationId
-    - 上下行 direction
-- 紧急停车按钮 emergencyStop
-  - 编号 id
-    - 所属站台 stationId
-    - 上下行 direction
-- 进路 route
-    - 编号 id
-    - 进路名称 name
-    - 关联信号机 signalIds
-    - 关联信号机状态 signalState
-    - 关联区段列表 seleIds
-    - 关联道岔 switchs
-    - 关联道岔状态 switchState
-    - 触发点位置 trigPosition
-    - 进路方向 direction
-- 停车标 stopSign
-    - 编号 id
-    - 所属站台 stationId
-    - 上下行 direction
-    - 所属区段号 selectionId
-    - 所属区段偏移 selectionOff
-- 列车 train
-  - 编号 id
-  - 车次号 name
-  - 长度 length
-  - 初始位置公里标 initKilometer
-  - 初始运行方向 direction

+ 0 - 83
train-demo/pom.xml

@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>top.haijunit</groupId>
-        <artifactId>mul-agent-virtual-simulation-system</artifactId>
-        <version>${revision}</version>
-    </parent>
-    <artifactId>train-demo</artifactId>
-
-    <properties>
-        <alibaba-ttl.version>2.14.2</alibaba-ttl.version>
-    </properties>
-    <dependencies>
-        <dependency>
-            <groupId>top.haijunit</groupId>
-            <artifactId>train-common-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>top.haijunit</groupId>
-            <artifactId>train-common-mybatis</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>top.haijunit</groupId>
-            <artifactId>train-common-websocket</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>top.haijunit</groupId>
-            <artifactId>train-common-web</artifactId>
-        </dependency>
-<!--        <dependency>-->
-<!--            <groupId>org.springframework.boot</groupId>-->
-<!--            <artifactId>spring-boot-starter</artifactId>-->
-<!--        </dependency>-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-thymeleaf</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.liquibase</groupId>
-            <artifactId>liquibase-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
-        <dependency>
-            <groupId>org.redisson</groupId>
-            <artifactId>redisson-spring-boot-starter</artifactId>
-            <version>3.17.1</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-assembly-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 57
train-demo/src/assembly/assembly.xml

@@ -1,57 +0,0 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-    <id>package</id>
-    <formats>
-        <format>zip</format>
-    </formats>
-    <includeBaseDirectory>true</includeBaseDirectory>
-    <fileSets>
-        <!--
-            0755-> 即用户具有读/写/执行权限,组用户和其它用户具有读写权限;
-            0644-> 即用户具有读写权限,组用户和其它用户具有只读权限;
-        -->
-        <fileSet>
-            <directory>src/assembly/bin</directory>
-            <outputDirectory>bin</outputDirectory>
-            <fileMode>0755</fileMode>
-            <lineEnding>unix</lineEnding>
-            <filtered>true</filtered>
-            <includes>
-                <include>*.sh</include>
-            </includes>
-        </fileSet>
-        <fileSet>
-            <directory>src/assembly/bin</directory>
-            <outputDirectory>bin</outputDirectory>
-            <filtered>true</filtered>
-            <includes>
-                <include>*.bat</include>
-                <include>*.vbs</include>
-            </includes>
-        </fileSet>
-        <fileSet>
-            <directory>${project.build.directory}/classes</directory>
-            <outputDirectory>/conf</outputDirectory>
-            <includes>
-                <include>application.*</include>
-                <include>*.yml</include>
-                <include>*.properties</include>
-            </includes>
-        </fileSet>
-        <fileSet>
-            <directory>${project.build.directory}</directory>
-            <outputDirectory>/</outputDirectory>
-            <includes>
-                <include>*.jar</include>
-            </includes>
-        </fileSet>
-    </fileSets>
-    <dependencySets>
-        <dependencySet>
-            <useProjectArtifact>false</useProjectArtifact>
-            <outputDirectory>lib</outputDirectory>
-            <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
-        </dependencySet>
-    </dependencySets>
-</assembly>

+ 0 - 33
train-demo/src/assembly/bin/date.bat

@@ -1,33 +0,0 @@
-@echo off
-chcp 65001 > nul
-setlocal EnableDelayedExpansion
-
-rem 设置目标日期和时间
-set "targetDateTime=2023-10-09 23:59:59"
-rem 设置要显示的消息,使用 vbNewLine 来表示换行
-set "message=这是第一行消息" & vbNewLine & "这是第二行消息"
-
-rem 获取当前日期和时间
-for /f "delims=" %%a in ('wmic os get LocalDateTime ^| find "."') do set currentDateTime=%%a
-
-rem 比较日期和时间
-if "%currentDateTime%" gtr "%targetDateTime%" (
-    echo 授权已过期,请联系管理员
-    pause
-) else (
-    echo 授权尚未过期
-    rem 在这里执行授权未过期时的操作
-)
-
-rem 比较日期和时间
-if "%currentDateTime%" gtr "%targetDateTime%" (
-    echo 授权已过期,请联系管理员
-    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
-) else (
-    echo 授权尚未过期
-    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
-
-    rem 在这里执行授权未过期时的操作
-)
-
-endlocal

+ 0 - 3
train-demo/src/assembly/bin/msgbox.vbs

@@ -1,3 +0,0 @@
-Set objShell = CreateObject("WScript.Shell")
-strMessage = WScript.Arguments(0)
-objShell.Popup strMessage, 0, "提示", 48

+ 0 - 12
train-demo/src/assembly/bin/run.bat

@@ -1,12 +0,0 @@
-@echo off
-chcp 65001
-
-:: Get the directory of the script
-for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
-:: Change directory to the parent directory of the script
-cd /d "%SCRIPT_DIR%"
-
-start /B /MIN cmd /C stop.bat 8086
-timeout /t 1 /nobreak
-start /MIN cmd /C start.bat > NUL 2>&1
-echo Jar程序已在后台运行。

+ 0 - 34
train-demo/src/assembly/bin/start-dev.bat

@@ -1,34 +0,0 @@
-@echo off
-chcp 65001
-
-:: Get the directory of the script
-for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
-:: Change directory to the parent directory of the script
-cd /d "%SCRIPT_DIR%\.."
-
-:: Check if Java is installed
-REM set "javaPath=C:\path\to\java\bin\java.exe"
-set "javaPath=java"
-set "plugin.dev=true"
-%javaPath% -version >nul 2>&1
-if errorlevel 1 (
-    echo Java is not installed or not found.
-    echo Please install Java and try again.
-    exit /b 1
-)
-if not exist "train-server.jar" (
-    echo The file train-server.jar does not exist.
-    exit /b 1
-)
-if not exist "./conf/application.yml" (
-    echo The file config/application.yml does not exist.
-    exit /b 1
-)
-if not exist "lib" (
-    echo The directory lib does not exist.
-    exit /b 1
-)
-:: rest of your script
-%javaPath% -Djava.security.egd=file:/dev/./urandom -Dloader.path=./lib -jar train-server.jar --spring.config.location=./conf/application.yml
-
-pause

+ 0 - 33
train-demo/src/assembly/bin/start.bat

@@ -1,33 +0,0 @@
-@echo off
-chcp 65001
-
-:: Get the directory of the script
-for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
-:: Change directory to the parent directory of the script
-cd /d "%SCRIPT_DIR%\.."
-
-:: Check if Java is installed
-set "javaPath=D:\windows\app\Java\jdk-17.0.8\bin\java.exe"
-REM set "javaPath=java"
-%javaPath% -version >nul 2>&1
-if errorlevel 1 (
-    echo Java is not installed or not found.
-    echo Please install Java and try again.
-    exit /b 1
-)
-if not exist "train-server.jar" (
-    echo The file train-server.jar does not exist.
-    exit /b 1
-)
-if not exist "./conf/application.yml" (
-    echo The file config/application.yml does not exist.
-    exit /b 1
-)
-if not exist "lib" (
-    echo The directory lib does not exist.
-    exit /b 1
-)
-:: rest of your script
-%javaPath% -Djava.security.egd=file:/dev/./urandom -Dloader.path=./lib -jar train-server.jar --spring.config.location=./conf/application.yml
-
-pause

+ 0 - 35
train-demo/src/assembly/bin/start.sh

@@ -1,35 +0,0 @@
-#!/bin/bash
-
-# Get the directory of the script
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-
-# Change directory to the parent directory of the script
-cd "$SCRIPT_DIR/.."
-
-# Check if Java is installed
-if ! type java >/dev/null 2>&1; then
-    echo Java is not installed or not found.
-    echo Please install Java and try again.
-    exit 1
-fi
-
-# Check if train-server.jar file exists
-if [ ! -f "train-server.jar" ]; then
-    echo The file train-server.jar does not exist.
-    exit 1
-fi
-
-# Check if application.yml file exists
-if [ ! -f "./conf/application.yml" ]; then
-    echo The file config/application.yml does not exist.
-    exit 1
-fi
-
-# Check if lib directory exists
-if [ ! -d "lib" ]; then
-    echo The directory lib does not exist.
-    exit 1
-fi
-
-JAVA_OPTS=" -server -Xmx2g -Xms2g -Xmn256m"
-exec java $JAVA_OPTS -Duser.timezone=Asia/Shanghai -Djava.security.egd=file:/dev/./urandom -Dloader.path=./lib -jar train-server.jar --spring.config.location=./conf/application.yml

+ 0 - 25
train-demo/src/assembly/bin/stop.bat

@@ -1,25 +0,0 @@
-@echo off
-chcp 65001
-
-setlocal
-
-REM 设置默认端口号
-set "port=%1"
-if "%port%"=="" (
-    set "port=8086"
-)
-echo 检测端口:%port%
-REM 使用 netstat 和 findstr 命令获取占用特定端口的进程信息
-set "pid="
-for /f "tokens=5" %%a in ('netstat -ano ^| findstr "\[::\]:%port%"') do (
-    set "pid=%%a"
-)
-REM 显示找到的PID
-if not "%pid%"=="" (
-	echo 端口(%port%)已经被线程(%pid%)占用。
-	taskkill /F /PID %pid%
-) else (
-    echo No process found on port %port%.
-)
-
-endlocal

+ 0 - 178
train-demo/src/assembly/bin/wait-for-it.sh

@@ -1,178 +0,0 @@
-#!/bin/bash
-# Use this script to test if a given TCP host/port are available
-## https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi; }
-
-usage() {
-	cat <<USAGE >&2
-Usage:
-    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-    -h HOST | --host=HOST       Host or IP under test
-    -p PORT | --port=PORT       TCP port under test
-                                Alternatively, you specify the host and port as host:port
-    -s | --strict               Only execute subcommand if the test succeeds
-    -q | --quiet                Don't output any status messages
-    -t TIMEOUT | --timeout=TIMEOUT
-                                Timeout in seconds, zero for no timeout
-    -- COMMAND ARGS             Execute command with args after the test finishes
-USAGE
-	exit 1
-}
-
-wait_for() {
-	if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-		echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-	else
-		echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
-	fi
-	WAITFORIT_start_ts=$(date +%s)
-	while :; do
-		if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
-			nc -z $WAITFORIT_HOST $WAITFORIT_PORT
-			WAITFORIT_result=$?
-		else
-			(echo -n >/dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
-			WAITFORIT_result=$?
-		fi
-		if [[ $WAITFORIT_result -eq 0 ]]; then
-			WAITFORIT_end_ts=$(date +%s)
-			echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
-			break
-		fi
-		sleep 1
-	done
-	return $WAITFORIT_result
-}
-
-wait_for_wrapper() {
-	# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
-	if [[ $WAITFORIT_QUIET -eq 1 ]]; then
-		timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-	else
-		timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-	fi
-	WAITFORIT_PID=$!
-	trap "kill -INT -$WAITFORIT_PID" INT
-	wait $WAITFORIT_PID
-	WAITFORIT_RESULT=$?
-	if [[ $WAITFORIT_RESULT -ne 0 ]]; then
-		echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-	fi
-	return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]; do
-	case "$1" in
-	*:*)
-		WAITFORIT_hostport=(${1//:/ })
-		WAITFORIT_HOST=${WAITFORIT_hostport[0]}
-		WAITFORIT_PORT=${WAITFORIT_hostport[1]}
-		shift 1
-		;;
-	--child)
-		WAITFORIT_CHILD=1
-		shift 1
-		;;
-	-q | --quiet)
-		WAITFORIT_QUIET=1
-		shift 1
-		;;
-	-s | --strict)
-		WAITFORIT_STRICT=1
-		shift 1
-		;;
-	-h)
-		WAITFORIT_HOST="$2"
-		if [[ $WAITFORIT_HOST == "" ]]; then break; fi
-		shift 2
-		;;
-	--host=*)
-		WAITFORIT_HOST="${1#*=}"
-		shift 1
-		;;
-	-p)
-		WAITFORIT_PORT="$2"
-		if [[ $WAITFORIT_PORT == "" ]]; then break; fi
-		shift 2
-		;;
-	--port=*)
-		WAITFORIT_PORT="${1#*=}"
-		shift 1
-		;;
-	-t)
-		WAITFORIT_TIMEOUT="$2"
-		if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
-		shift 2
-		;;
-	--timeout=*)
-		WAITFORIT_TIMEOUT="${1#*=}"
-		shift 1
-		;;
-	--)
-		shift
-		WAITFORIT_CLI=("$@")
-		break
-		;;
-	--help)
-		usage
-		;;
-	*)
-		echoerr "Unknown argument: $1"
-		usage
-		;;
-	esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
-	echoerr "Error: you need to provide a host and port to test."
-	usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-20}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# Check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-
-WAITFORIT_BUSYTIMEFLAG=""
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
-	WAITFORIT_ISBUSY=1
-	# Check if busybox timeout uses -t flag
-	# (recent Alpine versions don't support -t anymore)
-	if timeout &>/dev/stdout | grep -q -e '-t '; then
-		WAITFORIT_BUSYTIMEFLAG="-t"
-	fi
-else
-	WAITFORIT_ISBUSY=0
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
-	wait_for
-	WAITFORIT_RESULT=$?
-	exit $WAITFORIT_RESULT
-else
-	if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-		wait_for_wrapper
-		WAITFORIT_RESULT=$?
-	else
-		wait_for
-		WAITFORIT_RESULT=$?
-	fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
-	if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
-		echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
-		exit $WAITFORIT_RESULT
-	fi
-	exec "${WAITFORIT_CLI[@]}"
-else
-	exit $WAITFORIT_RESULT
-fi

+ 0 - 16
train-demo/src/main/java/top/haijunit/train/TrainDemoMain.java

@@ -1,16 +0,0 @@
-package top.haijunit.train;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
-
-@SpringBootApplication
-public class TrainDemoMain {
-
-    public static void main(String[] args) {
-        SpringApplication application = new SpringApplication(TrainDemoMain.class);
-        application.setApplicationStartup(new BufferingApplicationStartup(2048));
-        application.run(args);
-    }
-
-}

+ 0 - 18
train-demo/src/main/java/top/haijunit/train/config/WebSocketConfig.java

@@ -1,18 +0,0 @@
-package top.haijunit.train.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description WebSocket配置
- */
-@Configuration
-public class WebSocketConfig {
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
-}

+ 0 - 34
train-demo/src/main/java/top/haijunit/train/config/properties/RedisProperties.java

@@ -1,34 +0,0 @@
-package top.haijunit.train.config.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/7 13:29
- * @description Redis配置参数
- */
-@Data
-@Component
-@ConfigurationProperties(prefix = "redisson")
-public class RedisProperties {
-
-    /** 客户端名称 */
-    private String clientName;
-    /** 地址 */
-    private String host = "localhost";
-    /** 端口 */
-    private int port = 6379;
-    /** 认证密码 */
-    private String password;
-    /** 是否加密传输 */
-    private boolean ssl = false;
-    /** 库 */
-    private int database = 0;
-
-    public String getUrl() {
-        String protocol = isSsl() ? "rediss" : "redis";
-        return protocol + "://" + getHost() + ":" + getPort();
-    }
-}

+ 0 - 22
train-demo/src/main/java/top/haijunit/train/config/properties/TrainProperties.java

@@ -1,22 +0,0 @@
-package top.haijunit.train.config.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 13:31
- * @description 列车行车配置
- */
-@Data
-@Component
-@ConfigurationProperties(prefix = "train")
-public class TrainProperties {
-
-    private List<String> routes;
-}

+ 0 - 36
train-demo/src/main/java/top/haijunit/train/controller/DemoController.java

@@ -1,36 +0,0 @@
-package top.haijunit.train.controller;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import top.haijunit.common.domain.ResultData;
-import top.haijunit.train.domain.UserEntity;
-import top.haijunit.train.service.UserService;
-
-import java.util.List;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/7 15:30
- * @description 示例请求入口
- */
-@Slf4j
-@RequiredArgsConstructor
-@RestController
-@RequestMapping("/demo")
-public class DemoController {
-
-    private final UserService userService;
-
-    @GetMapping("")
-    public ResultData<String> demo() {
-        return ResultData.success("");
-    }
-
-    @GetMapping("/user")
-    public ResultData<List<UserEntity>> getUser() {
-        return ResultData.success(userService.getUserAll());
-    }
-}

+ 0 - 32
train-demo/src/main/java/top/haijunit/train/controller/TrainController.java

@@ -1,32 +0,0 @@
-package top.haijunit.train.controller;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import top.haijunit.common.domain.ResultData;
-import top.haijunit.train.domain.SignEntity;
-import top.haijunit.train.service.simulation.train.service.RouteService;
-
-import java.util.List;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 13:47
- * @description 列车请求处理
- */
-@Slf4j
-@RequiredArgsConstructor
-@RestController
-@RequestMapping("/train")
-public class TrainController {
-    private final RouteService routeService;
-
-    @GetMapping("/sign")
-    public ResultData<List<SignEntity>> getSignAll(){
-        return ResultData.success(routeService.getSignAll());
-    }
-
-
-}

+ 0 - 30
train-demo/src/main/java/top/haijunit/train/controller/WebSocketController.java

@@ -1,30 +0,0 @@
-package top.haijunit.train.controller;
-
-import top.haijunit.train.websocket.WebSocketServer;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.ModelAndView;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description 测试websocket界面
- */
-@RestController
-public class WebSocketController {
-
-    @GetMapping("/page")
-    public ModelAndView page() {
-        return new ModelAndView("webSocket");
-    }
-
-    @RequestMapping("/push/{toUID}")
-    public ResponseEntity<String> pushToClient(String message, @PathVariable String toUID) throws Exception {
-        WebSocketServer.sendInfo(message, toUID);
-        return ResponseEntity.ok("Send Success!");
-    }
-
-}

+ 0 - 74
train-demo/src/main/java/top/haijunit/train/domain/SignEntity.java

@@ -1,74 +0,0 @@
-package top.haijunit.train.domain;
-
-import cn.hutool.core.util.ArrayUtil;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import top.haijunit.mybatis.domain.BaseEntity;
-import top.haijunit.train.domain.constant.DirectionEnum;
-
-import java.util.function.DoubleBinaryOperator;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/8 11:52
- * @description 轨道中的点位
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("db_sign")
-public class SignEntity extends BaseEntity {
-
-    @TableId(value = "id")
-    private Long id;
-
-    /** 点位 名称 */
-    private String name;
-    /** 点位 编号 */
-    private String code;
-    /** 点位 公里标 */
-    private Double kilometer;
-    /** 上行/下行 */
-    private DirectionEnum direction;
-    /** 状态 */
-    private StatusEnum signStatus;
-    /** 标识类型 */
-    private SignEnum signType;
-    /** 所在区段名称 */
-    private String selectionName;
-    /** 归属车站 编码 */
-    private String stationCode;
-    /** 归属车站 名称 */
-    private String stationName;
-
-    public boolean isPass(double mileage, double trainLength) {
-        DoubleBinaryOperator compare = this.direction.getCompare();
-        return compare.applyAsDouble(this.kilometer, mileage + trainLength) >= 0;
-    }
-
-    // 一般以行车区间的结束节点为标准
-    public String getCurrentSelection() {
-        if (this.direction == DirectionEnum.TOP) {
-            return this.getRightSelection();
-        } else {
-            return this.getLeftSelection();
-        }
-    }
-
-    public String getLeftSelection() {
-        String[] split = this.getSelectionName().split("\\|");
-        if (ArrayUtil.isNotEmpty(split)) {
-            return split[0];
-        }
-        return "";
-    }
-
-    public String getRightSelection() {
-        String[] split = this.getSelectionName().split("\\|");
-        if (ArrayUtil.isNotEmpty(split) && split.length > 1) {
-            return split[1];
-        }
-        return "";
-    }
-}

+ 0 - 38
train-demo/src/main/java/top/haijunit/train/domain/SignEnum.java

@@ -1,38 +0,0 @@
-package top.haijunit.train.domain;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/8 11:54
- * @description 道路标志枚举
- */
-@Getter
-@AllArgsConstructor
-public enum SignEnum {
-
-    MachineSign("MachineSign", "信号机"),
-    ForkSign("forkSign", "道岔"),
-    StopSign("stopSign", "停车标");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static SignEnum getByValue(String value) {
-        for (SignEnum genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), value)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 37
train-demo/src/main/java/top/haijunit/train/domain/StatusEnum.java

@@ -1,37 +0,0 @@
-package top.haijunit.train.domain;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 10:25
- * @description 状态枚举
- */
-@Getter
-@AllArgsConstructor
-public enum StatusEnum {
-
-    Valid("valid","有效"),
-    Disable("disable","禁用");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static StatusEnum getByValue(String value) {
-        for (StatusEnum genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), value)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 28
train-demo/src/main/java/top/haijunit/train/domain/UserEntity.java

@@ -1,28 +0,0 @@
-package top.haijunit.train.domain;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import top.haijunit.mybatis.domain.BaseEntity;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description user实体
- */
-
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("db_user")
-public class UserEntity extends BaseEntity {
-
-    @TableId(value = "user_id")
-    private Long userId;
-
-    private String username;
-
-    private String email;
-
-    private UserStatusEnum status;
-}

+ 0 - 37
train-demo/src/main/java/top/haijunit/train/domain/UserStatusEnum.java

@@ -1,37 +0,0 @@
-package top.haijunit.train.domain;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 12:50
- * @description 用户状态枚举
- */
-@Getter
-@AllArgsConstructor
-public enum UserStatusEnum{
-
-    Valid(1, "有效"),
-    Disable(2, "禁用");
-
-    @JsonValue
-    @EnumValue
-    private final Integer code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static UserStatusEnum getByValue(Integer value) {
-        for (UserStatusEnum genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), value)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 37
train-demo/src/main/java/top/haijunit/train/domain/constant/ButtonStopStatus.java

@@ -1,37 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:48
- * @description 紧停按钮状态
- */
-@Getter
-@AllArgsConstructor
-public enum ButtonStopStatus {
-
-    DOWN("down", "按下(红色圆圈带X)"),
-    BOUNCE("bounce", "弹起(灰色圆圈带X)");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static ButtonStopStatus getByValue(String code) {
-        for (ButtonStopStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 40
train-demo/src/main/java/top/haijunit/train/domain/constant/DirectionEnum.java

@@ -1,40 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-import java.util.function.DoubleBinaryOperator;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/8 12:09
- * @description 方向枚举
- */
-@Getter
-@AllArgsConstructor
-public enum DirectionEnum {
-    // 上行 从右向左 里程越来越小
-    TOP("up", "上行", (start, end) -> end - start), // 下行 从左向右 里程越来越大
-    DOWN("down", "下行,从左向右", (start, end) -> start - end);
-
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-    private final DoubleBinaryOperator compare;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static DirectionEnum getByValue(String value) {
-        for (DirectionEnum genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), value)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 37
train-demo/src/main/java/top/haijunit/train/domain/constant/RouteStatus.java

@@ -1,37 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:33
- * @description 进路状态
- */
-@Getter
-@AllArgsConstructor
-public enum RouteStatus {
-    OCCUPY("occupy", "占用"),
-    IDLE("idle", "出清"),
-    LOCK("lock", "锁闭");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static RouteStatus getByValue(String code) {
-        for (RouteStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 38
train-demo/src/main/java/top/haijunit/train/domain/constant/SelectionStatus.java

@@ -1,38 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:42
- * @description 区段占用状态
- */
-@Getter
-@AllArgsConstructor
-public enum SelectionStatus {
-
-    OCCUPY("occupy", "占用(红光带)"),
-    IDLE("idle", "出清/空闲(灰光带)"),
-    LOCK("lock", "锁闭(白光带)");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static SelectionStatus getByValue(String code) {
-        for (SelectionStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 38
train-demo/src/main/java/top/haijunit/train/domain/constant/SignalStatus.java

@@ -1,38 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:33
- * @description 信号机点灯状态
- */
-@Getter
-@AllArgsConstructor
-public enum SignalStatus {
-    RED("red", "禁止通行"),
-    GREEN("green", "允许通行"),
-    YELLOW("yellow", "道岔"),
-    RED_YELLOW("red_yellow", "");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static SignalStatus getByValue(String code) {
-        for (SignalStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 37
train-demo/src/main/java/top/haijunit/train/domain/constant/StationDoorStatus.java

@@ -1,37 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:45
- * @description 站台门关闭锁紧状态
- */
-@Getter
-@AllArgsConstructor
-public enum StationDoorStatus {
-
-    CLOSE("close", "关闭锁紧(土黄色一条线)"),
-    OPEN("open", "打开(黄色两条线)");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static StationDoorStatus getByValue(String code) {
-        for (StationDoorStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 38
train-demo/src/main/java/top/haijunit/train/domain/constant/SwitchStatus.java

@@ -1,38 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-import com.baomidou.mybatisplus.annotation.EnumValue;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Objects;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:38
- * @description 道岔位置状态
- */
-@Getter
-@AllArgsConstructor
-public enum SwitchStatus {
-
-    POSITIONING("positioning", "定位"),
-    INVERSION("inversion", "反位"),
-    MISALIGNMENT("misalignment", "失标");
-
-    @JsonValue
-    @EnumValue
-    private final String code;
-    private final String describe;
-
-    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
-    public static SwitchStatus getByValue(String code) {
-        for (SwitchStatus genderEnum : values()) {
-            if (Objects.equals(genderEnum.getCode(), code)) {
-                return genderEnum;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 20
train-demo/src/main/java/top/haijunit/train/domain/constant/TrainConstant.java

@@ -1,20 +0,0 @@
-package top.haijunit.train.domain.constant;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/13 17:52
- * @description 列车运行的常量定义
- */
-public interface TrainConstant {
-
-    // 最高速度
-    double Velocity_MAX = 60;
-    // 加速度 单位:m/s
-    double SPEED_UP = 50.00;
-    // 减速度 单位:m/s
-    double SPEED_DOWN = 50.00;
-    // 车长 单位:m
-    double TRAIN_LENGTH = 135.63;
-    // 停车时间 单位:s
-    int TRAIN_STOP_SECOND = 30;
-}

+ 0 - 20
train-demo/src/main/java/top/haijunit/train/domain/dto/PlatformDto.java

@@ -1,20 +0,0 @@
-package top.haijunit.train.domain.dto;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import top.haijunit.train.domain.entity.PlatformEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:59
- * @description 站台
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-public class PlatformDto extends PlatformEntity {
-
-    // 站台跳停状态
-    private boolean jumpStopStatus;
-    // 站台扣车状态
-    private boolean detainStatus;
-}

+ 0 - 33
train-demo/src/main/java/top/haijunit/train/domain/dto/RouteDto.java

@@ -1,33 +0,0 @@
-package top.haijunit.train.domain.dto;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import top.haijunit.train.domain.constant.RouteStatus;
-import top.haijunit.train.domain.entity.RouteEntity;
-
-/**
- * @author zhang
- * @date 2023/11/21 06:53
- * @description 进路
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-public class RouteDto extends RouteEntity {
-
-    private RouteStatus status;
-
-    /** 是否触发进路 */
-    public boolean isTrigger(TrainDto train) {
-        double position = this.getTrigPosition();
-        return train.getFirst().getFrontPos() >= position && train.getLsat().getFrontPos() < position;
-    }
-
-    /** 是否包含道岔 */
-    public boolean isContainSwitch(){
-        // TODO 是否包含道岔
-        return false;
-    }
-    public boolean isValid(){
-        return this.getStatus() == RouteStatus.IDLE;
-    }
-}

+ 0 - 20
train-demo/src/main/java/top/haijunit/train/domain/dto/TrainDto.java

@@ -1,20 +0,0 @@
-package top.haijunit.train.domain.dto;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import top.haijunit.train.domain.entity.TrainEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:54
- * @description 列车运行
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-public class TrainDto extends TrainEntity {
-
-    // 上一个周期的信息
-    private TravelDto first;
-    // 下一个周期的信息
-    private TravelDto lsat;
-}

+ 0 - 21
train-demo/src/main/java/top/haijunit/train/domain/dto/TravelDto.java

@@ -1,21 +0,0 @@
-package top.haijunit.train.domain.dto;
-
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/21 00:06
- * @description 行驶信息
- */
-@Data
-public class TravelDto {
-
-    // 速度
-    private double speed;
-    // 加速度
-    private double speedFull;
-    // 车头位置
-    private double frontPos;
-    // 车尾位置
-    private double tailPos;
-}

+ 0 - 23
train-demo/src/main/java/top/haijunit/train/domain/entity/EmergencyStopEntity.java

@@ -1,23 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/21 00:03
- * @description 紧急停车按钮
- */
-@Data
-@TableName("db_emergency_stop")
-public class EmergencyStopEntity {
-
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 所属站台
-    private String stationId;
-    // 上下行
-    private String direction;
-}

+ 0 - 24
train-demo/src/main/java/top/haijunit/train/domain/entity/PlatformEntity.java

@@ -1,24 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:23
- * @description 站台
- */
-@Data
-@TableName("db_platform")
-public class PlatformEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 所属车站
-    private String stationId;
-    // 上下行
-    private String direction;
-    // 默认停站时间
-    private String stopTime;
-}

+ 0 - 34
train-demo/src/main/java/top/haijunit/train/domain/entity/RouteEntity.java

@@ -1,34 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:25
- * @description 进路
- */
-@Data
-@TableName("db_route")
-public class RouteEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 进路名称
-    private String name;
-    // 关联信号机
-    private String signalIds;
-    // 关联信号机状态
-    private String signalState;
-    // 关联区段列表
-    private String seleIds;
-    // 关联道岔
-    private String switchId;
-    // 关联道岔状态
-    private String switchState;
-    // 触发点位置
-    private double trigPosition;
-    // 进路方向
-    private String direction;
-}

+ 0 - 34
train-demo/src/main/java/top/haijunit/train/domain/entity/SelectionEntity.java

@@ -1,34 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:23
- * @description 区段
- */
-@Data
-@TableName("db_selection")
-public class SelectionEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 名称
-    private String name;
-    // 起始公里标
-    private String startKilometer;
-    // 长度
-    private String length;
-    // 前一区段号
-    private String preId;
-    // 后一区段号
-    private String nextId;
-    // 上下行
-    private String direction;
-    // 折返标志
-    private String zfState;
-    // 所属车站编号
-    private String stationId;
-}

+ 0 - 26
train-demo/src/main/java/top/haijunit/train/domain/entity/SignStopEntity.java

@@ -1,26 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:26
- * @description 停车标
- */
-@Data
-@TableName("db_stop_sign")
-public class SignStopEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 所属站台
-    private String stationId;
-    // 上下行
-    private String direction;
-    // 所属区段号
-    private String selectionId;
-    // 所属区段偏移
-    private String selectionOff;
-}

+ 0 - 30
train-demo/src/main/java/top/haijunit/train/domain/entity/SignalEntity.java

@@ -1,30 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:14
- * @description 信号灯
- */
-@Data
-@TableName("db_signal")
-public class SignalEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 名称
-    private String name;
-    // 公里标
-    private String kilometer;
-    // 状态:红、绿、黄、红黄
-    private String colorState;
-    // 区段号
-    private String selectionId;
-    // 类型:上行、下行
-    private String direction;
-    // 车站编号
-    private String stationId;
-}

+ 0 - 22
train-demo/src/main/java/top/haijunit/train/domain/entity/StationDoorEntity.java

@@ -1,22 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:24
- * @description 站台门
- */
-@Data
-@TableName("db_station_door")
-public class StationDoorEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 所属站台
-    private String stationId;
-    // 上下行
-    private String direction;
-}

+ 0 - 20
train-demo/src/main/java/top/haijunit/train/domain/entity/StationEntity.java

@@ -1,20 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:22
- * @description 车站
- */
-@Data
-@TableName("db_station")
-public class StationEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 名称
-    private String name;
-}

+ 0 - 32
train-demo/src/main/java/top/haijunit/train/domain/entity/SwitchEntity.java

@@ -1,32 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:21
- * @description 道岔
- */
-@Data
-@TableName("db_switch")
-public class SwitchEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 名称
-    private String name;
-    // 公里标
-    private String kilometer;
-    // 类型
-    private String type;
-    // 岔前区段号
-    private String preSelectionId;
-    // 岔后区段号
-    private String nextSelectionId;
-    // 岔后侧向区段号
-    private String nextSideSelectionId;
-    // 所属车站编号
-    private String stationId;
-}

+ 0 - 27
train-demo/src/main/java/top/haijunit/train/domain/entity/TrainEntity.java

@@ -1,27 +0,0 @@
-package top.haijunit.train.domain.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import top.haijunit.train.domain.constant.DirectionEnum;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:27
- * @description 列车
- */
-@Data
-@TableName("db_train")
-public class TrainEntity {
-    // 编号
-    @TableId(value = "id")
-    private String id;
-    // 车次号
-    private String name;
-    // 长度
-    private String length;
-    // 初始位置公里标
-    private String initKilometer;
-    // 运行方向
-    private DirectionEnum direction;
-}

+ 0 - 16
train-demo/src/main/java/top/haijunit/train/domain/mapper/EmergencyStopMapper.java

@@ -1,16 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.SignEntity;
-
-/**
- * @author zhang
- * @date 2023/11/21 00:03
- * @description 紧急停车按钮
- */
-@Mapper
-public interface EmergencyStopMapper extends BaseMapper<SignEntity> {
-
-
-}

+ 0 - 14
train-demo/src/main/java/top/haijunit/train/domain/mapper/PlatformMapper.java

@@ -1,14 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:23
- * @description 站台
- */
-@Mapper
-public interface PlatformMapper extends BaseMapper<PlatformMapper> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/RouteMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.RouteEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:25
- * @description 进路
- */
-@Mapper
-public interface RouteMapper extends BaseMapper<RouteEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/SelectionMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.SelectionEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:23
- * @description 区段
- */
-@Mapper
-public interface SelectionMapper extends BaseMapper<SelectionEntity> {
-
-}

+ 0 - 14
train-demo/src/main/java/top/haijunit/train/domain/mapper/SignStopMapper.java

@@ -1,14 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:26
- * @description 停车标
- */
-@Mapper
-public interface SignStopMapper extends BaseMapper<SignStopMapper> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/SignalMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.SignalEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:14
- * @description 信号灯
- */
-@Mapper
-public interface SignalMapper extends BaseMapper<SignalEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/StationDoorMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.StationDoorEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:24
- * @description 站台门
- */
-@Mapper
-public interface StationDoorMapper extends BaseMapper<StationDoorEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/StationMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.StationEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:22
- * @description 车站
- */
-@Mapper
-public interface StationMapper extends BaseMapper<StationEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/SwitchMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.SwitchEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:21
- * @description 道岔
- */
-@Mapper
-public interface SwitchMapper extends BaseMapper<SwitchEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/domain/mapper/TrainMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.domain.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.entity.TrainEntity;
-
-/**
- * @author zhang
- * @date 2023/11/20 23:27
- * @description 列车
- */
-@Mapper
-public interface TrainMapper extends BaseMapper<TrainEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/mapper/SignMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.mapper;
-
-import org.apache.ibatis.annotations.Mapper;
-import top.haijunit.mybatis.mapper.BaseMapper;
-import top.haijunit.train.domain.SignEntity;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 11:37
- * @description 轨道中的点位 数据库操作
- */
-@Mapper
-public interface SignMapper extends BaseMapper<SignEntity> {
-
-}

+ 0 - 15
train-demo/src/main/java/top/haijunit/train/mapper/UserMapper.java

@@ -1,15 +0,0 @@
-package top.haijunit.train.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Mapper;
-import org.springframework.stereotype.Component;
-import top.haijunit.train.domain.UserEntity;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description user数据库操作
- */
-@Mapper
-public interface UserMapper extends BaseMapper<UserEntity> {
-}

+ 0 - 36
train-demo/src/main/java/top/haijunit/train/service/RouteService.java

@@ -1,36 +0,0 @@
-package top.haijunit.train.service;
-
-import lombok.extern.slf4j.Slf4j;
-import top.haijunit.train.domain.constant.RouteStatus;
-import top.haijunit.train.domain.dto.RouteDto;
-import top.haijunit.train.domain.dto.TrainDto;
-import top.haijunit.train.domain.entity.RouteEntity;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author zhang
- * @date 2023/11/21 06:45
- * @description 进路业务处理
- */
-@Slf4j
-public class RouteService {
-
-    List<RouteDto> routeList = new ArrayList<>();
-
-    public void run(TrainDto train) {
-        for (RouteDto route : routeList) {
-            if (!route.isTrigger(train)) {
-                continue;
-            }
-            if (route.isValid() && route.isContainSwitch()) {
-                // TODO 出清且包含到拆
-                route.setStatus(RouteStatus.LOCK);
-            } else if (route.isValid()) {
-                // TODO 出清且不包括到道岔
-                route.setStatus(RouteStatus.LOCK);
-            }
-        }
-    }
-}

+ 0 - 27
train-demo/src/main/java/top/haijunit/train/service/TrainApplication.java

@@ -1,27 +0,0 @@
-package top.haijunit.train.service;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.stereotype.Component;
-import top.haijunit.train.service.simulation.train.TrainGlobalHolder;
-import top.haijunit.train.service.simulation.train.service.RouteService;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/17 17:32
- * @description [一句话描述该类的功能]
- */
-@Slf4j
-@Component
-@RequiredArgsConstructor
-public class TrainApplication implements ApplicationRunner {
-
-    private final RouteService routeService;
-
-    @Override
-    public void run(ApplicationArguments args) throws Exception {
-        TrainGlobalHolder.init(routeService.getRouteList());
-    }
-}

+ 0 - 32
train-demo/src/main/java/top/haijunit/train/service/UserService.java

@@ -1,32 +0,0 @@
-package top.haijunit.train.service;
-
-import cn.hutool.core.util.RandomUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Service;
-import top.haijunit.train.domain.UserStatusEnum;
-import top.haijunit.train.domain.UserEntity;
-import top.haijunit.train.mapper.UserMapper;
-
-import java.util.List;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 12:06
- * @description 用户业务处理
- */
-@Service
-@RequiredArgsConstructor
-public class UserService {
-
-    private final UserMapper userMapper;
-
-    public List<UserEntity> getUserAll() {
-        UserEntity user = new UserEntity();
-        user.setUsername(RandomUtil.randomString(4));
-        user.setEmail(RandomUtil.randomString(4) + "@qq.com");
-        user.setStatus(UserStatusEnum.Valid);
-        userMapper.insert(user);
-        return userMapper.selectList(new QueryWrapper<>());
-    }
-}

+ 0 - 39
train-demo/src/main/java/top/haijunit/train/service/simulation/train/TrainGlobalHolder.java

@@ -1,39 +0,0 @@
-package top.haijunit.train.service.simulation.train;
-
-import cn.hutool.core.util.StrUtil;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import top.haijunit.train.domain.SignEntity;
-import top.haijunit.train.service.simulation.train.domain.TrainRoute;
-
-import java.util.LinkedList;
-import java.util.concurrent.*;
-
-/**
- * @author zhang
- * @date 2023/11/18 17:42
- * @description [一句话描述该类的功能]
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class TrainGlobalHolder {
-
-    private static final CopyOnWriteArrayList<TrainRoute> ROUTE_LIST = new CopyOnWriteArrayList<>();
-
-    public static void init(LinkedList<SignEntity> list) {
-        ROUTE_LIST.addAll(TrainRoute.initTrainRoute(list));
-    }
-
-    public static TrainRoute getNextRoute(TrainRoute route) {
-        for (int i = 0; i < ROUTE_LIST.size(); i++) {
-            TrainRoute item = ROUTE_LIST.get(i);
-            if (StrUtil.equals(item.getName(), route.getName())) {
-                if (i == ROUTE_LIST.size() - 1) {
-                    return ROUTE_LIST.stream().findFirst().orElse(null);
-                } else {
-                    return ROUTE_LIST.get(i + 1);
-                }
-            }
-        }
-        return null;
-    }
-}

+ 0 - 152
train-demo/src/main/java/top/haijunit/train/service/simulation/train/TrainTravel.java

@@ -1,152 +0,0 @@
-package top.haijunit.train.service.simulation.train;
-
-import cn.hutool.core.collection.CollUtil;
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-import top.haijunit.common.utils.StreamUtils;
-import top.haijunit.train.domain.SignEntity;
-import top.haijunit.train.domain.constant.TrainConstant;
-import top.haijunit.train.service.simulation.train.domain.TrainDate;
-import top.haijunit.train.service.simulation.train.domain.TrainDateStatus;
-import top.haijunit.train.service.simulation.train.domain.TrainRoute;
-import top.haijunit.train.utils.CalculateUtil;
-
-import java.time.LocalDateTime;
-import java.util.LinkedList;
-import java.util.stream.Collectors;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/15 18:01
- * @description [一句话描述该类的功能]
- */
-@Data
-@Slf4j
-public class TrainTravel {
-
-    // 列车名称
-    private final String trainCode;
-    // 车长
-    private final double trainLength = TrainConstant.TRAIN_LENGTH;
-    // 时间集合
-    private final LinkedList<TrainDate> trainDateList = new LinkedList<>();
-    // 进路集合
-    private final LinkedList<TrainRoute> trainRouteList = new LinkedList<>();
-
-
-    // 运行计算
-    public void run() {
-        LocalDateTime now = LocalDateTime.now();
-        Integer[] array = getDateIndex(now);
-        int index_now = array[0];
-        int index_ensure = array[1];
-        // 进路添加
-        if (this.trainRouteList.size() < 2) {
-            TrainRoute nextRoute = TrainGlobalHolder.getNextRoute(this.trainRouteList.getLast());
-            // TODO 判断下一个进路是否可用
-            this.trainRouteList.addLast(nextRoute);
-        }
-        TrainDate date_ensure = this.trainDateList.get(index_ensure);
-        int index = this.getRouteIndex(date_ensure.getDistance());
-        double juli = 0.00;
-        for (int i = index; i < this.trainRouteList.size(); i++) {
-            TrainRoute item = this.trainRouteList.get(i);
-            if (i == index) {
-                juli += Math.abs(date_ensure.getDistance() - item.getSignEnd().getKilometer());
-            } else {
-                juli += Math.abs(item.getSignEnd().getKilometer() - item.getSignStart().getKilometer());
-            }
-        }
-        double speed = date_ensure.getSpeed();
-        // 距离 当前的速度
-        double distance = CalculateUtil.distance(speed, TrainConstant.SPEED_UP, TrainConstant.Velocity_MAX);
-
-
-
-
-
-        // 时间节点处理
-
-
-        LinkedList<TrainDate> trainDates = StreamUtils.filterToLinkedList(this.trainDateList, item -> item.getStatus() == TrainDateStatus.ENSURE);
-        TrainDate trainDate = trainDates.getLast();
-
-        TrainRoute route = getCurrentTrainRoute(trainDate.getDistance(), false);
-        SignEntity signEnd = route.getSignEnd();
-        // 计算到下一个节点的时间节点数据
-        // 距离差
-        //
-
-    }
-
-    /**
-     * @param mileage     当前里程
-     * @param deletePasse 是否删除车尾已过的进路
-     * @return 当前的进路
-     */
-    public TrainRoute getCurrentTrainRoute(double mileage, boolean deletePasse) {
-        LinkedList<TrainRoute> list = this.trainRouteList.stream().filter(item -> item.isPasse(mileage, this.trainLength)).collect(Collectors.toCollection(LinkedList::new));
-        if (CollUtil.isEmpty(list)) {
-            return null;
-        } else if (list.size() == 1) {
-            return list.getFirst();
-        } else {
-            TrainRoute trainRoute = list.removeLast();
-            if (deletePasse && !this.trainRouteList.removeAll(list)) {
-                log.error("移除已经走过的进路失败");
-            }
-            return trainRoute;
-        }
-    }
-
-    /**
-     * @param dateTime    当前时间
-     * @param deletePasse 是否删除已过时的时间段,过时时间点仅保留一条
-     * @return 当前的时间点
-     */
-    public TrainDate getCurrentTrainDate(LocalDateTime dateTime, boolean deletePasse) {
-        LinkedList<TrainDate> list = this.trainDateList.stream().filter(item -> item.isPasse(dateTime)).collect(Collectors.toCollection(LinkedList::new));
-        if (CollUtil.isEmpty(list)) {
-            return null;
-        } else if (list.size() == 1) {
-            return list.getFirst();
-        } else {
-            TrainDate trainDate = list.removeLast();
-            if (deletePasse && !trainDateList.removeAll(list)) {
-                log.error("无法删除数据,删除已过时的时间段,过时时间点仅保留一条");
-            }
-            return trainDate;
-        }
-    }
-
-
-    /**
-     * @param now 当前时间
-     * @return 数组下标 1:当前时间的下标 3 确定时间的最后下表
-     */
-    public Integer[] getDateIndex(LocalDateTime now) {
-        int index_now = -1;
-        int index_ensure = -1;
-        for (int i = 0; i < this.trainDateList.size(); i++) {
-            TrainDate item = this.trainDateList.get(i);
-            if (item.isPasse(now)) {
-                index_now = i;
-            }
-            if (item.getStatus() == TrainDateStatus.ENSURE) {
-                index_ensure = i;
-            }
-        }
-        return new Integer[]{index_now, index_ensure};
-    }
-
-    public int getRouteIndex(double mileage) {
-        int index = -1;
-        for (int i = 0; i < this.trainRouteList.size(); i++) {
-            TrainRoute item = this.trainRouteList.get(i);
-            if (item.isPasse(mileage, this.trainLength)) {
-                index = i;
-            }
-        }
-        return index;
-    }
-}

+ 0 - 31
train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainDate.java

@@ -1,31 +0,0 @@
-package top.haijunit.train.service.simulation.train.domain;
-
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/15 17:53
- * @description [一句话描述该类的功能]
- */
-@Data
-public class TrainDate {
-
-    // 时间
-    private final LocalDateTime data;
-    // 速度
-    private final double speed;
-    // 加速度
-    private final double speedUp;
-    // 距离
-    private final double distance;
-    // 状态
-    private final TrainDateStatus status;
-
-
-    // 确定且已过时
-    public boolean isPasse(LocalDateTime dateTime) {
-        return dateTime.isAfter(this.getData()) && this.getStatus() == TrainDateStatus.ENSURE;
-    }
-}

+ 0 - 20
train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainDateStatus.java

@@ -1,20 +0,0 @@
-package top.haijunit.train.service.simulation.train.domain;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * @author zhanghaijun
- * @version 1.0
- * @date 2023/11/15 17:54
- * @description [一句话描述该类的功能]
- */
-@Getter
-@AllArgsConstructor
-public enum TrainDateStatus {
-
-    // 确定
-    ENSURE,
-    // 不确定的
-    PENDING
-}

+ 0 - 42
train-demo/src/main/java/top/haijunit/train/service/simulation/train/domain/TrainRoute.java

@@ -1,42 +0,0 @@
-package top.haijunit.train.service.simulation.train.domain;
-
-import cn.hutool.core.collection.CollUtil;
-import lombok.Data;
-import top.haijunit.train.domain.SignEntity;
-
-import java.util.LinkedList;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/15 18:05
- * @description [一句话描述该类的功能]
- */
-@Data
-public class TrainRoute {
-
-
-    // 区间 名称
-    private final String name;
-    // 开始经过的点位
-    private final SignEntity signStart;
-    // 结束经过的点位
-    private final SignEntity signEnd;
-
-    // 是否 车尾已过该进路
-    public boolean isPasse(double mileage, double trainLength) {
-        return this.signStart.isPass(mileage, trainLength);
-    }
-
-    // 初始化预设的进路
-    public static LinkedList<TrainRoute> initTrainRoute(LinkedList<SignEntity> routeList) {
-        LinkedList<TrainRoute> result = new LinkedList<>();
-        if (CollUtil.isEmpty(routeList)) {
-            return result;
-        }
-        for (int i = 0; i < routeList.size() - 1; i++) {
-            SignEntity start = routeList.get(i);
-            result.addLast(new TrainRoute(start.getCurrentSelection(), start, routeList.get(i + 1)));
-        }
-        return result;
-    }
-}

+ 0 - 50
train-demo/src/main/java/top/haijunit/train/service/simulation/train/service/RouteService.java

@@ -1,50 +0,0 @@
-package top.haijunit.train.service.simulation.train.service;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import top.haijunit.train.config.properties.TrainProperties;
-import top.haijunit.train.domain.SignEntity;
-import top.haijunit.train.mapper.SignMapper;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/11 13:40
- * @description 列车行驶业务处理
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class RouteService {
-
-    private final TrainProperties trainProperties;
-    private final SignMapper signMapper;
-
-    public List<SignEntity> getSignAll() {
-        return signMapper.selectList();
-    }
-
-    public LinkedList<SignEntity> getRouteList() {
-        List<String> routeList = trainProperties.getRoutes();
-        if (null == routeList) {
-            return new LinkedList<>();
-        }
-        List<SignEntity> signAll = this.getSignAll();
-        Map<String, SignEntity> signMap = signAll.stream().collect(Collectors.toMap(SignEntity::getCode, Function.identity(), (a, b) -> a));
-        LinkedList<SignEntity> list = new LinkedList<>();
-        for (String code : routeList) {
-            if (signMap.containsKey(code)) {
-                list.addLast(signMap.get(code));
-            } else {
-                log.error("------预制线路错误,错误的code:" + code);
-            }
-        }
-        return list;
-    }
-}

+ 0 - 42
train-demo/src/main/java/top/haijunit/train/service/simulation/train/train.txt

@@ -1,42 +0,0 @@
-
-点:编号、名称、里程、类型(信号灯|停车标|道岔)
-
-列车运行数据: (接口数据:列车的集合)
-列车: 编号、车长、
-    时间集合:(在以下进路集合范围内)
-        时间1:速度、加速度、里程,状态(确定|不确定)
-        时间2:速度、加速度、里程,状态(确定|不确定)
-        时间3:速度、加速度、里程,状态(确定|不确定)
-        // 确定:下次不再计算,在下一个进路没有开启之前,  要在结束的点位停车,开始制动的节点是不确定
-        // 不确定:下次要重新计算该时间的列车信息
-    进路集合
-        占用进路1: 开始点(信号灯|停车标|道岔)、结束点(信号灯|停车标|道岔)、区间名称、上行|下行、
-        占用进路2: 开始点(信号灯|停车标|道岔)、结束点(信号灯|停车标|道岔)、区间名称、上行|下行、
-        占用进路3: 开始点(信号灯|停车标|道岔)、结束点(信号灯|停车标|道岔)、区间名称、上行|下行、
-
-init:
-    1、根据配置文件计算出可行驶的全部进路。
-    2、初始化第一辆车。
-
-run:
-    1、 在时间集合中查找最后一个确定的时间开始计算,之后时间的对的数据信息。== 开始计算时间+对应的数据
-    //  最小区间:(列车和列车之间必须保持一个非占用的区间,要不无法计算开始可占用的区间,列车是动态的。)
-    2、进路添加:
-        1、释放进路:时间小于当前时间+ 时间节点的状态是确定的。
-        2、可用进路 是否<2 否 : 跳过
-                         是 : 判断下一条进路是否可占用。
-    3、计算时间:
-        1、释放时间:时间小于当前时间+ 时间节点的状态是确定的。
-        2、时间集合 是否<10 否 : 跳过
-                  是 : 继续
-        判断开始计算的时间,所在那条占用进路内,
-        此进路后 有无 占用进路,有可用进路,计算 <到下一个进路末端的时间节点>。
-                        无可用进路,判断下一条进路是否占用,不占用,加入下一个进路,并计算 <到下一个进路末端的时间节点>
-                                                     占用,则 不处理
-    4、是否要执行制动
-        判断 刹车点和当前时间 不足 循环时间(50ms)则 更新制动点为确定状态。
-                   时间赋予,则不处理。等待下一次处理。
-
-到下一个进路末端的时间节点
-    1、停车标的停车时间是:30s
-

+ 0 - 19
train-demo/src/main/java/top/haijunit/train/service/simulation/train/utils/RouteUtil.java

@@ -1,19 +0,0 @@
-package top.haijunit.train.service.simulation.train.utils;
-
-import lombok.experimental.UtilityClass;
-import top.haijunit.common.utils.SpringUtils;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/17 17:13
- * @description [一句话描述该类的功能]
- */
-@UtilityClass
-public class RouteUtil {
-
-    public void getNextRoute() {
-        if (SpringUtils.containsBean("")) {
-
-        }
-    }
-}

+ 0 - 48
train-demo/src/main/java/top/haijunit/train/utils/CalculateUtil.java

@@ -1,48 +0,0 @@
-package top.haijunit.train.utils;
-
-import lombok.experimental.UtilityClass;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/13 17:38
- * @description [一句话描述该类的功能]
- */
-@UtilityClass
-public class CalculateUtil {
-
-    /**
-     * 输入当前的速度、加速度和时间
-     *
-     * @param v0 // 初始速度
-     * @param a  // 加速度
-     * @param t  // 时间
-     * @return 位置距离
-     */
-    public double calculateDistance(double v0, double a, double t) {
-        return v0 * t + 0.5 * a * t * t;
-    }
-
-    /**
-     * 计算速度为零时的距离
-     *
-     * @param v     速度
-     * @param vDown 减速度
-     * @return 到停车的距离
-     */
-    private static double calculateDecelerateDistance(double v, double vDown) {
-        return (v * v) / (2 * vDown);
-    }
-
-    /**
-     * 已知 当前速度、加速度,求速度达到一定的值,距离是多少
-     *
-     * @param v1 当前速度
-     * @param v0 加速度
-     * @param v2 最大速度
-     * @return 距离
-     */
-    public static double distance(double v1, double v0, double v2) {
-        double time = (v2 - v1) / v0;
-        return v1 * time + 0.5 * v0 * Math.pow(time, 2);
-    }
-}

+ 0 - 487
train-demo/src/main/java/top/haijunit/train/utils/RedisManage.java

@@ -1,487 +0,0 @@
-package top.haijunit.train.utils;
-
-import cn.hutool.core.convert.Convert;
-import org.redisson.api.*;
-import org.redisson.config.Config;
-
-import java.time.Duration;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * @author zhanghaijun
- * @date 2023/8/11 18:15
- * @description Redis工具类
- */
-public abstract class RedisManage {
-
-    /** 获取客户端实例 */
-    public abstract RedissonClient getClient();
-
-    public NameMapper getNameMapper() {
-        Config config = getClient().getConfig();
-        if (config.isClusterConfig()) {
-            return config.useClusterServers().getNameMapper();
-        }
-        return config.useSingleServer().getNameMapper();
-    }
-
-    /**
-     * 限流
-     *
-     * @param key          限流key
-     * @param rateType     限流类型
-     * @param rate         速率
-     * @param rateInterval 速率间隔
-     * @return -1 表示失败
-     */
-    public long rateLimiter(String key, RateType rateType, int rate, int rateInterval) {
-        RRateLimiter rateLimiter = getClient().getRateLimiter(key);
-        rateLimiter.trySetRate(rateType, rate, rateInterval, RateIntervalUnit.SECONDS);
-        if (rateLimiter.tryAcquire()) {
-            return rateLimiter.availablePermits();
-        } else {
-            return -1L;
-        }
-    }
-
-    /**
-     * 发布通道消息
-     *
-     * @param channelKey 通道key
-     * @param msg        发送数据
-     * @param consumer   自定义处理
-     */
-    public <T> void publish(String channelKey, T msg, Consumer<T> consumer) {
-        RTopic topic = getClient().getTopic(channelKey);
-        topic.publish(msg);
-        consumer.accept(msg);
-    }
-
-    public <T> void publish(String channelKey, T msg) {
-        RTopic topic = getClient().getTopic(channelKey);
-        topic.publish(msg);
-    }
-
-    /**
-     * 订阅通道接收消息
-     *
-     * @param channelKey 通道key
-     * @param clazz      消息类型
-     * @param consumer   自定义处理
-     */
-    public <T> void subscribe(String channelKey, Class<T> clazz, Consumer<T> consumer) {
-        RTopic topic = getClient().getTopic(channelKey);
-        topic.addListener(clazz, (channel, msg) -> consumer.accept(msg));
-    }
-
-    /**
-     * 缓存基本的对象,Integer、String、实体类等
-     *
-     * @param key   缓存的键值
-     * @param value 缓存的值
-     */
-    public <T> void setCacheObject(final String key, final T value) {
-        setCacheObject(key, value, false);
-    }
-
-    /**
-     * 缓存基本的对象,保留当前对象 TTL 有效期
-     *
-     * @param key       缓存的键值
-     * @param value     缓存的值
-     * @param isSaveTtl 是否保留TTL有效期(例如: set之前ttl剩余90 set之后还是为90)
-     * @since Redis 6.X 以上使用 setAndKeepTTL 兼容 5.X 方案
-     */
-    public <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) {
-        RBucket<T> bucket = getClient().getBucket(key);
-        if (isSaveTtl) {
-            try {
-                bucket.setAndKeepTTL(value);
-            } catch (Exception e) {
-                long timeToLive = bucket.remainTimeToLive();
-                setCacheObject(key, value, Duration.ofMillis(timeToLive));
-            }
-        } else {
-            bucket.set(value);
-        }
-    }
-
-    /**
-     * 缓存基本的对象,Integer、String、实体类等
-     *
-     * @param key      缓存的键值
-     * @param value    缓存的值
-     * @param duration 时间
-     */
-    public <T> void setCacheObject(final String key, final T value, final Duration duration) {
-        RBatch batch = getClient().createBatch();
-        RBucketAsync<T> bucket = batch.getBucket(key);
-        bucket.setAsync(value);
-        bucket.expireAsync(duration);
-        batch.execute();
-    }
-
-    /**
-     * 注册对象监听器
-     * <p>
-     * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
-     *
-     * @param key      缓存的键值
-     * @param listener 监听器配置
-     */
-    public <T> void addObjectListener(final String key, final ObjectListener listener) {
-        RBucket<T> result = getClient().getBucket(key);
-        result.addListener(listener);
-    }
-
-    /**
-     * 设置有效时间
-     *
-     * @param key     Redis键
-     * @param timeout 超时时间
-     * @return true=设置成功;false=设置失败
-     */
-    public boolean expire(final String key, final long timeout) {
-        return expire(key, Duration.ofSeconds(timeout));
-    }
-
-    /**
-     * 设置有效时间
-     *
-     * @param key      Redis键
-     * @param duration 超时时间
-     * @return true=设置成功;false=设置失败
-     */
-    public boolean expire(final String key, final Duration duration) {
-        RBucket<Object> rBucket = getClient().getBucket(key);
-        return rBucket.expire(duration);
-    }
-
-    /**
-     * 获得缓存的基本对象。
-     *
-     * @param key 缓存键值
-     * @return 缓存键值对应的数据
-     */
-    public <T> T getCacheObject(final String key) {
-        RBucket<T> rBucket = getClient().getBucket(key);
-        return rBucket.get();
-    }
-
-    /**
-     * 获得缓存的基本对象。
-     *
-     * @param key 缓存键值
-     * @return 缓存键值对应的数据
-     */
-    public String getCacheStr(final String key) {
-        return Convert.toStr(getCacheObject(key), "");
-    }
-
-    /**
-     * 获得key剩余存活时间
-     *
-     * @param key 缓存键值
-     * @return 剩余存活时间
-     */
-    public <T> long getTimeToLive(final String key) {
-        RBucket<T> rBucket = getClient().getBucket(key);
-        return rBucket.remainTimeToLive();
-    }
-
-    /**
-     * 删除单个对象
-     *
-     * @param key 缓存的键值
-     */
-    public boolean deleteObject(final String key) {
-        return getClient().getBucket(key).delete();
-    }
-
-    /**
-     * 删除集合对象
-     *
-     * @param collection 多个对象
-     */
-    public void deleteObject(final Collection collection) {
-        RBatch batch = getClient().createBatch();
-        collection.forEach(t -> {
-            batch.getBucket(t.toString()).deleteAsync();
-        });
-        batch.execute();
-    }
-
-    /**
-     * 缓存List数据
-     *
-     * @param key      缓存的键值
-     * @param dataList 待缓存的List数据
-     * @return 缓存的对象
-     */
-    public <T> boolean setCacheList(final String key, final List<T> dataList) {
-        RList<T> rList = getClient().getList(key);
-        return rList.addAll(dataList);
-    }
-
-    /**
-     * 注册List监听器
-     * <p>
-     * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
-     *
-     * @param key      缓存的键值
-     * @param listener 监听器配置
-     */
-    public <T> void addListListener(final String key, final ObjectListener listener) {
-        RList<T> rList = getClient().getList(key);
-        rList.addListener(listener);
-    }
-
-    /**
-     * 获得缓存的list对象
-     *
-     * @param key 缓存的键值
-     * @return 缓存键值对应的数据
-     */
-    public <T> List<T> getCacheList(final String key) {
-        RList<T> rList = getClient().getList(key);
-        return rList.readAll();
-    }
-
-    /**
-     * 缓存Set
-     *
-     * @param key     缓存键值
-     * @param dataSet 缓存的数据
-     * @return 缓存数据的对象
-     */
-    public <T> boolean setCacheSet(final String key, final Set<T> dataSet) {
-        RSet<T> rSet = getClient().getSet(key);
-        return rSet.addAll(dataSet);
-    }
-
-    /**
-     * 注册Set监听器
-     * <p>
-     * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
-     *
-     * @param key      缓存的键值
-     * @param listener 监听器配置
-     */
-    public <T> void addSetListener(final String key, final ObjectListener listener) {
-        RSet<T> rSet = getClient().getSet(key);
-        rSet.addListener(listener);
-    }
-
-    /**
-     * 获得缓存的set
-     *
-     * @param key 缓存的key
-     * @return set对象
-     */
-    public <T> Set<T> getCacheSet(final String key) {
-        RSet<T> rSet = getClient().getSet(key);
-        return rSet.readAll();
-    }
-
-    /**
-     * 缓存Map
-     *
-     * @param key     缓存的键值
-     * @param dataMap 缓存的数据
-     */
-    public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
-        if (dataMap != null) {
-            RMap<String, T> rMap = getClient().getMap(key);
-            rMap.putAll(dataMap);
-        }
-    }
-
-    /**
-     * 注册Map监听器
-     * <p>
-     * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
-     *
-     * @param key      缓存的键值
-     * @param listener 监听器配置
-     */
-    public <T> void addMapListener(final String key, final ObjectListener listener) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        rMap.addListener(listener);
-    }
-
-    /**
-     * 获得缓存的Map
-     *
-     * @param key 缓存的键值
-     * @return map对象
-     */
-    public <T> Map<String, T> getCacheMap(final String key) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        return rMap.getAll(rMap.keySet());
-    }
-
-    /**
-     * 获得缓存Map的key列表
-     *
-     * @param key 缓存的键值
-     * @return key列表
-     */
-    public <T> Set<String> getCacheMapKeySet(final String key) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        return rMap.keySet();
-    }
-
-    /**
-     * 往Hash中存入数据
-     *
-     * @param key   Redis键
-     * @param hKey  Hash键
-     * @param value 值
-     */
-    public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        rMap.put(hKey, value);
-    }
-
-    /**
-     * 获取Hash中的数据
-     *
-     * @param key  Redis键
-     * @param hKey Hash键
-     * @return Hash中的对象
-     */
-    public <T> T getCacheMapValue(final String key, final String hKey) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        return rMap.get(hKey);
-    }
-
-    /**
-     * 删除Hash中的数据
-     *
-     * @param key  Redis键
-     * @param hKey Hash键
-     * @return Hash中的对象
-     */
-    public <T> T delCacheMapValue(final String key, final String hKey) {
-        RMap<String, T> rMap = getClient().getMap(key);
-        return rMap.remove(hKey);
-    }
-
-    /**
-     * 获取多个Hash中的数据
-     *
-     * @param key   Redis键
-     * @param hKeys Hash键集合
-     * @return Hash对象集合
-     */
-    public <K, V> Map<K, V> getMultiCacheMapValue(final String key, final Set<K> hKeys) {
-        RMap<K, V> rMap = getClient().getMap(key);
-        return rMap.getAll(hKeys);
-    }
-
-    /**
-     * 设置原子值
-     *
-     * @param key   Redis键
-     * @param value 值
-     */
-    public void setAtomicValue(String key, long value) {
-        RAtomicLong atomic = getClient().getAtomicLong(key);
-        atomic.set(value);
-    }
-
-    /**
-     * 获取原子值
-     *
-     * @param key Redis键
-     * @return 当前值
-     */
-    public long getAtomicValue(String key) {
-        RAtomicLong atomic = getClient().getAtomicLong(key);
-        return atomic.get();
-    }
-
-    /**
-     * 递增原子值
-     *
-     * @param key Redis键
-     * @return 当前值
-     */
-    public long incrAtomicValue(String key) {
-        RAtomicLong atomic = getClient().getAtomicLong(key);
-        return atomic.incrementAndGet();
-    }
-
-    /**
-     * 递减原子值
-     *
-     * @param key Redis键
-     * @return 当前值
-     */
-    public long decrAtomicValue(String key) {
-        RAtomicLong atomic = getClient().getAtomicLong(key);
-        return atomic.decrementAndGet();
-    }
-
-    /**
-     * 获得缓存的基本对象列表
-     *
-     * @param pattern 字符串前缀
-     * @return 对象列表
-     */
-    public Collection<String> keys(final String pattern) {
-        Stream<String> stream = getClient().getKeys().getKeysStreamByPattern(getNameMapper().map(pattern));
-        return stream.map(key -> getNameMapper().unmap(key)).collect(Collectors.toList());
-    }
-
-    /**
-     * 删除缓存的基本对象列表
-     *
-     * @param pattern 字符串前缀
-     */
-    public void deleteKeys(final String pattern) {
-        getClient().getKeys().deleteByPattern(getNameMapper().map(pattern));
-    }
-
-    /**
-     * 检查redis中是否存在key
-     *
-     * @param key 键
-     */
-    public Boolean hasKey(String key) {
-        RKeys rKeys = getClient().getKeys();
-        return rKeys.countExists(getNameMapper().map(key)) > 0;
-    }
-
-    /**
-     * 尝试加锁
-     *
-     * @param key   lock key
-     * @param value lock value
-     * @return true 加锁成功, false 加锁失败
-     */
-    public boolean tryLock(String key, String value, long timeToLive, TimeUnit timeUnit) {
-        RBucket<Object> bucket = getClient().getBucket(key);
-        return bucket.trySet(value, timeToLive, timeUnit);
-    }
-
-    /**
-     * 解锁
-     *
-     * @param key   lock key
-     * @param value lock value
-     */
-    public void unLock(String key, String value) {
-        String DEL_LOCK_SCRIPT = "if redis.call(\"get\",KEYS[1]) == ARGV[1] then" +      // 如果 KEYS[1] 对应的 Value 值等于 ARGV[1]
-            " return redis.call(\"del\",KEYS[1])" +         // 删除 KEYS[1]
-            " else" +                                       // 否则
-            " return 0" +                                   // 返回 0
-            " end;";
-        getClient().getScript().eval(RScript.Mode.READ_WRITE, DEL_LOCK_SCRIPT, RScript.ReturnType.INTEGER, Collections.singletonList(key), value);
-    }
-
-}

+ 0 - 165
train-demo/src/main/java/top/haijunit/train/websocket/WebSocketServer.java

@@ -1,165 +0,0 @@
-package top.haijunit.train.websocket;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import jakarta.websocket.*;
-import jakarta.websocket.server.PathParam;
-import jakarta.websocket.server.ServerEndpoint;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description websocket服务接口
- */
-@Component
-@ServerEndpoint("/socket/{uid}")
-@Slf4j
-public class WebSocketServer {
-
-    /**
-     * 记录当前在线连接数
-     */
-    private static int onlineCount = 0;
-
-    /**
-     * 使用线程安全的ConcurrentHashMap来存放每个客户端对应的WebSocket对象
-     */
-    private static final ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
-
-    /**
-     * 与某个客户端的连接会话,需要通过它来给客户端发送数据
-     */
-    private Session session;
-
-    /**
-     * 接收客户端消息的uid
-     */
-    private String uid = "";
-
-    /**
-     * 连接建立成功调用的方法
-     * @param session
-     * @param uid
-     */
-    @OnOpen
-    public void onOpen(Session session, @PathParam("uid") String uid) {
-        this.session = session;
-        this.uid = uid;
-        if (webSocketMap.containsKey(uid)) {
-            webSocketMap.remove(uid);
-            //加入到set中
-            webSocketMap.put(uid, this);
-        } else {
-            //加入set中
-            webSocketMap.put(uid, this);
-            //在线数加1
-            addOnlineCount();
-        }
-
-        log.info("用户【" + uid + "】连接成功,当前在线人数为:" + getOnlineCount());
-        try {
-            sendMsg("连接成功");
-        } catch (IOException e) {
-            log.error("用户【" + uid + "】网络异常!", e);
-        }
-    }
-
-    /**
-     * 连接关闭调用的方法
-     */
-    @OnClose
-    public void onClose() {
-        if (webSocketMap.containsKey(uid)) {
-            webSocketMap.remove(uid);
-            //从set中删除
-            subOnlineCount();
-        }
-        log.info("用户【" + uid + "】退出,当前在线人数为:" + getOnlineCount());
-    }
-
-    /**
-     * 收到客户端消息后调用的方法
-     * @param message 客户端发送过来的消息
-     * @param session 会话
-     */
-    @OnMessage
-    public void onMessage(String message, Session session) {
-        log.info("用户【" + uid + "】发送报文:" + message);
-        //群发消息
-        //消息保存到数据库或者redis
-        if (StringUtils.isNotBlank(message)) {
-            try {
-                //解析发送的报文
-                ObjectMapper objectMapper = new ObjectMapper();
-                Map<String, String> map = objectMapper.readValue(message, new TypeReference<Map<String, String>>(){});
-                //追加发送人(防止串改)
-                map.put("fromUID", this.uid);
-                String toUID = map.get("toUID");
-                //传送给对应的toUserId用户的WebSocket
-                if (StringUtils.isNotBlank(toUID) && webSocketMap.containsKey(toUID)) {
-                    webSocketMap.get(toUID).sendMsg(objectMapper.writeValueAsString(map));
-                } else {
-                    //若果不在这个服务器上,可以考虑发送到mysql或者redis
-                    log.error("请求目标用户【" + toUID + "】不在该服务器上");
-                }
-            } catch (Exception e) {
-                log.error("用户【" + uid + "】发送消息异常!", e);
-            }
-        }
-    }
-
-    /**
-     * 处理错误
-     * @param session
-     * @param error
-     */
-    @OnError
-    public void onError(Session session, Throwable error) {
-        log.error("用户【" + this.uid + "】处理消息错误,原因:" + error.getMessage());
-        error.printStackTrace();
-    }
-
-    /**
-     * 实现服务器主动推送
-     * @param msg
-     * @throws IOException
-     */
-    private void sendMsg(String msg) throws IOException {
-        this.session.getBasicRemote().sendText(msg);
-    }
-
-    /**
-     * 发送自定义消息
-     * @param message
-     * @param uid
-     * @throws IOException
-     */
-    public static void sendInfo(String message, @PathParam("uid") String uid) throws IOException {
-        log.info("发送消息到用户【" + uid + "】发送的报文:" + message);
-        if (!StringUtils.isEmpty(uid) && webSocketMap.containsKey(uid)) {
-            webSocketMap.get(uid).sendMsg(message);
-        } else {
-            log.error("用户【" + uid + "】不在线!");
-        }
-    }
-
-    private static synchronized int getOnlineCount() {
-        return onlineCount;
-    }
-
-    private static synchronized void addOnlineCount() {
-        WebSocketServer.onlineCount++;
-    }
-
-    private static synchronized void subOnlineCount() {
-        WebSocketServer.onlineCount--;
-    }
-
-}

+ 0 - 71
train-demo/src/main/resources/application-demo.yml

@@ -1,71 +0,0 @@
-server:
-  port: 8686
-  servlet:
-    context-path: /
-  undertow:
-    max-http-post-size: -1
-    buffer-size: 512
-    direct-buffers: true
-    threads:
-      io: 8
-      worker: 256
-spring:
-  application:
-    name: server-train
-  profiles:
-    active: @profiles.active@
-  servlet:
-    multipart:
-      max-file-size: 10MB
-      max-request-size: 20MB
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    serialization:
-      indent_output: false
-      fail_on_empty_beans: false
-    deserialization:
-      fail_on_unknown_properties: false
-  mvc:
-    format:
-      date-time: yyyy-MM-dd HH:mm:ss
-  liquibase:
-    enabled: true
-    change-log: classpath:/db/changelog/db-server.xml
-  datasource:
-    driver-class-name: org.h2.Driver
-    type: com.zaxxer.hikari.HikariDataSource
-    url: jdbc:h2:./store/db_train;IGNORECASE=TRUE;MODE=MySQL;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9090;USER=root;PASSWORD=123456
-    username: root
-    password: 123456
-    hikari:
-      minimum-idle: 10
-      maximum-pool-size: 20
-      connectionTimeout: 30000
-      validationTimeout: 5000
-      idleTimeout: 600000
-      maxLifetime: 1800000
-      connectionTestQuery: SELECT 1
-      keepaliveTime: 30000
-  freemarker:
-    enabled: true
-    request-context-attribute: request
-    prefix: /templates/
-    suffix: .html
-    content-type: text/html
-    cache: false
-    charset: UTF-8
-    allow-request-override: false
-    expose-request-attributes: true
-    expose-session-attributes: true
-    expose-spring-macro-helpers: true
-  h2:
-    console:
-      path: /h2
-      settings:
-        trace: false
-        web-allow-others: true
-logging:
-  level:
-    com.example: @logging.level@
-    org.springframework: warn
-  config: classpath:/logback.xml

+ 0 - 97
train-demo/src/main/resources/application.yml

@@ -1,97 +0,0 @@
-train:
-  routes:
-    - S0102
-    - S0104
-    - S0202
-    - S0204
-    - S0302
-    - S0304
-    - S0306
----
-server:
-  port: 8086
-  servlet:
-    encoding:
-      charset: UTF-8
-      force: true
-    context-path: /
-  undertow:
-    max-http-post-size: -1
-    buffer-size: 512
-    direct-buffers: true
-    threads:
-      io: 8
-      worker: 256
-spring:
-  application:
-    name: train-server
-  profiles:
-    active: @profiles.active@
-  servlet:
-    multipart:
-      max-file-size: 10MB
-      max-request-size: 20MB
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    serialization:
-      indent_output: false
-      fail_on_empty_beans: false
-    deserialization:
-      fail_on_unknown_properties: false
-  mvc:
-    format:
-      date-time: yyyy-MM-dd HH:mm:ss
-  liquibase:
-    enabled: true
-    change-log: classpath:/db/changelog/db-server.xml
-  datasource:
-    type: com.zaxxer.hikari.HikariDataSource
-    driver-class-name: org.h2.Driver
-    url: jdbc:h2:./store/db_train;IGNORECASE=TRUE;MODE=MySQL;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9090;USER=root;PASSWORD=123456
-    username: root
-    password: 123456
-    hikari:
-      minimum-idle: 10
-      maximum-pool-size: 20
-      connectionTimeout: 30000
-      validationTimeout: 5000
-      idleTimeout: 600000
-      maxLifetime: 1800000
-      connectionTestQuery: SELECT 1
-      keepaliveTime: 30000
-  freemarker:
-    enabled: true
-    request-context-attribute: request
-    prefix: /templates/
-    suffix: .html
-    content-type: text/html
-    cache: false
-    charset: UTF-8
-    allow-request-override: false
-    expose-request-attributes: true
-    expose-session-attributes: true
-    expose-spring-macro-helpers: true
-  h2:
-    console:
-      enabled: true
-      path: /h2
-      settings:
-        trace: false
-        web-allow-others: true
-logging:
-  level:
-    top.haijunit: @logging.level@
-    org.springframework: warn
-    org.hibernate.validator: warn
-    org.apache: warn
-  config: classpath:logback.xml
-
-# MyBatisPlus配置
-# https://baomidou.com/config/
-mybatis-plus:
-  mapperPackage: top.haijunit.train.**.mapper
-  mapperLocations: classpath*:mapper/**/*Mapper.xml
-  typeAliasesPackage: top.haijunit.**.domain
-  global-config:
-    dbConfig:
-      idType: ASSIGN_ID

+ 0 - 210
train-demo/src/main/resources/db/changelog/db-server-train-1.xml

@@ -1,210 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<databaseChangeLog
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
-    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
-
-    <changeSet id="db_signal" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_signal" schemaName="${schema.name}" remarks="信号灯">
-            <column name="id" type="VARCHAR(128)" autoIncrement="true" remarks="唯一标识">
-                <constraints nullable="false" primaryKey="true"/>
-            </column>
-            <column name="name" type="VARCHAR(128)" defaultValue="" remarks="名称"/>
-            <column name="code" type="VARCHAR(64)" defaultValue="" remarks="编号"/>
-            <column name="kilometer" type="DOUBLE(10,5)" defaultValueNumeric="0" remarks="公里标(单位Km)"/>
-            <column name="color_state" type="VARCHAR(64)" defaultValue="" remarks="状态:红、绿、黄、红黄"/>
-            <column name="selection_id" type="VARCHAR(128)" defaultValue="" remarks="区段号"/>
-            <column name="direction" type="VARCHAR(128)" defaultValue="" remarks="上行、下行"/>
-            <column name="station_id" type="VARCHAR(64)" defaultValue="" remarks="归属车站/编码 "/>
-        </createTable>
-    </changeSet>
-    <changeSet id="load-sign-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_signal" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData file="db_signal.txt" tableName="db_signal" primaryKey="id" relativeToChangelogFile="true" quotchar="'"  catalogName="${catalog.name}" schemaName="${schema.name}" >
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-            <column name="kilometer" type="STRING"/>
-            <column name="color_state" type="STRING"/>
-            <column name="selection_id" type="NUMERIC"/>
-            <column name="direction" type="STRING"/>
-            <column name="station_id" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-    <changeSet id="db_switch" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_switch" schemaName="${schema.name}" remarks="道岔">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="name" type="VARCHAR128" defaultValue="" remarks="名称"/>
-            <column name="kilometer" type="VARCHAR128" defaultValue="" remarks="公里标"/>
-            <column name="type" type="VARCHAR128" defaultValue="" remarks="类型"/>
-            <column name="pre_selection_id" type="VARCHAR128" defaultValue="" remarks="岔前区段号"/>
-            <column name="next_selection_id" type="VARCHAR128" defaultValue="" remarks="岔后区段号"/>
-            <column name="next_side_selection_id" type="VARCHAR128" defaultValue="" remarks="岔后侧向区段号"/>
-            <column name="station_id" type="VARCHAR128" defaultValue="" remarks="所属车站编号"/>
-        </createTable>
-    </changeSet>
-	<changeSet id="load-switch-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_switch" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData catalogName="${catalog.name}" schemaName="${schema.name}" tableName="db_switch" file="db_switch.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'">
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-            <column name="kilometer" type="STRING"/>
-            <column name="type" type="STRING"/>
-            <column name="preSelectionId" type="STRING"/>
-            <column name="nextSelectionId" type="STRING"/>
-            <column name="nextSideSelectionId" type="STRING"/>
-            <column name="stationId" type="STRING"/>
-
-        </loadUpdateData>
-    </changeSet>
-
-    <changeSet id="db_station" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_station" schemaName="${schema.name}" remarks="车站">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="name" type="VARCHAR128" defaultValue="" remarks="名称"/>
-        </createTable>
-    </changeSet>
-	  <changeSet id="load-station-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_station" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_station" file="db_station.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}" >
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-
-    <changeSet id="db_platform" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_platform" schemaName="${schema.name}" remarks="站台">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="stationId" type="VARCHAR128" defaultValue="" remarks="所属车站"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="上下行"/>
-            <column name="stopTime" type="VARCHAR128" defaultValue="" remarks="默认停站时间"/>
-        </createTable>
-    </changeSet>
-	<changeSet id="load-platform-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_platform" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_platform" file="db_platform.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'"catalogName="${catalog.name}" schemaName="${schema.name}" >
-            <column name="id" type="STRING"/>
-            <column name="stationId" type="STRING"/>
-            <column name="direction" type="STRING"/>
-            <column name="stopTime" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-    <changeSet id="db_selection" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_selection" schemaName="${schema.name}" remarks="区段">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="name" type="VARCHAR128" defaultValue="" remarks="名称"/>
-            <column name="startKilometer" type="VARCHAR128" defaultValue="" remarks="起始公里标"/>
-            <column name="length" type="VARCHAR128" defaultValue="" remarks="长度"/>
-            <column name="preId" type="VARCHAR128" defaultValue="" remarks="前一区段号"/>
-            <column name="nextId" type="VARCHAR128" defaultValue="" remarks="后一区段号"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="上下行"/>
-            <column name="zfState" type="VARCHAR128" defaultValue="" remarks="折返标志"/>
-            <column name="stationId" type="VARCHAR128" defaultValue="" remarks="所属车站编号"/>
-        </createTable>
-    </changeSet>
-	<changeSet id="load-selection-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_selection" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_selection" file="db_selection.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}">
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-            <column name="startKilometer" type="STRING"/>
-            <column name="length" type="STRING"/>
-            <column name="preId" type="STRING"/>
-            <column name="nextId" type="STRING"/>
-            <column name="direction" type="STRING"/>
-            <column name="zfState" type="STRING"/>
-            <column name="stationId" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-    <changeSet id="db_emergencyStop" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_emergencyStop" schemaName="${schema.name}" remarks="紧急停车按钮">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="stationId" type="VARCHAR128" defaultValue="" remarks="所属站台"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="上下行"/>
-        </createTable>
-    </changeSet>
-	 <changeSet id="load-emergencyStop-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_emergencyStop" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_emergencyStop" file="db_emergencyStop.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}">
-            <column name="id" type="STRING"/>
-            <column name="stationId" type="STRING"/>
-            <column name="direction" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-
-    <changeSet id="db_route" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_route" schemaName="${schema.name}" remarks="进路">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="name" type="VARCHAR128" defaultValue="" remarks="进路名称"/>
-            <column name="signalIds" type="VARCHAR128" defaultValue="" remarks="关联信号机"/>
-            <column name="signalState" type="VARCHAR128" defaultValue="" remarks="关联信号机状态"/>
-            <column name="seleIds" type="VARCHAR128" defaultValue="" remarks="关联区段列表"/>
-            <column name="switch_id" type="VARCHAR128" defaultValue="" remarks="关联道岔"/>
-            <column name="switchState" type="VARCHAR128" defaultValue="" remarks="关联道岔状态"/>
-            <column name="trigPosition" type="VARCHAR128" defaultValue="" remarks="触发点位置"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="进路方向"/>
-        </createTable>
-    </changeSet>
-	 <changeSet id="load-route-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_route" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_route" file="db_route.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}">
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-            <column name="signalIds" type="STRING"/>
-            <column name="signalState" type="STRING"/>
-            <column name="seleIds" type="STRING"/>
-            <column name="switch_id" type="STRING"/>
-            <column name="switchState" type="STRING"/>
-            <column name="trigPosition" type="STRING"/>
-            <column name="direction" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-
-    <changeSet id="db_stopSign" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_stopSign" schemaName="${schema.name}" remarks="停车标">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="stationId" type="VARCHAR128" defaultValue="" remarks="所属站台"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="上下行"/>
-            <column name="selectionId" type="VARCHAR128" defaultValue="" remarks="所属区段号"/>
-            <column name="selectionOff" type="VARCHAR128" defaultValue="" remarks="所属区段偏移"/>
-        </createTable>
-    </changeSet>
-	<changeSet id="load-stopSign-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_stopSign" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_stopSign" file="db_stopSign.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}">
-            <column name="id" type="STRING"/>
-            <column name="stationId" type="STRING"/>
-            <column name="direction" type="STRING"/>
-            <column name="selectionId" type="STRING"/>
-            <column name="selectionOff" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-    <changeSet id="db_train" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_train" schemaName="${schema.name}" remarks="列车">
-            <column name="id" type="VARCHAR128" defaultValue="" remarks="编号"/>
-            <column name="name" type="VARCHAR128" defaultValue="" remarks="车次号"/>
-            <column name="length" type="VARCHAR128" defaultValue="" remarks="长度"/>
-            <column name="initKilometer" type="VARCHAR128" defaultValue="" remarks="初始位置公里标"/>
-            <column name="direction" type="VARCHAR128" defaultValue="" remarks="初始运行方向"/>
-        </createTable>
-    </changeSet>
-
-	 <changeSet id="load-train-data" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <delete tableName="db_train" catalogName="${catalog.name}" schemaName="${schema.name}"/>
-        <loadUpdateData tableName="db_train" file="db_train.txt" relativeToChangelogFile="true" primaryKey="id" quotchar="'" catalogName="${catalog.name}" schemaName="${schema.name}">
-            <column name="id" type="STRING"/>
-            <column name="name" type="STRING"/>
-            <column name="length" type="STRING"/>
-            <column name="initKilometer" type="STRING"/>
-            <column name="direction" type="STRING"/>
-        </loadUpdateData>
-    </changeSet>
-
-</databaseChangeLog>
-

+ 0 - 55
train-demo/src/main/resources/db/changelog/db-server-train.xml

@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<databaseChangeLog
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
-    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
-
-    <changeSet id="createTable-db_sign" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_sign" schemaName="${schema.name}" remarks="轨道点位表">
-            <column name="id" type="${autoing.type}" autoIncrement="true" remarks="唯一标识">
-                <constraints nullable="false" primaryKey="true"/>
-            </column>
-            <column name="name" type="VARCHAR(128)" defaultValue="" remarks="名称"/>
-            <column name="code" type="VARCHAR(64)" defaultValue="" remarks="编号"/>
-            <column name="kilometer" type="DOUBLE(10,5)" defaultValueNumeric="0" remarks="公里标(单位Km)"/>
-            <column name="direction" type="VARCHAR(64)" defaultValue="" remarks="上行/下行"/>
-            <column name="sign_status" type="VARCHAR(128)" defaultValue="" remarks="状态行"/>
-            <column name="sign_type" type="VARCHAR(128)" defaultValue="" remarks="点位类型"/>
-
-            <column name="station_code" type="VARCHAR(64)" defaultValue="" remarks="归属车站/编码 "/>
-            <column name="station_name" type="VARCHAR(128)" defaultValue="" remarks="归属车站/名称 "/>
-            <column name="selection_name" type="VARCHAR(128)" defaultValue="" remarks="所在区段名称"/>
-
-            <column name="create_time" type="datetime" remarks="创建时间"/>
-            <column name="create_by" type="${autoing.type}" remarks="创建者"/>
-            <column name="update_time" type="datetime" remarks="更新时间"/>
-            <column name="update_by" type="${autoing.type}" remarks="更新者"/>
-        </createTable>
-    </changeSet>
-
-    <changeSet id="load-sign-data11" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <sql splitStatements="true" stripComments="true">
-            delete from db_sign;
-        </sql>
-        <loadUpdateData catalogName="${catalog.name}"
-                        schemaName="${schema.name}"
-                        tableName = "db_sign"
-                        file="db_sign.txt"
-                        relativeToChangelogFile="true"
-                        primaryKey="code"
-                        quotchar="'"
-                        separator=","
-                        encoding="UTF-8">
-            <column name = "station_code" type="STRING" />
-            <column name = "station_name" type="STRING" />
-            <column name = "code" type="STRING" />
-            <column name = "name" type="STRING" />
-            <column name = "kilometer" type="NUMERIC" />
-            <column name = "direction" type="STRING" />
-            <column name = "sign_type" type="STRING" />
-            <column name = "selection_name" type="STRING" />
-        </loadUpdateData>
-    </changeSet>
-
-</databaseChangeLog>
-

+ 0 - 52
train-demo/src/main/resources/db/changelog/db-server.xml

@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<databaseChangeLog
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
-    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
-
-    <property name="schema.name" value="${database.defaultSchemaName}"/>
-    <property name="catalog.name" value="${database.defaultCatalogName}"/>
-
-    <property name="clob.type" value="longtext" dbms="h2"/>
-    <property name="clob.type" value="longtext" dbms="mysql,mariadb"/>
-    <property name="clob.type" value="clob"/>
-
-    <property name="autoing.type" value="bigint(20)" dbms="h2"/>
-    <property name="autoing.type" value="bigint(20)" dbms="mysql,mariadb"/>
-    <property name="autoing.type" value="serial"/>
-
-    <property name="number.type" value="bigint" dbms="h2"/>
-    <property name="number.type" value="int" dbms="mysql,mariadb"/>
-    <property name="number.type" value="serial"/>
-
-    <property name="now" value="now()" dbms="h2"/>
-    <property name="now" value="now()" dbms="mysql,mariadb"/>
-    <property name="now" value="sysdate"/>
-
-    <changeSet author="zhanghaijun" id="mysql_charsets_change" runOnChange="true" runAlways="true" failOnError="false" dbms="mysql,mariadb">
-        <validCheckSum>ANY</validCheckSum>
-        <sql dbms="mysql,mariadb" splitStatements="true" stripComments="true">
-            ALTER DATABASE ${schema.name} DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin
-        </sql>
-    </changeSet>
-
-    <changeSet id="demo" author="zhanghaijun" failOnError="false" runOnChange="true">
-        <createTable tableName="db_user" schemaName="${schema.name}" remarks="用户表">
-            <column name="user_id" type="${autoing.type}" autoIncrement="true" remarks="用户Id">
-                <constraints nullable="false" primaryKey="true"/>
-            </column>
-            <column name="username" type="VARCHAR(255)" defaultValue="" remarks="用户名称"/>
-            <column name="email" type="VARCHAR(128)" defaultValue="" remarks="邮箱地址"/>
-
-            <column name="status" type="${number.type}" defaultValue="1" remarks="数据状态"/>
-            <column name="create_time" type="datetime" remarks="创建时间"/>
-            <column name="create_by" type="${autoing.type}" remarks="创建者"/>
-            <column name="update_time" type="datetime" remarks="更新时间"/>
-            <column name="update_by" type="${autoing.type}" remarks="更新者"/>
-        </createTable>
-    </changeSet>
-
-    <include relativeToChangelogFile="true" file="db-server-train.xml"/>
-
-</databaseChangeLog>
-

+ 0 - 17
train-demo/src/main/resources/db/changelog/db_sign.txt

@@ -1,17 +0,0 @@
-station_code,station_name,code,name,kilometer,direction,sign_type,sign_status,selection_name
-T001,A站,S0101,S0101,250,up,MachineSign,disable,T0101|T0103
-T001,A站,S0102,S0102,250,down,MachineSign,disable,T0102|T0104
-T001,A站,S0103,S0103,1250,up,MachineSign,disable,T0103|T0105
-T001,A站,S0104,S0104,1250,down,MachineSign,disable,T0104|T0106
-T001,A站,S0105,S0105,1750,up,MachineSign,disable,T0105|T0107
-T001,A站,S0106,S0106,1750,down,MachineSign,disable,T0106|T0108
-T002,B站,S0201,S0201,4750,up,MachineSign,disable,T0107|T0203
-T002,B站,S0202,S0202,4750,down,MachineSign,disable,T0108|T0202
-T002,B站,S0203,S0203,5250,up,MachineSign,disable,T0203|T0205
-T002,B站,S0204,S0204,5250,down,MachineSign,disable,T0202|T0204
-T003,C站,S0301,S0301,8250,up,MachineSign,disable,T0205|T0301
-T003,C站,S0302,S0302,8250,down,MachineSign,disable,T0204|T0302
-T003,C站,S0303,S0303,8750,up,MachineSign,disable,T0301|T0303
-T003,C站,S0304,S0304,8750,down,MachineSign,disable,T0302|T0304
-T003,C站,S0305,S0305,9750,up,MachineSign,disable,T0303|T0305
-T003,C站,S0306,S0306,9750,down,MachineSign,disable,T0304|T0306

+ 0 - 2
train-demo/src/main/resources/db/changelog/信号灯-signal.txt

@@ -1,2 +0,0 @@
-id,name,kilometer,colorState,selectionId,direction,stationId
-编号,名称,公里标,状态,区段号,类型,车站编号

+ 0 - 3
train-demo/src/main/resources/db/changelog/停车标-stopSign.txt

@@ -1,3 +0,0 @@
-id,stationId,direction,selectionId,selectionOff
-编号,所属站台,上下行,所属区段号,所属区段偏移
-

+ 0 - 2
train-demo/src/main/resources/db/changelog/列车-train.txt

@@ -1,2 +0,0 @@
-id,name,length,initKilometer,direction
-编号,车次号,长度,初始位置公里标,初始运行方向

+ 0 - 3
train-demo/src/main/resources/db/changelog/区段-selection.txt

@@ -1,3 +0,0 @@
-id,name,startKilometer,length,preId,nextId,direction,zfState,stationId
-编号,名称,起始公里标,长度,前一区段号,后一区段号,上下行,折返标志,所属车站编号
-

+ 0 - 2
train-demo/src/main/resources/db/changelog/站台-platform.txt

@@ -1,2 +0,0 @@
-id,stationId,direction,stopTime
-编号,所属车站,上下行,默认停站时间

+ 0 - 2
train-demo/src/main/resources/db/changelog/站台门-stationDoor.txt

@@ -1,2 +0,0 @@
- id,stationId,direction
- 编号,所属站台,上下行

+ 0 - 3
train-demo/src/main/resources/db/changelog/紧急停车按钮-emergencyStop.txt

@@ -1,3 +0,0 @@
-id,stationId,direction
-编号,所属站台,上下行
-

+ 0 - 2
train-demo/src/main/resources/db/changelog/车站-station.txt

@@ -1,2 +0,0 @@
-id,name
-编号,名称

+ 0 - 3
train-demo/src/main/resources/db/changelog/进路-route.txt

@@ -1,3 +0,0 @@
-id,name,signalIds,signalState,seleIds,switch,switchState,trigPosition,direction
-编号,进路名称,关联信号机,关联信号机状态,关联区段列表,关联道岔,关联道岔状态,触发点位置,进路方向
-

+ 0 - 2
train-demo/src/main/resources/db/changelog/道岔-switch.txt

@@ -1,2 +0,0 @@
-id,name,kilometer,type,preSelectionId,nextSelectionId,nextSideSelectionId,stationId
-编号,名称,类型,岔前区段号,岔后区段号,岔后侧向区段号,所属车站编号

+ 0 - 106
train-demo/src/main/resources/logback.xml

@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs"/>
-    <property name="console.log.pattern" value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) - %msg%n"/>
-    <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${console.log.pattern}</pattern>
-            <charset>utf-8</charset>
-        </encoder>
-    </appender>
-    <!-- 控制台输出 -->
-    <appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/console.log</file>
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/console.log</fileNamePattern>
-            <!-- 日志最大 7天 -->
-            <maxHistory>7</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-            <charset>utf-8</charset>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-        </filter>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/info.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/%d{yyyy-MM-dd}/error.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- info异步输出 -->
-    <appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
-        <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
-        <discardingThreshold>0</discardingThreshold>
-        <!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
-        <queueSize>512</queueSize>
-        <!-- 添加附加的appender,最多只能添加一个 -->
-        <appender-ref ref="file_info"/>
-    </appender>
-
-    <!-- error异步输出 -->
-    <appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
-        <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
-        <discardingThreshold>0</discardingThreshold>
-        <!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
-        <queueSize>512</queueSize>
-        <!-- 添加附加的appender,最多只能添加一个 -->
-        <appender-ref ref="file_error"/>
-    </appender>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="console"/>
-        <appender-ref ref="async_info"/>
-        <appender-ref ref="async_error"/>
-        <appender-ref ref="file_console"/>
-    </root>
-</configuration>

+ 0 - 10
train-demo/src/main/resources/static/index.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>Title</title>
-</head>
-<body>
-
-</body>
-</html>

+ 0 - 75
train-demo/src/main/resources/templates/webSocket.html

@@ -1,75 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <title>WebSocket消息通知</title>
-</head>
-<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
-<script>
-    var socket;
-    //打开WebSocket
-    function openSocket() {
-        if (typeof (WebSocket) === "undefined") {
-            console.log("您的浏览器不支持WebSocket");
-        } else {
-            console.log("您的浏览器支持WebSocket");
-            //实现化WebSocket对象,指定要连接的服务器地址与端口,建立连接.
-            var socketUrl = "http://localhost:8086/socket/" + $("#uid").val();
-            //将https与http协议替换为ws协议
-            socketUrl = socketUrl.replace("https", "ws").replace("http", "ws");
-            console.log(socketUrl);
-            if (socket != null) {
-                socket.close();8
-                socket = null;
-            }
-            socket = new WebSocket(socketUrl);
-            //打开事件
-            socket.onopen = function () {
-                console.log("WebSocket已打开");
-                //socket.send("这是来自客户端的消息" + location.href + new Date());
-            };
-            //获得消息事件
-            socket.onmessage = function (msg) {
-                console.log(msg.data);
-                //发现消息进入,开始处理前端触发逻辑
-            };
-            //关闭事件
-            socket.onclose = function () {
-                console.log("WebSocket已关闭");
-            };
-            //发生了错误事件
-            socket.onerror = function () {
-                console.log("WebSocket发生了错误");
-            }
-        }
-    }
-
-    //发送消息
-    function sendMessage() {
-        if (typeof (WebSocket) === "undefined") {
-            console.log("您的浏览器不支持WebSocket");
-        } else {
-            console.log("您的浏览器支持WebSocket");
-            console.log('{"toUID":"' + $("#toUID").val() + '","Msg":"' + $("#msg").val() + '"}');
-            socket.send('{"toUID":"' + $("#toUID").val() + '","Msg":"' + $("#msg").val() + '"}');
-        }
-    }
-</script>
-<body>
-<p>【uid】:
-<div><input id="uid" name="uid" type="text" value="1"></div>
-<p>【toUID】:
-<div><input id="toUID" name="toUID" type="text" value="2"></div>
-<p>【Msg】:
-<div><input id="msg" name="msg" type="text" value="hello WebSocket2"></div>
-<p>【第一步操作:】:
-<div>
-    <button onclick="openSocket()">开启socket</button>
-</div>
-<p>【第二步操作:】:
-<div>
-    <button onclick="sendMessage()">发送消息</button>
-</div>
-</body>
-
-</html>

+ 0 - 13
train-demo/src/test/java/top/haijunit/train/TrainDemoMainTests.java

@@ -1,13 +0,0 @@
-package top.haijunit.train;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class TrainDemoMainTests {
-
-    @Test
-    void contextLoads() {
-    }
-
-}

+ 0 - 91
train-demo/src/test/java/top/haijunit/train/mapper/UserMapperTest.java

@@ -1,91 +0,0 @@
-package top.haijunit.train.mapper;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import jakarta.annotation.Resource;
-import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-import top.haijunit.train.domain.UserEntity;
-
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class UserMapperTest {
-    @Resource
-    private UserMapper userMapper;
-
-    /**
-     * 测试单条查询
-     */
-    @Test
-    public void testSelectOne() {
-        UserEntity user = userMapper.selectById(1L);
-        System.out.println(user);
-    }
-
-    /**
-     * 测试新增
-     */
-    @Test
-    public void testInsert() {
-        UserEntity user = new UserEntity();
-        user.setUsername("kk");
-        user.setEmail("kk@qq.com");
-        assertThat(userMapper.insert(user)).isGreaterThan(0);
-        assertThat(user.getUserId()).isNotNull();
-    }
-
-    /**
-     * 测试删除
-     */
-    @Test
-    public void testDelete() {
-        assertThat(userMapper.deleteById(3L)).isGreaterThan(0);
-        assertThat(userMapper.delete(new QueryWrapper<UserEntity>()
-            .lambda().eq(UserEntity::getUsername, "kk"))).isGreaterThan(0);
-    }
-
-    /**
-     * 测试更新
-     */
-    @Test
-    public void testUpdate() {
-        UserEntity user = userMapper.selectById(2);
-        assertThat(user.getUsername()).isEqualTo("Jack");
-        userMapper.update(null, Wrappers.<UserEntity>lambdaUpdate().set(UserEntity::getEmail, "zz@qq.com").eq(UserEntity::getUserId, 1));
-        Assertions.assertThat(userMapper.selectById(2).getEmail()).isEqualTo("11@qq.com");
-    }
-
-    /**
-     * 测试查询列表
-     */
-    @Test
-    public void testSelect() {
-        List<UserEntity> userList = userMapper.selectList(null);
-        Assert.assertEquals(5, userList.size());
-    }
-
-    /**
-     * 测试分页查询
-     */
-    @Test
-    public void testPage() {
-        Page<UserEntity> page = new Page<>(1, 2);
-        IPage<UserEntity> userIPage = userMapper.selectPage(page, new QueryWrapper<>());
-        assertThat(page).isSameAs(userIPage);
-        System.out.println("总条数: " + userIPage.getTotal());
-        System.out.println("当前页数: " + userIPage.getCurrent());
-        System.out.println("当前每页显示数: " + userIPage.getSize());
-        System.out.println("记录列表: " + userIPage.getRecords());
-    }
-
-}