添加新的项目

This commit is contained in:
wanglei 2025-09-14 12:49:22 +08:00
commit 52319416ca
43 changed files with 33191 additions and 0 deletions

33
.gitignore vendored Normal file
View File

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

10
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# 依赖于环境的 Maven 主目录路径
/mavenHomeManager.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

14
.idea/compiler.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="SimulationService" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="IU-251.23774.435">
<data-source name="SupportDB@127.0.0.1" uuid="1a857940-0a66-47dc-a5d7-2131554509f4">
<database-info product="MySQL" version="5.5.19" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="5.5.19" exact-driver-version="8.2">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="lower" quoted-identifiers="lower" />
<secret-storage>master_key</secret-storage>
<user-name>root</user-name>
<schema-mapping>
<introspection-scope>
<node kind="schema" qname="@" />
</introspection-scope>
</schema-mapping>
<load-sources>user_and_system_sources</load-sources>
</data-source>
<data-source name="0@127.0.0.1" uuid="a819c07c-fb1e-4a4b-954f-1a0efe084978">
<database-info product="Redis Standalone" version="3.2.100" jdbc-version="4.2" driver-name="Redis JDBC Driver" driver-version="1.5" dbms="REDIS" exact-version="3.2.100" exact-driver-version="1.5" />
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
<secret-storage>master_key</secret-storage>
<schema-mapping>
<introspection-scope>
<node kind="schema" qname="@" />
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>

29
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="SupportDB@127.0.0.1" uuid="1a857940-0a66-47dc-a5d7-2131554509f4">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://127.0.0.1:3306/SupportDB</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="0@127.0.0.1" uuid="a819c07c-fb1e-4a4b-954f-1a0efe084978">
<driver-ref>redis</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>jdbc.RedisDriver</jdbc-driver>
<jdbc-url>jdbc:redis://127.0.0.1:6379/0</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#n:information_schema
!<md> [null, 0, null, null, -2147483648, -2147483648]

View File

@ -0,0 +1,2 @@
#n:mysql
!<md> [null, 0, null, null, -2147483648, -2147483648]

View File

@ -0,0 +1,2 @@
#n:performance_schema
!<md> [null, 0, null, null, -2147483648, -2147483648]

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<dataSource name="0@127.0.0.1">
<database-model serializer="dbm" dbms="REDIS" family-id="REDIS" format-version="4.53">
<root id="1">
<ServerVersion>3.2.100</ServerVersion>
</root>
<schema id="2" parent="1" name="0">
<Current>1</Current>
</schema>
<schema id="3" parent="1" name="1"/>
<schema id="4" parent="1" name="10"/>
<schema id="5" parent="1" name="11"/>
<schema id="6" parent="1" name="12"/>
<schema id="7" parent="1" name="13"/>
<schema id="8" parent="1" name="14"/>
<schema id="9" parent="1" name="15"/>
<schema id="10" parent="1" name="2"/>
<schema id="11" parent="1" name="3"/>
<schema id="12" parent="1" name="4"/>
<schema id="13" parent="1" name="5"/>
<schema id="14" parent="1" name="6"/>
<schema id="15" parent="1" name="7"/>
<schema id="16" parent="1" name="8"/>
<schema id="17" parent="1" name="9"/>
</database-model>
</dataSource>

7
.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

25
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="d332453:19946490ddb:-7fff" />
</MTProjectMetadataState>
</option>
</component>
</project>

