|
@@ -1,13 +1,9 @@
|
|
package cn.com.qmth.mps.service.impl;
|
|
package cn.com.qmth.mps.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
+import cn.com.qmth.mps.enums.ArbitrateMethod;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -72,6 +68,10 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
|
|
for (PaperGroupEntity e : es) {
|
|
for (PaperGroupEntity e : es) {
|
|
PaperGroup vo = new PaperGroup();
|
|
PaperGroup vo = new PaperGroup();
|
|
vo.setNumber(e.getNumber());
|
|
vo.setNumber(e.getNumber());
|
|
|
|
+ vo.setDoubleEnable(e.getDoubleEnable());
|
|
|
|
+ vo.setDoubleRate(e.getDoubleRate());
|
|
|
|
+ vo.setArbitrateThreshold(e.getArbitrateThreshold());
|
|
|
|
+ vo.setArbitrateMethod(e.getArbitrateMethod());
|
|
map.put(e.getId(), vo);
|
|
map.put(e.getId(), vo);
|
|
ret.add(vo);
|
|
ret.add(vo);
|
|
}
|
|
}
|
|
@@ -197,21 +197,54 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
|
|
@Override
|
|
@Override
|
|
public void groupSave(PaperGroupDomain domain, User user) {
|
|
public void groupSave(PaperGroupDomain domain, User user) {
|
|
|
|
|
|
- if (domain.getPaperId() == null) {
|
|
|
|
|
|
+ Long paperId = domain.getPaperId();
|
|
|
|
+ if (Objects.isNull(paperId)) {
|
|
throw new StatusException("试卷结构ID不能为空");
|
|
throw new StatusException("试卷结构ID不能为空");
|
|
}
|
|
}
|
|
- if (domain.getNumber() == null) {
|
|
|
|
|
|
+ Integer groupNumber = domain.getNumber();
|
|
|
|
+ if (Objects.isNull(groupNumber)) {
|
|
throw new StatusException("分组号不能为空");
|
|
throw new StatusException("分组号不能为空");
|
|
}
|
|
}
|
|
if (CollectionUtils.isEmpty(domain.getGroupUnits())) {
|
|
if (CollectionUtils.isEmpty(domain.getGroupUnits())) {
|
|
throw new StatusException("分组信息不能为空");
|
|
throw new StatusException("分组信息不能为空");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Boolean doubleEnable = domain.getDoubleEnable();
|
|
|
|
+ if (Objects.isNull(doubleEnable)) {
|
|
|
|
+ throw new StatusException("是否开启双评未设置");
|
|
|
|
+ }
|
|
|
|
+ Double doubleRate = domain.getDoubleRate();
|
|
|
|
+ ArbitrateMethod arbitrateMethod = domain.getArbitrateMethod();
|
|
|
|
+ Double arbitrateThreshold = domain.getArbitrateThreshold();
|
|
|
|
+ if (doubleEnable) {
|
|
|
|
+ // 如果开启双评
|
|
|
|
+ if (Objects.isNull(doubleRate) || doubleRate < 0 || doubleRate > 1) {
|
|
|
|
+ throw new StatusException("双评比例未正确设置");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(arbitrateMethod)) {
|
|
|
|
+ throw new StatusException("仲裁方式未设置");
|
|
|
|
+ }
|
|
|
|
+ if (ArbitrateMethod.GROUP_ARBITRATE.equals(arbitrateMethod) || 0 < arbitrateThreshold) {
|
|
|
|
+ throw new StatusException("仲裁阈值未正确设置");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
for (PaperGroupUnit u : domain.getGroupUnits()) {
|
|
for (PaperGroupUnit u : domain.getGroupUnits()) {
|
|
|
|
+ // 小题仲裁阈值
|
|
|
|
+ Double questionArbitrateThreshold = u.getArbitrateThreshold();
|
|
if (u.getDetailNumber() == null || u.getDetailUnitNumber() == null) {
|
|
if (u.getDetailNumber() == null || u.getDetailUnitNumber() == null) {
|
|
throw new StatusException("大题号、小题号不能为空");
|
|
throw new StatusException("大题号、小题号不能为空");
|
|
}
|
|
}
|
|
|
|
+ if (ArbitrateMethod.QUESTION_ARBITRATE.equals(arbitrateMethod)) {
|
|
|
|
+ if (Objects.isNull(questionArbitrateThreshold) || 0 < questionArbitrateThreshold) {
|
|
|
|
+ throw new StatusException("仲裁阈值未正确设置");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (ArbitrateMethod.GROUP_ARBITRATE.equals(arbitrateMethod)){
|
|
|
|
+ u.setArbitrateThreshold(null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- PaperEntity paper = paperService.getById(domain.getPaperId());
|
|
|
|
|
|
+ PaperEntity paper = paperService.getById(paperId);
|
|
if (paper == null) {
|
|
if (paper == null) {
|
|
throw new StatusException("未找到试卷结构");
|
|
throw new StatusException("未找到试卷结构");
|
|
}
|
|
}
|
|
@@ -222,28 +255,49 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
|
|
if (!paper.getStructFinish()) {
|
|
if (!paper.getStructFinish()) {
|
|
throw new StatusException("试卷结构未提交,不能设置分组");
|
|
throw new StatusException("试卷结构未提交,不能设置分组");
|
|
}
|
|
}
|
|
- PaperGroupEntity g;
|
|
|
|
- if(domain.getGroupId()!=null) {
|
|
|
|
- g=this.getById(domain.getGroupId());
|
|
|
|
- paperGroupUnitService.removeByGroupId(domain.getGroupId());
|
|
|
|
- }else {
|
|
|
|
- g = new PaperGroupEntity();
|
|
|
|
- g.setPaperId(domain.getPaperId());
|
|
|
|
- }
|
|
|
|
- g.setNumber(domain.getNumber());
|
|
|
|
- this.saveOrUpdate(g);
|
|
|
|
- List<PaperDetail> pds = paperDetailService.getStructInfo(domain.getPaperId());
|
|
|
|
|
|
+ Long groupId = domain.getGroupId();
|
|
|
|
+ // 参数处理
|
|
|
|
+ if (!doubleEnable) {
|
|
|
|
+ // 未开启双评
|
|
|
|
+ doubleRate = null;
|
|
|
|
+ arbitrateThreshold = null;
|
|
|
|
+ arbitrateMethod = null;
|
|
|
|
+ } else {
|
|
|
|
+ if (ArbitrateMethod.QUESTION_ARBITRATE.equals(arbitrateMethod)) {
|
|
|
|
+ arbitrateThreshold = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(groupId)) {
|
|
|
|
+ // 编辑
|
|
|
|
+ paperGroupUnitService.removeByGroupId(groupId);
|
|
|
|
+ UpdateWrapper<PaperGroupEntity> paperGroupEntityUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ paperGroupEntityUpdateWrapper.lambda().eq(PaperGroupEntity::getId, groupId)
|
|
|
|
+ .set(PaperGroupEntity::getNumber, groupNumber).set(PaperGroupEntity::getDoubleEnable, doubleEnable)
|
|
|
|
+ .set(PaperGroupEntity::getDoubleRate, doubleRate)
|
|
|
|
+ .set(PaperGroupEntity::getArbitrateThreshold, arbitrateThreshold)
|
|
|
|
+ .set(PaperGroupEntity::getArbitrateMethod, arbitrateMethod);
|
|
|
|
+ this.update(paperGroupEntityUpdateWrapper);
|
|
|
|
+ } else {
|
|
|
|
+ // 新增
|
|
|
|
+ PaperGroupEntity paperGroupEntity = new PaperGroupEntity();
|
|
|
|
+ paperGroupEntity.setPaperId(paperId);
|
|
|
|
+ paperGroupEntity.setNumber(groupNumber);
|
|
|
|
+ paperGroupEntity.setDoubleEnable(doubleEnable);
|
|
|
|
+ paperGroupEntity.setDoubleRate(doubleRate);
|
|
|
|
+ paperGroupEntity.setArbitrateMethod(arbitrateMethod);
|
|
|
|
+ paperGroupEntity.setArbitrateThreshold(arbitrateThreshold);
|
|
|
|
+ this.save(paperGroupEntity);
|
|
|
|
+ groupId = paperGroupEntity.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<PaperDetail> pds = paperDetailService.getStructInfo(paperId);
|
|
if (CollectionUtils.isEmpty(pds)) {
|
|
if (CollectionUtils.isEmpty(pds)) {
|
|
throw new StatusException("试卷结构小题信息为空");
|
|
throw new StatusException("试卷结构小题信息为空");
|
|
}
|
|
}
|
|
checkStruct(pds, domain.getGroupUnits());
|
|
checkStruct(pds, domain.getGroupUnits());
|
|
- paperGroupUnitService.saveUnit(g, domain.getGroupUnits());
|
|
|
|
- if (paperGroupUnitService.countByPaperId(domain.getPaperId())
|
|
|
|
- .equals(paperDetailUnitService.countByPaperId(domain.getPaperId()))) {
|
|
|
|
- paper.setGroupFinish(true);
|
|
|
|
- }else {
|
|
|
|
- paper.setGroupFinish(false);
|
|
|
|
- }
|
|
|
|
|
|
+ paperGroupUnitService.saveUnit(groupId, paperId, domain.getGroupUnits());
|
|
|
|
+ paper.setGroupFinish(
|
|
|
|
+ paperGroupUnitService.countByPaperId(paperId).equals(paperDetailUnitService.countByPaperId(paperId)));
|
|
paperService.updateById(paper);
|
|
paperService.updateById(paper);
|
|
}
|
|
}
|
|
|
|
|