|
@@ -27,7 +27,9 @@ import com.qmth.teachcloud.report.business.enums.ExamCloudDataEnum;
|
|
|
import com.qmth.teachcloud.report.business.enums.NumberTypeEnum;
|
|
|
import com.qmth.teachcloud.report.business.service.*;
|
|
|
import com.qmth.teachcloud.common.util.Result;
|
|
|
+import io.netty.handler.codec.http.HttpRequest;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -35,8 +37,11 @@ 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.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.util.WebUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -132,8 +137,8 @@ public class BasicDatasourceController {
|
|
|
continue;
|
|
|
}
|
|
|
BigDecimal coefficient = BigDecimal.ZERO;
|
|
|
- if (Objects.nonNull(paperConfigDto.getCoefficient()) && paperConfigDto.getCoefficient() instanceof Double) {
|
|
|
- coefficient = BigDecimal.valueOf((Double) paperConfigDto.getCoefficient());
|
|
|
+ if (Objects.nonNull(paperConfigDto.getCoefficient())) {
|
|
|
+ coefficient = BigDecimal.valueOf(Long.parseLong(String.valueOf(paperConfigDto.getCoefficient())));
|
|
|
}
|
|
|
String paperType = paperConfigDto.getPaperType();
|
|
|
List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
|
|
@@ -344,12 +349,10 @@ public class BasicDatasourceController {
|
|
|
}
|
|
|
Set<String> moduleProficiencyRemove = tbModuleProficiencyList.stream().map(e -> e.getExamId() + SystemConstant.HYPHEN
|
|
|
+ e.getCourseCode() + SystemConstant.HYPHEN
|
|
|
- + e.getCourseName() + SystemConstant.HYPHEN
|
|
|
+ e.getModuleType()).collect(Collectors.toSet());
|
|
|
|
|
|
Set<String> moduleConfigRemove = tbModuleConfigList.stream().map(e -> e.getExamId() + SystemConstant.HYPHEN
|
|
|
+ e.getCourseCode() + SystemConstant.HYPHEN
|
|
|
- + e.getCourseName() + SystemConstant.HYPHEN
|
|
|
+ e.getModuleType()).collect(Collectors.toSet());
|
|
|
|
|
|
for (String s : moduleProficiencyRemove) {
|
|
@@ -357,16 +360,14 @@ public class BasicDatasourceController {
|
|
|
tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
|
|
|
.eq(TBModuleProficiency::getExamId, arr[0])
|
|
|
.eq(TBModuleProficiency::getCourseCode, arr[1])
|
|
|
- .eq(TBModuleProficiency::getCourseName, arr[2])
|
|
|
- .eq(TBModuleProficiency::getModuleType, arr[3]));
|
|
|
+ .eq(TBModuleProficiency::getModuleType, arr[2]));
|
|
|
}
|
|
|
for (String s : moduleConfigRemove) {
|
|
|
String[] arr = s.split(SystemConstant.HYPHEN);
|
|
|
tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
|
|
|
.eq(TBModuleConfig::getExamId, arr[0])
|
|
|
.eq(TBModuleConfig::getCourseCode, arr[1])
|
|
|
- .eq(TBModuleConfig::getCourseName, arr[2])
|
|
|
- .eq(TBModuleConfig::getModuleType, arr[3]));
|
|
|
+ .eq(TBModuleConfig::getModuleType, arr[2]));
|
|
|
}
|
|
|
tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
|
|
|
tbModuleConfigService.saveBatch(tbModuleConfigList);
|
|
@@ -443,12 +444,13 @@ public class BasicDatasourceController {
|
|
|
public Result examAnswerImport(@ApiParam(value = "云阅卷考试id", required = true) @RequestParam Long id, @ApiParam(value = "云阅卷考试编号", required = false)
|
|
|
@RequestParam(required = false) String cloudExamCode,
|
|
|
@ApiParam(value = "教研分析将AB卷分开分析时自定义科目和卷形的连接符(连接符必须和’t_e_course‘表中的科目名称中连接符对应)")
|
|
|
- @RequestParam(required = false) String linkSign, @RequestParam Long schoolId) throws IOException {
|
|
|
- if (schoolId == null || schoolId == 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("参数缺失");
|
|
|
- }
|
|
|
+ @RequestParam(required = false) String linkSign, @RequestParam Long pSchoolId) throws IOException {
|
|
|
TBExam tbExam = tbExamService.findByCloudExamId(id);
|
|
|
Long examId = tbExam.getId();
|
|
|
+ Long schoolId = tbExamService.getById(examId).getSchoolId();
|
|
|
+ if (schoolId != pSchoolId){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学校id不匹配");
|
|
|
+ }
|
|
|
|
|
|
// 该考试要考察的所有课程
|
|
|
List<TBExamCourse> tbExamCourseList = tbExamCourseService.list(new QueryWrapper<TBExamCourse>().lambda().eq(TBExamCourse::getExamId, examId));
|
|
@@ -595,7 +597,11 @@ public class BasicDatasourceController {
|
|
|
tbExamStudent.setInspectCollegeId(tbSchoolCollege.getId());
|
|
|
tbExamStudent.setClazzId(tbSchoolClazz.getId());
|
|
|
tbExamStudent.setMajorId(0L);
|
|
|
- tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
|
|
|
+ if (Objects.nonNull(tbSchoolTeacher)){
|
|
|
+ tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
|
|
|
+ }else {
|
|
|
+ tbExamStudent.setTeacherId(0L);
|
|
|
+ }
|
|
|
tbExamStudent.setTicketNumber(examNumber);
|
|
|
tbExamStudent.setAbsent(status == 2);
|
|
|
// 全部设置为本届
|
|
@@ -655,13 +661,11 @@ public class BasicDatasourceController {
|
|
|
tbStudentService.saveOrUpdateBatch(tbStudentList);
|
|
|
|
|
|
// 删除原t_b_answer、t_b_exam_record、t_b_exam_student表数据
|
|
|
- List<String> courseInfoList = tbExamStudentList.stream().map(e -> e.getCourseCode() + SystemConstant.HYPHEN + e.getCourseName()).collect(Collectors.toList());
|
|
|
+ List<String> courseInfoList = tbExamStudentList.stream().map(TBExamStudent::getCourseCode).collect(Collectors.toList());
|
|
|
Set<Long> examStudentRemoveIdSet = new HashSet<>();
|
|
|
for (String s : courseInfoList) {
|
|
|
- String[] arr = s.split(SystemConstant.HYPHEN);
|
|
|
Set<Long> ids = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
|
|
|
- .eq(TBExamStudent::getCourseCode, arr[0])
|
|
|
- .eq(TBExamStudent::getCourseName, arr[1]))
|
|
|
+ .eq(TBExamStudent::getCourseCode, s))
|
|
|
.stream().map(TBExamStudent::getId).collect(Collectors.toSet());
|
|
|
examStudentRemoveIdSet.addAll(ids);
|
|
|
}
|
|
@@ -687,6 +691,76 @@ public class BasicDatasourceController {
|
|
|
return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "公式赋分操作")
|
|
|
+ @RequestMapping(value = "/normal/assignScore", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result normalAssignScore(@RequestParam Long examId, @RequestParam Long schoolId, @RequestParam String courseCode) throws IOException, NoSuchFieldException {
|
|
|
+ List<String> courseCodeList = new ArrayList<>();
|
|
|
+ courseCodeList.add(courseCode);
|
|
|
+
|
|
|
+ // 数据同步操作
|
|
|
+ // 获取当前课程下所有学生考试成绩记录
|
|
|
+ List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId, courseCodeList);
|
|
|
+ for (String s : courseCodeList) {
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, s, basicCourseService.findByCourseCode(s).getName())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号[" + s + "]的课程分析数据已测试或发布,不能变更基础数据");
|
|
|
+ }
|
|
|
+ List<BasicExamRecordDto> basicExamRecordDtoList = basicExamRecordDtoDatasource.stream()
|
|
|
+ .filter(e -> s.equals(e.getCourseCode())).collect(Collectors.toList());
|
|
|
+ if (basicExamRecordDtoList.size() > 0) {
|
|
|
+ // 删除源数据
|
|
|
+ taExamCourseRecordService.remove(new QueryWrapper<TAExamCourseRecord>()
|
|
|
+ .lambda().eq(TAExamCourseRecord::getExamId, examId).eq(TAExamCourseRecord::getCourseCode, s));
|
|
|
+ // 迁移数据至't_a_exam_course_record'
|
|
|
+ List<TAExamCourseRecord> taExamCourseRecordList = new ArrayList<>();
|
|
|
+ for (BasicExamRecordDto basicExamRecordDto : basicExamRecordDtoList) {
|
|
|
+ boolean absent = basicExamRecordDto.getAbsent();
|
|
|
+ // 正常公式赋分操作
|
|
|
+ Long paperId = basicExamRecordDto.getPaperId();
|
|
|
+ TBPaper tbPaper = tbPaperService.getById(paperId);
|
|
|
+ if (Objects.isNull(tbPaper)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷信息数据异常");
|
|
|
+ }
|
|
|
+ BigDecimal fullScore = tbPaper.getTotalScore();
|
|
|
+ BigDecimal myScore = basicExamRecordDto.getTotalScore();
|
|
|
+ BigDecimal coefficient = tbPaper.getCoefficient();
|
|
|
+ BigDecimal assignScore;
|
|
|
+ // 当该试卷的赋分系数不为0时赋分
|
|
|
+ if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !absent) {
|
|
|
+ assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 0, BigDecimal.ROUND_HALF_DOWN));
|
|
|
+ } else {
|
|
|
+ assignScore = myScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ TAExamCourseRecord taExamCourseRecord = new TAExamCourseRecord();
|
|
|
+ taExamCourseRecord.setId(SystemConstant.getDbUuid());
|
|
|
+ taExamCourseRecord.setExamRecordId(basicExamRecordDto.getTbExamRecordId());
|
|
|
+ // 数据同步默认赋分成绩为卷面成绩
|
|
|
+ taExamCourseRecord.setSchoolId(tbExamService.getById(examId).getSchoolId());
|
|
|
+ taExamCourseRecord.setAssignedScore(assignScore);
|
|
|
+ taExamCourseRecord.setExamId(examId);
|
|
|
+ taExamCourseRecord.setCourseCode(basicExamRecordDto.getCourseCode());
|
|
|
+ taExamCourseRecord.setPaperId(basicExamRecordDto.getPaperId());
|
|
|
+ taExamCourseRecord.setPaperType(basicExamRecordDto.getPaperType());
|
|
|
+ taExamCourseRecord.setStudentId(basicExamRecordDto.getStudentId());
|
|
|
+ taExamCourseRecord.setStudentCode(basicExamRecordDto.getStudentCode());
|
|
|
+ taExamCourseRecord.setTeacherId(basicExamRecordDto.getTeacherId());
|
|
|
+ taExamCourseRecord.setClazzId(basicExamRecordDto.getClazzId());
|
|
|
+ taExamCourseRecord.setTeachCollegeId(basicExamRecordDto.getTeachCollegeId());
|
|
|
+ taExamCourseRecord.setInspectCollegeId(basicExamRecordDto.getInspectCollegeId());
|
|
|
+ taExamCourseRecord.setMajorId(basicExamRecordDto.getMajorId());
|
|
|
+ taExamCourseRecord.setTotalScore(myScore);
|
|
|
+ taExamCourseRecord.setAbsent(absent);
|
|
|
+ taExamCourseRecord.setStudentCurrent(basicExamRecordDto.getStudentCurrent());
|
|
|
+ taExamCourseRecordList.add(taExamCourseRecord);
|
|
|
+ }
|
|
|
+ taExamCourseRecordService.saveBatch(taExamCourseRecordList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "特殊科目赋分操作")
|
|
|
@RequestMapping(value = "/special/assignScore", method = RequestMethod.POST)
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -722,7 +796,7 @@ public class BasicDatasourceController {
|
|
|
BigDecimal myScore = basicExamRecordDto.getTotalScore();
|
|
|
BigDecimal coefficient = tbPaper.getCoefficient();
|
|
|
BigDecimal assignScore;
|
|
|
- if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !basicExamRecordDto.getAbsent()) {
|
|
|
assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 0, BigDecimal.ROUND_HALF_DOWN));
|
|
|
} else {
|
|
|
assignScore = myScore;
|
|
@@ -784,6 +858,9 @@ public class BasicDatasourceController {
|
|
|
.filter(e -> assExamId.equals(e.getExamId()) && s.equals(e.getCourseCode()) && assStudentCode.equals(e.getStudentCode()))
|
|
|
.collect(Collectors.toList());
|
|
|
if (taExamCourseRecordList.size() != 1) {
|
|
|
+ if (taExamCourseRecordList.size() < 1){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
System.out.println("-----------------------");
|
|
|
System.out.println(JSON.toJSONString(taExamCourseRecordList));
|
|
|
throw ExceptionResultEnum.ERROR.exception("赋分异常,考生记录分析表数据异常");
|