Browse Source

Merge remote-tracking branch 'remotes/origin/dev_1.0.0' into release_1.0.0

xiatian 2 years ago
parent
commit
cf6a35df4e

+ 2 - 0
src/main/java/cn/com/qmth/mps/service/PaperDetailService.java

@@ -19,5 +19,7 @@ public interface PaperDetailService  extends IService<PaperDetailEntity> {
 
 	void structSubmit(StructDomain domain, User accessUser);
 
+	void structImport(StructDomain domain, User user);
+
 
 }

+ 67 - 1
src/main/java/cn/com/qmth/mps/service/impl/PaperDetailServiceImpl.java

@@ -178,7 +178,73 @@ public class PaperDetailServiceImpl extends ServiceImpl<PaperDetailDao, PaperDet
 		lw.eq(PaperDetailEntity::getPaperId, paperId);
 		this.remove(wrapper);
 	}
-
+	
+	@Override
+	public void structImport(StructDomain domain, User user) {
+		if (domain.getPaperId() == null) {
+			throw new StatusException("试卷结构ID不能为空");
+		}
+		if (domain.getTotalScore() == null) {
+			throw new StatusException("试卷满分不能为空");
+		}
+		if (domain.getTotalScore() <= 0) {
+			throw new StatusException("试卷满分必须大于0");
+		}
+		String total = domain.getTotalScore().toString();
+		if (total.indexOf(".")>=0&&total.indexOf(".") < total.length() - 2) {
+			throw new StatusException("试卷满分只能有一位小数");
+		}
+		if (CollectionUtils.isEmpty(domain.getStructInfo())) {
+			throw new StatusException("大题信息不能为空");
+		}
+		for (PaperDetail u : domain.getStructInfo()) {
+			if (u.getNumber() == null || StringUtils.isBlank(u.getName())) {
+				throw new StatusException("大题号、大题名称不能为空");
+			}
+			if (CollectionUtils.isEmpty(u.getUnits())) {
+				throw new StatusException("小题信息不能为空");
+			}
+			for (PaperDetailUnit unit : u.getUnits()) {
+				if (unit.getNumber() == null || unit.getScore() == null || unit.getScoreStep() == null) {
+					throw new StatusException("小题号、小题满分、给分间隔不能为空");
+				}
+				if (unit.getNumber() <= 0) {
+					throw new StatusException("小题号必须大于0");
+				}
+				String score = unit.getScore().toString();
+				if (score.indexOf(".")>=0&&score.indexOf(".") < score.length() - 2) {
+					throw new StatusException("小题满分只能有一位小数");
+				}
+				String scoreStep = unit.getScoreStep().toString();
+				if (scoreStep.indexOf(".")>=0&&scoreStep.indexOf(".") < scoreStep.length() - 2) {
+					throw new StatusException("给分间隔只能有一位小数");
+				}
+			}
+		}
+		checkTotalScore(domain);
+		PaperEntity paper = paperService.getById(domain.getPaperId());
+		if (paper == null) {
+			throw new StatusException("未找到试卷结构");
+		}
+		examService.checkExamStatus(paper.getExamId());
+		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(paper.getSchoolId())) {
+			throw new StatusException("没有权限");
+		}
+		paperGroupService.groupClear(domain.getPaperId(),user);
+		clearPaperSruct(domain.getPaperId());
+		paper.setTotalScore(domain.getTotalScore());
+		paper.setSubjectiveScore(domain.getTotalScore());
+		paper.setStructFinish(true);
+		paperService.updateById(paper);
+		for (PaperDetail pd : domain.getStructInfo()) {
+			PaperDetailEntity e = new PaperDetailEntity();
+			e.setName(pd.getName());
+			e.setNumber(pd.getNumber());
+			e.setPaperId(domain.getPaperId());
+			this.save(e);
+			paperDetailUnitService.saveUnit(e, pd.getUnits());
+		}
+	}
 	@Transactional
 	@Override
 	public void structSubmit(StructDomain domain, User user) {

+ 0 - 1
src/main/java/cn/com/qmth/mps/service/impl/PaperGroupServiceImpl.java

@@ -308,7 +308,6 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
 			throw new StatusException("没有权限");
 		}
 		clearByPaperId(paperId);
-		paperGroupUnitService.clearByPaperId(paperId);
 		paper.setGroupFinish(false);
 		paperService.updateById(paper);
 	}

+ 4 - 4
src/main/java/cn/com/qmth/mps/service/impl/PaperServiceImpl.java

@@ -60,7 +60,7 @@ import cn.com.qmth.mps.vo.paper.StructDomain;
 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[] {"科目代码", "科目名称", "大题名称", "大题号", "小题号", "小题满分","间隔分"};
+	private static final String[] SUBJECT_STRUCT_EXCEL_HEADER = new String[] {"科目代码*","科目名称","大题名称*","大题号(只能用小写数字)*","小题号(只能用小写数字)*","小题满分*","间隔分*","评卷分组(只能用小写数字)*","图片序号(用英文逗号分割)","双评比例(0~1)","仲裁阀值","合分策略(1-平均,2-最高,3-最低)","评卷模式(common-普通,track-轨迹)","试评数量(0-跳过试评)","选做题数量"};
 
 	@Autowired
 	private ExamService examService;
@@ -328,7 +328,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		InputStream inputStream = null;
 		try {
 			inputStream = file.getInputStream();
-			ExcelReader reader=ExcelReader.create(ExcelType.XLSX, inputStream, 0);
+			ExcelReader reader=ExcelReader.create(ExcelType.XLSX, inputStream, 1);
 			List<DataMap> lineList = reader.getDataMapList();
 			if(!Arrays.equals(SUBJECT_STRUCT_EXCEL_HEADER,reader.getColumnNames())) {
 				throw new StatusException("Excel表头错误");
@@ -452,7 +452,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 				}
 
 				if (msg.length() > 0) {
-					failRecords.add(newError(i + 1, msg.toString()));
+					failRecords.add(newError(i + 3, msg.toString()));
 				} else {
 					ret.add(imp);
 				}
@@ -492,7 +492,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		}
 		for (StructDomain domain : ces) {
 			try {
-				paperDetailService.structSubmit(domain, user);
+				paperDetailService.structImport(domain, user);
 			} catch (StatusException e) {
 				failRecords.add("科目:"+map.get(domain.getPaperId())+" "+e.getMessage());
 			} catch (Exception e) {

BIN
src/main/resources/importtemplates/structImport.xlsx