|
@@ -21,6 +21,7 @@ import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
import com.qmth.teachcloud.common.util.Result;
|
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.CombineDto;
|
|
|
import com.qmth.teachcloud.report.business.bean.dto.excel.*;
|
|
|
import com.qmth.teachcloud.report.business.bean.dto.query.*;
|
|
|
import com.qmth.teachcloud.report.business.entity.*;
|
|
@@ -31,10 +32,7 @@ import com.qmth.teachcloud.report.business.service.*;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -1022,6 +1020,72 @@ public class BasicDatasourceController {
|
|
|
return ResultUtil.ok("有【" + count + "】条缺考学生数据被更新");
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "特殊科目合并题目处理")
|
|
|
+ @RequestMapping(value = "/special/combine", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result specialCombine(@RequestBody CombineDto combineDto) {
|
|
|
+
|
|
|
+ Long examId = combineDto.getExamId();
|
|
|
+ String courseCode = combineDto.getCourseCode();
|
|
|
+ String orgMain1 = combineDto.getOrgMain1();
|
|
|
+ String orgSub1 = combineDto.getOrgSub1();
|
|
|
+ String orgMain2 = combineDto.getOrgMain2();
|
|
|
+ String orgSub2 = combineDto.getOrgSub2();
|
|
|
+ String comMain = combineDto.getComMain();
|
|
|
+ String comSub = combineDto.getComSub();
|
|
|
+ // TODO: 2021/6/25 合题的检验
|
|
|
+ TBPaper tbPaper = tbPaperService.getOne(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
|
|
|
+ Long paperId = tbPaper.getId();
|
|
|
+ List<TBExamRecord> tbExamRecordList = tbExamRecordService.list(new QueryWrapper<TBExamRecord>().lambda().eq(TBExamRecord::getExamId,examId).eq(TBExamRecord::getPaperId,paperId));
|
|
|
+ List<Long> examRecordIdList = tbExamRecordList.stream().map(TBExamRecord::getId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<TBAnswer> tbAnswerList = tbAnswerService.list(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId,examRecordIdList));
|
|
|
+
|
|
|
+ List<Long> willDeleteList = new ArrayList<>();
|
|
|
+ List<TBAnswer> willInsertList = new ArrayList<>();
|
|
|
+ for (Long examRecordId : examRecordIdList) {
|
|
|
+ List<TBAnswer> oneStudentAnswerList = tbAnswerList.stream().filter(e -> e.getExamRecordId().equals(examRecordId)).collect(Collectors.toList());
|
|
|
+ if (oneStudentAnswerList.size() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 原始1题
|
|
|
+ TBAnswer org1 = oneStudentAnswerList.stream()
|
|
|
+ .filter(e -> e.getMainNumber().equals(orgMain1) && e.getSubNumber().equals(orgSub1))
|
|
|
+ .collect(Collectors.toList()).get(0);
|
|
|
+ Long org1Id = org1.getId();
|
|
|
+ BigDecimal org1Score = org1.getScore();
|
|
|
+
|
|
|
+ // 原始2题
|
|
|
+ TBAnswer org2 = oneStudentAnswerList.stream()
|
|
|
+ .filter(e -> e.getMainNumber().equals(orgMain2) && e.getSubNumber().equals(orgSub2))
|
|
|
+ .collect(Collectors.toList()).get(0);
|
|
|
+
|
|
|
+ Long org2Id = org2.getId();
|
|
|
+ BigDecimal org2Score = org2.getScore();
|
|
|
+ if (!org1.getNumberType().equals(org2.getNumberType())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题目类型不一致 合题失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal comboScore = org1Score.add(org2Score);
|
|
|
+ TBAnswer combo = new TBAnswer();
|
|
|
+ combo.setId(SystemConstant.getDbUuid());
|
|
|
+ combo.setExamRecordId(examRecordId);
|
|
|
+ combo.setNumberType(org1.getNumberType());
|
|
|
+ combo.setMainNumber(comMain);
|
|
|
+ combo.setSubNumber(comSub);
|
|
|
+ combo.setScore(comboScore);
|
|
|
+
|
|
|
+ willInsertList.add(combo);
|
|
|
+
|
|
|
+ willDeleteList.add(org1Id);
|
|
|
+ willDeleteList.add(org2Id);
|
|
|
+ }
|
|
|
+ tbAnswerService.removeByIds(willDeleteList);
|
|
|
+ tbAnswerService.saveBatch(willInsertList);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|