75
.idea/mbg-plugin.xml Normal file
View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="persistentStateService">
<option name="generatorProperties">
<GeneratorProperties>
<option name="commonProperties">
<CommonProperties>
<option name="author" value="frankly" />
<option name="basePackage" value="com.simulationservice" />
<option name="basePath" value="src/main/java" />
<option name="databaseComboBoxValue" value="SupportDB@127.0.0.1:3306:MySQL" />
<option name="entityRelativePackage" value="entity" />
<option name="frameworkTypeComboBoxValue" value="MyBatis" />
<option name="frameworkTypeComboBoxValues">
<list>
<option value="MyBatis" />
<option value="TkMyBatis" />
<option value="MyBatisPlus" />
</list>
</option>
<option name="moduleName" value="SimulationService" />
<option name="modulePath" value="$PROJECT_DIR$" />
</CommonProperties>
</option>
<option name="controllerProperties">
<ControllerProperties>
<option name="namePattern" value="%sController" />
<option name="packageName" value="com.simulationservice.controller" />
<option name="path" value="$PROJECT_DIR$/src/main/java/com/simulationservice/controller" />
</ControllerProperties>
</option>
<option name="entityProperties">
<EntityProperties>
<option name="exampleNamePattern" value="%sExample" />
<option name="namePattern" value="%s" />
<option name="packageName" value="com.simulationservice.entity" />
<option name="path" value="$PROJECT_DIR$/src/main/java/com/simulationservice/entity" />
</EntityProperties>
</option>
<option name="mapperProperties">
<MapperProperties>
<option name="namePattern" value="%sMapper" />
<option name="packageName" value="com.simulationservice.mapper" />
<option name="path" value="$PROJECT_DIR$/src/main/java/com/simulationservice/mapper" />
<option name="superMapperClass" value="" />
</MapperProperties>
</option>
<option name="mapperXmlProperties">
<MapperXmlProperties>
<option name="namePattern" value="%sMapper" />
<option name="path" value="$PROJECT_DIR$/src/main/resources/mapper" />
</MapperXmlProperties>
</option>
<option name="serviceImplProperties">
<ServiceImplProperties>
<option name="namePattern" value="%sServiceImpl" />
<option name="packageName" value="com.simulationservice.service.impl" />
<option name="path" value="$PROJECT_DIR$/src/main/java/com/simulationservice/service/impl" />
<option name="selectedGenerateCheckBox" value="true" />
<option name="superServiceImplClass" value="" />
</ServiceImplProperties>
</option>
<option name="serviceProperties">
<ServiceProperties>
<option name="namePattern" value="I%sService" />
<option name="packageName" value="com.simulationservice.service" />
<option name="path" value="$PROJECT_DIR$/src/main/java/com/simulationservice/service" />
<option name="selectedGenerateCheckBox" value="true" />
<option name="superServiceClass" value="" />
</ServiceProperties>
</option>
</GeneratorProperties>
</option>
</component>
</project>

14
.idea/misc.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MyBatisGeneratorConfiguration">
<option name="credentials">
<map>
<entry key="jdbc:mysql://127.0.0.1:3306/SupportDB">
<value>
<Credential>
<option name="username" value="root" />
</Credential>
</value>
</entry>
</map>
</option>
<option name="tableConfigs">
<map>
<entry key="sys_user">
<value>
<TableConfig>
<option name="basePackage" value="com.simulationservice" />
<option name="comment" value="true" />
<option name="domainName" value="SysUser" />
<option name="domainPackage" value="com.simulationservice.domain" />
<option name="exampleName" value="SysUserExample" />
<option name="examplePackage" value="com.simulationservice.example" />
<option name="examplePostfix" value="Example" />
<option name="lombokAnnotation" value="true" />
<option name="mapperName" value="SysUserMapper" />
<option name="mapperPackage" value="com.simulationservice.mapper" />
<option name="mapperPostfix" value="Mapper" />
<option name="moduleRootPath" value="$PROJECT_DIR$" />
<option name="name" value="sys_user" />
<option name="primaryKey" value="Id" />
<option name="resourcePath" value="src/main/resources" />
<option name="sourcePath" value="src/main/java" />
<option name="tableName" value="sys_user" />
<option name="useExample" value="true" />
<option name="xmlPackage" value="mapper" />
</TableConfig>
</value>
</entry>
</map>
</option>
</component>
</project>

119
.idea/workspace.xml Normal file
View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="050b8051-b1ec-42aa-bac3-c1c189a4697d" name="更改" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="KubernetesApiPersistence">{}</component>
<component name="KubernetesApiProvider">{
&quot;isMigrated&quot;: true
}</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="customMavenHome" value="D:\Maven\apache-maven-3.9.11" />
<option name="localRepository" value="D:\Maven\maven_repository" />
<option name="mavenHomeTypeForPersistence" value="CUSTOM" />
<option name="useMavenConfig" value="false" />
<option name="userSettingsFile" value="D:\Maven\apache-maven-3.9.11\conf\settings.xml" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="32RwW7uP5Sl3sYTSqvuyoP4kFtb" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Maven.SimulationService [compile].executor": "Run",
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RequestMappingsPanelOrder0": "0",
"RequestMappingsPanelOrder1": "1",
"RequestMappingsPanelWidth0": "75",
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.ShowReadmeOnStart": "true",
"Spring Boot.SimulationService.executor": "Debug",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "项目",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.37011495",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"DatabaseDriversLRU": [
"redis",
"mysql"
]
}
}]]></component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
<component name="RunManager">
<configuration name="SimulationService" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="SimulationService" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.simulationservice.SimulationServiceApplication" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-jdk-9823dce3aa75-fbdcb00ec9e3-intellij.indexing.shared.core-IU-251.23774.435" />
<option value="bundled-js-predefined-d6986cc7102b-f27c65a3e318-JavaScript-IU-251.23774.435" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="050b8051-b1ec-42aa-bac3-c1c189a4697d" name="更改" comment="" />
<created>1757396723396</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1757396723396</updated>
<workItem from="1757396724355" duration="4224000" />
<workItem from="1757400979509" duration="460000" />
<workItem from="1757401495519" duration="1386000" />
<workItem from="1757402907142" duration="13531000" />
<workItem from="1757487132740" duration="18062000" />
<workItem from="1757551777304" duration="1275000" />
<workItem from="1757594198944" duration="2502000" />
<workItem from="1757664586037" duration="3070000" />
<workItem from="1757820561153" duration="249000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

