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