|
@@ -2,12 +2,7 @@ package cn.com.qmth.mps.service.impl;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -33,6 +28,7 @@ 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;
|
|
@@ -40,21 +36,12 @@ import cn.com.qmth.mps.entity.ExamEntity;
|
|
|
import cn.com.qmth.mps.entity.PaperEntity;
|
|
|
import cn.com.qmth.mps.enums.ExamStatus;
|
|
|
import cn.com.qmth.mps.enums.Role;
|
|
|
-import cn.com.qmth.mps.service.CourseService;
|
|
|
-import cn.com.qmth.mps.service.ExamService;
|
|
|
-import cn.com.qmth.mps.service.PaperDetailService;
|
|
|
-import cn.com.qmth.mps.service.PaperGroupService;
|
|
|
-import cn.com.qmth.mps.service.PaperService;
|
|
|
+import cn.com.qmth.mps.service.*;
|
|
|
import cn.com.qmth.mps.util.BatchSetDataUtil;
|
|
|
import cn.com.qmth.mps.util.Calculator;
|
|
|
import cn.com.qmth.mps.util.PageUtil;
|
|
|
import cn.com.qmth.mps.vo.exam.ExamPaperCountVo;
|
|
|
-import cn.com.qmth.mps.vo.paper.GroupCountVo;
|
|
|
-import cn.com.qmth.mps.vo.paper.PaperInfoVo;
|
|
|
-import cn.com.qmth.mps.vo.paper.PaperQuery;
|
|
|
-import cn.com.qmth.mps.vo.paper.PaperStructInfoVo;
|
|
|
-import cn.com.qmth.mps.vo.paper.PaperVo;
|
|
|
-import cn.com.qmth.mps.vo.paper.StructDomain;
|
|
|
+import cn.com.qmth.mps.vo.paper.*;
|
|
|
|
|
|
@Service
|
|
|
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
|
|
@@ -452,6 +439,20 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
|
|
|
}
|
|
|
|
|
|
+ String groupNumber = trimAndNullIfBlank(line.get(SUBJECT_STRUCT_EXCEL_HEADER[8]));
|
|
|
+ if (StringUtils.isNotBlank(groupNumber)) {
|
|
|
+ try {
|
|
|
+ Integer n = Integer.valueOf(groupNumber);
|
|
|
+ if (n <= 0) {
|
|
|
+ msg.append(" 评卷分组不能小于0");
|
|
|
+ } else {
|
|
|
+ imp.setGroupNumber(n);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ msg.append(" 评卷分组格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (msg.length() > 0) {
|
|
|
failRecords.add(newError(i + 3, msg.toString()));
|
|
|
} else {
|
|
@@ -501,8 +502,43 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
throw new RuntimeException("系统错误", e);
|
|
|
}
|
|
|
}
|
|
|
+ List<PaperGroupDomain> list = getPaperGroups(cards);
|
|
|
+ for (PaperGroupDomain domain : list) {
|
|
|
+ try {
|
|
|
+ paperGroupService.groupSave(domain, user);
|
|
|
+ } catch (StatusException e) {
|
|
|
+ failRecords.add("科目:"+map.get(domain.getPaperId())+" "+e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("系统错误", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ private List<PaperGroupDomain> getPaperGroups(List<PaperStructInfoVo> cards) {
|
|
|
+ Map<String,PaperGroupDomain> map = new HashMap<>();
|
|
|
+ for (PaperStructInfoVo info : cards) {
|
|
|
+ if(info.getGroupNumber()!=null){
|
|
|
+ PaperGroupDomain curGroup =map.get(getKey(info));
|
|
|
+ if(curGroup==null){
|
|
|
+ curGroup = new PaperGroupDomain();
|
|
|
+ curGroup.setPaperId(info.getPaperId());
|
|
|
+ curGroup.setNumber(info.getGroupNumber());
|
|
|
+ curGroup.setGroupUnits(new ArrayList<>());
|
|
|
+ }
|
|
|
+ PaperGroupUnit unit = new PaperGroupUnit();
|
|
|
+ unit.setDetailNumber(info.getDetailNumber());
|
|
|
+ unit.setDetailUnitNumber(info.getUnitNumber());
|
|
|
+ curGroup.getGroupUnits().add(unit);
|
|
|
+ map.put(getKey(info),curGroup);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PaperGroupDomain> list = map.values().stream().collect(Collectors.toList());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ private String getKey(PaperStructInfoVo p) {
|
|
|
+ return p.getPaperId()+"-"+p.getCourseCode()+"-"+p.getGroupNumber();
|
|
|
+ }
|
|
|
// private void checkStruct(List<StructDomain> ces, List<String> failRecords,Map<Long,String> courseMap) {
|
|
|
// for (StructDomain card : ces) {
|
|
|
// int lastDetailNum = 0;
|