29
HELP.md Normal file
View File

@ -0,0 +1,29 @@
# Getting Started
### Reference Documentation
For further reference, please consider the following sections:
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.6/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.6/maven-plugin/reference/html/#build-image)
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#web)
* [WebSocket](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#messaging.websockets)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#data.sql.jpa-and-spring-data)
* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#using.devtools)
* [Spring Data Redis (Access+Driver)](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#data.nosql.redis)
* [Spring Data JDBC](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#data.sql.jdbc)
### Guides
The following guides illustrate how to use some features concretely:
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Using WebSocket to build an interactive web application](https://spring.io/guides/gs/messaging-stomp-websocket/)
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/)
* [Messaging with Redis](https://spring.io/guides/gs/messaging-redis/)
* [Using Spring Data JDBC](https://github.com/spring-projects/spring-data-examples/tree/master/jdbc/basics)

BIN
doc/业务流程.vsdx Normal file

Binary file not shown.

150
pom.xml Normal file
View File

@ -0,0 +1,150 @@
<?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>
<groupId>com</groupId>
<artifactId>SimulationService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SimulationService</name>
<description>SimulationService</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.7.6</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- MyBatis Spring Boot Starter -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.2</version>
</dependency>
<!-- MySQL 驱动,如果你的数据库是 MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- json相关 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<!-- 项目文档生成接口 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.4</version>
</dependency>
<!-- 项目文档生成接口 -->
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.112</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.simulationservice.SimulationServiceApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package com.simulationservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SimulationServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SimulationServiceApplication.class, args);
}
}

View File

@ -0,0 +1,9 @@
package com.simulationservice.common;
/**
定义Json数据返回的一些常量
*/
public class CommonConst {
public static final String SUCCESS_RESULT = "成功";
public static final String ERROR_RESULT = "失败";
}

View File

@ -0,0 +1,35 @@
package com.simulationservice.common;
import lombok.Data;
@Data
public class R<T> {
/**
* 编码1成功0和其它数字为失败
*/
private Integer code;
/**
* 信息返回
*/
private String msg;
/**
* 信息返回数据
*/
private T data;
public static <T> R<T> success(T object) {
R<T> r = new R<T>();
r.data = object;
r.code = 1;
r.msg = CommonConst.SUCCESS_RESULT;
return r;
}
public static <T> R<T> error(T object) {
R<T> r = new R<T>();
r.data = object;
r.code = 0;
r.msg = CommonConst.ERROR_RESULT;
return r;
}
}

View File

@ -0,0 +1,16 @@
package com.simulationservice.config;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenApiConfig {
@Bean
public GroupedOpenApi api() {
return GroupedOpenApi.builder()
.group("api")
.packagesToScan("com.simulationservice.controller") // 你的包名
.build();
}
}

View File

@ -0,0 +1,63 @@
package com.simulationservice.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import javax.annotation.Resource;
@Configuration
public class RedisSubConfig {
/** redis 连接工厂 */
@Resource
private RedisConnectionFactory redisConnectionFactory;
/**
* Redis消息监听器
*/
@Resource
private MessageListener redisMsgListener;
//任务池
private ThreadPoolTaskScheduler taskScheduler;
/**
* 创建任务池运行线程等待处理redis的消息
*/
@Bean
public ThreadPoolTaskScheduler initTaskScheduler() {
if (null != taskScheduler) {
return taskScheduler;
}
taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(20);
return taskScheduler;
}
/**
* 定义redis的监听器
* @return 监听容器
*/
@Bean
public RedisMessageListenerContainer initRedisContainer() {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
//Redis连接工厂
container.setConnectionFactory(redisConnectionFactory);
//设置运行任务的线程池
container.setTaskExecutor(initTaskScheduler());
//定义监听渠道名称为topic1
Topic topic = new ChannelTopic("topic1");
//使用监听器监听Redis的消息
container.addMessageListener(redisMsgListener, topic);
//定义监听渠道名称为topic2
Topic topic2 = new ChannelTopic("topic2");
//使用监听器监听Redis的消息
container.addMessageListener(redisMsgListener, topic2);
return container;
}
}

View File

@ -0,0 +1,14 @@
package com.simulationservice.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,37 @@
package com.simulationservice.controller;
import com.simulationservice.common.R;
import com.simulationservice.service.InferenceTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 想定控制与前端进行交互的接口
* 想定控制包括想定的加载开始暂停停止加速减速
*/
@RestController
public class InferenceController {
@Autowired
private InferenceTaskService inferenceTaskService;
@GetMapping("/api/loadScenario")
public R<Map<String, Object>> loadScenario(@RequestParam(value = "roomId") String roomId, @RequestParam(value = "scenarioId") String scenarioId) {
// 服务端加载想定
Map<String, Object> retMap = new HashMap<>();
boolean ret = inferenceTaskService.loadScenario(roomId, scenarioId);
return ret ? R.success(retMap) : R.error(retMap);
}
@GetMapping("/api/startScenario")
public String startTask(@RequestParam(value = "roomId") String roomId, @RequestParam(value = "scenarioId") String scenarioId) {
// 启动后台任务
inferenceTaskService.executeTask();
return "任务已启动";
}
}

View File

@ -0,0 +1,99 @@
package com.simulationservice.controller;
import com.simulationservice.domain.SysUser;
import com.simulationservice.service.SysUserService;
import com.simulationservice.service.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping(value = "/account")
public class TestController {
@Autowired
private SysUserService userService;
@Autowired
private RedisTemplate<String,String> redisTemplate;
/**
* 获取账号数据
* @return
*/
@RequestMapping(value="/getUserInfo")
public Map<String, Object> getUserInfo(@RequestParam(value = "id", defaultValue = "") String id) {
Map<String, Object> resultMap = new HashMap<>();
SysUser user = userService.queryUser(id);
String username = user.getUsername();
redisTemplate.opsForValue().set("test","123456789");
resultMap.put("username",username);
resultMap.put("redisValue",redisTemplate.opsForValue().get("test"));
return resultMap;
}
@RequestMapping(value="/subscribe")
public void subscribeMsg() {
// 使用convertAndSend方法向频道redisChat发布消息
redisTemplate.convertAndSend("topic1", "aaa");
redisTemplate.convertAndSend("topic2", "bbb");
}
@GetMapping(value = "/testPush", produces = "application/json;charset=utf-8")
public void testPush(String body) {
/**
* 使用redisTemplate的convertAndSend()函数
* String channel, Object message
* channel代表管道
* message代表发送的信息
*/
redisTemplate.convertAndSend("topic1", body);
}
@GetMapping(value = "/publicMsg", produces = "application/json;charset=utf-8")
public void publicMsg(String body) {
/**
* 使用redisTemplate的convertAndSend()函数
* String channel, Object message
* channel代表管道
* message代表发送的信息
*/
redisTemplate.convertAndSend("topic2", body);
}
@RequestMapping(value = "/get", method = RequestMethod.GET)
public String testGet(@RequestParam(value = "body", defaultValue = "") String body) {
redisTemplate.convertAndSend("topic2", body);
return "success";
}
@RequestMapping(value = "/set", method = RequestMethod.POST)
public String testPost(@RequestParam(value = "body", defaultValue = "") String body) {
redisTemplate.convertAndSend("topic2", body);
return "success";
}
@GetMapping("/index")
public ResponseEntity<String> index(){
return ResponseEntity.ok("请求成功");
}
@GetMapping("/wspage")
public ModelAndView page(){
return new ModelAndView("websocket");
}
@RequestMapping("/push/{toUserId}")
public ResponseEntity<String> pushToWeb(@RequestParam String message, @PathVariable String toUserId) throws IOException {
WebSocketServer.sendInfo(message,toUserId);
return ResponseEntity.ok("MSG SEND SUCCESS:" + message);
}
}

View File

@ -0,0 +1,14 @@
package com.simulationservice.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@GetMapping("/hello")
public String sayHello(@RequestParam(value = "name", defaultValue = "hello") String name) {
return "Hello " + name + "!";
}
}

