|
@@ -0,0 +1,941 @@
|
|
|
+package com.qmth.teachcloud.report.api;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicCourse;
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
+import com.qmth.teachcloud.common.entity.SysRole;
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.RoleTypeEnum;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
+import com.qmth.teachcloud.common.service.SysRoleService;
|
|
|
+import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
+import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
+import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
+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.*;
|
|
|
+import com.qmth.teachcloud.report.business.enums.AssignEnum;
|
|
|
+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.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.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 基础数据导入系统基础表控制类
|
|
|
+ * @Author: CaoZixuan
|
|
|
+ * @Date: 2021-06-01
|
|
|
+ */
|
|
|
+@Api(tags = "数据源处理controller")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/${prefix.url.wuda}/datasource")
|
|
|
+public class BasicDatasourceController {
|
|
|
+ @Resource
|
|
|
+ private TBPaperService tbPaperService;
|
|
|
+ @Resource
|
|
|
+ private TBPaperStructService tbPaperStructService;
|
|
|
+ @Resource
|
|
|
+ private TBExamCourseService tbExamCourseService;
|
|
|
+ @Resource
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleProficiencyService tbModuleProficiencyService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleConfigService tbModuleConfigService;
|
|
|
+ @Resource
|
|
|
+ private TBDimensionService tbDimensionService;
|
|
|
+ @Resource
|
|
|
+ private TBExamService tbExamService;
|
|
|
+ @Resource
|
|
|
+ private NewCallApiService newCallApiService;
|
|
|
+ @Resource
|
|
|
+ private TBSchoolClazzService tbSchoolClazzService;
|
|
|
+ @Resource
|
|
|
+ private SysOrgService sysOrgService;
|
|
|
+ @Resource
|
|
|
+ private TBSchoolMajorService tbSchoolMajorService;
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
+ @Resource
|
|
|
+ private TBStudentService tbStudentService;
|
|
|
+ @Resource
|
|
|
+ private TBAnswerService tbAnswerService;
|
|
|
+ @Resource
|
|
|
+ private TBExamRecordService tbExamRecordService;
|
|
|
+ @Resource
|
|
|
+ private TBExamStudentService tbExamStudentService;
|
|
|
+ @Resource
|
|
|
+ private TAExamCourseRecordService taExamCourseRecordService;
|
|
|
+ @Resource
|
|
|
+ private TBCommonLevelConfigService tbCommonLevelConfigService;
|
|
|
+ @Resource
|
|
|
+ private TBCommonRankLevelConfigService tbCommonRankLevelConfigService;
|
|
|
+ @Resource
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "试卷数据导入")
|
|
|
+ @RequestMapping(value = "/paper/import", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result paperImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam long examId, @RequestParam Long schoolId) throws IOException, NoSuchFieldException {
|
|
|
+ if (Objects.isNull(file)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
+ }
|
|
|
+ if (examId == 0){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考试id为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(PaperConfigDto.class, PaperStructDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+
|
|
|
+ //保存到数据库
|
|
|
+ Map<String,Long> paperMap = new HashMap<>();
|
|
|
+ List<TBPaper> tbPaperList = new ArrayList<>();
|
|
|
+ List<TBPaperStruct> tbPaperStructList = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
+ LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
|
+ List<Object> importList = map.get(i);
|
|
|
+
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(importList).size(); y++) {
|
|
|
+ if (importList.get(y) instanceof PaperConfigDto) {
|
|
|
+ PaperConfigDto paperConfigDto = (PaperConfigDto) importList.get(y);
|
|
|
+
|
|
|
+ String courseCode = paperConfigDto.getCourseCode();
|
|
|
+ String courseName = paperConfigDto.getCourseName();
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal coefficient = BigDecimal.ZERO;
|
|
|
+ if (Objects.nonNull(paperConfigDto.getCoefficient()) && paperConfigDto.getCoefficient() instanceof Double){
|
|
|
+ coefficient = BigDecimal.valueOf((Double) paperConfigDto.getCoefficient());
|
|
|
+ }
|
|
|
+ String paperType = paperConfigDto.getPaperType();
|
|
|
+ List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
|
|
|
+ .eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode).eq(TBPaper::getPaperType,paperType));
|
|
|
+ Long id;
|
|
|
+ if (oldList.size() == 1){
|
|
|
+ id = oldList.get(0).getId();
|
|
|
+ }else if (oldList.size() < 1){
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
+ }else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("表数据异常[t_b_paper]");
|
|
|
+ }
|
|
|
+
|
|
|
+ paperMap.put(paperType,id);
|
|
|
+ TBPaper tbPaper = new TBPaper();
|
|
|
+ tbPaper.setId(id);
|
|
|
+ tbPaper.setExamId(examId);
|
|
|
+ tbPaper.setCourseCode(courseCode);
|
|
|
+ tbPaper.setCourseName(courseName);
|
|
|
+ tbPaper.setPaperType(paperType);
|
|
|
+ tbPaper.setCoefficient(coefficient);
|
|
|
+ tbPaper.setTotalScore(BigDecimal.valueOf(Double.parseDouble(paperConfigDto.getFullScore())));
|
|
|
+ tbPaper.setPassScore(BigDecimal.valueOf(Double.parseDouble(paperConfigDto.getPassScore())));
|
|
|
+ String scoreType = paperConfigDto.getIsAssigned();
|
|
|
+ tbPaper.setScoreType(AssignEnum.convertToEnum(scoreType));
|
|
|
+ tbPaperList.add(tbPaper);
|
|
|
+ } else if (importList.get(y) instanceof PaperStructDto) {
|
|
|
+ PaperStructDto paperStructDto = (PaperStructDto) importList.get(y);
|
|
|
+
|
|
|
+ String courseCode = paperStructDto.getCourseCode();
|
|
|
+ String courseName = paperStructDto.getCourseName();
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String paperType = paperStructDto.getPaperCode();
|
|
|
+ Long paperId = paperMap.get(paperType);
|
|
|
+ String mainNumber = paperStructDto.getMainNumber();
|
|
|
+ String subNumber = paperStructDto.getSubNumber();
|
|
|
+ String questionType = paperStructDto.getQuestionType();
|
|
|
+ if (questionType == null){
|
|
|
+ questionType = "";
|
|
|
+ }
|
|
|
+ String questionName = questionType + " " + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
+ questionName = questionName.trim(); // 去前后空格
|
|
|
+
|
|
|
+ TBPaperStruct tbPaperStruct = new TBPaperStruct();
|
|
|
+ tbPaperStruct.setId(SystemConstant.getDbUuid());
|
|
|
+ tbPaperStruct.setPaperId(paperId);
|
|
|
+ tbPaperStruct.setQuestionName(questionName);
|
|
|
+ tbPaperStruct.setNumberType(paperStructDto.getNumberType());
|
|
|
+ tbPaperStruct.setBigQuestionNumber(mainNumber);
|
|
|
+ tbPaperStruct.setSmallQuestionNumber(subNumber);
|
|
|
+ tbPaperStruct.setQuestionType(questionType);
|
|
|
+ tbPaperStruct.setFullScore(BigDecimal.valueOf(Double.parseDouble(paperStructDto.getFullScore())));
|
|
|
+ tbPaperStruct.setScoreRules(paperStructDto.getScoreRules());
|
|
|
+ tbPaperStruct.setRulesDesc(paperStructDto.getRulesDesc());
|
|
|
+ tbPaperStruct.setKnowledgeDimension(paperStructDto.getKnowledgeDimension());
|
|
|
+ tbPaperStruct.setAbilityDimension(paperStructDto.getAbilityDimension());
|
|
|
+ tbPaperStructList.add(tbPaperStruct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> paperIdList = tbPaperStructList.stream().map(TBPaperStruct::getPaperId).collect(Collectors.toList());
|
|
|
+ // 删除已有的试卷结构数据
|
|
|
+ if (paperIdList.size() > 0){
|
|
|
+ tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().in(TBPaperStruct::getPaperId,paperIdList));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量新增或更新试卷表
|
|
|
+ tbPaperService.saveOrUpdateBatch(tbPaperList);
|
|
|
+ // 批量新增试卷结构表
|
|
|
+ tbPaperStructService.saveBatch(tbPaperStructList);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "模块和等级导入接口")
|
|
|
+ @RequestMapping(value = "/moduleLevel/import", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result moduleLevelImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long schoolId, @RequestParam Long examId) throws IOException, NoSuchFieldException {
|
|
|
+ if (Objects.isNull(file)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("附件不存在");
|
|
|
+ }
|
|
|
+ if (schoolId == null || schoolId == 0){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("参数缺失");
|
|
|
+ }
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(),
|
|
|
+ Lists.newArrayList(ModuleProficiencyDto.class, ModuleConfigDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+ //保存到数据库
|
|
|
+
|
|
|
+ // 模块二级考察点维度熟练度配置,及模块简要描述表
|
|
|
+ List<TBModuleProficiency> tbModuleProficiencyList = new ArrayList<>();
|
|
|
+ // 考察点模块配置表
|
|
|
+ List<TBModuleConfig> tbModuleConfigList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
+ LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
|
+ List<Object> importList = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(importList).size(); y++) {
|
|
|
+ if (importList.get(y) instanceof ModuleProficiencyDto) {
|
|
|
+
|
|
|
+ ModuleProficiencyDto moduleProficiencyDto = (ModuleProficiencyDto) importList.get(y);
|
|
|
+ String proficiencyDegree = moduleProficiencyDto.getProficiencyDegree(); // 精熟度范围
|
|
|
+ String define = moduleProficiencyDto.getProficiency(); // define
|
|
|
+ String courseCode = moduleProficiencyDto.getCourseCode();
|
|
|
+ String courseName = moduleProficiencyDto.getCourseName();
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (proficiencyDegree != null && proficiencyDegree.length() > 0 && define != null && define.length() > 0) {
|
|
|
+ // - 解析精熟度范围
|
|
|
+ String[] itemCell = proficiencyDegree.split(";"); // 每一项熟练度定义
|
|
|
+ String[] defineCell = define.split(";"); // 每个定义
|
|
|
+ if (itemCell.length > 0 && defineCell.length > 0) {
|
|
|
+ if (defineCell.length != itemCell.length) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int tmp = 0; tmp < itemCell.length; tmp++) {
|
|
|
+
|
|
|
+ String[] levelWithScopeCell = itemCell[tmp].split(":"); // 每一项中等级和对应分为标准的定义
|
|
|
+ if (levelWithScopeCell.length != 2) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("应该有2条数据,实际 :" + itemCell[tmp]);
|
|
|
+ }
|
|
|
+ String level = levelWithScopeCell[0];
|
|
|
+ String scope = levelWithScopeCell[1];
|
|
|
+ String limitTmp = scope.substring(1, scope.length() - 1);
|
|
|
+
|
|
|
+ String[] limitCell = limitTmp.split(","); // 每个范围中极值的数组
|
|
|
+ if (limitCell.length != 2) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据异常");
|
|
|
+ }
|
|
|
+ String min = limitCell[0];
|
|
|
+ String max = limitCell[1];
|
|
|
+ TBModuleProficiency tbModuleProficiency = new TBModuleProficiency();
|
|
|
+ tbModuleProficiency.setId(SystemConstant.getDbUuid());
|
|
|
+ tbModuleProficiency.setExamId(examId);
|
|
|
+ tbModuleProficiency.setCourseCode(courseCode);
|
|
|
+ tbModuleProficiency.setCourseName(courseName);
|
|
|
+ tbModuleProficiency.setModuleType(moduleProficiencyDto.getName());
|
|
|
+ tbModuleProficiency.setInterpret(moduleProficiencyDto.getDescription());
|
|
|
+ tbModuleProficiency.setRemark(moduleProficiencyDto.getRemark());
|
|
|
+ tbModuleProficiency.setDefine(defineCell[tmp].trim());
|
|
|
+ tbModuleProficiency.setLevel(level);
|
|
|
+ tbModuleProficiency.setMin(min);
|
|
|
+ tbModuleProficiency.setMax(max);
|
|
|
+ tbModuleProficiency.setScope(scope);
|
|
|
+
|
|
|
+ tbModuleProficiencyList.add(tbModuleProficiency);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ TBModuleProficiency tbModuleProficiency = new TBModuleProficiency();
|
|
|
+ tbModuleProficiency.setId(SystemConstant.getDbUuid());
|
|
|
+ tbModuleProficiency.setExamId(examId);
|
|
|
+ tbModuleProficiency.setCourseCode(courseCode);
|
|
|
+ tbModuleProficiency.setCourseName(courseName);
|
|
|
+ tbModuleProficiency.setModuleType(moduleProficiencyDto.getName());
|
|
|
+ tbModuleProficiency.setInterpret(moduleProficiencyDto.getDescription());
|
|
|
+
|
|
|
+ tbModuleProficiencyList.add(tbModuleProficiency);
|
|
|
+ }
|
|
|
+ } else if (importList.get(y) instanceof ModuleConfigDto) {
|
|
|
+ /*
|
|
|
+ 构建config_module
|
|
|
+ */
|
|
|
+ ModuleConfigDto moduleConfigDto = (ModuleConfigDto) importList.get(y);
|
|
|
+
|
|
|
+ String courseCode = moduleConfigDto.getCourseCode();
|
|
|
+ String courseName = basicCourseService.getOne(new QueryWrapper<BasicCourse>().lambda()
|
|
|
+ .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode))
|
|
|
+ .getName();
|
|
|
+
|
|
|
+
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TBModuleConfig tbModuleConfig = new TBModuleConfig();
|
|
|
+ tbModuleConfig.setId(SystemConstant.getDbUuid());
|
|
|
+ tbModuleConfig.setExamId(examId);
|
|
|
+ tbModuleConfig.setCourseCode(courseCode);
|
|
|
+ tbModuleConfig.setCourseName(courseName);
|
|
|
+ tbModuleConfig.setModuleType(moduleConfigDto.getModuleName());
|
|
|
+ tbModuleConfig.setFormula(moduleConfigDto.getFormula());
|
|
|
+ tbModuleConfig.setScope(moduleConfigDto.getLevelDegree());
|
|
|
+ tbModuleConfig.setLevelCode(moduleConfigDto.getCode());
|
|
|
+ tbModuleConfig.setLevelName(moduleConfigDto.getLevel());
|
|
|
+ tbModuleConfig.setResult(moduleConfigDto.getDiagnoseResult());
|
|
|
+ tbModuleConfig.setAdvice(moduleConfigDto.getLearnAdvice());
|
|
|
+ if (moduleConfigDto.getModuleName().equals("知识")) {
|
|
|
+ tbModuleConfig.setAttribute("knowledgeDimension");
|
|
|
+ } else if (moduleConfigDto.getModuleName().equals("能力")) {
|
|
|
+ tbModuleConfig.setAttribute("abilityDimension");
|
|
|
+ }
|
|
|
+ tbModuleConfigList.add(tbModuleConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ String[] arr = s.split(SystemConstant.HYPHEN);
|
|
|
+ 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]));
|
|
|
+ }
|
|
|
+ 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]));
|
|
|
+ }
|
|
|
+ tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
|
|
|
+ tbModuleConfigService.saveBatch(tbModuleConfigList);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "知识点导入模板")
|
|
|
+ @RequestMapping(value = "/dimension/import", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result dimensionImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long schoolId,@RequestParam Long examId) throws IOException, NoSuchFieldException {
|
|
|
+ if (Objects.isNull(file)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("附件不存在");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(schoolId) || schoolId == 0){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("参数缺失");
|
|
|
+ }
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(DimensionDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+ //保存到数据库
|
|
|
+ List<TBDimension> tbDimensionList = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
+ LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
|
+ List<Object> moduleLevelImportList = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(moduleLevelImportList).size(); y++) {
|
|
|
+ if (moduleLevelImportList.get(y) instanceof DimensionDto) {
|
|
|
+ DimensionDto dimensionDto = (DimensionDto) moduleLevelImportList.get(y);
|
|
|
+
|
|
|
+ String courseCode = dimensionDto.getCourseCode();
|
|
|
+ String courseName = basicCourseService.getOne(new QueryWrapper<BasicCourse>().lambda()
|
|
|
+ .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode))
|
|
|
+ .getName();
|
|
|
+
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TBDimension tbDimension = new TBDimension();
|
|
|
+ tbDimension.setId(SystemConstant.getDbUuid());
|
|
|
+ tbDimension.setExamId(examId);
|
|
|
+ tbDimension.setCourseCode(courseCode);
|
|
|
+ tbDimension.setCourseName(courseName);
|
|
|
+ tbDimension.setDimensionType(dimensionDto.getModule());
|
|
|
+ tbDimension.setCodePrimary(dimensionDto.getCodeOne());
|
|
|
+ tbDimension.setNamePrimary(dimensionDto.getNameOne());
|
|
|
+ tbDimension.setCodeSecond(dimensionDto.getCodeTwo());
|
|
|
+ tbDimension.setNameSecond(dimensionDto.getNameTwo());
|
|
|
+ tbDimension.setInterpretation(dimensionDto.getInterpretation());
|
|
|
+
|
|
|
+ tbDimensionList.add(tbDimension);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Set<String> tbDimensionRemove = tbDimensionList.stream().map(e -> e.getExamId() + SystemConstant.HYPHEN + e.getCourseCode()).collect(Collectors.toSet());
|
|
|
+ for (String s : tbDimensionRemove) {
|
|
|
+ String[] arr = s.split(SystemConstant.HYPHEN);
|
|
|
+ tbDimensionService.remove(new QueryWrapper<TBDimension>().lambda()
|
|
|
+ .eq(TBDimension::getExamId,arr[0])
|
|
|
+ .eq(TBDimension::getCourseCode,arr[1]));
|
|
|
+ }
|
|
|
+ tbDimensionService.saveBatch(tbDimensionList);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试作答信息导入模板")
|
|
|
+ @RequestMapping(value = "/examAnswer/import", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ 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("参数缺失");
|
|
|
+ }
|
|
|
+ TBExam tbExam = tbExamService.findByCloudExamId(id);
|
|
|
+ Long examId = tbExam.getId();
|
|
|
+
|
|
|
+ // 该考试要考察的所有课程
|
|
|
+ List<TBExamCourse> tbExamCourseList = tbExamCourseService.list(new QueryWrapper<TBExamCourse>().lambda().eq(TBExamCourse::getExamId,examId));
|
|
|
+
|
|
|
+ List<Map> finalList = newCallApiService.callStudentScore(id, cloudExamCode);
|
|
|
+// System.out.println("------------------map : --------------------- \n" + JacksonUtil.parseJson(finalList));
|
|
|
+
|
|
|
+ // 根据云阅卷数据源筛选并保存班级、学院、教师数据源
|
|
|
+ // TODO: 2021/6/2 筛选并创建学校班级表
|
|
|
+ List<TBSchoolClazzDto> tbSchoolClazzDtoList = new ArrayList<>();
|
|
|
+ List<String> clazzList = finalList.stream()
|
|
|
+ .map(e -> String.valueOf(e.get(ExamCloudDataEnum.CLASS_NAME.getName())))
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ for (String clazzInfo : clazzList) {
|
|
|
+ TBSchoolClazzDto tbSchoolClazzDto = new TBSchoolClazzDto();
|
|
|
+ tbSchoolClazzDto.setSchoolId(schoolId);
|
|
|
+ tbSchoolClazzDto.setClazzCode(clazzInfo);
|
|
|
+ tbSchoolClazzDto.setClazzName(clazzInfo);
|
|
|
+ tbSchoolClazzDtoList.add(tbSchoolClazzDto);
|
|
|
+ }
|
|
|
+ this.saveClazzInfo(tbSchoolClazzDtoList);
|
|
|
+ // TODO: 2021/6/2 筛选并创建学校学院表
|
|
|
+ List<TBSchoolCollegeDto> tbSchoolCollegeDtoList = new ArrayList<>();
|
|
|
+ List<String> collegeList = finalList.stream()
|
|
|
+ .map(e -> String.valueOf(e.get(ExamCloudDataEnum.COLLEGE.getName())))
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ for (String collegeInfo : collegeList) {
|
|
|
+ TBSchoolCollegeDto tbSchoolCollegeDto = new TBSchoolCollegeDto();
|
|
|
+ tbSchoolCollegeDto.setSchoolId(schoolId);
|
|
|
+ tbSchoolCollegeDto.setCollegeCode(collegeInfo);
|
|
|
+ tbSchoolCollegeDto.setCollegeName(collegeInfo);
|
|
|
+ tbSchoolCollegeDtoList.add(tbSchoolCollegeDto);
|
|
|
+ }
|
|
|
+ this.saveCollegeInfo(tbSchoolCollegeDtoList);
|
|
|
+ // TODO: 2021/6/2 筛选并创建学校教师表
|
|
|
+ List<TBSchoolTeacherDto> tbSchoolTeacherDtoList = new ArrayList<>();
|
|
|
+ List<String> teacherList = finalList.stream()
|
|
|
+ .map(e -> String.valueOf(e.get(ExamCloudDataEnum.TEACHER.getName())))
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ for (String teacherInfo : teacherList) {
|
|
|
+ TBSchoolTeacherDto tbSchoolTeacherDto = new TBSchoolTeacherDto();
|
|
|
+ tbSchoolTeacherDto.setSchoolId(schoolId);
|
|
|
+ tbSchoolTeacherDto.setTeacherCode(teacherInfo);
|
|
|
+ tbSchoolTeacherDto.setTeacherName(teacherInfo);
|
|
|
+ tbSchoolTeacherDtoList.add(tbSchoolTeacherDto);
|
|
|
+ }
|
|
|
+ this.saveTeacherInfo(tbSchoolTeacherDtoList);
|
|
|
+
|
|
|
+
|
|
|
+ List<TBStudent> tbStudentList = new ArrayList<>();
|
|
|
+ List<TBExamStudent> tbExamStudentList = new ArrayList<>();
|
|
|
+ List<TBExamRecord> tbExamRecordList = new ArrayList<>();
|
|
|
+ List<TBAnswer> tbAnswerList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> paperTypeList = finalList.stream().map(e -> String.valueOf(e.get("paperType"))).distinct().collect(Collectors.toList());
|
|
|
+ final String specialPaperType = "#";
|
|
|
+ paperTypeList.remove(specialPaperType);
|
|
|
+ int count = paperTypeList.size();
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ for (Map map : finalList) {
|
|
|
+ String subjectCode = (String) map.get(ExamCloudDataEnum.SUBJECT_CODE.getName()); //科目代码
|
|
|
+ String subjectName = (String) map.get(ExamCloudDataEnum.SUBJECT_NAME.getName()); //科目名称
|
|
|
+ String examNumber = (String) map.get(ExamCloudDataEnum.EXAM_NUMBER.getName()); //准考证号
|
|
|
+ String studentCode = (String) map.get(ExamCloudDataEnum.STUDENT_CODE.getName()); //学号
|
|
|
+ String name = (String) map.get(ExamCloudDataEnum.NAME.getName()); //名称
|
|
|
+ String paperType = (String) map.get(ExamCloudDataEnum.PAPER_TYPE.getName()); //试卷类型
|
|
|
+ if (count > 0 && paperType.equals(specialPaperType)) {
|
|
|
+ paperType = paperTypeList.get(i);
|
|
|
+ i++;
|
|
|
+ if (i == count) {
|
|
|
+ i = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String college = (String) map.get(ExamCloudDataEnum.COLLEGE.getName()); //学院
|
|
|
+ String className = (String) map.get(ExamCloudDataEnum.CLASS_NAME.getName()); //班级名称
|
|
|
+ String teacher = (String) map.get(ExamCloudDataEnum.TEACHER.getName()); //教师
|
|
|
+ int status = (int) map.get(ExamCloudDataEnum.STATUS.getName()); //学生考试状态
|
|
|
+ String totalScore = (String) map.get(ExamCloudDataEnum.TOTAL_SCORE.getName()); //考生总分
|
|
|
+ String objectiveScore = (String) map.get(ExamCloudDataEnum.OBJECTIVE_SCORE.getName()); //客观题总分
|
|
|
+ String subjectiveScore = (String) map.get(ExamCloudDataEnum.SUBJECTIVE_SCORE.getName()); //主观题总分
|
|
|
+ List<Map<Object, Object>> objectiveScoreDetailList = (List<Map<Object, Object>>) map.get(ExamCloudDataEnum.OBJECTIVE_SCORE_DETAIL.getName()); //客观题明细
|
|
|
+ List<Map<Object, Object>> subjectiveScoreDetailList = (List<Map<Object, Object>>) map.get(ExamCloudDataEnum.SUBJECTIVE_SCORE_DETAIL.getName()); //主观题答题明细
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ 组建学生基础信息 student
|
|
|
+ */
|
|
|
+ TBStudent studentTemp = tbStudentService.getOne(new QueryWrapper<TBStudent>().lambda()
|
|
|
+ .eq(TBStudent::getSchoolId,schoolId)
|
|
|
+ .eq(TBStudent::getName,name)
|
|
|
+ .eq(TBStudent::getStudentCode,studentCode));
|
|
|
+ Long studentId;
|
|
|
+ if (Objects.nonNull(studentTemp)){
|
|
|
+ studentId = studentTemp.getId();
|
|
|
+ }else {
|
|
|
+ studentId = SystemConstant.getDbUuid();
|
|
|
+ }
|
|
|
+ TBStudent tbStudent = new TBStudent();
|
|
|
+ tbStudent.setId(studentId);
|
|
|
+ tbStudent.setSchoolId(schoolId);
|
|
|
+ tbStudent.setName(name);
|
|
|
+ tbStudent.setStudentCode(studentCode);
|
|
|
+ tbStudentList.add(tbStudent);
|
|
|
+
|
|
|
+ /*
|
|
|
+ 组建考生考试信息 exm_pap_tik
|
|
|
+ */
|
|
|
+ List<TBExamCourse> needDisposeList;
|
|
|
+ if (linkSign != null && linkSign.length() > 0) { // 云阅卷在同一个考试下 科目名称相同分AB卷 但在教研分析时分科处理的科目
|
|
|
+ String finalPaperType = paperType;
|
|
|
+ needDisposeList = tbExamCourseList.stream().filter(e -> e.getCourseName().equals(subjectName + linkSign + finalPaperType)).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ needDisposeList = tbExamCourseList.stream().filter(e -> e.getCourseName().equals(subjectName)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (needDisposeList.size() == 1) {
|
|
|
+
|
|
|
+ TBExamCourse tbExamCourse = needDisposeList.get(0);
|
|
|
+ String courseCode = tbExamCourse.getCourseCode();
|
|
|
+ String courseName = tbExamCourse.getCourseName();
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: 2021/6/2 创建学生-考试关系表(全批次删除并新增)
|
|
|
+ // 获取关联的基础表主键
|
|
|
+ SysOrg tbSchoolCollege = sysOrgService.findByForeignKey(schoolId,college,college);
|
|
|
+ TBSchoolClazz tbSchoolClazz = tbSchoolClazzService.findByForeignKey(schoolId,className,className);
|
|
|
+ SysUser tbSchoolTeacher = sysUserService.findByForeignKey(schoolId,teacher,teacher);
|
|
|
+
|
|
|
+ TBExamStudent tbExamStudent = new TBExamStudent();
|
|
|
+ Long examStudentId = SystemConstant.getDbUuid();
|
|
|
+ tbExamStudent.setId(examStudentId);
|
|
|
+ tbExamStudent.setExamId(examId);
|
|
|
+ tbExamStudent.setName(name);
|
|
|
+ tbExamStudent.setStudentId(studentId);
|
|
|
+ tbExamStudent.setStudentCode(studentCode);
|
|
|
+ tbExamStudent.setCourseCode(courseCode);
|
|
|
+ tbExamStudent.setCourseName(courseName);
|
|
|
+ tbExamStudent.setTeachCollegeId(0L);
|
|
|
+ tbExamStudent.setInspectCollegeId(tbSchoolCollege.getId());
|
|
|
+ tbExamStudent.setClazzId(tbSchoolClazz.getId());
|
|
|
+ tbExamStudent.setMajorId(0L);
|
|
|
+ tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
|
|
|
+ tbExamStudent.setTicketNumber(examNumber);
|
|
|
+ tbExamStudent.setAbsent(status == 2);
|
|
|
+ // 全部设置为本届
|
|
|
+ tbExamStudent.setCurrent(true);
|
|
|
+ tbExamStudentList.add(tbExamStudent);
|
|
|
+
|
|
|
+ // TODO: 2021/6/2 创建考生-考试记录关系表(全批次删除并新增)
|
|
|
+ // 构建考生作答记录表(t_b_exam_record)
|
|
|
+ Long examRecordId = SystemConstant.getDbUuid();
|
|
|
+ TBExamRecord tbExamRecord = new TBExamRecord();
|
|
|
+ tbExamRecord.setId(examRecordId);
|
|
|
+ tbExamRecord.setExamId(examId);
|
|
|
+ tbExamRecord.setPaperId(tbPaperService.findByForeignKey(examId,courseCode,courseName,paperType).getId());
|
|
|
+ tbExamRecord.setPaperType(paperType);
|
|
|
+ tbExamRecord.setExamStudentId(examStudentId);
|
|
|
+ tbExamRecord.setSubjectiveScore(BigDecimal.valueOf(Double.parseDouble(subjectiveScore)));
|
|
|
+ tbExamRecord.setObjectiveScore(BigDecimal.valueOf(Double.parseDouble(objectiveScore)));
|
|
|
+ tbExamRecord.setTotalScore(BigDecimal.valueOf(Double.parseDouble(totalScore)));
|
|
|
+ tbExamRecordList.add(tbExamRecord);
|
|
|
+
|
|
|
+ // TODO: 2021/6/4 构建考生-详细作答记录表(全批次删除并新增)
|
|
|
+ // 构建考生作答明细表(t_b_answer)
|
|
|
+ // 客观题(选择)
|
|
|
+ for (Map<Object, Object> objectObjectMap : objectiveScoreDetailList) {
|
|
|
+ Long answerId = SystemConstant.getDbUuid();
|
|
|
+ TBAnswer tbAnswer = new TBAnswer();
|
|
|
+ tbAnswer.setId(answerId);
|
|
|
+ tbAnswer.setExamRecordId(examRecordId);
|
|
|
+ tbAnswer.setNumberType(NumberTypeEnum.OBJECTIVE.getValue());
|
|
|
+ String cloudMainNumber = String.valueOf(objectObjectMap.get(ExamCloudDataEnum.MAIN_NUMBER.getName()));
|
|
|
+ String cloudSubNumber = String.valueOf(objectObjectMap.get(ExamCloudDataEnum.SUB_NUMBER.getName()));
|
|
|
+ tbAnswer.setMainNumber(cloudMainNumber);
|
|
|
+ tbAnswer.setSubNumber(cloudSubNumber);
|
|
|
+ tbAnswer.setScore(BigDecimal.valueOf(Double.parseDouble(String.valueOf(objectObjectMap.get(ExamCloudDataEnum.SCORE.getName())))));
|
|
|
+ tbAnswer.setAnswer(String.valueOf(objectObjectMap.get(ExamCloudDataEnum.ANSWER.getName())));
|
|
|
+ tbAnswerList.add(tbAnswer);
|
|
|
+ }
|
|
|
+ // 主观题
|
|
|
+ for (Map<Object, Object> objectObjectMap : subjectiveScoreDetailList) {
|
|
|
+ Long answerId = SystemConstant.getDbUuid();
|
|
|
+ TBAnswer tbAnswer = new TBAnswer();
|
|
|
+ tbAnswer.setId(answerId);
|
|
|
+ tbAnswer.setExamRecordId(examRecordId);
|
|
|
+ tbAnswer.setNumberType(NumberTypeEnum.SUBJECTIVE.getValue());
|
|
|
+ String cloudMainNumber = String.valueOf(objectObjectMap.get(ExamCloudDataEnum.MAIN_NUMBER.getName()));
|
|
|
+ String cloudSubNumber = String.valueOf(objectObjectMap.get(ExamCloudDataEnum.SUB_NUMBER.getName()));
|
|
|
+ tbAnswer.setMainNumber(cloudMainNumber);
|
|
|
+ tbAnswer.setSubNumber(cloudSubNumber);
|
|
|
+ tbAnswer.setScore(BigDecimal.valueOf(Double.parseDouble(String.valueOf(objectObjectMap.get(ExamCloudDataEnum.SCORE.getName())))));
|
|
|
+ tbAnswer.setAnswer(String.valueOf(objectObjectMap.get(ExamCloudDataEnum.ANSWER.getName())));
|
|
|
+ tbAnswerList.add(tbAnswer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理并向数据库插入学生信息
|
|
|
+ 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());
|
|
|
+ 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]))
|
|
|
+ .stream().map(TBExamStudent::getId).collect(Collectors.toSet());
|
|
|
+ examStudentRemoveIdSet.addAll(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (examStudentRemoveIdSet.size() > 0){
|
|
|
+ // 删除考生表
|
|
|
+ tbExamStudentService.removeByIds(examStudentRemoveIdSet);
|
|
|
+ List<TBExamRecord> willRemoveRecord = tbExamRecordService.list(new QueryWrapper<TBExamRecord>()
|
|
|
+ .lambda().in(TBExamRecord::getExamStudentId,examStudentRemoveIdSet));
|
|
|
+ if (willRemoveRecord.size() > 0){
|
|
|
+ List<Long> willRemoveRecordIdList = willRemoveRecord.stream().map(TBExamRecord::getId).collect(Collectors.toList());
|
|
|
+ // 删除考生作答
|
|
|
+ tbExamRecordService.removeByIds(willRemoveRecordIdList);
|
|
|
+ // 删除考生作答
|
|
|
+ tbAnswerService.remove(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId,willRemoveRecordIdList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存数据
|
|
|
+ tbExamStudentService.saveBatch(tbExamStudentList);
|
|
|
+ tbExamRecordService.saveBatch(tbExamRecordList);
|
|
|
+ tbAnswerService.saveBatch(tbAnswerList);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "特殊科目赋分操作")
|
|
|
+ @RequestMapping(value = "/special/assignScore", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result specialAssignScore(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long examId,@RequestParam Long schoolId,
|
|
|
+ @ApiParam(value = "该Excel中包含多科目赋分时,各科目编号用','隔开", required = true) @RequestParam String courseCodeS) throws IOException, NoSuchFieldException {
|
|
|
+
|
|
|
+ List<String> courseCodeList = Arrays.asList(courseCodeS.split(","));
|
|
|
+ // 数据同步操作
|
|
|
+ // 获取当前课程下所有学生考试成绩记录
|
|
|
+ List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId,courseCodeList);
|
|
|
+ Set<TAExamCourseRecord> taExamCourseRecordDatasource = new HashSet<>();
|
|
|
+ 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) {
|
|
|
+ // 正常公式赋分操作
|
|
|
+ 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;
|
|
|
+ if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ 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.setAssignedScore(assignScore);
|
|
|
+ taExamCourseRecord.setExamId(basicExamRecordDto.getExamId());
|
|
|
+ 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(basicExamRecordDto.getAbsent());
|
|
|
+ taExamCourseRecord.setCurrent(basicExamRecordDto.getCurrent());
|
|
|
+ taExamCourseRecordList.add(taExamCourseRecord);
|
|
|
+ }
|
|
|
+ taExamCourseRecordDatasource.addAll(taExamCourseRecordList);
|
|
|
+ taExamCourseRecordService.saveBatch(taExamCourseRecordList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(AssignDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ });
|
|
|
+
|
|
|
+ //保存到数据库
|
|
|
+ List<TAExamCourseRecord> willUpdate = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
+ LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
|
+ List<Object> assignList = map.get(i);
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(assignList).size(); y++) {
|
|
|
+ if (assignList.get(y) instanceof AssignDto) {
|
|
|
+ AssignDto assignDto = (AssignDto) assignList.get(y);
|
|
|
+ Long assExamId = Long.parseLong(assignDto.getExamId());
|
|
|
+ if (!examId.equals(assExamId)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("excel考试数据异常");
|
|
|
+ }
|
|
|
+ String assCourseCodeS = assignDto.getPaperCodeS();
|
|
|
+ String assStudentCode = assignDto.getStudentCode();
|
|
|
+ String assAssignScore = assignDto.getAssignScore();
|
|
|
+ String[] courseCodeArr = assCourseCodeS.split(",");
|
|
|
+ for (String s : courseCodeArr) {
|
|
|
+ List<TAExamCourseRecord> taExamCourseRecordList = taExamCourseRecordDatasource.stream()
|
|
|
+ .filter(e -> assExamId.equals(e.getExamId()) && s.equals(e.getCourseCode()) && assStudentCode.equals(e.getStudentCode()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (taExamCourseRecordList.size() != 1){
|
|
|
+ System.out.println("-----------------------");
|
|
|
+ System.out.println(JSON.toJSONString(taExamCourseRecordList));
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("赋分异常,考生记录分析表数据异常");
|
|
|
+ }
|
|
|
+ TAExamCourseRecord taExamCourseRecord = taExamCourseRecordList.get(0);
|
|
|
+ taExamCourseRecord.setAssignedScore(BigDecimal.valueOf(Double.parseDouble(assAssignScore)));
|
|
|
+ willUpdate.add(taExamCourseRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taExamCourseRecordService.saveOrUpdateBatch(willUpdate);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "常规配置信息导入:试卷难易度和学院排名百分等级档位")
|
|
|
+ @RequestMapping(value = "/config/import", method = RequestMethod.POST)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result configImport(@RequestParam Long schoolId, @RequestParam Long examId, @RequestParam String courseCode) {
|
|
|
+ String courseName = basicCourseService.findByCourseCode(courseCode).getName();
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号[" + courseCode + "]的课程分析数据已测试或发布,不能变更基础数据");
|
|
|
+ }
|
|
|
+ tbCommonLevelConfigService.importLevelConfig(examId,courseCode,courseName);
|
|
|
+ tbCommonRankLevelConfigService.importRankLevelConfig(examId,courseCode,courseName);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新或新增专业信息
|
|
|
+ * @param tbSchoolMajorDtoList 基础专业数据源
|
|
|
+ */
|
|
|
+ private void saveMajorInfo(List<TBSchoolMajorDto> tbSchoolMajorDtoList){
|
|
|
+ List<TBSchoolMajor> tbSchoolMajorList = new ArrayList<>();
|
|
|
+ for (TBSchoolMajorDto tbSchoolMajorDto : tbSchoolMajorDtoList) {
|
|
|
+ TBSchoolMajor old = tbSchoolMajorService.getOne(new QueryWrapper<TBSchoolMajor>().lambda()
|
|
|
+ .eq(TBSchoolMajor::getSchoolId,tbSchoolMajorDto.getSchoolId())
|
|
|
+ .eq(TBSchoolMajor::getMajorCode,tbSchoolMajorDto.getMajorCode())
|
|
|
+ .eq(TBSchoolMajor::getMajorName,tbSchoolMajorDto.getMajorName()));
|
|
|
+ Long id;
|
|
|
+ if (Objects.nonNull(old)){
|
|
|
+ id = old.getId();
|
|
|
+ }else {
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
+ }
|
|
|
+
|
|
|
+ TBSchoolMajor tbSchoolMajor = new TBSchoolMajor();
|
|
|
+ tbSchoolMajor.setId(id);
|
|
|
+ tbSchoolMajor.setSchoolId(tbSchoolMajorDto.getSchoolId());
|
|
|
+ tbSchoolMajor.setMajorCode(tbSchoolMajorDto.getMajorCode());
|
|
|
+ tbSchoolMajor.setMajorName(tbSchoolMajorDto.getMajorName());
|
|
|
+ tbSchoolMajor.setEnable(true);
|
|
|
+ tbSchoolMajor.setCreateTime(System.currentTimeMillis());
|
|
|
+ tbSchoolMajor.setUpdateTime(System.currentTimeMillis());
|
|
|
+ tbSchoolMajorList.add(tbSchoolMajor);
|
|
|
+ }
|
|
|
+ tbSchoolMajorService.saveOrUpdateBatch(tbSchoolMajorList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新或新增班级信息
|
|
|
+ * @param tbSchoolClazzDtoList 基础班级数据源
|
|
|
+ */
|
|
|
+ private void saveClazzInfo(List<TBSchoolClazzDto> tbSchoolClazzDtoList){
|
|
|
+ List<TBSchoolClazz> tbSchoolClazzList = new ArrayList<>();
|
|
|
+ for (TBSchoolClazzDto tbSchoolClazzDto : tbSchoolClazzDtoList) {
|
|
|
+ TBSchoolClazz old = tbSchoolClazzService.getOne(new QueryWrapper<TBSchoolClazz>().lambda()
|
|
|
+ .eq(TBSchoolClazz::getSchoolId,tbSchoolClazzDto.getSchoolId())
|
|
|
+ .eq(TBSchoolClazz::getClazzCode,tbSchoolClazzDto.getClazzCode())
|
|
|
+ .eq(TBSchoolClazz::getClazzName,tbSchoolClazzDto.getClazzName()));
|
|
|
+ Long id;
|
|
|
+ if (Objects.nonNull(old)){
|
|
|
+ id = old.getId();
|
|
|
+ }else {
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
+ }
|
|
|
+
|
|
|
+ TBSchoolClazz tbSchoolClazz = new TBSchoolClazz();
|
|
|
+ tbSchoolClazz.setId(id);
|
|
|
+ tbSchoolClazz.setSchoolId(tbSchoolClazzDto.getSchoolId());
|
|
|
+ tbSchoolClazz.setClazzCode(tbSchoolClazzDto.getClazzCode());
|
|
|
+ tbSchoolClazz.setClazzName(tbSchoolClazzDto.getClazzName());
|
|
|
+ tbSchoolClazz.setEnable(true);
|
|
|
+ tbSchoolClazz.setCreateTime(System.currentTimeMillis());
|
|
|
+ tbSchoolClazz.setUpdateTime(System.currentTimeMillis());
|
|
|
+ tbSchoolClazzList.add(tbSchoolClazz);
|
|
|
+ }
|
|
|
+ tbSchoolClazzService.saveOrUpdateBatch(tbSchoolClazzList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新或新增学院信息
|
|
|
+ * @param tbSchoolCollegeDtoList 基础学院数据源
|
|
|
+ */
|
|
|
+ private void saveCollegeInfo(List<TBSchoolCollegeDto> tbSchoolCollegeDtoList){
|
|
|
+ List<SysOrg> sysOrgList = new ArrayList<>();
|
|
|
+ for (TBSchoolCollegeDto tbSchoolCollegeDto : tbSchoolCollegeDtoList) {
|
|
|
+ SysOrg old = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
|
|
|
+ .eq(SysOrg::getSchoolId,tbSchoolCollegeDto.getSchoolId())
|
|
|
+ .eq(SysOrg::getCode,tbSchoolCollegeDto.getCollegeCode())
|
|
|
+ .eq(SysOrg::getName,tbSchoolCollegeDto.getCollegeName()));
|
|
|
+ Long id;
|
|
|
+ if (Objects.nonNull(old)){
|
|
|
+ id = old.getId();
|
|
|
+ }else {
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOrg sysOrg = new SysOrg();
|
|
|
+ sysOrg.setId(id);
|
|
|
+ sysOrg.setSchoolId(tbSchoolCollegeDto.getSchoolId());
|
|
|
+ sysOrg.setCode(tbSchoolCollegeDto.getCollegeCode());
|
|
|
+ sysOrg.setName(tbSchoolCollegeDto.getCollegeName());
|
|
|
+ sysOrg.setEnable(true);
|
|
|
+ sysOrgList.add(sysOrg);
|
|
|
+ }
|
|
|
+ sysOrgService.saveOrUpdateBatch(sysOrgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新或新增教师信息
|
|
|
+ * @param tbSchoolTeacherDtoList 基础教师数据源
|
|
|
+ */
|
|
|
+ private void saveTeacherInfo(List<TBSchoolTeacherDto> tbSchoolTeacherDtoList){
|
|
|
+ List<SysUser> tbSchoolTeacherList = new ArrayList<>();
|
|
|
+ for (TBSchoolTeacherDto tbSchoolTeacherDto : tbSchoolTeacherDtoList) {
|
|
|
+ SysUser old = sysUserService.getOne(new QueryWrapper<SysUser>().lambda()
|
|
|
+ .eq(SysUser::getSchoolId,tbSchoolTeacherDto.getSchoolId())
|
|
|
+ .eq(SysUser::getLoginName,tbSchoolTeacherDto.getTeacherCode())
|
|
|
+ .eq(SysUser::getRealName,tbSchoolTeacherDto.getTeacherName()));
|
|
|
+ Long id = 0L;
|
|
|
+ if (Objects.nonNull(old)){
|
|
|
+ id = old.getId();
|
|
|
+ }
|
|
|
+ SysRole teacherRole = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.TEACHER)).get(0);
|
|
|
+ List<Long> roleIds = new ArrayList<>();
|
|
|
+ roleIds.add(teacherRole.getId());
|
|
|
+
|
|
|
+ UserSaveParams userSaveParams = new UserSaveParams();
|
|
|
+ if (id > 0){
|
|
|
+ userSaveParams.setId(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ userSaveParams.setSchoolId(tbSchoolTeacherDto.getSchoolId());
|
|
|
+ userSaveParams.setLoginName(tbSchoolTeacherDto.getTeacherCode());
|
|
|
+ userSaveParams.setRealName(tbSchoolTeacherDto.getTeacherName());
|
|
|
+ userSaveParams.setPassword(SystemConstant.DEFAULT_PASSWORD);
|
|
|
+ userSaveParams.setMobileNumber("11111111111");
|
|
|
+ userSaveParams.setEnable(true);
|
|
|
+ userSaveParams.setRoleIds(roleIds.toArray(new Long[0]));
|
|
|
+ sysUserService.save(userSaveParams);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|