考试定义调整
This commit is contained in:
parent
74193e6db7
commit
827a9b75ec
@ -54,20 +54,20 @@ public class PaperUserController {
|
|||||||
*
|
*
|
||||||
* @param puId 用户试卷id
|
* @param puId 用户试卷id
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/user/{puId}")
|
/*@DeleteMapping("/user/{puId}")
|
||||||
public void deletePaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
public void deletePaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
||||||
this.paperUserService.deletePaperUser(puId);
|
this.paperUserService.deletePaperUser(puId);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始答题
|
* 开始答题
|
||||||
*
|
*
|
||||||
* @param puId 用户试卷id
|
* @param puId 用户试卷id
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/{puId}/start")
|
/* @PostMapping("/user/{puId}/start")
|
||||||
public void paperStart(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
public void paperStart(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
||||||
this.paperUserService.paperStart(puId);
|
this.paperUserService.paperStart(puId);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户交卷
|
* 用户交卷
|
||||||
|
@ -57,27 +57,15 @@ public class PaperCompositionService {
|
|||||||
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(d.getSubTypeParam().getClient()))).findAny();
|
&& (Objects.isNull(d.getSubTypeParam()) || Objects.isNull(d.getSubTypeParam().getClient()))).findAny();
|
||||||
|
|
||||||
PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(), "试卷规则-单操缺少客户端的定义");
|
PaperExceptionAssert.PcNotHavePr.assertTrue(optionalRule.isEmpty(), "试卷规则-单操缺少客户端的定义");
|
||||||
//
|
PaperComposition newPc = PaperCompositionConvertor.convertToBean(req);
|
||||||
PaperComposition newPc = new PaperComposition();
|
|
||||||
newPc.setMapId(req.getMapId());
|
|
||||||
newPc.setName(req.getName());
|
|
||||||
newPc.setOrgId(req.getOrgId());
|
|
||||||
newPc.setProfile(req.getProfile());
|
|
||||||
newPc.setStartTime(req.getStartTime());
|
|
||||||
newPc.setEndTime(req.getEndTime());
|
|
||||||
newPc.setValidDuration(req.getValidDuration());
|
|
||||||
newPc.setPassScore(req.getPassScore());
|
|
||||||
newPc.setFullScore(req.getFullScore());
|
|
||||||
newPc.setCreateTime(LocalDateTime.now());
|
newPc.setCreateTime(LocalDateTime.now());
|
||||||
newPc.setUpdateTime(LocalDateTime.now());
|
newPc.setUpdateTime(LocalDateTime.now());
|
||||||
newPc.setCreatorId(user.getId());
|
newPc.setCreatorId(user.getId());
|
||||||
|
newPc.setUpdateId(user.getId());
|
||||||
newPc.setState(PaperCompositionState.Editing.getValue());
|
newPc.setState(PaperCompositionState.Editing.getValue());
|
||||||
compositionDAO.insertSelective(newPc);
|
compositionDAO.insertSelective(newPc);
|
||||||
// PaperExceptionAssert.PcStoreSuccess.assertTrue(newRt > 0, "存储试卷定义失败");
|
|
||||||
//
|
|
||||||
// pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
|
|
||||||
// newPc = pcList.get(0);
|
|
||||||
//
|
|
||||||
if (!CollectionUtils.isEmpty(req.getRuleList())) {
|
if (!CollectionUtils.isEmpty(req.getRuleList())) {
|
||||||
final Long pcId = newPc.getId();
|
final Long pcId = newPc.getId();
|
||||||
this.createPaperCompositionRule(pcId, req.getRuleList());
|
this.createPaperCompositionRule(pcId, req.getRuleList());
|
||||||
@ -95,31 +83,21 @@ public class PaperCompositionService {
|
|||||||
String key = String.format("%s-%s-%s",vo.getType(),vo.getSubtype(), CollectionUtils.isEmpty(vo.getTags())? "" : Joiner.on(",").join(vo.getTags()));
|
String key = String.format("%s-%s-%s",vo.getType(),vo.getSubtype(), CollectionUtils.isEmpty(vo.getTags())? "" : Joiner.on(",").join(vo.getTags()));
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 试卷蓝图添加规则
|
* 试卷蓝图添加规则
|
||||||
*/
|
*/
|
||||||
private void createPaperCompositionRule(Long pcId, List<PaperCompositionWithRuleVo.PaperRuleVo> reqList) {
|
private void createPaperCompositionRule(Long pcId, List<PaperCompositionWithRuleVo.PaperRuleVo> reqList) {
|
||||||
Map<String,List<PaperCompositionWithRuleVo.PaperRuleVo>> tmpList = reqList.stream().collect(Collectors.groupingBy(k->ruleMapKey(k)));
|
Map<String,List<PaperCompositionWithRuleVo.PaperRuleVo>> tmpList = reqList.stream().collect(Collectors.groupingBy(this::ruleMapKey));
|
||||||
|
|
||||||
for (PaperCompositionWithRuleVo.PaperRuleVo req : reqList) {
|
for (PaperCompositionWithRuleVo.PaperRuleVo req : reqList) {
|
||||||
req.setPcId(pcId);
|
req.setPcId(pcId);
|
||||||
|
|
||||||
//
|
|
||||||
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
|
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
|
||||||
String key = this.ruleMapKey(req);
|
String key = this.ruleMapKey(req);
|
||||||
List<PaperCompositionWithRuleVo.PaperRuleVo> voList = tmpList.get(key);
|
List<PaperCompositionWithRuleVo.PaperRuleVo> voList = tmpList.get(key);
|
||||||
if(!CollectionUtils.isEmpty(voList)){
|
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()));
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(voList.size() <= 1 ,String.format("试题规则类型[%s],规则类型[%s],分类%s 规则只能有一个", PaperQType.GroupType.getTypeName(req.getType()), PaperQType.SubType.getItemName(req.getSubtype()),req.getTags()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if(!CollectionUtils.isEmpty(req.getTags())){
|
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(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);
|
PaperRule rule = PaperRuleConvertor.convert(req);
|
||||||
|
|
||||||
//
|
|
||||||
ruleDAO.insertSelective(rule);
|
ruleDAO.insertSelective(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,6 +108,10 @@ public class PaperCompositionService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updatePaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) {
|
public void updatePaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) {
|
||||||
PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()), "请选择对应的线路");
|
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());
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId());
|
||||||
assertPaperCompositionCanModify(curPc);
|
assertPaperCompositionCanModify(curPc);
|
||||||
//
|
//
|
||||||
@ -138,21 +120,11 @@ public class PaperCompositionService {
|
|||||||
boolean exist = pcList.stream().anyMatch(c ->c.getId().compareTo(curPc.getId()) != 0);
|
boolean exist = pcList.stream().anyMatch(c ->c.getId().compareTo(curPc.getId()) != 0);
|
||||||
PaperExceptionAssert.PcExisted.assertNotTrue(exist, "试卷定义已经存在:orgId=" + req.getOrgId() + " name=" + req.getName());
|
PaperExceptionAssert.PcExisted.assertNotTrue(exist, "试卷定义已经存在:orgId=" + req.getOrgId() + " name=" + req.getName());
|
||||||
}
|
}
|
||||||
//
|
PaperComposition newPc = PaperCompositionConvertor.convertToBean(req);
|
||||||
curPc.setMapId(req.getMapId());
|
newPc.setId(curPc.getId());
|
||||||
curPc.setName(req.getName());
|
newPc.setUpdateTime(LocalDateTime.now());
|
||||||
curPc.setOrgId(req.getOrgId());
|
|
||||||
curPc.setProfile(req.getProfile());
|
|
||||||
curPc.setStartTime(req.getStartTime());
|
|
||||||
curPc.setEndTime(req.getEndTime());
|
|
||||||
curPc.setValidDuration(req.getValidDuration());
|
|
||||||
curPc.setPassScore(req.getPassScore());
|
|
||||||
curPc.setFullScore(req.getFullScore());
|
|
||||||
curPc.setCreateTime(LocalDateTime.now());
|
|
||||||
curPc.setUpdateTime(LocalDateTime.now());
|
|
||||||
curPc.setCreatorId(user.getId());
|
|
||||||
curPc.setUpdateId(user.getId());
|
curPc.setUpdateId(user.getId());
|
||||||
compositionDAO.updateByPrimaryKeySelective(curPc);
|
compositionDAO.updateByPrimaryKeySelective(newPc);
|
||||||
// 更新规则
|
// 更新规则
|
||||||
this.updateCompositionRule(req.getRuleList(), req.getId());
|
this.updateCompositionRule(req.getRuleList(), req.getId());
|
||||||
}
|
}
|
||||||
@ -162,39 +134,6 @@ public class PaperCompositionService {
|
|||||||
ruleExample.createCriteria().andPcIdEqualTo(pcId);
|
ruleExample.createCriteria().andPcIdEqualTo(pcId);
|
||||||
this.ruleDAO.deleteByExample(ruleExample);
|
this.ruleDAO.deleteByExample(ruleExample);
|
||||||
this.createPaperCompositionRule(pcId,updateRuleList);
|
this.createPaperCompositionRule(pcId,updateRuleList);
|
||||||
/* List<PaperRule> oldRuleList = this.findRuleByPcId(pcId);
|
|
||||||
Set<Long> oldRuleIdSet = new HashSet<>();
|
|
||||||
if (!CollectionUtils.isEmpty(oldRuleList)) {
|
|
||||||
oldRuleIdSet = oldRuleList.stream().map(PaperRule::getId).collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
//
|
|
||||||
List<PaperCompositionWithRuleVo.PaperRuleVo> needUpdate = new ArrayList<>();
|
|
||||||
List<PaperCompositionWithRuleVo.PaperRuleVo> needNew = new ArrayList<>();
|
|
||||||
for (PaperCompositionWithRuleVo.PaperRuleVo ur : updateRuleList) {
|
|
||||||
if (null == ur.getId()) {
|
|
||||||
needNew.add(ur);
|
|
||||||
} else {
|
|
||||||
PaperExceptionAssert.PdValid.assertTrue(oldRuleIdSet.contains(ur.getId()), String.format("试卷定义[id = %s]要更新的规则[id = %s]不存在", pcId, ur.getId()));
|
|
||||||
needUpdate.add(ur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
oldRuleIdSet.removeAll(needUpdate.stream().map(PaperCompositionWithRuleVo.PaperRuleVo::getId).collect(Collectors.toSet()));
|
|
||||||
Set<Long> neeDelete = oldRuleIdSet;
|
|
||||||
//
|
|
||||||
if (!CollectionUtils.isEmpty(needNew)) {
|
|
||||||
this.createPaperCompositionRule(pcId, needNew);
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(needUpdate)) {
|
|
||||||
needUpdate.forEach(nu -> {
|
|
||||||
PaperRule paperRule = PaperRuleConvertor.convert(nu);
|
|
||||||
this.ruleDAO.updateByPrimaryKeySelective(paperRule);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(neeDelete)) {
|
|
||||||
neeDelete.forEach(nd -> {
|
|
||||||
this.ruleDAO.deleteByPrimaryKey(nd);
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,13 +143,13 @@ public class PaperCompositionService {
|
|||||||
public void lockPaperComposition(Long pcId, AccountVO user) {
|
public void lockPaperComposition(Long pcId, AccountVO user) {
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非编辑中");
|
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非编辑中");
|
||||||
|
PaperExceptionAssert.PcScore.assertTrue(this.checkRulesScoreEqualFull(curPc.getId()), "规则总分值不等于试卷总分值");
|
||||||
//
|
//
|
||||||
PaperComposition nPc = new PaperComposition();
|
PaperComposition nPc = new PaperComposition();
|
||||||
nPc.setId(curPc.getId());
|
nPc.setId(curPc.getId());
|
||||||
nPc.setState(PaperCompositionState.Locked.getValue());
|
nPc.setState(PaperCompositionState.Locked.getValue());
|
||||||
compositionDAO.updateByPrimaryKeySelective(nPc);
|
compositionDAO.updateByPrimaryKeySelective(nPc);
|
||||||
// 封存试卷时校验总分值与规则总分值是否相等
|
// 封存试卷时校验总分值与规则总分值是否相等
|
||||||
PaperExceptionAssert.PcScore.assertTrue(this.checkRulesScoreEqualFull(curPc.getId()), "规则总分值不等于试卷总分值");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,6 +143,7 @@ public class PaperUserService {
|
|||||||
*
|
*
|
||||||
* @param puId 用户试卷id
|
* @param puId 用户试卷id
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void paperStart(Long puId) {
|
public void paperStart(Long puId) {
|
||||||
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
||||||
@ -153,6 +154,7 @@ public class PaperUserService {
|
|||||||
startPaper.setStartTime(LocalDateTime.now());
|
startPaper.setStartTime(LocalDateTime.now());
|
||||||
paperUserDAO.updateByPrimaryKeySelective(startPaper);
|
paperUserDAO.updateByPrimaryKeySelective(startPaper);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户交卷
|
* 用户交卷
|
||||||
|
@ -100,6 +100,10 @@ public class PaperQType {
|
|||||||
return "多选题";
|
return "多选题";
|
||||||
case Judge:
|
case Judge:
|
||||||
return "判断题";
|
return "判断题";
|
||||||
|
case Single:
|
||||||
|
return "单操实训";
|
||||||
|
case Scene:
|
||||||
|
return "场景实训";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,24 @@ import club.joylink.rtss.entity.paper.PaperComposition;
|
|||||||
import club.joylink.rtss.entity.paper.PaperRule;
|
import club.joylink.rtss.entity.paper.PaperRule;
|
||||||
import club.joylink.rtss.vo.paper.PaperCompositionState;
|
import club.joylink.rtss.vo.paper.PaperCompositionState;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PaperCompositionConvertor {
|
public class PaperCompositionConvertor {
|
||||||
|
public static PaperComposition convertToBean(PaperCompositionWithRuleVo ruleVO){
|
||||||
|
PaperComposition newPc = new PaperComposition();
|
||||||
|
newPc.setMapId(ruleVO.getMapId());
|
||||||
|
newPc.setName(ruleVO.getName());
|
||||||
|
newPc.setOrgId(ruleVO.getOrgId());
|
||||||
|
newPc.setProfile(ruleVO.getProfile());
|
||||||
|
newPc.setStartTime(ruleVO.getStartTime());
|
||||||
|
newPc.setEndTime(ruleVO.getEndTime());
|
||||||
|
newPc.setValidDuration(ruleVO.getValidDuration());
|
||||||
|
newPc.setPassScore(ruleVO.getPassScore());
|
||||||
|
newPc.setFullScore(ruleVO.getFullScore());
|
||||||
|
return newPc;
|
||||||
|
}
|
||||||
public static PaperCompositionWithRuleVo convert(PaperComposition from, List<PaperRule> ruleList){
|
public static PaperCompositionWithRuleVo convert(PaperComposition from, List<PaperRule> ruleList){
|
||||||
PaperCompositionWithRuleVo to = new PaperCompositionWithRuleVo();
|
PaperCompositionWithRuleVo to = new PaperCompositionWithRuleVo();
|
||||||
to.setMapId(from.getMapId());
|
to.setMapId(from.getMapId());
|
||||||
|
Loading…
Reference in New Issue
Block a user