|
@@ -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) {
|