Compare commits

..

1 Commits

Author SHA1 Message Date
joylink_zhangsai
5634ab0a39 南昌工学院沙盘项目特殊改动 2023-08-21 21:11:50 +08:00
352 changed files with 42955 additions and 97726 deletions

View File

@ -1,32 +0,0 @@
name: 公网服务发布
run-name: ${{ gitea.actor }} is testing out Gitea Actions
on:
schedule:
- cron: '30 3 * * 1' # 每周一的凌晨3:30
jobs:
Docker-Build-Push:
runs-on: joylink-local233
steps:
- name: 发布到正式环境1
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PUB1_DOMAIN_SSH_HOST }}
port: ${{ secrets.PUB1_DOMAIN_SSH_PORT }}
username: ${{ secrets.PUB1_DOMAIN_SSH_USER }}
password: ${{ secrets.PUB1_DOMAIN_SSH_PASSWORD }}
script: |
docker rm -f rt-sim-training-service || echo "rt-sim-training-service not exist"
docker pull gitea.joylink.club/joylink/rt-sim-training-service:latest
docker run --name rt-sim-training-service -it -u root --restart=always -d -e APP_ENV=prd -p 9000:9000 -p 19000:19000 -v /usr/local/joylink/logs/rtss:/usr/local/joylink/logs/rtss gitea.joylink.club/joylink/rt-sim-training-service:latest
- name: 发布到正式环境2
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PUB2_DOMAIN_SSH_HOST }}
port: ${{ secrets.PUB2_DOMAIN_SSH_PORT }}
username: ${{ secrets.PUB2_DOMAIN_SSH_USER }}
password: ${{ secrets.PUB2_DOMAIN_SSH_PASSWORD }}
script: |
docker rm -f rt-sim-training-service || echo "rt-sim-training-service not exist"
docker pull gitea.joylink.club/joylink/rt-sim-training-service:latest
docker run --name rt-sim-training-service -it -u root --restart=always -d -e APP_ENV=prd -p 9000:9000 -p 19000:19000 -v /usr/local/joylink/logs/rtss:/usr/local/joylink/logs/rtss gitea.joylink.club/joylink/rt-sim-training-service:latest

View File

@ -1,61 +0,0 @@
name: CI
run-name: ${{ gitea.actor }} is testing out Gitea Actions
on:
push:
branches:
- local-test
jobs:
Docker-Build:
runs-on: joylink-local233
steps:
- name: 检出代码
uses: https://gitea.joylink.club/actions/checkout@v4
with:
submodules: recursive
- name: 设置java环境
uses: https://gitea.joylink.club/actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
cache: 'maven'
cache-dependency-path: './pom.xml'
- name: 设置Maven环境
uses: https://gitea.joylink.club/actions/local-setup-maven@v0.1.1
with:
maven-version: 3.8.8
- name: 构建
run: |
mvn -Dmaven.test.skip=true clean package
- name: 设置 Docker
uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1
- name: 设置 Docker Buildx
uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3
- name: docker登录gitea.joylink.club
uses: https://gitea.joylink.club/docker/login-action@v3
with:
registry: gitea.joylink.club
username: shengxuqiang
password: ${{ secrets.SHENGXUQIANG_PASSWORD }}
- name: Docker Build and push
uses: https://gitea.joylink.club/docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
gitea.joylink.club/joylink/rt-sim-training-service:local-test
- name: 发布到本地测试环境
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.LOCAL_233_SSH_HOST }}
port: ${{ secrets.LOCAL_233_SSH_PORT }}
username: ${{ secrets.LOCAL_233_SSH_USER }}
password: ${{ secrets.LOCAL_233_SSH_PASSWORD }}
script: |
docker rm -f rt-sim-training-service || echo "rt-sim-training-service not exist"
docker pull gitea.joylink.club/joylink/rt-sim-training-service:local-test
docker run --name rt-sim-training-service --restart=always --network net --ip 192.168.53.3 -d -e APP_ENV=local-test -p 9000:9000 -p 19000:19000 -v /usr/local/joylink/logs/rtss:/usr/local/joylink/logs/rtss gitea.joylink.club/joylink/rt-sim-training-service:local-test
# - name: 清理tag为none的镜像
# run: |
# docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 2>/dev/null || echo "No dangling images to remove"

View File

@ -1,61 +0,0 @@
name: 版本发布docker构建并上传
run-name: ${{ gitea.actor }} is testing out Gitea Actions
on:
release:
types: [ published ]
jobs:
Docker-Build-Push:
runs-on: joylink-local233
steps:
- name: 检出代码
uses: https://gitea.joylink.club/actions/checkout@v4
with:
submodules: recursive
- name: 设置java环境
uses: https://gitea.joylink.club/actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
cache: 'maven'
cache-dependency-path: './pom.xml'
- name: 设置Maven环境
uses: https://gitea.joylink.club/actions/local-setup-maven@v0.1.1
with:
maven-version: 3.8.8
- name: 构建
run: |
mvn -Dmaven.test.skip=true clean package
- name: 设置 Docker
uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1
- name: 设置 Docker Buildx
uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3
- name: docker登录gitea.joylink.club
uses: https://gitea.joylink.club/docker/login-action@v3
with:
registry: gitea.joylink.club
username: shengxuqiang
password: ${{ secrets.SHENGXUQIANG_PASSWORD }}
- name: Docker Build and push
uses: https://gitea.joylink.club/docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
gitea.joylink.club/joylink/rt-sim-training-service:${{ github.event.release.tag_name }}
gitea.joylink.club/joylink/rt-sim-training-service:latest
# - name: 清理tag为none的镜像
# run: |
# docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 2>/dev/null || echo "No dangling images to remove"
# - name: 发布到本地测试环境
# uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.LOCAL_233_SSH_HOST }}
# port: ${{ secrets.LOCAL_233_SSH_PORT }}
# username: ${{ secrets.LOCAL_233_SSH_USER }}
# password: ${{ secrets.LOCAL_233_SSH_PASSWORD }}
# script: |
# docker rm -f rt-sim-training-service || echo "rt-sim-training-service not exist"
# docker pull gitea.joylink.club/joylink/rt-sim-training-service:latest
# docker run --name rt-sim-training-service --restart=always --network net --ip 192.168.53.3 -d -e APP_ENV=prd -p 9000:9000 -p 19000:19000 -v /usr/local/joylink/logs/rtss:/usr/local/joylink/logs/rtss gitea.joylink.club/joylink/rt-sim-training-service:latest

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "rt-sim-training-message"]
path = rt-sim-training-message
url = http://120.46.212.6:3000/joylink/rt-sim-training-message.git

View File

@ -1,11 +0,0 @@
FROM azul/zulu-openjdk-alpine:11
ADD target/rtss-0.0.1-SNAPSHOT.jar rtss-service.jar
ENV APP_ENV=prd
EXPOSE 9000 19000/tcp
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
CMD java -jar -Dfile.encoding=UTF-8 -Dspring.profiles.active=$APP_ENV /rtss-service.jar

View File

@ -1,7 +0,0 @@
# CI、CD说明
- 分支主要为developlocal-testmaster
- 本地233服务器部署方式为push到local-test分支即可触发
- 公网服务器发布方式:
1. push到master虽然可以用别的分支但不建议
2. 在版本发布处发布新版本触发构建docker镜像
3. 待docker镜像构建完成后点击Actions中CD_pub_deploy.yaml进入第一个任务点击重新运行所有任务进行服务发布

395
pom.xml
View File

@ -1,106 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?> <?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" <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"> 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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version> <version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>club.joylink</groupId> <groupId>club.joylink</groupId>
<artifactId>rtss</artifactId> <artifactId>rtss</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>rtss</name> <name>rtss</name>
<description>Rail transit simulation system</description> <description> Rail transit simulation system</description>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
<pagehelper.version>4.1.1</pagehelper.version> <pagehelper.version>4.1.1</pagehelper.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version> <version>2.1.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.3.0</version> <version>1.3.0</version>
</dependency> </dependency>
<!-- javax.validation --> <!-- javax.validation -->
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<!--spring切面aop依赖 --> <!--spring切面aop依赖 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.digitalpetri.modbus</groupId> <groupId>com.digitalpetri.modbus</groupId>
<artifactId>modbus-codec</artifactId> <artifactId>modbus-codec</artifactId>
<version>1.1.1</version> <version>1.1.1</version>
</dependency> </dependency>
<!-- 硬件检测依赖 --> <!-- 硬件检测依赖 -->
<dependency> <dependency>
<groupId>com.github.oshi</groupId> <groupId>com.github.oshi</groupId>
<artifactId>oshi-core-java11</artifactId> <artifactId>oshi-core-java11</artifactId>
<version>5.7.5</version> <version>5.7.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.junit.vintage</groupId> <groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId> <artifactId>junit-vintage-engine</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.wechatpay-apiv3</groupId> <groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId> <artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.2.1</version> <version>0.2.1</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.huawei.sis</groupId>--> <!-- <groupId>com.huawei.sis</groupId>-->
@ -130,123 +130,98 @@
<groupId>org.springframework.retry</groupId> <groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId> <artifactId>spring-retry</artifactId>
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.10.3</version> <version>2.10.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.belerweb</groupId> <groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId> <artifactId>pinyin4j</artifactId>
<version>2.5.0</version> <version>2.5.0</version>
</dependency> </dependency>
<!-- iscs --> <!-- iscs -->
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>
<version>3.23.1</version> <version>3.19.3</version>
</dependency> </dependency>
<dependency>
<groupId>com.hubspot.jackson</groupId>
<artifactId>jackson-datatype-protobuf</artifactId>
<version>0.9.12</version>
</dependency>
<!-- <dependency>
<groupId>com.chenlb.mmseg4j</groupId>
<artifactId>mmseg4j-core</artifactId>
<version>1.10.0</version>
</dependency>-->
<!-- <dependency>
<groupId>org.ansj</groupId>
<artifactId>ansj_seg</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- <dependency>
<groupId>info.debatty</groupId>
<artifactId>java-string-similarity</artifactId>
<version>2.0.0</version>
</dependency>-->
<dependency> <!-- <dependency>
<groupId>org.apache.commons</groupId> <groupId>com.chenlb.mmseg4j</groupId>
<artifactId>commons-text</artifactId> <artifactId>mmseg4j-core</artifactId>
<version>1.10.0</version> <version>1.10.0</version>
</dependency> </dependency>-->
<!-- <dependency>
<groupId>org.ansj</groupId>
<artifactId>ansj_seg</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- <dependency>
<groupId>info.debatty</groupId>
<artifactId>java-string-similarity</artifactId>
<version>2.0.0</version>
</dependency>-->
</dependencies> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
</dependency>
<build> </dependencies>
<plugins>
<plugin> <build>
<groupId>org.springframework.boot</groupId> <plugins>
<artifactId>spring-boot-maven-plugin</artifactId> <plugin>
<configuration> <groupId>org.springframework.boot</groupId>
<includeSystemScope>true</includeSystemScope> <artifactId>spring-boot-maven-plugin</artifactId>
</configuration> <configuration>
</plugin> <includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc-maven-plugin</artifactId>
<version>2.1.9</version>
<configuration>
<!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
<configFile>./src/main/resources/smart-doc.json</configFile>
<!--smart-doc实现自动分析依赖树加载第三方依赖的源码如果一些框架依赖库加载不到导致报错这时请使用excludes排除掉-->
<!-- <excludes>-->
<!-- &lt;!&ndash;格式为groupId:artifactId;参考如下&ndash;&gt;-->
<!-- <exclude>com.alibaba:fastjson</exclude>-->
<!-- </excludes>-->
<!-- &lt;!&ndash;自1.0.8版本开始插件提供includes支持,配置了includes后插件会按照用户配置加载而不是自动加载因此使用时需要注意&ndash;&gt;-->
<!-- &lt;!&ndash;smart-doc能自动分析依赖树加载所有依赖源码原则上会影响文档构建效率因此你可以使用includes来让插件加载你配置的组件&ndash;&gt;-->
<!-- <includes>-->
<!-- &lt;!&ndash;格式为groupId:artifactId;参考如下&ndash;&gt;-->
<!-- <include>com.alibaba:fastjson</include>-->
<!-- </includes>-->
</configuration>
<executions>
<execution>
<!--如果不需要在执行编译时启动smart-doc则将phase注释掉-->
<!-- <phase>compile</phase>-->
<goals>
<!--smart-doc提供了html、openapi、markdown等goal可按需配置-->
<goal>html</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc-maven-plugin</artifactId>
<version>2.1.9</version>
<configuration>
<!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
<configFile>./src/main/resources/smart-doc.json</configFile>
<!--smart-doc实现自动分析依赖树加载第三方依赖的源码如果一些框架依赖库加载不到导致报错这时请使用excludes排除掉-->
<!-- <excludes>-->
<!-- &lt;!&ndash;格式为groupId:artifactId;参考如下&ndash;&gt;-->
<!-- <exclude>com.alibaba:fastjson</exclude>-->
<!-- </excludes>-->
<!-- &lt;!&ndash;自1.0.8版本开始插件提供includes支持,配置了includes后插件会按照用户配置加载而不是自动加载因此使用时需要注意&ndash;&gt;-->
<!-- &lt;!&ndash;smart-doc能自动分析依赖树加载所有依赖源码原则上会影响文档构建效率因此你可以使用includes来让插件加载你配置的组件&ndash;&gt;-->
<!-- <includes>-->
<!-- &lt;!&ndash;格式为groupId:artifactId;参考如下&ndash;&gt;-->
<!-- <include>com.alibaba:fastjson</include>-->
<!-- </includes>-->
</configuration>
<executions>
<execution>
<!--如果不需要在执行编译时启动smart-doc则将phase注释掉-->
<!-- <phase>compile</phase>-->
<goals>
<!--smart-doc提供了html、openapi、markdown等goal可按需配置-->
<goal>html</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>aliyun-central</id>
<url>https://maven.aliyun.com/repository/central</url>
</repository>
<repository>
<id>aliyun-snapshots</id>
<url>https://maven.aliyun.com/repository/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-central</id>
<url>https://maven.aliyun.com/repository/central</url>
</pluginRepository>
</pluginRepositories>
</project> </project>

@ -1 +0,0 @@
Subproject commit 5dd7fdb3d568c829356fa59b746b559d17da49b8

16
sql/20230206-zhou.sql Normal file
View File

@ -0,0 +1,16 @@
-- 用户答题生成对应的规则id
ALTER TABLE `rts_paper_user_question`
ADD COLUMN `rule_id` bigint not NULL COMMENT '试卷规则rts_paper_rule的id' AFTER `pu_id`;
ALTER TABLE `rts_paper_user_question`
ADD COLUMN `sub_type` int not NULL COMMENT '规则类型:理论题(1-单选题2-多选题3-判断题);实训题(4-单操实训5-场景实训)' AFTER `type`;
ALTER TABLE `rts_paper_user_question` MODIFY COLUMN tmp_answer longtext;
ALTER TABLE `rts_paper_rule` ADD COLUMN scene_detail VARCHAR(1000) COMMENT '场景实训考试的规则';
ALTER TABLE `rts_paper_user_question`
ADD COLUMN `scene_cosplay_id` varchar(10) COMMENT '场景实训考试扮演的角色';

View File

@ -0,0 +1,2 @@
ALTER TABLE `joylink`.`rts_map_function`
ADD COLUMN `bg_url` varchar(255) NULL COMMENT '背景图片的url' AFTER `desc`;

View File

@ -0,0 +1,11 @@
CREATE TABLE `rts_map_function_template` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8mb4_general_ci NOT NULL,
`map_function_param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '地图功能参数',
`assistant_param` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '辅助参数(如默认角色类型)',
`create_time` datetime NOT NULL,
`creator_id` bigint NOT NULL,
`update_time` datetime DEFAULT NULL,
`updater_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='地图功能模板';

View File

@ -0,0 +1,3 @@
ALTER TABLE `joylink`.`rts_published_training2` ADD COLUMN `shared` int NULL DEFAULT 0 COMMENT '0 不共享1共享' AFTER `client`;
update rts_published_training2 SET shared = 1,org_id = null WHERE creator_id = 0 ;

View File

@ -0,0 +1,14 @@
CREATE TABLE `rts_voice_discriminate_config` (
`id` bigint NOT NULL AUTO_INCREMENT,
`key_word_rules` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关键字正则',
`params_rules` json DEFAULT NULL COMMENT ' /**\r\n * 所需参数 List\r\n * {@link ParamExtractRule}\r\n */',
`exec_operate_rule` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' /**\r\n * 执行指令(系统操作指令)\r\n * {@link OperateRule}\r\n */',
`reply_rule` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' /**\r\n * 回复指令(系统指令操作完毕或者无系统指令时,交互回复)\r\n * {@link ReplyRule}\r\n */',
`map_id` bigint DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`operate_id` bigint DEFAULT NULL,
`describe` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述',
`status` int DEFAULT NULL COMMENT '状态0=编辑,1=使用',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

View File

@ -0,0 +1,13 @@
CREATE TABLE `rts_conversation_group_info` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群组名称',
`map_id` bigint DEFAULT NULL COMMENT '所属地图ID',
`project_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属项目',
`leader_id` varchar(12) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群主角色ID',
`member_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '群组用户角色ID',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`status` int DEFAULT NULL COMMENT '状态0=编辑,1=使用',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='群组信息设置';

View File

@ -0,0 +1,2 @@
ALTER TABLE `joylink`.`rts_conversation_group_info` ADD COLUMN `image_url` varchar(255) NULL COMMENT '头像路径' AFTER `name`;
DROP TABLE IF EXISTS `joylink`.`rts_conversation_group_info`;

View File

@ -0,0 +1,10 @@
CREATE TABLE `rts_alarm_tips` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`alarm_type` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
`alarm_level` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
`tips` varchar(10000) COLLATE utf8mb4_general_ci NOT NULL,
`update_time` datetime NOT NULL,
`updater_id` bigint NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `alarm` (`alarm_type`,`alarm_level`) COMMENT '用以保证提示信息唯一'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='ATS报警信息提示';

View File

@ -0,0 +1 @@
ALTER TABLE `joylink`.`rts_training2_rule` ADD COLUMN `score_rule` text NULL COMMENT '得分规则' AFTER `location_rule`;

View File

@ -0,0 +1 @@
ALTER TABLE `rts_paper_rule` ADD COLUMN `sub_type_param` varchar(255) NULL COMMENT '规则参数';

View File

@ -0,0 +1,9 @@
INSERT INTO rts_user_simulation_record (map_id, user_id, type, duration, start_time, end_time)
SELECT map_id,
user_id,
'SIM',
duration,
start_time,
end_time
FROM user_simulation_stats
WHERE end_time > '2000-01-01 00:00:00';

View File

@ -1,41 +0,0 @@
package club.joylink.rtss.aop;
import club.joylink.rtss.services.cgy.CgyStatsService;
import club.joylink.rtss.simulation.cbtc.SimulationService;
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@Aspect
@Slf4j
@Component
public class CgyViewAspect {
private CgyStatsService cgyStatsService;
private RestTemplate restTemplate;
private SimulationService simulationService;
@Autowired
public CgyViewAspect(CgyStatsService cgyStatsService, RestTemplate restTemplate,
SimulationService simulationService) {
this.cgyStatsService = cgyStatsService;
this.restTemplate = restTemplate;
this.simulationService = simulationService;
}
/**
* 成工院第三方登录接口被调用后加一个浏览量并同步给虚仿平台
*/
@AfterReturning(value = "execution(public * club.joylink.rtss.controller.LoginController.cgyThirdPartyLogin(..))")
public void addViewCount(JoinPoint joinPoint) {
Object arg = joinPoint.getArgs()[0];
CgyThirdPartyLoginInfoVO loginInfoVO = (CgyThirdPartyLoginInfoVO) arg;
cgyStatsService.updateView(loginInfoVO.getAppId());
}
}

View File

@ -1,32 +0,0 @@
package club.joylink.rtss.bo.cgy;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
/**
* 成工院虚仿平台对接统计数据
*/
@Getter
@Setter
@RequiredArgsConstructor
public class CgyStatsBO {
private final String appId;
private final String appSecret;
private final Long FunctionId;
//统计数据是否发生变化
private AtomicBoolean change;
//浏览量
private AtomicLong view;
//实训人次
private AtomicLong visitor;
//实训人数
private final Set<Long> userSet = new HashSet<>();
//实训时长/s
private AtomicLong duration;
}

View File

@ -1,101 +0,0 @@
package club.joylink.rtss.bo.race;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.race.RaceApplication;
import club.joylink.rtss.vo.race.RaceApplication.ResultNode;
import club.joylink.rtss.vo.race.RaceApplication.ResultNode.Builder;
import club.joylink.rtss.vo.race.RaceTask;
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO.ChildNodeType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
@Data
public class RaceContent {
private long userId;
private long paperId;
private int moduleId;
/**
* 训练使用到的任务树
*/
private RaceTask.RacePaperSingleModuleGroupTask taskTree;
/**
* 训练结果
*/
private RaceApplication.RacePracticeResult.Builder result;
/**
* 结果节点映射仅为了通过ID找节点
*/
private Map<Long, Builder> resultNodeMap = new HashMap<>();
public RaceContent(long userId, long paperId, int moduleId,
RacePaperSingleModuleGroupTask taskTree) {
this.userId = userId;
this.paperId = paperId;
this.moduleId = moduleId;
this.taskTree = taskTree;
this.result = RaceApplication.RacePracticeResult.newBuilder();
result.setCustomModuleId(taskTree.getCustomModuleId());
Builder rootNode = ResultNode.newBuilder();
buildResultNodeTree(taskTree.getChildList(), rootNode);
result.addAllNode(rootNode.getChildList());
// for (RaceTaskChildVO childVO : taskTree.getChildList()) {
// Builder nodeBuilder = result.addNodeBuilder();
// nodeBuilder.setName(childVO.getName());
// nodeBuilder.setType(childVO.getNodeType());
// nodeBuilder.setSceneId(childVO.getSceneId());
// //构建任务映射
// if (ChildNodeType.TASK == childVO.getNodeType()) {
// resultNodeMap.put(childVO.getId(), nodeBuilder);
// }
// //递归
// buildResultNodeTree(childVO, nodeBuilder);
// }
}
public Builder getResultNode(long taskId) {
Builder builder = resultNodeMap.get(taskId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(builder,
String.format("任务[%d]不存在", taskId));
return builder;
}
private void buildResultNodeTree(List<RaceTaskChildVO> children, Builder parentNode) {
for (RaceTaskChildVO childVO : children) {
//构建对应的结果Node
Builder nodeBuilder = parentNode.addChildBuilder();
nodeBuilder.setName(childVO.getName());
nodeBuilder.setType(childVO.getNodeType());
nodeBuilder.setSceneId(childVO.getSceneId());
//构建任务映射
if (ChildNodeType.TASK == childVO.getNodeType()) {
resultNodeMap.put(childVO.getId(), nodeBuilder);
}
//递归
buildResultNodeTree(childVO.getChildrenList(), nodeBuilder);
}
}
// private void buildResultNodeTree(RaceTaskChildVO children, Builder parentNode) {
// for (RaceTaskChildVO childVO : children.getChildrenList()) {
// //构建对应的结果Node
// Builder nodeBuilder = parentNode.addChildBuilder();
// nodeBuilder.setName(childVO.getName());
// nodeBuilder.setType(childVO.getNodeType());
// nodeBuilder.setSceneId(childVO.getSceneId());
// //构建任务映射
// if (ChildNodeType.TASK == childVO.getNodeType()) {
// resultNodeMap.put(childVO.getId(), nodeBuilder);
// }
// //递归
// buildResultNodeTree(childVO, nodeBuilder);
// }
// }
}

View File

@ -6,7 +6,6 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import com.hubspot.jackson.datatype.protobuf.ProtobufModule;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -18,40 +17,36 @@ import java.time.format.DateTimeFormatter;
@Configuration @Configuration
public class LocalDateTimeSerializerConfig { public class LocalDateTimeSerializerConfig {
/**
* Date格式化字符串
*/
private static final String DATE_FORMAT = "yyyy-MM-dd";
/**
* DateTime格式化字符串
*/
private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* Time格式化字符串
*/
private static final String TIME_FORMAT = "HH:mm:ss";
/** @Bean
* Date格式化字符串 public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
*/ return builder -> {
private static final String DATE_FORMAT = "yyyy-MM-dd"; builder.serializerByType(LocalDateTime.class,
/** new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
* DateTime格式化字符串 builder.deserializerByType(LocalDateTime.class,
*/ new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* Time格式化字符串
*/
private static final String TIME_FORMAT = "HH:mm:ss";
@Bean builder.serializerByType(LocalDate.class,
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() { new LocalDateSerializer(DateTimeFormatter.ofPattern(DATE_FORMAT)));
return builder -> { builder.deserializerByType(LocalDate.class,
builder.modulesToInstall(ProtobufModule.class); new LocalDateDeserializer(DateTimeFormatter.ofPattern(DATE_FORMAT)));
builder.failOnUnknownProperties(false);
builder.serializerByType(LocalDateTime.class,
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
builder.deserializerByType(LocalDateTime.class,
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
builder.serializerByType(LocalDate.class, builder.serializerByType(LocalTime.class,
new LocalDateSerializer(DateTimeFormatter.ofPattern(DATE_FORMAT))); new LocalTimeSerializer(DateTimeFormatter.ofPattern(TIME_FORMAT)));
builder.deserializerByType(LocalDate.class, builder.deserializerByType(LocalTime.class,
new LocalDateDeserializer(DateTimeFormatter.ofPattern(DATE_FORMAT))); new LocalTimeDeserializer(DateTimeFormatter.ofPattern(TIME_FORMAT)));
};
builder.serializerByType(LocalTime.class, }
new LocalTimeSerializer(DateTimeFormatter.ofPattern(TIME_FORMAT)));
builder.deserializerByType(LocalTime.class,
new LocalTimeDeserializer(DateTimeFormatter.ofPattern(TIME_FORMAT)));
};
}
} }

View File

@ -70,8 +70,6 @@ public class WebConfig implements WebMvcConfigurer {
whiteList.add("/api/v2/paper/composition/oldData/handle"); whiteList.add("/api/v2/paper/composition/oldData/handle");
whiteList.add("/api/user/sync"); whiteList.add("/api/user/sync");
whiteList.add("/dataHandle"); whiteList.add("/dataHandle");
//modbus测试
whiteList.add("/api/test/modbus/writeCoil");
registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList);
} }

View File

@ -5,7 +5,5 @@ public interface ProjectCode {
String THAILAND_SANDBOX = "THAILAND_SANDBOX"; String THAILAND_SANDBOX = "THAILAND_SANDBOX";
String SR_SANDBOX = "SR_SANDBOX"; String SR_SANDBOX = "SR_SANDBOX";
String NGY_SAND_TABLE = "NGY_SAND_TABLE"; String NGY_SAND_TABLE = "NGY_SAND_TABLE";
String CDGXY = "CDGXY";
String CGY = "CGY";
} }

View File

@ -121,8 +121,6 @@ public enum ProjectDeviceType {
PIS_STAND, PIS_STAND,
PIS_TRAIN, PIS_TRAIN,
PIS,
TMS,
/* -----------client device end---------- */ /* -----------client device end---------- */
/* -----------Other start---------- */ /* -----------Other start---------- */
/** /**

View File

@ -7,148 +7,136 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.LoginStatusVO; import club.joylink.rtss.vo.client.LoginStatusVO;
import club.joylink.rtss.vo.client.LoginUserVO; import club.joylink.rtss.vo.client.LoginUserVO;
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
import club.joylink.rtss.vo.client.validGroup.LoginInfoCheck; import club.joylink.rtss.vo.client.validGroup.LoginInfoCheck;
import club.joylink.rtss.vo.client.validGroup.ThirdLoginInfoCheck; import club.joylink.rtss.vo.client.validGroup.ThirdLoginInfoCheck;
import javax.validation.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import javax.validation.constraints.NotBlank;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/api/login") @RequestMapping("/api/login")
public class LoginController { public class LoginController {
@Autowired @Autowired
private IAuthenticateService iAuthenticateService; private IAuthenticateService iAuthenticateService;
@PostMapping("/cgy/third") @PostMapping(path = "/third")
public String cgyThirdPartyLogin(@RequestBody @Validated CgyThirdPartyLoginInfoVO loginInfo) { public String thirdPartyLogin(@RequestBody @Validated(ThirdLoginInfoCheck.class) LoginUserVO loginInfo) {
return this.iAuthenticateService.cgyThirdPartyLogin(loginInfo); return this.iAuthenticateService.thirdPartyLogin(loginInfo);
}
@PostMapping(path = "/third")
public String thirdPartyLogin(
@RequestBody @Validated(ThirdLoginInfoCheck.class) LoginUserVO loginInfo) {
return this.iAuthenticateService.thirdPartyLogin(loginInfo);
}
/**
* 获取微信小程序登陆二维码
*/
@GetMapping(path = "/wmurl")
public LoginStatusVO getWmLoginUrl(@NotBlank String clientId, @NotBlank String secret,
String project, @RequestParam(required = false) String deviceCode) {
try {
return this.iAuthenticateService.getWmLoginUrl(clientId, secret, project, deviceCode);
} catch (BaseException e) {
throw e;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("获取登录二维码失败");
} }
}
/** /**
* 用户微信小程序扫登陆二维码 * 获取微信小程序登陆二维码
*/ */
@GetMapping(path = "/scan/wmLoginUrl") @GetMapping(path = "/wmurl")
public AccountVO scanWmLoginQrCode(String code, String state) { public LoginStatusVO getWmLoginUrl(@NotBlank String clientId, @NotBlank String secret,
return this.iAuthenticateService.scanWmLoginQrCode(code, state); String project, @RequestParam(required = false) String deviceCode) {
} try {
return this.iAuthenticateService.getWmLoginUrl(clientId, secret, project, deviceCode);
} catch (BaseException e) {
throw e;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("获取登录二维码失败");
}
}
/** /**
* 微信小程序确认登陆接口 * 用户微信小程序扫登陆二维码
*/ */
@PostMapping(path = "/wm") @GetMapping(path = "/scan/wmLoginUrl")
public void wmConfirmLogin(String code, String state) { public AccountVO scanWmLoginQrCode(String code, String state) {
this.iAuthenticateService.wmConfirmClientLogin(code, state); return this.iAuthenticateService.scanWmLoginQrCode(code, state);
} }
@PostMapping() /**
public String loginWithPwd(@RequestBody @Validated(LoginInfoCheck.class) LoginUserVO loginUser) { * 微信小程序确认登陆接口
return iAuthenticateService.loginWithPwd(loginUser); */
} @PostMapping(path = "/wm")
public void wmConfirmLogin(String code, String state) {
this.iAuthenticateService.wmConfirmClientLogin(code, state);
}
@GetMapping("/preLogout") @PostMapping()
public void preLogout(String token) { public String loginWithPwd(@RequestBody @Validated(LoginInfoCheck.class) LoginUserVO loginUser) {
this.iAuthenticateService.preLogout(token); return iAuthenticateService.loginWithPwd(loginUser);
} }
@GetMapping(path = "/logout") @GetMapping("/preLogout")
public void logout(String token) { public void preLogout(String token) {
this.iAuthenticateService.logout(token); this.iAuthenticateService.preLogout(token);
} }
@GetMapping(path = "/checkStatus") @GetMapping(path = "/logout")
public LoginStatusVO checkStatus(@NotBlank String sessionId) { public void logout(String token) {
return iAuthenticateService.checkStatus(sessionId); this.iAuthenticateService.logout(token);
} }
/** @GetMapping(path = "/checkStatus")
* 获取用户信息 - 通过token public LoginStatusVO checkStatus(@NotBlank String sessionId) {
* return iAuthenticateService.checkStatus(sessionId);
* @param token }
* @return
*/
@GetMapping(path = "/getUserInfo")
public AccountVO getUserInfo(String token) {
LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token);
return loginUserInfoVO.getAccountVO();
}
/** /**
* 获取用户登录信息包含登录的项目/客户端等 * 获取用户信息 - 通过token
* *
* @param token * @param token
* @return * @return
*/ */
@GetMapping("/loginUserInfo") @GetMapping(path = "/getUserInfo")
public LoginUserInfoVO getLoginUserInfo(String token) { public AccountVO getUserInfo(String token) {
return this.iAuthenticateService.getLoginUserInfoByToken(token); LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token);
} return loginUserInfoVO.getAccountVO();
}
/** /**
* <玖琏科技>微信小程序code换取token * 获取用户登录信息包含登录的项目/客户端等
*/ *
@GetMapping(path = "/wm/token") * @param token
public String getTokenByWmCode(String code) { * @return
return this.iAuthenticateService.getTokenByWmCode(code); */
} @GetMapping("/loginUserInfo")
public LoginUserInfoVO getLoginUserInfo(String token) {
return this.iAuthenticateService.getLoginUserInfoByToken(token);
}
/** /**
* 到那儿了小程序code换token * <玖琏科技>微信小程序code换取token
* */
* @param code @GetMapping(path = "/wm/token")
* @return public String getTokenByWmCode(String code) {
*/ return this.iAuthenticateService.getTokenByWmCode(code);
@GetMapping(path = "/wm2/token") }
public String getTokenByWmCode2(String code) {
return this.iAuthenticateService.getTokenByWmCode2(code);
}
/** /**
* 郑州共赢小程序code换token * 到那儿了小程序code换token
* *
* @param code * @param code
* @return * @return
*/ */
@GetMapping(path = "/wm/zzww/token") @GetMapping(path = "/wm2/token")
public String getTokenByWmCode3(String code) { public String getTokenByWmCode2(String code) {
return this.iAuthenticateService.getTokenByWmCode3(code); return this.iAuthenticateService.getTokenByWmCode2(code);
} }
/** /**
* token是否过期 * 郑州共赢小程序code换token
*/ *
@GetMapping(path = "/{token}/isExpired") * @param code
public boolean isTokenExpired(@PathVariable String token) { * @return
return this.iAuthenticateService.isTokenExpired(token); */
} @GetMapping(path = "/wm/zzww/token")
public String getTokenByWmCode3(String code) {
return this.iAuthenticateService.getTokenByWmCode3(code);
}
/**
* token是否过期
*/
@GetMapping(path = "/{token}/isExpired")
public boolean isTokenExpired(@PathVariable String token) {
return this.iAuthenticateService.isTokenExpired(token);
}
} }

View File

@ -26,79 +26,78 @@ import java.util.List;
@Slf4j @Slf4j
public class CommonResponseBody implements ResponseBodyAdvice { public class CommonResponseBody implements ResponseBodyAdvice {
@Override @Override
public boolean supports(MethodParameter returnType, Class converterType) { public boolean supports(MethodParameter returnType, Class converterType) {
return returnType.getMethod() != null && !returnType.getMethod().getReturnType().getSimpleName().equals("CommonJsonResponse"); return returnType.getMethod() != null && !returnType.getMethod().getReturnType().getSimpleName().equals("CommonJsonResponse");
}
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//byte[]
if (body instanceof byte[]) {
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
return body;
} }
//byte[]
/*if(body instanceof AbstractMessageLite){ @Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//byte[]
if(body instanceof byte[]){
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
return body;
}
//byte[]
if(body instanceof AbstractMessageLite){
response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM); response.getHeaders().setContentType(MediaType.APPLICATION_OCTET_STREAM);
final AbstractMessageLite proto = (AbstractMessageLite) body; final AbstractMessageLite proto = (AbstractMessageLite) body;
return proto.toByteArray(); return proto.toByteArray();
}*/ }
if (body instanceof CommonJsonResponse) { if(body instanceof CommonJsonResponse) {
return body; return body;
} }
if (request.getURI().getPath().startsWith("/swagger")) { if(request.getURI().getPath().startsWith("/swagger")) {
return body; return body;
} }
if (request.getURI().getPath().equals("/api/userinfo/ifRegisted")) { if (request.getURI().getPath().equals("/api/userinfo/ifRegisted")) {
return body; return body;
} }
if (request.getURI().getPath().equals("/api/userinfo/identity")) { if (request.getURI().getPath().equals("/api/userinfo/identity")) {
return body; return body;
} }
CommonJsonResponse commonJsonResponse = CommonJsonResponse.newSuccessResponse(body); CommonJsonResponse commonJsonResponse = CommonJsonResponse.newSuccessResponse(body);
if (returnType.getMethod().getReturnType().equals(String.class) || body instanceof String) { if(returnType.getMethod().getReturnType().equals(String.class) || body instanceof String) {
return commonJsonResponse.toJSONString(); return commonJsonResponse.toJSONString();
} }
return commonJsonResponse; return commonJsonResponse;
}
@ExceptionHandler({PayException.class})
@ResponseStatus
public CommonJsonResponse handleException(PayException e) {
log.error("【支付异常】", e);
return CommonJsonResponse.newErrorResponse();
}
@ExceptionHandler({Exception.class})
@ResponseBody
public CommonJsonResponse handleException(Exception e) {
if (e instanceof MethodArgumentNotValidException) {
// 参数验证异常处理
MethodArgumentNotValidException validException = (MethodArgumentNotValidException) e;
List<ObjectError> errorList = validException.getBindingResult().getAllErrors();
StringBuffer sb = new StringBuffer();
errorList.forEach(error ->
sb.append(error.getDefaultMessage()).append(";"));
log.error("【参数校验异常】{}", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), sb.toString());
}
if (e instanceof BusinessException) {
club.joylink.rtss.exception.BusinessException be = (club.joylink.rtss.exception.BusinessException) e;
log.error("【业务异常】{}", e);
return CommonJsonResponse.newErrorResponse(be.getCode(), be.getVoMessage());
} else if (e instanceof MissingServletRequestParameterException) {
log.error("【接口参数异常】", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), "接口参数异常");
} else if (e instanceof SimulationException) {
club.joylink.rtss.simulation.cbtc.exception.SimulationException simulationException = (club.joylink.rtss.simulation.cbtc.exception.SimulationException) e;
log.error("【仿真系统异常】{}", e);
return CommonJsonResponse.newErrorResponse(simulationException.getCode(), simulationException.getMessage());
} }
log.error("【系统异常】{}", e); @ExceptionHandler({PayException.class})
return CommonJsonResponse.newErrorResponse(); @ResponseStatus
} public CommonJsonResponse handleException(PayException e) {
log.error("【支付异常】", e);
return CommonJsonResponse.newErrorResponse();
}
@ExceptionHandler({Exception.class})
@ResponseBody
public CommonJsonResponse handleException(Exception e) {
if(e instanceof MethodArgumentNotValidException) {
// 参数验证异常处理
MethodArgumentNotValidException validException = (MethodArgumentNotValidException) e;
List<ObjectError> errorList = validException.getBindingResult().getAllErrors();
StringBuffer sb = new StringBuffer();
errorList.forEach(error ->
sb.append(error.getDefaultMessage()).append(";"));
log.error("【参数校验异常】{}", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), sb.toString());
} if(e instanceof BusinessException) {
club.joylink.rtss.exception.BusinessException be = (club.joylink.rtss.exception.BusinessException) e;
log.error("【业务异常】{}", e);
return CommonJsonResponse.newErrorResponse(be.getCode(), be.getVoMessage());
} else if(e instanceof MissingServletRequestParameterException) {
log.error("【接口参数异常】", e);
return CommonJsonResponse.newErrorResponse(ResponseConsts.VALIDATE_ERROR.getCode(), "接口参数异常");
} else if (e instanceof SimulationException) {
club.joylink.rtss.simulation.cbtc.exception.SimulationException simulationException = (club.joylink.rtss.simulation.cbtc.exception.SimulationException) e;
log.error("【仿真系统异常】{}", e);
return CommonJsonResponse.newErrorResponse(simulationException.getCode(), simulationException.getMessage());
}
log.error("【系统异常】{}", e);
return CommonJsonResponse.newErrorResponse();
}
} }

View File

@ -9,7 +9,6 @@ import club.joylink.rtss.vo.paper.CreatePaperCompositionRspVo;
import club.joylink.rtss.vo.paper.FindPaperCompositionByAccountReqVo; import club.joylink.rtss.vo.paper.FindPaperCompositionByAccountReqVo;
import club.joylink.rtss.vo.paper.FindPaperCompositionPageReqVo; import club.joylink.rtss.vo.paper.FindPaperCompositionPageReqVo;
import club.joylink.rtss.vo.paper.PaperCompositionWithRuleVo; import club.joylink.rtss.vo.paper.PaperCompositionWithRuleVo;
import club.joylink.rtss.vo.paper.PaperCompositionWithRuleVo.CreatorBasic;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -110,14 +109,6 @@ public class PaperCompositionController {
return this.compositionService.findPaperCompositionByPage(req); return this.compositionService.findPaperCompositionByPage(req);
} }
/**
* 查询试卷的创建者的信息
*/
@PostMapping("/list/creatorInfo")
public List<CreatorBasic> queryCreatorList(@RequestBody FindPaperCompositionPageReqVo req) {
return compositionService.queryCreatorList(req);
}
/** /**
* 根据mapId查询蓝图的基本信息 * 根据mapId查询蓝图的基本信息
* *

View File

@ -67,7 +67,7 @@ public class DeviceController {
@PostMapping("") @PostMapping("")
public String create(@RequestBody @Validated ProjectDeviceVO deviceVO, public String create(@RequestBody @Validated ProjectDeviceVO deviceVO,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO userLoginInfo) { LoginUserInfoVO userLoginInfo) {
return this.deviceService.create(deviceVO, userLoginInfo); return this.deviceService.create(deviceVO, userLoginInfo);
} }
@ -251,68 +251,63 @@ public class DeviceController {
@PostMapping("/xty/addOrUpdate") @PostMapping("/xty/addOrUpdate")
public void addOrUpdateXtyDeviceConfig( public void addOrUpdateXtyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateXtyDeviceConfig(accountVO); this.deviceService.addOrUpdateXtyDeviceConfig(accountVO);
} }
@PostMapping("/gzb/addOrUpdate") @PostMapping("/gzb/addOrUpdate")
public void addOrUpdateGzbDeviceConfig( public void addOrUpdateGzbDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateGzbDeviceConfig(accountVO); this.deviceService.addOrUpdateGzbDeviceConfig(accountVO);
} }
@PostMapping("/sdy/addOrUpdate") @PostMapping("/sdy/addOrUpdate")
public void addOrUpdateSdyDeviceConfig( public void addOrUpdateSdyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateSdyDeviceConfig(accountVO); this.deviceService.addOrUpdateSdyDeviceConfig(accountVO);
} }
@PostMapping("/zjd/addOrUpdate") @PostMapping("/zjd/addOrUpdate")
public void addOrUpdateZjdDeviceConfig( public void addOrUpdateZjdDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO); this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
} }
@PostMapping("/sr/addOrUpdate/{mapId}") @PostMapping("/sr/addOrUpdate/{mapId}")
public void addOrUpdateSrDeviceConfig( public void addOrUpdateSrDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) { AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateSrDeviceConfig(accountVO, mapId); this.deviceService.addOrUpdateSrDeviceConfig(accountVO, mapId);
} }
@PostMapping("/hhcj/addOrUpdate") @PostMapping("/hhcj/addOrUpdate")
public void addOrUpdateHhcjDeviceConfig( public void addOrUpdateHhcjDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateHhcjDeviceConfig(accountVO); this.deviceService.addOrUpdateHhcjDeviceConfig(accountVO);
} }
@PostMapping("/say/addOrUpdate") @PostMapping("/say/addOrUpdate")
public void addOrUpdateSayDeviceConfig( public void addOrUpdateSayDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateSayDeviceConfig(accountVO); this.deviceService.addOrUpdateSayDeviceConfig(accountVO);
} }
@PostMapping("/thailand/addOrUpdate/{mapId}") @PostMapping("/thailand/addOrUpdate/{mapId}")
public void addOrUpdateThailandDeviceConfig( public void addOrUpdateThailandDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) { AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateThailandDeviceConfig(accountVO, mapId); this.deviceService.addOrUpdateThailandDeviceConfig(accountVO, mapId);
} }
@PostMapping("/ngy/addOrUpdate/{mapId}") @PostMapping("/ngy/addOrUpdate/{mapId}")
public void addOrUpdateNgyDeviceConfig( public void addOrUpdateNgyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) { AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateNgyDeviceConfig(accountVO, mapId); this.deviceService.addOrUpdateNgyDeviceConfig(accountVO, mapId);
} }
@PostMapping("/cdgxy/addOrUpdate")
public void addOrUpdateCdgxyDeviceConfig(@RequestAttribute AccountVO user) {
this.deviceService.addOrUpdateCdgxyDeviceConfig(user);
}
} }

View File

@ -1,91 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.services.race.RaceApplicationService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.paper.PaperTrainAnswerDetail;
import club.joylink.rtss.vo.race.RaceApplication;
import club.joylink.rtss.vo.race.RaceTask;
import club.joylink.rtss.vo.race.RaceTaskFinishParamDTO;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 赛题训练接口
*/
@RestController
@RequestMapping("/api/race")
@AllArgsConstructor
public class RaceApplicationController {
private RaceApplicationService raceApplicationService;
/**
* 开始训练
* <p>
* 目前用用户id作为训练上下文的ID即用户同时进行一个训练
*
* @param paperId 赛题ID
* @return 训练的信息
*/
@PostMapping("/{paperId}/{moduleId}")
public RaceTask.RacePaperSingleModuleGroupTask start(@PathVariable long paperId,
@PathVariable int moduleId, @RequestAttribute AccountVO user) {
return raceApplicationService.start(paperId, moduleId, user.getId());
}
/**
* 加载场景
*
* @param simulationId 场景依托的仿真
* @param sceneId 场景的ID
*/
@PutMapping("/{simulationId}/load/{sceneId}")
public void loadScene(@PathVariable String simulationId, @PathVariable long sceneId,
@RequestAttribute LoginUserInfoVO loginInfo) {
raceApplicationService.loadScene(simulationId, sceneId, loginInfo);
}
/**
* 完成任务
*
* @param taskId 任务ID
* @param paramDTO 完成任务所需的参数主要就是需要前端做判定的操作/步骤
* @return
*/
@PutMapping("/{taskId}/finish")
public List<PaperTrainAnswerDetail> finishTask(@PathVariable long taskId,
@RequestBody RaceTaskFinishParamDTO paramDTO, @RequestAttribute AccountVO user) {
return raceApplicationService.finishTask(taskId, paramDTO, user);
}
/**
* 完成训练
*
* @return 评分结果
*/
@PutMapping("/finish")
public RaceApplication.RacePracticeResult finish(@RequestAttribute AccountVO user) {
return raceApplicationService.finish(user.getId());
}
// /**
// * 获取用户正在进行的竞赛信息
// * <p>
// * 目前想到的使用场景就是页面刷新后
// *
// * @return 竞赛信息
// */
// @GetMapping("")
// public Object getRaceInfo() {
// return null;
// }
}

View File

@ -1,145 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.paper.PagerQuestionService;
import club.joylink.rtss.services.race.RacePaperService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperCreateVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperDetailVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperMenuVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
import club.joylink.rtss.vo.race.RacePaperQueryVO;
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 竞赛-试题管理
*/
@RestController
@RequestMapping("/api/exercise/race/paper")
public class RacePaperController {
@Autowired
private RacePaperService racePaperService;
@Autowired
private PagerQuestionService questionService;
@GetMapping("/questions")
public List<Long> queryQuestionFromPBank() {
return this.questionService.queryAllDefaultOrgPaperIds();
}
/**
* 创建试卷
*/
@PostMapping()
public void save(@RequestBody RacePaperCreateVO createVO, @RequestAttribute AccountVO user) {
racePaperService.create(createVO, user);
}
/**
* 更新试卷内容
*
* @param id
* @param updateVO
* @param user
*/
@PostMapping("/{id}")
public void update(@PathVariable("id") Long id, @RequestBody RacePaperCreateVO updateVO,
@RequestAttribute AccountVO user) {
this.racePaperService.update(id, updateVO, user);
}
/**
* 分页查询
*/
@GetMapping("/page")
public PageVO<RacePaperVO> pageQuery(RacePaperQueryVO queryVO) {
return racePaperService.pageQuery(queryVO);
}
/**
* 获取赛季试卷菜单
*
* @param queryVO
* @return
*/
@GetMapping("/menu")
public RacePaperMenuVO pageMenu(RacePaperQueryVO queryVO) {
return this.racePaperService.pageMenuQuery(queryVO);
}
/**
* 试卷配置
*
* @param id
* @param moduleVO
* @param user
*/
@PostMapping("/{id}/config")
public void configSeting(@PathVariable("id") Long id, @RequestBody RacePaperModuleVO moduleVO,
@RequestAttribute AccountVO user) {
this.racePaperService.configSeting(id, moduleVO, user);
}
/**
* 获取明细
*
* @param id
* @return
*/
@GetMapping("/{id}")
public RacePaperDetailVO detail(@PathVariable("id") Long id) {
return this.racePaperService.detail(id);
}
/**
* 拷贝功能
*
* @param id
* @param user
*/
@PutMapping("/{id}/copy")
public void copy(@PathVariable("id") Long id, @RequestAttribute AccountVO user) {
this.racePaperService.copy(id, user);
}
/**
* 删除
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable("id") Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(id);
racePaperService.delete(id);
}
/**
* 获取试卷对应模块的模块任务树
*
* @param id
* @param moduleId
* @return
*/
@GetMapping("/{paperId}/module/{moduleId}/task")
public RacePaperSingleModuleGroupTask paperModuleTask(@PathVariable("paperId") Long id,
@PathVariable("moduleId") Integer moduleId) {
return this.racePaperService.singlePaperModuleTask(id, moduleId);
}
}

View File

@ -1,85 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.services.race.RaceSceneService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceSceneListVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceSceneVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.SceneCustomCreateVO;
import club.joylink.rtss.vo.race.RaceSceneQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 竞赛-场景管理-发布的管理
*/
@RestController
@RequestMapping("/api/exercise/race/scene")
public class RaceSceneController {
@Autowired
private RaceSceneService sceneService;
@PostMapping("/custom/edit")
public void customSave(@RequestBody SceneCustomCreateVO vo, @RequestAttribute AccountVO user) {
this.sceneService.customSave(vo, user);
}
@PostMapping("/custom/{id}/edit")
public void customUpdate(@PathVariable("id") Long id, @RequestBody SceneCustomCreateVO vo, @RequestAttribute AccountVO user) {
this.sceneService.customUpdate(id, vo, user);
}
/**
* 草稿实训发布到场景
*
* @param vo
* @param user
*/
@PostMapping("/publish/training")
public void publishHere(@RequestBody RaceScenePublishVO vo, @RequestAttribute AccountVO user) {
this.sceneService.publishHere(vo, user);
}
/**
* 获取明细
*
* @param id
* @return
*/
@GetMapping("/{id}")
public RaceSceneVO detail(@PathVariable("id") Long id) {
return this.sceneService.detail(id);
}
/**
* 分页
*
* @param query
* @return
*/
@GetMapping("/page")
public PageVO<RaceSceneListVO> page(RaceSceneQueryVO query) {
return this.sceneService.page(query);
}
/**
* 删除
*
* @param id
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable("id") Long id) {
this.sceneService.delete(id);
}
}

View File

@ -1,88 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.services.race.RaceScoreRuleService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.race.RaceScoringRule.RaceScoringRuleListVO;
import club.joylink.rtss.vo.race.RaceScoringRule.RaceScoringRuleVO;
import club.joylink.rtss.vo.race.RaceScoringRule.Rule;
import club.joylink.rtss.vo.race.TaskRuleQueryVO;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 竞赛-评分
*/
@RestController
@RequestMapping("/api/exercise/race/score")
public class RaceScoreRuleController {
@Autowired
private RaceScoreRuleService scoreRuleService;
/**
* 1.创建基础信息
*
* @param nameMap
* @param user
*/
@PostMapping
public void saveBasic(@RequestBody Map<String, String> nameMap, @RequestAttribute AccountVO user) {
this.scoreRuleService.saveBasic(nameMap.get("name"), user);
}
/**
* 评分配置
*
* @param ruleId
* @param rule
* @param user
*/
@PostMapping("/edit/rule/{ruleId}")
public void editRule(@PathVariable("ruleId") Long ruleId, @RequestBody Rule rule, @RequestAttribute AccountVO user) {
this.scoreRuleService.editRule(ruleId, rule, user);
}
/**
* 明细
*
* @param id
* @return
*/
@GetMapping(value = "/{id}")
public RaceScoringRuleVO detail(@PathVariable("id") Long id) {
return this.scoreRuleService.detail(id);
}
/**
* 分页
*
* @param query
* @return
*/
@GetMapping("/page")
public PageVO<RaceScoringRuleListVO> page(TaskRuleQueryVO query) {
return this.scoreRuleService.page(query);
}
/**
* 删除
*
* @param id
*/
@DeleteMapping("{id}")
public void delete(@PathVariable("id") Long id) {
this.scoreRuleService.delete(id);
}
}

View File

@ -1,102 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.services.race.RaceSeasonService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeasonCreateVO;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeasonVO;
import club.joylink.rtss.vo.race.RaceSeasonQueryVO;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 竞赛-赛季管理
*/
@RestController
@RequestMapping("/api/exercise/race/season")
public class RaceSeasonController {
@Autowired
private RaceSeasonService raceSeasonService;
/**
* 添加
*
* @param dto
* @param user
*/
@PostMapping
public void save(@RequestBody RaceSeasonCreateVO dto, @RequestAttribute AccountVO user) {
this.raceSeasonService.save(dto, user);
}
/**
* 修改
*
* @param id
* @param dto
* @param user
*/
@PostMapping("/{id}")
public void update(@PathVariable("id") Long id, @RequestBody RaceSeasonCreateVO dto, @RequestAttribute AccountVO user) {
this.raceSeasonService.update(id, dto, user);
}
/**
* 编辑html内容
*
* @param id
* @param user
*/
@PostMapping("/{id}/html")
public void updateHtmlContent(@PathVariable("id") Long id, @RequestBody Map<String, String> contentMap, @RequestAttribute AccountVO user) {
String content = contentMap.get("htmlContent");
this.raceSeasonService.updateHtmlContent(id, content, user);
}
/**
* 查找对应的html content
*
* @param id
* @return
*/
@GetMapping("/{id}/html")
public Map<String, String> queryHtmlContent(@PathVariable("id") Long id) {
String html = this.raceSeasonService.queryHtmlContent(id);
return Map.of("html", StringUtils.hasText(html) ? html : "");
}
/**
* 查找
*
* @param query
* @return
*/
@GetMapping(value = "/page")
public PageVO<RaceSeasonVO> page(RaceSeasonQueryVO query) {
return raceSeasonService.page(query);
}
/**
* 删除
*
* @param id
*/
//绑定过的数据不能删除没有绑定的可以删除物理删除
@DeleteMapping("/{id}")
public void delete(@PathVariable("id") Long id) {
this.raceSeasonService.delete(id);
}
}

View File

@ -1,94 +0,0 @@
package club.joylink.rtss.controller.racetr;
import club.joylink.rtss.services.race.RaceTaskService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskBind;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskCreateVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskDetailVO;
import club.joylink.rtss.vo.race.RaceTaskTreeVO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/exercise/race/task")
public class RaceTaskController {
@Autowired
private RaceTaskService taskService;
/**
* 创建任务并绑定对应的发布场景
*
* @param vo
* @param user
*/
@PostMapping
public void save(@RequestBody RaceTaskCreateVO vo, @RequestAttribute AccountVO user) {
this.taskService.save(vo, user);
}
@PostMapping("/{id}")
public void update(@PathVariable("id") Long id, @RequestBody RaceTaskCreateVO vo,
@RequestAttribute AccountVO user) {
this.taskService.update(id, vo, user);
}
@PostMapping("/{taskId}/bind")
public void bind(@PathVariable("taskId") Long taskId, @RequestBody List<RaceTaskBind> bind,
@RequestAttribute AccountVO user) {
this.taskService.bind(taskId, bind, user);
}
/**
* 返回任务数据以""的结构
*
* @return
*/
@GetMapping("/tree")
public List<RaceTaskTreeVO> tree() {
return this.taskService.tree();
}
/**
* 删除
*
* @param id
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable("id") Long id) {
this.taskService.delete(id);
}
/**
* 获取一个节点下的所有数据
*
* @param id
* @return
*/
@GetMapping("/{id}/children")
public List<RaceTaskTreeVO> childList(@PathVariable("id") Long id) {
return this.taskService.findChildren(id);
}
/**
* 获取一个节点的明细
*
* @param id
* @return
*/
@GetMapping("/{id}")
public RaceTaskDetailVO detail(@PathVariable("id") Long id) {
return this.taskService.detail(id);
}
}

View File

@ -6,33 +6,17 @@ import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.controller.advice.Role; import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.entity.training2.ExportTraining2; import club.joylink.rtss.entity.training2.ExportTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.services.training2.Training2DraftPublishService; import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.services.training2.Training2PublishService; import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.services.training2.Training2TypeEnum;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.training2.publish.DeletePublishedTraining2ReqVo; import club.joylink.rtss.vo.training2.publish.*;
import club.joylink.rtss.vo.training2.publish.DeletePublishedTraining2RspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2DetailRspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoPageReqVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoRspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTrainingListRspVo;
import club.joylink.rtss.vo.training2.publish.PullOffPublishedTraining2ReqVo;
import club.joylink.rtss.vo.training2.publish.PullOffPublishedTraining2RspVo;
import club.joylink.rtss.vo.training2.publish.PutOnPublishedTraining2ReqVo;
import club.joylink.rtss.vo.training2.publish.PutOnPublishedTraining2RspVo;
import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import java.util.List;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 已发布实训管理接口 * 已发布实训管理接口
@ -41,171 +25,123 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/api/v2/training/published") @RequestMapping("/api/v2/training/published")
public class TrainingV2PublishController { public class TrainingV2PublishController {
@Autowired
private Training2PublishService publishService;
@Autowired /**
private Training2PublishService publishService; * 已发布实训分页列表
*/
@PostMapping("/page")
public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage(@RequestBody PublishedTraining2InfoPageReqVo req){
return this.publishService.publishedTrainingsPage(req);
}
/**
* 已发布实训上架
*/
@PostMapping("/put/on")
public PutOnPublishedTraining2RspVo putOnPublishedTrainings(@RequestBody PutOnPublishedTraining2ReqVo req,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
return this.publishService.putOnPublishedTrainings(req,userInfoVO);
}
/**
* 已发布实训下架
*/
@PostMapping("/pull/off")
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(@RequestBody PullOffPublishedTraining2ReqVo req,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
return this.publishService.pullOffPublishedTrainings(req,userInfoVO);
}
@Autowired /**
private Training2DraftPublishService training2DraftPublishService; * 变更共享状态
* @param id
/** * @param shared
* 已发布实训分页列表 * @param userInfoVO
*/ */
@PostMapping("/page") @GetMapping("/{id}/{shared}")
public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage( public void changeSharedStatus(@PathVariable(name="id") Long id,@PathVariable(name="shared") Integer shared,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
@RequestBody PublishedTraining2InfoPageReqVo req) { this.publishService.changeSharedStatus(id,shared,userInfoVO);
return this.publishService.publishedTrainingsPage(req); }
} /**
* 删除已发布实训
/** */
* 已发布实训上架 @DeleteMapping
*/ public DeletePublishedTraining2RspVo deletePublishedTrainings(@RequestBody DeletePublishedTraining2ReqVo req,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
@PostMapping("/put/on") return this.publishService.deletePublishedTrainings(req,userInfoVO);
public PutOnPublishedTraining2RspVo putOnPublishedTrainings( }
@RequestBody PutOnPublishedTraining2ReqVo req,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
return this.publishService.putOnPublishedTrainings(req, userInfoVO);
}
/**
* 已发布实训下架
*/
@PostMapping("/pull/off")
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(
@RequestBody PullOffPublishedTraining2ReqVo req,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
return this.publishService.pullOffPublishedTrainings(req, userInfoVO);
}
/**
* 变更共享状态
*
* @param id
* @param shared
* @param userInfoVO
*/
@GetMapping("/{id}/{shared}")
public void changeSharedStatus(@PathVariable(name = "id") Long id,
@PathVariable(name = "shared") Integer shared,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
this.publishService.changeSharedStatus(id, shared, userInfoVO);
}
/**
* 删除已发布实训
*/
@DeleteMapping
public DeletePublishedTraining2RspVo deletePublishedTrainings(
@RequestBody DeletePublishedTraining2ReqVo req,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
return this.publishService.deletePublishedTrainings(req, userInfoVO);
}
/** /**
* 实训查询用户管理 * 实训查询用户管理
* * @param vo
* @param vo * @return
* @return */
*/ @PostMapping("/manage/infos")
@PostMapping("/manage/infos") public PageVO<PublishedTraining2InfoRspVo> findTrainingListManageInfosForPage(@RequestBody PublishedTrainingListRspVo vo,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
public PageVO<PublishedTraining2InfoRspVo> findTrainingListManageInfosForPage( vo.setOrgId(userInfoVO.getTopOrgId());
@RequestBody PublishedTrainingListRspVo vo, return this.publishService.findTrainingInfoForPage(vo,userInfoVO,true);
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) { }
vo.setOrgId(userInfoVO.getTopOrgId());
return this.publishService.findTrainingInfoForPage(vo, userInfoVO, true);
}
/** /**
* 实训查询 * 实训查询
* * @param vo
* @param vo * @return
* @return */
*/ @PostMapping("/infos")
@PostMapping("/infos") public List<PublishedTraining2InfoRspVo> findTrainingListInfos(@RequestBody PublishedTrainingListRspVo vo
public List<PublishedTraining2InfoRspVo> findTrainingListInfos( ,@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO){
@RequestBody PublishedTrainingListRspVo vo, //只查询以上架
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO) { vo.setState(BusinessConsts.STATUS_USE_INT);
//只查询以上架 vo.setOrgId(loginUserInfoVO.getTopOrgId());
vo.setState(BusinessConsts.STATUS_USE_INT); return this.publishService.findTrainingInfo(vo,loginUserInfoVO);
vo.setOrgId(loginUserInfoVO.getTopOrgId()); }
return this.publishService.findTrainingInfo(vo, loginUserInfoVO); /**
} * 查所有的已发布场景实训的基础信息
*/
@Role(value = RoleEnum.SuperAdmin)
@GetMapping("/list")
public PageVO<PublishedTraining2InfoRspVo> findTrainingList(@ModelAttribute PublishedTrainingListRspVo vo,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){
return this.publishService.findTrainingInfoForPage(vo,userInfoVO,false);
}
/** /**
* 查所有的已发布场景实训的基础信息 * 根据实训id查该已发布实训的所有信息
*/ */
@Role(value = RoleEnum.SuperAdmin) @GetMapping("/{trainingId}")
@GetMapping("/list") public PublishedTraining2DetailRspVo findTrainingAllInfo(@PathVariable("trainingId") Long trainingId){
public PageVO<PublishedTraining2InfoRspVo> findTrainingList( return this.publishService.findTrainingAllInfoById(trainingId);
@ModelAttribute PublishedTrainingListRspVo vo, }
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
return this.publishService.findTrainingInfoForPage(vo, userInfoVO, false);
}
/** /**
* 根据实训id查该已发布实训的所有信息 * 更新实训label
*/ */
@GetMapping("/{trainingId}") @PutMapping("/update/label")
public PublishedTraining2DetailRspVo findTrainingAllInfo( public void updateTrainingLabel(@RequestBody PublishedTraining2 training2) {
@PathVariable("trainingId") Long trainingId) { publishService.updateTrainingLabel(training2);
return this.publishService.findTrainingAllInfoById(trainingId); }
}
/** /**
* 更新实训label * 批量更新实训label
*/ */
@PutMapping("/update/label") @PutMapping("/update/batch/label")
public void updateTrainingLabel(@RequestBody PublishedTraining2 training2) { public void updateTrainingLabelList(@RequestBody List<PublishedTraining2> publishedTraining2List) {
publishService.updateTrainingLabel(training2); publishService.updateTrainingLabelList(publishedTraining2List);
} }
/** /**
* 更新发布实训信息 * 导出所选实训
*/ * @param tidList 实训ID列表
@PutMapping("/update") * @return 实训详情信息
public void updateTraining(@RequestBody PublishedTraining2 training2) { */
publishService.updateTrainingBaseInfo(training2); @PostMapping("/export")
} public List<ExportTraining2> exportTraining(@RequestBody List<Long> tidList) {
return publishService.exportTraining(tidList);
}
/**
/** * 导入实训信息
* 批量更新实训label * @return 导入结果
*/ */
@PutMapping("/update/batch/label") @PostMapping("/import")
public void updateTrainingLabelList( public List<String> importTraining(@RequestBody List<ExportTraining2> trainingList, @RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
@RequestBody List<PublishedTraining2> publishedTraining2List) { return publishService.importTraining(trainingList, userInfoVO);
publishService.updateTrainingLabelList(publishedTraining2List); }
}
/**
* 导出所选实训
*
* @param tidList 实训ID列表
* @return 实训详情信息
*/
@PostMapping("/export")
public List<ExportTraining2> exportTraining(@RequestBody List<Long> tidList) {
return publishService.exportTraining(tidList);
}
/**
* 导入实训信息
*
* @return 导入结果
*/
@PostMapping("/import")
public List<String> importTraining(@RequestBody List<ExportTraining2> trainingList,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
return publishService.importTraining(trainingList, userInfoVO);
}
/**
* 保存为草稿
*/
@PostMapping("/{trainingId}/saveAsDraft")
public void saveAsDraft(@PathVariable("trainingId") Long trainingId,
@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
training2DraftPublishService.saveAsDraft(trainingId, userInfoVO);
}
} }

View File

@ -4,25 +4,15 @@ import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.UserQueryVO; import club.joylink.rtss.vo.UserQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.user.MobileInfoVO; import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.client.user.RetrievePwdVO;
import club.joylink.rtss.vo.client.user.UpdateEmailVO;
import club.joylink.rtss.vo.client.user.UpdateMobileVO;
import club.joylink.rtss.vo.client.user.UpdatePasswordVO;
import club.joylink.rtss.vo.user.AccountCreateVO; import club.joylink.rtss.vo.user.AccountCreateVO;
import club.joylink.rtss.vo.user.AccountRegisterVO; import club.joylink.rtss.vo.user.AccountRegisterVO;
import club.joylink.rtss.vo.user.UserRegisterCheck; import club.joylink.rtss.vo.user.UserRegisterCheck;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import java.util.List;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 系统账户接口 * 系统账户接口
@ -31,186 +21,165 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/userinfo") @RequestMapping("/api/userinfo")
public class SysAccountController { public class SysAccountController {
@Autowired @Autowired
private ISysUserService iSysUserService; private ISysUserService iSysUserService;
@PostMapping("/register") @PostMapping("/register")
public void register( public void register(@RequestBody @Validated(value = UserRegisterCheck.class) AccountCreateVO accountCreateVO) {
@RequestBody @Validated(value = UserRegisterCheck.class) AccountCreateVO accountCreateVO) { this.iSysUserService.register(accountCreateVO);
this.iSysUserService.register(accountCreateVO); }
}
/** /**
* 新注册接口 * 新注册接口
*/ */
@PostMapping("/register2") @PostMapping("/register2")
public void register2(@RequestBody @Validated AccountRegisterVO registerVO) { public void register2(@RequestBody @Validated AccountRegisterVO registerVO) {
this.iSysUserService.register2(registerVO); this.iSysUserService.register2(registerVO);
} }
/** /**
* 根据姓名或电话号查询用户 *根据姓名或电话号查询用户
*/ */
@GetMapping(path = "/nameOrMobile") @GetMapping(path="/nameOrMobile")
public List<AccountVO> queryUserByNameOrMobile(String query) { public List<AccountVO> queryUserByNameOrMobile(String query) {
List<AccountVO> list = this.iSysUserService.queryUserByNameOrMobile(query); List<AccountVO> list = this.iSysUserService.queryUserByNameOrMobile(query);
return list; return list;
} }
/** /**
* 手机号是否已经注册 * 手机号是否已经注册
*/ */
@GetMapping("/isExist/mobile") @GetMapping("/isExist/mobile")
public boolean isMobileExist(String mobile) { public boolean isMobileExist(String mobile) {
return iSysUserService.isSameMobileExist(mobile); return iSysUserService.isSameMobileExist(mobile);
} }
/** /**
* 邮箱是否已经注册 * 邮箱是否已经注册
*/ */
@GetMapping("/isExist/email") @GetMapping("/isExist/email")
public boolean isEmailExist(String email) { public boolean isEmailExist(String email) {
return iSysUserService.isSameEmailExist(email); return iSysUserService.isSameEmailExist(email);
} }
/** /**
* 根据用户id获取用户信息 *根据用户id获取用户信息
*/ */
@GetMapping(path = "/{id}") @GetMapping(path = "/{id}")
public AccountVO getUserBaseInfoById(@PathVariable Long id) { public AccountVO getUserBaseInfoById(@PathVariable Long id) {
return this.iSysUserService.getUserBaseInfoById(id); return this.iSysUserService.getUserBaseInfoById(id);
} }
/** /**
* 修改用户信息 *修改用户信息
*/ */
@PutMapping(path = "/{id}") @PutMapping(path = "/{id}")
public void modify(@PathVariable Long id, @RequestBody AccountVO userInfo, String vdcode) { public void modify(@PathVariable Long id, @RequestBody AccountVO userInfo, String vdcode) {
this.iSysUserService.modify(id, userInfo, vdcode); this.iSysUserService.modify(id, userInfo, vdcode);
} }
/** /**
* 微信关注事件 *微信关注事件
*/ */
@GetMapping(path = "/wxsubscribe") @GetMapping(path = "/wxsubscribe")
public void wxSubscribe(@RequestParam String wxId) { public void wxSubscribe(@RequestParam String wxId) {
iSysUserService.wxSubscribeEventHandle(wxId); iSysUserService.wxSubscribeEventHandle(wxId);
} }
/** /**
* 批量修改用户的openId为unionId *批量修改用户的openId为unionId
*/ */
@PutMapping(path = "/batchchange/unionid") @PutMapping(path = "/batchchange/unionid")
public void batchChangeOpenId2UnionId() { public void batchChangeOpenId2UnionId() {
this.iSysUserService.batchChangeOpenId2UnionId(); this.iSysUserService.batchChangeOpenId2UnionId();
} }
/** /**
* 更新用户真实姓名 *更新用户真实姓名
*/ */
@PutMapping(path = "/{id}/name") @PutMapping(path = "/{id}/name")
public void updateName(@PathVariable Long id, String name) { public void updateName(@PathVariable Long id, String name) {
this.iSysUserService.updateUserName(id, name); this.iSysUserService.updateUserName(id, name);
} }
/** /**
* 更新用户昵称 *更新用户昵称
*/ */
@PutMapping(path = "/{id}/nickname") @PutMapping(path = "/{id}/nickname")
public void updateNickname(@PathVariable Long id, String nickname) { public void updateNickname(@PathVariable Long id, String nickname) {
this.iSysUserService.updateNickname(id, nickname); this.iSysUserService.updateNickname(id, nickname);
} }
/** /**
* 用户上传头像 *用户上传头像
*/ */
@PostMapping(path = "/{id}/avatar") @PostMapping(path = "/{id}/avatar")
public void uploadAvatar(@PathVariable Long id, @RequestBody AccountVO accountVO) { public void uploadAvatar(@PathVariable Long id, @RequestBody AccountVO accountVO) {
this.iSysUserService.updateAvatar(id, accountVO.getAvatarPath()); this.iSysUserService.updateAvatar(id, accountVO.getAvatarPath());
} }
/** /**
* 发送手机验证码 *发送手机验证码
*/ */
@PostMapping(path = "/mobile/code") @PostMapping(path = "/mobile/code")
public String sendMobileValidCode(@RequestBody MobileInfoVO mobileInfoVO) { public String sendMobileValidCode(@RequestBody MobileInfoVO mobileInfoVO) {
return this.iSysUserService.sendMobileValidCode(mobileInfoVO); return this.iSysUserService.sendMobileValidCode(mobileInfoVO);
} }
/** /**
* 发送邮箱验证码 *发送邮箱验证码
*/ */
@PostMapping(path = "/email/code") @PostMapping(path = "/email/code")
public String sendEmailValidCode(String email) { public String sendEmailValidCode(String email) {
return this.iSysUserService.sendEmailValidCode(email); return this.iSysUserService.sendEmailValidCode(email);
} }
/** /**
* 更新用户手机号 *更新用户手机号
*/ */
@PutMapping(path = "/{id}/mobile") @PutMapping(path = "/{id}/mobile")
public void updateMobile(@PathVariable Long id, public void updateMobile(@PathVariable Long id, @RequestBody @Validated UpdateMobileVO updateMobileVO) {
@RequestBody @Validated UpdateMobileVO updateMobileVO) { this.iSysUserService.updateMobile(id, updateMobileVO);
this.iSysUserService.updateMobile(id, updateMobileVO); }
}
/** /**
* 更新用户邮箱 *更新用户邮箱
*/ */
@PutMapping(path = "/{id}/email") @PutMapping(path = "/{id}/email")
public void updateEmail(@PathVariable Long id, public void updateEmail(@PathVariable Long id, @RequestBody @Validated UpdateEmailVO updateEmailVO) {
@RequestBody @Validated UpdateEmailVO updateEmailVO) { this.iSysUserService.updateEmail(id, updateEmailVO);
this.iSysUserService.updateEmail(id, updateEmailVO); }
}
/** /**
* 更新用户登陆密码 *更新用户登陆密码
*/ */
@PutMapping(path = "/{id}/password") @PutMapping(path = "/{id}/password")
public void updatePassword(@PathVariable Long id, public void updatePassword(@PathVariable Long id, @RequestBody @Validated UpdatePasswordVO updatePasswordVO) {
@RequestBody @Validated UpdatePasswordVO updatePasswordVO) { this.iSysUserService.updatePassword(id, updatePasswordVO);
this.iSysUserService.updatePassword(id, updatePasswordVO); }
}
/** /**
* 按条件分页查询指定来源的账号 * 按条件分页查询指定来源的账号
*/ */
@GetMapping("/page/criteria/{source}") @GetMapping("/page/criteria/{source}")
public PageVO<AccountVO> queryPagedAccountOfTheSource(UserQueryVO queryVO, public PageVO<AccountVO> queryPagedAccountOfTheSource(UserQueryVO queryVO, @PathVariable String source) {
@PathVariable String source) { queryVO.setSource(source);
queryVO.setSource(source); return this.iSysUserService.queryPagedUser(queryVO);
return this.iSysUserService.queryPagedUser(queryVO); }
}
/** /**
* 超管重置用户密码 * 超管重置用户密码
*/ */
@PutMapping("/{id}/reset/pwd") @PutMapping("/{id}/reset/pwd")
public void resetPwd(@PathVariable long id) { public void resetPwd(@PathVariable long id) {
iSysUserService.resetPwd(id); iSysUserService.resetPwd(id);
} }
/** /**
* 找回密码 * 找回密码
*/ */
@PutMapping("/retrieve/pwd") @PutMapping("/retrieve/pwd")
public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) { public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) {
iSysUserService.retrievePwd(vo); iSysUserService.retrievePwd(vo);
} }
/**
* 根据用户id列表获取用户信息
*/
@PostMapping("/list/ids")
public List<AccountVO> listByIds(@RequestBody List<Long> ids) {
return iSysUserService.listByIds(ids);
}
/**
* 查询所有用户
*/
@GetMapping("/list/all")
public List<AccountVO> listAll() {
return iSysUserService.listAll();
}
} }

View File

@ -4,14 +4,11 @@ import club.joylink.rtss.services.voice.IVoiceTrainingService;
import club.joylink.rtss.services.voice.baidu.TokenHolder; import club.joylink.rtss.services.voice.baidu.TokenHolder;
import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult; import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO; import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -23,46 +20,34 @@ import org.springframework.web.multipart.MultipartFile;
@RequestMapping("/api/voice") @RequestMapping("/api/voice")
public class VoiceController { public class VoiceController {
@Autowired @Autowired
private IVoiceTrainingService iVoiceTrainingService; private IVoiceTrainingService iVoiceTrainingService;
/** /**
* 语音识别 * 语音识别
* * @param file
* @param file * @return
* @return */
*/ @PostMapping("recognition")
@PostMapping("recognition") public VoiceRecognitionResult voiceRecognition(MultipartFile file) {
public VoiceRecognitionResult voiceRecognition(MultipartFile file) { return iVoiceTrainingService.voiceRecognition(file);
return iVoiceTrainingService.voiceRecognition(file); }
}
/** /**
* 查询语音识别错误集 * 查询语音识别错误集
* * @param queryVO
* @param queryVO * @return
* @return */
*/ @GetMapping("/errorSet/paged")
@GetMapping("/errorSet/paged") public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) {
public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) { return iVoiceTrainingService.pagedQueryErrorSet(queryVO);
return iVoiceTrainingService.pagedQueryErrorSet(queryVO); }
}
/** /**
* 获取百度语音识别token * 获取百度语音识别token
*/ */
@GetMapping("/token/baidu") @GetMapping("/token/baidu")
public String getBaiduToken() { public String getBaiduToken() {
return TokenHolder.getInstance().getToken(); return TokenHolder.getInstance().getToken();
} }
/**
* 校验语音识别结果
*/
@PostMapping("/verify")
public VoiceVerifyResultVO verifyVoice(HttpServletRequest request, @RequestBody byte[] fileData,
String text) {
String contentType = request.getHeader("Content-Type");
return iVoiceTrainingService.verifyVoice(contentType, fileData, text);
}
} }

View File

@ -2,55 +2,51 @@ package club.joylink.rtss.controller.voice;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.services.voice.IVoiceDataConfigService; import club.joylink.rtss.services.voice.IVoiceDataConfigService;
import club.joylink.rtss.services.voice.IVoiceTrainingService;
import club.joylink.rtss.services.voice.baidu.TokenHolder;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO; import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO;
import club.joylink.rtss.vo.voice.VoiceQueryVO; import club.joylink.rtss.vo.voice.VoiceQueryVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 语音管理接口 * 语音AI接口
*/ */
@RestController @RestController
@RequestMapping("/api/voice/manage") @RequestMapping("/api/voice/manage")
public class VoiceManageController { public class VoiceManageController {
@Autowired @Autowired
private IVoiceDataConfigService configService; private IVoiceDataConfigService configService;
@PostMapping("saveOrUpdate") @PostMapping("saveOrUpdate")
public void saveOrUpdate(@RequestBody VoiceDiscriminateConfigVO configVO, public void saveOrUpdate(@RequestBody VoiceDiscriminateConfigVO configVO, @RequestAttribute(name= AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) { this.configService.saveOrUpdate(configVO,userInfoVO);
this.configService.saveOrUpdate(configVO, userInfoVO); }
}
@GetMapping("find/{id}") @GetMapping("find/{id}")
public VoiceDiscriminateConfigVO find(@PathVariable(value = "id") Long id) { public VoiceDiscriminateConfigVO find(@PathVariable(value = "id") Long id) {
return this.configService.byId(id); return this.configService.byId(id);
} }
@GetMapping("query") @GetMapping("query")
public PageVO<VoiceDiscriminateConfigVO> query(@ModelAttribute VoiceQueryVO queryVO) { public PageVO<VoiceDiscriminateConfigVO> query(@ModelAttribute VoiceQueryVO queryVO){
return this.configService.query(queryVO); return this.configService.query(queryVO);
} }
/** /**
* 获取百度语音识别token * 获取百度语音识别token
*/ */
@GetMapping("{id}/{status}") @GetMapping("{id}/{status}")
public void changeStatus(@PathVariable(value = "id") Long id, public void changeStatus(@PathVariable(value = "id") Long id,@PathVariable(value = "status")Integer status,@RequestAttribute(name= AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) {
@PathVariable(value = "status") Integer status, this.configService.changeStatus(id,status,userInfoVO);
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO) { }
this.configService.changeStatus(id, status, userInfoVO);
}
} }

View File

@ -1,12 +0,0 @@
package club.joylink.rtss.dao;
import club.joylink.rtss.entity.CgyView;
import club.joylink.rtss.entity.CgyViewExample;
import org.springframework.stereotype.Repository;
/**
* CgyViewDAO继承基类
*/
@Repository
public interface CgyViewDAO extends MyBatisBaseDao<CgyView, String, CgyViewExample> {
}

View File

@ -0,0 +1,12 @@
//package club.joylink.rtss.dao;
//
//import club.joylink.rtss.entity.Company;
//import club.joylink.rtss.entity.CompanyExample;
//import org.springframework.stereotype.Repository;
//
///**
// * CompanyDAO继承基类
// */
////@Repository
////public interface CompanyDAO extends MyBatisBaseDao<Company, Integer, CompanyExample> {
////}

View File

@ -14,9 +14,8 @@ import java.util.List;
@Mapper @Mapper
@Repository @Repository
public interface PaperQuestionDAO { public interface PaperQuestionDAO {
@Select("<script>" +
@Select("<script>" + "select * from rts_paper_question where 1 = 1 " +
"select * from rts_paper_question where 1 = 1 " +
// "<choose>" + // "<choose>" +
// "<when test=\"projectCode == '"+ Project.DEFAULT_PROJECT_CODE +"'\">"+ // "<when test=\"projectCode == '"+ Project.DEFAULT_PROJECT_CODE +"'\">"+
// " and project_code is null" + // " and project_code is null" +
@ -25,54 +24,48 @@ public interface PaperQuestionDAO {
// " and project_code = #{projectCode} "+ // " and project_code = #{projectCode} "+
// " </otherwise>" + // " </otherwise>" +
// "</choose>" + // "</choose>" +
" and org_id = #{companyId,jdbcType=BIGINT} " + " and org_id = #{companyId,jdbcType=BIGINT} " +
// "<if test=\"companyIdList != null and companyIdList.size > 0\">"+ // "<if test=\"companyIdList != null and companyIdList.size > 0\">"+
// "<foreach collection=\"companyIdList\" open=\" and company_id in (\" close=\")\" item=\"d\" separator=\",\">"+ // "<foreach collection=\"companyIdList\" open=\" and company_id in (\" close=\")\" item=\"d\" separator=\",\">"+
// " #{d} "+ // " #{d} "+
// "</foreach></if>"+ // "</foreach></if>"+
" and is_del= #{isDelete,jdbcType=INTEGER} " + " and is_del= #{isDelete,jdbcType=INTEGER} " +
"<if test=\"types != null and types.size > 0\">" + "<if test=\"types != null and types.size > 0\">"+
"<foreach collection=\"types\" open=\" and type in (\" close=\")\" item=\"d\" separator=\",\">" + "<foreach collection=\"types\" open=\" and type in (\" close=\")\" item=\"d\" separator=\",\">"+
" #{d} " + " #{d} "+
"</foreach></if>" + "</foreach></if>"+
"<if test=\"lable != null and lable.size > 0\"> " + "<if test=\"lable != null and lable.size > 0\"> " +
" <foreach collection=\"lable\" open=\" and (\" close=\")\" item=\"d\" separator=\" or \"> " + " <foreach collection=\"lable\" open=\" and (\" close=\")\" item=\"d\" separator=\" or \"> "+
" find_in_set(#{d},race_lable) > 0 " + " find_in_set(#{d},race_lable) > 0 "+
" </foreach>" + " </foreach>" +
"</if>" + "</if>" +
"</script>") "</script>")
List<PaperQuestionWithBLOBs> findFromAndRaceLable(Long companyId, int isDelete, List<String> lable, List<String> types); List<PaperQuestionWithBLOBs> findFromAndRaceLable(Long companyId,int isDelete, List<String> lable, List<String> types);
long countByExample(PaperQuestionExample example);
@Select("<script>" + int deleteByExample(PaperQuestionExample example);
"select id from rts_paper_question where org_id = #{orgId} "
+ "</script>")
List<Long> findAllId(@Param("orgId") Long id);
long countByExample(PaperQuestionExample example); int deleteByPrimaryKey(Long id);
int deleteByExample(PaperQuestionExample example); int insert(PaperQuestionWithBLOBs record);
int deleteByPrimaryKey(Long id); int insertSelective(PaperQuestionWithBLOBs record);
int insert(PaperQuestionWithBLOBs record); List<PaperQuestionWithBLOBs> selectByExampleWithBLOBs(PaperQuestionExample example);
int insertSelective(PaperQuestionWithBLOBs record); List<PaperQuestion> selectByExample(PaperQuestionExample example);
List<PaperQuestionWithBLOBs> selectByExampleWithBLOBs(PaperQuestionExample example); PaperQuestionWithBLOBs selectByPrimaryKey(Long id);
List<PaperQuestion> selectByExample(PaperQuestionExample example); int updateByExampleSelective(@Param("record") PaperQuestionWithBLOBs record, @Param("example") PaperQuestionExample example);
PaperQuestionWithBLOBs selectByPrimaryKey(Long id); int updateByExampleWithBLOBs(@Param("record") PaperQuestionWithBLOBs record, @Param("example") PaperQuestionExample example);
int updateByExampleSelective(@Param("record") PaperQuestionWithBLOBs record, @Param("example") PaperQuestionExample example); int updateByExample(@Param("record") PaperQuestion record, @Param("example") PaperQuestionExample example);
int updateByExampleWithBLOBs(@Param("record") PaperQuestionWithBLOBs record, @Param("example") PaperQuestionExample example); int updateByPrimaryKeySelective(PaperQuestionWithBLOBs record);
int updateByExample(@Param("record") PaperQuestion record, @Param("example") PaperQuestionExample example); int updateByPrimaryKeyWithBLOBs(PaperQuestionWithBLOBs record);
int updateByPrimaryKeySelective(PaperQuestionWithBLOBs record); int updateByPrimaryKey(PaperQuestion record);
int updateByPrimaryKeyWithBLOBs(PaperQuestionWithBLOBs record);
int updateByPrimaryKey(PaperQuestion record);
} }

View File

@ -1,55 +0,0 @@
package club.joylink.rtss.dao.racetr;
import club.joylink.rtss.dao.MyBatisBaseDao;
import club.joylink.rtss.entity.racetr.RacetrPaper;
import club.joylink.rtss.entity.racetr.RacetrPaperExample;
import club.joylink.rtss.vo.race.RacePaperPageVO;
import club.joylink.rtss.vo.race.RacePaperQueryVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
/**
* RacetrPaperDAO继承基类
*/
@Repository
public interface RacetrPaperDAO extends MyBatisBaseDao<RacetrPaper, Long, RacetrPaperExample> {
@Select("<script>"
+ " select A.id,A.name,A.`desc`,A.season_id as seasonId ,B.code as seasonName,B.group,B.term as seasonTerm"
+ " ,A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ " from racetr_paper A left join racetr_season B on A.season_id = B.id "
+ " left join sys_account C on A.creator_id = C.id "
+ " left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ "<if test='vo.name!= null and vo.name!= \"\"'> "
+ " and A.name like CONCAT('%',#{vo.name},'%') "
+ "</if> "
+ "<if test='vo.group!= null and vo.group != \"\"'> "
+ " and B.group = #{vo.group} "
+ "</if> "
+ "<if test='vo.seasonId!= null and vo.seasonId!= \"\"'> "
+ " and A.season_id = #{vo.seasonId} "
+ "</if> "
+ "<if test='vo.seasonName!= null and vo.seasonName!= \"\"'> "
+ " and B.code like CONCAT('%',#{vo.seasonName},'%') "
+ "</if> "
+ "</script>")
List<RacePaperPageVO> pages(@Param("vo") RacePaperQueryVO vo);
@Select("<script>"
+ " select A.id,A.name,A.`desc`,A.season_id as seasonId ,B.code as seasonName "
+ " ,A.configs,A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ " from racetr_paper A left join racetr_season B on A.season_id = B.id "
+ " left join sys_account C on A.creator_id = C.id "
+ " left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ " and A.id = #{id}"
+ "</script>")
RacePaperPageVO detail(@Param("id") Long id);
}

View File

@ -1,47 +0,0 @@
package club.joylink.rtss.dao.racetr;
import club.joylink.rtss.dao.MyBatisBaseDao;
import club.joylink.rtss.entity.racetr.RacetrScene;
import club.joylink.rtss.entity.racetr.RacetrSceneExample;
import club.joylink.rtss.vo.race.RaceScenePageVO;
import club.joylink.rtss.vo.race.RaceSceneQueryVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
/**
* RacetrSceneDAO继承基类
*/
@Repository
public interface RacetrSceneDAO extends MyBatisBaseDao<RacetrScene, Long, RacetrSceneExample> {
@Select("<script>"
+ "select A.id,A.name,A.type,A.map_id as mapId, B.name as mapName, "
+ "A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ "from racetr_scene A left join map_info B on A.map_id = B.id "
+ "left join sys_account C on A.creator_id = C.id "
+ "left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ "<if test='vo.name!= null and vo.name!= \"\"'> "
+ " and A.name like CONCAT('%',#{vo.name},'%') "
+ "</if> "
+ "<if test='vo.type!= null and vo.type!= \"\"'> "
+ " and A.type = #{vo.type}"
+ "</if> "
+ "</script>")
List<RaceScenePageVO> pages(@Param("vo") RaceSceneQueryVO vo);
@Select("<script>"
+ "select A.id,A.name,A.type,A.map_id as mapId, B.name as mapName, A.proto"
+ ",A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ "from racetr_scene A left join map_info B on A.map_id = B.id "
+ "left join sys_account C on A.creator_id = C.id "
+ "left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ " and A.id = #{id} "
+ "</script>")
RaceScenePageVO detail(@Param("id") Long id);
}

View File

@ -1,47 +0,0 @@
package club.joylink.rtss.dao.racetr;
import club.joylink.rtss.dao.MyBatisBaseDao;
import club.joylink.rtss.entity.racetr.RacetrScoringRule;
import club.joylink.rtss.entity.racetr.RacetrScoringRuleExample;
import club.joylink.rtss.vo.race.RaceRuleListVO;
import club.joylink.rtss.vo.race.TaskRuleQueryVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
/**
* RacetrScoringRuleDAO继承基类
*/
@Repository
public interface RacetrScoringRuleDAO extends MyBatisBaseDao<RacetrScoringRule, Long, RacetrScoringRuleExample> {
@Select("<script>"
+ " select A.id,A.name"
+ " ,A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ " from racetr_scoring_rule A "
+ " left join sys_account C on A.creator_id = C.id "
+ " left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ "<if test='vo.name!= null and vo.name!= \"\"'> "
+ " and A.name like CONCAT('%',#{vo.name},'%') "
+ "</if> "
+ "<if test='vo.id!= null and vo.id >=0'> "
+ " and A.id = #{vo.id}"
+ "</if> "
+ "</script>")
List<RaceRuleListVO> pages(@Param("vo") TaskRuleQueryVO vo);
@Select("<script>"
+ " select A.id,A.name,A.rule"
+ " ,A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ " from racetr_scoring_rule A "
+ " left join sys_account C on A.creator_id = C.id "
+ " left JOIN sys_account D on A.updater_id = D.id "
+ " where 1 = 1 "
+ " and A.id = #{id}"
+ "</script>")
RaceRuleListVO detail(@Param("id") Long id);
}

View File

@ -1,18 +0,0 @@
package club.joylink.rtss.dao.racetr;
import club.joylink.rtss.dao.MyBatisBaseDao;
import club.joylink.rtss.entity.racetr.RacetrSeason;
import club.joylink.rtss.entity.racetr.RacetrSeasonExample;
import java.util.List;
import org.springframework.stereotype.Repository;
/**
* RacetrSeasonDAO继承基类
*/
@Repository
public interface RacetrSeasonDAO extends MyBatisBaseDao<RacetrSeason, Long, RacetrSeasonExample> {
List<RacetrSeason> selectByExampleWithBLOBs(RacetrSeasonExample example);
}

View File

@ -1,33 +0,0 @@
package club.joylink.rtss.dao.racetr;
import club.joylink.rtss.dao.MyBatisBaseDao;
import club.joylink.rtss.entity.racetr.RacetrTask;
import club.joylink.rtss.entity.racetr.RacetrTaskExample;
import club.joylink.rtss.vo.race.RaceTaskDetailDTO;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
/**
* RacetrTaskDAO继承基类
*/
@Repository
public interface RacetrTaskDAO extends MyBatisBaseDao<RacetrTask, Long, RacetrTaskExample> {
@Select("<script>"
+ "select A.id,A.name,A.desc,A.content,A.standards,B.id as scene_id,B.name as sceneName, "
+ "A.score_rule_id as rule_id,C.name as ruleName,A.parent_id,"
+ "A.creator_id,A.create_time,A.updater_id,A.update_time,D.nickname as creatorName,E.nickname as updaterName "
+ " from racetr_task A left join racetr_scene B on A.scene_id = B.id "
+ " left join racetr_scoring_rule C on A.score_rule_id = C.id "
+ " left join sys_account D on A.creator_id = D.id "
+ " left JOIN sys_account E on A.updater_id = E.id "
+ " where 1 = 1 "
+ " and A.id = #{id}"
+ "</script>")
RaceTaskDetailDTO details(@Param("id") Long id);
List<RaceTaskDetailDTO> recursiveFindTask(@Param("taskIds") List<Long> taskIds);
}

View File

@ -1,107 +0,0 @@
package club.joylink.rtss.entity;
import java.io.Serializable;
/**
* cgy_view
* @author
*/
public class CgyView implements Serializable {
/**
* 接入虚仿平台后获取
*/
private String appId;
/**
* 接入虚仿平台后获取
*/
private String appSecret;
/**
* 地图功能id
*/
private Long functionId;
/**
* 浏览量
*/
private Long viewCount;
private static final long serialVersionUID = 1L;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public Long getFunctionId() {
return functionId;
}
public void setFunctionId(Long functionId) {
this.functionId = functionId;
}
public Long getViewCount() {
return viewCount;
}
public void setViewCount(Long viewCount) {
this.viewCount = viewCount;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
CgyView other = (CgyView) that;
return (this.getAppId() == null ? other.getAppId() == null : this.getAppId().equals(other.getAppId()))
&& (this.getAppSecret() == null ? other.getAppSecret() == null : this.getAppSecret().equals(other.getAppSecret()))
&& (this.getFunctionId() == null ? other.getFunctionId() == null : this.getFunctionId().equals(other.getFunctionId()))
&& (this.getViewCount() == null ? other.getViewCount() == null : this.getViewCount().equals(other.getViewCount()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getAppId() == null) ? 0 : getAppId().hashCode());
result = prime * result + ((getAppSecret() == null) ? 0 : getAppSecret().hashCode());
result = prime * result + ((getFunctionId() == null) ? 0 : getFunctionId().hashCode());
result = prime * result + ((getViewCount() == null) ? 0 : getViewCount().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", appId=").append(appId);
sb.append(", appSecret=").append(appSecret);
sb.append(", functionId=").append(functionId);
sb.append(", viewCount=").append(viewCount);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -1,482 +0,0 @@
package club.joylink.rtss.entity;
import java.util.ArrayList;
import java.util.List;
public class CgyViewExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public CgyViewExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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 andAppIdIsNull() {
addCriterion("app_id is null");
return (Criteria) this;
}
public Criteria andAppIdIsNotNull() {
addCriterion("app_id is not null");
return (Criteria) this;
}
public Criteria andAppIdEqualTo(String value) {
addCriterion("app_id =", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdNotEqualTo(String value) {
addCriterion("app_id <>", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdGreaterThan(String value) {
addCriterion("app_id >", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdGreaterThanOrEqualTo(String value) {
addCriterion("app_id >=", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdLessThan(String value) {
addCriterion("app_id <", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdLessThanOrEqualTo(String value) {
addCriterion("app_id <=", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdLike(String value) {
addCriterion("app_id like", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdNotLike(String value) {
addCriterion("app_id not like", value, "appId");
return (Criteria) this;
}
public Criteria andAppIdIn(List<String> values) {
addCriterion("app_id in", values, "appId");
return (Criteria) this;
}
public Criteria andAppIdNotIn(List<String> values) {
addCriterion("app_id not in", values, "appId");
return (Criteria) this;
}
public Criteria andAppIdBetween(String value1, String value2) {
addCriterion("app_id between", value1, value2, "appId");
return (Criteria) this;
}
public Criteria andAppIdNotBetween(String value1, String value2) {
addCriterion("app_id not between", value1, value2, "appId");
return (Criteria) this;
}
public Criteria andAppSecretIsNull() {
addCriterion("app_secret is null");
return (Criteria) this;
}
public Criteria andAppSecretIsNotNull() {
addCriterion("app_secret is not null");
return (Criteria) this;
}
public Criteria andAppSecretEqualTo(String value) {
addCriterion("app_secret =", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretNotEqualTo(String value) {
addCriterion("app_secret <>", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretGreaterThan(String value) {
addCriterion("app_secret >", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretGreaterThanOrEqualTo(String value) {
addCriterion("app_secret >=", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretLessThan(String value) {
addCriterion("app_secret <", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretLessThanOrEqualTo(String value) {
addCriterion("app_secret <=", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretLike(String value) {
addCriterion("app_secret like", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretNotLike(String value) {
addCriterion("app_secret not like", value, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretIn(List<String> values) {
addCriterion("app_secret in", values, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretNotIn(List<String> values) {
addCriterion("app_secret not in", values, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretBetween(String value1, String value2) {
addCriterion("app_secret between", value1, value2, "appSecret");
return (Criteria) this;
}
public Criteria andAppSecretNotBetween(String value1, String value2) {
addCriterion("app_secret not between", value1, value2, "appSecret");
return (Criteria) this;
}
public Criteria andFunctionIdIsNull() {
addCriterion("function_id is null");
return (Criteria) this;
}
public Criteria andFunctionIdIsNotNull() {
addCriterion("function_id is not null");
return (Criteria) this;
}
public Criteria andFunctionIdEqualTo(Long value) {
addCriterion("function_id =", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotEqualTo(Long value) {
addCriterion("function_id <>", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdGreaterThan(Long value) {
addCriterion("function_id >", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdGreaterThanOrEqualTo(Long value) {
addCriterion("function_id >=", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdLessThan(Long value) {
addCriterion("function_id <", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdLessThanOrEqualTo(Long value) {
addCriterion("function_id <=", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdIn(List<Long> values) {
addCriterion("function_id in", values, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotIn(List<Long> values) {
addCriterion("function_id not in", values, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdBetween(Long value1, Long value2) {
addCriterion("function_id between", value1, value2, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotBetween(Long value1, Long value2) {
addCriterion("function_id not between", value1, value2, "functionId");
return (Criteria) this;
}
public Criteria andViewCountIsNull() {
addCriterion("view_count is null");
return (Criteria) this;
}
public Criteria andViewCountIsNotNull() {
addCriterion("view_count is not null");
return (Criteria) this;
}
public Criteria andViewCountEqualTo(Long value) {
addCriterion("view_count =", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountNotEqualTo(Long value) {
addCriterion("view_count <>", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountGreaterThan(Long value) {
addCriterion("view_count >", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountGreaterThanOrEqualTo(Long value) {
addCriterion("view_count >=", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountLessThan(Long value) {
addCriterion("view_count <", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountLessThanOrEqualTo(Long value) {
addCriterion("view_count <=", value, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountIn(List<Long> values) {
addCriterion("view_count in", values, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountNotIn(List<Long> values) {
addCriterion("view_count not in", values, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountBetween(Long value1, Long value2) {
addCriterion("view_count between", value1, value2, "viewCount");
return (Criteria) this;
}
public Criteria andViewCountNotBetween(Long value1, Long value2) {
addCriterion("view_count not between", value1, value2, "viewCount");
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

@ -1,57 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
* @author
*/
@Data
public class RacetrPaper implements Serializable {
private Long id;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String desc;
/**
* 赛季ID
*/
private Long seasonId;
/**
* 创建者的ID
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者的ID
*/
private Long updaterId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* module配置
*/
private byte[] configs;
private static final long serialVersionUID = 1L;
}

View File

@ -1,723 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RacetrPaperExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public RacetrPaperExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andDescIsNull() {
addCriterion("`desc` is null");
return (Criteria) this;
}
public Criteria andDescIsNotNull() {
addCriterion("`desc` is not null");
return (Criteria) this;
}
public Criteria andDescEqualTo(String value) {
addCriterion("`desc` =", value, "desc");
return (Criteria) this;
}
public Criteria andDescNotEqualTo(String value) {
addCriterion("`desc` <>", value, "desc");
return (Criteria) this;
}
public Criteria andDescGreaterThan(String value) {
addCriterion("`desc` >", value, "desc");
return (Criteria) this;
}
public Criteria andDescGreaterThanOrEqualTo(String value) {
addCriterion("`desc` >=", value, "desc");
return (Criteria) this;
}
public Criteria andDescLessThan(String value) {
addCriterion("`desc` <", value, "desc");
return (Criteria) this;
}
public Criteria andDescLessThanOrEqualTo(String value) {
addCriterion("`desc` <=", value, "desc");
return (Criteria) this;
}
public Criteria andDescLike(String value) {
addCriterion("`desc` like", value, "desc");
return (Criteria) this;
}
public Criteria andDescNotLike(String value) {
addCriterion("`desc` not like", value, "desc");
return (Criteria) this;
}
public Criteria andDescIn(List<String> values) {
addCriterion("`desc` in", values, "desc");
return (Criteria) this;
}
public Criteria andDescNotIn(List<String> values) {
addCriterion("`desc` not in", values, "desc");
return (Criteria) this;
}
public Criteria andDescBetween(String value1, String value2) {
addCriterion("`desc` between", value1, value2, "desc");
return (Criteria) this;
}
public Criteria andDescNotBetween(String value1, String value2) {
addCriterion("`desc` not between", value1, value2, "desc");
return (Criteria) this;
}
public Criteria andSeasonIdIsNull() {
addCriterion("season_id is null");
return (Criteria) this;
}
public Criteria andSeasonIdIsNotNull() {
addCriterion("season_id is not null");
return (Criteria) this;
}
public Criteria andSeasonIdEqualTo(Long value) {
addCriterion("season_id =", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdNotEqualTo(Long value) {
addCriterion("season_id <>", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdGreaterThan(Long value) {
addCriterion("season_id >", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdGreaterThanOrEqualTo(Long value) {
addCriterion("season_id >=", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdLessThan(Long value) {
addCriterion("season_id <", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdLessThanOrEqualTo(Long value) {
addCriterion("season_id <=", value, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdIn(List<Long> values) {
addCriterion("season_id in", values, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdNotIn(List<Long> values) {
addCriterion("season_id not in", values, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdBetween(Long value1, Long value2) {
addCriterion("season_id between", value1, value2, "seasonId");
return (Criteria) this;
}
public Criteria andSeasonIdNotBetween(Long value1, Long value2) {
addCriterion("season_id not between", value1, value2, "seasonId");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNull() {
addCriterion("updater_id is null");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNotNull() {
addCriterion("updater_id is not null");
return (Criteria) this;
}
public Criteria andUpdaterIdEqualTo(Long value) {
addCriterion("updater_id =", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotEqualTo(Long value) {
addCriterion("updater_id <>", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThan(Long value) {
addCriterion("updater_id >", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) {
addCriterion("updater_id >=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThan(Long value) {
addCriterion("updater_id <", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThanOrEqualTo(Long value) {
addCriterion("updater_id <=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdIn(List<Long> values) {
addCriterion("updater_id in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotIn(List<Long> values) {
addCriterion("updater_id not in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdBetween(Long value1, Long value2) {
addCriterion("updater_id between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotBetween(Long value1, Long value2) {
addCriterion("updater_id not between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
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

@ -1,67 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
* @author
*/
@Data
public class RacetrScene implements Serializable {
private Long id;
/**
* 名称
*/
private String name;
/**
* 类型本地/链接
*/
private String type;
/**
* 地图id
*/
private Long mapId;
/**
* 场景对应的线路功能ID
*/
private Long functionId;
/**
* 发布场景关联实训
*/
private Long draftTrainingId;
/**
* 创建者的ID
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者的ID
*/
private Long updaterId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 场景数据proto
*/
private byte[] proto;
private static final long serialVersionUID = 1L;
}

View File

@ -1,843 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RacetrSceneExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public RacetrSceneExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andMapIdIsNull() {
addCriterion("map_id is null");
return (Criteria) this;
}
public Criteria andMapIdIsNotNull() {
addCriterion("map_id is not null");
return (Criteria) this;
}
public Criteria andMapIdEqualTo(Long value) {
addCriterion("map_id =", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotEqualTo(Long value) {
addCriterion("map_id <>", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThan(Long value) {
addCriterion("map_id >", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThanOrEqualTo(Long value) {
addCriterion("map_id >=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThan(Long value) {
addCriterion("map_id <", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThanOrEqualTo(Long value) {
addCriterion("map_id <=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdIn(List<Long> values) {
addCriterion("map_id in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotIn(List<Long> values) {
addCriterion("map_id not in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdBetween(Long value1, Long value2) {
addCriterion("map_id between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotBetween(Long value1, Long value2) {
addCriterion("map_id not between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andFunctionIdIsNull() {
addCriterion("function_id is null");
return (Criteria) this;
}
public Criteria andFunctionIdIsNotNull() {
addCriterion("function_id is not null");
return (Criteria) this;
}
public Criteria andFunctionIdEqualTo(Long value) {
addCriterion("function_id =", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotEqualTo(Long value) {
addCriterion("function_id <>", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdGreaterThan(Long value) {
addCriterion("function_id >", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdGreaterThanOrEqualTo(Long value) {
addCriterion("function_id >=", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdLessThan(Long value) {
addCriterion("function_id <", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdLessThanOrEqualTo(Long value) {
addCriterion("function_id <=", value, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdIn(List<Long> values) {
addCriterion("function_id in", values, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotIn(List<Long> values) {
addCriterion("function_id not in", values, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdBetween(Long value1, Long value2) {
addCriterion("function_id between", value1, value2, "functionId");
return (Criteria) this;
}
public Criteria andFunctionIdNotBetween(Long value1, Long value2) {
addCriterion("function_id not between", value1, value2, "functionId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdIsNull() {
addCriterion("draft_training_id is null");
return (Criteria) this;
}
public Criteria andDraftTrainingIdIsNotNull() {
addCriterion("draft_training_id is not null");
return (Criteria) this;
}
public Criteria andDraftTrainingIdEqualTo(Long value) {
addCriterion("draft_training_id =", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdNotEqualTo(Long value) {
addCriterion("draft_training_id <>", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdGreaterThan(Long value) {
addCriterion("draft_training_id >", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdGreaterThanOrEqualTo(Long value) {
addCriterion("draft_training_id >=", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdLessThan(Long value) {
addCriterion("draft_training_id <", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdLessThanOrEqualTo(Long value) {
addCriterion("draft_training_id <=", value, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdIn(List<Long> values) {
addCriterion("draft_training_id in", values, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdNotIn(List<Long> values) {
addCriterion("draft_training_id not in", values, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdBetween(Long value1, Long value2) {
addCriterion("draft_training_id between", value1, value2, "draftTrainingId");
return (Criteria) this;
}
public Criteria andDraftTrainingIdNotBetween(Long value1, Long value2) {
addCriterion("draft_training_id not between", value1, value2, "draftTrainingId");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNull() {
addCriterion("updater_id is null");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNotNull() {
addCriterion("updater_id is not null");
return (Criteria) this;
}
public Criteria andUpdaterIdEqualTo(Long value) {
addCriterion("updater_id =", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotEqualTo(Long value) {
addCriterion("updater_id <>", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThan(Long value) {
addCriterion("updater_id >", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) {
addCriterion("updater_id >=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThan(Long value) {
addCriterion("updater_id <", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThanOrEqualTo(Long value) {
addCriterion("updater_id <=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdIn(List<Long> values) {
addCriterion("updater_id in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotIn(List<Long> values) {
addCriterion("updater_id not in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdBetween(Long value1, Long value2) {
addCriterion("updater_id between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotBetween(Long value1, Long value2) {
addCriterion("updater_id not between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
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

@ -1,47 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
* @author
*/
@Data
public class RacetrScoringRule implements Serializable {
private Long id;
/**
* 名称
*/
private String name;
/**
* 创建者的ID
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者的ID
*/
private Long updaterId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 评分规则细则proto
*/
private byte[] rule;
private static final long serialVersionUID = 1L;
}

View File

@ -1,593 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RacetrScoringRuleExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public RacetrScoringRuleExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNull() {
addCriterion("updater_id is null");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNotNull() {
addCriterion("updater_id is not null");
return (Criteria) this;
}
public Criteria andUpdaterIdEqualTo(Long value) {
addCriterion("updater_id =", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotEqualTo(Long value) {
addCriterion("updater_id <>", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThan(Long value) {
addCriterion("updater_id >", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) {
addCriterion("updater_id >=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThan(Long value) {
addCriterion("updater_id <", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThanOrEqualTo(Long value) {
addCriterion("updater_id <=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdIn(List<Long> values) {
addCriterion("updater_id in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotIn(List<Long> values) {
addCriterion("updater_id not in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdBetween(Long value1, Long value2) {
addCriterion("updater_id between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotBetween(Long value1, Long value2) {
addCriterion("updater_id not between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
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

@ -1,57 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
* @author
*/
@Data
public class RacetrSeason implements Serializable {
private Long id;
/**
* 编号
*/
private String code;
/**
* 组别1=中职/2=高职
*/
private String group;
/**
* 年度
*/
private String term;
/**
* 创建者的ID
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者的ID
*/
private Long updaterId;
/**
* 更新时间
*/
private LocalDateTime udpateTime;
/**
* html文本信息
*/
private String detailHtmlContent;
private static final long serialVersionUID = 1L;
}

View File

@ -1,733 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RacetrSeasonExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public RacetrSeasonExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andGroupIsNull() {
addCriterion("`group` is null");
return (Criteria) this;
}
public Criteria andGroupIsNotNull() {
addCriterion("`group` is not null");
return (Criteria) this;
}
public Criteria andGroupEqualTo(String value) {
addCriterion("`group` =", value, "group");
return (Criteria) this;
}
public Criteria andGroupNotEqualTo(String value) {
addCriterion("`group` <>", value, "group");
return (Criteria) this;
}
public Criteria andGroupGreaterThan(String value) {
addCriterion("`group` >", value, "group");
return (Criteria) this;
}
public Criteria andGroupGreaterThanOrEqualTo(String value) {
addCriterion("`group` >=", value, "group");
return (Criteria) this;
}
public Criteria andGroupLessThan(String value) {
addCriterion("`group` <", value, "group");
return (Criteria) this;
}
public Criteria andGroupLessThanOrEqualTo(String value) {
addCriterion("`group` <=", value, "group");
return (Criteria) this;
}
public Criteria andGroupLike(String value) {
addCriterion("`group` like", value, "group");
return (Criteria) this;
}
public Criteria andGroupNotLike(String value) {
addCriterion("`group` not like", value, "group");
return (Criteria) this;
}
public Criteria andGroupIn(List<String> values) {
addCriterion("`group` in", values, "group");
return (Criteria) this;
}
public Criteria andGroupNotIn(List<String> values) {
addCriterion("`group` not in", values, "group");
return (Criteria) this;
}
public Criteria andGroupBetween(String value1, String value2) {
addCriterion("`group` between", value1, value2, "group");
return (Criteria) this;
}
public Criteria andGroupNotBetween(String value1, String value2) {
addCriterion("`group` not between", value1, value2, "group");
return (Criteria) this;
}
public Criteria andTermIsNull() {
addCriterion("term is null");
return (Criteria) this;
}
public Criteria andTermIsNotNull() {
addCriterion("term is not null");
return (Criteria) this;
}
public Criteria andTermEqualTo(String value) {
addCriterion("term =", value, "term");
return (Criteria) this;
}
public Criteria andTermNotEqualTo(String value) {
addCriterion("term <>", value, "term");
return (Criteria) this;
}
public Criteria andTermGreaterThan(String value) {
addCriterion("term >", value, "term");
return (Criteria) this;
}
public Criteria andTermGreaterThanOrEqualTo(String value) {
addCriterion("term >=", value, "term");
return (Criteria) this;
}
public Criteria andTermLessThan(String value) {
addCriterion("term <", value, "term");
return (Criteria) this;
}
public Criteria andTermLessThanOrEqualTo(String value) {
addCriterion("term <=", value, "term");
return (Criteria) this;
}
public Criteria andTermLike(String value) {
addCriterion("term like", value, "term");
return (Criteria) this;
}
public Criteria andTermNotLike(String value) {
addCriterion("term not like", value, "term");
return (Criteria) this;
}
public Criteria andTermIn(List<String> values) {
addCriterion("term in", values, "term");
return (Criteria) this;
}
public Criteria andTermNotIn(List<String> values) {
addCriterion("term not in", values, "term");
return (Criteria) this;
}
public Criteria andTermBetween(String value1, String value2) {
addCriterion("term between", value1, value2, "term");
return (Criteria) this;
}
public Criteria andTermNotBetween(String value1, String value2) {
addCriterion("term not between", value1, value2, "term");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNull() {
addCriterion("updater_id is null");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNotNull() {
addCriterion("updater_id is not null");
return (Criteria) this;
}
public Criteria andUpdaterIdEqualTo(Long value) {
addCriterion("updater_id =", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotEqualTo(Long value) {
addCriterion("updater_id <>", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThan(Long value) {
addCriterion("updater_id >", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) {
addCriterion("updater_id >=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThan(Long value) {
addCriterion("updater_id <", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThanOrEqualTo(Long value) {
addCriterion("updater_id <=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdIn(List<Long> values) {
addCriterion("updater_id in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotIn(List<Long> values) {
addCriterion("updater_id not in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdBetween(Long value1, Long value2) {
addCriterion("updater_id between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotBetween(Long value1, Long value2) {
addCriterion("updater_id not between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUdpateTimeIsNull() {
addCriterion("udpate_time is null");
return (Criteria) this;
}
public Criteria andUdpateTimeIsNotNull() {
addCriterion("udpate_time is not null");
return (Criteria) this;
}
public Criteria andUdpateTimeEqualTo(Date value) {
addCriterion("udpate_time =", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeNotEqualTo(Date value) {
addCriterion("udpate_time <>", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeGreaterThan(Date value) {
addCriterion("udpate_time >", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("udpate_time >=", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeLessThan(Date value) {
addCriterion("udpate_time <", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeLessThanOrEqualTo(Date value) {
addCriterion("udpate_time <=", value, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeIn(List<Date> values) {
addCriterion("udpate_time in", values, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeNotIn(List<Date> values) {
addCriterion("udpate_time not in", values, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeBetween(Date value1, Date value2) {
addCriterion("udpate_time between", value1, value2, "udpateTime");
return (Criteria) this;
}
public Criteria andUdpateTimeNotBetween(Date value1, Date value2) {
addCriterion("udpate_time not between", value1, value2, "udpateTime");
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

@ -1,69 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
* @author
*/
@Data
public class RacetrTask implements Serializable {
private Long id;
private String name;
/**
* 基础描述文本
*/
private String desc;
/**
* 考核内容文本
*/
private String content;
/**
* 评价标准文本
*/
private String standards;
/**
* 任务场景
*/
private Long sceneId;
/**
* 评分规则
*/
private Long scoreRuleId;
/**
* 父任务ID
*/
private Long parentId;
/**
* 创建者的ID
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者的ID
*/
private Long updaterId;
/**
* 更新时间
*/
private LocalDateTime updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -1,983 +0,0 @@
package club.joylink.rtss.entity.racetr;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RacetrTaskExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public RacetrTaskExample() {
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;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
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(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andDescIsNull() {
addCriterion("`desc` is null");
return (Criteria) this;
}
public Criteria andDescIsNotNull() {
addCriterion("`desc` is not null");
return (Criteria) this;
}
public Criteria andDescEqualTo(String value) {
addCriterion("`desc` =", value, "desc");
return (Criteria) this;
}
public Criteria andDescNotEqualTo(String value) {
addCriterion("`desc` <>", value, "desc");
return (Criteria) this;
}
public Criteria andDescGreaterThan(String value) {
addCriterion("`desc` >", value, "desc");
return (Criteria) this;
}
public Criteria andDescGreaterThanOrEqualTo(String value) {
addCriterion("`desc` >=", value, "desc");
return (Criteria) this;
}
public Criteria andDescLessThan(String value) {
addCriterion("`desc` <", value, "desc");
return (Criteria) this;
}
public Criteria andDescLessThanOrEqualTo(String value) {
addCriterion("`desc` <=", value, "desc");
return (Criteria) this;
}
public Criteria andDescLike(String value) {
addCriterion("`desc` like", value, "desc");
return (Criteria) this;
}
public Criteria andDescNotLike(String value) {
addCriterion("`desc` not like", value, "desc");
return (Criteria) this;
}
public Criteria andDescIn(List<String> values) {
addCriterion("`desc` in", values, "desc");
return (Criteria) this;
}
public Criteria andDescNotIn(List<String> values) {
addCriterion("`desc` not in", values, "desc");
return (Criteria) this;
}
public Criteria andDescBetween(String value1, String value2) {
addCriterion("`desc` between", value1, value2, "desc");
return (Criteria) this;
}
public Criteria andDescNotBetween(String value1, String value2) {
addCriterion("`desc` not between", value1, value2, "desc");
return (Criteria) this;
}
public Criteria andContentIsNull() {
addCriterion("content is null");
return (Criteria) this;
}
public Criteria andContentIsNotNull() {
addCriterion("content is not null");
return (Criteria) this;
}
public Criteria andContentEqualTo(String value) {
addCriterion("content =", value, "content");
return (Criteria) this;
}
public Criteria andContentNotEqualTo(String value) {
addCriterion("content <>", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThan(String value) {
addCriterion("content >", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThanOrEqualTo(String value) {
addCriterion("content >=", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThan(String value) {
addCriterion("content <", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThanOrEqualTo(String value) {
addCriterion("content <=", value, "content");
return (Criteria) this;
}
public Criteria andContentLike(String value) {
addCriterion("content like", value, "content");
return (Criteria) this;
}
public Criteria andContentNotLike(String value) {
addCriterion("content not like", value, "content");
return (Criteria) this;
}
public Criteria andContentIn(List<String> values) {
addCriterion("content in", values, "content");
return (Criteria) this;
}
public Criteria andContentNotIn(List<String> values) {
addCriterion("content not in", values, "content");
return (Criteria) this;
}
public Criteria andContentBetween(String value1, String value2) {
addCriterion("content between", value1, value2, "content");
return (Criteria) this;
}
public Criteria andContentNotBetween(String value1, String value2) {
addCriterion("content not between", value1, value2, "content");
return (Criteria) this;
}
public Criteria andStandardsIsNull() {
addCriterion("standards is null");
return (Criteria) this;
}
public Criteria andStandardsIsNotNull() {
addCriterion("standards is not null");
return (Criteria) this;
}
public Criteria andStandardsEqualTo(String value) {
addCriterion("standards =", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsNotEqualTo(String value) {
addCriterion("standards <>", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsGreaterThan(String value) {
addCriterion("standards >", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsGreaterThanOrEqualTo(String value) {
addCriterion("standards >=", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsLessThan(String value) {
addCriterion("standards <", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsLessThanOrEqualTo(String value) {
addCriterion("standards <=", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsLike(String value) {
addCriterion("standards like", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsNotLike(String value) {
addCriterion("standards not like", value, "standards");
return (Criteria) this;
}
public Criteria andStandardsIn(List<String> values) {
addCriterion("standards in", values, "standards");
return (Criteria) this;
}
public Criteria andStandardsNotIn(List<String> values) {
addCriterion("standards not in", values, "standards");
return (Criteria) this;
}
public Criteria andStandardsBetween(String value1, String value2) {
addCriterion("standards between", value1, value2, "standards");
return (Criteria) this;
}
public Criteria andStandardsNotBetween(String value1, String value2) {
addCriterion("standards not between", value1, value2, "standards");
return (Criteria) this;
}
public Criteria andSceneIdIsNull() {
addCriterion("scene_id is null");
return (Criteria) this;
}
public Criteria andSceneIdIsNotNull() {
addCriterion("scene_id is not null");
return (Criteria) this;
}
public Criteria andSceneIdEqualTo(Long value) {
addCriterion("scene_id =", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotEqualTo(Long value) {
addCriterion("scene_id <>", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdGreaterThan(Long value) {
addCriterion("scene_id >", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdGreaterThanOrEqualTo(Long value) {
addCriterion("scene_id >=", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdLessThan(Long value) {
addCriterion("scene_id <", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdLessThanOrEqualTo(Long value) {
addCriterion("scene_id <=", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdIn(List<Long> values) {
addCriterion("scene_id in", values, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotIn(List<Long> values) {
addCriterion("scene_id not in", values, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdBetween(Long value1, Long value2) {
addCriterion("scene_id between", value1, value2, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotBetween(Long value1, Long value2) {
addCriterion("scene_id not between", value1, value2, "sceneId");
return (Criteria) this;
}
public Criteria andScoreRuleIdIsNull() {
addCriterion("score_rule_id is null");
return (Criteria) this;
}
public Criteria andScoreRuleIdIsNotNull() {
addCriterion("score_rule_id is not null");
return (Criteria) this;
}
public Criteria andScoreRuleIdEqualTo(Long value) {
addCriterion("score_rule_id =", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdNotEqualTo(Long value) {
addCriterion("score_rule_id <>", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdGreaterThan(Long value) {
addCriterion("score_rule_id >", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdGreaterThanOrEqualTo(Long value) {
addCriterion("score_rule_id >=", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdLessThan(Long value) {
addCriterion("score_rule_id <", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdLessThanOrEqualTo(Long value) {
addCriterion("score_rule_id <=", value, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdIn(List<Long> values) {
addCriterion("score_rule_id in", values, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdNotIn(List<Long> values) {
addCriterion("score_rule_id not in", values, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdBetween(Long value1, Long value2) {
addCriterion("score_rule_id between", value1, value2, "scoreRuleId");
return (Criteria) this;
}
public Criteria andScoreRuleIdNotBetween(Long value1, Long value2) {
addCriterion("score_rule_id not between", value1, value2, "scoreRuleId");
return (Criteria) this;
}
public Criteria andParentIdIsNull() {
addCriterion("parent_id is null");
return (Criteria) this;
}
public Criteria andParentIdIsNotNull() {
addCriterion("parent_id is not null");
return (Criteria) this;
}
public Criteria andParentIdEqualTo(Long value) {
addCriterion("parent_id =", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotEqualTo(Long value) {
addCriterion("parent_id <>", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdGreaterThan(Long value) {
addCriterion("parent_id >", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdGreaterThanOrEqualTo(Long value) {
addCriterion("parent_id >=", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdLessThan(Long value) {
addCriterion("parent_id <", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdLessThanOrEqualTo(Long value) {
addCriterion("parent_id <=", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdIn(List<Long> values) {
addCriterion("parent_id in", values, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotIn(List<Long> values) {
addCriterion("parent_id not in", values, "parentId");
return (Criteria) this;
}
public Criteria andParentIdBetween(Long value1, Long value2) {
addCriterion("parent_id between", value1, value2, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotBetween(Long value1, Long value2) {
addCriterion("parent_id not between", value1, value2, "parentId");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;
}
public Criteria andCreatorIdIsNotNull() {
addCriterion("creator_id is not null");
return (Criteria) this;
}
public Criteria andCreatorIdEqualTo(Long value) {
addCriterion("creator_id =", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotEqualTo(Long value) {
addCriterion("creator_id <>", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThan(Long value) {
addCriterion("creator_id >", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
addCriterion("creator_id >=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThan(Long value) {
addCriterion("creator_id <", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
addCriterion("creator_id <=", value, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdIn(List<Long> values) {
addCriterion("creator_id in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotIn(List<Long> values) {
addCriterion("creator_id not in", values, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdBetween(Long value1, Long value2) {
addCriterion("creator_id between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
addCriterion("creator_id not between", value1, value2, "creatorId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNull() {
addCriterion("updater_id is null");
return (Criteria) this;
}
public Criteria andUpdaterIdIsNotNull() {
addCriterion("updater_id is not null");
return (Criteria) this;
}
public Criteria andUpdaterIdEqualTo(Long value) {
addCriterion("updater_id =", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotEqualTo(Long value) {
addCriterion("updater_id <>", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThan(Long value) {
addCriterion("updater_id >", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdGreaterThanOrEqualTo(Long value) {
addCriterion("updater_id >=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThan(Long value) {
addCriterion("updater_id <", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdLessThanOrEqualTo(Long value) {
addCriterion("updater_id <=", value, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdIn(List<Long> values) {
addCriterion("updater_id in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotIn(List<Long> values) {
addCriterion("updater_id not in", values, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdBetween(Long value1, Long value2) {
addCriterion("updater_id between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdaterIdNotBetween(Long value1, Long value2) {
addCriterion("updater_id not between", value1, value2, "updaterId");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
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

@ -1,19 +0,0 @@
package club.joylink.rtss.exception;
import lombok.Getter;
@Getter
public enum RacetrExceptionAssert implements BusinessExceptionAssert {
publishSceneNotForce(12000, "发布重复的场景,是否强制替换"),
;
int code;
String message;
private RacetrExceptionAssert(int code, String message) {
this.code = code;
this.message = message;
}
}

View File

@ -6,365 +6,352 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserQueryVO; import club.joylink.rtss.vo.UserQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.OrgVO; import club.joylink.rtss.vo.client.org.OrgVO;
import club.joylink.rtss.vo.client.user.MobileInfoVO; import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.client.user.RetrievePwdVO;
import club.joylink.rtss.vo.client.user.UpdateEmailVO;
import club.joylink.rtss.vo.client.user.UpdateMobileVO;
import club.joylink.rtss.vo.client.user.UpdatePasswordVO;
import club.joylink.rtss.vo.client.user.WeChatBindStatusVO;
import club.joylink.rtss.vo.user.AccountCreateVO; import club.joylink.rtss.vo.user.AccountCreateVO;
import club.joylink.rtss.vo.user.AccountRegisterVO; import club.joylink.rtss.vo.user.AccountRegisterVO;
import club.joylink.rtss.vo.wx.WmUserSession; import club.joylink.rtss.vo.wx.WmUserSession;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotEmpty;
import lombok.NonNull; import lombok.NonNull;
import java.util.List;
public interface ISysUserService { public interface ISysUserService {
AccountVO queryUserByAccountForMaster(String account); AccountVO queryUserByAccountForMaster(String account);
AccountVO queryUserByAccount(String account);
AccountVO queryUserByAccount(String account);
/**
/** * 根据openId查询用户
* 根据openId查询用户 *
* * @param openid
* @param openid */
*/ AccountVO getUserByWxOpenId(String openid);
AccountVO getUserByWxOpenId(String openid);
/**
/** * 根据userId 主键查询用户
* 根据userId 主键查询用户 *
* * @param id
* @param id */
*/ AccountVO findUserById(Long id);
AccountVO findUserById(Long id);
SysAccount findEntity(@NonNull String account, long orgId);
SysAccount findEntity(@NonNull String account, long orgId);
boolean isExist(@NonNull String account, long orgId);
boolean isExist(@NonNull String account, long orgId);
/**
/** * 通过用户姓名或手机号查询
* 通过用户姓名或手机号查询 *
* * @param query
* @param query * @return
* @return */
*/ List<AccountVO> queryUserByNameOrMobile(String query);
List<AccountVO> queryUserByNameOrMobile(String query);
/**
/** * 判断用户是否已经注册
* 判断用户是否已经注册 *
* * @param wxId
* @param wxId * @return
* @return */
*/ Boolean ifRegistered(String wxId);
Boolean ifRegistered(String wxId);
/**
/** * 修改用户信息
* 修改用户信息 */
*/ void modify(Long id, AccountVO userInfo, String vdcode);
void modify(Long id, AccountVO userInfo, String vdcode);
/**
/** * 分页获取用户数据
* 分页获取用户数据 */
*/ PageVO<AccountVO> queryPagedUser(UserQueryVO queryVO);
PageVO<AccountVO> queryPagedUser(UserQueryVO queryVO);
/**
/** * 修改用户角色
* 修改用户角色 *
* * @param id
* @param id * @param userId
* @param userId * @param accountVO
* @param accountVO */
*/ void updateUserRole(Long id, Long userId, AccountVO accountVO);
void updateUserRole(Long id, Long userId, AccountVO accountVO);
/**
/** * 是否管理员
* 是否管理员 *
* * @param accountVO
* @param accountVO * @return
* @return */
*/ boolean isAdmin(AccountVO accountVO);
boolean isAdmin(AccountVO accountVO);
/**
/** * 确认用户是管理员否则报错
* 确认用户是管理员否则报错 */
*/ void confirmAdmin(AccountVO user);
void confirmAdmin(AccountVO user);
/**
/** * 根据地图id查询订阅人员
* 根据地图id查询订阅人员 *
* * @param mapId
* @param mapId * @return
* @return */
*/ List<Long> selectSubscribeUser(long mapId);
List<Long> selectSubscribeUser(long mapId);
/**
/** * 分页获取用户数据模糊查询
* 分页获取用户数据模糊查询 *
* * @param fuzzyParam
* @param fuzzyParam * @return
* @return */
*/ List<AccountVO> fuzzyQueryPagedUser(String fuzzyParam);
List<AccountVO> fuzzyQueryPagedUser(String fuzzyParam);
/**
/** * 根据名称模糊查询
* 根据名称模糊查询 *
* * @param name
* @param name * @return
* @return */
*/ List<AccountVO> fuzzyQueryByName(String name);
List<AccountVO> fuzzyQueryByName(String name);
/**
/** * 根据微信小程序openid查询用户
* 根据微信小程序openid查询用户 *
* * @param wmOpenId
* @param wmOpenId * @return
* @return */
*/ AccountVO findUserByWmOpenId(String wmOpenId);
AccountVO findUserByWmOpenId(String wmOpenId);
/**
/** * 根据微信小程序openid获取用户
* 根据微信小程序openid获取用户 *
* * @param wmOpenId
* @param wmOpenId * @return
* @return */
*/ AccountVO getUserByWmOpenId(String wmOpenId);
AccountVO getUserByWmOpenId(String wmOpenId);
/**
/** * 根据unionid查询用户
* 根据unionid查询用户 *
* * @param unionid
* @param unionid */
*/ AccountVO findUserByUnionId(String unionid);
AccountVO findUserByUnionId(String unionid);
/**
/** * 根据微信openId获取用户
* 根据微信openId获取用户 *
* * @param unionId
* @param unionId */
*/ AccountVO getUserByUnionId(String unionId);
AccountVO getUserByUnionId(String unionId);
/**
/** * 创建微信小程序来的用户
* 创建微信小程序来的用户 *
* * @param wmUserSession
* @param wmUserSession * @return
* @return */
*/ AccountVO createUserOfWechatMicro(WmUserSession wmUserSession);
AccountVO createUserOfWechatMicro(WmUserSession wmUserSession);
void createUser(SysAccount account);
void createUser(SysAccount account);
String createAccount(AccountCreateVO accountCreateVO, AccountVO user);
String createAccount(AccountCreateVO accountCreateVO, AccountVO user);
/**
/** * 更新用户微信小程序openid
* 更新用户微信小程序openid *
* * @param id
* @param id * @param wmOpenId
* @param wmOpenId */
*/ void updateUserWmOpenId(Long id, String wmOpenId);
void updateUserWmOpenId(Long id, String wmOpenId);
void updateUserWX(Long userId, WmUserSession wmUserSession);
void updateUserWX(Long userId, WmUserSession wmUserSession);
/**
/** * 更新用户的unionId
* 更新用户的unionId *
* * @param changeUserList
* @param changeUserList */
*/ void updateUserWxUnionId(List<AccountVO> changeUserList);
void updateUserWxUnionId(List<AccountVO> changeUserList);
/**
/** * 处理微信用户关注事件
* 处理微信用户关注事件 *
* * @param wxId
* @param wxId * @return
* @return */
*/ void wxSubscribeEventHandle(String wxId);
void wxSubscribeEventHandle(String wxId);
/**
/** * 把注册用户的openId变为unionId
* 把注册用户的openId变为unionId */
*/ void batchChangeOpenId2UnionId();
void batchChangeOpenId2UnionId();
/**
/** * 根据账号密码查询用户
* 根据账号密码查询用户 *
* * @param account
* @param account * @param password
* @param password * @return
* @return */
*/ AccountVO findUserByAccountAndPassword(String account, String password, String project);
AccountVO findUserByAccountAndPassword(String account, String password, String project);
/**
/** * 更新用户真实姓名
* 更新用户真实姓名 *
* * @param id
* @param id * @param name
* @param name */
*/ void updateUserName(Long id, String name);
void updateUserName(Long id, String name);
/**
/** * 更新用户昵称
* 更新用户昵称 *
* * @param id
* @param id * @param nickname
* @param nickname */
*/ void updateNickname(Long id, String nickname);
void updateNickname(Long id, String nickname);
/**
/** * 更新用户头像
* 更新用户头像 *
* * @param id
* @param id * @param avatarPath
* @param avatarPath */
*/ void updateAvatar(Long id, String avatarPath);
void updateAvatar(Long id, String avatarPath);
/**
/** * 更新用户手机号
* 更新用户手机号 *
* * @param id
* @param id * @param updateMobileVO
* @param updateMobileVO */
*/ void updateMobile(Long id, UpdateMobileVO updateMobileVO);
void updateMobile(Long id, UpdateMobileVO updateMobileVO);
/**
/** * 更新用户邮箱地址
* 更新用户邮箱地址 *
* * @param id
* @param id * @param updateEmailVO
* @param updateEmailVO */
*/ void updateEmail(Long id, UpdateEmailVO updateEmailVO);
void updateEmail(Long id, UpdateEmailVO updateEmailVO);
/**
/** * 发送邮箱验证码
* 发送邮箱验证码 *
* * @param email
* @param email * @return
* @return */
*/ String sendEmailValidCode(String email);
String sendEmailValidCode(String email);
/**
/** * 发送手机验证码
* 发送手机验证码 *
* * @param mobileInfoVO
* @param mobileInfoVO * @return
* @return */
*/ String sendMobileValidCode(MobileInfoVO mobileInfoVO);
String sendMobileValidCode(MobileInfoVO mobileInfoVO);
/**
/** * 查询用户总数量
* 查询用户总数量 *
* * @return
* @return */
*/ int getUserAmount();
int getUserAmount();
/**
/** * 更新用户密码
* 更新用户密码 *
* * @param id
* @param id * @param updatePasswordVO
* @param updatePasswordVO */
*/ void updatePassword(Long id, UpdatePasswordVO updatePasswordVO);
void updatePassword(Long id, UpdatePasswordVO updatePasswordVO);
/**
/** * 客户端修改用户密码
* 客户端修改用户密码 *
* * @param id
* @param id * @param password
* @param password */
*/ void updateUserPassword(Long id, String password);
void updateUserPassword(Long id, String password);
AccountVO getUserById(Long id);
AccountVO getUserById(Long id);
List<AccountVO> findUserByName(String name);
List<AccountVO> findUserByName(String name);
/**
/** * 是否是超级管理员
* 是否是超级管理员 */
*/ boolean isSuperAdmin(Long id);
boolean isSuperAdmin(Long id);
/**
* 确认用户是超管
*/
void confirmSuperAdmin(Long userId);
boolean isExist(Long id);
/**
* 获取微信小程序绑定url
*/
WeChatBindStatusVO getWeChatBindUrl(LoginUserInfoVO loginInfo);
/** /**
* 确认用户是超管 * 用户绑定微信小程序
*/ *
void confirmSuperAdmin(Long userId); * @param code
* @param userId
*/
void userBindWm(String code, Long userId);
boolean isExist(Long id); OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId);
/** AccountVO getUserBaseInfoById(Long id);
* 获取微信小程序绑定url
*/
WeChatBindStatusVO getWeChatBindUrl(LoginUserInfoVO loginInfo);
/** List<AccountVO> getUsersWithEmail();
* 用户绑定微信小程序
*
* @param code
* @param userId
*/
void userBindWm(String code, Long userId);
OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId); List<AccountVO> getUsersWithMobile();
AccountVO getUserBaseInfoById(Long id); List<AccountVO> getPlatformUsers();
List<AccountVO> getUsersWithEmail(); List<SysAccount> findEntities(List<Long> ids, String orderBy);
List<AccountVO> getUsersWithMobile(); /**
* 确认该用户存在
*/
void confirmExist(Long id);
List<AccountVO> getPlatformUsers(); void superAdminUpdateUserInfo(AccountVO updateUser, AccountVO superAdmin);
List<SysAccount> findEntities(List<Long> ids, String orderBy); /**
* 查询所有的销售人员
*/
List<AccountVO> querySellers();
Map<Long, SysAccount> findEntitiesForMap(List<Long> ids); void deleteById(Long id);
/** void register(AccountCreateVO accountCreateVO);
* 确认该用户存在
*/
void confirmExist(Long id);
void superAdminUpdateUserInfo(AccountVO updateUser, AccountVO superAdmin); List<AccountVO> queryUsers(List<Long> userIds);
/** /**
* 查询所有的销售人员 * 查询管理和超管
*/ */
List<AccountVO> querySellers(); List<AccountVO> queryAdminsAndSuperAdmins();
void deleteById(Long id); AccountVO queryOrCreateThirdAccount(String parentAccount, String account);
void register(AccountCreateVO accountCreateVO); AccountVO getThirdAccount(String account);
List<AccountVO> queryUsers(List<Long> userIds); void logicDelete(Long id);
/** boolean isThirdParentAccountExist(String parentAccount);
* 查询管理和超管
*/
List<AccountVO> queryAdminsAndSuperAdmins();
AccountVO queryOrCreateThirdAccount(String parentAccount, String account, @NotEmpty String name); List<SysAccount> findEntitiesBySource(String source);
AccountVO getThirdAccount(String account); void resetPwd(long id);
void logicDelete(Long id); void retrievePwd(RetrievePwdVO vo);
boolean isThirdParentAccountExist(String parentAccount); void register2(AccountRegisterVO registerVO);
List<SysAccount> findEntitiesBySource(String source); SysAccount getEntityByMobile(String mobile);
void resetPwd(long id); boolean isSameMobileExist(String mobile);
void retrievePwd(RetrievePwdVO vo); boolean isSameEmailExist(String email);
void register2(AccountRegisterVO registerVO);
SysAccount getEntityByMobile(String mobile);
boolean isSameMobileExist(String mobile);
boolean isSameEmailExist(String email);
List<AccountVO> listByIds(List<Long> ids);
List<AccountVO> listAll();
} }

View File

@ -6,25 +6,14 @@ import club.joylink.rtss.constants.SystemEnv;
import club.joylink.rtss.dao.LearnCommentDAO; import club.joylink.rtss.dao.LearnCommentDAO;
import club.joylink.rtss.dao.LearnMessageDAO; import club.joylink.rtss.dao.LearnMessageDAO;
import club.joylink.rtss.dao.LearnPostDAO; import club.joylink.rtss.dao.LearnPostDAO;
import club.joylink.rtss.entity.LearnComment; import club.joylink.rtss.entity.*;
import club.joylink.rtss.entity.LearnCommentExample;
import club.joylink.rtss.entity.LearnMessage;
import club.joylink.rtss.entity.LearnMessageExample;
import club.joylink.rtss.entity.LearnPost;
import club.joylink.rtss.entity.LearnPostExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.learn.LearnCommentUpdateVO; import club.joylink.rtss.vo.client.learn.*;
import club.joylink.rtss.vo.client.learn.LearnCommentVO;
import club.joylink.rtss.vo.client.learn.LearnCreateVO;
import club.joylink.rtss.vo.client.learn.LearnMessageUpdateVO;
import club.joylink.rtss.vo.client.learn.LearnPostCreateVO;
import club.joylink.rtss.vo.client.learn.LearnPostUpdateVO;
import club.joylink.rtss.vo.client.learn.LearnPostVO;
import club.joylink.rtss.vo.client.post.LearnMessageCreateVO; import club.joylink.rtss.vo.client.post.LearnMessageCreateVO;
import club.joylink.rtss.vo.client.post.LearnMessagePagedQueryVO; import club.joylink.rtss.vo.client.post.LearnMessagePagedQueryVO;
import club.joylink.rtss.vo.client.post.LearnMessageVO; import club.joylink.rtss.vo.client.post.LearnMessageVO;
@ -33,374 +22,362 @@ import club.joylink.rtss.wechat.MiniProgramService;
import club.joylink.rtss.wechat.vo.WxError; import club.joylink.rtss.wechat.vo.WxError;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class LearnService implements ILearnService { public class LearnService implements ILearnService {
@Autowired @Autowired
private LearnPostDAO learnPostDAO; private LearnPostDAO learnPostDAO;
@Autowired @Autowired
private LearnCommentDAO learnCommentDAO; private LearnCommentDAO learnCommentDAO;
@Autowired @Autowired
private ISysUserService iSysUserService; private ISysUserService iSysUserService;
@Autowired @Autowired
private WeChatConfig weChatConfig; private RestTemplate restTemplate;
@Autowired @Autowired
private MiniProgramService miniProgramService; private WeChatConfig weChatConfig;
@Autowired @Autowired
private LearnMessageDAO learnMessageDAO; private MiniProgramService miniProgramService;
@Autowired @Autowired
private OtherConfig otherConfig; private LearnMessageDAO learnMessageDAO;
@Override @Autowired
public PageVO<LearnPostVO> queryPagedPost(LearnPostPagedQueryVO queryVO) { private OtherConfig otherConfig;
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
LearnPostExample example = new LearnPostExample(); @Override
if (queryVO.getProject() != null) { public PageVO<LearnPostVO> queryPagedPost(LearnPostPagedQueryVO queryVO) {
example.createCriteria().andProjectEqualTo(queryVO.getProject()); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
LearnPostExample example = new LearnPostExample();
if (queryVO.getProject() != null) {
example.createCriteria().andProjectEqualTo(queryVO.getProject());
}
Page<LearnPost> page = (Page<LearnPost>) learnPostDAO.selectByExample(example);
List<LearnPostVO> vos = page.getResult().stream().map(LearnPostVO::new).collect(Collectors.toList());
return PageVO.convert(page, vos);
} }
Page<LearnPost> page = (Page<LearnPost>) learnPostDAO.selectByExample(example);
List<LearnPostVO> vos = page.getResult().stream().map(LearnPostVO::new)
.collect(Collectors.toList());
return PageVO.convert(page, vos);
}
@Override @Override
public Long createPost(LearnPostCreateVO createVO, AccountVO user) { public Long createPost(LearnPostCreateVO createVO, AccountVO user) {
//校验 //校验
String title = createVO.getTitle(); String title = createVO.getTitle();
String project = createVO.getProject(); String project = createVO.getProject();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(title, "名称不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(title, "名称不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(project, "所属项目不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(project, "所属项目不能为空");
confirmPostIsNotExist(project); confirmPostIsNotExist(project);
//添加 //添加
LearnPost post = new LearnPost(); LearnPost post = new LearnPost();
post.setProject(project); post.setProject(project);
post.setTitle(title); post.setTitle(title);
post.setCreatorId(user.getId()); post.setCreatorId(user.getId());
post.setCreateTime(LocalDateTime.now()); post.setCreateTime(LocalDateTime.now());
post.setTopping(false); post.setTopping(false);
post.setLike(0); post.setLike(0);
post.setUnlike(0); post.setUnlike(0);
learnPostDAO.insert(post); learnPostDAO.insert(post);
return post.getId(); return post.getId();
}
@Override
@Transactional
public void likePost(Long postId, AccountVO accountVO) {
LearnPost post = getPostEntity(postId);
post.setLike(post.getLike() + 1);
learnPostDAO.updateByPrimaryKey(post);
}
@Override
@Transactional
public void unlikePost(Long postId, AccountVO accountVO) {
LearnPost post = getPostEntity(postId);
post.setUnlike(post.getUnlike() + 1);
learnPostDAO.updateByPrimaryKey(post);
}
@Override
public LearnPostVO getPostInfo(Long postId) {
LearnPost post = getPostEntity(postId);
LearnPostVO postVO = new LearnPostVO(post);
// 用户昵称
AccountVO user = iSysUserService.findUserById(post.getCreatorId());
postVO.setUserNickname(user.getNickname());
postVO.setAvatarPath(user.getAvatarPath());
return postVO;
}
@Override
public PageVO<LearnCommentVO> pagedQueryComment(Long messageId, PageQueryVO queryVO) {
checkMessageExist(messageId);
List<LearnCommentVO> commentVOList = new ArrayList<>();
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
LearnCommentExample commentExample = new LearnCommentExample();
commentExample.setOrderByClause("id");
commentExample.createCriteria().andMessageIdEqualTo(messageId);
Page<LearnComment> page = (Page<LearnComment>) learnCommentDAO.selectByExample(commentExample);
page.getResult().forEach(comment -> commentVOList.add(convertComment(comment)));
return PageVO.convert(page, commentVOList);
}
@Override
public List<LearnCommentVO> queryCommentList(Long messageId) {
LearnCommentExample commentExample = new LearnCommentExample();
commentExample.createCriteria().andMessageIdEqualTo(messageId);
List<LearnComment> comments = learnCommentDAO.selectByExample(commentExample);
List<LearnCommentVO> commentVOList = new ArrayList<>();
comments.forEach(comment -> commentVOList.add(convertComment(comment)));
return commentVOList;
}
/**
* 回复数据完善
*
* @param comment
* @return
*/
private LearnCommentVO convertComment(LearnComment comment) {
LearnCommentVO commentVO = new LearnCommentVO(comment);
// 用户昵称
if (comment.getCreatorId() != null) {
String nickname = iSysUserService.findUserById(comment.getCreatorId()).getNickname();
commentVO.setUserNickname(nickname);
} }
// 回复的用户的昵称
if (comment.getParentId() != null) { @Override
commentVO.setReplyUserNickName( @Transactional
iSysUserService.findUserById(comment.getParentId()).getNickname()); public void likePost(Long postId, AccountVO accountVO) {
LearnPost post = getPostEntity(postId);
post.setLike(post.getLike() + 1);
learnPostDAO.updateByPrimaryKey(post);
} }
// 回复数
LearnCommentExample learnCommentExample = new LearnCommentExample();
learnCommentExample.createCriteria().andMessageIdEqualTo(comment.getMessageId())
.andRootIdEqualTo(comment.getId());
commentVO.setCommentCount(learnCommentDAO.countByExample(learnCommentExample));
return commentVO;
}
@Override @Override
public void addComment(Long messageId, LearnCreateVO commentCreateVO, AccountVO accountVO) { @Transactional
checkMessageExist(messageId); public void unlikePost(Long postId, AccountVO accountVO) {
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) { LearnPost post = getPostEntity(postId);
this.checkContent(commentCreateVO.getContent()); post.setUnlike(post.getUnlike() + 1);
learnPostDAO.updateByPrimaryKey(post);
} }
LearnComment comment = new LearnComment();
comment.setContent(commentCreateVO.getContent());
comment.setMessageId(messageId);
comment.setCreatorId(accountVO.getId());
comment.setCreateTime(LocalDateTime.now());
learnCommentDAO.insertSelective(comment);
}
@Override @Override
public void addComment(Long messageId, Long commentId, LearnCreateVO postCreateVO, public LearnPostVO getPostInfo(Long postId) {
AccountVO accountVO) { LearnPost post = getPostEntity(postId);
checkMessageExist(messageId); LearnPostVO postVO = new LearnPostVO(post);
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) { // 用户昵称
this.checkContent(postCreateVO.getContent()); AccountVO user = iSysUserService.findUserById(post.getCreatorId());
postVO.setUserNickname(user.getNickname());
postVO.setAvatarPath(user.getAvatarPath());
return postVO;
} }
LearnComment comment = new LearnComment();
comment.setContent(postCreateVO.getContent()); @Override
comment.setMessageId(messageId); public PageVO<LearnCommentVO> pagedQueryComment(Long messageId, PageQueryVO queryVO) {
LearnComment parentComment = learnCommentDAO.selectByPrimaryKey(commentId); checkMessageExist(messageId);
if (Objects.isNull(parentComment.getRootId())) { // 对评论的回复 List<LearnCommentVO> commentVOList = new ArrayList<>();
comment.setRootId(commentId); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
} else { // 对回复的回复 LearnCommentExample commentExample = new LearnCommentExample();
comment.setRootId(parentComment.getRootId()); commentExample.setOrderByClause("id");
commentExample.createCriteria().andMessageIdEqualTo(messageId);
Page<LearnComment> page = (Page<LearnComment>) learnCommentDAO.selectByExample(commentExample);
page.getResult().forEach(comment -> commentVOList.add(convertComment(comment)));
return PageVO.convert(page, commentVOList);
} }
comment.setParentId(parentComment.getCreatorId());
comment.setCreatorId(accountVO.getId());
comment.setCreateTime(LocalDateTime.now());
learnCommentDAO.insertSelective(comment);
}
@Override @Override
@Transactional public List<LearnCommentVO> queryCommentList(Long messageId) {
public void likeComment(Long commentId, AccountVO accountVO) { LearnCommentExample commentExample = new LearnCommentExample();
LearnComment comment = getCommentEntity(commentId); commentExample.createCriteria().andMessageIdEqualTo(messageId);
comment.setLike(comment.getLike() + 1); List<LearnComment> comments = learnCommentDAO.selectByExample(commentExample);
learnCommentDAO.updateByPrimaryKey(comment); List<LearnCommentVO> commentVOList = new ArrayList<>();
} comments.forEach(comment -> commentVOList.add(convertComment(comment)));
return commentVOList;
@Override
@Transactional
public void unlikeComment(Long commentId, AccountVO accountVO) {
LearnComment comment = getCommentEntity(commentId);
comment.setUnlike(comment.getUnlike() + 1);
learnCommentDAO.updateByPrimaryKey(comment);
}
@Override
public void top(Long postId, AccountVO accountVO) {
LearnPost post = topCheck(postId, accountVO);
post.setTopping(true);
learnPostDAO.updateByPrimaryKey(post);
}
@Override
public void unTop(Long postId, AccountVO accountVO) {
LearnPost post = topCheck(postId, accountVO);
post.setTopping(false);
learnPostDAO.updateByPrimaryKey(post);
}
@Override
public void deletePost(Long postId, AccountVO accountVO) {
topCheck(postId, accountVO);
//删除留言
LearnMessageExample messageExample = new LearnMessageExample();
messageExample.createCriteria().andPostIdEqualTo(postId);
List<Long> messageIds = learnMessageDAO.selectByExample(messageExample).stream()
.map(LearnMessage::getId).collect(Collectors.toList());
learnMessageDAO.deleteByExample(messageExample);
//删除评论
LearnCommentExample commentExample = new LearnCommentExample();
commentExample.createCriteria().andMessageIdIn(messageIds);
learnCommentDAO.deleteByExample(commentExample);
learnPostDAO.deleteByPrimaryKey(postId);
}
@Override
public void adminDeleteComment(Long commentId, AccountVO user) {
iSysUserService.confirmAdmin(user);
learnCommentDAO.deleteByPrimaryKey(commentId);
}
@Override
public void userDeleteComment(Long commentId, AccountVO user) {
LearnComment comment = getCommentEntity(commentId);
if (!comment.getCreatorId().equals(user.getId())) {
log.error(String.format("用户[%s]意外尝试删除别人的评论[%s]", user.getId(), commentId));
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的评论");
} }
learnCommentDAO.deleteByPrimaryKey(commentId);
}
@Override /**
public long createMessage(LearnMessageCreateVO messageCreateVO, AccountVO user) { * 回复数据完善
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( *
StringUtils.hasText(messageCreateVO.getContent()), * @param comment
"内容不能空白"); * @return
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) { */
this.checkContent(messageCreateVO.getContent()); private LearnCommentVO convertComment(LearnComment comment) {
LearnCommentVO commentVO = new LearnCommentVO(comment);
// 用户昵称
if (comment.getCreatorId() != null) {
String nickname = iSysUserService.findUserById(comment.getCreatorId()).getNickname();
commentVO.setUserNickname(nickname);
}
// 回复的用户的昵称
if (comment.getParentId() != null) {
commentVO.setReplyUserNickName(iSysUserService.findUserById(comment.getParentId()).getNickname());
}
// 回复数
LearnCommentExample learnCommentExample = new LearnCommentExample();
learnCommentExample.createCriteria().andMessageIdEqualTo(comment.getMessageId()).andRootIdEqualTo(comment.getId());
commentVO.setCommentCount(learnCommentDAO.countByExample(learnCommentExample));
return commentVO;
} }
LearnMessage message = messageCreateVO.convert2DB(user.getId());
learnMessageDAO.insert(message);
LearnMessageExample example = new LearnMessageExample();
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
return learnMessageDAO.countByExample(example);
}
@Override @Override
public PageVO<LearnMessageVO> pagedQueryMessageByPostId(Long postId, public void addComment(Long messageId, LearnCreateVO commentCreateVO, AccountVO accountVO) {
LearnMessagePagedQueryVO queryVO) { checkMessageExist(messageId);
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
Page<LearnMessageVO> page = (Page<LearnMessageVO>) learnMessageDAO.select(postId, queryVO); this.checkContent(commentCreateVO.getContent());
for (LearnMessageVO vo : page.getResult()) { }
vo.setComments(pagedQueryComment(vo.getId(), new PageQueryVO(1, 3))); LearnComment comment = new LearnComment();
comment.setContent(commentCreateVO.getContent());
comment.setMessageId(messageId);
comment.setCreatorId(accountVO.getId());
comment.setCreateTime(LocalDateTime.now());
learnCommentDAO.insertSelective(comment);
} }
return PageVO.convert(page);
}
@Override @Override
public void adminDeleteMessage(Long messageId, AccountVO user) { public void addComment(Long messageId, Long commentId, LearnCreateVO postCreateVO, AccountVO accountVO) {
iSysUserService.confirmAdmin(user); checkMessageExist(messageId);
deleteMessage(messageId); if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
} this.checkContent(postCreateVO.getContent());
}
@Override LearnComment comment = new LearnComment();
public void userDeleteMessage(Long messageId, AccountVO user) { comment.setContent(postCreateVO.getContent());
LearnMessage message = getMessageEntity(messageId); comment.setMessageId(messageId);
if (!message.getCreatorId().equals(user.getId())) { LearnComment parentComment = learnCommentDAO.selectByPrimaryKey(commentId);
log.error(String.format("用户[%s]意外尝试删除别人的留言[%s]", user.getId(), messageId)); if (Objects.isNull(parentComment.getRootId())) { // 对评论的回复
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的留言"); comment.setRootId(commentId);
} else { // 对回复的回复
comment.setRootId(parentComment.getRootId());
}
comment.setParentId(parentComment.getCreatorId());
comment.setCreatorId(accountVO.getId());
comment.setCreateTime(LocalDateTime.now());
learnCommentDAO.insertSelective(comment);
} }
deleteMessage(messageId);
}
@Override @Override
public LearnPostVO queryPost(String project) { @Transactional
LearnPostExample example = new LearnPostExample(); public void likeComment(Long commentId, AccountVO accountVO) {
example.createCriteria().andProjectEqualTo(project); LearnComment comment = getCommentEntity(commentId);
List<LearnPost> learnPosts = learnPostDAO.selectByExample(example); comment.setLike(comment.getLike() + 1);
if (CollectionUtils.isEmpty(learnPosts)) { learnCommentDAO.updateByPrimaryKey(comment);
return null;
} }
return new LearnPostVO(learnPosts.get(0));
}
@Override @Override
public PageVO<LearnMessageVO> pagedQueryMessageByProject(String project, @Transactional
LearnMessagePagedQueryVO queryVO) { public void unlikeComment(Long commentId, AccountVO accountVO) {
LearnPostVO post = queryPost(project); LearnComment comment = getCommentEntity(commentId);
if (post == null) { comment.setUnlike(comment.getUnlike() + 1);
log.error(String.format("项目[%s]的留言板不存在", project)); learnCommentDAO.updateByPrimaryKey(comment);
throw new SimulationException(SimulationExceptionType.System_Fault, "该项目的留言板不存在");
} }
return pagedQueryMessageByPostId(post.getId(), queryVO);
}
@Override @Override
public void updatePost(Long postId, LearnPostUpdateVO updateVO, AccountVO user) { public void top(Long postId, AccountVO accountVO) {
iSysUserService.confirmAdmin(user); LearnPost post = topCheck(postId, accountVO);
LearnPost entity = getPostEntity(postId); post.setTopping(true);
if (Objects.equals(updateVO.getTitle(), entity.getTitle())) { learnPostDAO.updateByPrimaryKey(post);
return;
} }
entity.setTitle(updateVO.getTitle());
learnPostDAO.updateByPrimaryKey(entity);
}
@Override @Override
public long cgyCreateMessage(LearnMessageCreateVO messageCreateVO) { public void unTop(Long postId, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( LearnPost post = topCheck(postId, accountVO);
StringUtils.hasText(messageCreateVO.getContent()), post.setTopping(false);
"内容不能空白"); learnPostDAO.updateByPrimaryKey(post);
LearnMessage message = messageCreateVO.convert2DB(1L); }
message.setCreatorId(null);
message.setUserName(messageCreateVO.getUserName());
learnMessageDAO.insert(message);
LearnMessageExample example = new LearnMessageExample();
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
return learnMessageDAO.countByExample(example);
}
@Override @Override
public void cgyAddComment(Long messageId, LearnCreateVO commentCreateVO) { public void deletePost(Long postId, AccountVO accountVO) {
checkMessageExist(messageId); topCheck(postId, accountVO);
LearnComment comment = new LearnComment(); //删除留言
comment.setContent(commentCreateVO.getContent()); LearnMessageExample messageExample = new LearnMessageExample();
comment.setMessageId(messageId); messageExample.createCriteria().andPostIdEqualTo(postId);
comment.setCreateTime(LocalDateTime.now()); List<Long> messageIds = learnMessageDAO.selectByExample(messageExample).stream().map(LearnMessage::getId).collect(Collectors.toList());
comment.setUserName(commentCreateVO.getUserName()); learnMessageDAO.deleteByExample(messageExample);
learnCommentDAO.insertSelective(comment); //删除评论
} LearnCommentExample commentExample = new LearnCommentExample();
commentExample.createCriteria().andMessageIdIn(messageIds);
learnCommentDAO.deleteByExample(commentExample);
learnPostDAO.deleteByPrimaryKey(postId);
}
@Override @Override
public void adminUpdateMessage(LearnMessageUpdateVO messageUpdateVO) { public void adminDeleteComment(Long commentId, AccountVO user) {
LearnMessage messageEntity = getMessageEntity(messageUpdateVO.getId()); iSysUserService.confirmAdmin(user);
messageEntity.setContent(messageUpdateVO.getContent()); learnCommentDAO.deleteByPrimaryKey(commentId);
messageEntity.setCreateTime(messageUpdateVO.getCreateTime()); }
learnMessageDAO.updateByPrimaryKey(messageEntity);
}
@Override @Override
public void adminUpdateComment(LearnCommentUpdateVO commentUpdateVO) { public void userDeleteComment(Long commentId, AccountVO user) {
LearnComment commentEntity = getCommentEntity(commentUpdateVO.getId()); LearnComment comment = getCommentEntity(commentId);
commentEntity.setMessageId(commentUpdateVO.getMessageId()); if (!comment.getCreatorId().equals(user.getId())) {
commentEntity.setContent(commentUpdateVO.getContent()); log.error(String.format("用户[%s]意外尝试删除别人的评论[%s]", user.getId(), commentId));
commentEntity.setCreatorId(commentUpdateVO.getCreatorId()); throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的评论");
commentEntity.setCreateTime(commentUpdateVO.getCreateTime()); }
learnCommentDAO.updateByPrimaryKey(commentEntity); learnCommentDAO.deleteByPrimaryKey(commentId);
} }
@Override
public long createMessage(LearnMessageCreateVO messageCreateVO, AccountVO user) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(messageCreateVO.getContent()),
"内容不能空白");
if (SystemEnv.isPrdEnv(otherConfig.getEnv())) {
this.checkContent(messageCreateVO.getContent());
}
LearnMessage message = messageCreateVO.convert2DB(user.getId());
learnMessageDAO.insert(message);
LearnMessageExample example = new LearnMessageExample();
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
return learnMessageDAO.countByExample(example);
}
@Override
public PageVO<LearnMessageVO> pagedQueryMessageByPostId(Long postId, LearnMessagePagedQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<LearnMessageVO> page = (Page<LearnMessageVO>) learnMessageDAO.select(postId, queryVO);
for (LearnMessageVO vo : page.getResult()) {
vo.setComments(pagedQueryComment(vo.getId(), new PageQueryVO(1, 3)));
}
return PageVO.convert(page);
}
@Override
public void adminDeleteMessage(Long messageId, AccountVO user) {
iSysUserService.confirmAdmin(user);
deleteMessage(messageId);
}
@Override
public void userDeleteMessage(Long messageId, AccountVO user) {
LearnMessage message = getMessageEntity(messageId);
if (!message.getCreatorId().equals(user.getId())) {
log.error(String.format("用户[%s]意外尝试删除别人的留言[%s]", user.getId(), messageId));
throw BusinessExceptionAssertEnum.INVALID_OPERATION.exception("无法删除非本人的留言");
}
deleteMessage(messageId);
}
@Override
public LearnPostVO queryPost(String project) {
LearnPostExample example = new LearnPostExample();
example.createCriteria().andProjectEqualTo(project);
List<LearnPost> learnPosts = learnPostDAO.selectByExample(example);
if (CollectionUtils.isEmpty(learnPosts)) {
return null;
}
return new LearnPostVO(learnPosts.get(0));
}
@Override
public PageVO<LearnMessageVO> pagedQueryMessageByProject(String project, LearnMessagePagedQueryVO queryVO) {
LearnPostVO post = queryPost(project);
if (post == null) {
log.error(String.format("项目[%s]的留言板不存在", project));
throw new SimulationException(SimulationExceptionType.System_Fault, "该项目的留言板不存在");
}
return pagedQueryMessageByPostId(post.getId(), queryVO);
}
@Override
public void updatePost(Long postId, LearnPostUpdateVO updateVO, AccountVO user) {
iSysUserService.confirmAdmin(user);
LearnPost entity = getPostEntity(postId);
if (Objects.equals(updateVO.getTitle(), entity.getTitle()))
return;
entity.setTitle(updateVO.getTitle());
learnPostDAO.updateByPrimaryKey(entity);
}
@Override
public long cgyCreateMessage(LearnMessageCreateVO messageCreateVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(messageCreateVO.getContent()),
"内容不能空白");
LearnMessage message = messageCreateVO.convert2DB(1L);
message.setCreatorId(null);
message.setUserName(messageCreateVO.getUserName());
learnMessageDAO.insert(message);
LearnMessageExample example = new LearnMessageExample();
example.createCriteria().andPostIdEqualTo(messageCreateVO.getPostId());
return learnMessageDAO.countByExample(example);
}
@Override
public void cgyAddComment(Long messageId, LearnCreateVO commentCreateVO) {
checkMessageExist(messageId);
LearnComment comment = new LearnComment();
comment.setContent(commentCreateVO.getContent());
comment.setMessageId(messageId);
comment.setCreateTime(LocalDateTime.now());
comment.setUserName(commentCreateVO.getUserName());
learnCommentDAO.insertSelective(comment);
}
@Override
public void adminUpdateMessage(LearnMessageUpdateVO messageUpdateVO) {
LearnMessage messageEntity = getMessageEntity(messageUpdateVO.getId());
messageEntity.setContent(messageUpdateVO.getContent());
messageEntity.setCreateTime(messageUpdateVO.getCreateTime());
learnMessageDAO.updateByPrimaryKey(messageEntity);
}
@Override
public void adminUpdateComment(LearnCommentUpdateVO commentUpdateVO) {
LearnComment commentEntity = getCommentEntity(commentUpdateVO.getId());
commentEntity.setMessageId(commentUpdateVO.getMessageId());
commentEntity.setContent(commentUpdateVO.getContent());
commentEntity.setCreatorId(commentUpdateVO.getCreatorId());
commentEntity.setCreateTime(commentUpdateVO.getCreateTime());
learnCommentDAO.updateByPrimaryKey(commentEntity);
}
// @Transactional // @Transactional
// @Override // @Override
@ -423,55 +400,50 @@ public class LearnService implements ILearnService {
// } // }
// } // }
@Transactional @Transactional
@Override @Override
public void cgyUpdateMessageTime() { public void cgyUpdateMessageTime() {
LearnMessageExample example = new LearnMessageExample(); LearnMessageExample example = new LearnMessageExample();
example.createCriteria().andPostIdEqualTo(27L); example.createCriteria().andPostIdEqualTo(27L);
List<LearnMessage> allMessage = learnMessageDAO.selectByExample(example); List<LearnMessage> allMessage = learnMessageDAO.selectByExample(example);
//删重复数据 //删重复数据
List<LearnMessage> list = allMessage.stream().collect( List<LearnMessage> list = allMessage.stream().collect(Collectors.toMap(LearnMessage::getContent, Function.identity(), (old, newValue) -> old))
Collectors.toMap(LearnMessage::getContent, Function.identity(), (old, newValue) -> old)) .values().stream().sorted(Comparator.comparingLong(LearnMessage::getId)).collect(Collectors.toList());
.values().stream().sorted(Comparator.comparingLong(LearnMessage::getId)) HashSet<LearnMessage> distinctSet = new HashSet<>(list);
.collect(Collectors.toList()); List<Long> deleteIds = allMessage.stream().filter(message -> !distinctSet.contains(message)).map(LearnMessage::getId).collect(Collectors.toList());
HashSet<LearnMessage> distinctSet = new HashSet<>(list); if (!CollectionUtils.isEmpty(deleteIds)) {
List<Long> deleteIds = allMessage.stream().filter(message -> !distinctSet.contains(message)) example.clear();
.map(LearnMessage::getId).collect(Collectors.toList()); example.createCriteria().andIdIn(deleteIds);
if (!CollectionUtils.isEmpty(deleteIds)) { learnMessageDAO.deleteByExample(example);
example.clear(); }
example.createCriteria().andIdIn(deleteIds); //修改时间
learnMessageDAO.deleteByExample(example); int day = 365 * 4;
Random random = new Random();
List<Integer> dayOffsetList = new ArrayList<>();
for (LearnMessage ignored : list) {
dayOffsetList.add(random.nextInt(day));
}
dayOffsetList.sort((i1, i2) -> i2 - i1);
Map<Integer, Long> dayCountMap = dayOffsetList.stream().collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()));
int startIndex = 0;
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
for (Integer dayOffset : dayCountMap.keySet()) {
List<Integer> secondsOffsetList = new ArrayList<>();
Long dayCount = dayCountMap.get(dayOffset);
for (int i = 0; i < dayCount; i++) {
secondsOffsetList.add(random.nextInt(24 * 3600 - 8 * 3600) + 8 * 3600);
secondsOffsetList.sort(Integer::compareTo);
}
for (int i = startIndex; i < startIndex + dayCount; i++) {
LearnMessage message = list.get(i);
message.setCreateTime(now.minusDays(dayOffset).plusSeconds(secondsOffsetList.get(i - startIndex)));
learnMessageDAO.updateByPrimaryKey(message);
}
startIndex += dayCount;
}
} }
//修改时间
int day = 365 * 4;
Random random = new Random();
List<Integer> dayOffsetList = new ArrayList<>();
for (LearnMessage ignored : list) {
dayOffsetList.add(random.nextInt(day));
}
dayOffsetList.sort((i1, i2) -> i2 - i1);
Map<Integer, Long> dayCountMap = dayOffsetList.stream().collect(
Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()));
int startIndex = 0;
LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
for (Integer dayOffset : dayCountMap.keySet()) {
List<Integer> secondsOffsetList = new ArrayList<>();
Long dayCount = dayCountMap.get(dayOffset);
for (int i = 0; i < dayCount; i++) {
secondsOffsetList.add(random.nextInt(24 * 3600 - 8 * 3600) + 8 * 3600);
secondsOffsetList.sort(Integer::compareTo);
}
for (int i = startIndex; i < startIndex + dayCount; i++) {
LearnMessage message = list.get(i);
message.setCreateTime(
now.minusDays(dayOffset).plusSeconds(secondsOffsetList.get(i - startIndex)));
learnMessageDAO.updateByPrimaryKey(message);
}
startIndex += dayCount;
}
}
// @Override // @Override
// public Integer likeMessage(Long messageId) { // public Integer likeMessage(Long messageId) {
// LearnMessageWithBLOBs message = getMessage(messageId); // LearnMessageWithBLOBs message = getMessage(messageId);
// message.setLike(message.getLike() == null ? 0 : message.getLike() + 1); // message.setLike(message.getLike() == null ? 0 : message.getLike() + 1);
@ -487,38 +459,38 @@ public class LearnService implements ILearnService {
// return message.getUnlike(); // return message.getUnlike();
// } // }
private LearnComment findCommentEntity(Long commentId) { private LearnComment findCommentEntity(Long commentId) {
return learnCommentDAO.selectByPrimaryKey(commentId); return learnCommentDAO.selectByPrimaryKey(commentId);
} }
private LearnComment getCommentEntity(Long commentId) { private LearnComment getCommentEntity(Long commentId) {
LearnComment comment = findCommentEntity(commentId); LearnComment comment = findCommentEntity(commentId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(comment, BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(comment,
"该评论不存在或已被删除"); "该评论不存在或已被删除");
return comment; return comment;
} }
private void deleteMessage(Long messageId) { private void deleteMessage(Long messageId) {
learnMessageDAO.deleteByPrimaryKey(messageId); learnMessageDAO.deleteByPrimaryKey(messageId);
deleteCommentByMessageId(messageId); deleteCommentByMessageId(messageId);
} }
private void deleteCommentByMessageId(Long messageId) { private void deleteCommentByMessageId(Long messageId) {
LearnCommentExample example = new LearnCommentExample(); LearnCommentExample example = new LearnCommentExample();
example.createCriteria().andMessageIdEqualTo(messageId); example.createCriteria().andMessageIdEqualTo(messageId);
learnCommentDAO.deleteByExample(example); learnCommentDAO.deleteByExample(example);
} }
private LearnPost topCheck(Long postId, AccountVO accountVO) { private LearnPost topCheck(Long postId, AccountVO accountVO) {
iSysUserService.confirmAdmin(accountVO); iSysUserService.confirmAdmin(accountVO);
LearnPost post = getPostEntity(postId); LearnPost post = getPostEntity(postId);
return post; return post;
} }
private void checkContent(String content) { private void checkContent(String content) {
WxError wxError = this.miniProgramService.msgSecCheck(content); WxError wxError = this.miniProgramService.msgSecCheck(content);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(wxError.isError(), BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(wxError.isError(),
String.format("内容校验不通过: [%s]", wxError.toString())); String.format("内容校验不通过: [%s]", wxError.toString()));
// Map<String, String> param = new HashMap<>(); // Map<String, String> param = new HashMap<>();
// param.put("content", content); // param.put("content", content);
// WxBaseResp resp = restTemplate.postForObject(weChatConfig.getMsgSecCheckUrl(), param, WxBaseResp.class); // WxBaseResp resp = restTemplate.postForObject(weChatConfig.getMsgSecCheckUrl(), param, WxBaseResp.class);
@ -530,46 +502,44 @@ public class LearnService implements ILearnService {
// } else { // } else {
// throw new BusinessException(ExceptionMapping.SERVER_CALL_EXCEPTION); // throw new BusinessException(ExceptionMapping.SERVER_CALL_EXCEPTION);
// } // }
} }
/** /**
* 留言检查 * 留言检查
*/ */
private void checkMessageExist(Long messageId) { private void checkMessageExist(Long messageId) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(findMessageEntity(messageId), BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(findMessageEntity(messageId),
String.format("id为[%s]的留言不存在", messageId)); String.format("id为[%s]的留言不存在", messageId));
} }
private LearnMessage findMessageEntity(Long messageId) { private LearnMessage findMessageEntity(Long messageId) {
return learnMessageDAO.selectByPrimaryKey(messageId); return learnMessageDAO.selectByPrimaryKey(messageId);
} }
private LearnMessage getMessageEntity(Long messageId) { private LearnMessage getMessageEntity(Long messageId) {
LearnMessage message = findMessageEntity(messageId); LearnMessage message = findMessageEntity(messageId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(message, BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(message, String.format("id为[%s]的留言不存在", messageId));
String.format("id为[%s]的留言不存在", messageId)); return message;
return message; }
}
private LearnPost findPostEntity(Long postId) { private LearnPost findPostEntity(Long postId) {
return learnPostDAO.selectByPrimaryKey(postId); return learnPostDAO.selectByPrimaryKey(postId);
} }
private LearnPost getPostEntity(Long postId) { private LearnPost getPostEntity(Long postId) {
LearnPost post = findPostEntity(postId); LearnPost post = findPostEntity(postId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(post); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(post);
return post; return post;
} }
/** /**
* 确认该项目的留言板不存在 * 确认该项目的留言板不存在
*/ */
private void confirmPostIsNotExist(String project) { private void confirmPostIsNotExist(String project) {
LearnPostExample example = new LearnPostExample(); LearnPostExample example = new LearnPostExample();
example.createCriteria().andProjectEqualTo(project); example.createCriteria().andProjectEqualTo(project);
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue( BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertTrue(learnPostDAO.countByExample(example) == 0,
learnPostDAO.countByExample(example) == 0, String.format("项目[%s]下留言板已存在", project));
String.format("项目[%s]下留言板已存在", project)); }
}
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ package club.joylink.rtss.services.auth;
import club.joylink.rtss.configuration.configProp.OtherConfig; import club.joylink.rtss.configuration.configProp.OtherConfig;
import club.joylink.rtss.configuration.configProp.WeChatConfig; import club.joylink.rtss.configuration.configProp.WeChatConfig;
import club.joylink.rtss.constants.Client; import club.joylink.rtss.constants.Client;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.dao.SysAccountLoginDAO; import club.joylink.rtss.dao.SysAccountLoginDAO;
import club.joylink.rtss.entity.SysAccountLogin; import club.joylink.rtss.entity.SysAccountLogin;
import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.entity.project.Project;
@ -23,7 +22,6 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.LoginStatusVO; import club.joylink.rtss.vo.client.LoginStatusVO;
import club.joylink.rtss.vo.client.LoginUserVO; import club.joylink.rtss.vo.client.LoginUserVO;
import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO; import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.project.RelationLoginConfigVO; import club.joylink.rtss.vo.client.project.RelationLoginConfigVO;
@ -241,24 +239,6 @@ public class AuthenticateService implements IAuthenticateService {
} }
} }
@Override
public String cgyThirdPartyLogin(CgyThirdPartyLoginInfoVO loginInfo) {
BusinessExceptionAssertEnum.INVALID_OPERATION
.assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()),
String.format("成工院父账号不存在: %s", loginInfo.getParentAccount()));
AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount(
loginInfo.getParentAccount(),
loginInfo.getAccount(),
loginInfo.getName());
ProjectVO projectVO = projectService.queryLoginProjectByCode(ProjectCode.CGY);
// 构造登陆用户信息
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(accountVO, Client.Joylink, projectVO, null);
loginUserInfo.setThirdLogin(true);
// 执行登录
login(loginUserInfo, true);
return loginUserInfo.getToken();
}
/** /**
* @update 20221019 去除设置组织信息 * @update 20221019 去除设置组织信息
*/ */
@ -404,7 +384,8 @@ public class AuthenticateService implements IAuthenticateService {
.assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()), .assertTrue(this.iSysUserService.isThirdParentAccountExist(loginInfo.getParentAccount()),
String.format("第三方企业账号不存在: %s", loginInfo.getParentAccount())); String.format("第三方企业账号不存在: %s", loginInfo.getParentAccount()));
AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount( AccountVO accountVO = this.iSysUserService.queryOrCreateThirdAccount(
loginInfo.getParentAccount(), loginInfo.getAccount(), null); loginInfo.getParentAccount(),
loginInfo.getAccount());
Client client = Client.getByIdAndSecret(loginInfo.getClientId(), loginInfo.getSecret()); Client client = Client.getByIdAndSecret(loginInfo.getClientId(), loginInfo.getSecret());
ProjectVO projectVO = projectService.queryLoginProjectByCode(loginInfo.getProject()); ProjectVO projectVO = projectService.queryLoginProjectByCode(loginInfo.getProject());
// 构造登陆用户信息 // 构造登陆用户信息
@ -497,8 +478,6 @@ public class AuthenticateService implements IAuthenticateService {
case ILW: case ILW:
case PIS_STAND: case PIS_STAND:
case PIS_TRAIN: case PIS_TRAIN:
case PIS:
case TMS:
case VR_IBP: { case VR_IBP: {
RelationLoginConfigVO config = deviceVO.buildRelationLoginConfig(); RelationLoginConfigVO config = deviceVO.buildRelationLoginConfig();
if (Objects.nonNull(config) && Objects.nonNull(config.getDeviceCode())) { if (Objects.nonNull(config) && Objects.nonNull(config.getDeviceCode())) {

View File

@ -5,127 +5,120 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.LoginStatusVO; import club.joylink.rtss.vo.client.LoginStatusVO;
import club.joylink.rtss.vo.client.LoginUserVO; import club.joylink.rtss.vo.client.LoginUserVO;
import club.joylink.rtss.vo.client.cgy.CgyThirdPartyLoginInfoVO;
public interface IAuthenticateService { public interface IAuthenticateService {
/** /**
* 获取登陆状态/token * 获取登陆状态/token
* *
* @param sessionId * @param sessionId
* @return * @return
*/ */
LoginStatusVO checkStatus(String sessionId); LoginStatusVO checkStatus(String sessionId);
/** /**
* 通过密码登陆 * 通过密码登陆
* *
* @param loginUser * @param loginUser
*/ */
String loginWithPwd(LoginUserVO loginUser); String loginWithPwd(LoginUserVO loginUser);
/** /**
* 第三方登录 * 第三方登录
* *
* @param loginInfo * @param loginInfo
* @return * @return
*/ */
String thirdPartyLogin(LoginUserVO loginInfo); String thirdPartyLogin(LoginUserVO loginInfo);
/** /**
* 登出 * 登出
* *
* @param token * @param token
*/ */
void logout(String token); void logout(String token);
/** /**
* 微信小程序扫登陆二维码 * 微信小程序扫登陆二维码
* *
* @param code * @param code
* @param state * @param state
* @return * @return
*/ */
AccountVO scanWmLoginQrCode(String code, String state); AccountVO scanWmLoginQrCode(String code, String state);
/** /**
* 获取微信小程序登陆url * 获取微信小程序登陆url
* *
* @param clientId * @param clientId
* @param secret * @param secret
* @param project * @param project
* @param deviceCode * @param deviceCode
* @return * @return
*/ */
// LoginStatusVO getWmLoginUrl(String clientId, String secret, Project project, String deviceCode); // LoginStatusVO getWmLoginUrl(String clientId, String secret, Project project, String deviceCode);
/** /**
* TODO 20220922 用于替换上方方法 占位 * TODO 20220922 用于替换上方方法 占位
* <p> * <p>
* 测试文档后删除相关注释 * 测试文档后删除相关注释
*/ */
LoginStatusVO getWmLoginUrl(String clientId, String secret, String projectCode, LoginStatusVO getWmLoginUrl(String clientId, String secret, String projectCode, String deviceCode);
String deviceCode);
/** /**
* 微信小程序确认登陆 * 微信小程序确认登陆
* *
* @param code * @param code
* @param state * @param state
*/ */
void wmConfirmClientLogin(String code, String state); void wmConfirmClientLogin(String code, String state);
/** /**
* 通过token获取登陆用户信息 * 通过token获取登陆用户信息
* *
* @param token * @param token
*/ */
LoginUserInfoVO getLoginUserInfoByToken(String token); LoginUserInfoVO getLoginUserInfoByToken(String token);
/** /**
* 根据微信小程序code获取用户若不存在创建用户若已登录则绑定微信 * 根据微信小程序code获取用户若不存在创建用户若已登录则绑定微信
* *
* @param code * @param code
* @return * @return
*/ */
AccountVO getOrCreateUserByWmcode(WxApiService.MiniApp miniApp, String code); AccountVO getOrCreateUserByWmcode(WxApiService.MiniApp miniApp, String code);
/** /**
* 玖琏科技小程序code换token * 玖琏科技小程序code换token
* *
* @param code * @param code
* @return * @return
*/ */
String getTokenByWmCode(String code); String getTokenByWmCode(String code);
/** /**
* 到那儿了小程序code换token * 到那儿了小程序code换token
* *
* @param code * @param code
* @return * @return
*/ */
String getTokenByWmCode2(String code); String getTokenByWmCode2(String code);
/** /**
* 郑州共赢小程序code换token * 郑州共赢小程序code换token
* *
* @param code * @param code
* @return * @return
*/ */
String getTokenByWmCode3(String code); String getTokenByWmCode3(String code);
boolean isTokenExpired(String token); boolean isTokenExpired(String token);
/** /**
* 预登出前端在刷新/关闭标签页的时候调用 * 预登出前端在刷新/关闭标签页的时候调用
* *
* @param token * @param token
*/ */
void preLogout(String token); void preLogout(String token);
/**
* 成工业虚仿平台跳转登录接口
*/
String cgyThirdPartyLogin(CgyThirdPartyLoginInfoVO loginInfo);
} }

View File

@ -1,171 +0,0 @@
package club.joylink.rtss.services.cgy;
import club.joylink.rtss.bo.cgy.CgyStatsBO;
import club.joylink.rtss.dao.CgyViewDAO;
import club.joylink.rtss.entity.CgyView;
import club.joylink.rtss.entity.CgyViewExample;
import club.joylink.rtss.entity.UserSimulationRecord;
import club.joylink.rtss.event.UserSimulationRecordEvent;
import club.joylink.rtss.services.user.UserSimulationRecordService;
import club.joylink.rtss.simulation.cbtc.SimulationService;
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import club.joylink.rtss.util.EncryptUtil;
import club.joylink.rtss.vo.client.simulationUsage.SimulationUsageRecordQueryVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
/**
* 成工院虚仿平台对接统计服务
*/
@Slf4j
@Service
public class CgyStatsService {
private CgyViewDAO cgyViewDAO;
private UserSimulationRecordService userSimulationRecordService;
private SimulationService simulationService;
private RestTemplate restTemplate;
@Autowired
public CgyStatsService(CgyViewDAO cgyViewDAO,
UserSimulationRecordService userSimulationRecordService,
SimulationService simulationService, RestTemplate restTemplate) {
this.cgyViewDAO = cgyViewDAO;
this.userSimulationRecordService = userSimulationRecordService;
this.simulationService = simulationService;
this.restTemplate = restTemplate;
}
private final ConcurrentHashMap<String, CgyStatsBO> appStatsMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Long, CgyStatsBO> functionStatsMap = new ConcurrentHashMap<>();
@PostConstruct
public void makeCache() {
List<CgyView> cgyViews = cgyViewDAO.selectByExample(new CgyViewExample());
if (CollectionUtils.isEmpty(cgyViews)) {
return;
}
cgyViews.forEach(cgyView -> {
CgyStatsBO bo = new CgyStatsBO(cgyView.getAppId(), cgyView.getAppSecret(),
cgyView.getFunctionId());
bo.setChange(new AtomicBoolean(true));
bo.setView(new AtomicLong(cgyView.getViewCount()));
makeCache(bo);
appStatsMap.put(cgyView.getAppId(), bo);
functionStatsMap.put(cgyView.getFunctionId(), bo);
});
}
/**
* 向虚仿平台同步数据
*/
@Scheduled(fixedRate = 2000)
public void syncData() {
appStatsMap.forEach((appId, statsBO) -> {
if (!statsBO.getChange().getAndSet(false)) {
return;
}
//同步汇总数据
Map<String, Object> body = new HashMap<>();
body.put("app_id", appId);
body.put("timestamp", System.currentTimeMillis());
body.put("view", statsBO.getView().get());
body.put("visitor", statsBO.getVisitor().get());
body.put("user", statsBO.getUserSet().size());
String sb = "app_id=" + body.get("app_id") + "&"
+ "timestamp=" + body.get("timestamp") + "&"
+ "user=" + body.get("user") + "&"
+ "view=" + body.get("view") + "&"
+ "visitor=" + body.get("visitor") + "&"
+ "app_secret=" + statsBO.getAppSecret();
body.put("sign", EncryptUtil.md5(sb).toLowerCase());
//扩展字段
body.put("duration", statsBO.getDuration().get() / 60); //分钟
SimulationInfoQueryVO queryVO = new SimulationInfoQueryVO();
queryVO.setFunctionId(statsBO.getFunctionId());
List<SimulationInfoVO> sims = simulationService.listAllSimulation(queryVO);
body.put("onlineUser", sims.size());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(body, httpHeaders);
Map<String, String> resBody = restTemplate.postForObject(
"http://gdjtapp.cdivtc.edu.cn/api/applicationCenter/openapi/summary", httpEntity,
Map.class);
if (resBody != null && Objects.equals(resBody.get("code"), "100001")) {
log.error(String.format("成工院虚仿平台同步数据失败:[%s][%s]", resBody.get("msg"),
resBody.get("data")));
}
});
}
@Async("thirdAccountDataSyncExecutor")
@EventListener
public void syncUserSimulationUsing(UserSimulationRecordEvent event) {
UserSimulationRecord record = event.getRecord();
CgyStatsBO cgyStatsBO = functionStatsMap.get(record.getFunctionId());
if (Objects.nonNull(cgyStatsBO)) {
cgyStatsBO.getVisitor().incrementAndGet();
cgyStatsBO.getUserSet().add(record.getUserId());
cgyStatsBO.getDuration().addAndGet(record.getDuration());
cgyStatsBO.getChange().set(true);
}
}
/**
* 更新此App的浏览量数据
*/
public void updateView(String appId) {
CgyStatsBO cgyStatsBO = appStatsMap.get(appId);
if (cgyStatsBO == null) {
log.warn(String.format("成工院虚仿平台未知的appId%s", appId));
return;
}
long count = cgyStatsBO.getView().incrementAndGet();
CgyView record = new CgyView();
record.setAppId(appId);
record.setViewCount(count);
CgyViewExample example = new CgyViewExample();
example.createCriteria().andAppIdEqualTo(appId).andViewCountLessThan(count);
cgyViewDAO.updateByExampleSelective(record, example);
cgyStatsBO.getChange().set(true);
}
/**
* 实训人数实训人次实训时长缓存
*/
private void makeCache(CgyStatsBO bo) {
long visitor = 0;
long duration = 0;
//实训人数人次时长
List<UserSimulationRecord> records = userSimulationRecordService.listSimulationUsageRecords(
new SimulationUsageRecordQueryVO(null, bo.getFunctionId()));
if (!CollectionUtils.isEmpty(records)) {
visitor = records.size();
for (UserSimulationRecord record : records) {
bo.getUserSet().add(record.getUserId()); //实训人数
duration += record.getDuration();
}
}
bo.setVisitor(new AtomicLong(visitor)); //实训人次
bo.setDuration(new AtomicLong(duration)); //实训时长
}
}

View File

@ -1,14 +1,26 @@
package club.joylink.rtss.services.draftData; package club.joylink.rtss.services.draftData;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Routing;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 交路生成 * 交路生成
*/ */
@ -122,7 +134,7 @@ public class RoutingGenerator {
if (signal == null) { if (signal == null) {
Section base = section; Section base = section;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Section next = base.getSectionOf(right); Section next = base.findNextRunningSectionBaseRealSwitch(right);
if (next == null) { // 可能到尽头了 if (next == null) { // 可能到尽头了
return; return;
} }

View File

@ -15,98 +15,91 @@ import java.util.Collection;
import java.util.List; import java.util.List;
public interface IOrgService { public interface IOrgService {
OrgVO createTopOrg(TopOrgCreateVO topOrgCreateVO, AccountVO user);
/** List<OrgVO> queryAllTopOrg();
* 查找默认组织
*
* @return
*/
Org findDefaultOrg();
OrgVO createTopOrg(TopOrgCreateVO topOrgCreateVO, AccountVO user); PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO);
List<OrgVO> queryAllTopOrg(); void confirmExist(Long orgId);
PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO); OrgVO createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo);
void confirmExist(Long orgId); Org getEntity(long orgId);
OrgVO createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo); Org findEntity(long orgId);
Org getEntity(long orgId); // TODO 20220922 将Project 修改为 String
Collection<Org> getEntities(String project, String status);
Org findEntity(long orgId); // TODO 20220922 将Project 修改为 String
Collection<Org> findEntities(String project, String status);
// TODO 20220922 将Project 修改为 String OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user);
Collection<Org> getEntities(String project, String status);
// TODO 20220922 将Project 修改为 String /**
Collection<Org> findEntities(String project, String status); * 删除非顶级组织
*
* @param nonTopOrgId
*/
void deleteNonTopOrg(Long nonTopOrgId);
OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user); List<Org> findEntitiesByParentId(Long parentId, String orderBy, String status);
/** /**
* 删除非顶级组织 * 分页查询自己创建的班级
* */
* @param nonTopOrgId PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
*/
void deleteNonTopOrg(Long nonTopOrgId);
List<Org> findEntitiesByParentId(Long parentId, String orderBy, String status); /**
* 查询自己创建的班级
*/
List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
/** /**
* 分页查询自己创建的班级 * 获取该组织所属的顶级组织
*/ */
PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo); Org getTopOrgEntity(Long orgId);
/** List<Org> findEntities(List<Long> orgIds, String status);
* 查询自己创建的班级
*/
List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
/** /**
* 获取该组织所属的顶级组织 * 管理员分页查询组织
*/ */
Org getTopOrgEntity(Long orgId); Node<Object> adminQueryOrgTree(Long orgId);
List<Org> findEntities(List<Long> orgIds, String status); OrgVO get(Long id);
/** /**
* 管理员分页查询组织 * 查询这些考试关联的班级
*/ */
Node<Object> adminQueryOrgTree(Long orgId); List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status);
OrgVO get(Long id); void confirmIsTopOrg(long id);
/** void confirmIsNonTopOrg(Long id);
* 查询这些考试关联的班级
*/
List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status);
void confirmIsTopOrg(long id); List<Org> queryAllSubOrgs(Long orgId);
void confirmIsNonTopOrg(Long id); String getBindQrCode(long orgId, String project);
List<Org> queryAllSubOrgs(Long orgId); /**
* 获取该用户所属的顶级组织
*/
Org getTopOrgOfUser(long userId);
String getBindQrCode(long orgId, String project); Org findTopOrgOfUser(long userId);
/** /**
* 获取该用户所属的顶级组织 * 查询该组织下的所有班级
*/ * 目前组织结构仅有两级非顶级的就是班级
Org getTopOrgOfUser(long userId); */
List<OrgVO> listQueryCls(long topOrgId);
Org findTopOrgOfUser(long userId); /**
* 查询组织信息可能返回null
*/
OrgVO query(Long id);
/** OrgVO getTopOrg(long topOrgId);
* 查询该组织下的所有班级 目前组织结构仅有两级非顶级的就是班级
*/
List<OrgVO> listQueryCls(long topOrgId);
/**
* 查询组织信息可能返回null
*/
OrgVO query(Long id);
OrgVO getTopOrg(long topOrgId);
} }

View File

@ -1,13 +1,11 @@
package club.joylink.rtss.services.org; package club.joylink.rtss.services.org;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.dao.OrgDAO; import club.joylink.rtss.dao.OrgDAO;
import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.ISysUserService; import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.services.QRCodeManager; import club.joylink.rtss.services.QRCodeManager;
import club.joylink.rtss.services.cache.ICacheService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.ExamDefinitionVO; import club.joylink.rtss.vo.client.ExamDefinitionVO;
@ -16,8 +14,6 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.*; import club.joylink.rtss.vo.client.org.*;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import lombok.NonNull; import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,470 +28,444 @@ import java.util.stream.Collectors;
@Service @Service
public class OrgService implements IOrgService { public class OrgService implements IOrgService {
@Autowired
private OrgDAO orgDAO;
@Autowired @Autowired
private OrgDAO orgDAO; private IOrgUserService iOrgUserService;
@Autowired @Autowired
private IOrgUserService iOrgUserService; private ISysUserService iSysUserService;
@Autowired @Autowired
private ISysUserService iSysUserService; private QRCodeManager qrCodeManager;
@Autowired @Autowired
private QRCodeManager qrCodeManager; private IOrgProjectService orgProjectService;
@Autowired @Transactional
private IOrgProjectService orgProjectService; @Override
public OrgVO createTopOrg(TopOrgCreateVO topOrgCreateVO, AccountVO user) {
@Autowired confirmNameUnique(null, topOrgCreateVO.getName());
private ICacheService cacheService; /* 处理 */
Org entity = topOrgCreateVO.toDB();
entity.setId(null);
@Override entity.setCreatorId(user.getId());
public Org findDefaultOrg() { entity.setCreateTime(LocalDateTime.now());
String defName = String.format("%s-org-default", Project.DEFAULT.name()); entity.setStatus(BusinessConsts.Org.Status.VALID);
Object obj = this.cacheService.get(defName); this.orgDAO.insert(entity);
if (Objects.nonNull(obj)) { entity.setRootId(entity.getId());
return (Org) obj; orgDAO.updateByPrimaryKey(entity);
// 20220929 增加
orgProjectService.save(entity.getId(), topOrgCreateVO.getProjectCodes(), user);
return new OrgVO(entity, topOrgCreateVO.getProjectCodes());
} }
OrgExample orgExample = new OrgExample(); /**
orgExample.createCriteria().andProjectCodeEqualTo(Project.DEFAULT.name()); * 确认名称唯一
List<Org> orgs = this.orgDAO.selectByExample(orgExample); */
if (!CollectionUtils.isEmpty(orgs)) { private void confirmNameUnique(Long orgId, String name) {
Org org = orgs.get(0); //名称检查
this.cacheService.putExpired(defName, org, 600, TimeUnit.SECONDS); OrgExample example = new OrgExample();
return org; OrgExample.Criteria criteria = example.createCriteria().andNameEqualTo(name);
if (orgId != null) {
criteria.andIdNotEqualTo(orgId);
}
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(orgDAO.countByExample(example) == 0,
"名称重复");
} }
return null;
}
@Transactional @Override
@Override public List<OrgVO> queryAllTopOrg() {
public OrgVO createTopOrg(TopOrgCreateVO topOrgCreateVO, AccountVO user) { OrgExample example = new OrgExample();
confirmNameUnique(null, topOrgCreateVO.getName()); example.createCriteria().andParentIdIsNull();
/* 处理 */ List<Org> orgs = this.orgDAO.selectByExample(example);
Org entity = topOrgCreateVO.toDB(); List<Long> orgIds = orgs.stream().map(Org::getId).collect(Collectors.toList());
entity.setId(null); List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds);
entity.setCreatorId(user.getId()); return OrgVO.convert2VOList(orgs, orgProjects);
entity.setCreateTime(LocalDateTime.now());
entity.setStatus(BusinessConsts.Org.Status.VALID);
this.orgDAO.insert(entity);
entity.setRootId(entity.getId());
orgDAO.updateByPrimaryKey(entity);
// 20220929 增加
orgProjectService.save(entity.getId(), topOrgCreateVO.getProjectCodes(), user);
return new OrgVO(entity, topOrgCreateVO.getProjectCodes());
}
/**
* 确认名称唯一
*/
private void confirmNameUnique(Long orgId, String name) {
//名称检查
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andNameEqualTo(name);
if (orgId != null) {
criteria.andIdNotEqualTo(orgId);
} }
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(orgDAO.countByExample(example) == 0,
"名称重复");
}
@Override @Override
public List<OrgVO> queryAllTopOrg() { public PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO) {
OrgExample example = new OrgExample(); PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
example.createCriteria().andParentIdIsNull(); OrgExample example = new OrgExample();
List<Org> orgs = this.orgDAO.selectByExample(example); OrgExample.Criteria criteria = example.createCriteria();
List<Long> orgIds = orgs.stream().map(Org::getId).collect(Collectors.toList()); criteria.andParentIdIsNull().andStatusEqualTo(BusinessConsts.Org.Status.VALID);
List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds); if (StringUtils.hasText(queryVO.getName())) {
return OrgVO.convert2VOList(orgs, orgProjects); criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
} }
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
@Override List<Long> orgIds = page.getResult().stream().map(Org::getId).collect(Collectors.toList());
public PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO) { List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds);
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); List<OrgVO> voList = OrgVO.convert2VOList(page.getResult(), orgProjects);
OrgExample example = new OrgExample(); return PageVO.convert(page, voList);
OrgExample.Criteria criteria = example.createCriteria();
criteria.andParentIdIsNull().andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
} }
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<Long> orgIds = page.getResult().stream().map(Org::getId).collect(Collectors.toList());
List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds);
List<OrgVO> voList = OrgVO.convert2VOList(page.getResult(), orgProjects);
return PageVO.convert(page, voList);
}
@Override @Override
public void confirmExist(Long orgId) { public void confirmExist(Long orgId) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(orgDAO.selectByPrimaryKey(orgId), BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(orgDAO.selectByPrimaryKey(orgId),
String.format("id为[%s]的组织不存在", orgId)); String.format("id为[%s]的组织不存在", orgId));
}
@Transactional
@Override
public OrgVO createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo) {
//检查
Long topOrgId = loginInfo.getTopOrgId();
Long userId = loginInfo.getAccountVO().getId();
iOrgUserService.confirmUserIsTheRoleInThisOrg(userId, topOrgId, BusinessConsts.OrgRole.Admin);
Org cls = createNonTopOrg(createVO.getName(), topOrgId, topOrgId, userId);
iOrgUserService.create(cls.getId(), userId, BusinessConsts.OrgRole.Teacher);
return new OrgVO(cls);
}
@Override
public Org getEntity(long orgId) {
Org org = orgDAO.selectByPrimaryKey(orgId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(org, String.format("id为[%s]的组织不存在", orgId));
return org;
}
@Override
public Org findEntity(long orgId) {
return orgDAO.selectByPrimaryKey(orgId);
}
@Override
public Collection<Org> getEntities(String project, String status) {
Collection<Org> orgs = findEntities(project, status);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("关联项目[%s]的组织不存在", project));
return orgs;
}
@Override
public Collection<Org> findEntities(@NonNull String project, String status) {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andProjectCodeLike(String.format("%%%s%%", project));
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
} }
return orgDAO.selectByExample(example);
}
@Override @Transactional
public OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user) { @Override
//校验 public OrgVO createCls(NonTopOrgCreateVO createVO, LoginUserInfoVO loginInfo) {
Org org = getEntity(id); //检查
if (!CollectionUtils.isEmpty(orgVO.getProjectCodes())) { Long topOrgId = loginInfo.getTopOrgId();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(isTopOrg(org), "非顶级组织不能修改关联项目"); Long userId = loginInfo.getAccountVO().getId();
iOrgUserService.confirmUserIsTheRoleInThisOrg(userId, topOrgId, BusinessConsts.OrgRole.Admin);
Org cls = createNonTopOrg(createVO.getName(), topOrgId, topOrgId, userId);
iOrgUserService.create(cls.getId(), userId, BusinessConsts.OrgRole.Teacher);
return new OrgVO(cls);
}
@Override
public Org getEntity(long orgId) {
Org org = orgDAO.selectByPrimaryKey(orgId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(org, String.format("id为[%s]的组织不存在", orgId));
return org;
}
@Override
public Org findEntity(long orgId) {
return orgDAO.selectByPrimaryKey(orgId);
}
@Override
public Collection<Org> getEntities(String project, String status) {
Collection<Org> orgs = findEntities(project, status);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, String.format("关联项目[%s]的组织不存在", project));
return orgs;
}
@Override
public Collection<Org> findEntities(@NonNull String project, String status) {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andProjectCodeLike(String.format("%%%s%%", project));
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
}
@Override
public OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user) {
//校验
Org org = getEntity(id);
if (!CollectionUtils.isEmpty(orgVO.getProjectCodes())) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(isTopOrg(org), "非顶级组织不能修改关联项目");
// confirmProjectCodesNotRepeat(org.getId(), orgVO.getProjectCodes()); // confirmProjectCodesNotRepeat(org.getId(), orgVO.getProjectCodes());
// 20220929 增加 // 20220929 增加
orgProjectService.update(id, orgVO.getProjectCodes(), user); orgProjectService.update(id, orgVO.getProjectCodes(), user);
} }
confirmNameUnique(id, orgVO.getName()); confirmNameUnique(id, orgVO.getName());
//更新 //更新
org.setName(orgVO.getName()); org.setName(orgVO.getName());
// org.setProjectCode(orgVO.getDBProjectCode()); // org.setProjectCode(orgVO.getDBProjectCode());
org.setUpdateId(user.getId()); org.setUpdateId(user.getId());
org.setUpdateTime(LocalDateTime.now()); org.setUpdateTime(LocalDateTime.now());
this.orgDAO.updateByPrimaryKeySelective(org); this.orgDAO.updateByPrimaryKeySelective(org);
List<String> projects = orgProjectService.queryOrgProjectListByOrgId(org.getId()).stream() List<String> projects = orgProjectService.queryOrgProjectListByOrgId(org.getId()).stream()
.map(OrgProject::getProjectCode).collect(Collectors.toList()); .map(OrgProject::getProjectCode).collect(Collectors.toList());
return new OrgVO(org, projects); return new OrgVO(org, projects);
}
@Override
public void deleteNonTopOrg(Long nonTopOrgId) {
confirmIsNonTopOrg(nonTopOrgId);
Org org = new Org();
org.setId(nonTopOrgId);
org.setStatus(BusinessConsts.Org.Status.DELETE);
orgDAO.updateByPrimaryKeySelective(org);
}
@Override
public List<Org> findEntitiesByParentId(@NonNull Long parentId, String orderBy, String status) {
OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
} }
OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(parentId);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
}
@Override @Override
public PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) { public void deleteNonTopOrg(Long nonTopOrgId) {
OrgExample example = new OrgExample(); confirmIsNonTopOrg(nonTopOrgId);
OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(loginInfo.getTopOrgId()) Org org = new Org();
.andStatusEqualTo(BusinessConsts.Org.Status.VALID); org.setId(nonTopOrgId);
if (StringUtils.hasText(queryVO.getName())) { org.setStatus(BusinessConsts.Org.Status.DELETE);
criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); orgDAO.updateByPrimaryKeySelective(org);
} }
if (StringUtils.hasText(queryVO.getCreatorName())) {
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(AccountVO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(creatorIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<Long> creatorIds = page.stream().map(Org::getCreatorId).collect(Collectors.toList());
Map<Long, SysAccount> creatorMap = iSysUserService.findEntities(creatorIds, null).stream()
.collect(Collectors.toMap(SysAccount::getId, Function.identity()));
List<OrgVO> list = page.getResult().stream().map(entity -> {
int numberOfPeople = iOrgUserService.getQuantities(entity.getId(), BusinessConsts.OrgRole.Student);
return new OrgVO(entity, null, numberOfPeople, creatorMap.get(entity.getCreatorId()));
}).collect(Collectors.toList());
return PageVO.convert(page, list);
}
@Override @Override
public List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) { public List<Org> findEntitiesByParentId(@NonNull Long parentId, String orderBy, String status) {
OrgExample example = new OrgExample(); OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria() if (StringUtils.hasText(orderBy)) {
.andParentIdEqualTo(loginInfo.getTopOrgId()) example.setOrderByClause(orderBy);
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
}
List<Org> clsList = orgDAO.selectByExample(example);
return clsList.stream().map(OrgVO::new).collect(Collectors.toList());
}
@Override
public Org getTopOrgEntity(Long orgId) {
Org entity = getEntity(orgId);
if (isTopOrg(entity)) {
return entity;
}
return getEntity(entity.getRootId());
}
@Override
public List<Org> findEntities(List<Long> orgIds, String status) {
if (CollectionUtils.isEmpty(orgIds)) {
return new ArrayList<>();
} else {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria().andIdIn(orgIds);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
}
}
@Override
public Node<Object> adminQueryOrgTree(Long orgId) {
/* 先筛选组织 */
OrgVO orgVO = get(orgId);
Map<Long, List<Org>> groupByParentIdOrg = findEntitiesByRootId(orgVO.getRootId(), null, BusinessConsts.Org.Status.VALID)
.stream().filter(o -> !isTopOrg(o)).collect(Collectors.groupingBy(Org::getParentId));
Node<Object> root = new Node<>(orgVO, Node.Type.ORG);
Map<Long, Node<Object>> all_orgId_node_map = new HashMap<>(); //所有的组织和对应的节点
Map<Long, Node<Object>> orgId_node_map = new HashMap<>();
orgId_node_map.put(orgVO.getId(), root);
while (!orgId_node_map.isEmpty()) {
all_orgId_node_map.putAll(orgId_node_map);
Map<Long, Node<Object>> newMap = new HashMap<>();
orgId_node_map.forEach((k, v) -> {
List<Org> childOrgList = groupByParentIdOrg.get(k);
if (!CollectionUtils.isEmpty(childOrgList)) {
List<Node<Object>> children = childOrgList.stream().map(o -> {
Node<Object> node = new Node<>(new OrgVO(o), Node.Type.ORG);
newMap.put(o.getId(), node);
return node;
}).collect(Collectors.toList());
v.setChildren(children);
} }
}); OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(parentId);
orgId_node_map = newMap; if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
} }
/* 再查询用户 */
List<OrgUser> orgUsers = iOrgUserService.findEntitiesByOrgIds(new ArrayList<>(all_orgId_node_map.keySet()), null); @Override
Map<Long, List<OrgUser>> groupByOrgIdOrgUsers = orgUsers.stream().collect(Collectors.groupingBy(OrgUser::getOrgId)); public PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
List<Long> userIds = orgUsers.stream().map(OrgUser::getUserId).collect(Collectors.toList()); OrgExample example = new OrgExample();
Map<Long, SysAccount> userMap = iSysUserService.findEntities(userIds, null) OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(loginInfo.getTopOrgId())
.stream().collect(Collectors.toMap(SysAccount::getId, Function.identity())); .andStatusEqualTo(BusinessConsts.Org.Status.VALID);
all_orgId_node_map.forEach((k, v) -> { if (StringUtils.hasText(queryVO.getName())) {
List<OrgUser> ous = groupByOrgIdOrgUsers.get(k); criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
if (!CollectionUtils.isEmpty(ous)) { }
List<Node<Object>> children = ous.stream().map(ou -> { if (StringUtils.hasText(queryVO.getCreatorName())) {
OrgUserVO vo = new OrgUserVO(ou, userMap.get(ou.getUserId())); List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(AccountVO::getId).collect(Collectors.toList());
return new Node<Object>(vo, Node.Type.USER); if (CollectionUtils.isEmpty(creatorIds)) {
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
} else {
criteria.andCreatorIdIn(creatorIds);
}
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
List<Long> creatorIds = page.stream().map(Org::getCreatorId).collect(Collectors.toList());
Map<Long, SysAccount> creatorMap = iSysUserService.findEntities(creatorIds, null).stream()
.collect(Collectors.toMap(SysAccount::getId, Function.identity()));
List<OrgVO> list = page.getResult().stream().map(entity -> {
int numberOfPeople = iOrgUserService.getQuantities(entity.getId(), BusinessConsts.OrgRole.Student);
return new OrgVO(entity, null, numberOfPeople, creatorMap.get(entity.getCreatorId()));
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(v.getChildren())) { return PageVO.convert(page, list);
children.addAll(v.getChildren()); }
@Override
public List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
OrgExample example = new OrgExample();
OrgExample.Criteria criteria = example.createCriteria()
.andParentIdEqualTo(loginInfo.getTopOrgId())
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
if (queryVO != null) {
if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
} }
v.setChildren(children); List<Org> clsList = orgDAO.selectByExample(example);
} return clsList.stream().map(OrgVO::new).collect(Collectors.toList());
});
return root;
}
@Override
public OrgVO get(Long id) {
OrgVO vo = query(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(vo, String.format("[id:%s]的组织不存在", id));
return vo;
}
@Override
public List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status) {
if (CollectionUtils.isEmpty(examIds)) {
return new ArrayList<>();
} }
return orgDAO.queryByExamIds(examIds, status);
}
/** @Override
* 确认是顶级组织 public Org getTopOrgEntity(Long orgId) {
* Org entity = getEntity(orgId);
* @param id if (isTopOrg(entity))
*/ return entity;
@Override return getEntity(entity.getRootId());
public void confirmIsTopOrg(long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isTopOrg(id),
String.format("组织[%s]不是顶级组织", id));
}
/**
* 确认是非顶级组织
*/
@Override
public void confirmIsNonTopOrg(Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!isTopOrg(id),
String.format("组织[%s]是顶级组织", id));
}
@Override
public List<Org> queryAllSubOrgs(Long orgId) {
OrgExample example = new OrgExample();
example.createCriteria()
.andParentIdEqualTo(orgId)
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
List<Org> orgs = this.orgDAO.selectByExample(example);
return orgs;
}
@Override
public String getBindQrCode(long orgId, String project) {
return qrCodeManager.getOrgBindCode(orgId, project);
}
@Override
public Org getTopOrgOfUser(long userId) {
Org org = findTopOrgOfUser(userId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(org, String.format("用户[%s]无所属顶级组织", userId));
return org;
}
@Override
public Org findTopOrgOfUser(long userId) {
List<OrgUser> orgUsers = iOrgUserService.findEntitiesByUserId(userId, null);
if (CollectionUtils.isEmpty(orgUsers)) {
return null;
} }
Long orgId = orgUsers.stream()
.filter(orgUser -> BusinessConsts.OrgRole.Admin.name().equals(orgUser.getRole())) //目前有管理员的一定是顶级组织 @Override
.findAny().orElse(orgUsers.get(0)).getOrgId(); public List<Org> findEntities(List<Long> orgIds, String status) {
Org org = getTopOrgEntity(orgId); if (CollectionUtils.isEmpty(orgIds)) {
if (BusinessConsts.Org.Status.VALID.equals(org.getStatus())) { return new ArrayList<>();
return org; } else {
} else { OrgExample example = new OrgExample();
return null; OrgExample.Criteria criteria = example.createCriteria().andIdIn(orgIds);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
return orgDAO.selectByExample(example);
}
} }
}
@Override @Override
public List<OrgVO> listQueryCls(long topOrgId) { public Node<Object> adminQueryOrgTree(Long orgId) {
List<Org> clsList = findClsByTopOrgId(topOrgId); /* 先筛选组织 */
return OrgVO.convert2VOList(clsList); OrgVO orgVO = get(orgId);
} Map<Long, List<Org>> groupByParentIdOrg = findEntitiesByRootId(orgVO.getRootId(), null, BusinessConsts.Org.Status.VALID)
.stream().filter(o -> !isTopOrg(o)).collect(Collectors.groupingBy(Org::getParentId));
@Override Node<Object> root = new Node<>(orgVO, Node.Type.ORG);
public OrgVO query(Long id) { Map<Long, Node<Object>> all_orgId_node_map = new HashMap<>(); //所有的组织和对应的节点
Org entity = findEntity(id); Map<Long, Node<Object>> orgId_node_map = new HashMap<>();
if (entity == null) { orgId_node_map.put(orgVO.getId(), root);
return null; while (!orgId_node_map.isEmpty()) {
all_orgId_node_map.putAll(orgId_node_map);
Map<Long, Node<Object>> newMap = new HashMap<>();
orgId_node_map.forEach((k, v) -> {
List<Org> childOrgList = groupByParentIdOrg.get(k);
if (!CollectionUtils.isEmpty(childOrgList)) {
List<Node<Object>> children = childOrgList.stream().map(o -> {
Node<Object> node = new Node<>(new OrgVO(o), Node.Type.ORG);
newMap.put(o.getId(), node);
return node;
}).collect(Collectors.toList());
v.setChildren(children);
}
});
orgId_node_map = newMap;
}
/* 再查询用户 */
List<OrgUser> orgUsers = iOrgUserService.findEntitiesByOrgIds(new ArrayList<>(all_orgId_node_map.keySet()), null);
Map<Long, List<OrgUser>> groupByOrgIdOrgUsers = orgUsers.stream().collect(Collectors.groupingBy(OrgUser::getOrgId));
List<Long> userIds = orgUsers.stream().map(OrgUser::getUserId).collect(Collectors.toList());
Map<Long, SysAccount> userMap = iSysUserService.findEntities(userIds, null)
.stream().collect(Collectors.toMap(SysAccount::getId, Function.identity()));
all_orgId_node_map.forEach((k, v) -> {
List<OrgUser> ous = groupByOrgIdOrgUsers.get(k);
if (!CollectionUtils.isEmpty(ous)) {
List<Node<Object>> children = ous.stream().map(ou -> {
OrgUserVO vo = new OrgUserVO(ou, userMap.get(ou.getUserId()));
return new Node<Object>(vo, Node.Type.USER);
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(v.getChildren())) {
children.addAll(v.getChildren());
}
v.setChildren(children);
}
});
return root;
} }
List<String> projects;
if (isTopOrg(entity)) { @Override
projects = orgProjectService.queryOrgProjectListByOrgId(entity.getId()).stream() public OrgVO get(Long id) {
.map(OrgProject::getProjectCode).collect(Collectors.toList()); OrgVO vo = query(id);
} else { BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(vo, String.format("[id:%s]的组织不存在", id));
projects = null; return vo;
} }
return new OrgVO(entity, projects);
}
@Override @Override
public OrgVO getTopOrg(long topOrgId) { public List<ExamDefinitionVO> queryByExamIds(List<Long> examIds, String status) {
Org org = getEntity(topOrgId); if (CollectionUtils.isEmpty(examIds)) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(isTopOrg(org), return new ArrayList<>();
String.format("[id:%s]的组织不是顶级组织", topOrgId)); }
List<String> projects = orgProjectService.queryOrgProjectListByOrgId(topOrgId) return orgDAO.queryByExamIds(examIds, status);
.stream().map(OrgProject::getProjectCode).collect(Collectors.toList());
return new OrgVO(org, projects);
}
/**
* 查询该顶级组织下的班级
*/
private List<Org> findClsByTopOrgId(long topOrgId) {
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andRootIdEqualTo(topOrgId).andParentIdIsNull();
return orgDAO.selectByExample(orgExample);
}
/**
* 创建非顶级组织
*/
private Org createNonTopOrg(@NonNull String name, @NonNull Long parentId, @NonNull Long rootId, @NonNull Long creatorId) {
//检查顶级组织
confirmIsTopOrg(rootId);
//检查同级同名组织
List<Org> entities = findEntitiesByParentId(parentId, null, BusinessConsts.Org.Status.VALID);
if (!CollectionUtils.isEmpty(entities)) {
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)),
String.format("上级为[%s]的同名组织已存在", parentId));
} }
//创建新组织
Org org = new Org();
org.setName(name);
org.setParentId(parentId);
org.setRootId(rootId);
org.setCreatorId(creatorId);
org.setCreateTime(LocalDateTime.now());
org.setStatus(BusinessConsts.Org.Status.VALID);
orgDAO.insert(org);
return org;
}
private boolean isTopOrg(long orgId) { /**
return isTopOrg(getEntity(orgId)); * 确认是顶级组织
} *
* @param id
private boolean isTopOrg(Org org) { */
return org.getParentId() == null; @Override
} public void confirmIsTopOrg(long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(isTopOrg(id),
private List<Org> findEntitiesByRootId(Long rootId, String orderBy, String status) { String.format("组织[%s]不是顶级组织", id));
OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
} }
OrgExample.Criteria criteria = example.createCriteria().andRootIdEqualTo(rootId);
if (StringUtils.hasText(status)) { /**
criteria.andStatusEqualTo(status); * 确认是非顶级组织
*/
@Override
public void confirmIsNonTopOrg(Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!isTopOrg(id),
String.format("组织[%s]是顶级组织", id));
} }
List<Org> orgs = orgDAO.selectByExample(example);
@Override
public List<Org> queryAllSubOrgs(Long orgId) {
OrgExample example = new OrgExample();
example.createCriteria()
.andParentIdEqualTo(orgId)
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
List<Org> orgs = this.orgDAO.selectByExample(example);
return orgs;
}
@Override
public String getBindQrCode(long orgId, String project) {
return qrCodeManager.getOrgBindCode(orgId, project);
}
@Override
public Org getTopOrgOfUser(long userId) {
Org org = findTopOrgOfUser(userId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(org, String.format("用户[%s]无所属顶级组织", userId));
return org;
}
@Override
public Org findTopOrgOfUser(long userId) {
List<OrgUser> orgUsers = iOrgUserService.findEntitiesByUserId(userId, null);
if (CollectionUtils.isEmpty(orgUsers))
return null;
Long orgId = orgUsers.stream()
.filter(orgUser -> BusinessConsts.OrgRole.Admin.name().equals(orgUser.getRole())) //目前有管理员的一定是顶级组织
.findAny().orElse(orgUsers.get(0)).getOrgId();
Org org = getTopOrgEntity(orgId);
if (BusinessConsts.Org.Status.VALID.equals(org.getStatus())) {
return org;
} else {
return null;
}
}
@Override
public List<OrgVO> listQueryCls(long topOrgId) {
List<Org> clsList = findClsByTopOrgId(topOrgId);
return OrgVO.convert2VOList(clsList);
}
@Override
public OrgVO query(Long id) {
Org entity = findEntity(id);
if (entity == null) {
return null;
}
List<String> projects;
if (isTopOrg(entity)) {
projects = orgProjectService.queryOrgProjectListByOrgId(entity.getId()).stream()
.map(OrgProject::getProjectCode).collect(Collectors.toList());
} else {
projects = null;
}
return new OrgVO(entity, projects);
}
@Override
public OrgVO getTopOrg(long topOrgId) {
Org org = getEntity(topOrgId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(isTopOrg(org),
String.format("[id:%s]的组织不是顶级组织", topOrgId));
List<String> projects = orgProjectService.queryOrgProjectListByOrgId(topOrgId)
.stream().map(OrgProject::getProjectCode).collect(Collectors.toList());
return new OrgVO(org, projects);
}
/**
* 查询该顶级组织下的班级
*/
private List<Org> findClsByTopOrgId(long topOrgId) {
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andRootIdEqualTo(topOrgId).andParentIdIsNull();
return orgDAO.selectByExample(orgExample);
}
/**
* 创建非顶级组织
*/
private Org createNonTopOrg(@NonNull String name, @NonNull Long parentId, @NonNull Long rootId, @NonNull Long creatorId) {
//检查顶级组织
confirmIsTopOrg(rootId);
//检查同级同名组织
List<Org> entities = findEntitiesByParentId(parentId, null, BusinessConsts.Org.Status.VALID);
if (!CollectionUtils.isEmpty(entities)) {
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(entities.stream().noneMatch(org -> org.getName().equals(name)),
String.format("上级为[%s]的同名组织已存在", parentId));
}
//创建新组织
Org org = new Org();
org.setName(name);
org.setParentId(parentId);
org.setRootId(rootId);
org.setCreatorId(creatorId);
org.setCreateTime(LocalDateTime.now());
org.setStatus(BusinessConsts.Org.Status.VALID);
orgDAO.insert(org);
return org;
}
private boolean isTopOrg(long orgId) {
return isTopOrg(getEntity(orgId));
}
private boolean isTopOrg(Org org) {
return org.getParentId() == null;
}
private List<Org> findEntitiesByRootId(Long rootId, String orderBy, String status) {
OrgExample example = new OrgExample();
if (StringUtils.hasText(orderBy)) {
example.setOrderByClause(orderBy);
}
OrgExample.Criteria criteria = example.createCriteria().andRootIdEqualTo(rootId);
if (StringUtils.hasText(status)) {
criteria.andStatusEqualTo(status);
}
List<Org> orgs = orgDAO.selectByExample(example);
// BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs, // BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(orgs,
// String.format("没有顶级组织id为[%s]的组织", rootId)); // String.format("没有顶级组织id为[%s]的组织", rootId));
return orgs; return orgs;
} }
// /** // /**
// * 确认这些项目没有被关联到其它的组织 // * 确认这些项目没有被关联到其它的组织

View File

@ -2,12 +2,10 @@ package club.joylink.rtss.services.paper;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.paper.PaperQuestionDAO; import club.joylink.rtss.dao.paper.PaperQuestionDAO;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.paper.question.PaperQuestion; import club.joylink.rtss.entity.paper.question.PaperQuestion;
import club.joylink.rtss.entity.paper.question.PaperQuestionExample; import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
import club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs; import club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.org.OrgService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
@ -39,69 +37,56 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class PagerQuestionService { public class PagerQuestionService {
@Resource
private PaperQuestionDAO questionDAO;
@Resource /**
private PaperQuestionDAO questionDAO; * 创建对应的查询example
* @param queryVO 查询对象
@Resource * @param orgIdCanNull orgId是否可以为空
private OrgService orgService; * @param queryLabelIsNull 当查询对象labels属性为空时 是否查询 tags is null
* @return
public List<Long> queryAllDefaultOrgPaperIds() { */
Org org = this.orgService.findDefaultOrg(); public void createQueryExample(PaperQuestionExample.Criteria criteria,QuestionQueryVO queryVO, boolean orgIdCanNull,boolean queryLabelIsNull){
if (Objects.isNull(org)) { if(Objects.equals(false,orgIdCanNull)){
return Collections.emptyList(); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getOrgId()),"用户组织信息不能为空");
}
return this.questionDAO.findAllId(org.getId());
}
/**
* 创建对应的查询example
*
* @param queryVO 查询对象
* @param orgIdCanNull orgId是否可以为空
* @param queryLabelIsNull 当查询对象labels属性为空时 是否查询 tags is null
* @return
*/
public void createQueryExample(PaperQuestionExample.Criteria criteria, QuestionQueryVO queryVO, boolean orgIdCanNull, boolean queryLabelIsNull) {
if (Objects.equals(false, orgIdCanNull)) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getOrgId()), "用户组织信息不能为空");
}
if (StringUtils.hasText(queryVO.getTopic())) {
criteria.andQuestionLike(String.format("%%%s%%", queryVO.getTopic()));
}
if (StringUtils.hasText(queryVO.getType())) {
criteria.andTypeEqualTo(queryVO.getType());
}
if (Objects.nonNull(queryVO.getOrgId())) {
criteria.andOrgIdEqualTo(queryVO.getOrgId());
}
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
if (Objects.equals(false, queryLabelIsNull) && StringUtils.hasText(queryVO.getLabels())) {
List<String> tmpLableList = Splitter.on(",").omitEmptyStrings().splitToList(queryVO.getLabels());
if (Objects.equals(false, CollectionUtils.isEmpty(tmpLableList))) {
StringBuilder sqlBuilder = new StringBuilder("(");
for (var i = 0; i < tmpLableList.size(); i++) {
String data = tmpLableList.get(i);
if (i != 0) {
sqlBuilder.append(" and ");
}
sqlBuilder.append(String.format(" find_in_set('%s',tags) > 0 ", data));
} }
sqlBuilder.append(")"); if (StringUtils.hasText(queryVO.getTopic())) {
Class<?> criteriaCls = criteria.getClass(); criteria.andQuestionLike(String.format("%%%s%%", queryVO.getTopic()));
Class<?> generatedCriteriaCls = criteriaCls.getSuperclass(); }
try { if (StringUtils.hasText(queryVO.getType())) {
Method addCriterion = generatedCriteriaCls.getDeclaredMethod("addCriterion", String.class); criteria.andTypeEqualTo(queryVO.getType());
addCriterion.setAccessible(true); }
addCriterion.invoke(criteria, sqlBuilder.toString());
} catch (Exception e) { if(Objects.nonNull(queryVO.getOrgId())){
log.error("拼写查询标签错误 msg:" + e.getMessage(), e); criteria.andOrgIdEqualTo(queryVO.getOrgId());
}
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
if(Objects.equals(false,queryLabelIsNull) && StringUtils.hasText(queryVO.getLabels())){
List<String> tmpLableList = Splitter.on(",").omitEmptyStrings().splitToList(queryVO.getLabels());
if(Objects.equals(false,CollectionUtils.isEmpty(tmpLableList))){
StringBuilder sqlBuilder = new StringBuilder("(");
for(var i = 0 ; i < tmpLableList.size();i++){
String data = tmpLableList.get(i);
if(i != 0){
sqlBuilder.append(" and ");
}
sqlBuilder.append(String.format(" find_in_set('%s',tags) > 0 ",data));
}
sqlBuilder.append(")");
Class<?> criteriaCls = criteria.getClass();
Class<?> generatedCriteriaCls = criteriaCls.getSuperclass();
try{
Method addCriterion = generatedCriteriaCls.getDeclaredMethod("addCriterion", String.class);
addCriterion.setAccessible(true);
addCriterion.invoke(criteria, sqlBuilder.toString());
}catch (Exception e){
log.error("拼写查询标签错误 msg:" + e.getMessage(),e);
}
}
}else {
criteria.andTagsIsNull();
} }
}
} else {
criteria.andTagsIsNull();
}
/* if(!StringUtils.hasText(queryVO.getLabels())){ /* if(!StringUtils.hasText(queryVO.getLabels())){
if(queryLabelIsNull) { if(queryLabelIsNull) {
criteria.andTagsIsNull(); criteria.andTagsIsNull();
@ -130,265 +115,258 @@ public class PagerQuestionService {
} }
}*/ }*/
}
/**
* 查询对应的类型标签对应的数量
*
* @param orgId 用户组织id
* @param type 类型
* @param labels 逗号隔开的标签
* @return
*/
public long queryCount(Long orgId, BusinessConsts.TheoryType type, String labels) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId), "组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(type == BusinessConsts.TheoryType.select
|| type == BusinessConsts.TheoryType.multi
|| type == BusinessConsts.TheoryType.judge, "查询类型只支持单选,多选,选择");
QuestionQueryVO queryVO = new QuestionQueryVO();
queryVO.setOrgId(orgId);
queryVO.setType(type.name());
queryVO.setLabels(labels);
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria, queryVO, false, false);
return this.questionDAO.countByExample(example);
}
/**
* 获取题库分页列表
*
* @param queryVO
* @param companyIdCanNull
* @return
*/
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO, boolean companyIdCanNull) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria, queryVO, companyIdCanNull, false);
Page<PaperQuestionWithBLOBs> page = (Page<PaperQuestionWithBLOBs>) this.questionDAO.selectByExampleWithBLOBs(example);
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(page.getResult());
return PageVO.convert(page, questionVOS);
}
/**
* 获取题型列表
*
* @param queryVO
* @param companyIdCanNull
* @return
*/
public List<PaperQuestionVO> queryQuestions(QuestionQueryVO queryVO, boolean companyIdCanNull) {
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria, queryVO, companyIdCanNull, false);
List<PaperQuestionWithBLOBs> list = this.questionDAO.selectByExampleWithBLOBs(example);
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(list);
return questionVOS;
}
/**
* 获取题型所有数据
*
* @param questionId
* @param doNotCheckDel 是否检测数据状态是否删除 true = 不检测false=检测
* @return
*/
public PaperQuestionVO getQuestion(Long questionId, boolean doNotCheckDel, boolean random) {
PaperQuestionWithBLOBs question = questionDAO.selectByPrimaryKey(questionId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(question), "没有找到对应的数据");
boolean isDel = question.getIsDel() == BusinessConsts.DBLogicDelete.NORMAL.ordinal();
if (doNotCheckDel) {
isDel = true;
} }
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(isDel);
PaperQuestionVO questionVO = new PaperQuestionVO(question);
if (random) {
Collections.shuffle(questionVO.getOptionList());
}
return questionVO;
}
/** /**
* 检测题目是否正确 * 查询对应的类型标签对应的数量
* * @param orgId 用户组织id
* @param questionId 题目id * @param type 类型
* @param answerIds 检测的答案Id * @param labels 逗号隔开的标签
* @return * @return
*/ */
public boolean answer(Long questionId, List<Integer> answerIds) { public long queryCount(Long orgId,BusinessConsts.TheoryType type,String labels){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds), "题目答案不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
PaperQuestionVO vo = this.getQuestion(questionId, true, false); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(type == BusinessConsts.TheoryType.select
List<Integer> newAnswerList = answerIds.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); || type == BusinessConsts.TheoryType.multi
|| type == BusinessConsts.TheoryType.judge ,"查询类型只支持单选,多选,选择");
QuestionQueryVO queryVO = new QuestionQueryVO();
queryVO.setOrgId(orgId);
queryVO.setType(type.name());
queryVO.setLabels(labels);
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria,queryVO,false,false);
return this.questionDAO.countByExample(example);
}
/**
* 获取题库分页列表
* @param queryVO  
* @param companyIdCanNull  
* @return
*/
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria,queryVO,companyIdCanNull,false);
Page<PaperQuestionWithBLOBs> page = (Page<PaperQuestionWithBLOBs>)this.questionDAO.selectByExampleWithBLOBs(example);
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(page.getResult());
return PageVO.convert(page, questionVOS);
}
/**
* 获取题型列表
* @param queryVO  
* @param companyIdCanNull  
* @return
*/
public List<PaperQuestionVO> queryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
this.createQueryExample(criteria,queryVO,companyIdCanNull,false);
List<PaperQuestionWithBLOBs> list = this.questionDAO.selectByExampleWithBLOBs(example);
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(list);
return questionVOS;
}
/**
* 获取题型所有数据
* @param questionId  
* @param doNotCheckDel 是否检测数据状态是否删除 true = 不检测false=检测
* @return
*/
public PaperQuestionVO getQuestion(Long questionId,boolean doNotCheckDel,boolean random) {
PaperQuestionWithBLOBs question = questionDAO.selectByPrimaryKey(questionId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(question),"没有找到对应的数据");
boolean isDel = question.getIsDel() == BusinessConsts.DBLogicDelete.NORMAL.ordinal();
if(doNotCheckDel){
isDel = true;
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(isDel);
PaperQuestionVO questionVO = new PaperQuestionVO(question);
if(random){
Collections.shuffle(questionVO.getOptionList());
}
return questionVO;
}
/**
* 检测题目是否正确
* @param questionId 题目id
* @param answerIds 检测的答案Id
* @return
*/
public boolean answer(Long questionId,List<Integer> answerIds){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空");
PaperQuestionVO vo = this.getQuestion(questionId,true,false);
List<Integer> newAnswerList = answerIds.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
/* if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType()) /* if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType())
|| Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){ || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!");
}else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){ }else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() >= 2 ,"多选题答案最少需要2个"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() >= 2 ,"多选题答案最少需要2个");
}*/ }*/
Collections.sort(newAnswerList); Collections.sort(newAnswerList);
String answerStr = Joiner.on(",").skipNulls().join(newAnswerList); String answerStr = Joiner.on(",").skipNulls().join(newAnswerList);
if (Objects.equals(answerStr, vo.getAnswer())) { if(Objects.equals(answerStr,vo.getAnswer())){
return true; return true;
}
log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] ",questionId, answerStr,vo.getQuestionAnswer());
return false;
} }
log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] ", questionId, answerStr, vo.getQuestionAnswer());
return false;
}
/** /**
* 获取所有公司组织下的标签 * 获取所有公司组织下的标签
*/ *
public Collection<String> findAllLable(Long orgId, String type) { */
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId), "组织id不能为空"); public Collection<String> findAllLable(Long orgId,String type){
PaperQuestionExample example = new PaperQuestionExample(); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织id不能为空");
PaperQuestionExample.Criteria criteria = example.createCriteria(); PaperQuestionExample example = new PaperQuestionExample();
if (Objects.nonNull(type)) { PaperQuestionExample.Criteria criteria = example.createCriteria();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.equals(type, BusinessConsts.TheoryType.select.name()) if(Objects.nonNull(type)){
|| Objects.equals(type, BusinessConsts.TheoryType.multi.name()) BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.equals(type,BusinessConsts.TheoryType.select.name())
|| Objects.equals(type, BusinessConsts.TheoryType.judge.name()), "查询类型只支持单选,多选,选择"); ||Objects.equals(type,BusinessConsts.TheoryType.multi.name())
criteria.andTypeEqualTo(type); ||Objects.equals(type,BusinessConsts.TheoryType.judge.name()),"查询类型只支持单选,多选,选择");
criteria.andTypeEqualTo(type);
}
criteria.andOrgIdEqualTo(orgId);
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
List<PaperQuestion> lableList = this.questionDAO.selectByExample(example);
if(CollectionUtils.isEmpty(lableList)){
return Collections.emptyList();
}
return lableList.stream().map(PaperQuestion::getTags).filter(StringUtils::hasText).flatMap(d-> Splitter.on(",").omitEmptyStrings()
.trimResults().splitToStream(d)).collect(Collectors.toSet());
} }
criteria.andOrgIdEqualTo(orgId);
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
List<PaperQuestion> lableList = this.questionDAO.selectByExample(example);
if (CollectionUtils.isEmpty(lableList)) {
return Collections.emptyList();
}
return lableList.stream().map(PaperQuestion::getTags).filter(StringUtils::hasText).flatMap(d -> Splitter.on(",").omitEmptyStrings()
.trimResults().splitToStream(d)).collect(Collectors.toSet());
}
/** /**
* 根据公司id和标签或类型查询 * 根据公司id和标签或类型查询
* * @param companyId  
* @param companyId * @param queryVO  
* @param queryVO * @return
* @return */
*/ public List<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO) {
public List<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO) {
/*boolean isDefault = Project.isDefault(projectCode); /*boolean isDefault = Project.isDefault(projectCode);
List<Long> idList = null; List<Long> idList = null;
if(Objects.equals(false,isDefault)){ if(Objects.equals(false,isDefault)){
idList = this.queryFromProjectCode(projectCode); idList = this.queryFromProjectCode(projectCode);
}*/ }*/
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId), "组织id不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(queryVO.allNotNullOrEmpty(), "查询内容不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(queryVO.allNotNullOrEmpty(),"查询内容不能为空");
int isDel = BusinessConsts.DBLogicDelete.NORMAL.ordinal(); int isDel = BusinessConsts.DBLogicDelete.NORMAL.ordinal();
List<PaperQuestionWithBLOBs> list = this.questionDAO.findFromAndRaceLable(companyId, isDel, queryVO.getLables(), queryVO.getTypes()); List<PaperQuestionWithBLOBs> list = this.questionDAO.findFromAndRaceLable(companyId,isDel,queryVO.getLables(),queryVO.getTypes());
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(list); List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(list);
return questionVOS; return questionVOS;
}
/**
* 添加修改
*
* @param questionVO
* @param accountVO
*/
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(questionVO.getOrgId()), "组织id不能为空");
this.checkQuestionType(questionVO, "题库目前只支持单选,多选和判断");
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO, "单选或判断题正确答案有且只有一个!");
} else if (questionVO.isMulti()) {
this.checkQuestionTypeForMulti(questionVO, "多选题正确答案必须是2个以上");
}
if (StringUtils.hasText(questionVO.getTags())) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Splitter.on(",").splitToList(questionVO.getTags()).size() <= 1, "分类最多只能有1个");
}
PaperQuestionWithBLOBs question = questionVO.convert2DB();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(question.getQuestion().length() < 512, "问题字符长度不用超过512");
int wordCounts = questionVO.getOptionList().stream().map(d -> d.getContent().length()).reduce(0, Integer::sum);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(wordCounts < 512, "问题选项长度不用超过512");
question.setCreateUserId(accountVO.getId());
question.setCreateTime(LocalDateTime.now());
if (Objects.nonNull(questionVO.getId())) {
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(questionVO.getId());
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
Long exist = this.questionDAO.countByExample(example);
if (exist <= 0) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(true,
"未找到要修改的数据!");
}
questionDAO.updateByPrimaryKeyWithBLOBs(question);
} else {
questionDAO.insert(question);
} }
}
private void checkQuestionType(PaperQuestionVO vo, String errStr) { /**
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue((Objects.equals(BusinessConsts.TheoryType.select.name(), vo.getType()) * 添加修改
|| Objects.equals(BusinessConsts.TheoryType.judge.name(), vo.getType()) * @param questionVO  
|| Objects.equals(BusinessConsts.TheoryType.multi.name(), vo.getType())), errStr); * @param accountVO  
} */
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(questionVO.getOrgId()),"组织id不能为空");
this.checkQuestionType(questionVO,"题库目前只支持单选,多选和判断");
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!");
}else if(questionVO.isMulti()){
this.checkQuestionTypeForMulti(questionVO,"多选题正确答案必须是2个以上");
}
if(StringUtils.hasText(questionVO.getTags())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Splitter.on(",").splitToList(questionVO.getTags()).size() <= 1,"分类最多只能有1个");
}
PaperQuestionWithBLOBs question = questionVO.convert2DB();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(question.getQuestion().length() <512,"问题字符长度不用超过512");
int wordCounts = questionVO.getOptionList().stream().map(d->d.getContent().length()).reduce(0,Integer::sum);
private void checkQuestionTypeForSelectAndJudge(PaperQuestionVO vo, String errStr) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(wordCounts <512,"问题选项长度不用超过512");
long answerCount = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count(); question.setCreateUserId(accountVO.getId());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount == 1, errStr); question.setCreateTime(LocalDateTime.now());
} if(Objects.nonNull(questionVO.getId())){
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(questionVO.getId());
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
Long exist = this.questionDAO.countByExample(example);
if(exist <= 0){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(true,
"未找到要修改的数据!");
}
questionDAO.updateByPrimaryKeyWithBLOBs(question);
}else{
questionDAO.insert(question);
}
private void checkQuestionTypeForMulti(PaperQuestionVO vo, String errStr) { }
long answerCount = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount >= 2, errStr);
}
public void clearAllForOrgId(LoginUserInfoVO userInfoVO) { private void checkQuestionType(PaperQuestionVO vo ,String errStr){
PaperQuestionExample example = new PaperQuestionExample(); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue((Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType())
PaperQuestionExample.Criteria criteria = example.createCriteria(); || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())
criteria.andOrgIdEqualTo(userInfoVO.getTopOrgId()); || Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())),errStr);
PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs(); }
pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal());
questionDAO.updateByExampleSelective(pq, example);
}
@Transactional private void checkQuestionTypeForSelectAndJudge(PaperQuestionVO vo,String errStr){
public void importProjectQuestion(List<PaperQuestionVO> questions, Long companyId, AccountVO accountVO) { long answerCount = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId), "组织id不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount == 1,errStr);
questions.forEach(questionVO -> { }
String topic = questionVO.getTopic();
this.checkQuestionType(questionVO, String.format("题库目前只支持单选,多选和判断,题序[%s]", questionVO.getId()));
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO, String.format("题序[%s]:单选或判断题[%s]正确答案应当有且只有一个!", questionVO.getId(), topic));
} else if (questionVO.isMulti()) {
this.checkQuestionTypeForMulti(questionVO, String.format("题序[%s]:多选题[%s]正确答案应当至少有两个以上!", questionVO.getId(), topic));
}
if (StringUtils.hasText(questionVO.getTags())) {
List<String> tagList = Splitter.on(",").splitToList(questionVO.getTags());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(tagList.size() <= 1, "分类最多只能为1个");
}
});
questions.forEach(questionVO -> { private void checkQuestionTypeForMulti(PaperQuestionVO vo,String errStr){
PaperQuestionWithBLOBs question = questionVO.convert2DB(); long answerCount = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count();
question.setOrgId(companyId); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount >= 2,errStr);
question.setCreateUserId(accountVO.getId()); }
question.setCreateTime(LocalDateTime.now());
questionDAO.insert(question); public void clearAllForOrgId(LoginUserInfoVO userInfoVO){
}); PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
criteria.andOrgIdEqualTo(userInfoVO.getTopOrgId());
PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs();
pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal());
questionDAO.updateByExampleSelective(pq,example);
}
@Transactional
public void importProjectQuestion(List<PaperQuestionVO> questions, Long companyId, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(companyId),"组织id不能为空");
questions.forEach(questionVO -> {
String topic = questionVO.getTopic();
this.checkQuestionType(questionVO,String.format("题库目前只支持单选,多选和判断,题序[%s]",questionVO.getId()));
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO,String.format("题序[%s]:单选或判断题[%s]正确答案应当有且只有一个!", questionVO.getId(),topic));
}else if(questionVO.isMulti()){
this.checkQuestionTypeForMulti(questionVO,String.format("题序[%s]:多选题[%s]正确答案应当至少有两个以上!", questionVO.getId(),topic));
}
if(StringUtils.hasText(questionVO.getTags())){
List<String> tagList = Splitter.on(",").splitToList(questionVO.getTags());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(tagList.size() <= 1 ,"分类最多只能为1个");
}
});
questions.forEach(questionVO -> {
PaperQuestionWithBLOBs question = questionVO.convert2DB();
question.setOrgId(companyId);
question.setCreateUserId(accountVO.getId());
question.setCreateTime(LocalDateTime.now());
questionDAO.insert(question);
});
} }
/** /**
* 删除 逻辑删除 * 删除 逻辑删除
* * @param questionId 文本id
* @param questionId 文本id */
*/ public void deleteQuestion(List<Long> questionId) {
public void deleteQuestion(List<Long> questionId) { PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample example = new PaperQuestionExample(); example.createCriteria().andIdIn(questionId);
example.createCriteria().andIdIn(questionId); PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs();
PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs(); pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal());
pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal()); questionDAO.updateByExampleSelective(pq,example);
questionDAO.updateByExampleSelective(pq, example); }
}
} }

View File

@ -15,7 +15,6 @@ import club.joylink.rtss.exception.PaperExceptionAssert;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.paper.*; import club.joylink.rtss.vo.paper.*;
import club.joylink.rtss.vo.paper.PaperCompositionWithRuleVo.CreatorBasic;
import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor; import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor;
import club.joylink.rtss.vo.paper.convertor.PaperRuleConvertor; import club.joylink.rtss.vo.paper.convertor.PaperRuleConvertor;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
@ -38,170 +37,139 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class PaperCompositionService { public class PaperCompositionService {
@Autowired
private PaperCompositionDAO compositionDAO;
@Autowired
private PaperRuleDAO ruleDAO;
@Autowired
private SysAccountDAO sysAccountDAO;
@Autowired /**
private PaperCompositionDAO compositionDAO; * 创建试卷蓝图包括规则定义
@Autowired */
private PaperRuleDAO ruleDAO; @Transactional(rollbackFor = Exception.class)
@Autowired public CreatePaperCompositionRspVo createPaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) {
private SysAccountDAO sysAccountDAO; //根据项目和名称来查如果存在则结束
PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()), "请选择对应的线路");
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
PaperExceptionAssert.PcNotExisted.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName());
Optional<PaperCompositionWithRuleVo.PaperRuleVo> optionalRule = req.getRuleList().stream().filter(d->d.getSubtype() == PaperQType.SubType.Single
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(d.getSubTypeParam().getClient()))).findAny();
/** PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(), "试卷规则-单操缺少客户端的定义");
* 创建试卷蓝图包括规则定义 PaperComposition newPc = PaperCompositionConvertor.convertToBean(req);
*/
@Transactional(rollbackFor = Exception.class)
public CreatePaperCompositionRspVo createPaperCompositionWithRule(PaperCompositionWithRuleVo req,
AccountVO user) {
//根据项目和名称来查如果存在则结束
PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()),
"请选择对应的线路");
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(),
req.getName());
PaperExceptionAssert.PcNotExisted.assertTrue(CollectionUtils.isEmpty(pcList),
"试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName());
Optional<PaperCompositionWithRuleVo.PaperRuleVo> optionalRule = req.getRuleList().stream()
.filter(d -> d.getSubtype() == PaperQType.SubType.Single
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(
d.getSubTypeParam().getClient()))).findAny();
PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(), newPc.setCreateTime(LocalDateTime.now());
"试卷规则-单操缺少客户端的定义"); newPc.setUpdateTime(LocalDateTime.now());
PaperComposition newPc = PaperCompositionConvertor.convertToBean(req); newPc.setCreatorId(user.getId());
newPc.setUpdateId(user.getId());
newPc.setState(PaperCompositionState.Editing.getValue());
compositionDAO.insertSelective(newPc);
newPc.setCreateTime(LocalDateTime.now()); if (!CollectionUtils.isEmpty(req.getRuleList())) {
newPc.setUpdateTime(LocalDateTime.now()); final Long pcId = newPc.getId();
newPc.setCreatorId(user.getId()); this.createPaperCompositionRule(pcId, req.getRuleList());
newPc.setUpdateId(user.getId()); }
newPc.setState(PaperCompositionState.Editing.getValue()); //
compositionDAO.insertSelective(newPc); CreatePaperCompositionRspVo rsp = new CreatePaperCompositionRspVo();
rsp.setId(newPc.getId());
if (!CollectionUtils.isEmpty(req.getRuleList())) { rsp.setName(newPc.getName());
final Long pcId = newPc.getId(); rsp.setProfile(newPc.getProfile());
this.createPaperCompositionRule(pcId, req.getRuleList()); rsp.setOrgId(newPc.getOrgId());
return rsp;
} }
//
CreatePaperCompositionRspVo rsp = new CreatePaperCompositionRspVo();
rsp.setId(newPc.getId());
rsp.setName(newPc.getName());
rsp.setProfile(newPc.getProfile());
rsp.setOrgId(newPc.getOrgId());
return rsp;
}
private String ruleMapKey(PaperCompositionWithRuleVo.PaperRuleVo vo) { private String ruleMapKey(PaperCompositionWithRuleVo.PaperRuleVo vo){
String key = String.format("%s-%s-%s", vo.getType(), vo.getSubtype(), String key = String.format("%s-%s-%s",vo.getType(),vo.getSubtype(), CollectionUtils.isEmpty(vo.getTags())? "" : Joiner.on(",").join(vo.getTags()));
CollectionUtils.isEmpty(vo.getTags()) ? "" : Joiner.on(",").join(vo.getTags())); return key;
return key;
}
/**
* 试卷蓝图添加规则
*/
private void createPaperCompositionRule(Long pcId,
List<PaperCompositionWithRuleVo.PaperRuleVo> reqList) {
Map<String, List<PaperCompositionWithRuleVo.PaperRuleVo>> tmpList = reqList.stream()
.collect(Collectors.groupingBy(this::ruleMapKey));
for (PaperCompositionWithRuleVo.PaperRuleVo req : reqList) {
req.setPcId(pcId);
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
String key = this.ruleMapKey(req);
List<PaperCompositionWithRuleVo.PaperRuleVo> voList = tmpList.get(key);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
!CollectionUtils.isEmpty(voList) && voList.size() <= 1,
String.format("试题规则类型[%s],规则类型[%s] 规则只能有一个",
PaperQType.GroupType.getTypeName(req.getType()),
PaperQType.SubType.getItemName(req.getSubtype())));
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
!CollectionUtils.isEmpty(req.getTags()) && req.getTags().size() <= 1,
String.format("试题规则类型[%s],规则类型[%s],分类%s最多只能有一个",
PaperQType.GroupType.getTypeName(req.getType()),
PaperQType.SubType.getItemName(req.getSubtype()), req.getTags()));
PaperRule rule = PaperRuleConvertor.convert(req);
ruleDAO.insertSelective(rule);
} }
}
/** /**
* 更新试卷蓝图包括规则定义 * 试卷蓝图添加规则
*/ */
@Transactional(rollbackFor = Exception.class) private void createPaperCompositionRule(Long pcId, List<PaperCompositionWithRuleVo.PaperRuleVo> reqList) {
public void updatePaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) { Map<String,List<PaperCompositionWithRuleVo.PaperRuleVo>> tmpList = reqList.stream().collect(Collectors.groupingBy(this::ruleMapKey));
PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()),
"请选择对应的线路");
Optional<PaperCompositionWithRuleVo.PaperRuleVo> optionalRule = req.getRuleList().stream()
.filter(d -> d.getSubtype() == PaperQType.SubType.Single
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(
d.getSubTypeParam().getClient()))).findAny();
PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(),
"试卷规则-单操缺少客户端的定义");
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId()); for (PaperCompositionWithRuleVo.PaperRuleVo req : reqList) {
assertPaperCompositionCanModify(curPc); req.setPcId(pcId);
// PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), String key = this.ruleMapKey(req);
req.getName()); List<PaperCompositionWithRuleVo.PaperRuleVo> voList = tmpList.get(key);
if (!CollectionUtils.isEmpty(pcList)) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(voList) && voList.size() <= 1 ,String.format("试题规则类型[%s],规则类型[%s] 规则只能有一个", PaperQType.GroupType.getTypeName(req.getType()), PaperQType.SubType.getItemName(req.getSubtype())));
boolean exist = pcList.stream().anyMatch(c -> c.getId().compareTo(curPc.getId()) != 0); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(req.getTags()) && req.getTags().size() <= 1 ,String.format("试题规则类型[%s],规则类型[%s],分类%s最多只能有一个", PaperQType.GroupType.getTypeName(req.getType()), PaperQType.SubType.getItemName(req.getSubtype()),req.getTags()));
PaperExceptionAssert.PcExisted.assertNotTrue(exist, PaperRule rule = PaperRuleConvertor.convert(req);
"试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName()); ruleDAO.insertSelective(rule);
}
} }
PaperComposition newPc = PaperCompositionConvertor.convertToBean(req);
newPc.setId(curPc.getId());
newPc.setUpdateTime(LocalDateTime.now());
curPc.setUpdateId(user.getId());
compositionDAO.updateByPrimaryKeySelective(newPc);
// 更新规则
this.updateCompositionRule(req.getRuleList(), req.getId());
}
private void updateCompositionRule(List<PaperCompositionWithRuleVo.PaperRuleVo> updateRuleList, /**
Long pcId) { * 更新试卷蓝图包括规则定义
PaperRuleExample ruleExample = new PaperRuleExample(); */
ruleExample.createCriteria().andPcIdEqualTo(pcId); @Transactional(rollbackFor = Exception.class)
this.ruleDAO.deleteByExample(ruleExample); public void updatePaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) {
this.createPaperCompositionRule(pcId, updateRuleList); PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()), "请选择对应的线路");
} Optional<PaperCompositionWithRuleVo.PaperRuleVo> optionalRule = req.getRuleList().stream().filter(d->d.getSubtype() == PaperQType.SubType.Single
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(d.getSubTypeParam().getClient()))).findAny();
PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(), "试卷规则-单操缺少客户端的定义");
/** PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId());
* 将编辑好的试卷蓝图封存 assertPaperCompositionCanModify(curPc);
*/ //
@Transactional(rollbackFor = Exception.class) List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
public void lockPaperComposition(Long pcId, AccountVO user) { if (!CollectionUtils.isEmpty(pcList)) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); boolean exist = pcList.stream().anyMatch(c ->c.getId().compareTo(curPc.getId()) != 0);
PaperExceptionAssert.PcCanModify.assertTrue( PaperExceptionAssert.PcExisted.assertNotTrue(exist, "试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName());
null != curPc && PaperCompositionState.Editing.equals( }
PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非编辑中"); PaperComposition newPc = PaperCompositionConvertor.convertToBean(req);
PaperExceptionAssert.PcScore.assertTrue(this.checkRulesScoreEqualFull(curPc.getId()), newPc.setId(curPc.getId());
"规则总分值不等于试卷总分值"); newPc.setUpdateTime(LocalDateTime.now());
// curPc.setUpdateId(user.getId());
PaperComposition nPc = new PaperComposition(); compositionDAO.updateByPrimaryKeySelective(newPc);
nPc.setId(curPc.getId()); // 更新规则
nPc.setState(PaperCompositionState.Locked.getValue()); this.updateCompositionRule(req.getRuleList(), req.getId());
compositionDAO.updateByPrimaryKeySelective(nPc); }
// 封存试卷时校验总分值与规则总分值是否相等
}
/** private void updateCompositionRule(List<PaperCompositionWithRuleVo.PaperRuleVo> updateRuleList, Long pcId) {
* 将封存的试卷蓝图设置失效 PaperRuleExample ruleExample = new PaperRuleExample();
*/ ruleExample.createCriteria().andPcIdEqualTo(pcId);
@Transactional(rollbackFor = Exception.class) this.ruleDAO.deleteByExample(ruleExample);
public void unlockPaperComposition(Long pcId, AccountVO user) { this.createPaperCompositionRule(pcId,updateRuleList);
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); }
PaperExceptionAssert.PcCanModify.assertTrue(
null != curPc && PaperCompositionState.Locked.equals(
PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非封存中");
//
PaperComposition nPc = new PaperComposition();
nPc.setId(curPc.getId());
nPc.setState(PaperCompositionState.Invalid.getValue());
nPc.setUpdateId(user.getId());
compositionDAO.updateByPrimaryKeySelective(nPc);
}
/** /**
* 标记已封存的试卷已使用 * 将编辑好的试卷蓝图封存
*/ */
@Transactional(rollbackFor = Exception.class)
public void lockPaperComposition(Long pcId, AccountVO user) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非编辑中");
PaperExceptionAssert.PcScore.assertTrue(this.checkRulesScoreEqualFull(curPc.getId()), "规则总分值不等于试卷总分值");
//
PaperComposition nPc = new PaperComposition();
nPc.setId(curPc.getId());
nPc.setState(PaperCompositionState.Locked.getValue());
compositionDAO.updateByPrimaryKeySelective(nPc);
// 封存试卷时校验总分值与规则总分值是否相等
}
/**
* 将封存的试卷蓝图设置失效
*/
@Transactional(rollbackFor = Exception.class)
public void unlockPaperComposition(Long pcId, AccountVO user) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Locked.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非封存中");
//
PaperComposition nPc = new PaperComposition();
nPc.setId(curPc.getId());
nPc.setState(PaperCompositionState.Invalid.getValue());
nPc.setUpdateId(user.getId());
compositionDAO.updateByPrimaryKeySelective(nPc);
}
/**
* 标记已封存的试卷已使用
*/
/* @Transactional(rollbackFor = Exception.class) /* @Transactional(rollbackFor = Exception.class)
public void usePaperComposition(Long pcId) { public void usePaperComposition(Long pcId) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
@ -213,299 +181,289 @@ public class PaperCompositionService {
} }
}*/ }*/
/** /**
* 删除试卷蓝图(只能删除处于编辑状态的) * 删除试卷蓝图(只能删除处于编辑状态的)
* *
* @param pcId 试卷蓝图id * @param pcId 试卷蓝图id
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deletePaperComposition(Long pcId, AccountVO user) { public void deletePaperComposition(Long pcId, AccountVO user) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
if (null != curPc) { if (null != curPc) {
assertPaperCompositionCanModify(curPc); assertPaperCompositionCanModify(curPc);
//先删除试卷定义中的规则 //先删除试卷定义中的规则
PaperRuleExample ruleExample = new PaperRuleExample(); PaperRuleExample ruleExample = new PaperRuleExample();
ruleExample.createCriteria().andPcIdEqualTo(pcId); ruleExample.createCriteria().andPcIdEqualTo(pcId);
ruleDAO.deleteByExample(ruleExample); ruleDAO.deleteByExample(ruleExample);
//删除试卷定义 //删除试卷定义
compositionDAO.deleteByPrimaryKey(pcId); compositionDAO.deleteByPrimaryKey(pcId);
}
} }
}
/** /**
* 断言试卷蓝图可以修改 * 断言试卷蓝图可以修改
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
public void assertPaperCompositionCanModify(Long pcId) { public void assertPaperCompositionCanModify(Long pcId) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
this.assertPaperCompositionCanModify(curPc); this.assertPaperCompositionCanModify(curPc);
} }
/** /**
* 断言试卷蓝图可以修改 * 断言试卷蓝图可以修改
*/ */
public void assertPaperCompositionCanModify(PaperComposition curPc) { public void assertPaperCompositionCanModify(PaperComposition curPc) {
PaperExceptionAssert.PcCanModify.assertTrue( PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或状态非编辑中不能修改pcId = " + curPc.getId());
null != curPc && PaperCompositionState.Editing.equals( }
PaperCompositionState.getItem(curPc.getState())),
"试卷定义不存在或状态非编辑中不能修改pcId = " + curPc.getId());
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public PageVO<PaperCompositionWithRuleVo> findPaperCompositionByPageForAccount( public PageVO<PaperCompositionWithRuleVo> findPaperCompositionByPageForAccount(FindPaperCompositionByAccountReqVo req) {
FindPaperCompositionByAccountReqVo req) { PaperExceptionAssert.PpValid.assertTrue(null != req.getAccount() || null != req.getUserId(), "账号和用户id不能同时为空");
PaperExceptionAssert.PpValid.assertTrue(null != req.getAccount() || null != req.getUserId(), Long userId = req.getUserId();
"账号和用户id不能同时为空"); if (null == userId) {
Long userId = req.getUserId(); SysAccountExample accountExample = new SysAccountExample();
if (null == userId) { //
SysAccountExample accountExample = new SysAccountExample(); SysAccountExample.Criteria mobileC = accountExample.or();
// mobileC.andMobileEqualTo(req.getAccount());
SysAccountExample.Criteria mobileC = accountExample.or(); if (null != req.getPwd()) {
mobileC.andMobileEqualTo(req.getAccount()); mobileC.andPasswordEqualTo(req.getPwd());
if (null != req.getPwd()) { }
mobileC.andPasswordEqualTo(req.getPwd()); //
} SysAccountExample.Criteria emailC = accountExample.or();
// emailC.andEmailEqualTo(req.getAccount());
SysAccountExample.Criteria emailC = accountExample.or(); if (null != req.getPwd()) {
emailC.andEmailEqualTo(req.getAccount()); emailC.andPasswordEqualTo(req.getPwd());
if (null != req.getPwd()) { }
emailC.andPasswordEqualTo(req.getPwd()); //
} SysAccountExample.Criteria accountC = accountExample.or();
// accountC.andAccountEqualTo(req.getAccount());
SysAccountExample.Criteria accountC = accountExample.or(); if (null != req.getPwd()) {
accountC.andAccountEqualTo(req.getAccount()); accountC.andPasswordEqualTo(req.getPwd());
if (null != req.getPwd()) { }
accountC.andPasswordEqualTo(req.getPwd()); //
} List<SysAccount> users = this.sysAccountDAO.selectByExample(accountExample);
// PaperExceptionAssert.PdValid.assertTrue(null != users && users.size() == 1, "用户不存在或根据账户信息匹配了多个");
List<SysAccount> users = this.sysAccountDAO.selectByExample(accountExample); userId = users.get(0).getId();
PaperExceptionAssert.PdValid.assertTrue(null != users && users.size() == 1, }
"用户不存在或根据账户信息匹配了多个"); //
userId = users.get(0).getId(); PaperCompositionExample pcEx = new PaperCompositionExample();
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
pcExCriteria.andCreatorIdEqualTo(userId);
List<PaperCompositionState> findStates = req.stateList();
pcExCriteria.andStateIn(findStates.stream().map(pcState -> {
return pcState.getValue();
}).collect(Collectors.toList()));
//
//1--创建时间 2--更新时间 3--名称默认值为1
String orderBy = "create_time";
switch (req.getOrderBy()) {
case 1:
orderBy = "create_time";
break;
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
}
orderBy+=(req.getDesc()?" desc":"");
//
PageHelper.clearPage();
PageHelper.startPage(req.getPageNum(),req.getPageSize(),orderBy);
Page<PaperComposition> sqlPage = (Page<PaperComposition>) compositionDAO.selectByExample(pcEx);
//
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>();
if(!CollectionUtils.isEmpty(sqlPage.getResult())){
sqlPage.getResult().forEach(pc->{
List<PaperRule> prList = this.findRuleByPcId(pc.getId());
rtList.add(PaperCompositionConvertor.convert(pc, prList));
});
}
//
PageVO<PaperCompositionWithRuleVo> page = PageVO.convert(sqlPage,rtList);
//
if (!CollectionUtils.isEmpty(page.getList())) {
page.getList().forEach(pc -> {
pc.setCreatorInfo(this.findCreatorInfo(pc.getCreatorId()));
});
}
//
return page;
} }
//
PaperCompositionExample pcEx = new PaperCompositionExample();
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
pcExCriteria.andCreatorIdEqualTo(userId);
List<PaperCompositionState> findStates = req.stateList();
pcExCriteria.andStateIn(findStates.stream().map(pcState -> {
return pcState.getValue();
}).collect(Collectors.toList()));
//
//1--创建时间 2--更新时间 3--名称默认值为1
String orderBy = "create_time";
switch (req.getOrderBy()) {
case 1:
orderBy = "create_time";
break;
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
}
orderBy += (req.getDesc() ? " desc" : "");
//
PageHelper.clearPage();
PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy);
Page<PaperComposition> sqlPage = (Page<PaperComposition>) compositionDAO.selectByExample(pcEx);
//
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>();
if (!CollectionUtils.isEmpty(sqlPage.getResult())) {
sqlPage.getResult().forEach(pc -> {
List<PaperRule> prList = this.findRuleByPcId(pc.getId());
rtList.add(PaperCompositionConvertor.convert(pc, prList));
});
}
//
PageVO<PaperCompositionWithRuleVo> page = PageVO.convert(sqlPage, rtList);
//
if (!CollectionUtils.isEmpty(page.getList())) {
page.getList().forEach(pc -> {
pc.setCreatorInfo(this.findCreatorInfo(pc.getCreatorId()));
});
}
//
return page;
}
/** /**
* 返回蓝图的列表基本信息 * 返回蓝图的列表基本信息
*/ */
public List<PaperCompositionWithRuleVo> findPaperCompositionList( public List<PaperCompositionWithRuleVo> findPaperCompositionList(FindPaperCompositionPageReqVo req){
FindPaperCompositionPageReqVo req) { PaperCompositionExample pcEx = this.queryExample(req);
PaperCompositionExample pcEx = this.queryExample(req); pcEx.setOrderByClause(" create_time desc ");
pcEx.setOrderByClause(" create_time desc "); List<PaperComposition> sqlPage = compositionDAO.selectByExample(pcEx);
List<PaperComposition> sqlPage = compositionDAO.selectByExample(pcEx); //
// final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>();
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>(); for (PaperComposition pc : sqlPage) {
for (PaperComposition pc : sqlPage) { rtList.add(PaperCompositionConvertor.convert(pc,null));
rtList.add(PaperCompositionConvertor.convert(pc, null)); }
return rtList;
} }
return rtList;
}
private PaperCompositionExample queryExample(FindPaperCompositionPageReqVo req) { private PaperCompositionExample queryExample(FindPaperCompositionPageReqVo req){
PaperCompositionExample pcEx = new PaperCompositionExample(); PaperCompositionExample pcEx = new PaperCompositionExample();
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria(); PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
if (Objects.nonNull(req.getOrgId())) { if (Objects.nonNull(req.getOrgId())) {
pcExCriteria.andOrgIdEqualTo(req.getOrgId()); pcExCriteria.andOrgIdEqualTo(req.getOrgId());
}
if(Objects.nonNull(req.getMapId())){
pcExCriteria.andMapIdEqualTo(req.getMapId());
}
if (StringUtils.hasText(req.getName())) {
if (req.getNameLike()) {
pcExCriteria.andNameLike(String.format("%%%s%%", req.getName()));
} else {
pcExCriteria.andNameEqualTo(req.getName());
}
}
if (StringUtils.hasText(req.getProfile())) {
if (req.getProfileLike()) {
pcExCriteria.andProfileLike(String.format("%%%s%%", req.getProfile()));
} else {
pcExCriteria.andProfileEqualTo(req.getProfile());
}
}
List<PaperCompositionState> findStates = req.stateList();
pcExCriteria.andStateIn(findStates.stream().map(pcState -> {
return pcState.getValue();
}).collect(Collectors.toList()));
return pcEx;
} }
if (Objects.nonNull(req.getMapId())) { /**
pcExCriteria.andMapIdEqualTo(req.getMapId()); * 分页查找试卷蓝图
*/
@Transactional(readOnly = true)
public PageVO<PaperCompositionWithRuleVo> findPaperCompositionByPage(FindPaperCompositionPageReqVo req) {
PaperCompositionExample pcEx = this.queryExample(req);
//
//1--创建时间 2--更新时间 3--名称默认值为1
String orderBy = "create_time";
switch (req.getOrderBy()) {
case 1:
orderBy = "create_time";
break;
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
}
orderBy+=(req.getDesc()?" desc":"");
//
PageHelper.clearPage();
PageHelper.startPage(req.getPageNum(),req.getPageSize(),orderBy);
Page<PaperComposition> sqlPage = (Page<PaperComposition>) compositionDAO.selectByExample(pcEx);
//
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>();
if(!CollectionUtils.isEmpty(sqlPage.getResult())){
for (PaperComposition pc : sqlPage.getResult()) {
List<PaperRule> prList = this.findRuleByPcId(pc.getId());
rtList.add(PaperCompositionConvertor.convert(pc, prList));
}
}
//
PageVO<PaperCompositionWithRuleVo> page = PageVO.convert(sqlPage,rtList);
//
if (!CollectionUtils.isEmpty(page.getList())) {
page.getList().forEach(pc -> {
pc.setCreatorInfo(this.findCreatorInfo(pc.getCreatorId()));
});
}
//
return page;
} }
if (StringUtils.hasText(req.getName())) {
if (req.getNameLike()) {
pcExCriteria.andNameLike(String.format("%%%s%%", req.getName()));
} else {
pcExCriteria.andNameEqualTo(req.getName());
}
}
if (StringUtils.hasText(req.getProfile())) {
if (req.getProfileLike()) {
pcExCriteria.andProfileLike(String.format("%%%s%%", req.getProfile()));
} else {
pcExCriteria.andProfileEqualTo(req.getProfile());
}
}
if (req.getCreatorId() != null) {
pcExCriteria.andCreatorIdEqualTo(req.getCreatorId());
}
List<PaperCompositionState> findStates = req.stateList();
pcExCriteria.andStateIn(findStates.stream().map(pcState -> {
return pcState.getValue();
}).collect(Collectors.toList()));
return pcEx;
}
/** private PaperCompositionWithRuleVo.CreatorBasic findCreatorInfo(Long creatorId) {
* 分页查找试卷蓝图 SysAccount sa = this.sysAccountDAO.selectByPrimaryKey(creatorId);
*/ if (null != sa) {
@Transactional(readOnly = true) PaperCompositionWithRuleVo.CreatorBasic rt = new PaperCompositionWithRuleVo.CreatorBasic();
public PageVO<PaperCompositionWithRuleVo> findPaperCompositionByPage( rt.setId(sa.getId());
FindPaperCompositionPageReqVo req) { rt.setName(sa.getName());
PaperCompositionExample pcEx = this.queryExample(req); rt.setAccount(sa.getAccount());
// rt.setMobile(sa.getMobile());
//1--创建时间 2--更新时间 3--名称默认值为1 rt.setEmail(sa.getEmail());
String orderBy = "create_time"; return rt;
switch (req.getOrderBy()) { }
case 1: return null;
orderBy = "create_time";
break;
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
} }
orderBy += (req.getDesc() ? " desc" : "");
// /**
PageHelper.clearPage(); * 获取试卷完整的蓝图包括规则
PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy); *
Page<PaperComposition> sqlPage = (Page<PaperComposition>) compositionDAO.selectByExample(pcEx); * @param pcId 试卷蓝图id
// */
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>(); @Transactional(readOnly = true)
if (!CollectionUtils.isEmpty(sqlPage.getResult())) { public PaperCompositionWithRuleVo findPaperComposition(Long pcId, AccountVO user) {
for (PaperComposition pc : sqlPage.getResult()) { PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
List<PaperRule> prList = this.findRuleByPcId(pc.getId()); PaperExceptionAssert.PcExisted.assertTrue(null != curPc, "试卷定义不存在id=" + pcId);
rtList.add(PaperCompositionConvertor.convert(pc, prList)); List<PaperRule> paperRuleList = this.findRuleByPcId(pcId);
} //
PaperCompositionWithRuleVo rt = PaperCompositionConvertor.convert(curPc, paperRuleList);
rt.setCreatorInfo(this.findCreatorInfo(rt.getCreatorId()));
return rt;
} }
//
PageVO<PaperCompositionWithRuleVo> page = PageVO.convert(sqlPage, rtList); /**
// * 根据试卷蓝图的项目和名称查找项目
if (!CollectionUtils.isEmpty(page.getList())) { */
page.getList().forEach(pc -> { @Transactional(readOnly = true)
pc.setCreatorInfo(this.findCreatorInfo(pc.getCreatorId())); public List<PaperComposition> findCompositionByCompanyIdAndName(Long orgId, String name) {
}); PaperCompositionExample example = new PaperCompositionExample();
example.createCriteria().andOrgIdEqualTo(orgId).andNameEqualTo(name);
List<PaperComposition> list = compositionDAO.selectByExample(example);
return list;
} }
//
return page;
}
private PaperCompositionWithRuleVo.CreatorBasic findCreatorInfo(Long creatorId) { /**
SysAccount sa = this.sysAccountDAO.selectByPrimaryKey(creatorId); * 查询试卷蓝图的所有规则
if (null != sa) { *
PaperCompositionWithRuleVo.CreatorBasic rt = new PaperCompositionWithRuleVo.CreatorBasic(); * @param pcId 试卷蓝图的id
rt.setId(sa.getId()); */
if (StringUtils.hasText(sa.getName())) { @Transactional(readOnly = true)
rt.setName(sa.getName()); public List<PaperRule> findRuleByPcId(Long pcId) {
} else { PaperRuleExample example = new PaperRuleExample();
rt.setName("昵称:" + sa.getNickname()); example.createCriteria().andPcIdEqualTo(pcId);
} return ruleDAO.selectByExample(example);
rt.setAccount(sa.getAccount());
rt.setMobile(sa.getMobile());
rt.setEmail(sa.getEmail());
return rt;
} }
return null;
}
/** /**
* 获取试卷完整的蓝图包括规则 * 校验规则当前规定的总分值是否小于等于试卷蓝图中的满分
* */
* @param pcId 试卷蓝图id private boolean checkRulesScoreLessOrEqualFull(Long pcId) {
*/ PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
@Transactional(readOnly = true) PaperExceptionAssert.PcExisted.assertTrue(null != curPc, String.format("试卷定义[id = %s]不存在", pcId));
public PaperCompositionWithRuleVo findPaperComposition(Long pcId, AccountVO user) { List<PaperRule> ruleList = findRuleByPcId(pcId);
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId); int ruleScore = 0;
PaperExceptionAssert.PcExisted.assertTrue(null != curPc, "试卷定义不存在id=" + pcId); if (!CollectionUtils.isEmpty(ruleList)) {
List<PaperRule> paperRuleList = this.findRuleByPcId(pcId); ruleScore = ruleList.stream().mapToInt(rule -> {
// return rule.getScore() * rule.getAmount();
PaperCompositionWithRuleVo rt = PaperCompositionConvertor.convert(curPc, paperRuleList); }).sum();
rt.setCreatorInfo(this.findCreatorInfo(rt.getCreatorId())); }
return rt; return ruleScore <= curPc.getFullScore();
} }
/** /**
* 根据试卷蓝图的项目和名称查找项目 * 校验规则当前规定的总分值是否等于试卷蓝图中的满分
*/ */
@Transactional(readOnly = true) private boolean checkRulesScoreEqualFull(Long pcId) {
public List<PaperComposition> findCompositionByCompanyIdAndName(Long orgId, String name) { PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperCompositionExample example = new PaperCompositionExample(); PaperExceptionAssert.PcExisted.assertTrue(null != curPc, String.format("试卷定义[id = %s]不存在", pcId));
example.createCriteria().andOrgIdEqualTo(orgId).andNameEqualTo(name); List<PaperRule> ruleList = findRuleByPcId(pcId);
List<PaperComposition> list = compositionDAO.selectByExample(example); int ruleScore = 0;
return list; if (!CollectionUtils.isEmpty(ruleList)) {
} ruleScore = ruleList.stream().mapToInt(rule -> {
return rule.getScore() * rule.getAmount();
/** }).sum();
* 查询试卷蓝图的所有规则 }
* return ruleScore == curPc.getFullScore();
* @param pcId 试卷蓝图的id
*/
@Transactional(readOnly = true)
public List<PaperRule> findRuleByPcId(Long pcId) {
PaperRuleExample example = new PaperRuleExample();
example.createCriteria().andPcIdEqualTo(pcId);
return ruleDAO.selectByExample(example);
}
public List<CreatorBasic> queryCreatorList(FindPaperCompositionPageReqVo req) {
List<CreatorBasic> creators = new ArrayList<>();
List<PaperCompositionWithRuleVo> rules = findPaperCompositionList(req);
rules.stream().map(PaperCompositionWithRuleVo::getCreatorId)
.distinct()
.forEach(creatorId -> creators.add(this.findCreatorInfo(creatorId)));
return creators;
}
/**
* 校验规则当前规定的总分值是否等于试卷蓝图中的满分
*/
private boolean checkRulesScoreEqualFull(Long pcId) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcExisted.assertTrue(null != curPc,
String.format("试卷定义[id = %s]不存在", pcId));
List<PaperRule> ruleList = findRuleByPcId(pcId);
int ruleScore = 0;
if (!CollectionUtils.isEmpty(ruleList)) {
ruleScore = ruleList.stream().mapToInt(rule -> {
return rule.getScore() * rule.getAmount();
}).sum();
} }
return ruleScore == curPc.getFullScore();
}
} }

View File

@ -231,7 +231,8 @@ public interface DeviceService {
void addOrUpdateThailandDeviceConfig(AccountVO accountVO, Long mapId); void addOrUpdateThailandDeviceConfig(AccountVO accountVO, Long mapId);
/**
* 所有沙盘项目通用接口
*/
void addOrUpdateNgyDeviceConfig(AccountVO accountVO, Long mapId); void addOrUpdateNgyDeviceConfig(AccountVO accountVO, Long mapId);
void addOrUpdateCdgxyDeviceConfig(AccountVO user);
} }

View File

@ -34,10 +34,6 @@ import club.joylink.rtss.vo.client.project.UDPClientConfigVO;
import club.joylink.rtss.vo.client.project.UDPLowConfigVO; import club.joylink.rtss.vo.client.project.UDPLowConfigVO;
import club.joylink.rtss.vo.client.project.VrIbpConfigVO; import club.joylink.rtss.vo.client.project.VrIbpConfigVO;
import club.joylink.rtss.vo.client.project.VrpsdConfigVO; import club.joylink.rtss.vo.client.project.VrpsdConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySectionConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO;
import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO; import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO;
@ -260,8 +256,7 @@ public class DeviceServiceImpl implements DeviceService {
ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id); ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals( BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(
ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.SANDBOX, ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.SANDBOX,
String.format("设备[%s(%s)]不是电子沙盘工作站,不能更新", device.getCode(), String.format("设备[%s(%s)]不是电子沙盘工作站,不能更新", device.getCode(), device.getType()));
device.getType()));
device.setConfig(configVO.toJson()); device.setConfig(configVO.toJson());
this.projectDeviceDAO.updateByPrimaryKeySelective(device); this.projectDeviceDAO.updateByPrimaryKeySelective(device);
} }
@ -271,8 +266,7 @@ public class DeviceServiceImpl implements DeviceService {
ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id); ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals( BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(
ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.ISCS_LW, ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.ISCS_LW,
String.format("设备[%s(%s)]不是现地综合监控工作站,不能更新", device.getCode(), String.format("设备[%s(%s)]不是现地综合监控工作站,不能更新", device.getCode(), device.getType()));
device.getType()));
device.setConfig(configVO.toJson()); device.setConfig(configVO.toJson());
this.projectDeviceDAO.updateByPrimaryKeySelective(device); this.projectDeviceDAO.updateByPrimaryKeySelective(device);
} }
@ -282,8 +276,7 @@ public class DeviceServiceImpl implements DeviceService {
ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id); ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals( BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(
ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.ISCS_CW, ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.ISCS_CW,
String.format("设备[%s(%s)]不是中心综合监控工作站,不能更新", device.getCode(), String.format("设备[%s(%s)]不是中心综合监控工作站,不能更新", device.getCode(), device.getType()));
device.getType()));
device.setConfig(configVO.toJson()); device.setConfig(configVO.toJson());
this.projectDeviceDAO.updateByPrimaryKeySelective(device); this.projectDeviceDAO.updateByPrimaryKeySelective(device);
} }
@ -293,8 +286,7 @@ public class DeviceServiceImpl implements DeviceService {
ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id); ProjectDevice device = this.projectDeviceDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals( BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(
ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.VR_PSD, ProjectDeviceType.valueOf(device.getType()), ProjectDeviceType.VR_PSD,
String.format("设备[%s(%s)]不是虚拟屏蔽门工作站,不能更新", device.getCode(), String.format("设备[%s(%s)]不是虚拟屏蔽门工作站,不能更新", device.getCode(), device.getType()));
device.getType()));
device.setConfig(configVO.toJson()); device.setConfig(configVO.toJson());
this.projectDeviceDAO.updateByPrimaryKeySelective(device); this.projectDeviceDAO.updateByPrimaryKeySelective(device);
} }
@ -553,109 +545,6 @@ public class DeviceServiceImpl implements DeviceService {
} }
} }
@Override
public void addOrUpdateCdgxyDeviceConfig(AccountVO accountVO) {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo(ProjectCode.CDGXY)
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name)
.collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildCdgxyProjectDevices(accountVO);
for (ProjectDevice projectDevice : list) {
this.projectDeviceDAO.insert(projectDevice);
}
}
private List<ProjectDevice> buildCdgxyProjectDevices(AccountVO accountVO) {
LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>();
String projectCode = ProjectCode.CDGXY;
String prefix = "cdgxy-";
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode(projectCode);
plcGateway.setCode(prefix + "gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
plcGateway.setCreateTime(now);
PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 64);
plcGateway.setConfig(plcGatewayConfigVO.toJson());
list.add(plcGateway);
//SIGNAL
ProjectDevice signal1 = new ProjectDevice();
signal1.setProjectCode(projectCode);
signal1.setCode(prefix + "signal");
signal1.setType(ProjectDeviceType.SIGNAL.name());
signal1.setCreator(accountVO.getId());
signal1.setCreateTime(now);
signal1.setConfig(new CgySignalConfigVO("S13289", 0, 1, 2, 3, 4, 5, 16, 17, 18, 19).toJson());
list.add(signal1);
ProjectDevice signal2 = new ProjectDevice();
signal2.setProjectCode(projectCode);
signal2.setCode(prefix + "signal");
signal2.setType(ProjectDeviceType.SIGNAL.name());
signal2.setCreator(accountVO.getId());
signal2.setCreateTime(now);
signal2.setConfig(new CgySignalConfigVO("X44854", 6, 7, 8, 9, 10, 11, 20, 21, 22, 23).toJson());
list.add(signal2);
//SWITCH
ProjectDevice aSwitch = new ProjectDevice();
aSwitch.setProjectCode(projectCode);
aSwitch.setCode(prefix + "switch");
aSwitch.setType(ProjectDeviceType.SWITCH.name());
aSwitch.setCreator(accountVO.getId());
aSwitch.setCreateTime(now);
aSwitch.setConfig(new CgySwitchConfigVO("W37779").toJson());
list.add(aSwitch);
//PSL
ProjectDevice psl = new ProjectDevice();
psl.setProjectCode(projectCode);
psl.setCode(prefix + "psl");
psl.setType(ProjectDeviceType.PSL.name());
psl.setCreator(accountVO.getId());
psl.setCreateTime(now);
psl.setConfig(new CgyPslConfigVO("PF59020_PSL").toJson());
list.add(psl);
//SECTION
ProjectDevice section106 = new ProjectDevice();
section106.setProjectCode(projectCode);
section106.setCode(prefix + "section106");
section106.setType(ProjectDeviceType.SECTION.name());
section106.setCreator(accountVO.getId());
section106.setCreateTime(now);
section106.setConfig(new CgySectionConfigVO(null, 35).toJson());
list.add(section106);
ProjectDevice section104 = new ProjectDevice();
section104.setProjectCode(projectCode);
section104.setCode(prefix + "section104");
section104.setType(ProjectDeviceType.SECTION.name());
section104.setCreator(accountVO.getId());
section104.setCreateTime(now);
section104.setConfig(new CgySectionConfigVO(null, 36).toJson());
list.add(section104);
ProjectDevice section101 = new ProjectDevice();
section101.setProjectCode(projectCode);
section101.setCode(prefix + "section101");
section101.setType(ProjectDeviceType.SECTION.name());
section101.setCreator(accountVO.getId());
section101.setCreateTime(now);
section101.setConfig(new CgySectionConfigVO(null, 37).toJson());
list.add(section101);
ProjectDevice section102 = new ProjectDevice();
section102.setProjectCode(projectCode);
section102.setCode(prefix + "section102");
section102.setType(ProjectDeviceType.SECTION.name());
section102.setCreator(accountVO.getId());
section102.setCreateTime(now);
section102.setConfig(new CgySectionConfigVO(null, 38).toJson());
list.add(section102);
return list;
}
private List<ProjectDevice> buildSayProjectDevices(AccountVO accountVO) { private List<ProjectDevice> buildSayProjectDevices(AccountVO accountVO) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>(); List<ProjectDevice> list = new ArrayList<>();
@ -1299,8 +1188,8 @@ public class DeviceServiceImpl implements DeviceService {
section.setCreateTime(now); section.setCreateTime(now);
SandTableSectionConfigVO configVO = new SandTableSectionConfigVO(mapSectionNewVO.getCode(), SandTableSectionConfigVO configVO = new SandTableSectionConfigVO(mapSectionNewVO.getCode(),
mapSectionNewVO.getSrCode()); mapSectionNewVO.getSrCode());
section.setConfig(JsonUtils.writeValueAsString(configVO));
ngyFillTime(configVO, mapSectionNewVO); ngyFillTime(configVO, mapSectionNewVO);
section.setConfig(JsonUtils.writeValueAsString(configVO));
list.add(section); list.add(section);
} }
} }
@ -1324,7 +1213,8 @@ public class DeviceServiceImpl implements DeviceService {
private void ngyFillTime(SandTableSectionConfigVO configVO, MapSectionNewVO section) { private void ngyFillTime(SandTableSectionConfigVO configVO, MapSectionNewVO section) {
Float headDelayTime = null; Float headDelayTime = null;
Float tailDelayTime = null; Float tailDelayTime = null;
if (section.isStandTrack() || section.isReentryTrack() || section.isTransferTrack()) { if (section.isStandTrack() || section.isReentryTrack() || section.isTransferTrack()
|| section.isParkingTrack()) {
if (section.isStandTrack()) { if (section.isStandTrack()) {
tailDelayTime = 1f; tailDelayTime = 1f;
} else { } else {

View File

@ -12,166 +12,152 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent;
import club.joylink.rtss.vo.client.psl.PslStatus; import club.joylink.rtss.vo.client.psl.PslStatus;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
@Service @Service
public class VirtualRealityPslService implements IVirtualRealityPslService { public class VirtualRealityPslService implements IVirtualRealityPslService {
@Autowired @Autowired
private GroupSimulationService groupSimulationService; private GroupSimulationService groupSimulationService;
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Autowired @Autowired
private CiApiService ciApiService; private CiApiService ciApiService;
@Override @Override
public PslStatus getStatus(String group, String standCode) { public PslStatus getStatus(String group, String standCode) {
Simulation simulation = groupSimulationService.getSimulationByGroup(group); Simulation simulation = groupSimulationService.getSimulationByGroup(group);
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
Map<String, PslStatus> pslStatusMap = repository.getPslStatusMap(); Map<String, PslStatus> pslStatusMap = repository.getPslStatusMap();
PslStatus status = pslStatusMap.get(standCode); PslStatus status = pslStatusMap.get(standCode);
if (status != null) { if (status != null) {
return status; return status;
}
Stand stand = repository.getByCode(standCode, Stand.class);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(),
String.format("%s没有屏蔽门", stand.debugStr()));
VirtualRealityPsl vrPsl = collectStatus(stand);
status = new PslStatus(vrPsl);
pslStatusMap.put(standCode, status);
return status;
}
@Override
public void pressTheButton(Simulation simulation, String standCode,
VirtualRealityPsl.Button button) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand();
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(!vrPsl.isYxjzKey());
break;
case HSJC:
vrPsl.setHsjcKey(!vrPsl.isHsjcKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break;
case KM:
ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break;
case GM:
ciApiService.closeScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break;
case SD:
vrPsl.setSdButton(!vrPsl.isSdButton());
break;
}
}
@Override
public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button, boolean on) {
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(on);
break;
case HSJC:
vrPsl.setHsjcKey(on);
break;
case KM:
vrPsl.setKmButton(on);
break;
case GM:
vrPsl.setGmButton(on);
break;
case SD:
vrPsl.setSdButton(on);
break;
}
effective(simulation, vrPsl.getStand(), button, on);
}
private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button,
boolean on) {
switch (button) {
case YXJZ:
break;
case HSJC:
ciApiService.setOrCancelInterlockRelease(simulation, stand, on);
break;
case KM:
if (on) {
ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
} }
break; Stand stand = repository.getByCode(standCode, Stand.class);
case GM: BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(),
if (on) { String.format("%s没有屏蔽门", stand.debugStr()));
ciApiService.closeScreenDoor(simulation, stand.getCode(), VirtualRealityPsl vrPsl = collectStatus(stand);
CiStandService.PsdCommandSource.PSL); status = new PslStatus(vrPsl);
pslStatusMap.put(standCode, status);
return status;
}
@Override
public void pressTheButton(Simulation simulation, String standCode, VirtualRealityPsl.Button button) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand();
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(!vrPsl.isYxjzKey());
break;
case HSJC:
vrPsl.setHsjcKey(!vrPsl.isHsjcKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break;
case KM:
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case GM:
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
vrPsl.setSdButton(!vrPsl.isSdButton());
break;
} }
break;
case SD:
break;
} }
}
@Override @Override
public void addJobs(Simulation simulation) { public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on) {
simulation.addJobIfAbsent(Simulation.JobName.pslStatus, switch (button) {
() -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE); case YXJZ:
} vrPsl.setYxjzKey(on);
break;
public void collectAndDispatcher(Simulation simulation) { case HSJC:
SimulationDataRepository repository = simulation.getRepository(); vrPsl.setHsjcKey(on);
Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap(); break;
Map<String, PslStatus> collectionMap = new HashMap<>(); case KM:
for (Stand stand : repository.getStandList()) { case GM:
if (stand.getVrPsl() == null) { break;
continue; case SD:
} vrPsl.setSdButton(on);
VirtualRealityPsl vrPsl = this.collectStatus(stand); break;
PslStatus pslStatus = ibpStatusMap.get(stand.getCode());
if (pslStatus == null) {
PslStatus newStatus = new PslStatus(vrPsl);
ibpStatusMap.put(stand.getCode(), newStatus);
collectionMap.put(stand.getCode(), newStatus);
} else {
PslStatus difference = pslStatus.collectDifference(vrPsl);
if (difference != null) {
collectionMap.put(stand.getCode(), difference);
} }
} effective(simulation, vrPsl.getStand(), button, on);
} }
if (!CollectionUtils.isEmpty(collectionMap)) {
applicationContext.publishEvent(
new SimulationPslStatusEvent(this, simulation, collectionMap));
}
}
private VirtualRealityPsl collectStatus(Stand stand) { private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button, boolean on) {
VirtualRealityPsl vrPsl = stand.getVrPsl(); switch (button) {
PSD psd = stand.getPsd(); case YXJZ:
vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock()); break;
vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey()); case HSJC:
vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey()); ciApiService.setOrCancelInterlockRelease(simulation, stand, on);
vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose()); break;
vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose()); case KM:
return vrPsl; if (on)
} ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case GM:
if (on)
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
break;
}
}
@Override
public void addJobs(Simulation simulation) {
simulation.addJobIfAbsent(Simulation.JobName.pslStatus,
() -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE);
}
public void collectAndDispatcher(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap();
Map<String, PslStatus> collectionMap = new HashMap<>();
for (Stand stand : repository.getStandList()) {
if (stand.getVrPsl() == null)
continue;
VirtualRealityPsl vrPsl = this.collectStatus(stand);
PslStatus pslStatus = ibpStatusMap.get(stand.getCode());
if (pslStatus == null) {
PslStatus newStatus = new PslStatus(vrPsl);
ibpStatusMap.put(stand.getCode(), newStatus);
collectionMap.put(stand.getCode(), newStatus);
} else {
PslStatus difference = pslStatus.collectDifference(vrPsl);
if (difference != null) {
collectionMap.put(stand.getCode(), difference);
}
}
}
if (!CollectionUtils.isEmpty(collectionMap)) {
applicationContext.publishEvent(new SimulationPslStatusEvent(this, simulation, collectionMap));
}
}
private VirtualRealityPsl collectStatus(Stand stand) {
VirtualRealityPsl vrPsl = stand.getVrPsl();
PSD psd = stand.getPsd();
vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock());
vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey());
vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey());
vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose());
vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose());
return vrPsl;
}
} }

View File

@ -280,7 +280,13 @@ public class PublishMapDataHandler {
MapGraphDataNewVO data = JsonUtils.read(map.getGraphData(), MapGraphDataNewVO.class); MapGraphDataNewVO data = JsonUtils.read(map.getGraphData(), MapGraphDataNewVO.class);
for (MapSectionNewVO section : data.getSectionList()) { for (MapSectionNewVO section : data.getSectionList()) {
if (section.getLengthFact() != null && section.getLengthFact() != 0) { if (section.getLengthFact() != null && section.getLengthFact() != 0) {
section.setLengthFact(section.getLengthFact() * multiple); if (section.isStandTrack() || section.isParkingTrack()) {
section.setLengthFact(140f);
} else if (section.isSwitchSection()) {
section.setLengthFact(30f);
} else {
section.setLengthFact(1000f);
}
} }
} }
map.setGraphData(JsonUtils.writeValueAsString(data)); map.setGraphData(JsonUtils.writeValueAsString(data));

View File

@ -1,119 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.bo.race.RaceContent;
import club.joylink.rtss.entity.racetr.RacetrScene;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.training2.Training2Service;
import club.joylink.rtss.simulation.cbtc.training2.Training2.Type;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.paper.PaperTrainAnswerDetail;
import club.joylink.rtss.vo.race.RaceApplication.RacePracticeResult;
import club.joylink.rtss.vo.race.RaceApplication.ResultNode.Builder;
import club.joylink.rtss.vo.race.RaceSceneOuterClass;
import club.joylink.rtss.vo.race.RaceTask;
import club.joylink.rtss.vo.race.RaceTaskFinishParamDTO;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@AllArgsConstructor
public class RaceApplicationService {
private RacePaperService racePaperService;
private Training2Service training2Service;
private RaceSceneService raceSceneService;
private static final Map<Long, RaceContent> raceContentMap = new HashMap<>();
/**
* 开始训练
*
* @return 模块任务树
*/
public RaceTask.RacePaperSingleModuleGroupTask start(long paperId, int moduleId, long userId) {
RaceContent content = new RaceContent(userId, paperId, moduleId,
racePaperService.singlePaperModuleTask(paperId, moduleId));
RaceContent oldContent = raceContentMap.put(userId, content);
if (oldContent != null) {
log.info("用户[%d]开始了[赛题:{}|模块:{}]的训练,并且覆盖了就训练", paperId, moduleId);
} else {
log.info("用户[%d]开始了[赛题:{}|模块:{}]的训练", paperId, moduleId);
}
return content.getTaskTree();
}
public void loadScene(String simulationId, long sceneId, LoginUserInfoVO loginInfo) {
//获取场景数据
RacetrScene scene = raceSceneService.findById(sceneId);
RaceSceneOuterClass.StorageSimulation sceneProto;
try {
sceneProto = RaceSceneOuterClass.Scene.parseFrom(scene.getProto()).getStorageSimulation();
} catch (InvalidProtocolBufferException e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("场景数据解析出错", e);
}
//场景数据转实训数据
DraftTraining2WithBLOBs draftTraining2 = new DraftTraining2WithBLOBs();
draftTraining2.setName(scene.getName());
draftTraining2.setBgSceneJson(sceneProto.getBgSceneJson());
// draftTraining2.setOperaJson(sceneProto.get); operaJson没了
draftTraining2.setStepJson(sceneProto.getStepJson());
draftTraining2.setScoringRuleJson(sceneProto.getScoringRuleJson());
draftTraining2.setMemberJson(sceneProto.getMemberJson());
draftTraining2.setPlayerIdJson(JsonUtils.writeValueAsString(sceneProto.getPlayerIdsList()));
// draftTraining2.setClient(sceneProto); client没了
draftTraining2.setType(Type.SCENE.name()); //数据里没存暂时固定用此类型
training2Service.trainingDataValid(draftTraining2);
//加载实训
training2Service.simulationLoadTraining(simulationId, draftTraining2, loginInfo);
}
public List<PaperTrainAnswerDetail> finishTask(long taskId, RaceTaskFinishParamDTO paramDTO,
AccountVO user) {
if (paramDTO == null) {
return null;
}
RaceContent content = getContent(user.getId());
List<PaperTrainAnswerDetail> result = training2Service.finishTraining2(
paramDTO.getSimulationId(), user, paramDTO.getScoreList());
Builder resultNode = content.getResultNode(taskId);
float fullScore = 0;
float score = 0;
for (PaperTrainAnswerDetail paperTrainAnswerDetail : result) {
if (paperTrainAnswerDetail.getRuleScore() != null) {
fullScore += paperTrainAnswerDetail.getRuleScore();
}
if (paperTrainAnswerDetail.getScore() != null) {
score += paperTrainAnswerDetail.getScore();
}
}
resultNode.setFullScore(fullScore);
resultNode.setScore(score);
return result;
}
public RacePracticeResult finish(long userId) {
RaceContent content = getContent(userId);
RacePracticeResult result = content.getResult().build();
raceContentMap.remove(userId);
log.info("用户[{}]完成[赛题:{} | 模块:{}]", userId, content.getPaperId(),
content.getModuleId());
return result;
}
private RaceContent getContent(long userId) {
RaceContent content = raceContentMap.get(userId);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(content,
String.format("未找到用户[%d]的训练上下文", userId));
return content;
}
}

View File

@ -1,382 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.dao.racetr.RacetrPaperDAO;
import club.joylink.rtss.dao.racetr.RacetrSeasonDAO;
import club.joylink.rtss.entity.racetr.RacetrPaper;
import club.joylink.rtss.entity.racetr.RacetrPaperExample;
import club.joylink.rtss.entity.racetr.RacetrSeason;
import club.joylink.rtss.entity.racetr.RacetrSeasonExample;
import club.joylink.rtss.entity.racetr.RacetrSeasonExample.Criteria;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperCreateVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperDetailVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperMenuVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperMenuVO.PaperMenu;
import club.joylink.rtss.vo.race.RacePaper.RacePaperMenuVO.SeasonMenu;
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO.PaperModule;
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
import club.joylink.rtss.vo.race.RacePaperPageVO;
import club.joylink.rtss.vo.race.RacePaperQueryVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScene.Type;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeason.Group;
import club.joylink.rtss.vo.race.RaceTask.RacePaperSingleModuleGroupTask;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskChildVO.ChildNodeType;
import club.joylink.rtss.vo.race.RaceTaskDetailDTO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
@Slf4j
public class RacePaperService {
@Autowired
private RacetrPaperDAO paperDAO;
@Autowired
private RaceTaskService taskService;
@Autowired
private RacetrSeasonDAO seasonDAO;
private RacetrPaper findId(Long id) {
RacetrPaper rp = this.paperDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(rp), "未找到对应的试卷");
return rp;
}
public void create(RacePaperCreateVO createVO, AccountVO user) {
LocalDateTime now = LocalDateTime.now();
RacetrPaper rp = new RacetrPaper();
rp.setName(createVO.getName());
rp.setDesc(createVO.getDesc());
rp.setSeasonId(createVO.getSeasonId());
rp.setCreateTime(now);
rp.setUpdateTime(now);
rp.setCreatorId(user.getId());
rp.setUpdaterId(user.getId());
this.paperDAO.insertSelective(rp);
}
public void update(Long id, RacePaperCreateVO updateVO, AccountVO user) {
RacetrPaper rp = this.findId(id);
rp.setName(updateVO.getName());
rp.setDesc(updateVO.getDesc());
rp.setSeasonId(updateVO.getSeasonId());
rp.setUpdateTime(LocalDateTime.now());
rp.setUpdaterId(user.getId());
this.paperDAO.updateByPrimaryKey(rp);
}
private List<RacetrSeason> findSeasonMenu(Group group) {
RacetrSeasonExample example = new RacetrSeasonExample();
Criteria c = example.createCriteria();
if (Objects.nonNull(group) && group != Group.Unknown) {
c.andGroupEqualTo(group.name());
}
List<RacetrSeason> seasons = this.seasonDAO.selectByExampleWithBLOBs(example);
return seasons;
}
public RacePaperMenuVO pageMenuQuery(RacePaperQueryVO query) {
Group group = Group.Unknown;
if (StringUtils.isNotEmpty(query.getGroup())) {
group = Group.valueOf(query.getGroup());
}
List<RacetrSeason> seasons = this.findSeasonMenu(group);
RacePaperMenuVO.Builder menuBuilder = RacePaperMenuVO.newBuilder();
if (CollectionUtils.isEmpty(seasons)) {
return menuBuilder.build();
}
List<Long> seasonIdList = seasons.stream().map(RacetrSeason::getId).collect(Collectors.toList());
RacetrPaperExample paperExample = new RacetrPaperExample();
paperExample.createCriteria().andSeasonIdIn(seasonIdList);
List<RacetrPaper> papers = this.paperDAO.selectByExample(paperExample);
Map<Long, List<RacetrPaper>> paperMapList = papers.stream().collect(Collectors.groupingBy(RacetrPaper::getSeasonId));
for (RacetrSeason season : seasons) {
SeasonMenu.Builder sm = SeasonMenu.newBuilder();
sm.setSeasonId(season.getId());
sm.setSeasonName(season.getTerm());
sm.setSeasonCode(season.getCode());
if (StringUtils.isNotEmpty(season.getDetailHtmlContent())) {
sm.setDetailHtmlContent(season.getDetailHtmlContent());
}
this.convertPaperMenu(sm, paperMapList);
menuBuilder.addMenu(sm);
}
return menuBuilder.build();
}
private void convertPaperMenu(SeasonMenu.Builder seasonBuild, Map<Long, List<RacetrPaper>> paperMapList) {
List<RacetrPaper> paperList = paperMapList.get(seasonBuild.getSeasonId());
if (!CollectionUtils.isEmpty(paperList)) {
for (RacetrPaper paper : paperList) {
PaperMenu.Builder pm = PaperMenu.newBuilder();
pm.setId(paper.getId());
pm.setName(paper.getName());
seasonBuild.addPapers(pm);
}
}
}
public PageVO<RacePaperVO> pageQuery(RacePaperQueryVO query) {
if (!StringUtils.equalsAny(query.getGroup(), Group.GZ.name(), Group.ZZ.name())) {
query.setGroup(null);
}
PageHelper.startPage(query.getPageNum(), query.getPageSize());
Page<RacePaperPageVO> page = (Page<RacePaperPageVO>) this.paperDAO.pages(query);
List<RacePaperVO> voList = this.convertEntity(page.getResult());
return PageVO.convert(page, voList);
}
private RacePaperVO convertGroupDTO(RacePaperPageVO rp) {
RacePaperVO.Builder builder = RacePaperVO.newBuilder();
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(rp.getCreatorId(), rp.getCreatorName(), rp.getUpdaterId(), rp.getUpdaterName(), rp.getCreateTime(), rp.getUpdateTime());
builder.setId(rp.getId());
builder.setName(rp.getName());
builder.setDesc(rp.getDesc());
builder.setModifyInfo(modifyInfoVO);
builder.setSeasonId(rp.getSeasonId());
builder.setSeasonName(Objects.isNull(rp.getSeasonName()) ? "" : rp.getSeasonName());
builder.setGroup(Group.Unknown);
if (Objects.nonNull(rp.getGroup())) {
builder.setGroup(Group.valueOf(rp.getGroup()));
}
return builder.build();
}
private List<RacePaperVO> convertEntity(List<RacePaperPageVO> rpList) {
if (CollectionUtils.isEmpty(rpList)) {
return Collections.emptyList();
}
List<RacePaperVO> voList = Lists.newArrayListWithCapacity(rpList.size());
for (RacePaperPageVO rp : rpList) {
voList.add(this.convertGroupDTO(rp));
}
return voList;
}
public void delete(long id) {
this.paperDAO.deleteByPrimaryKey(id);
}
public RacePaperDetailVO detail(Long id) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(id), "请选择对应的试卷");
RacePaperPageVO paper = this.paperDAO.detail(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(paper), "未找到对应的试卷");
RacePaperDetailVO.Builder vo = RacePaperDetailVO.newBuilder();
vo.setId(paper.getId());
vo.setName(paper.getName());
vo.setDesc(paper.getDesc());
vo.setSupportCopy(!Objects.isNull(paper.getSupportCopy()) && paper.getSupportCopy());
vo.setModifyInfo(RaceServiceUtil.createModifyInfo(paper.getCreatorId(), paper.getCreatorName(), paper.getUpdaterId(), paper.getUpdaterName(), paper.getCreateTime(), paper.getUpdateTime()));
if (Objects.nonNull(paper.getSeasonId())) {
vo.setSeasonId(paper.getSeasonId());
vo.setSeasonName(paper.getSeasonName());
}
if (Objects.nonNull(paper.getConfigs())) {
try {
RacePaperModuleVO moduleVO = RacePaperModuleVO.parseFrom(paper.getConfigs());
vo.setModuleVo(moduleVO);
} catch (Exception e) {
log.error("试卷[{}][{}] 配置解析失败 msg:[{}]", paper.getName(), paper.getId(), e.getMessage());
BusinessExceptionAssertEnum.DATA_ERROR.fail("数据配置解析失败");
}
}
return vo.build();
}
public void configSeting(Long id, RacePaperModuleVO moduleVO, AccountVO user) {
RacetrPaper paper = this.findId(id);
paper.setUpdateTime(LocalDateTime.now());
paper.setUpdaterId(user.getId());
int customId = 1;
RacePaperModuleVO.Builder voBuild = moduleVO.toBuilder();
List<PaperModule> pmList = Lists.newArrayListWithExpectedSize(voBuild.getModulesList().size());
for (PaperModule pm : voBuild.getModulesList()) {
PaperModule.Builder pmBuild = pm.toBuilder();
pmBuild.setCustomModuleId(++customId);
pmList.add(pmBuild.build());
}
voBuild.clearModules();
voBuild.addAllModules(pmList);
paper.setConfigs(voBuild.build().toByteArray());
this.paperDAO.updateByPrimaryKeySelective(paper);
}
public void copy(Long id, AccountVO user) {
RacetrPaper paper = this.findId(id);
LocalDateTime now = LocalDateTime.now();
paper.setId(null);
paper.setName(String.format("%s_copy", paper.getName()));
paper.setCreatorId(user.getId());
paper.setUpdaterId(user.getId());
paper.setCreateTime(now);
paper.setUpdateTime(now);
this.paperDAO.insert(paper);
}
/**
* 试卷考试返回模块下所有的group和任务所有数据形成在一个""
*
* @param paperId
* @param moduleId
* @return
*/
public RacePaperSingleModuleGroupTask singlePaperModuleTask(Long paperId, Integer moduleId) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(moduleId), "请选择对应的模型");
RacePaperDetailVO detailVO = this.detail(paperId);
RacePaperModuleVO moduleVO = detailVO.getModuleVo();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(moduleVO.getModulesList()), "此试卷没有模块数据");
PaperModule pm = moduleVO.getModulesList().stream().filter(d -> d.getCustomModuleId() == moduleId).findFirst().orElse(null);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(pm), "没有找到对应的模块");
List<Long> allGroupTaskIds = this.collectAllTaskIds(pm.getGroupList());
Map<Long, List<RaceTaskDetailDTO>> taskMapList = this.taskService.recursiveFindTask(allGroupTaskIds);
List<RaceTaskChildVO> childVOS = this.singleTreeConvertModuleGroup(pm.getGroupList(), taskMapList);
RacePaperSingleModuleGroupTask.Builder modultTask = RacePaperSingleModuleGroupTask.newBuilder();
modultTask.setCustomModuleId(moduleId);
modultTask.addAllChild(childVOS);
return modultTask.build();
}
/**
* 获取模块下的所有数据包括""
*
* @param groupList
* @param allTaskMapList
* @return
*/
private List<RaceTaskChildVO> singleTreeConvertModuleGroup(List<RacePaperModuleVO.Group> groupList, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
List<RaceTaskChildVO> groups = new ArrayList<>();
for (RacePaperModuleVO.Group group : groupList) {
RaceTaskChildVO.Builder childVOB = RaceTaskChildVO.newBuilder();
childVOB.setName(group.getName());
childVOB.setNodeType(ChildNodeType.MODULE_GROUP);
for (Long taskId : group.getTaskIdsList()) {
RaceTaskChildVO taskVO = this.findTask(taskId, allTaskMapList);
childVOB.addChildren(taskVO);
}
if (!CollectionUtils.isEmpty(group.getGroupList())) {
List<RaceTaskChildVO> childGroup = this.singleTreeConvertModuleGroup(group.getGroupList(), allTaskMapList);
childVOB.addAllChildren(childGroup);
}
groups.add(childVOB.build());
}
return groups;
}
/**
* 获取任务树的根节点
*
* @param taskId
* @param allTaskMapList
* @return
*/
private RaceTaskChildVO findTask(Long taskId, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
List<RaceTaskDetailDTO> dtoList = allTaskMapList.get(RaceTaskService.TASK_ROOT_ID);
RaceTaskDetailDTO taskDto = dtoList.stream().filter(d -> Objects.equals(d.getId(), taskId)).findFirst().orElse(null);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(taskDto), String.format("对应的任务没有找到[%s]", taskDto));
RaceTaskChildVO.Builder vo = this.convertGroupDTO(taskDto, ChildNodeType.TASK);
this.findChildTask(vo, allTaskMapList);
return vo.build();
}
/**
* 获取任务树的所有子节点
*
* @param vob
* @param allTaskMapList
*/
private void findChildTask(RaceTaskChildVO.Builder vob, Map<Long, List<RaceTaskDetailDTO>> allTaskMapList) {
List<RaceTaskDetailDTO> childDto = allTaskMapList.get(vob.getId());
if (!CollectionUtils.isEmpty(childDto)) {
for (RaceTaskDetailDTO ch : childDto) {
RaceTaskChildVO.Builder chvo = this.convertGroupDTO(ch, ChildNodeType.TASK);
vob.addChildren(chvo);
this.findChildTask(chvo, allTaskMapList);
}
}
}
private RaceTaskChildVO.Builder convertGroupDTO(RaceTaskDetailDTO dto, ChildNodeType nodeType) {
RaceTaskChildVO.Builder cb = RaceTaskChildVO.newBuilder();
if (ChildNodeType.TASK == nodeType) {
cb.setId(dto.getId());
cb.setDesc(dto.getDesc());
cb.setContent(dto.getContent());
cb.setStandards(dto.getStandards());
cb.setParentId(dto.getParentId());
}
if (Objects.nonNull(dto.getRuleId())) {
cb.setRuleId(dto.getRuleId());
}
if (StringUtils.isNotEmpty(dto.getSceneType())) {
cb.setSceneType(Type.valueOf(dto.getSceneType()));
}
if (Objects.nonNull(dto.getSceneId())) {
cb.setSceneId(dto.getSceneId());
}
cb.setNodeType(nodeType);
cb.setName(dto.getName());
return cb;
}
/**
* 收集模块及子模块所有的任务id
*
* @param groupList
* @return
*/
private List<Long> collectAllTaskIds(List<RacePaperModuleVO.Group> groupList) {
List<Long> allTaskIds = Lists.newArrayList();
for (RacePaperModuleVO.Group group : groupList) {
this.collectTaskIds(group, allTaskIds);
}
return allTaskIds.stream().distinct().collect(Collectors.toList());
}
/**
* 收集所有子级任务ID
*
* @param group
* @param collectorList
*/
private void collectTaskIds(RacePaperModuleVO.Group group, List<Long> collectorList) {
collectorList.addAll(group.getTaskIdsList());
if (!CollectionUtils.isEmpty(group.getGroupList())) {
for (RacePaperModuleVO.Group group1 : group.getGroupList()) {
this.collectTaskIds(group1, collectorList);
}
}
}
}

View File

@ -1,246 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.dao.DraftTraining2DAO;
import club.joylink.rtss.dao.racetr.RacetrSceneDAO;
import club.joylink.rtss.dao.racetr.RacetrTaskDAO;
import club.joylink.rtss.entity.racetr.RacetrScene;
import club.joylink.rtss.entity.racetr.RacetrSceneExample;
import club.joylink.rtss.entity.racetr.RacetrTaskExample;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
import club.joylink.rtss.exception.BusinessExceptionAssert;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.exception.RacetrExceptionAssert;
import club.joylink.rtss.services.MinioService;
import club.joylink.rtss.simulation.cbtc.training2.Training2;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScene;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScene.Type;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceSceneListVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceScenePublishVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.RaceSceneVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.Scene;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.SceneCustomCreateVO;
import club.joylink.rtss.vo.race.RaceSceneOuterClass.StorageSimulation;
import club.joylink.rtss.vo.race.RaceScenePageVO;
import club.joylink.rtss.vo.race.RaceSceneQueryVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.google.protobuf.InvalidProtocolBufferException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestAttribute;
@Service
@Slf4j
public class RaceSceneService {
@Autowired
private RacetrSceneDAO sceneDAO;
@Autowired
private RacetrTaskDAO taskDAO;
@Autowired
private DraftTraining2DAO trainingDao;
@Autowired
private MinioService minioService;
public RacetrScene findById(Long id) {
RacetrScene rs = this.sceneDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(rs), "没有找到对应的场景");
return rs;
}
public void customSave(SceneCustomCreateVO vo, AccountVO user) {
LocalDateTime now = LocalDateTime.now();
RacetrScene rs = new RacetrScene();
rs.setName(vo.getName());
rs.setType(vo.getType().name());
rs.setProto(vo.getScene().toByteArray());
rs.setCreatorId(user.getId());
rs.setUpdaterId(user.getId());
rs.setCreateTime(now);
rs.setUpdateTime(now);
this.sceneDAO.insert(rs);
}
public void customUpdate(Long id, SceneCustomCreateVO vo, AccountVO user) {
RacetrScene rs = this.findById(id);
this.removeObj(rs);
rs.setName(vo.getName());
rs.setType(vo.getType().name());
rs.setProto(vo.getScene().toByteArray());
rs.setUpdaterId(user.getId());
rs.setUpdateTime(LocalDateTime.now());
this.sceneDAO.updateByPrimaryKeySelective(rs);
}
private void removeObj(RacetrScene rs) {
byte[] protoData = rs.getProto();
if (ArrayUtils.isEmpty(protoData)) {
log.error("自定义删除场景附件proto数据不能为空 id:[{}]", rs.getId());
return;
}
try {
if (!Objects.equals(rs.getType(), Type.Video.name())) {
return;
}
Scene sceneProto = Scene.parseFrom(protoData);
this.minioService.removeMinioObject(rs.getType(), sceneProto.getFileName());
} catch (Exception e) {
log.error("场景附件处理失败 id:[{}] msg:[{}]", rs.getId(), e.getMessage(), e);
}
}
public PageVO<RaceSceneListVO> page(RaceSceneQueryVO query) {
PageHelper.startPage(query.getPageNum(), query.getPageSize());
Page<RaceScenePageVO> page = (Page<RaceScenePageVO>) this.sceneDAO.pages(query);
List<RaceSceneListVO> voList = this.convertDto(page.getResult());
return PageVO.convert(page, voList);
}
private RaceSceneListVO convertVO(RaceScenePageVO rs) {
RaceSceneListVO.Builder vo = RaceSceneListVO.newBuilder();
vo.setId(rs.getId());
vo.setName(rs.getName());
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(rs.getCreatorId(), rs.getCreatorName(), rs.getUpdaterId(), rs.getUpdaterName(), rs.getCreateTime(), rs.getUpdateTime());
vo.setModifyInfo(modifyInfoVO);
vo.setType(Type.valueOf(rs.getType()));
if (Objects.nonNull(rs.getMapId())) {
vo.setMapId(rs.getMapId());
vo.setMapName(rs.getMapName());
}
return vo.build();
}
public List<RaceSceneListVO> convertDto(List<RaceScenePageVO> list) {
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
List<RaceSceneListVO> voList = Lists.newArrayListWithCapacity(list.size());
for (RaceScenePageVO rs : list) {
voList.add(this.convertVO(rs));
}
return voList;
}
public void delete(Long id) {
RacetrTaskExample taskExample = new RacetrTaskExample();
taskExample.createCriteria().andSceneIdEqualTo(id);
long bindTaskCount = this.taskDAO.countByExample(taskExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(bindTaskCount <= 0, "此场景已被任务绑定不能删除");
RacetrScene rs = this.findById(id);
this.removeObj(rs);
this.sceneDAO.deleteByPrimaryKey(id);
}
public void publishHere(RaceScenePublishVO vo, AccountVO user) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.hasText(vo.getName()), "请输入发布场景的名称");
String publishName = vo.getName().trim();
PublishHereVO phvo = this.createSceneProto(vo.getDafitid());
RacetrSceneExample sceneExample = new RacetrSceneExample();
sceneExample.createCriteria().andNameEqualTo(publishName);
// sceneExample.createCriteria().andDraftTrainingIdEqualTo(vo.getDafitid());
List<RacetrScene> rsList = this.sceneDAO.selectByExample(sceneExample);
if (!CollectionUtils.isEmpty(rsList) && Objects.equals(vo.getForcePublish(), false)) {
RacetrExceptionAssert.publishSceneNotForce.fail();
}
LocalDateTime now = LocalDateTime.now();
RacetrScene rs;
boolean sceneExist = false;
if (CollectionUtils.isEmpty(rsList)) {
rs = new RacetrScene();
rs.setCreatorId(user.getId());
rs.setCreateTime(now);
rs.setType(Type.Local.name());
rs.setDraftTrainingId(vo.getDafitid());
} else {
sceneExist = true;
rs = rsList.get(0);
}
rs.setUpdaterId(user.getId());
rs.setUpdateTime(now);
rs.setMapId(phvo.mapId);
rs.setName(publishName);
Scene.Builder sceneBu = Scene.newBuilder();
sceneBu.setStorageSimulation(phvo.getStorageSimulation());
rs.setProto(sceneBu.build().toByteArray());
if (sceneExist) {
this.sceneDAO.updateByPrimaryKeySelective(rs);
} else {
this.sceneDAO.insert(rs);
}
}
private PublishHereVO createSceneProto(Long TraningPublish) {
DraftTraining2WithBLOBs bs = this.trainingDao.selectByPrimaryKey(TraningPublish);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(bs), "没有找到对应的实训数据");
Training2.Type traingType = Training2.Type.valueOf(bs.getType());
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(traingType == Training2.Type.SCENE, "发布的实训类型只能位场景类型");
List<String> plays = JsonUtils.readCollection(bs.getPlayerIdJson(), ArrayList.class, String.class);
StorageSimulation.Builder ss = StorageSimulation.newBuilder();
ss.setBgSceneJson(bs.getBgSceneJson());
ss.setMemberJson(bs.getMemberJson());
ss.setStepJson(bs.getStepJson());
ss.addAllPlayerIds(plays);
ss.setScoringRuleJson(bs.getScoringRuleJson());
return new PublishHereVO(bs.getMapId(), ss.build());
}
public RaceSceneVO detail(Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id), "请选择对应的场景");
RaceScenePageVO rs = this.sceneDAO.detail(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(rs), "没有找到对应的场景");
RaceSceneVO.Builder builder = RaceSceneVO.newBuilder();
builder.setId(rs.getId());
builder.setName(rs.getName());
builder.setType(Type.valueOf(rs.getType()));
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(rs.getCreatorId(), rs.getCreatorName(), rs.getUpdaterId(), rs.getUpdaterName(), rs.getCreateTime(), rs.getUpdateTime());
builder.setModifyInfo(modifyInfoVO);
if (Objects.nonNull(rs.getMapId())) {
builder.setMapId(rs.getMapId());
builder.setMapName(rs.getName());
}
if (Objects.nonNull(rs.getProto())) {
try {
Scene scene = Scene.parseFrom(rs.getProto());
builder.setScene(scene);
} catch (Exception e) {
log.error("场景解析数据失败id[{}] msg:{}", id, e.getMessage());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.fail("数据获取失败");
}
}
return builder.build();
}
@Getter
private static class PublishHereVO {
private Long mapId;
private StorageSimulation storageSimulation;
public PublishHereVO(Long mapId, StorageSimulation storageSimulation) {
this.mapId = mapId;
this.storageSimulation = storageSimulation;
}
}
}

View File

@ -1,129 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.dao.racetr.RacetrScoringRuleDAO;
import club.joylink.rtss.dao.racetr.RacetrTaskDAO;
import club.joylink.rtss.entity.racetr.RacetrScoringRule;
import club.joylink.rtss.entity.racetr.RacetrTaskExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RaceRuleListVO;
import club.joylink.rtss.vo.race.RaceScoringRule.RaceScoringRuleListVO;
import club.joylink.rtss.vo.race.RaceScoringRule.RaceScoringRuleVO;
import club.joylink.rtss.vo.race.RaceScoringRule.Rule;
import club.joylink.rtss.vo.race.TaskRuleQueryVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@Service
@Slf4j
public class RaceScoreRuleService {
@Autowired
private RacetrScoringRuleDAO ruleDAO;
@Autowired
private RacetrTaskDAO taskDAO;
private RacetrScoringRule findId(Long id) {
RacetrScoringRule rule = this.ruleDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(Objects.nonNull(rule), "没有找到该评分规则");
return rule;
}
public void saveBasic(String name, AccountVO user) {
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(StringUtils.hasText(name), "规则名称不能为空");
LocalDateTime now = LocalDateTime.now();
RacetrScoringRule rule = new RacetrScoringRule();
rule.setName(name);
rule.setCreatorId(user.getId());
rule.setUpdaterId(user.getId());
rule.setCreateTime(now);
rule.setUpdateTime(now);
ruleDAO.insertSelective(rule);
}
public void editRule(Long ruleId, Rule ruleProto, AccountVO user) {
RacetrScoringRule rule = this.findId(ruleId);
rule.setUpdaterId(user.getId());
rule.setUpdateTime(LocalDateTime.now());
rule.setRule(ruleProto.toByteArray());
ruleDAO.updateByPrimaryKeySelective(rule);
}
public PageVO<RaceScoringRuleListVO> page(TaskRuleQueryVO query) {
PageHelper.startPage(query.getPageNum(), query.getPageSize());
/*RacetrScoringRuleExample example = new RacetrScoringRuleExample();
if (StringUtils.hasText(query.getName())) {
example.createCriteria().andNameLike(String.format("%%%s%%", query.getName()));
}*/
// Page<RacetrScoringRule> page = (Page<RacetrScoringRule>) this.ruleDAO.selectByExample(example);
Page<RaceRuleListVO> page = (Page<RaceRuleListVO>) this.ruleDAO.pages(query);
List<RaceScoringRuleListVO> voList = this.convertEntity(page.getResult());
return PageVO.convert(page, voList);
}
private RaceScoringRuleListVO convertVO(RaceRuleListVO rule) {
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(rule.getCreatorId(), rule.getCreatorName(), rule.getUpdaterId(), rule.getUpdaterName(), rule.getCreateTime(), rule.getUpdateTime());
RaceScoringRuleListVO.Builder builder = RaceScoringRuleListVO.newBuilder();
builder.setId(rule.getId());
builder.setName(rule.getName());
builder.setModifyInfo(modifyInfoVO);
return builder.build();
}
private List<RaceScoringRuleListVO> convertEntity(List<RaceRuleListVO> list) {
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
List<RaceScoringRuleListVO> voList = Lists.newArrayListWithCapacity(list.size());
for (RaceRuleListVO rs : list) {
voList.add(this.convertVO(rs));
}
return voList;
}
public void delete(Long id) {
RacetrTaskExample taskExample = new RacetrTaskExample();
taskExample.createCriteria().andScoreRuleIdEqualTo(id);
long bindCount = this.taskDAO.countByExample(taskExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(bindCount <= 0, "该规则已经绑定了对应方的任务,无法删除");
ruleDAO.deleteByPrimaryKey(id);
}
public RaceScoringRuleVO detail(Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id), "请选择对应的评分规则");
RaceRuleListVO detailVO = this.ruleDAO.detail(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(detailVO), "未找到对应的评分规则");
RaceScoringRuleVO.Builder builder = RaceScoringRuleVO.newBuilder();
builder.setId(detailVO.getId());
builder.setName(detailVO.getName());
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(detailVO.getCreatorId(), detailVO.getCreatorName(), detailVO.getUpdaterId(), detailVO.getUpdaterName(), detailVO.getCreateTime(),
detailVO.getUpdateTime());
builder.setModifyInfo(modifyInfoVO);
if (Objects.nonNull(detailVO.getRule())) {
try {
Rule rulePro = Rule.parseFrom(detailVO.getRule());
builder.setRule(rulePro);
} catch (Exception e) {
log.error("竞赛评分详情规则解析失败,msg:{} ", e.getMessage(), e);
BusinessExceptionAssertEnum.DATA_ERROR.fail("评分规则数据解析失败");
}
}
return builder.build();
}
}

View File

@ -1,152 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.dao.racetr.RacetrPaperDAO;
import club.joylink.rtss.dao.racetr.RacetrSeasonDAO;
import club.joylink.rtss.entity.SysAccount;
import club.joylink.rtss.entity.racetr.RacetrPaperExample;
import club.joylink.rtss.entity.racetr.RacetrSeason;
import club.joylink.rtss.entity.racetr.RacetrSeasonExample;
import club.joylink.rtss.entity.racetr.RacetrSeasonExample.Criteria;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeason.Group;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeasonCreateVO;
import club.joylink.rtss.vo.race.RaceSeasonOuterClass.RaceSeasonVO;
import club.joylink.rtss.vo.race.RaceSeasonQueryVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
public class RaceSeasonService {
@Autowired
private RacetrSeasonDAO seasonDAO;
@Autowired
private RacetrPaperDAO racePaperDAO;
@Autowired
private ISysUserService iSysUserService;
public RacetrSeason find(Long id) {
RacetrSeason rs = this.seasonDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(rs), "");
return rs;
}
public void updateHtmlContent(Long id, String htmlContent, AccountVO user) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.isNotEmpty(htmlContent), "请填写需要展示的内容");
LocalDateTime now = LocalDateTime.now();
RacetrSeason rr = this.find(id);
rr.setUpdaterId(user.getId());
rr.setUdpateTime(now);
rr.setDetailHtmlContent(htmlContent);
this.seasonDAO.updateByPrimaryKeySelective(rr);
}
public String queryHtmlContent(Long id) {
RacetrSeason rr = this.find(id);
return rr.getDetailHtmlContent();
}
public void save(RaceSeasonCreateVO dto, AccountVO user) {
LocalDateTime now = LocalDateTime.now();
RacetrSeason rs = new RacetrSeason();
rs.setCode(dto.getCode());
rs.setTerm(dto.getTerm());
rs.setGroup(dto.getGroup().name());
rs.setCreatorId(user.getId());
rs.setUpdaterId(user.getId());
rs.setCreateTime(now);
rs.setUdpateTime(now);
this.seasonDAO.insert(rs);
}
public void update(Long id, RaceSeasonCreateVO dto, AccountVO user) {
LocalDateTime now = LocalDateTime.now();
RacetrSeason rr = this.find(id);
rr.setUpdaterId(user.getId());
rr.setUdpateTime(now);
rr.setCode(dto.getCode());
rr.setTerm(dto.getTerm());
rr.setGroup(dto.getGroup().name());
this.seasonDAO.updateByPrimaryKeySelective(rr);
}
public PageVO<RaceSeasonVO> page(RaceSeasonQueryVO query) {
RacetrSeasonExample example = new RacetrSeasonExample();
Criteria c = example.createCriteria();
if (StringUtils.isNotEmpty(query.getCode())) {
c.andCodeLike(String.format("%%%s%%", query.getCode()));
}
if (StringUtils.isNotEmpty(query.getTerm())) {
c.andTermLike(String.format("%%%s%%", query.getTerm()));
}
if (Objects.nonNull(query.getGroup()) && query.getGroup() != Group.Unknown) {
c.andGroupEqualTo(query.getGroup().name());
}
PageHelper.startPage(query.getPageNum(), query.getPageSize());
Page<RacetrSeason> page = (Page<RacetrSeason>) this.seasonDAO.selectByExample(example);
PageHelper.clearPage();
List<RaceSeasonVO> voList = this.convertDTO(page.getResult());
return PageVO.convert(page, voList);
}
private RaceSeasonVO convertVO(RacetrSeason rs, Map<Long, SysAccount> accountMap) {
RaceSeasonVO.Builder voBuild = RaceSeasonVO.newBuilder();
voBuild.setId(rs.getId());
voBuild.setCode(rs.getCode());
voBuild.setGroup(Group.valueOf(rs.getGroup()));
voBuild.setTerm(rs.getTerm());
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(accountMap, rs.getCreatorId(), rs.getUpdaterId(), rs.getCreateTime(), rs.getUdpateTime());
voBuild.setModifyInfo(modifyInfoVO);
return voBuild.build();
}
private List<RaceSeasonVO> convertDTO(List<RacetrSeason> rsList) {
if (CollectionUtils.isEmpty(rsList)) {
return Collections.emptyList();
}
List<Long> userIdList = rsList.stream().map(d -> List.of(d.getCreatorId(), d.getUpdaterId())).flatMap(Collection::stream).distinct().collect(Collectors.toList());
Map<Long, SysAccount> accountMap = this.iSysUserService.findEntitiesForMap(userIdList);
List<RaceSeasonVO> voList = Lists.newArrayListWithCapacity(rsList.size());
for (RacetrSeason rs : rsList) {
voList.add(this.convertVO(rs, accountMap));
}
return voList;
}
/**
* 删除数据
*
* @param id
*/
public void delete(Long id) {
// this.find(id);
//检查数据确定没有被绑定过
RacetrPaperExample paperExample = new RacetrPaperExample();
RacetrPaperExample.Criteria c = paperExample.createCriteria();
c.andSeasonIdEqualTo(id);
Long exsitCounter = this.racePaperDAO.countByExample(paperExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(exsitCounter <= 0, "该数据已经被试卷绑定,无法删除");
this.seasonDAO.deleteByPrimaryKey(id);
}
}

View File

@ -1,51 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.entity.SysAccount;
import club.joylink.rtss.util.DateTimeUtil;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Objects;
public class RaceServiceUtil {
public static ModifyInfoVO createModifyInfo(Map<Long, SysAccount> accountMap, Long createId, Long updateId, LocalDateTime createTime, LocalDateTime updateTime) {
SysAccount createAcc = accountMap.get(createId);
ModifyInfoVO.Builder builder = ModifyInfoVO.newBuilder();
if (Objects.nonNull(createAcc)) {
builder.setCreatorId(createId);
builder.setCreatorName(createAcc.getNickname());
}
SysAccount updateAcc = accountMap.get(updateId);
if (Objects.nonNull(updateAcc)) {
builder.setCreatorId(updateId);
builder.setCreatorName(updateAcc.getNickname());
}
if (Objects.nonNull(createTime)) {
builder.setCreateTime(createTime.format(DateTimeUtil.DATE_TIME_DTF));
}
if (Objects.nonNull(updateTime)) {
builder.setUpdateTime(updateTime.format(DateTimeUtil.DATE_TIME_DTF));
}
return builder.build();
}
public static ModifyInfoVO createModifyInfo(Long createId, String createName, Long updateId, String updateName, LocalDateTime createTime, LocalDateTime updateTime) {
ModifyInfoVO.Builder builder = ModifyInfoVO.newBuilder();
builder.setCreatorId(createId);
builder.setCreatorName(createName);
builder.setUpdaterId(updateId);
builder.setUpdaterName(updateName);
if (Objects.nonNull(createTime)) {
builder.setCreateTime(createTime.format(DateTimeUtil.DATE_TIME_DTF));
}
if (Objects.nonNull(updateTime)) {
builder.setUpdateTime(updateTime.format(DateTimeUtil.DATE_TIME_DTF));
}
return builder.build();
}
}

View File

@ -1,203 +0,0 @@
package club.joylink.rtss.services.race;
import club.joylink.rtss.dao.racetr.RacetrTaskDAO;
import club.joylink.rtss.entity.racetr.RacetrTask;
import club.joylink.rtss.entity.racetr.RacetrTaskExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskBind;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskBind.TaskBindType;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskCreateVO;
import club.joylink.rtss.vo.race.RaceTask.RaceTaskDetailVO;
import club.joylink.rtss.vo.race.RaceTaskDetailDTO;
import club.joylink.rtss.vo.race.RaceTaskTreeVO;
import com.google.common.collect.Lists;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@Service
@Transactional
@Slf4j
public class RaceTaskService {
@Autowired
private RacetrTaskDAO raceTaskDAO;
protected final static Long TASK_ROOT_ID = 0L;
private RacetrTask findById(Long id) {
RacetrTask task = this.raceTaskDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(task),
"没有找到对应的任务");
return task;
}
public RaceTaskDetailVO detail(Long id) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id),
"请选择对应的任务");
RaceTaskDetailDTO task = this.raceTaskDAO.details(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(task),
"未找到对应的任务数据");
RaceTaskDetailVO.Builder vo = RaceTaskDetailVO.newBuilder();
vo.setId(task.getId());
vo.setName(task.getName());
vo.setDesc(task.getDesc());
vo.setContent(task.getContent());
vo.setStandards(task.getStandards());
vo.setParentId(task.getParentId());
ModifyInfoVO modifyInfoVO = RaceServiceUtil.createModifyInfo(task.getCreatorId(),
task.getCreatorName(), task.getUpdaterId(), task.getUpdaterName(), task.getCreateTime(),
task.getUpdateTime());
vo.setModifyInfo(modifyInfoVO);
if (Objects.nonNull(task.getSceneId())) {
vo.setSceneId(task.getSceneId());
vo.setSceneName(task.getSceneName());
}
if (Objects.nonNull(task.getRuleId())) {
vo.setRuleId(task.getRuleId());
vo.setRuleName(task.getRuleName());
}
return vo.build();
}
public void save(RaceTaskCreateVO vo, AccountVO user) {
LocalDateTime now = LocalDateTime.now();
RacetrTask task = new RacetrTask();
task.setName(vo.getName());
task.setDesc(vo.getDesc());
task.setContent(vo.getContent());
task.setStandards(vo.getStandards());
task.setCreatorId(user.getId());
task.setUpdaterId(user.getId());
task.setCreateTime(now);
task.setUpdateTime(now);
task.setParentId(vo.getParentId());
this.raceTaskDAO.insert(task);
}
public void update(Long id, RaceTaskCreateVO vo, AccountVO user) {
RacetrTask task = this.findById(id);
task.setName(vo.getName());
task.setDesc(vo.getDesc());
task.setContent(vo.getContent());
task.setStandards(vo.getStandards());
task.setUpdaterId(user.getId());
task.setUpdateTime(LocalDateTime.now());
this.raceTaskDAO.updateByPrimaryKey(task);
}
public void bind(Long taskId, List<RaceTaskBind> bind, AccountVO user) {
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(!CollectionUtils.isEmpty(bind),
"请选择要绑定的数据");
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(bind.size() <= 2, "最多绑定只能选择2个类型");
if (bind.size() > 1) {
List<TaskBindType> bindTypes = bind.stream().map(RaceTaskBind::getBindType).distinct()
.collect(Collectors.toList());
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(bindTypes.size() != 1,
"最多绑定只能选择2个类型");
}
RacetrTask task = this.findById(taskId);
for (RaceTaskBind raceTaskBind : bind) {
if (raceTaskBind.getBindType() == TaskBindType.rule) {
task.setScoreRuleId(raceTaskBind.getBindId());
if (raceTaskBind.getStatus() == 1) {
task.setScoreRuleId(null);
}
} else if (raceTaskBind.getBindType() == TaskBindType.scene) {
task.setSceneId(raceTaskBind.getBindId());
if (raceTaskBind.getStatus() == 1) {
task.setSceneId(null);
}
} else {
log.error("未知任务绑定类型{}", raceTaskBind.getBindType().name());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.fail("未知绑定类型");
}
}
task.setUpdaterId(user.getId());
task.setUpdateTime(LocalDateTime.now());
this.raceTaskDAO.updateByPrimaryKey(task);
}
public List<RaceTaskTreeVO> tree() {
List<RacetrTask> taskList = this.raceTaskDAO.selectByExample(null);
Map<Long, List<RaceTaskTreeVO>> mapList = taskList.stream().map(RaceTaskTreeVO::new)
.collect(Collectors.groupingBy(RaceTaskTreeVO::getParentId));
List<RaceTaskTreeVO> rootTaskList = mapList.get(TASK_ROOT_ID);
if (CollectionUtils.isEmpty(rootTaskList)) {
return Collections.emptyList();
}
for (RaceTaskTreeVO rootTask : rootTaskList) {
this.loopFind(rootTask, mapList);
}
return rootTaskList;
}
public List<RaceTaskTreeVO> findChildren(Long parentId) {
RacetrTaskExample example = new RacetrTaskExample();
example.createCriteria().andParentIdEqualTo(parentId);
List<RacetrTask> taskList = this.raceTaskDAO.selectByExample(example);
return taskList.stream().map(RaceTaskTreeVO::new).collect(Collectors.toList());
}
private void loopFind(RaceTaskTreeVO task, Map<Long, List<RaceTaskTreeVO>> mapList) {
List<RaceTaskTreeVO> children = mapList.get(task.getId());
if (Objects.nonNull(children)) {
task.setChildren(children);
for (RaceTaskTreeVO child : children) {
this.loopFind(child, mapList);
}
}
}
public void delete(Long id) {
RacetrTask rt = this.findById(id);
List<RaceTaskTreeVO> collection = Lists.newArrayList(new RaceTaskTreeVO(rt));
this.collectAllChildren(rt.getId(), collection);
List<Long> deleteIds = collection.stream().map(RaceTaskTreeVO::getId).distinct()
.collect(Collectors.toList());
log.info("删除任务[{}] 对应所有的子节点id[{}]", id, deleteIds);
RacetrTaskExample example = new RacetrTaskExample();
example.createCriteria().andIdIn(deleteIds);
this.raceTaskDAO.deleteByExample(example);
}
private void collectAllChildren(Long parentId, List<RaceTaskTreeVO> collection) {
List<RaceTaskTreeVO> list = this.findChildren(parentId);
if (!CollectionUtils.isEmpty(list)) {
for (RaceTaskTreeVO c : list) {
collection.add(c);
this.collectAllChildren(c.getId(), collection);
}
}
}
/**
* 递归查找taskId下相关的所有数据
*
* @param taskIds
* @return
*/
public Map<Long, List<RaceTaskDetailDTO>> recursiveFindTask(List<Long> taskIds) {
List<RaceTaskDetailDTO> taskDtoList = this.raceTaskDAO.recursiveFindTask(taskIds);
Map<Long, List<RaceTaskDetailDTO>> dtoMapList = taskDtoList.stream()
.collect(Collectors.groupingBy(RaceTaskDetailDTO::getParentId));
return dtoMapList;
}
}

View File

@ -18,10 +18,24 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO;
import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.client.runplan.user.*; import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingQueryVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingSection;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO;
import club.joylink.rtss.vo.client.runplan.user.RunPlanUserConfigVO;
import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.MapVO;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,230 +43,258 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class RunPlanRoutingService implements IRunPlanRoutingService { public class RunPlanRoutingService implements IRunPlanRoutingService {
@Autowired @Autowired
private RunPlanRoutingDAO runPlanRoutingDAO; private RunPlanRoutingDAO runPlanRoutingDAO;
@Autowired @Autowired
private RunPlanDraftDAO runPlanDraftDAO; private RunPlanDraftDAO runPlanDraftDAO;
@Autowired @Autowired
private IRunPlanRunlevelService planRunlevelService; private IRunPlanRunlevelService planRunlevelService;
@Autowired @Autowired
private IRunPlanParktimeService planParktimeService; private IRunPlanParktimeService planParktimeService;
@Autowired @Autowired
private IRunPlanUserConfigService planConfigService; private IRunPlanUserConfigService planConfigService;
@Autowired @Autowired
private IMapService iMapService; private IMapService iMapService;
@Transactional @Transactional
@Override @Override
public void createUserRouting(RunPlanRoutingVO routingVO) { public void createUserRouting(RunPlanRoutingVO routingVO) {
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO), "交路数据重复"); BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); "交路数据重复");
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
if (map.getCheckConfig().isCheck()) { SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), map);
"地图基础数据校验不通过"); if (map.getCheckConfig().isCheck()) {
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
"地图基础数据校验不通过");
}
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
setRoutingType(routingVO, deviceMap);
RunPlanRouting routing = routingVO.convert2Entity();
runPlanRoutingDAO.insert(routing);
createRoutingRefData(deviceMap, routingVO);
if (Objects.equals(RunPlanRoutingVO.UserRoutingType.LOOP, routingVO.getRoutingType())) {
RunPlanRoutingVO routingDataLoop = routingVO.getRoutingDataLoop();
try {
generateUserRoutingSections(routingDataLoop, deviceMap);
} catch (BaseException e) {
return;
}
if (routingDataExist(routingDataLoop)) {
return;
}
Section endSection = (Section) deviceMap.get(routingDataLoop.getEndSectionCode());
routingDataLoop.setDestinationCode(endSection.getDestinationCode());
runPlanRoutingDAO.insert(routingDataLoop.convert2Entity());
createRoutingRefData(deviceMap, routingDataLoop);
}
}
@Override
@Transactional
public void createDefaultRoutings(List<RunPlanRoutingVO> defaultRoutings) {
if (CollectionUtils.isEmpty(defaultRoutings)) {
return;
}
MapVO map = this.iMapService.getMapDetail(defaultRoutings.get(0).getMapId());
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
map);
// BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过");
if (CollectionUtils.isEmpty(buildResult.getErrMsgList())) {
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
defaultRoutings.forEach(routingVO -> {
routingVO.setUserId(null);
if (routingDataExist(routingVO)) {
return;
} }
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
setRoutingType(routingVO, deviceMap); setRoutingType(routingVO, deviceMap);
RunPlanRouting routing = routingVO.convert2Entity(); RunPlanRouting routing = routingVO.convert2Entity();
runPlanRoutingDAO.insert(routing); runPlanRoutingDAO.insert(routing);
createRoutingRefData(deviceMap, routingVO); });
if (Objects.equals(RunPlanRoutingVO.UserRoutingType.LOOP, routingVO.getRoutingType())) {
RunPlanRoutingVO routingDataLoop = routingVO.getRoutingDataLoop();
try {
generateUserRoutingSections(routingDataLoop, deviceMap);
}catch (BaseException e){
return;
}
if (routingDataExist(routingDataLoop)) return;
Section endSection = (Section) deviceMap.get(routingDataLoop.getEndSectionCode());
routingDataLoop.setDestinationCode(endSection.getDestinationCode());
runPlanRoutingDAO.insert(routingDataLoop.convert2Entity());
createRoutingRefData(deviceMap, routingDataLoop);
}
} }
}
@Override @Override
@Transactional @Transactional
public void createDefaultRoutings(List<RunPlanRoutingVO> defaultRoutings) { public void syncDefaultRoutingRefData(Long userId, Long mapId) {
if (CollectionUtils.isEmpty(defaultRoutings)) return; List<RunPlanRoutingVO> defaultRoutingVOs = getDefaultRoutings(mapId);
MapVO map = this.iMapService.getMapDetail(defaultRoutings.get(0).getMapId()); if (CollectionUtils.isEmpty(defaultRoutingVOs)) {
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); return;
// BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过");
if (CollectionUtils.isEmpty(buildResult.getErrMsgList())) {
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
defaultRoutings.forEach(routingVO -> {
routingVO.setUserId(null);
if (routingDataExist(routingVO)) return;
setRoutingType(routingVO, deviceMap);
RunPlanRouting routing = routingVO.convert2Entity();
runPlanRoutingDAO.insert(routing);
});
}
} }
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
@Override this.iMapService.getMapDetail(mapId));
@Transactional BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
public void syncDefaultRoutingRefData(Long userId, Long mapId) { "地图基础数据校验不通过");
List<RunPlanRoutingVO> defaultRoutingVOs = getDefaultRoutings(mapId); Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
if (CollectionUtils.isEmpty(defaultRoutingVOs)) return; //根据默认交路生成站间运行等级停站时间折返数据
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(this.iMapService.getMapDetail(mapId)); Set<RunPlanRunlevelVO> levelList = new HashSet<>(100);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过"); Set<RunPlanParkingTimeVO> parkingTimeList = new HashSet<>(30);
Map<String, MapElement> deviceMap = buildResult.getDeviceMap(); RunPlanUserConfigVO userConfig = planConfigService.getConfig(userId, mapId);
//根据默认交路生成站间运行等级停站时间折返数据 Map<String, RunPlanUserConfigVO.ReentryTime> reentryData;
Set<RunPlanRunlevelVO> levelList = new HashSet<>(100); if (Objects.nonNull(userConfig)) {
Set<RunPlanParkingTimeVO> parkingTimeList = new HashSet<>(30); reentryData = userConfig.getConfig().getReentryData();
RunPlanUserConfigVO userConfig = planConfigService.getConfig(userId, mapId); } else {
Map<String, RunPlanUserConfigVO.ReentryTime> reentryData; RunPlanUserConfigVO.Config config = new RunPlanUserConfigVO.Config();
if (Objects.nonNull(userConfig)) { reentryData = config.getReentryData();
reentryData = userConfig.getConfig().getReentryData(); userConfig = new RunPlanUserConfigVO(mapId, userId, config);
} else { }
RunPlanUserConfigVO.Config config = new RunPlanUserConfigVO.Config(); defaultRoutingVOs.forEach(routingVO -> {
reentryData = config.getReentryData(); routingVO.setUserId(userId);
userConfig = new RunPlanUserConfigVO(mapId, userId, config); List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
} levelList.addAll(levels.stream().filter(l -> {
defaultRoutingVOs.forEach(routingVO -> {
routingVO.setUserId(userId);
List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
levelList.addAll(levels.stream().filter(l -> {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
if ((startSection.isTurnBackTrack() && !startSection.isStandTrack())
|| (endSection.isTurnBackTrack() && !endSection.isStandTrack())) {
return false;
}
return true;
}).collect(Collectors.toList()));
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO);
parkingTimeVOS.forEach(p -> {
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
parkingTimeList.add(p);
}
});
setStationReentryTime(deviceMap, reentryData, routingVO);
}
);
//先简单插入新数据
List<RunPlanRunlevelVO> levels = planRunlevelService.queryUserRunLevels(userId, mapId);
levelList.removeAll(levels);
levelList.forEach(l -> {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())) { if ((startSection.isTurnBackTrack() && !startSection.isStandTrack())
Float distance; || (endSection.isTurnBackTrack() && !endSection.isStandTrack())) {
try { return false;
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
} catch (SimulationException e) {
distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight());
}
l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
return;
} }
Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); return true;
l.setDistance(distance); }).collect(Collectors.toList()));
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
});
List<RunPlanParkingTimeVO> parktimes = planParktimeService.queryUserParktimes(userId, mapId);
parkingTimeList.removeAll(parktimes);
parkingTimeList.forEach(p -> {
planParktimeService.createUserParktime(p);
});
planConfigService.saveConfig(userId, mapId, userConfig.getConfig());
}
private void setStationReentryTime(Map<String, MapElement> deviceMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, RunPlanRoutingVO routingVO) { List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode()); routingVO);
if (startSection.isTurnBackTrack()) { parkingTimeVOS.forEach(p -> {
reentryData.putIfAbsent(routingVO.getStartStationCode(), new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45)); if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
parkingTimeList.add(p);
}
});
setStationReentryTime(deviceMap, reentryData, routingVO);
} }
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode()); );
if (endSection.isTurnBackTrack()) { //先简单插入新数据
reentryData.putIfAbsent(routingVO.getEndStationCode(), new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45)); List<RunPlanRunlevelVO> levels = planRunlevelService.queryUserRunLevels(userId, mapId);
levelList.removeAll(levels);
levelList.forEach(l -> {
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (
endSection.isStandTrack() && startSection.isTransferTrack())) {
Float distance;
try {
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
} catch (SimulationException e) {
distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight());
} }
} l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
return;
}
Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
});
List<RunPlanParkingTimeVO> parktimes = planParktimeService.queryUserParktimes(userId, mapId);
parkingTimeList.removeAll(parktimes);
parkingTimeList.forEach(p -> {
planParktimeService.createUserParktime(p);
});
planConfigService.saveConfig(userId, mapId, userConfig.getConfig());
}
private void createRoutingRefData(Map<String, MapElement> deviceMap, RunPlanRoutingVO routingVO) { private void setStationReentryTime(Map<String, MapElement> deviceMap,
generateUserRunlevels(routingVO, deviceMap); Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, RunPlanRoutingVO routingVO) {
generateUserParktimes(routingVO, deviceMap); Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
generateUserStationReentryTimes(routingVO, deviceMap); if (startSection.isTurnBackTrack()) {
reentryData.putIfAbsent(routingVO.getStartStationCode(),
new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
} }
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
if (endSection.isTurnBackTrack()) {
reentryData.putIfAbsent(routingVO.getEndStationCode(),
new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
}
}
@Override private void createRoutingRefData(Map<String, MapElement> deviceMap, RunPlanRoutingVO routingVO) {
public RunPlanRoutingVO generateUserRoutingData(RunPlanRoutingVO routingVO) { generateUserRunlevels(routingVO, deviceMap);
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); generateUserParktimes(routingVO, deviceMap);
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); generateUserStationReentryTimes(routingVO, deviceMap);
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), }
"地图基础数据校验不通过");
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
generateUserRoutingSections(routingVO, deviceMap);
return routingVO;
}
@Override @Override
public List<RunPlanRoutingVO> queryRoutes(Long mapId, RunPlanRoutingQueryVO queryVO, AccountVO user) { public RunPlanRoutingVO generateUserRoutingData(RunPlanRoutingVO routingVO) {
return getUserRoutingBy(user.getId(), mapId).stream() MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
.filter(routing -> Objects.equals(routing.getDestinationCode(), queryVO.getDestinationCode())) SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
.collect(Collectors.toList()); map);
} BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
"地图基础数据校验不通过");
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
generateUserRoutingSections(routingVO, deviceMap);
return routingVO;
}
private void generateUserRoutingSections(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { @Override
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode()); public List<RunPlanRoutingVO> queryRoutes(Long mapId, RunPlanRoutingQueryVO queryVO,
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode()); AccountVO user) {
//中间经停所有站台轨 return getUserRoutingBy(user.getId(), mapId).stream()
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection, endSection, routingVO.getRight()); .filter(
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack, routing -> Objects.equals(routing.getDestinationCode(), queryVO.getDestinationCode()))
String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路", routingVO.getRight() ? "右向" : "左向")); .collect(Collectors.toList());
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode())).collect(Collectors.toCollection(LinkedList::new)); }
parkSectionCodeList.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(), routingVO.getStartSectionCode()));
parkSectionCodeList.addLast(new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
routingVO.setParkSectionCodeList(parkSectionCodeList);
}
@Override private void generateUserRoutingSections(RunPlanRoutingVO routingVO,
public RunPlanRoutingVO getUserRouting(Long routingId) { Map<String, MapElement> deviceMap) {
RunPlanRouting routing = getRunPlanRoutingData(routingId); Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
return RunPlanRoutingVO.convert2VO(routing); Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
} //中间经停所有站台轨
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection,
endSection, routingVO.getRight());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack,
String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路",
routingVO.getRight() ? "右向" : "左向"));
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(
section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode()))
.collect(Collectors.toCollection(LinkedList::new));
parkSectionCodeList.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(),
routingVO.getStartSectionCode()));
parkSectionCodeList.addLast(
new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
routingVO.setParkSectionCodeList(parkSectionCodeList);
}
@Transactional @Override
@Override public RunPlanRoutingVO getUserRouting(Long routingId) {
public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) { RunPlanRouting routing = getRunPlanRoutingData(routingId);
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId()); return RunPlanRoutingVO.convert2VO(routing);
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map); }
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
"地图基础数据校验不通过"); @Transactional
Map<String, MapElement> deviceMap = buildResult.getDeviceMap(); @Override
setRoutingType(routingVO, deviceMap); public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) {
RunPlanRouting newRouting = routingVO.convert2Entity(); MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
newRouting.setId(routingId); SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
RunPlanRouting routing = getRunPlanRoutingData(routingId); map);
if(Objects.equals(routing.getSectionData(),JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList()))){ BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
runPlanRoutingDAO.updateByPrimaryKey(newRouting); "地图基础数据校验不通过");
return; Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
} setRoutingType(routingVO, deviceMap);
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO), "交路数据重复"); RunPlanRouting newRouting = routingVO.convert2Entity();
runPlanRoutingDAO.updateByPrimaryKeyWithBLOBs(newRouting); newRouting.setId(routingId);
generateUserRunlevels(routingVO, deviceMap); RunPlanRouting routing = getRunPlanRoutingData(routingId);
generateUserParktimes(routingVO, deviceMap); if (Objects.equals(routing.getSectionData(),
generateUserStationReentryTimes(routingVO, deviceMap); JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList()))) {
runPlanRoutingDAO.updateByPrimaryKey(newRouting);
return;
} }
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),
"交路数据重复");
runPlanRoutingDAO.updateByPrimaryKeyWithBLOBs(newRouting);
generateUserRunlevels(routingVO, deviceMap);
generateUserParktimes(routingVO, deviceMap);
generateUserStationReentryTimes(routingVO, deviceMap);
}
private void setRoutingType(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { private void setRoutingType(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode()); Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
@ -268,175 +310,200 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
} }
} }
private void generateUserParktimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { private void generateUserParktimes(RunPlanRoutingVO routingVO,
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO); Map<String, MapElement> deviceMap) {
parkingTimeVOS.forEach(p -> { List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) { routingVO);
planParktimeService.createUserParktime(p); parkingTimeVOS.forEach(p -> {
} if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
}); planParktimeService.createUserParktime(p);
} }
});
}
private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) { private void generateUserRunlevels(RunPlanRoutingVO routingVO,
List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO); Map<String, MapElement> deviceMap) {
levels.forEach(l -> { List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); levels.forEach(l -> {
Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
if ((startSection.isTurnBackTrack() && !startSection.isStandTrack()) Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
|| (endSection.isTurnBackTrack() && !endSection.isStandTrack())) { if ((startSection.isTurnBackTrack() && !startSection.isStandTrack())
return; || (endSection.isTurnBackTrack() && !endSection.isStandTrack())) {
} return;
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())) { }
Float distance; if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (
try { endSection.isStandTrack() && startSection.isTransferTrack())) {
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); Float distance;
} catch (SimulationException e) { try {
distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight()); distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
} } catch (SimulationException e) {
l.setDistance(distance); distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight());
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
return;
}
Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
});
}
private void generateUserStationReentryTimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
RunPlanUserConfigVO userConfig = planConfigService.getConfig(routingVO.getUserId(), routingVO.getMapId());
Map<String, RunPlanUserConfigVO.ReentryTime> reentryData;
if (Objects.nonNull(userConfig)) {
reentryData = userConfig.getConfig().getReentryData();
}else{
RunPlanUserConfigVO.Config config = new RunPlanUserConfigVO.Config();
reentryData = config.getReentryData();
userConfig = new RunPlanUserConfigVO( routingVO.getMapId(),routingVO.getUserId(),config);
} }
//交路是折返轨的一头 设置折返时间 l.setDistance(distance);
setStationReentryTime(deviceMap, reentryData, routingVO); l.generateDefaultRunLevel();
planConfigService.saveConfig(routingVO.getUserId(), routingVO.getMapId(),userConfig.getConfig()); planRunlevelService.createUserRunlevel(l);
return;
}
Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
l.setDistance(distance);
l.generateDefaultRunLevel();
planRunlevelService.createUserRunlevel(l);
});
}
private void generateUserStationReentryTimes(RunPlanRoutingVO routingVO,
Map<String, MapElement> deviceMap) {
RunPlanUserConfigVO userConfig = planConfigService.getConfig(routingVO.getUserId(),
routingVO.getMapId());
Map<String, RunPlanUserConfigVO.ReentryTime> reentryData;
if (Objects.nonNull(userConfig)) {
reentryData = userConfig.getConfig().getReentryData();
} else {
RunPlanUserConfigVO.Config config = new RunPlanUserConfigVO.Config();
reentryData = config.getReentryData();
userConfig = new RunPlanUserConfigVO(routingVO.getMapId(), routingVO.getUserId(), config);
} }
//交路是折返轨的一头 设置折返时间
setStationReentryTime(deviceMap, reentryData, routingVO);
planConfigService.saveConfig(routingVO.getUserId(), routingVO.getMapId(),
userConfig.getConfig());
}
@Override @Override
public void deleteUserRouting(Long routingId) { public void deleteUserRouting(Long routingId) {
runPlanRoutingDAO.deleteByPrimaryKey(routingId); runPlanRoutingDAO.deleteByPrimaryKey(routingId);
}
@Override
@Transactional
public void deleteDefaultRouting(Long mapId) {
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
runPlanRoutingDAO.deleteByExample(example);
}
@Override
public PageVO<RunPlanRoutingVO> queryPagedUserRouting(Long userId, Long mapId,
RunPlanRoutingQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.setOrderByClause("user_id DESC,id");
RunPlanRoutingExample.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
RunPlanRoutingExample.Criteria or = example.or();
or.andMapIdEqualTo(mapId).andUserIdIsNull();
if (StringUtils.hasText(queryVO.getStartStationCode())) {
criteria.andStartStationCodeEqualTo(queryVO.getStartStationCode());
or.andStartStationCodeEqualTo(queryVO.getStartStationCode());
} }
if (StringUtils.hasText(queryVO.getEndStationCode())) {
@Override criteria.andEndStationCodeEqualTo(queryVO.getEndStationCode());
@Transactional or.andEndStationCodeEqualTo(queryVO.getEndStationCode());
public void deleteDefaultRouting(Long mapId) {
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
runPlanRoutingDAO.deleteByExample(example);
} }
if (StringUtils.hasText(queryVO.getStartSectionCode())) {
@Override criteria.andStartSectionCodeEqualTo(queryVO.getStartSectionCode());
public PageVO<RunPlanRoutingVO> queryPagedUserRouting(Long userId, Long mapId, RunPlanRoutingQueryVO queryVO) { or.andStartSectionCodeEqualTo(queryVO.getStartSectionCode());
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.setOrderByClause("user_id DESC,id");
RunPlanRoutingExample.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
RunPlanRoutingExample.Criteria or = example.or();
or.andMapIdEqualTo(mapId).andUserIdIsNull();
if (StringUtils.hasText(queryVO.getStartStationCode())) {
criteria.andStartStationCodeEqualTo(queryVO.getStartStationCode());
or.andStartStationCodeEqualTo(queryVO.getStartStationCode());
}
if (StringUtils.hasText(queryVO.getEndStationCode())) {
criteria.andEndStationCodeEqualTo(queryVO.getEndStationCode());
or.andEndStationCodeEqualTo(queryVO.getEndStationCode());
}
if (StringUtils.hasText(queryVO.getStartSectionCode())) {
criteria.andStartSectionCodeEqualTo(queryVO.getStartSectionCode());
or.andStartSectionCodeEqualTo(queryVO.getStartSectionCode());
}
if (StringUtils.hasText(queryVO.getEndSectionCode())) {
criteria.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
or.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
}
Page<RunPlanRouting> page = (Page<RunPlanRouting>) runPlanRoutingDAO.selectByExampleWithBLOBs(example);
List<RunPlanRoutingVO> routingVOList = page.getResult().stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(page, routingVOList);
} }
if (StringUtils.hasText(queryVO.getEndSectionCode())) {
public List<RunPlanRoutingVO> getDefaultRoutings(Long mapId) { criteria.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
RunPlanRoutingExample example = new RunPlanRoutingExample(); or.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings);
} }
Page<RunPlanRouting> page = (Page<RunPlanRouting>) runPlanRoutingDAO.selectByExampleWithBLOBs(
example);
List<RunPlanRoutingVO> routingVOList = page.getResult().stream()
.map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
return PageVO.convert(page, routingVOList);
}
public List<RunPlanRoutingVO> getDefaultRoutings(Long mapId) {
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings);
}
@Override @Override
public List<RunPlanRoutingVO> getUserRoutingBy(Long userId, Long mapId) { public List<RunPlanRoutingVO> getUserRoutingBy(Long userId, Long mapId) {
RunPlanRoutingExample example = new RunPlanRoutingExample(); RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId); example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
example.or().andMapIdEqualTo(mapId).andUserIdIsNull(); example.or().andMapIdEqualTo(mapId).andUserIdIsNull();
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExample(example); List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExample(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId)); return RunPlanRoutingVO.convert2VOList(runPlanRoutings, this.iMapService.getMapDetail(mapId));
}
@Override
public List<RunPlanRoutingVO> getUserRoutingByType(Long userId, Long mapId,
RunPlanRoutingVO.UserRoutingType routingType) {
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId)
.andTypeEqualTo(routingType.name());
example.or().andMapIdEqualTo(mapId).andUserIdIsNull().andTypeEqualTo(routingType.name());
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings, this.iMapService.getMapDetail(mapId));
}
@Override
public RunPlanRoutingVO queryUserRoutingBySDTNumber(Long userId, Long planId, String SDTNumber) {
RunPlanVO planVO = this.getRunPlanById(planId);
RunPlanTripVO trip = planVO.getTripList().stream()
.filter(tripVO -> tripVO.getSDTNumberNew().equals(SDTNumber))
.findFirst()
.orElseThrow(() -> BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception());
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId)
.andStartSectionCodeEqualTo(trip.getStartSectionCode())
.andEndSectionCodeEqualTo(trip.getEndSectionCode());
example.or().andMapIdEqualTo(planVO.getMapId()).andUserIdIsNull()
.andStartSectionCodeEqualTo(trip.getStartSectionCode())
.andEndSectionCodeEqualTo(trip.getEndSectionCode());
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
if (CollectionUtils.isEmpty(runPlanRoutings)) {
return null;
} }
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0),
this.iMapService.getMapDetail(planVO.getMapId()));
}
@Override @Override
public List<RunPlanRoutingVO> getUserRoutingByType(Long userId, Long mapId, RunPlanRoutingVO.UserRoutingType routingType) { public RunPlanRoutingVO queryUserRoutingById(Long userId, Long mapId, Long routingId) {
RunPlanRoutingExample example = new RunPlanRoutingExample(); RunPlanRouting runPlanRouting = getRunPlanRoutingData(routingId);
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId).andTypeEqualTo(routingType.name()); return RunPlanRoutingVO.convert2VO(runPlanRouting, this.iMapService.getMapDetail(mapId));
example.or().andMapIdEqualTo(mapId).andUserIdIsNull().andTypeEqualTo(routingType.name()); }
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId)); @Override
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long routingId) {
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
if (Objects.isNull(routing)) {
return Collections.emptyList();
} }
return RunPlanRoutingVO.convert2VO(routing).getParkSectionCodeList();
}
@Override
public RunPlanRoutingVO queryUserRoutingBySDTNumber(Long userId, Long planId, String SDTNumber) { private boolean routingDataExist(RunPlanRoutingVO routingVO) {
RunPlanVO planVO = this.getRunPlanById(planId); return
RunPlanTripVO trip = planVO.getTripList().stream() runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(),
.filter(tripVO -> tripVO.getSDTNumberNew().equals(SDTNumber)) JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0;
.findFirst() }
.orElseThrow(() -> BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception());
RunPlanRoutingExample example = new RunPlanRoutingExample(); private RunPlanRouting getRunPlanRoutingData(Long routingId) {
example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId).andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode()); RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
example.or().andMapIdEqualTo(planVO.getMapId()).andUserIdIsNull().andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode()); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(routing,
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example); String.format("交路[%s]不存在", routingId));
if (CollectionUtils.isEmpty(runPlanRoutings)) return null; return routing;
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0), this.iMapService.getMapDetail(planVO.getMapId())); }
}
private RunPlanVO getRunPlanById(Long planId) {
@Override RunPlanDraft runPlanDraft = this.runPlanDraftDAO.selectByPrimaryKey(planId);
public RunPlanRoutingVO queryUserRoutingById(Long userId, Long mapId, Long routingId) { BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanDraft);
RunPlanRouting runPlanRouting = getRunPlanRoutingData(routingId); RunPlanVO runPlanVO = new RunPlanVO(runPlanDraft);
return RunPlanRoutingVO.convert2VO(runPlanRouting,this.iMapService.getMapDetail(mapId)); if (StringUtils.hasText(runPlanDraft.getTrips())) {
} runPlanVO.setTripList(JsonUtils.read(runPlanDraft.getTrips(),
JsonUtils.getCollectionType(List.class, RunPlanTripVO.class)));
@Override } else {
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long routingId) { runPlanVO.setTripList(new ArrayList<>());
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
if (Objects.isNull(routing)) return Collections.emptyList();
return RunPlanRoutingVO.convert2VO(routing).getParkSectionCodeList();
}
private boolean routingDataExist(RunPlanRoutingVO routingVO) {
return runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(), JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0;
}
private RunPlanRouting getRunPlanRoutingData(Long routingId) {
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(routing, String.format("交路[%s]不存在", routingId));
return routing;
}
private RunPlanVO getRunPlanById(Long planId) {
RunPlanDraft runPlanDraft = this.runPlanDraftDAO.selectByPrimaryKey(planId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanDraft);
RunPlanVO runPlanVO = new RunPlanVO(runPlanDraft);
if (StringUtils.hasText(runPlanDraft.getTrips())) {
runPlanVO.setTripList(JsonUtils.read(runPlanDraft.getTrips(), JsonUtils.getCollectionType(List.class, RunPlanTripVO.class)));
} else {
runPlanVO.setTripList(new ArrayList<>());
}
return runPlanVO;
} }
return runPlanVO;
}
} }

View File

@ -7,104 +7,82 @@ import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.vo.training2.draft.DraftTraining2InfoVo; import club.joylink.rtss.vo.training2.draft.DraftTraining2InfoVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoRspVo; import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoRspVo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
public class Training2Convertor { public class Training2Convertor {
public static DraftTraining2InfoVo convertFrom(DraftTraining2 dt) {
DraftTraining2InfoVo ti = new DraftTraining2InfoVo();
ti.setCreateTime(dt.getCreateTime());
ti.setCreatorId(dt.getCreatorId());
ti.setId(dt.getId());
ti.setDescription(dt.getDescription());
ti.setLabelJson(dt.getLabelJson());
ti.setMapId(dt.getMapId());
ti.setName(dt.getName());
ti.setUpdateTime(dt.getUpdateTime());
ti.setType(dt.getType());
ti.setClient(dt.getClient());
return ti;
}
public static DraftTraining2InfoVo convertFrom(DraftTraining2 dt) { /**
DraftTraining2InfoVo ti = new DraftTraining2InfoVo(); * 实训草稿转化为已发布实训注意已发布实训的状态为上架且已发布实训的id为空(数据库自动生成)
ti.setCreateTime(dt.getCreateTime()); */
ti.setCreatorId(dt.getCreatorId()); public static PublishedTraining2WithBLOBs convertFrom(DraftTraining2WithBLOBs from) {
ti.setId(dt.getId()); PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
ti.setDescription(dt.getDescription()); //
ti.setLabelJson(dt.getLabelJson()); pub.setState(PublishedTraining2StateEnum.PutOn.getState());
ti.setMapId(dt.getMapId()); //
ti.setName(dt.getName()); pub.setMemberJson(null == from.getMemberJson() ? "" : from.getMemberJson());
ti.setUpdateTime(dt.getUpdateTime()); pub.setBgSceneJson(null == from.getBgSceneJson() ? "" : from.getBgSceneJson());
ti.setType(dt.getType()); pub.setOperaJson(null == from.getOperaJson() ? "" : from.getOperaJson());
ti.setClient(dt.getClient()); pub.setDescription(null == from.getDescription() ? "" : from.getDescription());
return ti; pub.setCreateTime(LocalDateTime.now());
} pub.setUpdateTime(LocalDateTime.now());
pub.setCreatorId(from.getCreatorId());
pub.setName(null == from.getName() ? "" : from.getName());
pub.setPlayerIdJson(null == from.getPlayerIdJson() ? "" : from.getPlayerIdJson());
pub.setScoringRuleJson(null == from.getScoringRuleJson() ? "" : from.getScoringRuleJson());
pub.setStepJson(null == from.getStepJson() ? "" : from.getStepJson());
pub.setFailureConditionJson(null == from.getFailureConditionJson() ? "" : from.getFailureConditionJson());
pub.setLabelJson(null == from.getLabelJson() ? "" : from.getLabelJson());
pub.setMapId(from.getMapId());
pub.setMapLocationJson(null == from.getMapLocationJson() ? "" : from.getMapLocationJson());
pub.setType(null == from.getType() ? "" : from.getType());
pub.setRunPlanId(from.getRunPlanId());
pub.setClient(from.getClient());
//
return pub;
}
/** public static List<PublishedTraining2InfoRspVo> convertFrom(List<PublishedTraining2> froms) {
* 实训草稿转化为已发布实训注意已发布实训的状态为上架且已发布实训的id为空(数据库自动生成) List<PublishedTraining2InfoRspVo> list = Lists.newArrayList();
*/ froms.forEach(d -> list.add(convertFrom(d)));
public static PublishedTraining2WithBLOBs convertFrom(DraftTraining2WithBLOBs from) { return list;
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs(); }
//
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
//
pub.setMemberJson(null == from.getMemberJson() ? "" : from.getMemberJson());
pub.setBgSceneJson(null == from.getBgSceneJson() ? "" : from.getBgSceneJson());
pub.setOperaJson(null == from.getOperaJson() ? "" : from.getOperaJson());
pub.setDescription(null == from.getDescription() ? "" : from.getDescription());
pub.setCreateTime(LocalDateTime.now());
pub.setUpdateTime(LocalDateTime.now());
pub.setCreatorId(from.getCreatorId());
pub.setName(null == from.getName() ? "" : from.getName());
pub.setPlayerIdJson(null == from.getPlayerIdJson() ? "" : from.getPlayerIdJson());
pub.setScoringRuleJson(null == from.getScoringRuleJson() ? "" : from.getScoringRuleJson());
pub.setStepJson(null == from.getStepJson() ? "" : from.getStepJson());
pub.setFailureConditionJson(
null == from.getFailureConditionJson() ? "" : from.getFailureConditionJson());
pub.setLabelJson(null == from.getLabelJson() ? "" : from.getLabelJson());
pub.setMapId(from.getMapId());
pub.setMapLocationJson(null == from.getMapLocationJson() ? "" : from.getMapLocationJson());
pub.setType(null == from.getType() ? "" : from.getType());
pub.setRunPlanId(from.getRunPlanId());
pub.setClient(from.getClient());
//
return pub;
}
public static List<PublishedTraining2InfoRspVo> convertFrom(List<PublishedTraining2> froms) { public static PublishedTraining2InfoRspVo convertFrom(PublishedTraining2 from) {
List<PublishedTraining2InfoRspVo> list = Lists.newArrayList(); PublishedTraining2InfoRspVo rsp = new PublishedTraining2InfoRspVo();
froms.forEach(d -> list.add(convertFrom(d))); rsp.setCreateTime(from.getCreateTime());
return list; rsp.setDescription(from.getDescription());
} rsp.setCreatorId(from.getCreatorId());
rsp.setId(from.getId());
public static PublishedTraining2InfoRspVo convertFrom(PublishedTraining2 from) { rsp.setName(from.getName());
PublishedTraining2InfoRspVo rsp = new PublishedTraining2InfoRspVo(); rsp.setLabelJson(from.getLabelJson());
rsp.setCreateTime(from.getCreateTime()); rsp.setMapId(from.getMapId());
rsp.setDescription(from.getDescription()); rsp.setPlayerIdJson(from.getPlayerIdJson());
rsp.setCreatorId(from.getCreatorId()); rsp.setType(from.getType());
rsp.setId(from.getId()); rsp.setFailureConditionJson(from.getFailureConditionJson());
rsp.setName(from.getName()); rsp.setUpdateTime(from.getUpdateTime());
rsp.setLabelJson(from.getLabelJson()); rsp.setRunPlanId(from.getRunPlanId());
rsp.setMapId(from.getMapId()); rsp.setMapLocationJson(from.getMapLocationJson());
rsp.setPlayerIdJson(from.getPlayerIdJson()); rsp.setState(from.getState());
rsp.setType(from.getType()); rsp.setClient(from.getClient());
rsp.setFailureConditionJson(from.getFailureConditionJson()); rsp.setShared(from.getShared());
rsp.setUpdateTime(from.getUpdateTime()); rsp.setOrgId(from.getOrgId());
rsp.setRunPlanId(from.getRunPlanId()); return rsp;
rsp.setMapLocationJson(from.getMapLocationJson()); }
rsp.setState(from.getState());
rsp.setClient(from.getClient());
rsp.setShared(from.getShared());
rsp.setOrgId(from.getOrgId());
return rsp;
}
public static DraftTraining2WithBLOBs convertFrom(PublishedTraining2WithBLOBs from) {
DraftTraining2WithBLOBs dtb = new DraftTraining2WithBLOBs();
dtb.setName(from.getName());
dtb.setMapId(from.getMapId());
// map_systemterminal
dtb.setDescription(from.getDescription());
dtb.setType(from.getType());
dtb.setLabelJson(from.getLabelJson());
dtb.setMapLocationJson(from.getMapLocationJson());
dtb.setBgSceneJson(from.getBgSceneJson());
dtb.setRunPlanId(from.getRunPlanId());
dtb.setOperaJson(from.getOperaJson());
dtb.setStepJson(from.getStepJson());
dtb.setScoringRuleJson(from.getScoringRuleJson());
dtb.setMemberJson(from.getMemberJson());
dtb.setPlayerIdJson(from.getPlayerIdJson());
dtb.setFailureConditionJson(from.getFailureConditionJson());
dtb.setClient(from.getClient());
return dtb;
}
} }

View File

@ -3,110 +3,82 @@ package club.joylink.rtss.services.training2;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.DraftTraining2DAO; import club.joylink.rtss.dao.DraftTraining2DAO;
import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.dao.PublishedTraining2DAO;
import club.joylink.rtss.entity.training2.DraftTraining2; import club.joylink.rtss.entity.training2.*;
import club.joylink.rtss.entity.training2.DraftTraining2Example;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.training2.draft.TrainingDraftPublishReqVo; import club.joylink.rtss.vo.training2.draft.TrainingDraftPublishReqVo;
import java.time.LocalDateTime;
import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* 实训草稿发布业务实现 * 实训草稿发布业务实现
*/ */
@Service @Service
@Slf4j @Slf4j
public class Training2DraftPublishService { public class Training2DraftPublishService {
@Autowired
private DraftTraining2DAO trainingDao;
@Autowired
private PublishedTraining2DAO publishedDao;
@Autowired
private Training2TraceService training2TraceService;
@Autowired /**
private DraftTraining2DAO trainingDao; * 草稿发布
@Autowired */
private PublishedTraining2DAO publishedDao; @Transactional(rollbackFor = Exception.class)
@Autowired public void draftPublish(TrainingDraftPublishReqVo req, Long userId,Long orgId) {
private Training2TraceService training2TraceService; Long draftId = Long.valueOf(req.getDraftId());
DraftTraining2Example dtExample = new DraftTraining2Example();
/** dtExample.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(draftId);
* 草稿发布 List<DraftTraining2WithBLOBs> dtFinds = this.trainingDao.selectByExampleWithBLOBs(dtExample);
*/ BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != dtFinds && !dtFinds.isEmpty(), "实训草稿不存在");
@Transactional(rollbackFor = Exception.class) DraftTraining2WithBLOBs draft = dtFinds.get(0);
public void draftPublish(TrainingDraftPublishReqVo req, Long userId, Long orgId) { //
Long draftId = Long.valueOf(req.getDraftId()); PublishedTraining2WithBLOBs pub = Training2Convertor.convertFrom(draft);
DraftTraining2Example dtExample = new DraftTraining2Example(); //加入共享默认不共享
dtExample.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(draftId); pub.setShared(BusinessConsts.STATUS_NOT_USE_INT);
List<DraftTraining2WithBLOBs> dtFinds = this.trainingDao.selectByExampleWithBLOBs(dtExample); if(null!=req.getReName()&&req.getReName().trim().length()>0){
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != dtFinds && !dtFinds.isEmpty(), pub.setName(req.getReName());
"实训草稿不存在"); }
DraftTraining2WithBLOBs draft = dtFinds.get(0); //根据要发布的草稿名称来查找已发布的实训
// //如果以有同名的则会被覆盖
PublishedTraining2WithBLOBs pub = Training2Convertor.convertFrom(draft); PublishedTraining2Example ptExample = new PublishedTraining2Example();
//加入共享默认不共享 ptExample.createCriteria().andNameEqualTo(pub.getName()).andMapIdEqualTo(pub.getMapId());
pub.setShared(BusinessConsts.STATUS_NOT_USE_INT); List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
if (null != req.getReName() && req.getReName().trim().length() > 0) { pub.setOrgId(orgId);
pub.setName(req.getReName()); //
if(null==ptFinds||ptFinds.isEmpty()){//同地图同名已发布实训不存在则直接存入
//发布
this.publishedDao.insertSelective(pub);
}else{//同地图同名已发布实训存在
if(ptFinds.size()>1){//当有多个存在时则全部删除再存入
this.publishedDao.deleteByExample(ptExample);
this.publishedDao.insertSelective(pub);
}else{//当有且仅有一个时直接更新
PublishedTraining2 old = ptFinds.get(0);
pub.setId(old.getId());
this.publishedDao.updateByPrimaryKeySelective(pub);
}
}
//记录发布轨迹
final PublishedTraining2 tracePub = this.findByNameAndMapId(pub.getName(),pub.getMapId());
final DraftTraining2 traceDraft = draft;
this.training2TraceService.addTrace(traceDraft,tracePub,userId);
} }
//根据要发布的草稿名称来查找已发布的实训 @Transactional(readOnly = true)
//如果以有同名的则会被覆盖 public PublishedTraining2 findByNameAndMapId(String name,Long mapId){
PublishedTraining2Example ptExample = new PublishedTraining2Example(); PublishedTraining2Example ptExample = new PublishedTraining2Example();
ptExample.createCriteria().andNameEqualTo(pub.getName()).andMapIdEqualTo(pub.getMapId()); ptExample.createCriteria().andNameEqualTo(name).andMapIdEqualTo(mapId);
List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample); List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
pub.setOrgId(orgId); //
// if(null!=ptFinds){
if (null == ptFinds || ptFinds.isEmpty()) {//同地图同名已发布实训不存在则直接存入 BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(ptFinds.size()<=1, String.format("已发布实训[name=%s mapId=%s]不唯一!",name,mapId));
//发布 return ptFinds.get(0);
this.publishedDao.insertSelective(pub); }
} else {//同地图同名已发布实训存在 return null;
if (ptFinds.size() > 1) {//当有多个存在时则全部删除再存入
this.publishedDao.deleteByExample(ptExample);
this.publishedDao.insertSelective(pub);
} else {//当有且仅有一个时直接更新
PublishedTraining2 old = ptFinds.get(0);
pub.setId(old.getId());
this.publishedDao.updateByPrimaryKeySelective(pub);
}
} }
//记录发布轨迹
final PublishedTraining2 tracePub = this.findByNameAndMapId(pub.getName(), pub.getMapId());
final DraftTraining2 traceDraft = draft;
this.training2TraceService.addTrace(traceDraft, tracePub, userId);
}
@Transactional(readOnly = true)
public PublishedTraining2 findByNameAndMapId(String name, Long mapId) {
PublishedTraining2Example ptExample = new PublishedTraining2Example();
ptExample.createCriteria().andNameEqualTo(name).andMapIdEqualTo(mapId);
List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
//
if (null != ptFinds) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(ptFinds.size() <= 1,
String.format("已发布实训[name=%s mapId=%s]不唯一!", name, mapId));
return ptFinds.get(0);
}
return null;
}
/**
* 发布信息保存为草稿
*
* @param trainingId 发布ID
* @param userInfoVO 用户
*/
@Transactional(rollbackFor = Exception.class)
public void saveAsDraft(Long trainingId, LoginUserInfoVO userInfoVO) {
PublishedTraining2WithBLOBs b = this.publishedDao.selectByPrimaryKey(trainingId);
DraftTraining2WithBLOBs dtb = Training2Convertor.convertFrom(b);
dtb.setCreateTime(LocalDateTime.now());
dtb.setUpdateTime(LocalDateTime.now());
dtb.setCreatorId(userInfoVO.getAccountVO().getId());
this.trainingDao.insert(dtb);
}
} }

View File

@ -15,27 +15,9 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.paper.FindCountForQuestionReqVo; import club.joylink.rtss.vo.paper.FindCountForQuestionReqVo;
import club.joylink.rtss.vo.paper.PaperQType; import club.joylink.rtss.vo.paper.PaperQType;
import club.joylink.rtss.vo.training2.publish.DeletePublishedTraining2ReqVo; import club.joylink.rtss.vo.training2.publish.*;
import club.joylink.rtss.vo.training2.publish.DeletePublishedTraining2RspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2DetailRspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoPageReqVo;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2InfoRspVo;
import club.joylink.rtss.vo.training2.publish.PublishedTrainingListRspVo;
import club.joylink.rtss.vo.training2.publish.PullOffPublishedTraining2ReqVo;
import club.joylink.rtss.vo.training2.publish.PullOffPublishedTraining2RspVo;
import club.joylink.rtss.vo.training2.publish.PutOnPublishedTraining2ReqVo;
import club.joylink.rtss.vo.training2.publish.PutOnPublishedTraining2RspVo;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -43,489 +25,491 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 已发布实训管理业务实现 * 已发布实训管理业务实现
*/ */
@Service @Service
@Slf4j @Slf4j
public class Training2PublishService { public class Training2PublishService {
@Autowired
private PublishedTraining2DAO publishedDao;
@Autowired
private IMapService mapService;
@Autowired @Transactional(readOnly = true)
private PublishedTraining2DAO publishedDao; public PublishedTraining2 findById(Long id) {
@Autowired PublishedTraining2Example example = new PublishedTraining2Example();
private IMapService mapService; example.createCriteria().andIdEqualTo(id);
List<PublishedTraining2> find = this.publishedDao.selectByExample(example);
@Transactional(readOnly = true) return null != find && find.size() > 0 ? find.get(0) : null;
public PublishedTraining2 findById(Long id) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(id);
List<PublishedTraining2> find = this.publishedDao.selectByExample(example);
return null != find && find.size() > 0 ? find.get(0) : null;
}
/**
* 根据组织类型单操作实操标签获取对应的数量
*/
public Long queryCountForLabel(FindCountForQuestionReqVo reqVo) {
if (Objects.isNull(reqVo.getTrainingClient())) {
//单操没有选定客户端不查询数量
return 0L;
} }
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example, reqVo.getMapId(),
reqVo.getOrgId(), reqVo.getSubType().name().toUpperCase(), Arrays.asList(reqVo.getTags()),
reqVo.getTrainingClient());
return this.publishedDao.countByExample(example);
}
/** /**
* 根据 组织类型单操作实操 获取标签 * 根据组织类型单操作实操标签获取对应的数量
*/
public Collection<String> findAllLabel(Long mapId, Long orgId, String type,
PaperQType.TrainingClient client) {
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example, mapId, orgId, type,
null, client);
List<PublishedTraining2> dataList = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(dataList)) {
return Collections.emptyList();
}
return dataList.stream().map(PublishedTraining2::getLabelJson).filter(StringUtils::hasText)
.map(d -> {
List<String> l = JsonUtils.readCollection(d, List.class, String.class);
return l;
}).flatMap(Collection::stream).collect(Collectors.toSet());
}
public PublishedTraining2Example.Criteria basicQueryCriteria(PublishedTraining2Example example, */
Long mapId, Long orgId, String type, List<String> lables, PaperQType.TrainingClient client) { public Long queryCountForLabel(FindCountForQuestionReqVo reqVo){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId), if(Objects.isNull(reqVo.getTrainingClient())){
"请关联对应的线路"); //单操没有选定客户端不查询数量
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId), return 0L;
"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),
"查询类型信息不能为空");
PublishedTraining2Example.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId);
criteria.andOrgIdEqualTo(orgId);
criteria.andTypeEqualTo(type);
criteria.andStateEqualTo(BusinessConsts.STATUS_USE_INT);//上架
//查询共享的数据
PublishedTraining2Example.Criteria or = example.or();
or.andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(mapId);
or.andTypeEqualTo(type);
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT);
if (Objects.nonNull(client)) {
criteria.andClientEqualTo(client.name());
or.andClientEqualTo(client.name());
}
// or.andOrgIdNotEqualTo(orgId);
if (!CollectionUtils.isEmpty(lables)) {
for (String tag : lables) {
if (StringUtils.hasText(tag)) {
criteria.andLabelJsonLike(String.format("%%%s%%", tag));
or.andLabelJsonLike(String.format("%%%s%%", tag));
} }
} PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example,reqVo.getMapId(),reqVo.getOrgId(),reqVo.getSubType().name().toUpperCase(),Arrays.asList(reqVo.getTags()),reqVo.getTrainingClient());
return this.publishedDao.countByExample(example);
} }
return criteria;
}
/** /**
* 已发布实训分页列表 * 根据 组织类型单操作实操 获取标签
*/ */
@Transactional(readOnly = true) public Collection<String> findAllLabel(Long mapId, Long orgId, String type, PaperQType.TrainingClient client){
public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage( PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2InfoPageReqVo req) { PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example,mapId,orgId,type,null,client);
PageHelper.startPage(req.getPageNum(), req.getPageSize()); List<PublishedTraining2> dataList = this.publishedDao.selectByExample(example);
PublishedTraining2Example example = new PublishedTraining2Example(); if(CollectionUtils.isEmpty(dataList)){
PublishedTraining2Example.Criteria c = example.createCriteria(); return Collections.emptyList();
if (Objects.nonNull(req.getState())) { }
c.andStateEqualTo(req.getState()); return dataList.stream().map(PublishedTraining2::getLabelJson).filter(StringUtils::hasText).map(d->{
List<String> l = JsonUtils.readCollection(d,List.class,String.class);
return l;
}).flatMap(Collection::stream).collect(Collectors.toSet());
} }
if (Objects.nonNull(req.getOrgId())) {
c.andOrgIdEqualTo(req.getOrgId()); public PublishedTraining2Example.Criteria basicQueryCriteria(PublishedTraining2Example example, Long mapId, Long orgId, String type, List<String> lables, PaperQType.TrainingClient client){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId),"请关联对应的线路");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空");
PublishedTraining2Example.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId);
criteria.andOrgIdEqualTo(orgId);
criteria.andTypeEqualTo(type);
criteria.andStateEqualTo(BusinessConsts.STATUS_USE_INT);//上架
//查询共享的数据
PublishedTraining2Example.Criteria or = example.or();
or.andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(mapId);
or.andTypeEqualTo(type);
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT);
if(Objects.nonNull(client)){
criteria.andClientEqualTo(client.name());
or.andClientEqualTo(client.name());
}
// or.andOrgIdNotEqualTo(orgId);
if(!CollectionUtils.isEmpty(lables)){
for (String tag : lables) {
if(StringUtils.hasText(tag)){
criteria.andLabelJsonLike(String.format("%%%s%%", tag));
or.andLabelJsonLike(String.format("%%%s%%", tag));
}
}
}
return criteria;
} }
if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId()); /**
} * 已发布实训分页列表
if (Objects.nonNull(req.getMapId())) { */
c.andMapIdEqualTo(req.getMapId()); @Transactional(readOnly = true)
} public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage(PublishedTraining2InfoPageReqVo req) {
if (Objects.nonNull(req.getType())) { PageHelper.startPage(req.getPageNum(), req.getPageSize());
c.andTypeEqualTo(req.getType()); PublishedTraining2Example example = new PublishedTraining2Example();
} PublishedTraining2Example.Criteria c = example.createCriteria();
if (StringUtils.hasText(req.getName())) { if (Objects.nonNull(req.getState())) {
c.andNameLike(String.format("%%%s%%", req.getName())); c.andStateEqualTo(req.getState());
} }
if (Objects.equals(false, CollectionUtils.isEmpty(req.getLabelLikes()))) { if (Objects.nonNull(req.getOrgId())) {
for (String ll : req.getLabelLikes()) { c.andOrgIdEqualTo(req.getOrgId());
c.andLabelJsonLike(String.format("%%%s%%", ll)); }
} if (Objects.nonNull(req.getMapId())) {
} c.andMapIdEqualTo(req.getMapId());
String orderBy = "create_time"; }
switch (req.getOrderBy()) { if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId());
}
if (Objects.nonNull(req.getType())) {
c.andTypeEqualTo(req.getType());
}
if (StringUtils.hasText(req.getName())) {
c.andNameLike(String.format("%%%s%%", req.getName()));
}
if (Objects.equals(false, CollectionUtils.isEmpty(req.getLabelLikes()))) {
for (String ll : req.getLabelLikes()) {
c.andLabelJsonLike(String.format("%%%s%%", ll));
}
}
String orderBy = "create_time";
switch (req.getOrderBy()) {
// case 1:orderBy="create_time";break; // case 1:orderBy="create_time";break;
case 2: case 2:
orderBy = "update_time"; orderBy = "update_time";
break; break;
case 3: case 3:
orderBy = "name"; orderBy = "name";
break; break;
case 4: case 4:
orderBy = "state"; orderBy = "state";
break; break;
} }
if (req.getDesc()) { if (req.getDesc()) {
example.setOrderByClause(String.format(" %s desc", orderBy)); example.setOrderByClause(String.format(" %s desc", orderBy));
} }
Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample( Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample(example);
example); List<PublishedTraining2InfoRspVo> tmpList = Training2Convertor.convertFrom(page.getResult());
List<PublishedTraining2InfoRspVo> tmpList = Training2Convertor.convertFrom(page.getResult());
return PageVO.convert(page, tmpList); return PageVO.convert(page, tmpList);
}
/**
* 已发布实训上架
*/
@Transactional(rollbackFor = Exception.class)
public PutOnPublishedTraining2RspVo putOnPublishedTrainings(PutOnPublishedTraining2ReqVo req,
LoginUserInfoVO userInfoVO) {
final PutOnPublishedTraining2RspVo rsp = new PutOnPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if (CollectionUtils.isEmpty(req.getIds())) {
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
return rsp;
}
public void changeSharedStatus(Long id, Integer shared, LoginUserInfoVO userInfoVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id), "id信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(shared),
"未知共享类型");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
shared == BusinessConsts.STATUS_USE_INT || shared == BusinessConsts.STATUS_NOT_USE_INT,
"未知共享类型");
}
/**
* 已发布实训下架
*/
@Transactional(rollbackFor = Exception.class)
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(
PullOffPublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
final PullOffPublishedTraining2RspVo rsp = new PullOffPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if (CollectionUtils.isEmpty(req.getIds())) {
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PullOff.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
} }
return rsp; /**
} * 已发布实训上架
*/
/** @Transactional(rollbackFor = Exception.class)
* 删除已发布实训 public PutOnPublishedTraining2RspVo putOnPublishedTrainings(PutOnPublishedTraining2ReqVo req,LoginUserInfoVO userInfoVO) {
*/ final PutOnPublishedTraining2RspVo rsp = new PutOnPublishedTraining2RspVo();
@Transactional(rollbackFor = Exception.class) rsp.setIds(new ArrayList<>());
public DeletePublishedTraining2RspVo deletePublishedTrainings(DeletePublishedTraining2ReqVo req, if(CollectionUtils.isEmpty(req.getIds())){
LoginUserInfoVO userInfoVO) { return rsp;
DeletePublishedTraining2RspVo rsp = new DeletePublishedTraining2RspVo(); }
rsp.setIds(new ArrayList<>()); List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
if (CollectionUtils.isEmpty(req.getIds())) { for (Long newId : newIds) {
return rsp; PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
/* req.getIds().forEach(id -> {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(Long.valueOf(id));
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(id);
}
});*/
return rsp;
} }
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) { public void changeSharedStatus(Long id ,Integer shared,LoginUserInfoVO userInfoVO){
int drt = this.publishedDao.deleteByPrimaryKey(newId); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id),"id信息不能为空");
if (drt > 0) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(shared),"未知共享类型");
rsp.getIds().add(newId.toString()); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(shared == BusinessConsts.STATUS_USE_INT || shared == BusinessConsts.STATUS_NOT_USE_INT,"未知共享类型");
}
} }
return rsp; /**
} * 已发布实训下架
*/
@Transactional(rollbackFor = Exception.class)
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(PullOffPublishedTraining2ReqVo req,LoginUserInfoVO userInfoVO) {
final PullOffPublishedTraining2RspVo rsp = new PullOffPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if(CollectionUtils.isEmpty(req.getIds())){
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PullOff.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
private List<Long> pretreatmentFindData(List<String> ids, LoginUserInfoVO userInfoVO) { return rsp;
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
List<Long> idLong = ids.stream().map(Long::valueOf).collect(Collectors.toList());
criteria.andIdIn(idLong);
List<PublishedTraining2> t2 = this.publishedDao.selectByExample(example);
List<PublishedTraining2> notExeList = t2.stream().filter(
d -> Objects.equals(d.getOrgId(), userInfoVO.getTopOrgId()) && !Objects.equals(
d.getCreatorId(), userInfoVO.getAccountVO().getId()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(notExeList)) {
String names = notExeList.stream().map(d -> d.getName()).collect(Collectors.joining(","));
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(false,
String.format("共享数据[%s]不能删除", names));
} }
List<Long> findIds = t2.stream()
.filter(d -> Objects.equals(d.getOrgId(), userInfoVO.getTopOrgId()))
.map(d -> d.getId()).collect(Collectors.toList());
return findIds;
}
private PublishedTraining2Example.Criteria createQueryOrExample(PublishedTraining2Example example, /**
PublishedTrainingListRspVo reqVO, List<Long> mapIdList) { * 删除已发布实训
*/
@Transactional(rollbackFor = Exception.class)
public DeletePublishedTraining2RspVo deletePublishedTrainings(DeletePublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
DeletePublishedTraining2RspVo rsp = new DeletePublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if(CollectionUtils.isEmpty(req.getIds())){
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
for (Long newId : newIds) {
int drt = this.publishedDao.deleteByPrimaryKey(newId);
if (drt > 0) {
rsp.getIds().add(newId.toString());
}
}
/*req.getIds().forEach(id -> {
int drt = this.publishedDao.deleteByPrimaryKey(Long.valueOf(id));
if (drt > 0) {
rsp.getIds().add(id);
}
});*/
//
return rsp;
}
PublishedTraining2Example.Criteria criteria = example.createCriteria(); private List<Long> pretreatmentFindData(List<String> ids, LoginUserInfoVO userInfoVO){
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
List<Long> idLong = ids.stream().map(Long::valueOf).collect(Collectors.toList());
criteria.andIdIn(idLong);
List<PublishedTraining2> t2 = this.publishedDao.selectByExample(example);
List<PublishedTraining2> notExeList = t2.stream().filter(d->Objects.equals(d.getOrgId(),userInfoVO.getTopOrgId())).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(notExeList)){
String names = notExeList.stream().map(d->d.getName()).collect(Collectors.joining(","));
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(false,String.format("共享数据[%s]不能删除",names));
}
List<Long> findIds = t2.stream()
.filter(d->Objects.equals(d.getOrgId(),userInfoVO.getTopOrgId()))
.map(d->d.getId()).collect(Collectors.toList());
return findIds;
}
private PublishedTraining2Example.Criteria createQueryOrExample(PublishedTraining2Example example , PublishedTrainingListRspVo reqVO,List<Long> mapIdList){
PublishedTraining2Example.Criteria criteria = example.createCriteria();
// PublishedTraining2Example.Criteria or = example.or(); // PublishedTraining2Example.Criteria or = example.or();
if (reqVO.getMapId() != null) { if (reqVO.getMapId() != null) {
criteria.andMapIdEqualTo(reqVO.getMapId()); criteria.andMapIdEqualTo(reqVO.getMapId());
} else { }else{
criteria.andMapIdIn(mapIdList); criteria.andMapIdIn(mapIdList);
}
if (reqVO.getType() != null) {
criteria.andTypeEqualTo(reqVO.getType().value());
}
if(StringUtils.hasText(reqVO.getName())){
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
if(Objects.nonNull(reqVO.getState())){
criteria.andStateEqualTo(reqVO.getState());
}
if(!CollectionUtils.isEmpty(reqVO.getLabels())){
for (String label : reqVO.getLabels()) {
criteria.andLabelJsonLike(String.format("%%%s%%", label));
}
}
if (reqVO.getOrgId() != null) {
criteria.andOrgIdEqualTo(reqVO.getOrgId());
}
return criteria;
} }
if (reqVO.getType() != null) { /* private PublishedTraining2Example.Criteria createQueryExample(PublishedTraining2Example example ,PublishedTrainingListRspVo reqVO){
criteria.andTypeEqualTo(reqVO.getType().value());
}
if (StringUtils.hasText(reqVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
if (Objects.nonNull(reqVO.getState())) {
criteria.andStateEqualTo(reqVO.getState());
}
if (!CollectionUtils.isEmpty(reqVO.getLabels())) {
for (String label : reqVO.getLabels()) {
criteria.andLabelJsonLike(String.format("%%%s%%", label));
}
}
if (reqVO.getOrgId() != null) {
criteria.andOrgIdEqualTo(reqVO.getOrgId());
}
return criteria;
}
public PageVO<PublishedTraining2InfoRspVo> findTrainingInfoForPage( PublishedTraining2Example.Criteria criteria = example.createCriteria();
PublishedTrainingListRspVo reqVO, LoginUserInfoVO userInfoVO, boolean findSharedData) { if (reqVO.getMapId() != null) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO); criteria.andMapIdEqualTo(reqVO.getMapId());
List<Long> mapIdList = mapVOS.stream().map(d -> d.getId()).collect(Collectors.toList()); }
if (reqVO.getType() != null) {
criteria.andTypeEqualTo(reqVO.getType().value());
}
if(StringUtils.hasText(reqVO.getName())){
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
if(Objects.nonNull(reqVO.getState())){
criteria.andStateEqualTo(reqVO.getState());
}
if(!CollectionUtils.isEmpty(reqVO.getLabels())){
for (String label : reqVO.getLabels()) {
criteria.andLabelJsonLike(String.format("%%%s%%", label));
}
}
if (reqVO.getOrgId() != null) {
criteria.andOrgIdEqualTo(reqVO.getOrgId());
}
return criteria;
}*/
PublishedTraining2Example example = new PublishedTraining2Example(); public PageVO<PublishedTraining2InfoRspVo> findTrainingInfoForPage(PublishedTrainingListRspVo reqVO,LoginUserInfoVO userInfoVO,boolean findSharedData){
PublishedTraining2Example.Criteria criteria = this.createQueryOrExample(example, reqVO, List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
mapIdList); List<Long> mapIdList = mapVOS.stream().map(d->d.getId()).collect(Collectors.toList());
if (findSharedData) {
PublishedTraining2Example.Criteria or = example.or(); PublishedTraining2Example example = new PublishedTraining2Example();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT) PublishedTraining2Example.Criteria criteria = this.createQueryOrExample(example,reqVO,mapIdList);
.andSharedEqualTo(BusinessConsts.STATUS_USE_INT); if(findSharedData){
if (reqVO.getType() != null) { PublishedTraining2Example.Criteria or = example.or();
or.andTypeEqualTo(reqVO.getType().value()); or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
} if (reqVO.getType() != null) {
if (Objects.isNull(reqVO.getMapId())) { or.andTypeEqualTo(reqVO.getType().value());
or.andMapIdIn(mapIdList); }
} else { if(Objects.isNull(reqVO.getMapId())){
or.andMapIdIn(mapIdList);
}else{
or.andMapIdEqualTo(reqVO.getMapId());
}
// if(Objects.nonNull(reqVO.getOrgId())){
// or.andOrgIdNotEqualTo(reqVO.getOrgId());
// }
}
PageHelper.startPage(reqVO.getPageNum(), reqVO.getPageSize());
Page<PublishedTraining2> page = (Page<PublishedTraining2>)this.publishedDao.selectByExample(example);
if(page.isEmpty()){
return PageVO.convert(page,Collections.emptyList());
}
return PageVO.convert(page,Training2Convertor.convertFrom(page.getResult()));
}
/**
* 根据地图ID和类型查询实训列表
*/
public List<PublishedTraining2InfoRspVo> findTrainingInfo(PublishedTrainingListRspVo reqVO,LoginUserInfoVO userInfoVO) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
List<Long> mapIdList = mapVOS.stream().map(d->d.getId()).collect(Collectors.toList());
PublishedTraining2Example example = new PublishedTraining2Example();
this.createQueryOrExample(example,reqVO,mapIdList);
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(reqVO.getMapId()); or.andMapIdEqualTo(reqVO.getMapId());
} if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
}
// if(reqVO.getOrgId() !=null){
// or.andOrgIdNotEqualTo(reqVO.getOrgId());
// }
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return List.of();
} else {
return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList());
}
} }
PageHelper.startPage(reqVO.getPageNum(), reqVO.getPageSize());
Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample( /**
example); * 根据已发布实训的id来查询实现的所有信息
if (page.isEmpty()) { */
return PageVO.convert(page, Collections.emptyList()); @Transactional(readOnly = true)
public PublishedTraining2DetailRspVo findTrainingAllInfoById(Long trainingId) {
PublishedTraining2WithBLOBs b = this.publishedDao.selectByPrimaryKey(trainingId);
if (null != b) {
PublishedTraining2DetailRspVo rsp = new PublishedTraining2DetailRspVo();
//
rsp.setDescription(b.getDescription());
rsp.setFailureConditionJson(b.getFailureConditionJson());
rsp.setCreateTime(b.getCreateTime());
rsp.setCreatorId(b.getCreatorId());
rsp.setLabelJson(b.getLabelJson());
rsp.setMapId(b.getMapId());
rsp.setName(b.getName());
rsp.setId(b.getId());
rsp.setType(b.getType());
rsp.setBgSceneJson(b.getBgSceneJson());
rsp.setMemberJson(b.getMemberJson());
rsp.setOperaJson(b.getOperaJson());
rsp.setStepJson(b.getStepJson());
rsp.setUpdateTime(b.getUpdateTime());
rsp.setPlayerIdJson(b.getPlayerIdJson());
rsp.setMapLocationJson(b.getMapLocationJson());
rsp.setRunPlanId(b.getRunPlanId());
rsp.setScoringRuleJson(b.getScoringRuleJson());
rsp.setState(b.getState());
rsp.setClient(b.getClient());
//
return rsp;
}
return null;
} }
return PageVO.convert(page, Training2Convertor.convertFrom(page.getResult()));
}
/** /**
* 根据地图ID和类型查询实训列表 * 根据地图ID列表修改生成实训的组织ID
*/ */
public List<PublishedTraining2InfoRspVo> findTrainingInfo(PublishedTrainingListRspVo reqVO, public void updatePublishTrainingOrgIdByMapId(Long orgId, List<Long> mapIdList) {
LoginUserInfoVO userInfoVO) { if (!CollectionUtils.isEmpty(mapIdList)) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO); publishedDao.updateTrainingOrgByMapIdList(orgId, mapIdList);
List<Long> mapIdList = mapVOS.stream().map(d -> d.getId()).collect(Collectors.toList()); }
PublishedTraining2Example example = new PublishedTraining2Example();
this.createQueryOrExample(example, reqVO, mapIdList);
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT)
.andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(reqVO.getMapId());
if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
} }
example.setOrderByClause("id desc");
List<PublishedTraining2> list = this.publishedDao.selectByExample(example); /**
if (CollectionUtils.isEmpty(list)) { * 批量更新实训label
return List.of(); */
} else { public void updateTrainingLabelList(List<PublishedTraining2> publishedTraining2List) {
return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList()); List<PublishedTraining2> training2List = publishedTraining2List.stream().filter(t -> t.getId() != null).collect(Collectors.toList());
if (CollectionUtils.isEmpty(training2List)) {
return;
}
publishedDao.updateTrainingLabelList(training2List);
} }
}
/** /**
* 根据已发布实训的id来查询实现的所有信息 * 更新实训label
*/ */
@Transactional(readOnly = true) public void updateTrainingLabel(PublishedTraining2 training2) {
public PublishedTraining2DetailRspVo findTrainingAllInfoById(Long trainingId) { PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs();
PublishedTraining2WithBLOBs b = this.publishedDao.selectByPrimaryKey(trainingId); blobs.setId(training2.getId());
if (null != b) { blobs.setLabelJson(training2.getLabelJson());
PublishedTraining2DetailRspVo rsp = new PublishedTraining2DetailRspVo(); publishedDao.updateByPrimaryKeySelective(blobs);
//
rsp.setDescription(b.getDescription());
rsp.setFailureConditionJson(b.getFailureConditionJson());
rsp.setCreateTime(b.getCreateTime());
rsp.setCreatorId(b.getCreatorId());
rsp.setLabelJson(b.getLabelJson());
rsp.setMapId(b.getMapId());
rsp.setName(b.getName());
rsp.setId(b.getId());
rsp.setType(b.getType());
rsp.setBgSceneJson(b.getBgSceneJson());
rsp.setMemberJson(b.getMemberJson());
rsp.setOperaJson(b.getOperaJson());
rsp.setStepJson(b.getStepJson());
rsp.setUpdateTime(b.getUpdateTime());
rsp.setPlayerIdJson(b.getPlayerIdJson());
rsp.setMapLocationJson(b.getMapLocationJson());
rsp.setRunPlanId(b.getRunPlanId());
rsp.setScoringRuleJson(b.getScoringRuleJson());
rsp.setState(b.getState());
rsp.setClient(b.getClient());
//
return rsp;
} }
return null;
}
/** /**
* 根据地图ID列表修改生成实训的组织ID * 导出实训信息
*/ * @param tidList 实训列表
public void updatePublishTrainingOrgIdByMapId(Long orgId, List<Long> mapIdList) { * @return 实训列表
if (!CollectionUtils.isEmpty(mapIdList)) { */
publishedDao.updateTrainingOrgByMapIdList(orgId, mapIdList); public List<ExportTraining2> exportTraining(List<Long> tidList) {
} PublishedTraining2Example example = new PublishedTraining2Example();
} example.createCriteria().andIdIn(tidList);
List<PublishedTraining2WithBLOBs> training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(example);
/** Map<Long, List<PublishedTraining2WithBLOBs>> mapTrainingMap = training2WithBLOBsList.stream().peek(t -> {
* 批量更新实训label t.setId(null);
*/ t.setUpdateTime(null);
public void updateTrainingLabelList(List<PublishedTraining2> publishedTraining2List) { t.setCreateTime(null);
List<PublishedTraining2> training2List = publishedTraining2List.stream()
.filter(t -> t.getId() != null).collect(Collectors.toList());
if (CollectionUtils.isEmpty(training2List)) {
return;
}
publishedDao.updateTrainingLabelList(training2List);
}
/**
* 更新实训label
*/
public void updateTrainingLabel(PublishedTraining2 training2) {
PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs();
blobs.setId(training2.getId());
blobs.setLabelJson(training2.getLabelJson());
publishedDao.updateByPrimaryKeySelective(blobs);
}
/**
* 修改发布实训的基本信息名称描述等
*
* @param training2
*/
public void updateTrainingBaseInfo(PublishedTraining2 training2) {
PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs();
blobs.setId(training2.getId());
blobs.setName(training2.getName());
blobs.setDescription(training2.getDescription());
blobs.setLabelJson(training2.getLabelJson());
publishedDao.updateByPrimaryKeySelective(blobs);
}
/**
* 导出实训信息
*
* @param tidList 实训列表
* @return 实训列表
*/
public List<ExportTraining2> exportTraining(List<Long> tidList) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdIn(tidList);
List<PublishedTraining2WithBLOBs> training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(
example);
Map<Long, List<PublishedTraining2WithBLOBs>> mapTrainingMap = training2WithBLOBsList.stream()
.peek(t -> {
t.setId(null);
t.setUpdateTime(null);
t.setCreateTime(null);
}).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId)); }).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId));
// 地图基本信息列表 // 地图基本信息列表
List<MapInfo> mapInfoList = mapService.queryMapInfoList( List<MapInfo> mapInfoList = mapService.queryMapInfoList(new ArrayList<>(mapTrainingMap.keySet()));
new ArrayList<>(mapTrainingMap.keySet())); Map<Long, MapInfo> mapInfoMap = mapInfoList.stream().collect(Collectors.toMap(MapInfo::getId, m -> m, (o,n) -> n));
Map<Long, MapInfo> mapInfoMap = mapInfoList.stream() List<ExportTraining2> exportTraining2List = new ArrayList<>(mapTrainingMap.size());
.collect(Collectors.toMap(MapInfo::getId, m -> m, (o, n) -> n)); mapInfoMap.forEach((k, v) -> {
List<ExportTraining2> exportTraining2List = new ArrayList<>(mapTrainingMap.size()); ExportTraining2 exportData = new ExportTraining2();
mapInfoMap.forEach((k, v) -> { exportData.setName(v.getName());
ExportTraining2 exportData = new ExportTraining2(); exportData.setLineCode(v.getLineCode());
exportData.setName(v.getName()); exportData.setList(mapTrainingMap.get(k));
exportData.setLineCode(v.getLineCode()); exportTraining2List.add(exportData);
exportData.setList(mapTrainingMap.get(k));
exportTraining2List.add(exportData);
});
return exportTraining2List;
}
/**
* 导入实训接口
*
* @param trainingList 实训列表
*/
public List<String> importTraining(List<ExportTraining2> trainingList,
LoginUserInfoVO userInfoVO) {
List<String> msgList = new ArrayList<>();
trainingList.forEach(t -> {
List<MapInfo> mapInfoList = mapService.queryMapInfo(t.getName(), t.getLineCode());
if (mapInfoList.size() == 1) {
Long mapId = mapInfoList.get(0).getId();
t.getList().forEach(training -> {
training.setMapId(mapId);
training.setCreatorId(userInfoVO.getAccountVO().getId());
training.setCreateTime(LocalDateTime.now());
}); });
publishedDao.insertList(t.getList()); return exportTraining2List;
msgList.add(String.format("地图【%s】实训信息导入成功", t.getName())); }
} else {
msgList.add(String.format("地图【%s】实训信息导入失败线路【%s】地图【%s】未上线", t.getName(), /**
t.getLineCode(), t.getName())); * 导入实训接口
} * @param trainingList 实训列表
}); */
return msgList; public List<String> importTraining(List<ExportTraining2> trainingList, LoginUserInfoVO userInfoVO) {
} List<String> msgList = new ArrayList<>();
trainingList.forEach(t -> {
List<MapInfo> mapInfoList = mapService.queryMapInfo(t.getName(), t.getLineCode());
if (mapInfoList.size() == 1) {
Long mapId = mapInfoList.get(0).getId();
t.getList().forEach(training -> {
training.setMapId(mapId);
training.setCreatorId(userInfoVO.getAccountVO().getId());
training.setCreateTime(LocalDateTime.now());
});
publishedDao.insertList(t.getList());
msgList.add(String.format("地图【%s】实训信息导入成功", t.getName()));
} else {
msgList.add(String.format("地图【%s】实训信息导入失败", t.getName()));
}
});
return msgList;
}
} }

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.services.training2; package club.joylink.rtss.services.training2;
import club.joylink.rtss.constants.MapStatus; import club.joylink.rtss.constants.MapStatus;
import club.joylink.rtss.constants.Project;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.dao.MapInfoDAO; import club.joylink.rtss.dao.MapInfoDAO;
import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.dao.PublishedTraining2DAO;
import club.joylink.rtss.dao.RtsMapFunctionDAO; import club.joylink.rtss.dao.RtsMapFunctionDAO;
@ -9,29 +11,36 @@ import club.joylink.rtss.entity.MapInfo;
import club.joylink.rtss.entity.MapInfoExample; import club.joylink.rtss.entity.MapInfoExample;
import club.joylink.rtss.entity.RtsMapFunction; import club.joylink.rtss.entity.RtsMapFunction;
import club.joylink.rtss.entity.RtsMapFunctionExample; import club.joylink.rtss.entity.RtsMapFunctionExample;
import club.joylink.rtss.entity.training2.PublishedTraining2Example; import club.joylink.rtss.entity.training2.*;
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import club.joylink.rtss.entity.training2.RtsTraining2RuleExample;
import club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs;
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
import club.joylink.rtss.services.project.ProjectService; import club.joylink.rtss.services.project.ProjectService;
import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.SimulationService; import club.joylink.rtss.simulation.cbtc.SimulationService;
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.training2.ScoringRuleVO; import club.joylink.rtss.vo.client.training2.ScoringRuleVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.training2.rule.BgSceneStatusRule;
import club.joylink.rtss.vo.training2.rule.MapLocationRule;
import club.joylink.rtss.vo.training2.rule.StepRule; import club.joylink.rtss.vo.training2.rule.StepRule;
import club.joylink.rtss.vo.training2.rule.Training2Rule; import club.joylink.rtss.vo.training2.rule.Training2Rule;
import com.fasterxml.jackson.core.JsonParseException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.BiConsumer; import org.apache.logging.log4j.util.BiConsumer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -76,7 +85,7 @@ public class Training2RuleService {
* @return 生成结果 * @return 生成结果
*/ */
public List<String> generateTrainingByRule(String groupId) { public List<String> generateTrainingByRule(String groupId) {
Simulation simulation = simulationManager.getById(groupId, Simulation.class); Simulation simulation = simulationManager.getById(groupId , Simulation.class);
Long mapId = simulation.getBuildParams().getMap().getId(); Long mapId = simulation.getBuildParams().getMap().getId();
if (runningMapIdSet.contains(mapId)) { if (runningMapIdSet.contains(mapId)) {
return Arrays.asList("该地图正在生成实训!"); return Arrays.asList("该地图正在生成实训!");
@ -122,6 +131,7 @@ public class Training2RuleService {
} }
/** /**
*
* @param mapId * @param mapId
* @param functionId * @param functionId
* @return * @return
@ -134,7 +144,7 @@ public class Training2RuleService {
/** /**
* 根据地图ID生成实训 * 根据地图ID生成实训
*/ */
public List<String> generateTrainingByMapId(List<Long> mapIdList, LoginUserInfoVO loginUserInfoVO) { public List<String> generateTrainingByMapId(List<Long> mapIdList, LoginUserInfoVO loginUserInfoVO){
// 地图列表 // 地图列表
MapInfoExample example = new MapInfoExample(); MapInfoExample example = new MapInfoExample();
MapInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(MapStatus.Online.getCode()); MapInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(MapStatus.Online.getCode());
@ -213,7 +223,7 @@ public class Training2RuleService {
List<Map<String, Long>> publishTrainingIdList = publishedTraining2DAO.selectTrainingByRuleId( List<Map<String, Long>> publishTrainingIdList = publishedTraining2DAO.selectTrainingByRuleId(
ruleIdList, mapList.stream().map(MapInfo::getId).collect(Collectors.toList())); ruleIdList, mapList.stream().map(MapInfo::getId).collect(Collectors.toList()));
Map<Long, List<Long>> publishTrainingIdMap = publishTrainingIdList.stream().collect( Map<Long, List<Long>> publishTrainingIdMap = publishTrainingIdList.stream().collect(
Collectors.groupingBy(m -> m.get("mapId"), Collectors.mapping(m -> m.get("id"), Collectors.toList()))); Collectors.groupingBy(m -> m.get("mapId"), Collectors.mapping(m -> m.get("id") , Collectors.toList())));
List<String> errorMsgList = new ArrayList<>(); List<String> errorMsgList = new ArrayList<>();
loopMapListGenerateTraining(loginUserInfoVO, mapList, lineCodeRuleMap, errorMsgList, publishTrainingIdMap); loopMapListGenerateTraining(loginUserInfoVO, mapList, lineCodeRuleMap, errorMsgList, publishTrainingIdMap);
@ -227,7 +237,7 @@ public class Training2RuleService {
List<String> errorMsgList = new ArrayList<>(); List<String> errorMsgList = new ArrayList<>();
mapRuleIdMap.forEach((k, v) -> { mapRuleIdMap.forEach((k, v) -> {
// 地图信息 // 地图信息
MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(k); MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(k);
// 规则列表 // 规则列表
RtsTraining2RuleExample rtsTraining2RuleExample = new RtsTraining2RuleExample(); RtsTraining2RuleExample rtsTraining2RuleExample = new RtsTraining2RuleExample();
rtsTraining2RuleExample.createCriteria().andIdIn(v).andLineCodeEqualTo(mapInfo.getLineCode()); rtsTraining2RuleExample.createCriteria().andIdIn(v).andLineCodeEqualTo(mapInfo.getLineCode());
@ -236,8 +246,8 @@ public class Training2RuleService {
// 获取客户端参数 // 获取客户端参数
List<RtsMapFunction> entities = getRtsMapFunctions(k); List<RtsMapFunction> entities = getRtsMapFunctions(k);
if (!CollectionUtils.isEmpty(entities)) { if (!CollectionUtils.isEmpty(entities)) {
List<Map<String, String>> ruleNameMapList = ruleList.stream().map(r -> { List<Map<String,String>> ruleNameMapList = ruleList.stream().map(r -> {
Map<String, String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("ruleName", r.getName()); map.put("ruleName", r.getName());
map.put("client", r.getClient()); map.put("client", r.getClient());
return map; return map;
@ -245,7 +255,7 @@ public class Training2RuleService {
// 需要删除的列表 // 需要删除的列表
List<Long> delTrainingIdList = publishedTraining2DAO.selectTrainingIdByRuleNameAndMapId(ruleNameMapList, k); List<Long> delTrainingIdList = publishedTraining2DAO.selectTrainingIdByRuleNameAndMapId(ruleNameMapList, k);
try { try {
Simulation simulation = simulationService.createSimulation(entities.get(0).getId(), loginUserInfoVO, false); Simulation simulation = simulationService.createSimulationPojo(entities.get(0).getId(), loginUserInfoVO, false);
errorMsgList.addAll(generateTraining(simulation, ruleList, delTrainingIdList, delPublishTrainingByIds)); errorMsgList.addAll(generateTraining(simulation, ruleList, delTrainingIdList, delPublishTrainingByIds));
} catch (Exception e) { } catch (Exception e) {
log.error("创建仿真失败", e); log.error("创建仿真失败", e);
@ -278,7 +288,7 @@ public class Training2RuleService {
bloBs.setId(rule.getId()); bloBs.setId(rule.getId());
bloBs.setScoreRule(JsonUtils.writeValueAsString(detailVOList)); bloBs.setScoreRule(JsonUtils.writeValueAsString(detailVOList));
return bloBs; return bloBs;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
rtsTraining2RuleMapper.updateScoreRule(ruleScoreList); rtsTraining2RuleMapper.updateScoreRule(ruleScoreList);
} }
@ -292,7 +302,7 @@ public class Training2RuleService {
List<RtsMapFunction> entities = getRtsMapFunctions(mapInfo.getId()); List<RtsMapFunction> entities = getRtsMapFunctions(mapInfo.getId());
if (!CollectionUtils.isEmpty(entities) && !CollectionUtils.isEmpty(lineCodeRuleMap.get(mapInfo.getLineCode()))) { if (!CollectionUtils.isEmpty(entities) && !CollectionUtils.isEmpty(lineCodeRuleMap.get(mapInfo.getLineCode()))) {
try { try {
Simulation simulation = simulationService.createSimulation(entities.get(0).getId(), loginUserInfoVO, false); Simulation simulation = simulationService.createSimulationPojo(entities.get(0).getId(), loginUserInfoVO, false);
if (CollectionUtils.isEmpty(deleteTrainingIdMap)) { if (CollectionUtils.isEmpty(deleteTrainingIdMap)) {
errorMsgList.addAll(generateTraining(simulation, lineCodeRuleMap.get(mapInfo.getLineCode()), null, delPublishTrainingByMapId)); errorMsgList.addAll(generateTraining(simulation, lineCodeRuleMap.get(mapInfo.getLineCode()), null, delPublishTrainingByMapId));
} else { } else {
@ -308,9 +318,8 @@ public class Training2RuleService {
/** /**
* 生成实训方法 * 生成实训方法
* * @param simulation 对应地图仿真
* @param simulation 对应地图仿真 * @param ruleList 生成规则
* @param ruleList 生成规则
* @param delTrainingIds 要删除已发布的实训ID * @param delTrainingIds 要删除已发布的实训ID
* @param delConsumer 删除实训方法 * @param delConsumer 删除实训方法
* @return * @return
@ -349,11 +358,11 @@ public class Training2RuleService {
publishedTraining2DAO.insertList(training2WithBLOBs); publishedTraining2DAO.insertList(training2WithBLOBs);
} catch (RuntimeException e) { } catch (RuntimeException e) {
log.error("实训反序列化失败", e); log.error("实训反序列化失败", e);
errorMsgList.add(String.format("地图%d实训[%s]反序列化实训ID【%d】", mapId, rule.getName(), rule.getId(), Locale.ENGLISH)); errorMsgList.add(String.format("地图%d实训[%s]反序列化实训ID【%d】", mapId, rule.getName(), rule.getId(),Locale.ENGLISH));
} catch (Exception e) { } catch (Exception e) {
log.error("实训生成失败", e); log.error("实训生成失败", e);
errorMsgList.add(String.format("地图%d实训[%s]生成失败,设备信息【%s】原因%s", mapId, errorMsgList.add(String.format("地图%d实训[%s]生成失败,设备信息【%s】原因%s", mapId,
rule.getName(), rule.getDeviceRule(), e.getMessage(), Locale.ENGLISH)); rule.getName(), rule.getDeviceRule(),e.getMessage(),Locale.ENGLISH));
} }
} }
} }

View File

@ -5,7 +5,6 @@ import club.joylink.rtss.entity.RtsMapFunction;
import club.joylink.rtss.entity.SysAccount; import club.joylink.rtss.entity.SysAccount;
import club.joylink.rtss.entity.UserSimulationRecord; import club.joylink.rtss.entity.UserSimulationRecord;
import club.joylink.rtss.entity.UserSimulationRecordExample; import club.joylink.rtss.entity.UserSimulationRecordExample;
import club.joylink.rtss.entity.UserSimulationRecordExample.Criteria;
import club.joylink.rtss.event.UserSimulationRecordEvent; import club.joylink.rtss.event.UserSimulationRecordEvent;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService; import club.joylink.rtss.services.IMapService;
@ -14,7 +13,6 @@ import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
import club.joylink.rtss.simulation.cbtc.message.UserSimulationRecordManager; import club.joylink.rtss.simulation.cbtc.message.UserSimulationRecordManager;
import club.joylink.rtss.util.TimeUnit; import club.joylink.rtss.util.TimeUnit;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.simulationUsage.SimulationUsageRecordQueryVO;
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationQueryVO; import club.joylink.rtss.vo.client.simulationUsage.UserSimulationQueryVO;
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationRecordVO; import club.joylink.rtss.vo.client.simulationUsage.UserSimulationRecordVO;
import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsVO; import club.joylink.rtss.vo.client.simulationUsage.UserSimulationStatsVO;
@ -68,8 +66,7 @@ public class UserSimulationRecordService {
} }
public List<UserSimulationRecord> queryByMapAndUserIds(Long mapId, List<Long> userIds) { public List<UserSimulationRecord> queryByMapAndUserIds(Long mapId, List<Long> userIds) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds, BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(userIds, "用户列表不能为空");
"用户列表不能为空");
UserSimulationRecordExample example = new UserSimulationRecordExample(); UserSimulationRecordExample example = new UserSimulationRecordExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIn(userIds); example.createCriteria().andMapIdEqualTo(mapId).andUserIdIn(userIds);
return userSimulationRecordDAO.selectByExample(example); return userSimulationRecordDAO.selectByExample(example);
@ -168,22 +165,6 @@ public class UserSimulationRecordService {
return statistic(startTime, endTime, timeUnit, list); return statistic(startTime, endTime, timeUnit, list);
} }
/**
* 查询仿真使用记录
*/
public List<UserSimulationRecord> listSimulationUsageRecords(
SimulationUsageRecordQueryVO queryVO) {
UserSimulationRecordExample example = new UserSimulationRecordExample();
Criteria criteria = example.createCriteria();
if (queryVO.getUid() != null) {
criteria.andUserIdEqualTo(queryVO.getUid());
}
if (queryVO.getFunctionId() != null) {
criteria.andFunctionIdEqualTo(queryVO.getFunctionId());
}
return userSimulationRecordDAO.selectByExample(example);
}
/** /**
* 对使用记录按照时间单位开始结束时间分段统计 * 对使用记录按照时间单位开始结束时间分段统计
*/ */
@ -242,12 +223,9 @@ public class UserSimulationRecordService {
} }
private void checkParam(UserSimulationQueryVO queryVO) { private void checkParam(UserSimulationQueryVO queryVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getTimeUnit(), BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getTimeUnit(), "缺少时间单位");
"缺少时间单位"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getStartTime(), "缺少开始时间");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getStartTime(), BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getEndTime(), "缺少结束时间");
"缺少开始时间");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(queryVO.getEndTime(),
"缺少结束时间");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
!queryVO.getStartTime().isAfter(queryVO.getEndTime()), "开始时间不能晚于结束时间"); !queryVO.getStartTime().isAfter(queryVO.getEndTime()), "开始时间不能晚于结束时间");
} }

View File

@ -4,7 +4,6 @@ import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.competition.VoiceErrorVO; import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult; import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
/** /**
@ -12,19 +11,9 @@ import org.springframework.web.multipart.MultipartFile;
*/ */
public interface IVoiceTrainingService { public interface IVoiceTrainingService {
PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO); PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO);
VoiceRecognitionResult voiceRecognition(MultipartFile file); VoiceRecognitionResult voiceRecognition(MultipartFile file);
VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath); VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath);
/**
* 校验语音识别结果
*
* @param contentType
* @param file 需要校验的语音
* @param text 正确的文本
* @return 校验结果
*/
VoiceVerifyResultVO verifyVoice(String contentType, byte[] file, String text);
} }

View File

@ -19,70 +19,66 @@ import java.util.Objects;
@Component @Component
public class VoiceService { public class VoiceService {
private final MinioClientUtil voiceSynthesisUtil; private final MinioClientUtil voiceSynthesisUtil;
private final MinioClientUtil voiceRecognitionUtil; private final MinioClientUtil voiceRecognitionUtil;
private final static String SYNTHESIS_FOLDER = "synthesis"; private final static String SYNTHESIS_FOLDER = "synthesis";
private final static String RECOGNITION_FOLDER = "recognition"; private final static String RECOGNITION_FOLDER = "recognition";
@Autowired @Autowired
@Qualifier(value = "baiDuVoiceService2") @Qualifier(value = "baiDuVoiceService2")
private IVoiceService2 voiceService; private IVoiceService2 voiceService;
public VoiceService(MinioClientConfig minioClientConfig) { public VoiceService(MinioClientConfig minioClientConfig){
this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig, SYNTHESIS_FOLDER); this.voiceSynthesisUtil = MinioClientUtil.getInstance(minioClientConfig,SYNTHESIS_FOLDER);
this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig, RECOGNITION_FOLDER); this.voiceRecognitionUtil = MinioClientUtil.getInstance(minioClientConfig,RECOGNITION_FOLDER);
}
/**
* 语音识别
*
* @param vo
* @return
*/
public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo) {
String fileName = String.format("%s.wav", System.currentTimeMillis());
this.uploadFile(voiceRecognitionUtil, vo.getData(), fileName, RECOGNITION_FOLDER);
String filePath = this.voiceRecognitionUtil.getDownLoadPath(fileName);
VoiceAsrResult voiceResult = voiceService.recognition(vo);
return new VoiceRecognitionResult(filePath, voiceResult.getResult().get(0));
}
/**
* 语音合成
*
* @param vo
* @return
*/
public VoiceCompose synthesis(BaseVoiceSynthesisVO vo) {
String md5Code = vo.md5Code();
String fileName = String.format("%s.wav", md5Code);
if (Objects.equals(false, this.voiceSynthesisUtil.checkFileIsExist(fileName))) {
byte[] bytes = voiceService.voiceSynthesis(vo);
byte[] data = bytes;
this.uploadFile(voiceSynthesisUtil, data, fileName, SYNTHESIS_FOLDER);
} }
String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName);
return new VoiceCompose(filePath, md5Code, vo.getMessage());
}
/** /**
* 语音合成返回原数据 * 语音识别
* * @param vo
* @param vo * @return
* @return */
*/ public VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo){
public byte[] synthesisSource(BaseVoiceSynthesisVO vo) { String fileName = String.format("%s.wav",System.currentTimeMillis());
byte[] data = voiceService.voiceSynthesis(vo); this.uploadFile(voiceRecognitionUtil,vo.getData(),fileName,RECOGNITION_FOLDER);
return data; String filePath = this.voiceRecognitionUtil.getDownLoadPath(fileName);
} VoiceAsrResult voiceResult = voiceService.recognition(vo);
return new VoiceRecognitionResult(filePath,voiceResult.getResult().get(0));
private void uploadFile(MinioClientUtil minioClient, byte[] data, String fileName, String folder) { }
try {
minioClient.uploadBytes(data, fileName); /**
} catch (SimulationException e) { * 语音合成
log.error("文件上传失败 folder:{},文件名:{} errmsg:{}", folder, fileName, e.getMessage(), e); * @param vo
throw e; * @return
*/
public VoiceCompose synthesis(BaseVoiceSynthesisVO vo){
String md5Code = vo.md5Code();
String fileName = String.format("%s.wav",md5Code);
if(Objects.equals(false,this.voiceSynthesisUtil.checkFileIsExist(fileName))){
byte[] data = voiceService.voiceSynthesis(vo);
this.uploadFile(voiceSynthesisUtil,data,fileName,SYNTHESIS_FOLDER);
}
String filePath = this.voiceSynthesisUtil.getDownLoadPath(fileName);
return new VoiceCompose(filePath,md5Code,vo.getMessage());
}
/**
* 语音合成返回原数据
* @param vo
* @return
*/
public byte[] synthesisSource(BaseVoiceSynthesisVO vo){
byte[] data = voiceService.voiceSynthesis(vo);
return data;
}
private void uploadFile(MinioClientUtil minioClient ,byte[] data,String fileName,String folder){
try{
minioClient.uploadBytes(data,fileName);
}catch (SimulationException e){
log.error("文件上传失败 folder:{},文件名:{} errmsg:{}",folder,fileName,e.getMessage(),e);
throw e;
}
} }
}
} }

View File

@ -2,118 +2,63 @@ package club.joylink.rtss.services.voice;
import club.joylink.rtss.dao.CompetitionErrorSetDAO; import club.joylink.rtss.dao.CompetitionErrorSetDAO;
import club.joylink.rtss.entity.CompetitionErrorSet; import club.joylink.rtss.entity.CompetitionErrorSet;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler; import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler;
import club.joylink.rtss.util.StrUtils;
import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.competition.VoiceErrorVO; import club.joylink.rtss.vo.client.competition.VoiceErrorVO;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult; import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO; import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
import club.joylink.rtss.vo.voice.VoiceVerifyResultVO;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class VoiceTrainingService implements IVoiceTrainingService { public class VoiceTrainingService implements IVoiceTrainingService {
@Autowired @Autowired
private CompetitionErrorSetDAO competitionErrorSetDAO; private CompetitionErrorSetDAO competitionErrorSetDAO;
/* @Autowired /* @Autowired
@Qualifier("baiDuVoiceService") @Qualifier("baiDuVoiceService")
private IVoiceService iVoiceService;*/ private IVoiceService iVoiceService;*/
@Autowired @Autowired
// @Qualifier("baiDuVoiceService2") // @Qualifier("baiDuVoiceService2")
private VoiceService iVoiceService; private VoiceService iVoiceService;
@Autowired @Autowired
private SimulationVoiceHandler simulationVoiceHandler; private SimulationVoiceHandler simulationVoiceHandler;
@Override @Override
public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) { public PageVO<VoiceErrorVO> pagedQueryErrorSet(PageQueryVO queryVO) {
Page<Object> page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); Page<Object> page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
List<CompetitionErrorSet> sets = competitionErrorSetDAO.selectByExample(null); List<CompetitionErrorSet> sets = competitionErrorSetDAO.selectByExample(null);
List<VoiceErrorVO> list = sets.stream().map(VoiceErrorVO::new).collect(Collectors.toList()); List<VoiceErrorVO> list = sets.stream().map(VoiceErrorVO::new).collect(Collectors.toList());
return PageVO.convert(page, list); return PageVO.convert(page, list);
} }
@Override @Override
public VoiceRecognitionResult voiceRecognition(MultipartFile file) { public VoiceRecognitionResult voiceRecognition(MultipartFile file) {
VoiceRecognitionVO vo = VoiceRecognitionVO.load(file); VoiceRecognitionVO vo = VoiceRecognitionVO.load(file);
return voiceRecognition(vo); VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(vo);
} // VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(file, "");
result.setResult(simulationVoiceHandler.handle(result.getResult()));
@Override return result;
public VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath) { }
VoiceRecognitionVO vo = new VoiceRecognitionVO(bytes);
return voiceRecognition(vo); @Override
} public VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath) {
VoiceRecognitionVO vo = new VoiceRecognitionVO(bytes);
@Override VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(vo);
public VoiceVerifyResultVO verifyVoice(String contentType, byte[] fileData, String text) { // VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(bytes, filePath);
byte[] monoData = convertToMonoChannel(fileData); result.setResult(simulationVoiceHandler.handle(result.getResult()));
VoiceRecognitionResult voiceRecognitionResult = voiceRecognition( return result;
new VoiceRecognitionVO(monoData, contentType));
boolean match = StrUtils.isMatch(text, voiceRecognitionResult.getResult(), 70);
return new VoiceVerifyResultVO(voiceRecognitionResult.getResult(), match);
}
private VoiceRecognitionResult voiceRecognition(VoiceRecognitionVO vo) {
VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(vo);
// VoiceRecognitionResult result = this.iVoiceService.voiceRecognition(file, "");
result.setResult(simulationVoiceHandler.handle(result.getResult()));
return result;
}
private byte[] convertToMonoChannel(byte[] audioData) {
try {
// 假设输入和输出音频都存储在字节数组中
byte[] outputAudioBytes;
// 将输入音频字节数组转换为音频输入流
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(audioData);
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(byteArrayInputStream);
AudioFormat format = audioInputStream.getFormat();
// 确保输入音频是立体声
if (format.getChannels() != 2) {
System.out.println("Input audio is not stereo.");
return audioData;
}
// 创建单声道格式
AudioFormat monoFormat = new AudioFormat(format.getEncoding(), format.getSampleRate(),
format.getSampleSizeInBits(), 1, format.getFrameSize() / 2, format.getFrameRate(), false);
// 从立体声转换为单声道
AudioInputStream monoInputStream = AudioSystem.getAudioInputStream(monoFormat,
audioInputStream);
// 将单声道音频写入字节数组输出流
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
AudioSystem.write(monoInputStream, AudioFileFormat.Type.WAVE, byteArrayOutputStream);
// 获取输出音频的字节数组
return byteArrayOutputStream.toByteArray();
} catch (UnsupportedAudioFileException | IOException e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(
String.format("音频转单声道失败:%s", e));
} }
}
} }

View File

@ -0,0 +1,78 @@
/*
package club.joylink.rtss.services.voice.huawei;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.voice.IVoiceService;
import club.joylink.rtss.util.VoiceFileUtils;
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
import com.huawei.sis.bean.AuthInfo;
import com.huawei.sis.bean.SisConfig;
import com.huawei.sis.bean.request.AsrCustomShortRequest;
import com.huawei.sis.bean.response.AsrCustomShortResponse;
import com.huawei.sis.client.AsrCustomizationClient;
import com.huawei.sis.exception.SisException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Base64;
@Slf4j
@Service("HuaWeiVoiceService")
public class HuaweiVoiceServiceImpl implements IVoiceService {
@Override
public String synthesis(String message, String per) {
throw BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.exception("功能暂未实现");
}
@Override
public String synthesis(String message) {
return this.synthesis(message, "0");
}
*/
/**
* 华为语音识别配置
*//*
private final String ak = "YDUXTXRYGAHGPHAIXZCU";
private final String sk = "Kcbm3sTDCYEou8kGeAhKxfBkgWybIn6IjJyGBX3p";
private final String region = "cn-north-4";
private final String projectId = "0aada8176180f28c2f34c0196f5394e8";
@Override
public VoiceRecognitionResult voiceRecognition(MultipartFile file, String lang) {
String filePath = VoiceFileUtils.saveFile(file);
try {
return voiceRecognition(file.getBytes(), filePath);
} catch (IOException e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("第三方服务调用异常");
}
}
@Override
public VoiceRecognitionResult voiceRecognition(byte[] bytes, String filePath) {
AuthInfo authInfo = new AuthInfo(ak, sk, region, projectId);
SisConfig sisConfig = new SisConfig();
AsrCustomizationClient client = new AsrCustomizationClient(authInfo, sisConfig);
String data = Base64.getEncoder().encodeToString(bytes);
try {
AsrCustomShortRequest request = new AsrCustomShortRequest(data, "pcm16k16bit", "chinese_16k_common");
AsrCustomShortResponse response = client.getAsrShortResponse(request);
return new VoiceRecognitionResult(filePath, response.getResult().getText());
} catch (SisException e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音识别失败", e);
}
}
@Override
public VoiceRecognitionResult voiceRecognition(String fileBase64) {
String base64 = fileBase64.substring(fileBase64.indexOf("base64,") + "base64,".length());
byte[] bytes = Base64.getDecoder().decode(base64.trim());
String filePath = VoiceFileUtils.saveFile(bytes);
return voiceRecognition(bytes, filePath);
}
}
*/

View File

@ -0,0 +1,154 @@
//package club.joylink.rtss.simulation;
//
//import club.joylink.rtss.simulation.operation.SimulationOperationDispatcher;
//import club.joylink.rtss.simulation.vo.SimulationFaultVO;
//import club.joylink.rtss.simulation.vo.SimulationInfoVO;
//import club.joylink.rtss.simulation.vo.SimulationMemberVO;
//import club.joylink.rtss.simulation.vo.SimulationUserVO;
//import club.joylink.rtss.vo.LoginUserInfoVO;
//import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY;
//
///**
// * 仿真通用接口
// */
//@Slf4j
//@RestController
//@RequestMapping("/common/simulation")
//public class SimulationCommonController {
// @Autowired
// private SimulationManager simulationManager;
// @Autowired
// private SimulationOperationDispatcher simulationOperationDispatcher;
//
// /**
// * 监管仿真
// * @param loginUserInfoVO
// * @param queryVO
// * @return
// */
// @GetMapping("/supervise")
// public List<SimulationInfoVO> superviseSimulation(@RequestAttribute(name=LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, SimulationInfoQueryVO queryVO) {
// List<Simulation> simulationList = this.simulationManager.getSimulationList();
// Stream<Simulation> stream = simulationList.stream();
//
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
// && Objects.equals(loginUserInfoVO.getTopOrgId(),((club.joylink.rtss.simulation.cbtc.Simulation)simulation).getBuildParams().getLoginUserInfo().getTopOrgId()));
//
// if (StringUtils.hasText(queryVO.getGroup())) {
// stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
// }
// if (StringUtils.hasText(queryVO.getUserName())) {
// stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> ((SimulationUser) user).getName().contains(queryVO.getUserName())));
// }
// if (StringUtils.hasText(queryVO.getPrdType())) {
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
// && queryVO.getPrdType().equals(((club.joylink.rtss.simulation.cbtc.Simulation) simulation).getBuildParams().getProdType().getCode()));
// }
// return stream.map(Simulation::convertToVO).collect(Collectors.toList());
// }
//
// @GetMapping("/list")
// public List<SimulationInfoVO> queryInfo(SimulationInfoQueryVO queryVO) {
// List<Simulation> simulationList = this.simulationManager.getSimulationList();
// Stream<Simulation> stream = simulationList.stream();
// if (StringUtils.hasText(queryVO.getGroup())) {
// stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup()));
// }
// if (StringUtils.hasText(queryVO.getUserName())) {
// stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> ((SimulationUser) user).getName().contains(queryVO.getUserName())));
// }
// if (StringUtils.hasText(queryVO.getPrdType())) {
// stream = stream.filter(simulation -> simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation
// && queryVO.getPrdType().equals(((club.joylink.rtss.simulation.cbtc.Simulation) simulation).getBuildParams().getProdType().getCode()));
// }
// return stream.map(Simulation::convertToVO).collect(Collectors.toList());
// }
//
// @PutMapping("/{id}/pause")
// public void pause(@PathVariable String id) {
// this.simulationManager.pause(id);
// }
//
// @PutMapping("/{id}/start")
// public void start(@PathVariable String id) {
// this.simulationManager.start(id);
// }
//
// @PutMapping("/{id}/init")
// public void init(@PathVariable String id) {
// this.simulationManager.init(id);
// }
//
// @PutMapping("/{id}/updateSpeed/{speed}")
// public void updateSpeed(@PathVariable String id, @PathVariable int speed) {
// this.simulationManager.updateSpeed(id, speed);
// }
//
// @GetMapping("/{id}")
// public SimulationInfoVO getSimulationInfo(@PathVariable String id) {
// return this.simulationManager.getById(id).convertToVO();
// }
//
// @GetMapping("/{id}/users")
// public List<SimulationUserVO> getSimulationUsers(@PathVariable String id) {
// return this.simulationManager.getSimulationUsers(id).stream()
// .map(SimulationUser::convertToVO)
// .collect(Collectors.toList());
// }
//
// @GetMapping("/{id}/members")
// public List<SimulationMemberVO> getSimulationMembers(@PathVariable String id, @RequestParam(required = false) String role) {
// return this.simulationManager.getSimulationMembers(id).stream()
// .map(SimulationMember::convertToVO)
// .filter(member -> StringUtils.hasText(role) ? member.getRole().toString().equals(role) : true)
// .collect(Collectors.toList());
// }
//
// @GetMapping("/{id}/member/playedBy/{userId}")
// public SimulationMemberVO queryUserPlayedMember(@PathVariable String id, @PathVariable String userId) {
// return this.simulationManager.getById(id)
// .getSimulationMemberByUserId(userId).convertToVO();
// }
//
// @PostMapping("/{id}/member/{memberId}/operate/{type}")
// public Object operate(@PathVariable String id, @PathVariable String memberId,
// @PathVariable String type, @RequestBody Map<String, Object> params) {
// return this.simulationOperationDispatcher.doDispatch(id, memberId, type, params);
// }
//
// /**
// * 故障注入
// */
// @PostMapping("/{id}/fault")
// public void injectFault(@PathVariable String id, @RequestBody SimulationFaultVO faultVO) {
// this.simulationManager.injectFault(id, faultVO);
// }
//
// @DeleteMapping("/{id}/device/{deviceId}/fault/{fault}")
// public void removeFault(@PathVariable String id, @PathVariable String deviceId, @PathVariable String fault) {
// this.simulationManager.removeFault(id, deviceId, fault);
// }
//
// @PutMapping("/{id}/member/{memberId}/playby/{userId}")
// public void memberPlay(@PathVariable String id, @PathVariable String memberId, @PathVariable String userId) {
// this.simulationManager.memberPlayedByUser(id, memberId, userId);
// }
//
// @DeleteMapping("/{id}/destroy")
// public void destroy(@PathVariable String id) {
// this.simulationManager.destroy(id);
// log.info(String.format("仿真通用接口销毁仿真[%s]", id));
// }
//}

View File

@ -9,15 +9,14 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
/** /**
* 地面ATP逻辑循环 * 地面ATP逻辑循环
@ -26,226 +25,235 @@ import java.util.stream.Collectors;
@Component @Component
public class AtpSectionService { public class AtpSectionService {
/** /**
* 收集列车接近信号机消息并发送给CI * 收集列车接近信号机消息并发送给CI
*/ */
public void changeSignalModeByTrainApproach(Simulation simulation, public void changeSignalModeByTrainApproach(Simulation simulation,
List<VirtualRealityTrain> onlineTrainList, List<VirtualRealityTrain> onlineTrainList,
Map<String, List<Section>> trainAtpSectionMap) { Map<String, List<Section>> trainAtpSectionMap) {
List<Signal> signalList = simulation.getRepository().getSignalList(); List<Signal> signalList = simulation.getRepository().getSignalList();
signalList.forEach(signal -> { signalList.forEach(signal -> {
int a = 0; // 列车接近信号消息0-无车接近1-通信车接近2-非通信车接近 int a = 0; // 列车接近信号消息0-无车接近1-通信车接近2-非通信车接近
for (VirtualRealityTrain train : onlineTrainList) { for (VirtualRealityTrain train : onlineTrainList) {
List<Section> atpSectionList = trainAtpSectionMap.get(train.getGroupNumber()); List<Section> atpSectionList = trainAtpSectionMap.get(train.getGroupNumber());
List<Section> physicalList = this.convert2PhysicalSectionList(atpSectionList); List<Section> physicalList = this.convert2PhysicalSectionList(atpSectionList);
if (train.isCommunicable() && signal.containsApproachAtpSection(atpSectionList)) { //存在通信车接近继续 if (train.isCommunicable() && signal.containsApproachAtpSection(
a = 1; atpSectionList)) { //存在通信车接近继续
} else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(physicalList)) { //存在非通信车接近结束 a = 1;
a = 2; } else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(
break; physicalList)) { //存在非通信车接近结束
} a = 2;
} break;
if (1 == a) { // 只有通信车接近 }
if(!signal.getSignalModel().getGuideAspect().equals(signal.getAspect())) { }
signal.changeToCbtcMode(); if (1 == a) { // 只有通信车接近
} if (!signal.getSignalModel().getGuideAspect().equals(signal.getAspect())) {
} else if (2 == a) { // 有非通信车接近 signal.changeToCbtcMode();
signal.changeToBackupMode(); }
} } else if (2 == a) { // 有非通信车接近
signal.updateApproachLock();//更新信号机接近锁闭状态 signal.changeToBackupMode();
}); }
} signal.updateApproachLock();//更新信号机接近锁闭状态
});
}
private List<Section> convert2PhysicalSectionList(List<Section> sectionList) { private List<Section> convert2PhysicalSectionList(List<Section> sectionList) {
List<Section> physicalList = new ArrayList<>(); List<Section> physicalList = new ArrayList<>();
sectionList.forEach(section -> { sectionList.forEach(section -> {
if (section.isPhysical()) { if (section.isPhysical()) {
physicalList.add(section); physicalList.add(section);
} else if (section.isLogicSection()) { } else if (section.isLogicSection()) {
if (!physicalList.contains(section.getParent())) { if (!physicalList.contains(section.getParent())) {
physicalList.add(section.getParent()); physicalList.add(section.getParent());
} }
} }
}); });
return physicalList; return physicalList;
} }
/** /**
* ATP区段列车占用检测并设置 * ATP区段列车占用检测并设置
* *
* @param simulation * @param simulation
* @param train * @param train
* @return * @return
*/ */
public List<Section> atpSectionOccupyCheck(Simulation simulation, VirtualRealityTrain train) { public List<Section> atpSectionOccupyCheck(Simulation simulation, VirtualRealityTrain train) {
List<Section> atpSectionList = new ArrayList<>(); List<Section> atpSectionList = new ArrayList<>();
boolean right = train.isRight(); boolean right = train.isRight();
SectionPosition trainHeadPosition = train.getHeadPosition(); SectionPosition trainHeadPosition = train.getHeadPosition();
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
MapConfig config = repository.getConfig(); MapConfig config = repository.getConfig();
boolean switchSingleHandle = config.isSwitchSingleHandle(); boolean switchSingleHandle = config.isSwitchSingleHandle();
boolean isRailway = config.isRailway(); // 大铁逻辑 boolean isRailway = config.isRailway(); // 大铁逻辑
if (train.isCommunicable() || isRailway) { // 通信车占用 或者 大铁配置 if (train.isCommunicable() || isRailway) { // 通信车占用 或者 大铁配置
// 车尾位置追加不确定性距离(速度*2)m // 车尾位置追加不确定性距离(速度*2)m
SectionPosition trainTailPosition = CalculateService SectionPosition trainTailPosition = CalculateService
.calculateNextPositionByStartAndLen(trainHeadPosition, !right, train.getLen() + train.getSpeed() * 2, false); .calculateNextPositionByStartAndLen(trainHeadPosition, !right,
atpSectionList = CalculateService.getAtpSections(trainHeadPosition, trainTailPosition, train.getLen() + train.getSpeed() * 2, false);
right, switchSingleHandle); atpSectionList = CalculateService.getAtpSections(trainHeadPosition, trainTailPosition,
List<Section> removes = new ArrayList<>(); right, switchSingleHandle);
for (Section atpSection : atpSectionList) { List<Section> removes = new ArrayList<>();
Section axle = atpSection; for (Section atpSection : atpSectionList) {
Section parent = atpSection.getParent(); Section axle = atpSection;
if (parent != null) { Section parent = atpSection.getParent();
axle = parent; if (parent != null) {
} axle = parent;
if (axle.isAxleCounter() && (!axle.isNctOccupied() || Section.AxleFault.FAULT.equals(axle.getFault()))) { }
removes.add(atpSection); if (axle.isAxleCounter() && (!axle.isNctOccupied() || Section.AxleFault.FAULT.equals(
continue; axle.getFault()))) {
} removes.add(atpSection);
continue;
}
// atpSection.communicateTrainOccupy(right); // atpSection.communicateTrainOccupy(right);
} }
if (!removes.isEmpty()) { if (!removes.isEmpty()) {
atpSectionList.removeAll(removes); atpSectionList.removeAll(removes);
} }
} else { // 非通信车 } else { // 非通信车
List<Section> sectionList = repository.queryTrainOccupySectionList(train.getGroupNumber()); List<Section> sectionList = repository.queryTrainOccupySectionList(train.getGroupNumber());
if (!CollectionUtils.isEmpty(sectionList)) { if (!CollectionUtils.isEmpty(sectionList)) {
for (Section section : sectionList) { for (Section section : sectionList) {
if (section.isSwitchAxleCounterSection()) { if (section.isSwitchAxleCounterSection()) {
Section switchSection = section.getLogicList().get(0); Section switchSection = section.getLogicList().get(0);
atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPosition()); atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPosition());
continue; continue;
} }
if (CollectionUtils.isEmpty(section.getLogicList())) { if (CollectionUtils.isEmpty(section.getLogicList())) {
atpSectionList.add(section); atpSectionList.add(section);
} else { } else {
atpSectionList.addAll(section.getLogicList()); atpSectionList.addAll(section.getLogicList());
} }
} }
} }
//将列车占压的物理区段及其关联的逻辑区段全部设为非通信车占用 //将列车占压的物理区段及其关联的逻辑区段全部设为非通信车占用
// atpSectionList.forEach(atpSection -> atpSection.nonCommunicateTrainOccupy(right)); // atpSectionList.forEach(atpSection -> atpSection.nonCommunicateTrainOccupy(right));
}
return atpSectionList;
} }
return atpSectionList;
}
/** /**
* ARB检测 * ARB检测
* *
* @param simulation * @param simulation
* @param section * @param section
* @param sectionList * @param sectionList
*/ */
public void sectionARBCheck(Simulation simulation, Section section, List<Section> sectionList) { public void sectionARBCheck(Simulation simulation, Section section, List<Section> sectionList) {
//目前ARB故障才会导致ARB判定 //目前ARB故障才会导致ARB判定
if (Section.AxleFault.ARB.equals(section.getFault()) && section.getVirtualAxleCounter().isOccupy()) { if (Section.AxleFault.ARB.equals(section.getFault()) && section.getVirtualAxleCounter()
if (!sectionList.contains(section)) { .isOccupy()) {
section.judgeAsARB(); if (!sectionList.contains(section)) {
} else { section.judgeAsARB();
section.setFault(Section.AxleFault.FAULT); } else {
} section.setFault(Section.AxleFault.FAULT);
} else if (Section.AxleFault.FAULT.equals(section.getFault()) && section.getVirtualAxleCounter().isOccupy()) { }
section.judgeAsNctOccupied(simulation); } else if (Section.AxleFault.FAULT.equals(section.getFault()) && section.getVirtualAxleCounter()
} .isOccupy()) {
if (/*!section.isInvalid() &&*/ section.isNctOccupied()) { section.judgeAsNctOccupied(simulation);
if (!sectionList.contains(section)) {
section.judgeAsNctOccupied(simulation);
}
}
//ARB故障恢复判断
if (Section.AxleFault.ARB.equals(section.getFault()) && !section.getVirtualAxleCounter().isOccupy()) {
Section.AxleFault.ARB.fix(section);
}
} }
if (/*!section.isInvalid() &&*/ section.isNctOccupied()) {
section.judgeAsNctOccupied(simulation);
}
//ARB故障恢复判断
if (Section.AxleFault.ARB.equals(section.getFault()) && !section.getVirtualAxleCounter()
.isOccupy()) {
Section.AxleFault.ARB.fix(section);
}
}
/** /**
* 获取非通信车可能存在的范围 * 获取非通信车可能存在的范围
* *
* @param simulation * @param simulation
* @param trainList * @param trainList
* @return * @return
*/ */
public List<Section> getTrainExistAxleSectionsUnderDelay(Simulation simulation, List<VirtualRealityTrain> trainList) { public List<Section> getTrainExistAxleSectionsUnderDelay(Simulation simulation,
List<Section> list = new ArrayList<>(); List<VirtualRealityTrain> trainList) {
for (VirtualRealityTrain train : trainList) { List<Section> list = new ArrayList<>();
//只统计非通信车 for (VirtualRealityTrain train : trainList) {
if (train.isCommunicable()) //只统计非通信车
continue; if (train.isCommunicable()) {
boolean right = train.isRight(); continue;
SectionPosition headPosition = train.getHeadPosition(); }
float offset = 50; boolean right = train.isRight();
SectionPosition head = CalculateService SectionPosition headPosition = train.getHeadPosition();
.calculateNextPositionByStartAndLen(headPosition, right, offset, false); float offset = 50;
// 考虑列车最大可能占用区间用于判断ARB区段 SectionPosition head = CalculateService
SectionPosition tail = CalculateService .calculateNextPositionByStartAndLen(headPosition, right, offset, false);
.calculateNextPositionByStartAndLen(headPosition, // 考虑列车最大可能占用区间用于判断ARB区段
!right, train.getLen() + offset, false); SectionPosition tail = CalculateService
List<Section> sectionList = CalculateService.getTrainOccupyAxleSection(head, tail, right); .calculateNextPositionByStartAndLen(headPosition,
if (!CollectionUtils.isEmpty(sectionList)) { !right, train.getLen() + offset, false);
for (Section section : sectionList) { List<Section> sectionList = CalculateService.getTrainOccupyAxleSection(head, tail, right);
if (!list.contains(section)) { if (!CollectionUtils.isEmpty(sectionList)) {
list.add(section); for (Section section : sectionList) {
} if (!list.contains(section)) {
} list.add(section);
} else { }
log.warn(String.format("列车[%s]没有存在范围的计轴区段",
train.getGroupNumber()));
}
} }
return list; } else {
log.warn(String.format("列车[%s]没有存在范围的计轴区段",
train.getGroupNumber()));
}
} }
return list;
}
public void removeOfflineTrainOccupySections(Simulation simulation, List<VirtualRealityTrain> onlineTrainList) { public void removeOfflineTrainOccupySections(Simulation simulation,
// 移除已经下线的列车占用区段数据 List<VirtualRealityTrain> onlineTrainList) {
SimulationDataRepository repository = simulation.getRepository(); // 移除已经下线的列车占用区段数据
Set<String> oldTOSKeyList = repository.queryTrainOccupySectionKeys(); SimulationDataRepository repository = simulation.getRepository();
Set<String> currentTrainCodeList = onlineTrainList.stream() Set<String> oldTOSKeyList = repository.queryTrainOccupySectionKeys();
.map(VirtualRealityTrain::getGroupNumber) Set<String> currentTrainCodeList = onlineTrainList.stream()
.collect(Collectors.toSet()); .map(VirtualRealityTrain::getGroupNumber)
oldTOSKeyList.removeAll(currentTrainCodeList); .collect(Collectors.toSet());
oldTOSKeyList.forEach(groupNumber -> { oldTOSKeyList.removeAll(currentTrainCodeList);
List<Section> sections = repository.queryTrainOccupySectionList(groupNumber); oldTOSKeyList.forEach(groupNumber -> {
sections.forEach(section -> { List<Section> sections = repository.queryTrainOccupySectionList(groupNumber);
section.getVirtualAxleCounter().clear(); sections.forEach(section -> {
section.clearOccupy(); section.getVirtualAxleCounter().clear();
}); section.clearOccupy();
repository.deleteTrainOccupySectionList(groupNumber); });
}); repository.deleteTrainOccupySectionList(groupNumber);
} });
}
/** /**
* isSwitchSingleHandle 为TRUE的情况下获取区段列表 * isSwitchSingleHandle 为TRUE的情况下获取区段列表
* *
* @param section 区段 * @param section 区段
* @param right 列车行驶方向 * @param right 列车行驶方向
* @return 区段列表 * @return 区段列表
*/ */
private List<Section> handleSingleSwitchPosition(Section section, boolean right) { private List<Section> handleSingleSwitchPosition(Section section, boolean right) {
List<Section> atpSectionList = new ArrayList<>(); List<Section> atpSectionList = new ArrayList<>();
// 道岔列表 // 道岔列表
List<Switch> relSwitchList = section.getRelSwitchList(); List<Switch> relSwitchList = section.getRelSwitchList();
// 反位情况下 // 反位情况下
Switch relSwitch = null; Switch relSwitch = null;
if (relSwitchList.stream().anyMatch(Switch::isPosR)) { if (relSwitchList.stream().anyMatch(Switch::isPosR)) {
relSwitch = relSwitchList.stream().filter(Switch::isPosR).findFirst().orElse(null); relSwitch = relSwitchList.stream().filter(Switch::isPosR).findFirst().orElse(null);
} else { } else {
relSwitch = relSwitchList.stream().filter(Switch::isPosN).findFirst().orElse(null); relSwitch = relSwitchList.stream().filter(Switch::isPosN).findFirst().orElse(null);
//relSwitchList.forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition())); //relSwitchList.forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition()));
}
if (relSwitch != null) {
// 反位前区段列表
Section nextSection = relSwitch.getA();
do {
atpSectionList.add(0, nextSection);
nextSection = nextSection.getNextRunningSectionOf(!right);
} while (nextSection.getRelSwitch() != null && relSwitchList.contains(nextSection.getRelSwitch()));
// 反位后区段列表
nextSection = relSwitch.getA().getNextRunningSectionOf(right);
while (nextSection != null && relSwitchList.contains(nextSection.getRelSwitch())) {
atpSectionList.add(nextSection);
nextSection = nextSection.getNextRunningSectionOf(right);
}
}
return atpSectionList;
} }
if (relSwitch != null) {
// 反位前区段列表
Section nextSection = relSwitch.getA();
do {
atpSectionList.add(0, nextSection);
nextSection = nextSection.getNextRunningSectionOf(!right);
} while (nextSection.getRelSwitch() != null && relSwitchList.contains(
nextSection.getRelSwitch()));
// 反位后区段列表
nextSection = relSwitch.getA().getNextRunningSectionOf(right);
while (nextSection != null && relSwitchList.contains(nextSection.getRelSwitch())) {
atpSectionList.add(nextSection);
nextSection = nextSection.getNextRunningSectionOf(right);
}
}
return atpSectionList;
}
} }

Some files were not shown because too many files have changed in this diff Show More