|
@@ -5,6 +5,8 @@ import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.com.qmth.mps.bean.*;
|
|
|
+import cn.com.qmth.mps.enums.ArbitrateMethod;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -26,10 +28,6 @@ import com.qmth.boot.tools.excel.ExcelReader;
|
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
import com.qmth.boot.tools.excel.model.DataMap;
|
|
|
|
|
|
-import cn.com.qmth.mps.bean.PaperDetail;
|
|
|
-import cn.com.qmth.mps.bean.PaperDetailUnit;
|
|
|
-import cn.com.qmth.mps.bean.PaperGroupUnit;
|
|
|
-import cn.com.qmth.mps.bean.User;
|
|
|
import cn.com.qmth.mps.dao.PaperDao;
|
|
|
import cn.com.qmth.mps.entity.CourseEntity;
|
|
|
import cn.com.qmth.mps.entity.ExamEntity;
|
|
@@ -47,7 +45,7 @@ import cn.com.qmth.mps.vo.paper.*;
|
|
|
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
|
|
|
private static final String[] SUBJECT_EXCEL_HEADER = new String[] {"科目代码", "科目名称"};
|
|
|
|
|
|
- private static final String[] SUBJECT_STRUCT_EXCEL_HEADER = new String[] {"科目代码*","科目名称","大题名称*","题目昵称","大题号(只能用小写数字)*","小题号(只能用小写数字)*","小题满分*","间隔分*","评卷分组(只能用小写数字)*","图片序号(用英文逗号分割)","双评比例(0~1)","仲裁阀值","合分策略(1-平均,2-最高,3-最低)","评卷模式(common-普通,track-轨迹)","试评数量(0-跳过试评)","选做题数量"};
|
|
|
+ private static final String[] SUBJECT_STRUCT_EXCEL_HEADER = new String[] {"科目代码*","科目名称","大题名称*","题目昵称","大题号(只能用小写数字)*","小题号(只能用小写数字)*","小题满分*","间隔分*","评卷分组(只能用小写数字)*","图片序号(用英文逗号分割)","仲裁方式(0-分组,1-小题)","双评比例(0~1)","仲裁阀值","合分策略(1-平均,2-最高,3-最低)","评卷模式(common-普通,track-轨迹)","试评数量(0-跳过试评)","选做题数量"};
|
|
|
|
|
|
@Autowired
|
|
|
private ExamService examService;
|
|
@@ -218,29 +216,32 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(query.getSchoolId())) {
|
|
|
throw new StatusException("没有权限");
|
|
|
}
|
|
|
- IPage<PaperVo> iPage = this.baseMapper.page(new Page<PaperVo>(query.getPageNumber(), query.getPageSize()),
|
|
|
+ IPage<PaperVo> iPage = this.baseMapper.page(new Page<>(query.getPageNumber(), query.getPageSize()),
|
|
|
query);
|
|
|
if (CollectionUtils.isNotEmpty(iPage.getRecords())) {
|
|
|
new BatchSetDataUtil<PaperVo>() {
|
|
|
|
|
|
@Override
|
|
|
protected void setData(List<PaperVo> dataList) {
|
|
|
- List<Long> paperIds = dataList.stream().map(dto -> dto.getId()).distinct()
|
|
|
+ List<Long> paperIds = dataList.stream().map(PaperVo::getId).distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
List<GroupCountVo> ret = paperGroupService.findGroupCount(paperIds);
|
|
|
if (ret != null && ret.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
+ Map<Long, Boolean> doubleEnableMap = new HashMap<>();
|
|
|
for (GroupCountVo item : ret) {
|
|
|
countMap.put(item.getPaperId(), item.getGroupCount());
|
|
|
+ doubleEnableMap.put(item.getPaperId(), item.getDoubleEnable());
|
|
|
}
|
|
|
for (PaperVo vo : dataList) {
|
|
|
vo.setGroupCount(countMap.get(vo.getId()));
|
|
|
+ vo.setDoubleEnable(doubleEnableMap.get(vo.getId()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}.setDataForBatch(iPage.getRecords(), 20);
|
|
|
for (PaperVo vo : iPage.getRecords()) {
|
|
|
- if(vo.getGroupCount()==null) {
|
|
|
+ if (vo.getGroupCount() == null) {
|
|
|
vo.setGroupCount(0);
|
|
|
}
|
|
|
}
|
|
@@ -329,6 +330,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
}
|
|
|
List<String> failRecords = new ArrayList<>();
|
|
|
List<PaperStructInfoVo> ret = new ArrayList<>();
|
|
|
+ // 双评设置
|
|
|
+ Map<String, DoubleMarkImportParam> doubleMarkSettingMap = new HashMap<>();
|
|
|
for (int i = 0; i < lineList.size(); i++) {
|
|
|
DataMap line = lineList.get(i);
|
|
|
|
|
@@ -439,10 +442,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
|
|
|
}
|
|
|
|
|
|
- String groupNumber = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[8]));
|
|
|
- if (StringUtils.isNotBlank(groupNumber)) {
|
|
|
+ String groupNumberStr = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[8]));
|
|
|
+ if (StringUtils.isNotBlank(groupNumberStr)) {
|
|
|
try {
|
|
|
- Integer n = Integer.valueOf(groupNumber);
|
|
|
+ Integer n = Integer.valueOf(groupNumberStr);
|
|
|
if (n <= 0) {
|
|
|
msg.append(" 评卷分组不能小于0");
|
|
|
} else {
|
|
@@ -453,12 +456,109 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Long paperId = imp.getPaperId();
|
|
|
+ Integer groupNumber = imp.getGroupNumber();
|
|
|
+ if (Objects.nonNull(paperId) && Objects.nonNull(groupNumber)){
|
|
|
+ // 有分组信息才解析双评信息
|
|
|
+ String groupKey = paperId + "-" + groupNumber;
|
|
|
+ ArbitrateMethod arbitrateMethod = null;
|
|
|
+ Double doubleRate = null;
|
|
|
+ Double arbitrateThreshold = null;
|
|
|
+
|
|
|
+ if (doubleMarkSettingMap.containsKey(groupKey)){
|
|
|
+ DoubleMarkImportParam doubleMarkImportParam = doubleMarkSettingMap.get(groupKey);
|
|
|
+ arbitrateMethod = doubleMarkImportParam.getArbitrateMethod();
|
|
|
+ doubleRate = doubleMarkImportParam.getDoubleRate();
|
|
|
+ arbitrateThreshold = doubleMarkImportParam.getArbitrateThreshold();
|
|
|
+ }
|
|
|
+
|
|
|
+ String arbitrateMethodStr = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[10]));
|
|
|
+ String doubleRateStr = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[11]));
|
|
|
+ String arbitrateThresholdStr = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[12]));
|
|
|
+
|
|
|
+ // 双评比例
|
|
|
+ if (StringUtils.isNotBlank(doubleRateStr)) {
|
|
|
+ try {
|
|
|
+ double n = Double.parseDouble(doubleRateStr);
|
|
|
+
|
|
|
+ if (n < 0 || n > 1){
|
|
|
+ msg.append(" 双评比例只能在(0~1)");
|
|
|
+ } else {
|
|
|
+ if (Objects.nonNull(doubleRate) && !doubleRate.equals(n)){
|
|
|
+ msg.append(" 同分组的双评比例必须相同");
|
|
|
+ } else {
|
|
|
+ doubleRate = n;
|
|
|
+ imp.setDoubleRate(doubleRate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ msg.append(" 双评比例格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(doubleRate) && doubleRate > 0){
|
|
|
+ // 开启双评才继续解析 仲裁方式和仲裁值
|
|
|
+ // 仲裁方式(0-分组,1-小题)
|
|
|
+ if (StringUtils.isNotBlank(arbitrateMethodStr)) {
|
|
|
+ try {
|
|
|
+ int n = Integer.parseInt(arbitrateMethodStr);
|
|
|
+ List<ArbitrateMethod> arbitrateMethodList = Arrays.stream(ArbitrateMethod.values()).filter(e -> e.getValue().equals(n)).collect(
|
|
|
+ Collectors.toList());
|
|
|
+ if (arbitrateMethodList.size() != 1){
|
|
|
+ msg.append(" 仲裁方式只能选择0或1");
|
|
|
+ } else {
|
|
|
+ if (Objects.nonNull(arbitrateMethod) && !arbitrateMethod.equals(arbitrateMethodList.get(0))){
|
|
|
+ msg.append(" 同分组的仲裁方式必须相同");
|
|
|
+ } else {
|
|
|
+ arbitrateMethod = arbitrateMethodList.get(0);
|
|
|
+ imp.setArbitrateMethod(arbitrateMethod);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ msg.append(" 仲裁方式格式错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ msg.append(" 仲裁方式不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(arbitrateMethod)){
|
|
|
+ // 仲裁方式不为空才解析
|
|
|
+ // 仲裁阀值
|
|
|
+ if (StringUtils.isNotBlank(arbitrateThresholdStr)) {
|
|
|
+ try {
|
|
|
+ double n = Double.parseDouble(arbitrateThresholdStr);
|
|
|
+ if (n < 0){
|
|
|
+ msg.append(" 仲裁阀值不能小于0");
|
|
|
+ }
|
|
|
+ if (ArbitrateMethod.QUESTION_ARBITRATE.equals(arbitrateMethod)){
|
|
|
+ Double questionScore = imp.getScore();
|
|
|
+ if (Objects.nonNull(questionScore) && n > questionScore){
|
|
|
+ msg.append(" 仲裁阀值不能超过小题满分");
|
|
|
+ }
|
|
|
+ } else if (ArbitrateMethod.GROUP_ARBITRATE.equals(arbitrateMethod)) {
|
|
|
+ if (Objects.nonNull(arbitrateThreshold) && !arbitrateThreshold.equals(n)) {
|
|
|
+ msg.append(" 同分组的仲裁阀值必须相同");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ arbitrateThreshold = n;
|
|
|
+ imp.setArbitrateThreshold(n);
|
|
|
+ } catch (Exception e) {
|
|
|
+ msg.append(" 仲裁阀值格式错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ msg.append(" 仲裁阀值不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!doubleMarkSettingMap.containsKey(groupKey)){
|
|
|
+ doubleMarkSettingMap.put(groupKey, new DoubleMarkImportParam(arbitrateMethod, doubleRate, arbitrateThreshold));
|
|
|
+ }
|
|
|
+ }
|
|
|
if (msg.length() > 0) {
|
|
|
failRecords.add(newError(i + 3, msg.toString()));
|
|
|
} else {
|
|
|
ret.add(imp);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
@@ -524,11 +624,26 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
curGroup = new PaperGroupDomain();
|
|
|
curGroup.setPaperId(info.getPaperId());
|
|
|
curGroup.setNumber(info.getGroupNumber());
|
|
|
+ if (Objects.nonNull(info.getDoubleRate()) && info.getDoubleRate()>0){
|
|
|
+ curGroup.setDoubleEnable(true);
|
|
|
+ curGroup.setDoubleRate(info.getDoubleRate());
|
|
|
+ if (Objects.nonNull(info.getArbitrateMethod())){
|
|
|
+ curGroup.setArbitrateMethod(info.getArbitrateMethod());
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(info.getArbitrateThreshold())){
|
|
|
+ curGroup.setArbitrateThreshold(info.getArbitrateThreshold());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ curGroup.setDoubleEnable(false);
|
|
|
+ }
|
|
|
curGroup.setGroupUnits(new ArrayList<>());
|
|
|
}
|
|
|
PaperGroupUnit unit = new PaperGroupUnit();
|
|
|
unit.setDetailNumber(info.getDetailNumber());
|
|
|
unit.setDetailUnitNumber(info.getUnitNumber());
|
|
|
+ if (Objects.equals(ArbitrateMethod.QUESTION_ARBITRATE, info.getArbitrateMethod()) && Objects.nonNull(info.getArbitrateThreshold())){
|
|
|
+ unit.setArbitrateThreshold(info.getArbitrateThreshold());
|
|
|
+ }
|
|
|
curGroup.getGroupUnits().add(unit);
|
|
|
map.put(getKey(info),curGroup);
|
|
|
}
|