Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
d648a44369
40
sql/20221008-xia-paper_composition.sql
Normal file
40
sql/20221008-xia-paper_composition.sql
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : room
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80029
|
||||||
|
Source Host : 192.168.3.233:3306
|
||||||
|
Source Schema : joylink
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80029
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 08/10/2022 15:18:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for paper_composition
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `paper_composition`;
|
||||||
|
CREATE TABLE `paper_composition` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷蓝图id',
|
||||||
|
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '试卷蓝图名称',
|
||||||
|
`profile` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '试卷蓝图简介',
|
||||||
|
`company_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '组织id',
|
||||||
|
`start_time` datetime NULL DEFAULT NULL COMMENT '启用起始时间',
|
||||||
|
`end_time` datetime NULL DEFAULT NULL COMMENT '启用截止时间',
|
||||||
|
`valid_duration` int NULL DEFAULT NULL COMMENT '完成考试有效最长时长,单位min',
|
||||||
|
`pass_score` int NULL DEFAULT NULL COMMENT '及格分',
|
||||||
|
`creator_id` bigint NULL DEFAULT NULL COMMENT '创建者id',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`state` int NULL DEFAULT NULL COMMENT '试卷蓝图状态:1-正在编辑,2-封存(不能修改),3-已经被使用(不能修改删除);定于见PaperCompositionState',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
35
sql/20221008-xia-paper_rule.sql
Normal file
35
sql/20221008-xia-paper_rule.sql
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : room
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80029
|
||||||
|
Source Host : 192.168.3.233:3306
|
||||||
|
Source Schema : joylink
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80029
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 08/10/2022 15:18:14
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for paper_rule
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `paper_rule`;
|
||||||
|
CREATE TABLE `paper_rule` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷规则定义id',
|
||||||
|
`pc_id` bigint NULL DEFAULT NULL COMMENT 'paper_compostion的id',
|
||||||
|
`type` int NULL DEFAULT NULL COMMENT '试题类型:1-理论题,2-实训题',
|
||||||
|
`subType` int NULL DEFAULT NULL COMMENT '规则类型:理论题(1-单选题,2-多选题,3-判断题);实训题(4-单操实训,5-场景实训)',
|
||||||
|
`tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '筛选题目的标签,即根据标签来筛选题目;List<String>的json',
|
||||||
|
`sum` int NULL DEFAULT NULL COMMENT '该类型题目数量',
|
||||||
|
`score` int NULL DEFAULT NULL COMMENT '每题分值',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
37
sql/20221008-xia-paper_user.sql
Normal file
37
sql/20221008-xia-paper_user.sql
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : room
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80029
|
||||||
|
Source Host : 192.168.3.233:3306
|
||||||
|
Source Schema : joylink
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80029
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 08/10/2022 15:18:36
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for paper_user
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `paper_user`;
|
||||||
|
CREATE TABLE `paper_user` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户试卷id',
|
||||||
|
`user_id` bigint NOT NULL COMMENT '用户id',
|
||||||
|
`pc_id` bigint NOT NULL COMMENT '生成用户试卷的paper_compostion的id',
|
||||||
|
`company_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '组织id',
|
||||||
|
`score` int NULL DEFAULT NULL COMMENT '用户最终得分',
|
||||||
|
`start_time` datetime NULL DEFAULT NULL COMMENT '用户开始做题时间',
|
||||||
|
`end_time` datetime NULL DEFAULT NULL COMMENT '用户结束做题时间',
|
||||||
|
`cause` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原因',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '用户试卷生成时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
34
sql/20221008-xia-paper_user_question.sql
Normal file
34
sql/20221008-xia-paper_user_question.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : room
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80029
|
||||||
|
Source Host : 192.168.3.233:3306
|
||||||
|
Source Schema : joylink
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80029
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 08/10/2022 15:18:25
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for paper_user_question
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `paper_user_question`;
|
||||||
|
CREATE TABLE `paper_user_question` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户试卷试题结果id',
|
||||||
|
`pu_id` bigint NOT NULL COMMENT '用户试卷paper_user的id',
|
||||||
|
`company_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '组织id',
|
||||||
|
`type` int NULL DEFAULT NULL COMMENT '试题类型:1-理论题,2-实训题',
|
||||||
|
`question_id` bigint NOT NULL COMMENT '试题id',
|
||||||
|
`state` int NULL DEFAULT NULL COMMENT '试题状态:1-未做(初始),2-答对,3-答错,4-时间到结束',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
@ -2,6 +2,7 @@ package club.joylink.rtss.constants;
|
|||||||
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端枚举
|
* 客户端枚举
|
||||||
@ -32,17 +33,22 @@ public enum Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据客户端id查询客户端对象
|
* 根据客户端id查询客户端对象
|
||||||
|
*
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Client getByIdAndSecret(String clientId, String secret) {
|
public static Client getByIdAndSecret(String clientId, String secret) {
|
||||||
|
// 传入为空时,设置默认客户端
|
||||||
|
if (StringUtils.isEmpty(clientId) && StringUtils.isEmpty(secret)) {
|
||||||
|
return Client.Joylink;
|
||||||
|
}
|
||||||
Client[] values = Client.values();
|
Client[] values = Client.values();
|
||||||
for (Client value : values) {
|
for (Client value : values) {
|
||||||
if(value.getId().equals(clientId)
|
if (value.getId().equals(clientId)
|
||||||
&& value.getSecret().equals(secret)) {
|
&& value.getSecret().equals(secret)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw BusinessExceptionAssertEnum.INVALID_CLIENT.exception(String.format("未找到id为[%s]的客户端",clientId));
|
throw BusinessExceptionAssertEnum.INVALID_CLIENT.exception(String.format("未找到id为[%s]的客户端", clientId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import club.joylink.rtss.services.MinioService;
|
|||||||
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.minio.MinioFilePageVO;
|
import club.joylink.rtss.vo.minio.MinioFilePageVO;
|
||||||
|
import io.minio.http.Method;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -17,6 +18,11 @@ public class MinioController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MinioService minioService;
|
private MinioService minioService;
|
||||||
|
|
||||||
|
@GetMapping("/preSignedUrl")
|
||||||
|
public String getPreSignedObjectUrl(String directory, String fileName, Method method) {
|
||||||
|
return minioService.preSignedObjectUrl(directory, fileName, method);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/file/save")
|
@PostMapping("/file/save")
|
||||||
public void saveFile(@RequestAttribute AccountVO user, @RequestBody MinioFileInfo fileInfo) {
|
public void saveFile(@RequestAttribute AccountVO user, @RequestBody MinioFileInfo fileInfo) {
|
||||||
minioService.saveFileInfo(user, fileInfo);
|
minioService.saveFileInfo(user, fileInfo);
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package club.joylink.rtss.controller.draft;
|
package club.joylink.rtss.controller.draft;
|
||||||
|
|
||||||
import club.joylink.rtss.services.draftData.DraftMapDisStationService;
|
import club.joylink.rtss.services.draftData.DraftMapDisStationService;
|
||||||
|
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||||
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
|
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
|
||||||
|
import lombok.Data;
|
||||||
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.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -39,4 +42,18 @@ public class DraftMapDisStationController {
|
|||||||
public void delete(@PathVariable("id") Long mapId,@PathVariable("code") String code){
|
public void delete(@PathVariable("id") Long mapId,@PathVariable("code") String code){
|
||||||
this.draftMapDisStationService.delete(mapId,code);
|
this.draftMapDisStationService.delete(mapId,code);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 分页获取调度台
|
||||||
|
*/
|
||||||
|
@PostMapping("/page")
|
||||||
|
public PageVO<MapDisStationNewVO> findByPage(@PathVariable("id") Long mapId, @RequestBody FindByPageReq req){
|
||||||
|
return this.draftMapDisStationService.findByPage(mapId,req);
|
||||||
|
}
|
||||||
|
@Data
|
||||||
|
public static class FindByPageReq extends PageQueryVO{
|
||||||
|
/**
|
||||||
|
* 是否降序,true-降序,false-升序,默认值为true;
|
||||||
|
*/
|
||||||
|
private Boolean desc = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package club.joylink.rtss.controller.paper;
|
package club.joylink.rtss.controller.paper;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.paper.*;
|
import club.joylink.rtss.vo.paper.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||||
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;
|
||||||
|
|
||||||
@ -14,7 +18,12 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v2/test/paper")
|
@RequestMapping("/api/v2/test/paper")
|
||||||
public class PaperApiTestController {
|
public class PaperApiTestController {
|
||||||
|
@Autowired
|
||||||
|
private PaperApiTestService paperApiTestService;
|
||||||
|
@PostMapping("/create/common")
|
||||||
|
public void createCommonQuestions(@RequestAttribute AccountVO user){
|
||||||
|
paperApiTestService.addTestQuestions(user);
|
||||||
|
}
|
||||||
public static void createPaperCompositionReqVo(){
|
public static void createPaperCompositionReqVo(){
|
||||||
CreatePaperCompositionReqVo rt = new CreatePaperCompositionReqVo();
|
CreatePaperCompositionReqVo rt = new CreatePaperCompositionReqVo();
|
||||||
rt.setName("测试试卷1");
|
rt.setName("测试试卷1");
|
||||||
@ -71,6 +80,24 @@ public class PaperApiTestController {
|
|||||||
rt.setTags(tags);
|
rt.setTags(tags);
|
||||||
System.out.println(JsonUtils.writeValueAsString(rt));
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
}
|
}
|
||||||
|
public static void paperSubmitAnswerReqVo(){
|
||||||
|
PaperSubmitAnswerReqVo rt = new PaperSubmitAnswerReqVo();
|
||||||
|
rt.setPuId(1L);
|
||||||
|
rt.setPqId(1L);
|
||||||
|
rt.setType(PaperQType.GroupType.Common);
|
||||||
|
rt.setSubType(PaperQType.SubType.Select);
|
||||||
|
List<String> answer = new ArrayList<>();
|
||||||
|
answer.add("1");
|
||||||
|
answer.add("3");
|
||||||
|
rt.setAnswer(answer);
|
||||||
|
rt.setTrainingSuccess(true);
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void findPaperUserForCompositionReqVo(){
|
||||||
|
FindPaperUserForCompositionReqVo rt = new FindPaperUserForCompositionReqVo();
|
||||||
|
rt.setPcId(2L);
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
public static void main(String[]args){
|
public static void main(String[]args){
|
||||||
createPaperCompositionReqVo();
|
createPaperCompositionReqVo();
|
||||||
paperCompositionBasicVo();
|
paperCompositionBasicVo();
|
||||||
@ -78,5 +105,7 @@ public class PaperApiTestController {
|
|||||||
findPaperCompositionPageReqVo();
|
findPaperCompositionPageReqVo();
|
||||||
createPaperRuleReqVo();
|
createPaperRuleReqVo();
|
||||||
paperRuleVo();
|
paperRuleVo();
|
||||||
|
paperSubmitAnswerReqVo();
|
||||||
|
findPaperUserForCompositionReqVo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package club.joylink.rtss.controller.paper;
|
||||||
|
|
||||||
|
import club.joylink.rtss.dao.paper.PaperQuestionDAO;
|
||||||
|
import club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
|
import club.joylink.rtss.vo.paper.PaperCommonQuestionVo;
|
||||||
|
import club.joylink.rtss.vo.paper.PaperQType;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PaperApiTestService {
|
||||||
|
@Autowired
|
||||||
|
private PaperQuestionDAO paperQuestionDAO;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void addTestQuestions(AccountVO user){
|
||||||
|
user.setCompanyId(1L);
|
||||||
|
//单选1
|
||||||
|
for(int i=0;i<200;i++){
|
||||||
|
PaperQuestionWithBLOBs select = new PaperQuestionWithBLOBs();
|
||||||
|
select.setType(PaperQType.CommonQType.select.name());
|
||||||
|
select.setQuestion("我是选择题"+i);
|
||||||
|
select.setCreateUserId(user.getId());
|
||||||
|
select.setCreateTime(LocalDateTime.now());
|
||||||
|
select.setCompanyId(user.getCompanyId());
|
||||||
|
select.setRaceLable("6,8");
|
||||||
|
//
|
||||||
|
List<PaperCommonQuestionVo.OptionVo> opts = new ArrayList<>();
|
||||||
|
PaperCommonQuestionVo.OptionVo opt =new PaperCommonQuestionVo.OptionVo();
|
||||||
|
opt.setId(i);
|
||||||
|
opt.setContent("我是选择题"+i);
|
||||||
|
opts.add(opt);
|
||||||
|
//
|
||||||
|
select.setQuestionOption(JsonUtils.writeValueAsString(opts));
|
||||||
|
select.setQuestionAnswer(String.valueOf(i%4));
|
||||||
|
select.setIsDel(0);
|
||||||
|
//
|
||||||
|
paperQuestionDAO.insertSelective(select);
|
||||||
|
}
|
||||||
|
//多选2
|
||||||
|
for(int i=0;i<200;i++){
|
||||||
|
PaperQuestionWithBLOBs select = new PaperQuestionWithBLOBs();
|
||||||
|
select.setType(PaperQType.CommonQType.multi.name());
|
||||||
|
select.setQuestion("我是多选题"+i);
|
||||||
|
select.setCreateUserId(user.getId());
|
||||||
|
select.setCreateTime(LocalDateTime.now());
|
||||||
|
select.setCompanyId(user.getCompanyId());
|
||||||
|
select.setRaceLable("7,9");
|
||||||
|
//
|
||||||
|
List<PaperCommonQuestionVo.OptionVo> opts = new ArrayList<>();
|
||||||
|
PaperCommonQuestionVo.OptionVo opt =new PaperCommonQuestionVo.OptionVo();
|
||||||
|
opt.setId(i);
|
||||||
|
opt.setContent("我是多选题"+i);
|
||||||
|
opts.add(opt);
|
||||||
|
//
|
||||||
|
select.setQuestionOption(JsonUtils.writeValueAsString(opts));
|
||||||
|
select.setQuestionAnswer("2,3,4");
|
||||||
|
select.setIsDel(0);
|
||||||
|
//
|
||||||
|
paperQuestionDAO.insertSelective(select);
|
||||||
|
}
|
||||||
|
//判断题3
|
||||||
|
for(int i=0;i<200;i++){
|
||||||
|
PaperQuestionWithBLOBs select = new PaperQuestionWithBLOBs();
|
||||||
|
select.setType(PaperQType.CommonQType.judge.name());
|
||||||
|
select.setQuestion("我是判断题"+i);
|
||||||
|
select.setCreateUserId(user.getId());
|
||||||
|
select.setCreateTime(LocalDateTime.now());
|
||||||
|
select.setCompanyId(user.getCompanyId());
|
||||||
|
select.setRaceLable("7,9");
|
||||||
|
//
|
||||||
|
List<PaperCommonQuestionVo.OptionVo> opts = new ArrayList<>();
|
||||||
|
PaperCommonQuestionVo.OptionVo opt =new PaperCommonQuestionVo.OptionVo();
|
||||||
|
opt.setId(i);
|
||||||
|
opt.setContent("我是判断题"+i);
|
||||||
|
opts.add(opt);
|
||||||
|
//
|
||||||
|
select.setQuestionOption(JsonUtils.writeValueAsString(opts));
|
||||||
|
select.setQuestionAnswer("2");
|
||||||
|
select.setIsDel(0);
|
||||||
|
//
|
||||||
|
paperQuestionDAO.insertSelective(select);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,14 +38,20 @@ public class PaperUserController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户试卷完整信息
|
* 获取用户试卷完整信息
|
||||||
*
|
|
||||||
* @param puId 用户试卷id
|
* @param puId 用户试卷id
|
||||||
*/
|
*/
|
||||||
@GetMapping("/user/{puId}")
|
@GetMapping("/user/{puId}")
|
||||||
public PaperUserWholeVo findPaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
public PaperUserWholeVo findPaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
||||||
return this.paperUserService.findPaperUser(puId, user);
|
return this.paperUserService.findPaperUser(puId, user);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 删除用户试卷
|
||||||
|
* @param puId 用户试卷id
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/user/{puId}")
|
||||||
|
public void deletePaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user){
|
||||||
|
this.paperUserService.deletePaperUser(puId,user);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 开始答题
|
* 开始答题
|
||||||
*
|
*
|
||||||
@ -75,7 +81,6 @@ public class PaperUserController {
|
|||||||
@GetMapping("/user/question/{groupType}/{qId}")
|
@GetMapping("/user/question/{groupType}/{qId}")
|
||||||
public PaperQuestionLoadRspVo loadQuestion(@PathVariable("groupType") Integer groupType, @PathVariable("qId") Long qId, @RequestAttribute AccountVO user) {
|
public PaperQuestionLoadRspVo loadQuestion(@PathVariable("groupType") Integer groupType, @PathVariable("qId") Long qId, @RequestAttribute AccountVO user) {
|
||||||
PaperQType.GroupType pgType = PaperQType.GroupType.getItem(groupType);
|
PaperQType.GroupType pgType = PaperQType.GroupType.getItem(groupType);
|
||||||
|
|
||||||
return this.paperUserLoadQuestionService.loadQuestion(pgType, qId, user);
|
return this.paperUserLoadQuestionService.loadQuestion(pgType, qId, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,4 +103,5 @@ public class PaperUserController {
|
|||||||
return this.paperUserFindPageService.findPaperUserByPage(req,user);
|
return this.paperUserFindPageService.findPaperUserByPage(req,user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import club.joylink.rtss.util.MinioClientUtil;
|
|||||||
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.minio.MinioFilePageVO;
|
import club.joylink.rtss.vo.minio.MinioFilePageVO;
|
||||||
|
import io.minio.http.Method;
|
||||||
|
|
||||||
public interface MinioService {
|
public interface MinioService {
|
||||||
/**
|
/**
|
||||||
@ -12,6 +13,8 @@ public interface MinioService {
|
|||||||
*/
|
*/
|
||||||
MinioClientUtil createMinioClientUtil(String directory);
|
MinioClientUtil createMinioClientUtil(String directory);
|
||||||
|
|
||||||
|
String preSignedObjectUrl(String directory, String fileName, Method method);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前端保存minio上传的文件信息
|
* 前端保存minio上传的文件信息
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import club.joylink.rtss.vo.client.PageVO;
|
|||||||
import club.joylink.rtss.vo.minio.MinioFilePageVO;
|
import club.joylink.rtss.vo.minio.MinioFilePageVO;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import io.minio.http.Method;
|
||||||
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.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -38,6 +39,12 @@ public class MinioServiceImpl implements MinioService {
|
|||||||
return minioClientUtil;
|
return minioClientUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String preSignedObjectUrl(String directory, String fileName, Method method) {
|
||||||
|
MinioClientUtil minioClientUtil = createMinioClientUtil(directory);
|
||||||
|
return minioClientUtil.getPreSignedObjectUrl(fileName, method);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveFileInfo(AccountVO user, MinioFileInfo minioFileInfo) {
|
public void saveFileInfo(AccountVO user, MinioFileInfo minioFileInfo) {
|
||||||
minioFileInfo.setCreator(user.getId());
|
minioFileInfo.setCreator(user.getId());
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package club.joylink.rtss.services.draftData;
|
package club.joylink.rtss.services.draftData;
|
||||||
|
|
||||||
|
import club.joylink.rtss.controller.draft.DraftMapDisStationController;
|
||||||
import club.joylink.rtss.dao.DraftMapDisStationDAO;
|
import club.joylink.rtss.dao.DraftMapDisStationDAO;
|
||||||
import club.joylink.rtss.entity.DraftMapDisStation;
|
import club.joylink.rtss.entity.DraftMapDisStation;
|
||||||
import club.joylink.rtss.entity.DraftMapDisStationExample;
|
import club.joylink.rtss.entity.DraftMapDisStationExample;
|
||||||
|
import club.joylink.rtss.entity.paper.PaperUser;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
|
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
|
||||||
|
import club.joylink.rtss.vo.paper.PaperUserInfoVo;
|
||||||
|
import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor;
|
||||||
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;
|
||||||
@ -75,6 +80,35 @@ public class DraftMapDisStationService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
|
public PageVO<MapDisStationNewVO> findByPage(Long mapId, DraftMapDisStationController.FindByPageReq req){
|
||||||
|
PageVO<MapDisStationNewVO> page = new PageVO<>();
|
||||||
|
DraftMapDisStationExample example = new DraftMapDisStationExample();
|
||||||
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
|
long sum = draftMapDisStationDAO.countByExample(example);
|
||||||
|
page.setTotal(sum);
|
||||||
|
page.setPageNum(req.getPageNum());
|
||||||
|
page.setPageSize(req.getPageSize());
|
||||||
|
page.setList(new ArrayList<>());
|
||||||
|
if (sum > 0) {
|
||||||
|
//
|
||||||
|
String orderBy = "id";
|
||||||
|
long startIndex = (req.getPageNum() - 1) * req.getPageSize();
|
||||||
|
//
|
||||||
|
if (req.getDesc()) {
|
||||||
|
example.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize()));
|
||||||
|
} else {
|
||||||
|
example.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize()));
|
||||||
|
}
|
||||||
|
List<DraftMapDisStation> pContent = this.draftMapDisStationDAO.selectByExample(example);
|
||||||
|
if (null != pContent) {
|
||||||
|
pContent.forEach(t -> {
|
||||||
|
page.getList().add(convert(t));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public List<MapDisStationNewVO> getAll(Long mapId){
|
public List<MapDisStationNewVO> getAll(Long mapId){
|
||||||
List<MapDisStationNewVO> list = new ArrayList<>();
|
List<MapDisStationNewVO> list = new ArrayList<>();
|
||||||
DraftMapDisStationExample example = new DraftMapDisStationExample();
|
DraftMapDisStationExample example = new DraftMapDisStationExample();
|
||||||
|
@ -63,15 +63,19 @@ public class OrgProjectService implements IOrgProjectService {
|
|||||||
}
|
}
|
||||||
// 用户关联组织ID列表
|
// 用户关联组织ID列表
|
||||||
List<Long> orgIdList = orgUserList.stream().map(OrgUser::getOrgId).distinct().collect(Collectors.toList());
|
List<Long> orgIdList = orgUserList.stream().map(OrgUser::getOrgId).distinct().collect(Collectors.toList());
|
||||||
// 项目关联顶级组织ID
|
|
||||||
List<Long> orgTopIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList());
|
|
||||||
// 用户关联组织信息
|
// 用户关联组织信息
|
||||||
OrgExample orgExample = new OrgExample();
|
OrgExample orgExample = new OrgExample();
|
||||||
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList).andRootIdIn(orgTopIdList);
|
|
||||||
List<Org> orgList = orgDAO.selectByExample(orgExample);
|
|
||||||
// 筛选出有权限的顶级组织
|
|
||||||
orgIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList());
|
|
||||||
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList);
|
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList);
|
||||||
|
List<Org> orgList = orgDAO.selectByExample(orgExample);
|
||||||
|
if (CollectionUtils.isEmpty(orgUserList)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<Long> userOrgTopIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList());
|
||||||
|
// 有权限的组织ID
|
||||||
|
List<Long> authOrgIdList = orgProjectList.stream().filter(orgProject -> userOrgTopIdList.contains(orgProject.getOrgId()))
|
||||||
|
.map(OrgProject::getOrgId).collect(Collectors.toList());
|
||||||
|
orgExample = new OrgExample();
|
||||||
|
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(authOrgIdList);
|
||||||
orgList = orgDAO.selectByExample(orgExample);
|
orgList = orgDAO.selectByExample(orgExample);
|
||||||
return orgList.stream().map(OrgProjectVO::new).collect(Collectors.toList());
|
return orgList.stream().map(OrgProjectVO::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -89,14 +93,14 @@ public class OrgProjectService implements IOrgProjectService {
|
|||||||
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andRootIdEqualTo(orgId);
|
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andRootIdEqualTo(orgId);
|
||||||
List<Org> orgList = orgDAO.selectByExample(orgExample);
|
List<Org> orgList = orgDAO.selectByExample(orgExample);
|
||||||
// 没有顶级项目
|
// 没有顶级项目
|
||||||
Org topOrg = orgList.stream().filter(o -> o.getId() == o.getRootId()).findFirst().orElse(null);
|
Org topOrg = orgList.stream().filter(o -> o.getId().equals(o.getRootId())).findFirst().orElse(null);
|
||||||
if (topOrg == null) {
|
if (topOrg == null) {
|
||||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||||
}
|
}
|
||||||
List<Long> orgIdList = orgList.stream().map(Org::getId).distinct().collect(Collectors.toList());
|
List<Long> orgIdList = orgList.stream().map(Org::getId).distinct().collect(Collectors.toList());
|
||||||
// 检验用户是否有组织信息
|
// 检验用户是否有组织信息
|
||||||
OrgUserExample example = new OrgUserExample();
|
OrgUserExample example = new OrgUserExample();
|
||||||
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andIdIn(orgIdList);
|
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdIn(orgIdList);
|
||||||
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
|
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
|
||||||
if (CollectionUtils.isEmpty(orgUserList)) {
|
if (CollectionUtils.isEmpty(orgUserList)) {
|
||||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||||
@ -123,8 +127,8 @@ public class OrgProjectService implements IOrgProjectService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Long orgId, List<String> projectList, AccountVO user) {
|
public void update(Long orgId, List<String> projectList, AccountVO user) {
|
||||||
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
||||||
|
orgProjectExample.createCriteria().andOrgIdEqualTo(orgId);
|
||||||
if (CollectionUtils.isEmpty(projectList)) { // 为空,直接删除项目列表
|
if (CollectionUtils.isEmpty(projectList)) { // 为空,直接删除项目列表
|
||||||
orgProjectExample.createCriteria().andOrgIdEqualTo(orgId);
|
|
||||||
orgProjectDao.deleteByExampleSelective(orgProjectExample);
|
orgProjectDao.deleteByExampleSelective(orgProjectExample);
|
||||||
} else {
|
} else {
|
||||||
List<OrgProject> orgProjects = orgProjectDao.selectByExample(orgProjectExample);
|
List<OrgProject> orgProjects = orgProjectDao.selectByExample(orgProjectExample);
|
||||||
|
@ -17,6 +17,7 @@ import club.joylink.rtss.vo.paper.CreatePaperRspVo;
|
|||||||
import club.joylink.rtss.vo.paper.PaperCompositionState;
|
import club.joylink.rtss.vo.paper.PaperCompositionState;
|
||||||
import club.joylink.rtss.vo.paper.PaperQType;
|
import club.joylink.rtss.vo.paper.PaperQType;
|
||||||
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
||||||
|
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;
|
||||||
@ -29,6 +30,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 创建用户试卷业务
|
* 创建用户试卷业务
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class PaperUserCreateService {
|
public class PaperUserCreateService {
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -112,46 +114,18 @@ public class PaperUserCreateService {
|
|||||||
private void dispatcherCommonQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
private void dispatcherCommonQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
||||||
final int qSum = rule.getSum();//该类型问题个数
|
final int qSum = rule.getSum();//该类型问题个数
|
||||||
//
|
//
|
||||||
PaperQuestionExample questionExample = this.commonQuestionExample(pu, pc, rule, null, null);
|
PaperQuestionExample questionExample = this.commonQuestionExample(pu, pc, rule);
|
||||||
//符合条件的题目数目
|
//符合条件的题目数目
|
||||||
long count = questionDAO.countByExample(questionExample);
|
long count = questionDAO.countByExample(questionExample);
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
||||||
//引入随机数
|
final String orderBy = "rand()";
|
||||||
//每页记录数
|
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
||||||
final int pageSize = 5;
|
List<PaperQuestion> findRand = questionDAO.selectByExample(questionExample);
|
||||||
//页数
|
|
||||||
final long pageSum = count / pageSize + count % pageSize > 0 ? 1 : 0;
|
|
||||||
//随机生成页码
|
|
||||||
int pageNum = (int) (Math.random() * pageSum) + 1;
|
|
||||||
//在页内随机选择一条,在该条前后连续取够qSum个问题
|
|
||||||
long startIndex = (pageNum - 1) * pageSize;
|
|
||||||
final String orderBy = "id";
|
|
||||||
questionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, pageSize));
|
|
||||||
List<PaperQuestion> page = questionDAO.selectByExample(questionExample);
|
|
||||||
final int randomIndex = (int) (Math.random() * page.size());
|
|
||||||
//选择该题目后边连续qSum个
|
|
||||||
PaperQuestion randomQuestion = page.get(randomIndex);
|
|
||||||
final List<PaperQuestion> questionList = new ArrayList<>(qSum);
|
|
||||||
questionList.add(randomQuestion);
|
|
||||||
final int questionSum = qSum - 1;
|
|
||||||
PaperQuestionExample greaterExample = this.commonQuestionExample(pu, pc, rule, true, randomQuestion.getId());
|
|
||||||
greaterExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, questionSum));
|
|
||||||
List<PaperQuestion> greaterList = questionDAO.selectByExample(greaterExample);
|
|
||||||
if (!CollectionUtils.isEmpty(greaterList)) {
|
|
||||||
questionList.addAll(greaterList);
|
|
||||||
}
|
|
||||||
final int lessSum = questionSum - questionList.size();
|
|
||||||
if (lessSum > 0) {
|
|
||||||
PaperQuestionExample lessExample = this.commonQuestionExample(pu, pc, rule, false, randomQuestion.getId());
|
|
||||||
lessExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, lessSum));
|
|
||||||
List<PaperQuestion> lessList = questionDAO.selectByExample(lessExample);
|
|
||||||
questionList.addAll(lessList);
|
|
||||||
}
|
|
||||||
//校验最终查询到的题目数目
|
//校验最终查询到的题目数目
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(questionList.size() == qSum, "没有足够的符合条件的理论题目");
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(findRand.size() == qSum, "没有足够的符合条件的理论题目");
|
||||||
//将题目与试卷关联
|
//将题目与试卷关联
|
||||||
questionList.forEach(q -> {
|
findRand.forEach(q -> {
|
||||||
PaperUserQuestion puq = new PaperUserQuestion();
|
PaperUserQuestion puq = new PaperUserQuestion();
|
||||||
puq.setState(PaperQuestionState.Undo.getValue());
|
puq.setState(PaperQuestionState.Undo.getValue());
|
||||||
puq.setPuId(pu.getId());
|
puq.setPuId(pu.getId());
|
||||||
@ -162,52 +136,25 @@ public class PaperUserCreateService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机选择实训题目
|
* 随机选择实训题目
|
||||||
*/
|
*/
|
||||||
private void dispatcherTrainingQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
private void dispatcherTrainingQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
||||||
final int qSum = rule.getSum();//该类型问题个数
|
final int qSum = rule.getSum();//该类型问题个数
|
||||||
//
|
//
|
||||||
PublishedTraining2Example questionExample = this.trainingQuestionExample(pu, pc, rule, null, null);
|
PublishedTraining2Example questionExample = this.trainingQuestionExample(pu, pc, rule);
|
||||||
//符合条件的题目数目
|
//符合条件的题目数目
|
||||||
long count = trainingDAO.countByExample(questionExample);
|
long count = trainingDAO.countByExample(questionExample);
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
||||||
//引入随机数
|
final String orderBy = "rand()";
|
||||||
//每页记录数
|
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
||||||
final int pageSize = 5;
|
List<PublishedTraining2> findRand = trainingDAO.selectByExample(questionExample);
|
||||||
//页数
|
|
||||||
final long pageSum = count / pageSize + count % pageSize > 0 ? 1 : 0;
|
|
||||||
//随机生成页码
|
|
||||||
int pageNum = (int) (Math.random() * pageSum) + 1;
|
|
||||||
//在页内随机选择一条,在该条前后连续取够qSum个问题
|
|
||||||
long startIndex = (pageNum - 1) * pageSize;
|
|
||||||
final String orderBy = "id";
|
|
||||||
questionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, pageSize));
|
|
||||||
List<PublishedTraining2> page = trainingDAO.selectByExample(questionExample);
|
|
||||||
final int randomIndex = (int) (Math.random() * page.size());
|
|
||||||
//选择该题目后边连续qSum个
|
|
||||||
PublishedTraining2 randomQuestion = page.get(randomIndex);
|
|
||||||
final List<PublishedTraining2> questionList = new ArrayList<>(qSum);
|
|
||||||
questionList.add(randomQuestion);
|
|
||||||
final int questionSum = qSum - 1;
|
|
||||||
PublishedTraining2Example greaterExample = this.trainingQuestionExample(pu, pc, rule, true, randomQuestion.getId());
|
|
||||||
greaterExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, questionSum));
|
|
||||||
List<PublishedTraining2> greaterList = trainingDAO.selectByExample(greaterExample);
|
|
||||||
if (!CollectionUtils.isEmpty(greaterList)) {
|
|
||||||
questionList.addAll(greaterList);
|
|
||||||
}
|
|
||||||
final int lessSum = questionSum - questionList.size();
|
|
||||||
if (lessSum > 0) {
|
|
||||||
PublishedTraining2Example lessExample = this.trainingQuestionExample(pu, pc, rule, false, randomQuestion.getId());
|
|
||||||
lessExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, lessSum));
|
|
||||||
List<PublishedTraining2> lessList = trainingDAO.selectByExample(lessExample);
|
|
||||||
questionList.addAll(lessList);
|
|
||||||
}
|
|
||||||
//校验最终查询到的题目数目
|
//校验最终查询到的题目数目
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(questionList.size() == qSum, "没有足够的符合条件的实训题目");
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(findRand.size() == qSum, "没有足够的符合条件的实训题目");
|
||||||
//将题目与试卷关联
|
//将题目与试卷关联
|
||||||
questionList.forEach(q -> {
|
findRand.forEach(q -> {
|
||||||
PaperUserQuestion puq = new PaperUserQuestion();
|
PaperUserQuestion puq = new PaperUserQuestion();
|
||||||
puq.setState(PaperQuestionState.Undo.getValue());
|
puq.setState(PaperQuestionState.Undo.getValue());
|
||||||
puq.setPuId(pu.getId());
|
puq.setPuId(pu.getId());
|
||||||
@ -221,31 +168,18 @@ public class PaperUserCreateService {
|
|||||||
/**
|
/**
|
||||||
* 生成根据tag查询的条件
|
* 生成根据tag查询的条件
|
||||||
*/
|
*/
|
||||||
private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) {
|
private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
||||||
String tags = rule.getTags();//规则标签,list json
|
String tags = rule.getTags();//规则标签,list json
|
||||||
List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
|
List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
||||||
//
|
//
|
||||||
PublishedTraining2Example questionExample = new PublishedTraining2Example();
|
PublishedTraining2Example questionExample = new PublishedTraining2Example();
|
||||||
if (null == tagArray) {
|
if (null == tagArray) {
|
||||||
PublishedTraining2Example.Criteria c = questionExample.createCriteria().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1);//1-上架
|
questionExample.createCriteria().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1);//1-上架
|
||||||
if (null != isGreaterThan && null != id) {
|
|
||||||
if (isGreaterThan) {
|
|
||||||
c.andIdGreaterThan(id);
|
|
||||||
} else {
|
|
||||||
c.andIdLessThan(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (String tag : tagArray) {
|
for (String tag : tagArray) {
|
||||||
PublishedTraining2Example.Criteria c = questionExample.or().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1).andLabelJsonLike(String.format("%%%s%%", tag));
|
questionExample.or().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1).andLabelJsonLike(String.format("%%%s%%", tag));
|
||||||
if (null != isGreaterThan && null != id) {
|
|
||||||
if (isGreaterThan) {
|
|
||||||
c.andIdGreaterThan(id);
|
|
||||||
} else {
|
|
||||||
c.andIdLessThan(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return questionExample;
|
return questionExample;
|
||||||
@ -254,31 +188,19 @@ public class PaperUserCreateService {
|
|||||||
/**
|
/**
|
||||||
* 生成根据tag查询的条件
|
* 生成根据tag查询的条件
|
||||||
*/
|
*/
|
||||||
private PaperQuestionExample commonQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) {
|
private PaperQuestionExample commonQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule) {
|
||||||
String tags = rule.getTags();//规则标签,list json
|
String tags = rule.getTags();//规则标签,list json
|
||||||
List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
|
List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
||||||
//
|
//
|
||||||
PaperQuestionExample questionExample = new PaperQuestionExample();
|
PaperQuestionExample questionExample = new PaperQuestionExample();
|
||||||
if (null == tagArray) {
|
if (null == tagArray) {
|
||||||
PaperQuestionExample.Criteria c = questionExample.createCriteria().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0);
|
questionExample.createCriteria().andCompanyIdEqualTo(Long.valueOf(pc.getCompanyId())).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0);
|
||||||
if (null != isGreaterThan && null != id) {
|
|
||||||
if (isGreaterThan) {
|
|
||||||
c.andIdGreaterThan(id);
|
|
||||||
} else {
|
|
||||||
c.andIdLessThan(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (String tag : tagArray) {
|
for (String tag : tagArray) {
|
||||||
PaperQuestionExample.Criteria c = questionExample.or().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(String.format("%%%s%%", tag));
|
questionExample.or().andCompanyIdEqualTo(Long.valueOf(pc.getCompanyId())).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(String.format("%%%s%%", tag));
|
||||||
if (null != isGreaterThan && null != id) {
|
|
||||||
if (isGreaterThan) {
|
|
||||||
c.andIdGreaterThan(id);
|
|
||||||
} else {
|
|
||||||
c.andIdLessThan(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return questionExample;
|
return questionExample;
|
||||||
|
@ -20,6 +20,9 @@ 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.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -72,6 +75,21 @@ public class PaperUserService {
|
|||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户试卷
|
||||||
|
*
|
||||||
|
* @param puId 用户试卷id
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deletePaperUser(Long puId, AccountVO user) {
|
||||||
|
//删除试卷试题关联表
|
||||||
|
PaperUserQuestionExample puqExample = new PaperUserQuestionExample();
|
||||||
|
puqExample.createCriteria().andPuIdEqualTo(puId);
|
||||||
|
paperUserQuestionDAO.deleteByExample(puqExample);
|
||||||
|
//删除试卷
|
||||||
|
paperUserDAO.deleteByPrimaryKey(puId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始答题
|
* 开始答题
|
||||||
*
|
*
|
||||||
@ -119,9 +137,9 @@ public class PaperUserService {
|
|||||||
for (PaperUserQuestion uq : userQuestionList) {
|
for (PaperUserQuestion uq : userQuestionList) {
|
||||||
switch (PaperQType.GroupType.getItem(uq.getType())) {
|
switch (PaperQType.GroupType.getItem(uq.getType())) {
|
||||||
case Common:
|
case Common:
|
||||||
scoreCommon += calculateCommonScore(uq, ruleMap);
|
scoreCommon += calculateCommonScore(uq, ruleMap);break;
|
||||||
case Training:
|
case Training:
|
||||||
scoreTraining += calculateTrainingScore(uq, ruleMap);
|
scoreTraining += calculateTrainingScore(uq, ruleMap);break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -178,7 +196,7 @@ public class PaperUserService {
|
|||||||
List<PaperUserQuestion> findList = paperUserQuestionDAO.selectByExample(example);
|
List<PaperUserQuestion> findList = paperUserQuestionDAO.selectByExample(example);
|
||||||
List<PaperUserQuestion> commonList = new ArrayList<>();
|
List<PaperUserQuestion> commonList = new ArrayList<>();
|
||||||
List<PaperUserQuestion> trainingList = new ArrayList<>();
|
List<PaperUserQuestion> trainingList = new ArrayList<>();
|
||||||
if (CollectionUtils.isEmpty(findList)) {
|
if (!CollectionUtils.isEmpty(findList)) {
|
||||||
findList.forEach(puq -> {
|
findList.forEach(puq -> {
|
||||||
PaperQType.GroupType type = PaperQType.GroupType.getItem(puq.getType());
|
PaperQType.GroupType type = PaperQType.GroupType.getItem(puq.getType());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,11 @@ public class PaperUserSubmitAnswerService {
|
|||||||
//用户试卷题目
|
//用户试卷题目
|
||||||
final PaperUserQuestionExample puqExample = new PaperUserQuestionExample();
|
final PaperUserQuestionExample puqExample = new PaperUserQuestionExample();
|
||||||
puqExample.createCriteria().andPuIdEqualTo(req.getPuId()).andQuestionIdEqualTo(req.getPqId());
|
puqExample.createCriteria().andPuIdEqualTo(req.getPuId()).andQuestionIdEqualTo(req.getPqId());
|
||||||
final PaperUserQuestion puq = paperUserQuestionDAO.selectByExample(puqExample).get(0);
|
final List<PaperUserQuestion> paperUserQuestionList = paperUserQuestionDAO.selectByExample(puqExample);
|
||||||
|
final String pqNotExistMsg = String.format("用户试卷题目不存在,题目类型:%s 题目子类型:%s 题目id:%s 试卷id:%s",req.getType().name(),req.getSubType().name(),req.getPqId(),req.getPuId());
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(paperUserQuestionList,pqNotExistMsg);
|
||||||
|
//
|
||||||
|
final PaperUserQuestion puq = paperUserQuestionList.get(0);
|
||||||
//用户试卷
|
//用户试卷
|
||||||
final PaperUser pu = paperUserDAO.selectByPrimaryKey(req.getPuId());
|
final PaperUser pu = paperUserDAO.selectByPrimaryKey(req.getPuId());
|
||||||
//生成试卷的试卷蓝图
|
//生成试卷的试卷蓝图
|
||||||
|
@ -41,11 +41,15 @@ public class DisCmdFindService {
|
|||||||
if(is){
|
if(is){
|
||||||
rsp.addDisCmd(cmd.copy());
|
rsp.addDisCmd(cmd.copy());
|
||||||
rsp.addCompany(cp.copy());
|
rsp.addCompany(cp.copy());
|
||||||
rsp.addCompanyState(db.getUnSafeCmdStateMap().get(cp.getId()).copy());
|
if(db.getUnSafeCmdStateMap().containsKey(cp.getId())){
|
||||||
|
rsp.addCompanyState(db.getUnSafeCmdStateMap().get(cp.getId()).copy());
|
||||||
|
}
|
||||||
if(!cp.getRsCompany()){//发令单位
|
if(!cp.getRsCompany()){//发令单位
|
||||||
cmd.getRcvCompanies().forEach(rcp->{
|
cmd.getRcvCompanies().forEach(rcp->{
|
||||||
rsp.addCompany(rcp.copy());
|
rsp.addCompany(rcp.copy());
|
||||||
rsp.addCompanyState(db.getUnSafeCmdStateMap().get(rcp.getId()).copy());
|
if(db.getUnSafeCmdStateMap().containsKey(rcp.getId())){
|
||||||
|
rsp.addCompanyState(db.getUnSafeCmdStateMap().get(rcp.getId()).copy());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class DisCmdSendService {
|
|||||||
cmd.getRcvCompanies().forEach(rc -> {
|
cmd.getRcvCompanies().forEach(rc -> {
|
||||||
if (cpCode.equals(rc.getCode())) {
|
if (cpCode.equals(rc.getCode())) {
|
||||||
DisCmdCompanyState rcState = db.getUnSafeCmdStateMap().get(rc.getId());
|
DisCmdCompanyState rcState = db.getUnSafeCmdStateMap().get(rc.getId());
|
||||||
if (DisCmdCompanyState.Status.Sent.equals(rcState.getState())) {//未读
|
if (null != rcState && DisCmdCompanyState.Status.Sent.equals(rcState.getState())) {//未读
|
||||||
this.sendDisCmdMessage(simulation, db, cmd, rc);
|
this.sendDisCmdMessage(simulation, db, cmd, rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ public class DisCmdSendService {
|
|||||||
DisCmd sendMsg = cmd.createSendMsg(to.getId());
|
DisCmd sendMsg = cmd.createSendMsg(to.getId());
|
||||||
//
|
//
|
||||||
SocketMessageVO<DisCmd> nt = SocketMessageFactory.buildDisCmdAddNotify(simulation.getId(), sendMsg);
|
SocketMessageVO<DisCmd> nt = SocketMessageFactory.buildDisCmdAddNotify(simulation.getId(), sendMsg);
|
||||||
this.pushMessage(simulation,nt,to);
|
this.pushMessage(simulation, nt, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,10 +164,11 @@ public class DisCmdSendService {
|
|||||||
*/
|
*/
|
||||||
public void sendDisCmdSyncMessage(Simulation simulation, DisCmdSyncMsgVo msg, List<DisCmdCompany> toList) {
|
public void sendDisCmdSyncMessage(Simulation simulation, DisCmdSyncMsgVo msg, List<DisCmdCompany> toList) {
|
||||||
SocketMessageVO<DisCmdSyncMsgVo> nt = SocketMessageFactory.buildDisCmdSyncMessage(simulation.getId(), msg);
|
SocketMessageVO<DisCmdSyncMsgVo> nt = SocketMessageFactory.buildDisCmdSyncMessage(simulation.getId(), msg);
|
||||||
for(DisCmdCompany to:toList){
|
for (DisCmdCompany to : toList) {
|
||||||
this.pushMessage(simulation,nt,to);
|
this.pushMessage(simulation, nt, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushMessage(Simulation simulation, SocketMessageVO<?> nt, DisCmdCompany to) {
|
private void pushMessage(Simulation simulation, SocketMessageVO<?> nt, DisCmdCompany to) {
|
||||||
if (DisCmdCompany.Type.Station.equals(to.getCpType())) {//向车站的相关成员发送通知
|
if (DisCmdCompany.Type.Station.equals(to.getCpType())) {//向车站的相关成员发送通知
|
||||||
Station station = simulation.getRepository().getByCode(to.getCode(), Station.class);
|
Station station = simulation.getRepository().getByCode(to.getCode(), Station.class);
|
||||||
|
@ -38,7 +38,9 @@ public class MemberManager {
|
|||||||
public void init(Simulation simulation) {
|
public void init(Simulation simulation) {
|
||||||
/* -----------默认创建一个行调,一个通号;车站和司机按设备创建----------- */
|
/* -----------默认创建一个行调,一个通号;车站和司机按设备创建----------- */
|
||||||
// 调度
|
// 调度
|
||||||
this.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
if (!simulation.getRepository().getConfig().isRailway()){
|
||||||
|
this.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
||||||
|
}
|
||||||
// 通号
|
// 通号
|
||||||
this.addRole(simulation, SimulationMember.Type.MAINTAINER);
|
this.addRole(simulation, SimulationMember.Type.MAINTAINER);
|
||||||
// 行值
|
// 行值
|
||||||
@ -59,12 +61,15 @@ public class MemberManager {
|
|||||||
SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR,
|
SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR,
|
||||||
SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER
|
SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER
|
||||||
).forEach(type -> this.addRole(simulation, type, null, station));
|
).forEach(type -> this.addRole(simulation, type, null, station));
|
||||||
// 调度台--调度关联
|
}
|
||||||
List<DisStation> disStationList = simulation.getRepository().getDisStationList();
|
}
|
||||||
if(null!=disStationList){
|
//调度台
|
||||||
for(DisStation disStation : disStationList){
|
if (simulation.getRepository().getConfig().isRailway()) {
|
||||||
this.addRole(simulation,SimulationMember.Type.DISPATCHER,disStation.getName()+"调度",disStation);
|
// 调度台--调度关联
|
||||||
}
|
List<DisStation> disStationList = simulation.getRepository().getDisStationList();
|
||||||
|
if(null!=disStationList){
|
||||||
|
for(DisStation disStation : disStationList){
|
||||||
|
this.addRole(simulation,SimulationMember.Type.DISPATCHER,disStation.getName()+"调度",disStation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,14 @@ import java.io.*;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class MinioClientUtil {
|
public class MinioClientUtil {
|
||||||
private final static String PATH_SEPARATOR = "/";
|
private final static String PATH_SEPARATOR = "/";
|
||||||
|
|
||||||
private MinioClientConfig config;
|
private MinioClientConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,6 +223,25 @@ public class MinioClientUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预处理连接
|
||||||
|
*/
|
||||||
|
public String getPreSignedObjectUrl(String fileName, Method method) {
|
||||||
|
try {
|
||||||
|
Map<String, String> reqParams = new HashMap<String, String>();
|
||||||
|
reqParams.put("response-content-type", "application/json");
|
||||||
|
return config.getMinioClient().getPresignedObjectUrl(
|
||||||
|
GetPresignedObjectUrlArgs.builder().method(method)
|
||||||
|
.bucket(config.getBucket()).object(getSavePath(fileName))
|
||||||
|
.expiry(60 * 60 * 24)
|
||||||
|
.extraQueryParams(reqParams)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SimulationException(SimulationExceptionType.System_Fault, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getSavePath(String fileName) {
|
private String getSavePath(String fileName) {
|
||||||
return FileInfo.getStoragePath(directory, fileName);
|
return FileInfo.getStoragePath(directory, fileName);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,8 @@ public class LoginUserVO {
|
|||||||
/**
|
/**
|
||||||
* 登陆的客户端id
|
* 登陆的客户端id
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "客户端id不能为空", groups = {LoginInfoCheck.class, ThirdLoginInfoCheck.class})
|
|
||||||
private String clientId;
|
private String clientId;
|
||||||
|
|
||||||
@NotBlank(message = "客户端密钥不能为空", groups = {LoginInfoCheck.class, ThirdLoginInfoCheck.class})
|
|
||||||
private String secret;
|
private String secret;
|
||||||
/**
|
/**
|
||||||
* 所属项目
|
* 所属项目
|
||||||
|
@ -92,41 +92,13 @@ public class PaperQType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 理论题(1-单选题,2-多选题,3-判断题)
|
* 类型 选择题=select,判断题=judge,多选题=multi
|
||||||
*/
|
*/
|
||||||
public enum CommonSubType {
|
public enum CommonQType{
|
||||||
Select(SubType.Select),
|
select,
|
||||||
Multi(SubType.Multi),
|
judge,
|
||||||
Judge(SubType.Judge),
|
multi,
|
||||||
;
|
;
|
||||||
private SubType type;
|
|
||||||
|
|
||||||
private CommonSubType(SubType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubType value() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实训题(4-单操实训,5-场景实训)
|
|
||||||
*/
|
|
||||||
public enum TrainingSubType {
|
|
||||||
Single(SubType.Single),
|
|
||||||
Scene(SubType.Scene),
|
|
||||||
;
|
|
||||||
private SubType type;
|
|
||||||
|
|
||||||
private TrainingSubType(SubType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubType value() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user