View File

@ -0,0 +1,67 @@
/*
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.simulationservice.demos.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
*/
@Controller
public class BasicController {
// http://127.0.0.1:8080/hello?name=lisi
@RequestMapping("/hello")
@ResponseBody
public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
return "Hello " + name;
}
// http://127.0.0.1:8080/user
@RequestMapping("/user")
@ResponseBody
public User user() {
User user = new User();
user.setName("theonefx");
user.setAge(666);
return user;
}
// http://127.0.0.1:8080/save_user?name=newName&age=11
@RequestMapping("/save_user")
@ResponseBody
public String saveUser(User u) {
return "user will save: name=" + u.getName() + ", age=" + u.getAge();
}
// http://127.0.0.1:8080/html
@RequestMapping("/html")
public String html() {
return "index.html";
}
@ModelAttribute
public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name
, @RequestParam(name = "age", defaultValue = "12") Integer age, User user) {
user.setName("zhangsan");
user.setAge(18);
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.simulationservice.demos.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
*/
@Controller
public class PathVariableController {
// http://127.0.0.1:8080/user/123/roles/222
@RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET)
@ResponseBody
public String getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId) {
return "User Id : " + userId + " Role Id : " + roleId;
}
// http://127.0.0.1:8080/javabeat/somewords
@RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET)
@ResponseBody
public String getRegExp(@PathVariable("regexp1") String regexp1) {
return "URI Part : " + regexp1;
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.simulationservice.demos.web;
/**
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
*/
public class User {
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}

View File

@ -0,0 +1,49 @@
package com.simulationservice.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* sys_user
* @author
*/
@Data
public class SysUser implements Serializable {
/**
* 用户id
*/
private String id;
/**
* 登录用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 真实名称
*/
private String realname;
/**
* 是否为管理员 1为管理员
*/
private Integer isadmin;
/**
* 预留
*/
private String createuserid;
/**
* 创建时间
*/
private Date createtime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,673 @@
package com.simulationservice.example;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SysUserExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public SysUserExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("Id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("Id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("Id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("Id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("Id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("Id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("Id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("Id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("Id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("Id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("Id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("Id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("Id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("Id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andUsernameIsNull() {
addCriterion("UserName is null");
return (Criteria) this;
}
public Criteria andUsernameIsNotNull() {
addCriterion("UserName is not null");
return (Criteria) this;
}
public Criteria andUsernameEqualTo(String value) {
addCriterion("UserName =", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotEqualTo(String value) {
addCriterion("UserName <>", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThan(String value) {
addCriterion("UserName >", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThanOrEqualTo(String value) {
addCriterion("UserName >=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThan(String value) {
addCriterion("UserName <", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThanOrEqualTo(String value) {
addCriterion("UserName <=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLike(String value) {
addCriterion("UserName like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotLike(String value) {
addCriterion("UserName not like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameIn(List<String> values) {
addCriterion("UserName in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameNotIn(List<String> values) {
addCriterion("UserName not in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameBetween(String value1, String value2) {
addCriterion("UserName between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andUsernameNotBetween(String value1, String value2) {
addCriterion("UserName not between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andPasswordIsNull() {
addCriterion("`Password` is null");
return (Criteria) this;
}
public Criteria andPasswordIsNotNull() {
addCriterion("`Password` is not null");
return (Criteria) this;
}
public Criteria andPasswordEqualTo(String value) {
addCriterion("`Password` =", value, "password");
return (Criteria) this;
}
public Criteria andPasswordNotEqualTo(String value) {
addCriterion("`Password` <>", value, "password");
return (Criteria) this;
}
public Criteria andPasswordGreaterThan(String value) {
addCriterion("`Password` >", value, "password");
return (Criteria) this;
}
public Criteria andPasswordGreaterThanOrEqualTo(String value) {
addCriterion("`Password` >=", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLessThan(String value) {
addCriterion("`Password` <", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLessThanOrEqualTo(String value) {
addCriterion("`Password` <=", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLike(String value) {
addCriterion("`Password` like", value, "password");
return (Criteria) this;
}
public Criteria andPasswordNotLike(String value) {
addCriterion("`Password` not like", value, "password");
return (Criteria) this;
}
public Criteria andPasswordIn(List<String> values) {
addCriterion("`Password` in", values, "password");
return (Criteria) this;
}
public Criteria andPasswordNotIn(List<String> values) {
addCriterion("`Password` not in", values, "password");
return (Criteria) this;
}
public Criteria andPasswordBetween(String value1, String value2) {
addCriterion("`Password` between", value1, value2, "password");
return (Criteria) this;
}
public Criteria andPasswordNotBetween(String value1, String value2) {
addCriterion("`Password` not between", value1, value2, "password");
return (Criteria) this;
}
public Criteria andRealnameIsNull() {
addCriterion("RealName is null");
return (Criteria) this;
}
public Criteria andRealnameIsNotNull() {
addCriterion("RealName is not null");
return (Criteria) this;
}
public Criteria andRealnameEqualTo(String value) {
addCriterion("RealName =", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameNotEqualTo(String value) {
addCriterion("RealName <>", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameGreaterThan(String value) {
addCriterion("RealName >", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameGreaterThanOrEqualTo(String value) {
addCriterion("RealName >=", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameLessThan(String value) {
addCriterion("RealName <", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameLessThanOrEqualTo(String value) {
addCriterion("RealName <=", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameLike(String value) {
addCriterion("RealName like", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameNotLike(String value) {
addCriterion("RealName not like", value, "realname");
return (Criteria) this;
}
public Criteria andRealnameIn(List<String> values) {
addCriterion("RealName in", values, "realname");
return (Criteria) this;
}
public Criteria andRealnameNotIn(List<String> values) {
addCriterion("RealName not in", values, "realname");
return (Criteria) this;
}
public Criteria andRealnameBetween(String value1, String value2) {
addCriterion("RealName between", value1, value2, "realname");
return (Criteria) this;
}
public Criteria andRealnameNotBetween(String value1, String value2) {
addCriterion("RealName not between", value1, value2, "realname");
return (Criteria) this;
}
public Criteria andIsadminIsNull() {
addCriterion("IsAdmin is null");
return (Criteria) this;
}
public Criteria andIsadminIsNotNull() {
addCriterion("IsAdmin is not null");
return (Criteria) this;
}
public Criteria andIsadminEqualTo(Integer value) {
addCriterion("IsAdmin =", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminNotEqualTo(Integer value) {
addCriterion("IsAdmin <>", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminGreaterThan(Integer value) {
addCriterion("IsAdmin >", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminGreaterThanOrEqualTo(Integer value) {
addCriterion("IsAdmin >=", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminLessThan(Integer value) {
addCriterion("IsAdmin <", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminLessThanOrEqualTo(Integer value) {
addCriterion("IsAdmin <=", value, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminIn(List<Integer> values) {
addCriterion("IsAdmin in", values, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminNotIn(List<Integer> values) {
addCriterion("IsAdmin not in", values, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminBetween(Integer value1, Integer value2) {
addCriterion("IsAdmin between", value1, value2, "isadmin");
return (Criteria) this;
}
public Criteria andIsadminNotBetween(Integer value1, Integer value2) {
addCriterion("IsAdmin not between", value1, value2, "isadmin");
return (Criteria) this;
}
public Criteria andCreateuseridIsNull() {
addCriterion("CreateUserId is null");
return (Criteria) this;
}
public Criteria andCreateuseridIsNotNull() {
addCriterion("CreateUserId is not null");
return (Criteria) this;
}
public Criteria andCreateuseridEqualTo(String value) {
addCriterion("CreateUserId =", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridNotEqualTo(String value) {
addCriterion("CreateUserId <>", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridGreaterThan(String value) {
addCriterion("CreateUserId >", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridGreaterThanOrEqualTo(String value) {
addCriterion("CreateUserId >=", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridLessThan(String value) {
addCriterion("CreateUserId <", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridLessThanOrEqualTo(String value) {
addCriterion("CreateUserId <=", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridLike(String value) {
addCriterion("CreateUserId like", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridNotLike(String value) {
addCriterion("CreateUserId not like", value, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridIn(List<String> values) {
addCriterion("CreateUserId in", values, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridNotIn(List<String> values) {
addCriterion("CreateUserId not in", values, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridBetween(String value1, String value2) {
addCriterion("CreateUserId between", value1, value2, "createuserid");
return (Criteria) this;
}
public Criteria andCreateuseridNotBetween(String value1, String value2) {
addCriterion("CreateUserId not between", value1, value2, "createuserid");
return (Criteria) this;
}
public Criteria andCreatetimeIsNull() {
addCriterion("CreateTime is null");
return (Criteria) this;
}
public Criteria andCreatetimeIsNotNull() {
addCriterion("CreateTime is not null");
return (Criteria) this;
}
public Criteria andCreatetimeEqualTo(Date value) {
addCriterion("CreateTime =", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeNotEqualTo(Date value) {
addCriterion("CreateTime <>", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeGreaterThan(Date value) {
addCriterion("CreateTime >", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeGreaterThanOrEqualTo(Date value) {
addCriterion("CreateTime >=", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeLessThan(Date value) {
addCriterion("CreateTime <", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeLessThanOrEqualTo(Date value) {
addCriterion("CreateTime <=", value, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeIn(List<Date> values) {
addCriterion("CreateTime in", values, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeNotIn(List<Date> values) {
addCriterion("CreateTime not in", values, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeBetween(Date value1, Date value2) {
addCriterion("CreateTime between", value1, value2, "createtime");
return (Criteria) this;
}
public Criteria andCreatetimeNotBetween(Date value1, Date value2) {
addCriterion("CreateTime not between", value1, value2, "createtime");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,19 @@
package com.simulationservice.mapper;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
@Component
public class RedisSubscribe implements MessageListener {
@Override
public void onMessage(Message message, byte[] pattern) {
//消息体
String body = new String(message.getBody());
//渠道名称
String topic = new String(pattern);
System.out.println("消息体:" + body);
System.out.println("主题名称:" + topic);
}
}

View File

@ -0,0 +1,32 @@
package com.simulationservice.mapper;
import com.simulationservice.domain.SysUser;
import com.simulationservice.example.SysUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SysUserMapper {
long countByExample(SysUserExample example);
int deleteByExample(SysUserExample example);
int deleteByPrimaryKey(String id);
int insert(SysUser record);
int insertSelective(SysUser record);
List<SysUser> selectByExample(SysUserExample example);
SysUser selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") SysUser record, @Param("example") SysUserExample example);
int updateByExample(@Param("record") SysUser record, @Param("example") SysUserExample example);
int updateByPrimaryKeySelective(SysUser record);
int updateByPrimaryKey(SysUser record);
}

View File

@ -0,0 +1,23 @@
package com.simulationservice.service;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
/**
* 推演任务服务用于创建线程和管理
*/
@Service
public class InferenceTaskService {
@Async
public boolean loadScenario(String roomId, String scenarioId) {
return true;
}
@Async
public void executeTask() {
// 启动我们的任务
//new MyTask().run();
}
}

View File

@ -0,0 +1,20 @@
package com.simulationservice.service;
import com.simulationservice.domain.SysUser;
import com.simulationservice.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@Service
public class SysUserService {
@Lazy
@Autowired
private SysUserMapper userMapper;
//查询用户信息
public SysUser queryUser(String id) {
return userMapper.selectByPrimaryKey(id);
}
}

View File

@ -0,0 +1,149 @@
package com.simulationservice.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint("/wsServer/{userId}")
@Component
@Slf4j
public class WebSocketServer {
/**
* 静态变量用来记录当前在线连接数应该把它设计成线程安全的
*/
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set用来存放每个客户端对应的MyWebSocket对象
*/
private static ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
/**
* 与某个客户端的连接会话需要通过它来给客户端发送数据
*/
private Session session;
/**
* 接收userId
*/
private String userId = "";
/**
* 连接建立成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("userId") String userId) {
this.session = session;
this.userId = userId;
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
webSocketMap.put(userId, this);
//加入set中
} else {
webSocketMap.put(userId, this); // 连接建立成功后将userId作为key将Session作为value存入Map中
//加入set中
addOnlineCount();
//在线数加1
}
log.info("用户连接:" + userId + ",当前在线人数为:" + getOnlineCount());
try {
sendMessage("连接成功"); // 服务器主动推送数据到客户端
} catch (IOException e) {
log.error("用户:" + userId + ",网络异常!!!!!!");
}
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
//从set中删除
subOnlineCount();
}
log.info("用户退出:" + userId + ",当前在线人数为:" + getOnlineCount());
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
@OnMessage
public void onMessage(String message, Session session) {
log.info("用户消息:" + userId + ",报文:" + message);
//可以群发消息
//消息保存到数据库redis
if (StringUtils.isNotBlank(message)) {
try {
//解析发送的报文
JSONObject jsonObject = JSON.parseObject(message);
//追加发送人(防止串改)
jsonObject.put("fromUserId", this.userId);
String toUserId = jsonObject.getString("toUserId");
// 传送给对应toUserId用户的websocket
if (StringUtils.isNotBlank(toUserId) && webSocketMap.containsKey(toUserId)) {
webSocketMap.get(toUserId).sendMessage(jsonObject.toJSONString());
} else {
log.error("请求的userId:" + toUserId + "不在该服务器上");
//否则不在这个服务器上发送到mysql或者redis
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 出现错误
*
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
log.error("用户错误:" + this.userId + ",原因:" + error.getMessage());
error.printStackTrace();
}
/**
* 实现服务器主动推送
*/
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText(message);
}
/**
* 发送自定义消息
*/
public static void sendInfo(String message, @PathParam("userId") String userId) throws IOException {
log.info("发送消息到:" + userId + ",报文:" + message);
if (StringUtils.isNotBlank(userId) && webSocketMap.containsKey(userId)) {
webSocketMap.get(userId).sendMessage(message);
} else {
log.error("用户" + userId + ",不在线!");
}
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
WebSocketServer.onlineCount++;
}
public static synchronized void subOnlineCount() {
WebSocketServer.onlineCount--;
}
}

View File

@ -0,0 +1,31 @@
server:
port: 8088
spring:
datasource: # 数据源配置
url: jdbc:mysql://127.0.0.1:3306/SupportDB?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
redis:
host: 127.0.0.1
port: 6379
password:
pool:
max-active: 100
max-idle: 10
max-wait: 100000
timeout: 300
database: 0
springdoc:
api-docs:
enabled: true
swagger-ui:
enabled: true
path: /api.html
mybatis:
mapper-locations: classpath:mapper/*xml
type-aliases-package: com.simulationservice.domain

View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.simulationservice.mapper.SysUserMapper">
<resultMap id="BaseResultMap" type="com.simulationservice.domain.SysUser">
<id column="Id" jdbcType="VARCHAR" property="id" />
<result column="UserName" jdbcType="VARCHAR" property="username" />
<result column="Password" jdbcType="VARCHAR" property="password" />
<result column="RealName" jdbcType="VARCHAR" property="realname" />
<result column="IsAdmin" jdbcType="INTEGER" property="isadmin" />
<result column="CreateUserId" jdbcType="VARCHAR" property="createuserid" />
<result column="CreateTime" jdbcType="TIMESTAMP" property="createtime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
Id, UserName, `Password`, RealName, IsAdmin, CreateUserId, CreateTime
</sql>
<select id="selectByExample" parameterType="com.simulationservice.example.SysUserExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_user
where Id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_user
where Id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.simulationservice.example.SysUserExample">
delete from sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="Id" keyProperty="id" parameterType="com.simulationservice.domain.SysUser" useGeneratedKeys="true">
insert into sys_user (UserName, `Password`, RealName,
IsAdmin, CreateUserId, CreateTime
)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{realname,jdbcType=VARCHAR},
#{isadmin,jdbcType=INTEGER}, #{createuserid,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="Id" keyProperty="id" parameterType="com.simulationservice.domain.SysUser" useGeneratedKeys="true">
insert into sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="username != null">
UserName,
</if>
<if test="password != null">
`Password`,
</if>
<if test="realname != null">
RealName,
</if>
<if test="isadmin != null">
IsAdmin,
</if>
<if test="createuserid != null">
CreateUserId,
</if>
<if test="createtime != null">
CreateTime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="realname != null">
#{realname,jdbcType=VARCHAR},
</if>
<if test="isadmin != null">
#{isadmin,jdbcType=INTEGER},
</if>
<if test="createuserid != null">
#{createuserid,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
#{createtime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.simulationservice.example.SysUserExample" resultType="java.lang.Long">
select count(*) from sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update sys_user
<set>
<if test="record.id != null">
Id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.username != null">
UserName = #{record.username,jdbcType=VARCHAR},
</if>
<if test="record.password != null">
`Password` = #{record.password,jdbcType=VARCHAR},
</if>
<if test="record.realname != null">
RealName = #{record.realname,jdbcType=VARCHAR},
</if>
<if test="record.isadmin != null">
IsAdmin = #{record.isadmin,jdbcType=INTEGER},
</if>
<if test="record.createuserid != null">
CreateUserId = #{record.createuserid,jdbcType=VARCHAR},
</if>
<if test="record.createtime != null">
CreateTime = #{record.createtime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update sys_user
set Id = #{record.id,jdbcType=VARCHAR},
UserName = #{record.username,jdbcType=VARCHAR},
`Password` = #{record.password,jdbcType=VARCHAR},
RealName = #{record.realname,jdbcType=VARCHAR},
IsAdmin = #{record.isadmin,jdbcType=INTEGER},
CreateUserId = #{record.createuserid,jdbcType=VARCHAR},
CreateTime = #{record.createtime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.simulationservice.domain.SysUser">
update sys_user
<set>
<if test="username != null">
UserName = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
`Password` = #{password,jdbcType=VARCHAR},
</if>
<if test="realname != null">
RealName = #{realname,jdbcType=VARCHAR},
</if>
<if test="isadmin != null">
IsAdmin = #{isadmin,jdbcType=INTEGER},
</if>
<if test="createuserid != null">
CreateUserId = #{createuserid,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
CreateTime = #{createtime,jdbcType=TIMESTAMP},
</if>
</set>
where Id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.simulationservice.domain.SysUser">
update sys_user
set UserName = #{username,jdbcType=VARCHAR},
`Password` = #{password,jdbcType=VARCHAR},
RealName = #{realname,jdbcType=VARCHAR},
IsAdmin = #{isadmin,jdbcType=INTEGER},
CreateUserId = #{createuserid,jdbcType=VARCHAR},
CreateTime = #{createtime,jdbcType=TIMESTAMP}
where Id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,6 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

View File

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