Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
480553625e
@ -0,0 +1,82 @@
|
|||||||
|
package club.joylink.rtss.controller.paper;
|
||||||
|
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.paper.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v2/test/paper")
|
||||||
|
public class PaperApiTestController {
|
||||||
|
|
||||||
|
public static void createPaperCompositionReqVo(){
|
||||||
|
CreatePaperCompositionReqVo rt = new CreatePaperCompositionReqVo();
|
||||||
|
rt.setName("测试试卷1");
|
||||||
|
rt.setProfile("XX单位用于测试CMM的试题");
|
||||||
|
rt.setCompanyId("1");
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void paperCompositionBasicVo(){
|
||||||
|
PaperCompositionBasicVo rt = new PaperCompositionBasicVo();
|
||||||
|
rt.setId(1L);
|
||||||
|
rt.setName("测试试卷1");
|
||||||
|
rt.setProfile("XX单位用于测试CMM的试题");
|
||||||
|
rt.setCompanyId("1");
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void paperCompositionDetailVo(){
|
||||||
|
PaperCompositionDetailVo rt = new PaperCompositionDetailVo();
|
||||||
|
rt.setId(1L);
|
||||||
|
rt.setPassScore(60);
|
||||||
|
rt.setValidDuration(120);
|
||||||
|
rt.setStartTime(LocalDateTime.now().plusDays(20));
|
||||||
|
rt.setEndTime(LocalDateTime.now().plusDays(30));
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void findPaperCompositionPageReqVo(){
|
||||||
|
FindPaperCompositionPageReqVo rt = new FindPaperCompositionPageReqVo();
|
||||||
|
rt.setName("2");
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void createPaperRuleReqVo(){
|
||||||
|
CreatePaperRuleReqVo rt = new CreatePaperRuleReqVo();
|
||||||
|
rt.setPcId(1L);
|
||||||
|
rt.setScore(2);
|
||||||
|
rt.setType(PaperQType.GroupType.Common);
|
||||||
|
rt.setSubtype(PaperQType.SubType.Select);
|
||||||
|
rt.setSum(10);
|
||||||
|
List<String> tags = new ArrayList<>();
|
||||||
|
tags.add("6");
|
||||||
|
tags.add("8");
|
||||||
|
rt.setTags(tags);
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void paperRuleVo(){
|
||||||
|
PaperRuleVo rt = new PaperRuleVo();
|
||||||
|
rt.setId(4L);
|
||||||
|
rt.setPcId(1L);
|
||||||
|
rt.setScore(2);
|
||||||
|
rt.setType(PaperQType.GroupType.Common);
|
||||||
|
rt.setSubtype(PaperQType.SubType.Select);
|
||||||
|
rt.setSum(10);
|
||||||
|
List<String> tags = new ArrayList<>();
|
||||||
|
tags.add("6");
|
||||||
|
tags.add("8");
|
||||||
|
rt.setTags(tags);
|
||||||
|
System.out.println(JsonUtils.writeValueAsString(rt));
|
||||||
|
}
|
||||||
|
public static void main(String[]args){
|
||||||
|
createPaperCompositionReqVo();
|
||||||
|
paperCompositionBasicVo();
|
||||||
|
paperCompositionDetailVo();
|
||||||
|
findPaperCompositionPageReqVo();
|
||||||
|
createPaperRuleReqVo();
|
||||||
|
paperRuleVo();
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,9 @@ public class PaperUserController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户提交答案
|
* 用户提交答案
|
||||||
|
* <p>
|
||||||
|
* 对于理论题:用户完成一道题提交一道题的答案;<br>
|
||||||
|
* 对于实训题:用户完成实训操作后,由实训系统自己评判实训是否成功完成,前端提交实训是否成功完成的结果即可。
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/question/answer")
|
@PostMapping("/user/question/answer")
|
||||||
public PaperSubmitAnswerRspVo submitAnswer(@RequestBody PaperSubmitAnswerReqVo req, @RequestAttribute AccountVO user) {
|
public PaperSubmitAnswerRspVo submitAnswer(@RequestBody PaperSubmitAnswerReqVo req, @RequestAttribute AccountVO user) {
|
||||||
|
@ -188,21 +188,14 @@ public class PaperCompositionService {
|
|||||||
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
|
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
|
||||||
if (null != req.getName()) {
|
if (null != req.getName()) {
|
||||||
if (req.getNameLike()) {
|
if (req.getNameLike()) {
|
||||||
pcExCriteria.andNameLike(req.getName());
|
pcExCriteria.andNameLike(String.format("%%%s%%",req.getName()));
|
||||||
} else {
|
} else {
|
||||||
pcExCriteria.andNameEqualTo(req.getName());
|
pcExCriteria.andNameEqualTo(req.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != req.getCompanyId()) {
|
|
||||||
if (req.getProjectCodeLike()) {
|
|
||||||
pcExCriteria.andCompanyIdLike(String.format("%%%s%%",req.getCompanyId()));
|
|
||||||
} else {
|
|
||||||
pcExCriteria.andCompanyIdEqualTo(req.getCompanyId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (null != req.getProfile()) {
|
if (null != req.getProfile()) {
|
||||||
if (req.getProfileLike()) {
|
if (req.getProfileLike()) {
|
||||||
pcExCriteria.andProfileLike(req.getProfile());
|
pcExCriteria.andProfileLike(String.format("%%%s%%",req.getProfile()));
|
||||||
} else {
|
} else {
|
||||||
pcExCriteria.andProfileEqualTo(req.getProfile());
|
pcExCriteria.andProfileEqualTo(req.getProfile());
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ public class PaperRuleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createPaperCompositionRule(CreatePaperRuleReqVo req, AccountVO user) {
|
public void createPaperCompositionRule(CreatePaperRuleReqVo req, AccountVO user) {
|
||||||
|
//
|
||||||
|
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(),req.getType());
|
||||||
//
|
//
|
||||||
assertPaperCompositionRuleNotExist(req.getPcId(),req.getSubtype());
|
assertPaperCompositionRuleNotExist(req.getPcId(),req.getSubtype());
|
||||||
compositionService.assertPaperCompositionCanModify(req.getPcId());
|
compositionService.assertPaperCompositionCanModify(req.getPcId());
|
||||||
@ -68,6 +70,8 @@ public class PaperRuleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updatePaperCompositionRule(PaperRuleVo req, AccountVO user) {
|
public void updatePaperCompositionRule(PaperRuleVo req, AccountVO user) {
|
||||||
|
//
|
||||||
|
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(),req.getType());
|
||||||
//
|
//
|
||||||
assertPaperCompositionRuleCanModify(req.getId());
|
assertPaperCompositionRuleCanModify(req.getId());
|
||||||
//
|
//
|
||||||
|
@ -48,9 +48,9 @@ public class PaperUserSubmitAnswerService {
|
|||||||
//用户试卷
|
//用户试卷
|
||||||
final PaperUser pu = paperUserDAO.selectByPrimaryKey(req.getPuId());
|
final PaperUser pu = paperUserDAO.selectByPrimaryKey(req.getPuId());
|
||||||
//生成试卷的试卷蓝图
|
//生成试卷的试卷蓝图
|
||||||
final PaperComposition pc =paperCompositionDAO.selectByPrimaryKey(pu.getPcId());
|
final PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(pu.getPcId());
|
||||||
//校验
|
//校验
|
||||||
this.assertCanSubmitAnswer(pc,pu,puq,user);
|
this.assertCanSubmitAnswer(pc, pu, puq, user);
|
||||||
//
|
//
|
||||||
final PaperSubmitAnswerRspVo rsp = new PaperSubmitAnswerRspVo();
|
final PaperSubmitAnswerRspVo rsp = new PaperSubmitAnswerRspVo();
|
||||||
rsp.setPuId(req.getPuId());
|
rsp.setPuId(req.getPuId());
|
||||||
@ -78,12 +78,12 @@ public class PaperUserSubmitAnswerService {
|
|||||||
/**
|
/**
|
||||||
* 校验用户此时能否提交答案
|
* 校验用户此时能否提交答案
|
||||||
*/
|
*/
|
||||||
private void assertCanSubmitAnswer(PaperComposition pc, PaperUser pu,PaperUserQuestion puq,AccountVO user) {
|
private void assertCanSubmitAnswer(PaperComposition pc, PaperUser pu, PaperUserQuestion puq, AccountVO user) {
|
||||||
final LocalDateTime now = LocalDateTime.now();
|
final LocalDateTime now = LocalDateTime.now();
|
||||||
final LocalDateTime start = pu.getStartTime();
|
final LocalDateTime start = pu.getStartTime();
|
||||||
final LocalDateTime dead = start.plusMinutes(pc.getValidDuration());
|
final LocalDateTime dead = start.plusMinutes(pc.getValidDuration());
|
||||||
//校验时间
|
//校验时间
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(now.isAfter(dead),"剩余答题时间为0");
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(now.isAfter(dead), "剩余答题时间为0");
|
||||||
//校验重复做题
|
//校验重复做题
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
||||||
}
|
}
|
||||||
@ -92,8 +92,8 @@ public class PaperUserSubmitAnswerService {
|
|||||||
* 处理实训题答案
|
* 处理实训题答案
|
||||||
*/
|
*/
|
||||||
private PaperQuestionState submitTrainingAnswer(PaperUserQuestion puq, PaperSubmitAnswerReqVo req) {
|
private PaperQuestionState submitTrainingAnswer(PaperUserQuestion puq, PaperSubmitAnswerReqVo req) {
|
||||||
//todo
|
|
||||||
return PaperQuestionState.Wrong;
|
return req.getTrainingSuccess() ? PaperQuestionState.Right : PaperQuestionState.Wrong;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,26 +15,6 @@ public enum WebSocketMessageType {
|
|||||||
* 订单支付结果
|
* 订单支付结果
|
||||||
*/
|
*/
|
||||||
Order_Pay_Result,
|
Order_Pay_Result,
|
||||||
/**
|
|
||||||
* 综合演练室-房间消息
|
|
||||||
*/
|
|
||||||
JointTraining_Room,
|
|
||||||
/**
|
|
||||||
* 综合演练室-房间邀请消息
|
|
||||||
*/
|
|
||||||
JointTraining_Room_Invite,
|
|
||||||
/**
|
|
||||||
* 综合演练室-用户消息
|
|
||||||
*/
|
|
||||||
JointTraining_User,
|
|
||||||
/**
|
|
||||||
* 综合演练-设备消息
|
|
||||||
*/
|
|
||||||
JointTraining_Device,
|
|
||||||
/**
|
|
||||||
* 综合演练室-群聊消息
|
|
||||||
*/
|
|
||||||
JointTraining_Chat,
|
|
||||||
/**
|
/**
|
||||||
* 被登出消息
|
* 被登出消息
|
||||||
*/
|
*/
|
||||||
@ -158,26 +138,14 @@ public enum WebSocketMessageType {
|
|||||||
* 仿真-控制权转换申请回复
|
* 仿真-控制权转换申请回复
|
||||||
*/
|
*/
|
||||||
Simulation_ControlTransfer_Reply,
|
Simulation_ControlTransfer_Reply,
|
||||||
/**
|
|
||||||
* 仿真-回放会话消息
|
|
||||||
*/
|
|
||||||
Simulation_PlayBack_Conversation,
|
|
||||||
/**
|
/**
|
||||||
* 仿真-结束消息
|
* 仿真-结束消息
|
||||||
*/
|
*/
|
||||||
Simulation_Over,
|
Simulation_Over,
|
||||||
/**
|
|
||||||
* 仿真-权限用完
|
|
||||||
*/
|
|
||||||
Simulation_Permission_Over,
|
|
||||||
/**
|
/**
|
||||||
* 仿真-任务已加载
|
* 仿真-任务已加载
|
||||||
*/
|
*/
|
||||||
Simulation_Quest_Loaded,
|
Simulation_Quest_Loaded,
|
||||||
/**
|
|
||||||
* 仿真-任务完成
|
|
||||||
*/
|
|
||||||
Simulation_Quest_Finish,
|
|
||||||
/**
|
/**
|
||||||
* 仿真-退出任务
|
* 仿真-退出任务
|
||||||
*/
|
*/
|
||||||
@ -200,10 +168,6 @@ public enum WebSocketMessageType {
|
|||||||
* 仿真-退出剧本
|
* 仿真-退出剧本
|
||||||
*/
|
*/
|
||||||
Simulation_Script_Quit,
|
Simulation_Script_Quit,
|
||||||
/**
|
|
||||||
* 仿真-剧本完成
|
|
||||||
*/
|
|
||||||
Simulation_Script_Finish,
|
|
||||||
/**
|
/**
|
||||||
* 仿真-竞赛实操完成
|
* 仿真-竞赛实操完成
|
||||||
*/
|
*/
|
||||||
@ -229,10 +193,6 @@ public enum WebSocketMessageType {
|
|||||||
* 仿真-暂停/开始消息
|
* 仿真-暂停/开始消息
|
||||||
*/
|
*/
|
||||||
Simulation_Control_Pause,
|
Simulation_Control_Pause,
|
||||||
/**
|
|
||||||
* 仿真回放完成消息
|
|
||||||
*/
|
|
||||||
Simulation_PlayBack_Finish,
|
|
||||||
/**
|
/**
|
||||||
* 仿真驾驶数据路由
|
* 仿真驾驶数据路由
|
||||||
*/
|
*/
|
||||||
|
@ -70,23 +70,11 @@ public class SocketMessageFactory {
|
|||||||
}
|
}
|
||||||
case BROADCAST:
|
case BROADCAST:
|
||||||
case Order_Pay_Result:
|
case Order_Pay_Result:
|
||||||
case JointTraining_Room_Invite:
|
|
||||||
case Be_Logged_Out:
|
case Be_Logged_Out:
|
||||||
case Simulation_Invite: {
|
case Simulation_Invite: {
|
||||||
topicList.add(WebSocketSubscribeTopic.Common);
|
topicList.add(WebSocketSubscribeTopic.Common);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JointTraining_Room:
|
|
||||||
case JointTraining_Device:
|
|
||||||
case JointTraining_Chat: {
|
|
||||||
topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case JointTraining_User: {
|
|
||||||
topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
|
|
||||||
topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Simulation_Time_Sync:
|
case Simulation_Time_Sync:
|
||||||
case Simulation_User:
|
case Simulation_User:
|
||||||
case Simulation_Member:
|
case Simulation_Member:
|
||||||
@ -98,14 +86,10 @@ public class SocketMessageFactory {
|
|||||||
case Simulation_RunAsPlan_Start:
|
case Simulation_RunAsPlan_Start:
|
||||||
case Simulation_RunFact:
|
case Simulation_RunFact:
|
||||||
case Simulation_ApplyHandle:
|
case Simulation_ApplyHandle:
|
||||||
case Simulation_PlayBack_Conversation:
|
|
||||||
case Simulation_Control_Pause:
|
case Simulation_Control_Pause:
|
||||||
case Simulation_Permission_Over:
|
|
||||||
case Simulation_Run_Plan_Reload:
|
case Simulation_Run_Plan_Reload:
|
||||||
case Simulation_Trip_Plan_Change:
|
case Simulation_Trip_Plan_Change:
|
||||||
case Simulation_Scenes_Reload:
|
case Simulation_Scenes_Reload:
|
||||||
case Simulation_Quest_Finish:
|
|
||||||
case Simulation_PlayBack_Finish:
|
|
||||||
case Competition_Practical:
|
case Competition_Practical:
|
||||||
case SIMULATION_RAIL_TICKET:
|
case SIMULATION_RAIL_TICKET:
|
||||||
case Simulation_Alarm: {
|
case Simulation_Alarm: {
|
||||||
@ -139,7 +123,6 @@ public class SocketMessageFactory {
|
|||||||
case Simulation_Script_Action_Tip:
|
case Simulation_Script_Action_Tip:
|
||||||
case Simulation_Script_Action_Finish:
|
case Simulation_Script_Action_Finish:
|
||||||
case Simulation_Script_Action_Error:
|
case Simulation_Script_Action_Error:
|
||||||
case Simulation_Script_Finish:
|
|
||||||
case Simulation_Competition_Practice_Finish:
|
case Simulation_Competition_Practice_Finish:
|
||||||
case Simulation_Script_Action:
|
case Simulation_Script_Action:
|
||||||
case Simulation_Driver_Change:
|
case Simulation_Driver_Change:
|
||||||
|
@ -31,16 +31,6 @@ public class FindPaperCompositionPageReqVo extends PageQueryVO {
|
|||||||
* 选填<br>
|
* 选填<br>
|
||||||
*/
|
*/
|
||||||
private Boolean nameLike = true;
|
private Boolean nameLike = true;
|
||||||
/**
|
|
||||||
* 组织id<br>
|
|
||||||
* 选填<br>
|
|
||||||
*/
|
|
||||||
private String companyId;
|
|
||||||
/**
|
|
||||||
* 项目code--是否模糊查询,默认false<br>
|
|
||||||
* 选填<br>
|
|
||||||
*/
|
|
||||||
private Boolean projectCodeLike = false;
|
|
||||||
/**
|
/**
|
||||||
* 试卷蓝图简介<br>
|
* 试卷蓝图简介<br>
|
||||||
* 选填<br>
|
* 选填<br>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.rtss.vo.paper;
|
package club.joylink.rtss.vo.paper;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
@ -10,6 +11,15 @@ import java.util.Map;
|
|||||||
* 试卷试题子类型
|
* 试卷试题子类型
|
||||||
*/
|
*/
|
||||||
public class PaperQType {
|
public class PaperQType {
|
||||||
|
|
||||||
|
public static void assertPaperSubTypeMatchGroupType(SubType sub,GroupType type){
|
||||||
|
boolean match = false;
|
||||||
|
switch (type){
|
||||||
|
case Training:match= sub.getValue()>=4;break;
|
||||||
|
case Common:match=sub.getValue()<=3;break;
|
||||||
|
}
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(match,"试卷试题小类型["+sub.name()+"]与大类型["+type.name()+"]不匹配");
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 试卷试题大类型:1-理论题,2-实训题
|
* 试卷试题大类型:1-理论题,2-实训题
|
||||||
*/
|
*/
|
||||||
@ -53,6 +63,7 @@ public class PaperQType {
|
|||||||
Select(1),
|
Select(1),
|
||||||
Multi(2),
|
Multi(2),
|
||||||
Judge(3),
|
Judge(3),
|
||||||
|
//////////////
|
||||||
Single(4),
|
Single(4),
|
||||||
Scene(5),
|
Scene(5),
|
||||||
;
|
;
|
||||||
|
@ -32,7 +32,11 @@ public class PaperSubmitAnswerReqVo {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private PaperQType.SubType subType;
|
private PaperQType.SubType subType;
|
||||||
/**
|
/**
|
||||||
* 答案
|
* 理论试题答案
|
||||||
*/
|
*/
|
||||||
private List<String> answer;
|
private List<String> answer;
|
||||||
|
/**
|
||||||
|
* 实训题完成结果,true-实训题成功完成,false-实训题未成功完成
|
||||||
|
*/
|
||||||
|
private Boolean trainingSuccess;
|
||||||
}
|
}
|
||||||
|
@ -246,4 +246,12 @@
|
|||||||
where id = #{id,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="countByExample" parameterType="club.joylink.rtss.entity.project.ProjectViewExample"
|
||||||
|
resultType="java.lang.Long">
|
||||||
|
select count(*) from project_view
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause"/>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user